@opencorestack/opengridx 0.1.9 → 1.0.0

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/index.d.ts +60 -41
  3. package/dist/opengridx.es.js +5045 -4549
  4. package/dist/opengridx.es.js.map +1 -1
  5. package/dist/opengridx.umd.js +11 -11
  6. package/dist/opengridx.umd.js.map +1 -1
  7. package/docs/README.md +14 -0
  8. package/docs/components/aggregation-footer.md +48 -0
  9. package/docs/components/datagrid.md +3 -0
  10. package/docs/components/empty-state.md +50 -0
  11. package/docs/components/error-overlay.md +40 -0
  12. package/docs/roadmap.md +20 -1
  13. package/lib/components/Cell/Cell.tsx +9 -10
  14. package/lib/components/Cell/GridEditInputCell.tsx +4 -4
  15. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +3 -2
  16. package/lib/components/DataGrid/DataGrid.regression.test.tsx +132 -0
  17. package/lib/components/DataGrid/DataGrid.tsx +336 -1018
  18. package/lib/components/DataGrid/GridAggregationFooter.tsx +68 -0
  19. package/lib/components/DataGrid/GridEmptyState.tsx +16 -0
  20. package/lib/components/DataGrid/GridErrorOverlay.tsx +33 -0
  21. package/lib/components/DataGrid/GridListView.tsx +116 -0
  22. package/lib/components/DataGrid/GridPinnedRows.tsx +98 -0
  23. package/lib/components/DataGrid/GridStandaloneColumnPanel.tsx +124 -0
  24. package/lib/components/DataGrid/GridVirtualRows.tsx +202 -0
  25. package/lib/components/FilterPanel/FilterPanel.tsx +18 -10
  26. package/lib/components/Header/ColumnMenu.tsx +2 -2
  27. package/lib/components/Header/Header.tsx +4 -4
  28. package/lib/components/ListView/ListViewRow.tsx +2 -2
  29. package/lib/components/Row/Row.tsx +10 -10
  30. package/lib/components/SkeletonRow/SkeletonRow.tsx +9 -2
  31. package/lib/components/Toolbar/GridToolbar.tsx +6 -0
  32. package/lib/hooks/core/useDataGrid.regression.test.ts +66 -0
  33. package/lib/hooks/core/useDataGrid.ts +14 -34
  34. package/lib/hooks/core/useGridColumns.tsx +228 -0
  35. package/lib/hooks/core/useGridControlledState.ts +192 -0
  36. package/lib/hooks/core/useGridRowPipeline.ts +109 -0
  37. package/lib/hooks/core/useGridScrollSync.ts +52 -0
  38. package/lib/hooks/core/useGridStateSnapshot.ts +63 -0
  39. package/lib/hooks/core/useGridVirtualization.ts +186 -0
  40. package/lib/hooks/core/useGridVisibleRows.ts +66 -0
  41. package/lib/hooks/core/useLayout.ts +0 -6
  42. package/lib/hooks/features/useAggregation.ts +7 -7
  43. package/lib/hooks/features/useGridDataSource.ts +1 -1
  44. package/lib/hooks/features/useGridEditing.ts +31 -32
  45. package/lib/hooks/features/usePivot.test.ts +202 -0
  46. package/lib/hooks/features/usePivot.ts +0 -0
  47. package/lib/hooks/useColumnReorder.ts +1 -1
  48. package/lib/hooks/useRowGrouping.ts +14 -14
  49. package/lib/hooks/useTreeData.ts +1 -1
  50. package/lib/state/types.ts +1 -1
  51. package/lib/state/useGridStateStorage.ts +1 -1
  52. package/lib/types/index.ts +48 -32
  53. package/lib/utils/export/exportToExcelAdvanced.ts +14 -14
  54. package/lib/utils/export/index.ts +22 -17
  55. package/lib/utils/filtering/index.ts +20 -20
  56. package/lib/utils/sorting/index.ts +1 -1
  57. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
- (function(ie,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],i):(ie=typeof globalThis<"u"?globalThis:ie||self,i(ie.OpenGridX={},ie.React,ie.ReactDOM))})(this,(function(ie,i,nt){"use strict";var Ot={exports:{}},Ct={};var En;function xo(){if(En)return Ct;En=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function e(r,l,a){var d=null;if(a!==void 0&&(d=""+a),l.key!==void 0&&(d=""+l.key),"key"in l){a={};for(var s in l)s!=="key"&&(a[s]=l[s])}else a=l;return l=a.ref,{$$typeof:t,type:r,key:d,ref:l!==void 0?l:null,props:a}}return Ct.Fragment=o,Ct.jsx=e,Ct.jsxs=e,Ct}var yt={};var Nn;function mo(){return Nn||(Nn=1,process.env.NODE_ENV!=="production"&&(function(){function t(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===C?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case j:return"Fragment";case k:return"Profiler";case P:return"StrictMode";case v:return"Suspense";case N:return"SuspenseList";case M:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case h:return"Portal";case y:return _.displayName||"Context";case E:return(_._context.displayName||"Context")+".Consumer";case g:var G=_.render;return _=_.displayName,_||(_=G.displayName||G.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case S:return G=_.displayName||null,G!==null?G:t(_.type)||"Memo";case I:G=_._payload,_=_._init;try{return t(_(G))}catch{}}return null}function o(_){return""+_}function e(_){try{o(_);var G=!1}catch{G=!0}if(G){G=console;var B=G.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return B.call(G,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),o(_)}}function r(_){if(_===j)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===I)return"<...>";try{var G=t(_);return G?"<"+G+">":"<...>"}catch{return"<...>"}}function l(){var _=W.A;return _===null?null:_.getOwner()}function a(){return Error("react-stack-top-frame")}function d(_){if(Y.call(_,"key")){var G=Object.getOwnPropertyDescriptor(_,"key").get;if(G&&G.isReactWarning)return!1}return _.key!==void 0}function s(_,G){function B(){K||(K=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",G))}B.isReactWarning=!0,Object.defineProperty(_,"key",{get:B,configurable:!0})}function f(){var _=t(this.type);return O[_]||(O[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function c(_,G,B,z,L,X){var H=B.ref;return _={$$typeof:w,type:_,key:G,props:B,_owner:z},(H!==void 0?H:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:f}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function p(_,G,B,z,L,X){var H=G.children;if(H!==void 0)if(z)if(F(H)){for(z=0;z<H.length;z++)m(H[z]);Object.freeze&&Object.freeze(H)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(H);if(Y.call(G,"key")){H=t(_);var R=Object.keys(G).filter(function(Z){return Z!=="key"});z=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",ee[H+z]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(oe,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(oe=typeof globalThis<"u"?globalThis:oe||self,l(oe.OpenGridX={},oe.React,oe.ReactDOM))})(this,(function(oe,l,We){"use strict";var ht={exports:{}},rt={};var dn;function Un(){if(dn)return rt;dn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,i,s){var d=null;if(s!==void 0&&(d=""+s),i.key!==void 0&&(d=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:n,type:o,key:d,ref:i!==void 0?i:null,props:s}}return rt.Fragment=t,rt.jsx=e,rt.jsxs=e,rt}var it={};var cn;function Kn(){return cn||(cn=1,process.env.NODE_ENV!=="production"&&(function(){function n(k){if(k==null)return null;if(typeof k=="function")return k.$$typeof===C?null:k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case j:return"Fragment";case h:return"Profiler";case I:return"StrictMode";case f:return"Suspense";case x:return"SuspenseList";case N:return"Activity"}if(typeof k=="object")switch(typeof k.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),k.$$typeof){case _:return"Portal";case y:return k.displayName||"Context";case S:return(k._context.displayName||"Context")+".Consumer";case w:var B=k.render;return k=k.displayName,k||(k=B.displayName||B.name||"",k=k!==""?"ForwardRef("+k+")":"ForwardRef"),k;case E:return B=k.displayName||null,B!==null?B:n(k.type)||"Memo";case M:B=k._payload,k=k._init;try{return n(k(B))}catch{}}return null}function t(k){return""+k}function e(k){try{t(k);var B=!1}catch{B=!0}if(B){B=console;var W=B.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&k[Symbol.toStringTag]||k.constructor.name||"Object";return W.call(B,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),t(k)}}function o(k){if(k===j)return"<>";if(typeof k=="object"&&k!==null&&k.$$typeof===M)return"<...>";try{var B=n(k);return B?"<"+B+">":"<...>"}catch{return"<...>"}}function i(){var k=P.A;return k===null?null:k.getOwner()}function s(){return Error("react-stack-top-frame")}function d(k){if(O.call(k,"key")){var B=Object.getOwnPropertyDescriptor(k,"key").get;if(B&&B.isReactWarning)return!1}return k.key!==void 0}function a(k,B){function W(){H||(H=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",B))}W.isReactWarning=!0,Object.defineProperty(k,"key",{get:W,configurable:!0})}function u(){var k=n(this.type);return R[k]||(R[k]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),k=this.props.ref,k!==void 0?k:null}function c(k,B,W,F,V,G){var D=W.ref;return k={$$typeof:v,type:k,key:B,props:W,_owner:F},(D!==void 0?D:null)!==null?Object.defineProperty(k,"ref",{enumerable:!1,get:u}):Object.defineProperty(k,"ref",{enumerable:!1,value:null}),k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(k,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(k,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.defineProperty(k,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k}function g(k,B,W,F,V,G){var D=B.children;if(D!==void 0)if(F)if(T(D)){for(F=0;F<D.length;F++)m(D[F]);Object.freeze&&Object.freeze(D)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(D);if(O.call(B,"key")){D=n(k);var L=Object.keys(B).filter(function(Q){return Q!=="key"});F=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",K[D+F]||(L=0<L.length?"{"+L.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,z,H,R,H),ee[H+z]=!0)}if(H=null,B!==void 0&&(e(B),H=""+B),d(G)&&(e(G.key),H=""+G.key),"key"in G){B={};for(var re in G)re!=="key"&&(B[re]=G[re])}else B=G;return H&&s(B,typeof _=="function"?_.displayName||_.name||"Unknown":_),c(_,H,B,l(),L,X)}function m(_){b(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===I&&(_._payload.status==="fulfilled"?b(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function b(_){return typeof _=="object"&&_!==null&&_.$$typeof===w}var x=i,w=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),y=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),W=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,F=Array.isArray,D=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(_){return _()}};var K,O={},V=x.react_stack_bottom_frame.bind(x,a)(),J=D(r(a)),ee={};yt.Fragment=j,yt.jsx=function(_,G,B){var z=1e4>W.recentlyCreatedOwnerStacks++;return p(_,G,B,!1,z?Error("react-stack-top-frame"):V,z?D(r(_)):J)},yt.jsxs=function(_,G,B){var z=1e4>W.recentlyCreatedOwnerStacks++;return p(_,G,B,!0,z?Error("react-stack-top-frame"):V,z?D(r(_)):J)}})()),yt}var In;function bo(){return In||(In=1,process.env.NODE_ENV==="production"?Ot.exports=xo():Ot.exports=mo()),Ot.exports}var n=bo();function Ft(t,o){return o?o.left?.includes(t)?"left":o.right?.includes(t)?"right":null:null}function wo(t,o){const e=[],r=[],l=[];return o?(t.forEach(a=>{const d=Ft(a.field,o);d==="left"?e.push(a):d==="right"?l.push(a):r.push(a)}),o.left&&e.sort((a,d)=>{const s=o.left.indexOf(a.field),f=o.left.indexOf(d.field);return s-f}),o.right&&l.sort((a,d)=>{const s=o.right.indexOf(a.field),f=o.right.indexOf(d.field);return s-f}),{left:e,center:r,right:l}):{left:e,center:t,right:l}}function Pn(t,o,e,r,l,a,d,s){const f={};if(!e)return f;const c=wo(t,e);let p=0;s&&(p+=48),a&&d&&(p+=48),r&&l&&(p+=48),c.left.forEach(b=>{f[b.field]=p;const x=o[b.field]??b.width??100;p+=x});let m=0;return[...c.right].reverse().forEach(b=>{const x=o[b.field]??b.width??100;f[b.field]=m,m+=x}),f}function tn(t,o){return o?o.top?.includes(t)?"top":o.bottom?.includes(t)?"bottom":null:null}function vo(t,o){const e=[],r=[],l=[];return o?(t.forEach(a=>{const d=tn(a.id,o);d==="top"?e.push(a):d==="bottom"?l.push(a):r.push(a)}),o.top&&e.sort((a,d)=>{const s=o.top.indexOf(a.id),f=o.top.indexOf(d.id);return s-f}),o.bottom&&l.sort((a,d)=>{const s=o.bottom.indexOf(a.id),f=o.bottom.indexOf(d.id);return s-f}),{top:e,center:r,bottom:l}):{top:e,center:t,bottom:l}}function it(t){if(t===void 0)return{type:"auto",value:0};if(typeof t=="number")return{type:"fixed",value:t};if(typeof t=="string"){if(t.toLowerCase()==="auto")return{type:"auto",value:0};if(t.endsWith("%"))return{type:"percentage",value:parseFloat(t)};const o=parseFloat(t);if(!isNaN(o))return{type:"fixed",value:o}}return{type:"fixed",value:100}}function _o(t){const{rowHeight:o,pagination:e,paginatedUnpinnedRows:r,sortedUnpinnedRows:l,expandedRowIds:a,getDetailPanelHeight:d,pinnedTopRowsLength:s,pinnedBottomRowsLength:f,visibleOrderedColumns:c,pinnedColumns:p,columnWidths:m,viewportWidth:b,checkboxSelection:x,hasDetailPanel:w,rowReordering:h,pinCheckboxColumn:j,pinExpandColumn:P,autoHeight:k,paginationMode:E,isLoading:y,pageSize:g}=t;return i.useMemo(()=>{const v=e?r:l,N=v.map(($,q)=>{let te=o;if(a.has($.id)){const he=d?.({row:$,id:$.id,rowIndex:s+q})??200;te+=typeof he=="number"?he:parseInt(String(he),10)||200}return te}),S=N.reduce(($,q,te)=>($.push(($[te-1]||0)+q),$),[]),I=E==="infinite"&&y&&v.length>0?Math.min(g,20):0,M=(S[S.length-1]||0)+I*o,C=s*o,W=f*o,Y=[],F=[],D=[],K=[];c.forEach($=>{const q=Ft($.field,p);q==="left"?Y.push($):q==="right"?F.push($):D.push($)});const O=(x?48:0)+(w?48:0)+(h?48:0),V=$=>m[$.field]??$.width,J=Y.reduce(($,q)=>{const te=it(V(q));return $+(te.type==="fixed"?te.value:100)},0),ee=F.reduce(($,q)=>{const te=it(V(q));return $+(te.type==="fixed"?te.value:100)},0),_=D.reduce(($,q)=>{if(!Object.prototype.hasOwnProperty.call(m,q.field)&&q.flex&&q.flex>0){const de=q.minWidth??150,ct=typeof q.width=="number"?q.width:150;return $+(de||ct)}const he=it(V(q));return he.type==="fixed"?$+he.value:he.type==="percentage"?$+100:$+(q.minWidth??150)},0),G=Math.max(b-O-J-ee,_),B=[],z=[],L=[];D.forEach($=>{const q=Object.prototype.hasOwnProperty.call(m,$.field),te=it(V($));if(!q&&$.flex&&$.flex>0){L.push({col:$,flex:$.flex});return}te.type==="fixed"?B.push({col:$,width:te.value}):te.type==="percentage"?z.push({col:$,percentage:te.value}):L.push({col:$,flex:1})});const X=B.reduce(($,{width:q})=>$+q,0);let H=Math.max(0,G-X);const R=new Map;z.forEach(({col:$,percentage:q})=>{const te=q/100*H;R.set($.field,te),H-=te}),H=Math.max(0,H);const re=new Map,Z=L.map($=>({...$,minWidth:$.col.minWidth??50,maxWidth:$.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let $=0;const q=Z.length*2;for(;$<q;){$++;const te=Z.filter(oe=>!oe.frozen);if(te.length===0)break;const he=te.reduce((oe,Ee)=>oe+Ee.flex,0),de=Z.reduce((oe,Ee)=>Ee.frozen?oe+Ee.computedWidth:oe,0),ct=Math.max(0,H-de);if(he<=0){te.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0});break}const At=ct/he;let Ve=0;const ot=[],Re=[];if(te.forEach(oe=>{const Ee=At*oe.flex;Ee<oe.minWidth?(Ve+=oe.minWidth-Ee,ot.push(oe)):Ee>oe.maxWidth?(Ve+=oe.maxWidth-Ee,Re.push(oe)):oe.computedWidth=Ee}),ot.length===0&&Re.length===0){te.forEach(oe=>oe.frozen=!0);break}Ve>0?ot.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}):Ve<0?Re.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}):(ot.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}),Re.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}))}})(),Z.forEach($=>re.set($.col.field,$.computedWidth));const me=new Map;D.forEach($=>{let q;if(re.has($.field))q=re.get($.field);else{const te=B.find(de=>de.col.field===$.field),he=z.find(de=>de.col.field===$.field);if(te)q=te.width;else if(he){const de=R.get($.field)||0;q=Math.max($.minWidth??50,de||100)}else q=100}K.push(q),me.set($.field,q)});const U=D.map($=>{const q=Z.find(te=>te.col.field===$.field);return{...$,width:me.get($.field)??(typeof $.width=="number"?$.width:100),flex:q?q.flex:$.flex}}),pe=11,fe=Y.map(($,q)=>{const te=it(V($));return{...$,width:te.type==="fixed"?te.value:100,zIndex:pe+q}}),je=11,ge=F.map(($,q)=>{const te=it(V($));return{...$,width:te.type==="fixed"?te.value:100,zIndex:je+(F.length-1-q)}}),be=K.reduce(($,q)=>$+q,0),Ce=J+be+ee+O,Ge=K.reduce(($,q,te)=>($.push(($[te-1]||0)+q),$),[]);return{rowHeights:N,cumulativeHeights:S,unpinnedRowsHeight:M,pinnedTopHeight:C,pinnedBottomHeight:W,leftPinnedCols:fe,rightPinnedCols:ge,unpinnedColsWithWidth:U,unpinnedColWidths:K,unpinnedAccWidths:Ge,totalWidth:Ce,leftWidth:J,rightWidth:ee,unpinnedTotalWidth:be,systemColumnsWidth:O,pinnedTopRowsLength:s,pinnedBottomRowsLength:f,unpinnedRowsLength:v.length}},[o,e,r,l,a,d,s,f,c,p,m,b,x,w,h,j,P,k,E,y,g])}function Co(t){const{allRenderableRows:o,navigationColumns:e,checkboxSelection:r,selectedRowIds:l,handleSelectionChange:a,handleDetailPanelToggle:d,editingHandlers:s,setKeyboardMode:f,sortModel:c,handleSort:p,isCellEditable:m,pagination:b,pageSize:x,virtualization:w,viewportRef:h}=t,[j,P]=i.useState(null),k=i.useCallback(g=>{g.target===g.currentTarget&&P(v=>{if(v)return v;if(r)return{id:"HEADER",field:"__checkbox_col__"};const N=o[0],S=e[0];return N&&S?{id:N.id,field:S.field}:null})},[o,e,r]),E=i.useCallback(g=>{g.currentTarget.contains(g.relatedTarget)||P(null)},[]),y=i.useCallback(g=>{if(f(!0),!j)return;const{id:v,field:N}=j,S=!!s.editingCell;if(v==="HEADER"&&(g.key==="Enter"||g.key===" ")){g.preventDefault();const O=e.find(V=>V.field===N);if(O&&O.sortable!==!1){const V=c.find(ee=>ee.field===N);let J="asc";V&&(J=V.sort==="asc"?"desc":null),p(N,J)}return}if(g.key==="Enter"){if(g.preventDefault(),S)s.stopCellEdit();else if(e.find(V=>V.field===N)?.editable){const V=o.find(J=>J.id===v);V&&s.startCellEdit({id:v,field:N,value:V[N]})}return}if((g.key===" "||g.key==="Spacebar")&&!S){if(N==="__checkbox_col__"){g.preventDefault(),a(v,!l.has(v));return}if(N==="__expand_col__"){g.preventDefault(),d(v);return}}if(g.key==="Escape"){S&&(g.preventDefault(),s.stopCellEdit({cancel:!0}));return}if(S&&g.key!=="Tab")return;const I=v==="HEADER",M=I?-1:o.findIndex(O=>O.id===v),C=e.findIndex(O=>O.field===N);if(!I&&M===-1||C===-1)return;const W=(O,V,J,ee,_,G=!1)=>{let B=O+J,z=V+ee;return _&&ee!==0&&(ee>0&&z>=e.length?(z=0,B++):ee<0&&z<0&&(z=e.length-1,B--)),!_&&(z<0||z>=e.length)||B<(G?-1:0)||B>=o.length?null:{r:B,c:z}},Y=(O,V,J,ee,_,G=!1)=>{let B=O,z=V,L=0;const X=o.length*e.length+e.length;for(;L<X;){if(L++,B+=J,z+=ee,ee!==0)ee>0?z>=e.length&&(z=0,B++):z<0&&(z=e.length-1,B--);else if(z<0||z>=e.length)return null;if(B<-1||B>=o.length)return null;if(B===-1){if(!G)continue;const se=e[z],me=se.sortable!==!1;if(["__checkbox_col__"].includes(se.field)||me)return{r:B,c:z};continue}const H=o[B],R=e[z],re=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(R.field);let Z=R.editable||re;if(m&&!re)try{Z=m({row:H,field:R.field,value:H[R.field],colDef:R,rowIndex:B,colIndex:z})}catch{}if(Z)return{r:B,c:z}}return null};let F=M,D=C,K=!1;if(g.key==="Tab"){const O=g.shiftKey?-1:1,V=Y(M,C,0,O,!0,!1);V&&(F=V.r,D=V.c,K=!0)}else if(g.key==="ArrowRight"){const O=W(M,C,0,1,!0,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowLeft"){const O=W(M,C,0,-1,!0,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowDown"){const O=W(M,C,1,0,!1,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowUp"){const O=W(M,C,-1,0,!1,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="Home")D=0,(g.ctrlKey||g.metaKey)&&(F=-1),K=!0;else if(g.key==="End")D=e.length-1,(g.ctrlKey||g.metaKey)&&(F=o.length-1),K=!0;else if(g.key==="PageUp")F=Math.max(-1,F-(b?x:10)),K=!0;else if(g.key==="PageDown"){const O=b?x:10;F=Math.min(o.length-1,F+O),K=!0}if(K&&(g.preventDefault(),S&&g.key==="Tab"&&s.stopCellEdit(),F>=-1&&F<o.length&&D>=0&&D<e.length)){const O=e[D];P(F===-1?{id:"HEADER",field:O.field}:{id:o[F].id,field:O.field});const V=h.current;if(V){const{cumulativeHeights:J,pinnedTopHeight:ee,columnMetrics:_}=w,{clientHeight:G,clientWidth:B,scrollTop:z,scrollLeft:L}=V,X=F<=0?0:J[F-1],H=J[F],R=z+ee,re=z+G;let Z=z;if(X<R?Z=Math.max(0,X-ee):H>re&&(Z=H-G),Z!==z&&(V.scrollTop=Z),_){const{leftPinnedWidth:se,rightPinnedWidth:me,unpinnedAccWidths:U,unpinnedCols:pe,totalSpecialsWidth:fe,pinnedSpecialsWidth:je}=_,ge=pe.findIndex(be=>be.field===O.field);if(ge!==-1){const be=fe+se+(ge>0?U[ge-1]:0),Ce=fe+se+U[ge],Ge=L+je+se,$=L+B-me;let q=L;be<Ge?q=Math.max(0,be-je-se):Ce>$&&(q=Ce-B+me),q!==L&&(V.scrollLeft=q)}}}}},[j,o,e,s,w,l,a,d,f,c,p,m,b,x,h]);return{focusedCell:j,setFocusedCell:P,handleFocus:k,handleBlur:E,handleKeyDown:y}}function yo({row:t,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:l=!1,rowHeight:a,onRowClick:d,onSelectionChange:s}){const f={row:t,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},c=p=>{p.stopPropagation(),s?.(t.id,p.target.checked)};return n.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:a?{minHeight:a}:void 0,onClick:()=>d?.(t),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[l&&n.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:n.jsx("input",{type:"checkbox",checked:r,onChange:c,"aria-label":`Select row ${t.id}`})}),n.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(f)})]})}const kt=({indeterminate:t=!1,label:o,className:e="",inputRef:r,...l})=>{const a=i.useRef(null),d=i.useCallback(f=>{a.current=f,typeof r=="function"?r(f):r&&(r.current=f)},[r]);i.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]);const s=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return n.jsxs("label",{className:s,children:[n.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||l["aria-label"]||(t?"Select some":l.checked?"Deselect":"Select"),...l}),n.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!t&&n.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),t&&n.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),o&&n.jsx("span",{className:"ogx-checkbox__label",children:o})]})};function ko(t){const{field:o,currentWidth:e,onResize:r,minWidth:l=50,maxWidth:a=1e3}=t,[d,s]=i.useState(!1),f=i.useRef(0),c=i.useRef(0),p=i.useCallback(x=>{x.preventDefault(),x.stopPropagation(),s(!0),f.current=x.clientX,c.current=e;let w=0;const h=16,j=k=>{const E=k.clientX-f.current,y=Math.max(l,Math.min(a,c.current+E)),g=Date.now();g-w>=h&&(r(o,y),w=g)},P=k=>{s(!1);const E=k.clientX-f.current,y=Math.max(l,Math.min(a,c.current+E));r(o,y),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",P)},[o,e,r,l,a]),m=i.useCallback(x=>{x.preventDefault(),x.stopPropagation()},[]),b=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return n.jsx("div",{className:b,onMouseDown:p,onClick:x=>x.stopPropagation(),onDragStart:x=>{x.preventDefault(),x.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} column`,children:n.jsx("div",{className:"ogx-column-resize-handle__line"})})}function lt(){return n.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:n.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function st(){return n.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function So(){return n.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function jo(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),n.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Eo(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function No(){return n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Io(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),n.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),n.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Po(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),n.jsx("polyline",{points:"11 8 4 12 11 16"}),n.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Mo(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),n.jsx("polyline",{points:"13 8 20 12 13 16"}),n.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function To(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),n.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),n.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Lo({colDef:t,sortModel:o,onSort:e,onHide:r,onPin:l,pinnedColumns:a,onManageColumns:d,onClose:s,anchorEl:f}){const c=i.useRef(null),[p,m]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!f||!c.current)return;const g=f.getBoundingClientRect(),v=c.current.getBoundingClientRect(),N=window.innerWidth,S=window.innerHeight,I=8;let M=g.left;M+v.width+I>N&&(M=N-v.width-I),M<I&&(M=I);let C=g.bottom+4;C+v.height+I>S&&(C=g.top-v.height-4),m({position:"fixed",zIndex:1300,top:C,left:M,visibility:"visible"})},[f]),i.useEffect(()=>{function g(N){c.current&&!c.current.contains(N.target)&&f&&!f.contains(N.target)&&s()}function v(N){N.key==="Escape"&&s()}return document.addEventListener("mousedown",g),document.addEventListener("keydown",v),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",v),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[f,s]);const b=g=>{e?.(t.field,g),s()},x=()=>{r?.(t.field),s()},w=g=>{l?.(t.field,g),s()},h=o?.find(g=>g.field===t.field)?.sort,j=h==null,P=a?.left?.includes(t.field)??!1,k=a?.right?.includes(t.field)??!1,E=!P&&!k,y=t.headerName||t.field;return nt.createPortal(n.jsxs("div",{ref:c,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${y}`,children:[e&&t.sortable!==!1&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{className:`ogx-menu-item${h==="asc"?" ogx-menu-item--active":""}`,onClick:()=>b("asc"),role:"menuitemradio","aria-checked":h==="asc",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="asc"?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(jo,{})}),"Sort Ascending"]}),n.jsxs("button",{className:`ogx-menu-item${h==="desc"?" ogx-menu-item--active":""}`,onClick:()=>b("desc"),role:"menuitemradio","aria-checked":h==="desc",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="desc"?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Eo,{})}),"Sort Descending"]}),n.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>b(null),role:"menuitemradio","aria-checked":j,children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(No,{})}),"Unsort"]}),n.jsx("div",{className:"ogx-menu-divider"})]}),n.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),n.jsxs("button",{className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>w("left"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to left",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Po,{})}),"Pin to Left"]}),n.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>w("right"),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to right",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Mo,{})}),"Pin to Right"]}),n.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":E,"aria-label":"Unpin column",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(To,{})}),"Unpin"]}),n.jsx("div",{className:"ogx-menu-divider"}),n.jsxs("button",{className:"ogx-menu-item",onClick:x,role:"menuitem","aria-label":`Hide ${y} column`,children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Io,{})}),"Hide Column"]}),n.jsx("div",{className:"ogx-menu-divider"}),n.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),s()},role:"menuitem","aria-label":"Manage all columns",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(So,{})}),"Manage columns"]})]}),f?.closest(".ogx-theme-provider")||document.body)}function Ro(){return n.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:n.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Wo(){return n.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:n.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Mn(t){const o=[];for(const e of t.children)typeof e=="string"?o.push(e):o.push(...Mn(e));return o}function Oo(t){let o=0;function e(r,l){o=Math.max(o,l);for(const a of r.children)typeof a!="string"&&e(a,l+1)}return t.forEach(r=>e(r,1)),o}function Fo(t,o,e){function r(s,f,c){if(!Mn(s).includes(f))return null;if(c===e)return s;for(const p of s.children)if(typeof p!="string"){const m=r(p,f,c+1);if(m)return m}return null}const l=new Map;for(const s of o){let f=null;for(const c of t)if(f=r(c,s.field,0),f)break;l.set(s.field,f)}const a=[];let d=0;for(;d<o.length;){const s=o[d],f=l.get(s.field)??null,c=s.width;if(!f)a.push({key:`fg-${s.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let p=0,m=d;for(;m<o.length&&l.get(o[m].field)===f;)p+=o[m].width,m++;a.push({key:`${f.groupId}-${e}`,label:f.headerName,width:p,isGroup:!0}),d=m}}return a}function Tn(t){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:l=!1,allSelected:a=!1,someSelected:d=!1,onSelectAll:s,onSort:f,sortModel:c=[],onColumnResize:p,columnWidths:m={},pinnedColumns:b,hasDetailPanel:x=!1,pinCheckboxColumn:w=!0,pinExpandColumn:h=!0,rowReordering:j=!1,aggregationModel:P,draggedColumn:k,dragOverColumn:E,onDragStart:y,onDragOver:g,onDragEnd:v,onDrop:N,focusedCell:S,onHeaderClick:I,onHideColumn:M,onPinColumn:C,onManageColumns:W}=t,Y=i.useRef({}),[F,D]=i.useState(null),K=R=>re=>{re.stopPropagation(),D({colDef:R,anchorEl:re.currentTarget})},O=()=>{D(null)};i.useLayoutEffect(()=>{if(S?.id==="HEADER"){const R=Y.current[S.field];R&&R.focus()}},[S]);const V=R=>()=>{if(R.sortable===!1||!f)return;const re=c.find(se=>se.field===R.field);let Z="asc";re&&(re.sort==="asc"?Z="desc":Z=null),f(R.field,Z)},J=R=>{const re=c.find(Z=>Z.field===R);return re?n.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${re.sort}`,"aria-hidden":"true"}):null},ee=i.useMemo(()=>Pn(o,m,b,l,w,x,h,j),[o,m,b,l,w,x,h,j]),_=r?Oo(r):0,B=(e??o).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:m[R.field]??R.width??100})),H=(j?48:0)+(x?48:0)+(l?48:0);return n.jsxs("div",{className:"ogx__header-wrap",children:[_>0&&Array.from({length:_},(R,re)=>{const Z=Fo(r,B,re);return n.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[H>0&&n.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:H,minWidth:H,flexShrink:0},role:"columnheader"}),Z.map(se=>n.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${se.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:se.width,minWidth:se.width,flexShrink:0},title:se.isGroup?se.label:void 0,children:se.isGroup&&n.jsx("span",{className:"ogx-col-group-cell__label",children:se.label})},se.key))]},`ogx-grp-${re}`)}),n.jsxs("div",{className:"ogx__header",role:"row",children:[j&&n.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),x&&n.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,left:h?j?48:0:void 0,zIndex:h?5:void 0}}),l&&n.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${w?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:w?"sticky":void 0,left:w?(j?48:0)+(x&&h?48:0):void 0},children:n.jsx(kt,{id:"ogx-select-all",name:"ogx-select-all",checked:a,indeterminate:d,onChange:R=>s?.(R.target.checked),"aria-label":a?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{Y.current.__checkbox_col__=R}})}),o.map((R,re)=>{if(R.isSpacer)return n.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const Z=R.sortable!==!1,se=c.some(de=>de.field===R.field),me=R.resizable!==!1,U=Ft(R.field,b),pe=U!==null,fe=k===R.field,je=E===R.field,ge=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Z&&"ogx__header-cell--sortable",se&&"ogx__header-cell--sorted",pe&&"ogx__header-cell--pinned",pe&&`ogx__header-cell--pinned-${U}`,fe&&"ogx__header-cell--dragging",je&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),be=m[R.field]??R.width??100,Ce={width:be,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:pe?"sticky":"relative",zIndex:R.zIndex,opacity:fe?.5:1};if(pe&&U){const de=ee[R.field];U==="left"?Ce.left=de:Ce.right=de}const Ge=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:re}):R.headerName||R.field,$=de=>{if(de.target.closest(".ogx-column-resize-handle")){de.stopPropagation();return}I?.(R.field),Z&&V(R)()},q=y?y(R.field):void 0,te=g?g(R.field):void 0,he=N?N(R.field):void 0;return n.jsxs("div",{className:ge,style:Ce,onClick:$,role:"columnheader",draggable:!!y,onDragStart:q,onDragOver:te,onDragEnd:v,onDrop:he,"aria-sort":Z?se?c.find(de=>de.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":re+1+(l?1:0),"data-field":R.field,tabIndex:-1,ref:de=>{Y.current[R.field]=de},children:[n.jsxs("div",{className:"ogx__header-cell-content",children:[fe&&n.jsx("div",{className:"ogx__header-drag-icon",children:n.jsx(Wo,{})}),n.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[n.jsx("span",{className:"ogx__header-cell-title",children:Ge}),P&&P[R.field]&&n.jsx("span",{className:"ogx__header-cell-aggregation",children:P[R.field]})]}),Z&&J(R.field),!R.disableColumnMenu&&n.jsx("button",{className:"ogx__menu-icon-btn",onClick:K(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:n.jsx(Ro,{})})]}),me&&p&&n.jsx(ko,{field:R.field,currentWidth:be,onResize:p,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),F&&n.jsx(Lo,{colDef:F.colDef,sortModel:c,onSort:f,onHide:M,onPin:C,pinnedColumns:b,onManageColumns:W,onClose:O,anchorEl:F.anchorEl})]})]})}function Ao({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(String(t??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),n.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function zo({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(t??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),n.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:s=>{const f=s.target.value===""?"":Number(s.target.value);a(f),o(f===""?null:f)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function Bo({value:t,onValueChange:o,onCommit:e,onCancel:r}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const a=()=>{o(!t),setTimeout(e,0)};return n.jsx("div",{className:"ogx__edit-boolean",children:n.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!t,onChange:a,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),r())}})})}function $o({value:t,colDef:o,onValueChange:e,onCommit:r,onCancel:l}){const a=i.useRef(null);i.useEffect(()=>{a.current?.focus()},[]);const d=o.valueOptions??[];return n.jsx("select",{ref:a,className:"ogx__edit-select",value:t??"",onChange:s=>{e(s.target.value)},onBlur:r,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),r()),s.key==="Escape"&&(s.stopPropagation(),l())},children:d.map(s=>{const f=typeof s=="object"?s.value:s,c=typeof s=="object"?s.label:String(s);return n.jsx("option",{value:String(f),children:c},String(f))})})}function Do({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(t??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),n.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function Ho(t){const{colDef:o}=t;switch(o.type){case"number":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(zo,{...t})});case"boolean":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Bo,{...t})});case"singleSelect":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx($o,{...t})});case"date":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Do,{...t})});default:return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Ao,{...t})})}}function Go(t){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:l,row:a,colDef:d,rowIndex:s,colIndex:f,isSelected:c,onClick:p,width:m,pinnedPosition:b,pinnedOffset:x,isFocused:w,isFocusVisible:h,isEditable:j,isEditing:P,onEditStart:k,onEditStop:E,onValueChange:y,colSpanInfo:g,rowSpan:v,isHiddenByRowSpan:N}=t,S=i.useCallback(_=>{r?r(d.field,_):y?.(_)},[r,y,d.field]),I=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:a,field:d.field}):l==null?"":String(l),[l,a,d]),M=i.useMemo(()=>P&&(r||y)&&E?d.renderEditCell?d.renderEditCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f}):n.jsx(Ho,{value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f,onValueChange:S,onCommit:()=>E(),onCancel:()=>E(!0)}):d.renderCell?d.renderCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f}):I,[l,a,d,s,f,I,P,S,E,r,y]),C=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f})||"":d.cellClassName:"",[d,l,a,s,f]),W=i.useRef(null);if(i.useLayoutEffect(()=>{w&&W.current&&W.current.focus({preventScroll:!0})},[w]),g?.spannedByColSpan)return null;if(N)return n.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":f});const Y=_=>{o&&(_.stopPropagation(),o({row:a,field:d.field,value:l,colDef:d,rowIndex:s,colIndex:f})),p?.(_)},F=_=>{j&&(k||e)&&(_.stopPropagation(),e?e(d.field,l):k?.())},D=b!=null,K=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&h&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${b}`,P&&"ogx__cell--editing",v&&v>1&&"ogx__cell--spanned",C].filter(Boolean).join(" "),O=g?.cellProps?.colSpan||1,V=v||1,J=g?.cellProps?.width??m??d.width??100,ee={width:"var(--width)","--width":typeof J=="number"?`${J}px`:J,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:D?"sticky":void 0,zIndex:d.zIndex??(D?3:void 0),padding:P?0:void 0};return V>1&&(ee.height=`calc(var(--height) * ${V} - var(--border-width, 1px))`,ee.zIndex=10,D&&(ee.zIndex=40)),D&&x!==void 0&&(b==="left"?ee.left=x:ee.right=x),n.jsx("div",{ref:W,className:K,style:ee,onClick:Y,onDoubleClick:F,role:"gridcell","aria-colindex":f+1,"aria-readonly":!j||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":f,...O>1?{"aria-colspan":O}:{},...V>1?{"aria-rowspan":V}:{},children:n.jsx("div",{className:"ogx__cell-content",children:M})})}const Ln=i.memo(Go);function Rn({isExpanded:t,onClick:o,variant:e="chevron"}){return n.jsx("button",{className:`ogx-expand-icon ${t?"ogx-expand-icon--expanded":""}`,onClick:r=>{o&&o(r)},"aria-label":t?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:t?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:n.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Vo=({className:t="",...o})=>n.jsx("button",{type:"button",className:`ogx-drag-handle ${t}`,"aria-label":"Drag to reorder row",...o,children:n.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function Uo(t){const{content:o,height:e,isExpanded:r}=t;if(!r)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return n.jsx("div",{className:"ogx__detail-panel",style:l,children:n.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function St(t){const{row:o,columns:e,rowIndex:r,isSelected:l=!1,checkboxSelection:a=!1,onRowClick:d,onCellClick:s,onSelectionChange:f,columnWidths:c={},pinnedColumns:p,pinnedRows:m,hasDetailPanel:b=!1,isDetailPanelExpanded:x=!1,onDetailPanelToggle:w,detailPanelContent:h,detailPanelHeight:j=200,pinCheckboxColumn:P=!0,pinExpandColumn:k=!0,rowReordering:E=!1,onDragStart:y,onDragOver:g,onDragEnd:v,onDrop:N,isDragging:S,isDragOver:I,editingCell:M,onEditStart:C,onEditStop:W,onEditCellValueChange:Y,focusedCellField:F,isFocusVisible:D,colspanMap:K,rowSpanningCaches:O,rowHeight:V=52}=t,J=i.useRef(null),ee=i.useRef(null);i.useLayoutEffect(()=>{F==="__expand_col__"&&J.current&&J.current.focus({preventScroll:!0}),F==="__checkbox_col__"&&ee.current&&ee.current.focus({preventScroll:!0})},[F]);const _=i.useMemo(()=>Pn(e,c,p,a,P,b,k,E),[e,c,p,a,P,b,k,E]),G=o._hasChildren===!0,B=i.useCallback((U,pe)=>{G||C?.({id:o.id,field:U,value:pe})},[G,o.id,C]),z=i.useCallback((U,pe)=>{Y?.({id:o.id,field:U,value:pe})},[Y,o.id]),L=i.useCallback(U=>{W?.({cancel:U})},[W]);if(o._isSkeleton){const U=Math.max(e.length,5);return n.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:V,minHeight:V},children:Array.from({length:U}).map((pe,fe)=>n.jsx("div",{className:"ogx__skeleton-cell",children:n.jsx("div",{className:"ogx__skeleton-bar"})},fe))})}const X=U=>{U.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:o,id:o.id,rowIndex:r})},H=U=>{U.stopPropagation(),f?.(o.id,U.target.checked)},R=U=>{U.stopPropagation(),w?.(o.id)},re=tn(o.id,m),Z=re==="top",se=re==="bottom",me=["ogx__row",l&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",Z&&"ogx__row--pinned-top",se&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",I&&"ogx__row--drag-over",G&&"ogx__row--group"].filter(Boolean).join(" ");return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:me,onClick:X,role:"row","aria-rowindex":r+1,"aria-selected":l,"data-rowindex":r,onDragOver:g?g(o.id):void 0,onDrop:N?N(o.id):void 0,style:{maxHeight:`${V}px`,minHeight:`${V}px`,"--height":`${V}px`,"--border-width":"1px"},children:[E&&n.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:y?y(o.id):void 0,onDragEnd:v,onClick:U=>U.stopPropagation(),children:n.jsx(Vo,{})}),b&&n.jsx("div",{className:`ogx__cell ogx__cell--expand ${k?"ogx__cell--pinned-left":""} ${F==="__expand_col__"?"ogx__cell--focused":""} ${F==="__expand_col__"&&D?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":x?"Collapse row details":"Expand row details","aria-expanded":x,style:{position:k?"sticky":void 0,left:k?E?48:0:void 0,zIndex:k?5:void 0},ref:J,tabIndex:-1,onClick:U=>{U.stopPropagation(),s?.({row:o,field:"__expand_col__",value:x,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:n.jsx(Rn,{isExpanded:x,onClick:R,variant:"plus-minus"})}),a&&n.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${F==="__checkbox_col__"?"ogx__cell--focused":""} ${F==="__checkbox_col__"&&D?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(E?48:0)+(b&&k?48:0):void 0,zIndex:P?11:void 0},ref:ee,tabIndex:-1,onClick:U=>{U.stopPropagation(),s?.({row:o,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:n.jsx(kt,{id:`ogx-select-row-${o.id}`,name:`ogx-select-row-${o.id}`,checked:l,onChange:H,onClick:U=>U.stopPropagation(),"aria-label":l?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:U=>U.preventDefault()})}),e.map((U,pe)=>{if(U.isSpacer)return n.jsx("div",{style:{width:U.width,minWidth:U.width,flexShrink:0},"aria-hidden":"true"},U.field);const fe=U.valueGetter?U.valueGetter({row:o,field:U.field,value:o[U.field]}):o[U.field],je=c[U.field]??U.width,ge=Ft(U.field,p),be=ge?_[U.field]:void 0,Ce=M?.id===o.id&&M?.field===U.field,Ge=Ce?M?.value:fe,$=K?.get(o.id)?.[U.field],q=O?.spannedCells[o.id]?.[U.field],te=O?.hiddenCells[o.id]?.[U.field]||!1;return n.jsx(Ln,{value:Ge,row:o,colDef:U,rowIndex:r,colIndex:pe,isSelected:l,onCellClick:s,width:je,pinnedPosition:ge,pinnedOffset:be,isFocused:F===U.field,isFocusVisible:D,isEditable:U.editable,isEditing:Ce,onCellEditStart:B,onEditStop:L,onCellValueChange:z,colSpanInfo:$,rowSpan:q,isHiddenByRowSpan:te},U.field)})]}),b&&n.jsx(Uo,{row:o,rowId:o.id,rowIndex:r,content:h,height:j,isExpanded:x})]})}const Ko=({columns:t,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:l=!1})=>n.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:o},role:"row",children:[e&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),t.map((a,d)=>{const s=a.width||150,f=Math.min(s*.7,s-20);return n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:s,minWidth:a.minWidth,maxWidth:a.maxWidth,left:a.left,right:a.right,position:a.isSpacer?"relative":a.pinned?"sticky":"relative",zIndex:a.zIndex},children:!a.isSpacer&&n.jsx("div",{className:"ogx-skeleton-box",style:{width:f,height:16,borderRadius:4}})},a.field||d)})]}),jt=({variant:t="text",size:o="medium",color:e="default",disabled:r=!1,className:l="",children:a,...d})=>{const s=["ogx-button",`ogx-button--${t}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",l].filter(Boolean).join(" ");return n.jsx("button",{className:s,disabled:r,...d,children:a})};function Wn(t){const{page:o,pageSize:e,rowCount:r,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:s=!0,showLastButton:f=!0}=t,c=Math.max(1,Math.ceil(r/e)),p=Math.min(o,c-1),m=p*e,b=Math.min(m+e,r),x=r===0?0:`${m+1}–${b}`,w=()=>{l(0)},h=()=>{l(Math.max(0,p-1))},j=()=>{l(Math.min(c-1,p+1))},P=()=>{l(c-1)},k=g=>{const v=parseInt(g.target.value,10);a(v)},E=p===0,y=p>=c-1;return n.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[n.jsxs("div",{className:"ogx-pagination__page-size",children:[n.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),n.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:k,"aria-label":"Rows per page",children:d.map(g=>n.jsx("option",{value:g,children:g},g))})]}),n.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[x," of ",r]}),n.jsxs("div",{className:"ogx-pagination__actions",children:[s&&n.jsx(jt,{variant:"text",size:"small",onClick:w,disabled:E,"aria-label":"Go to first page",title:"First page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),n.jsx(jt,{variant:"text",size:"small",onClick:h,disabled:E,"aria-label":"Go to previous page",title:"Previous page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),n.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",p+1," of ",c]}),n.jsx(jt,{variant:"text",size:"small",onClick:j,disabled:y,"aria-label":"Go to next page",title:"Next page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&n.jsx(jt,{variant:"text",size:"small",onClick:P,disabled:y,"aria-label":"Go to last page",title:"Last page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Yo(t,o,e={}){const r=new Map,l=[];t.forEach(s=>{const f=s.id;r.set(f,s),l.push(f)});const a=new Map,d=[];return o.forEach(s=>{a.set(s.field,s),d.push(s.field)}),{rows:{idRowsLookup:r,allRows:l},columns:{all:o,lookup:a,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:t.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0},scrollTop:0,scrollLeft:0},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Xo(t,o){switch(o.type){case"SET_ROWS":{const e=Array.from(t.rows.idRowsLookup.values()),r=typeof o.payload=="function"?o.payload(e):o.payload,l=new Map,a=[];return r.forEach(d=>{l.set(d.id,d),a.push(d.id)}),{...t,rows:{idRowsLookup:l,allRows:a},pagination:{...t.pagination,rowCount:o.preserveRowCount?t.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(l=>{e.set(l.field,l),r.push(l.field)}),{...t,columns:{all:o.payload,lookup:e,orderedFields:r,columnVisibilityModel:{}}}}case"SET_SORT_MODEL":return{...t,sorting:{sortModel:o.payload}};case"SET_FILTER_MODEL":return{...t,filter:{filterModel:o.payload}};case"SET_PAGINATION_MODEL":return{...t,pagination:{...t.pagination,paginationModel:o.payload}};case"SET_SELECTION":return{...t,selection:{selectedRows:o.payload}};case"SET_SCROLL":return{...t,virtualization:{...t.virtualization,scrollTop:o.payload.scrollTop,scrollLeft:o.payload.scrollLeft}};case"SET_DIMENSIONS":return{...t,dimensions:{...t.dimensions,viewportWidth:o.payload.viewportWidth,viewportHeight:o.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...t,dataSource:{...t.dataSource,loading:o.payload}};case"SET_DATASOURCE_ERROR":return{...t,dataSource:{...t.dataSource,error:o.payload}};case"SET_ROW_COUNT":return{...t,pagination:{...t.pagination,rowCount:o.payload}};default:return t}}function qo(t){const{rows:o,columns:e,rowHeight:r=52,headerHeight:l=56,columnVisibilityModel:a,initialState:d}=t,s=i.useMemo(()=>Yo(o,e,a),[]),[f,c]=i.useReducer(Xo,{...s,sorting:d?.sorting||s.sorting,filter:d?.filter||s.filter,dataSource:d?.dataSource?{...s.dataSource,...d.dataSource}:s.dataSource,pagination:{...s.pagination,...d?.pagination||{},rowCount:t.rowCount??d?.pagination?.rowCount??s.pagination.rowCount},dimensions:{...s.dimensions,rowHeight:r,headerHeight:l}}),p=i.useRef(f);i.useLayoutEffect(()=>{p.current=f});const m=i.useRef(o);i.useEffect(()=>{o!==m.current&&(m.current=o,c({type:"SET_ROWS",payload:o}))},[o]);const b=i.useCallback((S,I)=>{c({type:"SET_ROWS",payload:S,preserveRowCount:I})},[]),x=i.useCallback(S=>{c({type:"SET_COLUMNS",payload:S})},[]),w=i.useCallback(S=>{c({type:"SET_SORT_MODEL",payload:S})},[]),h=i.useCallback(S=>{c({type:"SET_FILTER_MODEL",payload:S})},[]),j=i.useCallback(S=>{c({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=i.useCallback(S=>{c({type:"SET_SELECTION",payload:S})},[]),k=i.useCallback((S,I)=>{c({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:I}})},[]),E=i.useCallback((S,I)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:I}})},[]),y=i.useCallback(S=>{c({type:"SET_DATASOURCE_LOADING",payload:S})},[]),g=i.useCallback(S=>{c({type:"SET_DATASOURCE_ERROR",payload:S})},[]),v=i.useCallback(S=>{c({type:"SET_ROW_COUNT",payload:S})},[]),N=i.useRef({getRow:S=>p.current.rows.idRowsLookup.get(S)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:S=>p.current.columns.lookup.get(S)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(S,I=!0)=>{const M=new Set(p.current.selection.selectedRows);I?M.add(S):M.delete(S),P(M)},selectRows:(S,I=!0)=>{const M=new Set(p.current.selection.selectedRows);S.forEach(C=>{I?M.add(C):M.delete(C)}),P(M)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(S,I)=>{if(I===null)w(p.current.sorting.sortModel.filter(M=>M.field!==S));else{const M=p.current.sorting.sortModel.findIndex(C=>C.field===S);if(M>=0){const C=[...p.current.sorting.sortModel];C[M]={field:S,sort:I},w(C)}else w([...p.current.sorting.sortModel,{field:S,sort:I}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:h,getFilterModel:()=>p.current.filter.filterModel,setPage:S=>{j({...p.current.pagination.paginationModel,page:S})},setPageSize:S=>{j({...p.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:f,dispatch:c,apiRef:N,setRows:b,setColumns:x,setSortModel:w,setFilterModel:h,setPaginationModel:j,setSelection:P,setScroll:k,setDimensions:E,setDataSourceLoading:y,setDataSourceError:g,setRowCount:v}}function Jo(t){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=t,[l,a]=i.useState(null),[d,s]=i.useState(null),f=i.useRef(-1),c=i.useCallback(x=>w=>{if(r)return;const h=o.findIndex(P=>P.field===x);if(o[h]?.pinnable===!1){w.preventDefault();return}a(x),f.current=h,w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",x))},[o,r]),p=i.useCallback(x=>w=>{r||!l||(w.preventDefault(),w.dataTransfer.dropEffect="move",s(x))},[l,r]),m=i.useCallback(x=>w=>{if(w.preventDefault(),r||!l||l===x){a(null),s(null);return}const h=o.findIndex(k=>k.field===l),j=o.findIndex(k=>k.field===x);if(h===-1||j===-1){a(null),s(null);return}const P=o[h];e&&e({column:P,oldIndex:h,targetIndex:j}),a(null),s(null),f.current=-1},[o,l,r,e]),b=i.useCallback(()=>{a(null),s(null),f.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:r?void 0:c,onDragOver:r?void 0:p,onDragEnd:r?void 0:b,onDrop:r?void 0:m}}function Qo(t){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:l=!1}=t,[a,d]=i.useState(null),[s,f]=i.useState(null),c=i.useCallback(w=>r?r(w):w.id,[r]),p=i.useCallback(w=>h=>{l&&(d(w),h.dataTransfer.effectAllowed="move")},[l]),m=i.useCallback(w=>h=>{!l||!a||(h.preventDefault(),h.dataTransfer.dropEffect="move",s!==w&&f(w))},[l,a,s]),b=i.useCallback(()=>{d(null),f(null)},[]),x=i.useCallback(w=>h=>{if(h.preventDefault(),!a||!o){b();return}const j=e.findIndex(k=>c(k)===a),P=e.findIndex(k=>c(k)===w);j!==-1&&P!==-1&&j!==P&&o({row:e[j],oldIndex:j,targetIndex:P}),b()},[a,o,e,c,b]);return{draggedRowId:a,dragOverRowId:s,onDragStart:l?p:void 0,onDragOver:l?m:void 0,onDragEnd:l?b:void 0,onDrop:l?x:void 0}}const Zo={contains:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().includes(String(o).toLowerCase()),equals:(t,o)=>t==null&&o==null?!0:t==null||o==null?!1:String(t).toLowerCase()===String(o).toLowerCase(),startsWith:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().startsWith(String(o).toLowerCase()),endsWith:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().endsWith(String(o).toLowerCase()),isEmpty:t=>t==null||String(t).trim()==="",isNotEmpty:t=>t!=null&&String(t).trim()!=="",">":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>r},">=":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>=r},"<":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<r},"<=":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<=r},"!=":(t,o)=>{if(o==null||o==="")return!0;const e=Number(t),r=Number(o);return!isNaN(e)&&!isNaN(r)?e!==r:String(t).toLowerCase()!==String(o).toLowerCase()},isAnyOf:(t,o)=>t==null||!Array.isArray(o)?!1:o.some(e=>String(t).toLowerCase()===String(e).toLowerCase()),not:(t,o)=>t==null&&o==null?!1:t==null||o==null?!0:String(t).toLowerCase()!==String(o).toLowerCase(),is:(t,o)=>{if(o==null||o==="")return!0;const e=String(t).toLowerCase(),r=String(o).toLowerCase();return e===r},"=":(t,o)=>t==null||o==null||o===""?!1:Number(t)===Number(o)};function er(t,o){const{field:e,operator:r,value:l}=o,a=t[e],d=Zo[r];return d?d(a,l):(console.warn(`Unknown filter operator: ${r}`),!0)}function tr(t,o){return!o||o.length===0?!0:o.every(e=>{const r=e.toLowerCase();return Object.values(t).some(l=>l==null?!1:String(l).toLowerCase().includes(r))})}function nn(t,o){const e=o.items||[],r=o.logicOperator||"and",l=o.quickFilterValues||[];if(l.length>0&&!tr(t,l))return!1;if(e.length===0)return!0;const a=d=>{if("logicOperator"in d&&"items"in d){const s=d,f=s.items;return f.length===0?!0:s.logicOperator==="and"?f.every(a):f.some(a)}else return er(t,d)};return r==="and"?e.every(a):e.some(a)}function nr(t,o){if(!o)return t;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?t:t.filter(l=>nn(l,o))}function or(t){switch(t){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function on(t,o,e){if(t==null&&o==null)return 0;if(t==null)return e==="asc"?1:-1;if(o==null)return e==="asc"?-1:1;if(typeof t=="number"&&typeof o=="number")return e==="asc"?t-o:o-t;if(t instanceof Date&&o instanceof Date)return e==="asc"?t.getTime()-o.getTime():o.getTime()-t.getTime();const r=String(t).toLowerCase(),l=String(o).toLowerCase();return e==="asc"?r<l?-1:r>l?1:0:r>l?-1:r<l?1:0}function rr(t,o){if(o.length===0)return t;const e=[...t];return e.sort((r,l)=>{for(const a of o){const d=r[a.field],s=l[a.field],f=on(d,s,a.sort);if(f!==0)return f}return 0}),e}function ir(t){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:l=!1,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,onRowExpansionChange:f}=t,{treeNodes:c,rootIds:p,groupingRows:m}=i.useMemo(()=>{if(!l||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,g=[],v=[],N=new Map,S=I=>I.join("/");return o.forEach(I=>{const M=e(I),C=r(I),W=S(C);N.set(W,M),y.set(M,{id:M,parentId:null,depth:C.length-1,groupingKey:C[C.length-1],isExpanded:!1,children:[],serverChildrenCount:I.serverChildrenCount})}),o.forEach(I=>{const M=e(I),C=r(I);if(C.length===1){g.push(M);return}const W=F=>{if(F.length<=1)return;const D=F.slice(0,-1),K=S(D);let O=N.get(K);if(O===void 0&&(O=`auto-group-${K}`,!y.has(O))){const V=D[D.length-1];y.set(O,{id:O,parentId:null,depth:D.length-1,groupingKey:V,isExpanded:!1,children:[],label:V}),N.set(K,O);const J={id:O,name:V,_isGroupRow:!0};v.push(J),D.length===1&&g.push(O),W(D)}return O},Y=W(C);if(Y!==void 0){const F=y.get(Y),D=y.get(M);F&&D&&(D.parentId=Y,F.children=F.children||[],F.children.includes(M)||F.children.push(M))}}),v.forEach(I=>{const M=I.id,C=y.get(M);if(!C)return;const Y=M.replace("auto-group-","").split("/");if(Y.length>1){const F=Y.slice(0,-1),D=S(F),K=N.get(D);if(K&&y.has(K)){C.parentId=K;const O=y.get(K);O&&(O.children=O.children||[],O.children.includes(M)||O.children.push(M))}}}),{treeNodes:y,rootIds:g,groupingRows:v}},[o,r,l,e]),b=i.useMemo(()=>{if(!l)return new Set;const y=new Set;return c.forEach(g=>{g.children&&g.children.length>0&&(a===-1||g.depth<a)&&y.add(g.id)}),y},[c,l,a]),[x,w]=i.useState(new Set);i.useEffect(()=>{b.size>0&&w(b)},[b]);const h=i.useCallback(y=>{w(g=>{const v=new Set(g),N=!v.has(y);if(v.has(y)?v.delete(y):v.add(y),N&&f){const S=c.get(y);S&&f(S)}return v})},[c,f]),j=i.useCallback(()=>{if(!l)return null;const y=new Map;o.forEach(W=>y.set(e(W),W)),m.forEach(W=>y.set(W.id,W));const g=W=>nn(W,d),v=new Map,N=W=>{if(v.has(W))return v.get(W);const Y=y.get(W);if(!Y)return!1;if(g(Y))return v.set(W,!0),!0;const D=c.get(W);return D&&D.children&&D.children.some(O=>N(O))?(v.set(W,!0),!0):(v.set(W,!1),!1)},S=(W,Y)=>{if(!s||s.length===0)return 0;const F=y.get(W),D=y.get(Y);if(!F||!D)return 0;for(const K of s){const O=F[K.field],V=D[K.field],J=on(O,V,K.sort);if(J!==0)return J}return 0},I=[],M=new Set,C=W=>{const Y=W.filter(F=>N(F));Y.sort(S),Y.forEach(F=>{if(M.has(F))return;const D=y.get(F),K=c.get(F);if(D&&K){M.add(F);const O={...D,_treeDepth:K.depth,_isExpanded:x.has(F),_hasChildren:K.children&&K.children.length>0||K.serverChildrenCount&&K.serverChildrenCount>0,_descendantCount:K.children?K.children.length:0};I.push(O),x.has(F)&&K.children&&K.children.length>0&&C(K.children)}})};return C(p),I},[l,o,m,p,c,x,d,s,e]),P=i.useCallback(y=>x.has(y),[x]),k=i.useCallback(y=>c.get(y),[c]),E=i.useCallback(y=>{const g=[];let v=y;for(;v!==null;){const N=c.get(v);if(!N)break;g.unshift(N.groupingKey),v=N.parentId}return g},[c]);return i.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:h,isGroupExpanded:P,getVisibleRows:j,getNode:k,getNodePath:E}),[c,m,h,P,j,k,E])}const lr=t=>t?.depth===-1?"footer":"inline";function sr(t){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:l={},defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,getAggregationPosition:f=lr}=t,[c,p]=i.useState(new Set),{treeNodes:m,rootIds:b,groupingRows:x}=i.useMemo(()=>{const k=new Map,E=new Map,y=[];if(r.length===0)return{treeNodes:k,rootIds:y,groupingRows:E};const g=(S,I,M)=>`auto-group-${S}-${I}-${M||"root"}`,v=(S,I,M)=>{if(I>=r.length)return S.map(F=>{const D=e(F);return k.set(D,{id:D,parentId:M,depth:I,groupingKey:"",isExpanded:!1}),D});const C=r[I],W=new Map;S.forEach(F=>{const D=F[C],K=String(D);W.has(K)||W.set(K,[]),W.get(K).push(F)});const Y=[];return W.forEach((F,D)=>{const O=F[0][C],V=g(C,D,M);Y.push(V);const J={};l&&Object.entries(l).forEach(([z,L])=>{const X=F.map(H=>H[z]);if(L==="sum")J[z]=X.reduce((H,R)=>(Number(H)||0)+(Number(R)||0),0);else if(L==="min")J[z]=Math.min(...X.map(H=>Number(H)||0));else if(L==="max")J[z]=Math.max(...X.map(H=>Number(H)||0));else if(L==="avg"){const H=X.reduce((R,re)=>(Number(R)||0)+(Number(re)||0),0);J[z]=X.length?H/X.length:0}else L==="count"&&(J[z]=X.length)});const ee={[C]:O,...J,id:V};E.set(V,ee);const _={id:V,parentId:M,depth:I,groupingKey:D,groupingField:C,groupingValue:O,aggregatedValues:J,isExpanded:!1,children:[],label:`${C}: ${String(O)}`};_.aggregationPosition=f(_),k.set(V,_);const G=v(F,I+1,V);k.get(V).children=G;const B=F.length;k.get(V).descendantCount=B}),Y},N=v(o,0,null);return y.push(...N),{treeNodes:k,rootIds:y,groupingRows:E}},[o,r,l,e,f]);i.useEffect(()=>{if(a===-1){const k=new Set;m.forEach((E,y)=>{E.children&&E.children.length>0&&k.add(y)}),p(k)}else if(a>0){const k=new Set;m.forEach((E,y)=>{E.depth<a&&E.children&&E.children.length>0&&k.add(y)}),p(k)}else p(new Set)},[r,a]);const w=i.useCallback(k=>{p(E=>{const y=new Set(E);return y.has(k)?y.delete(k):y.add(k),y})},[]),h=i.useCallback(k=>c.has(k),[c]),j=i.useCallback(()=>{if(r.length===0)return null;const k=[],E=new Set,y=new Map;o.forEach(S=>y.set(e(S),S));const g=S=>{const I=m.get(S);if(!I)return!1;if(!I.children||I.children.length===0){const M=y.get(S);return!(!M||d&&!nn(M,d))}return I.children.some(M=>g(M))},v=S=>{let I=S;d&&(I=S.filter(g)),s&&s.length>0&&I.sort((M,C)=>{const W=x.get(M)||y.get(M),Y=x.get(C)||y.get(C);if(!W||!Y)return 0;for(const F of s){const D=W[F.field],K=Y[F.field],O=on(D,K,F.sort);if(O!==0)return O}return 0}),I.forEach(M=>{if(E.has(M))return;const C=m.get(M),W=C?.children&&C.children.length>0,Y=W?x.get(M):y.get(M);if(Y&&C){E.add(M);const F={...Y,_treeDepth:C.depth,_isExpanded:c.has(M),_hasChildren:W,_groupingField:C.groupingField,_groupingValue:C.groupingValue,_descendantCount:C.descendantCount};k.push(F),N.has(M)&&W&&v(C.children)}})},N=c;return v(b),k},[o,e,m,b,x,d,s,c]),P=i.useCallback(k=>m.get(k),[m]);return i.useMemo(()=>({treeNodes:m,groupingRows:x,toggleExpansion:w,isGroupExpanded:h,getVisibleRows:j,getNode:P}),[m,x,w,h,j,P])}function ar(t){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:l,onRowChange:a}=t,[d,s]=i.useState(null),f=i.useRef(null),c=i.useCallback(x=>{s(x),f.current=typeof x=="function"?x(f.current):x},[]),p=i.useCallback(x=>{c({id:x.id,field:x.field,value:x.value,originalValue:x.value})},[]),m=i.useCallback(async x=>{const w=f.current;if(!w)return;if(x?.cancel){c(null);return}const{id:h,field:j,value:P,originalValue:k}=w;if(P===k){c(null);return}const E=o.find(g=>e(g)===h);if(!E){c(null);return}const y={...E,[j]:P};try{if(r){const g=await r(y,E);a?.(g)}else a?.(y);c(null)}catch(g){l&&l(g)}},[d,o,e,r,a,l]),b=i.useCallback(x=>{d&&d.id===x.id&&d.field===x.field&&c(w=>w?{...w,value:x.value}:null)},[d]);return{editingCell:d,startCellEdit:p,stopCellEdit:m,setEditCellValue:b}}function dr(t,o,e){const[r,l]=i.useState(new Map),[a,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),s=i.useCallback(()=>{l(new Map)},[]),f=i.useCallback((h,j)=>r.get(h)?.[j],[r]),c=i.useCallback((h,j,P,k,E)=>{const y=new Map(r);for(let g=k;g<E;g++){const v=o[g];if(!v)continue;let N=1;if(v.colSpan)if(typeof v.colSpan=="function"){const I={row:j,value:j[v.field],field:v.field,colDef:v,rowIndex:P,colIndex:g};N=v.colSpan(I)}else N=v.colSpan;if(N<=1){at(y,h,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[v.field]||100}});continue}let S=e[v.field]||100;for(let I=1;I<N;I++)if(g+I<E){const M=o[g+I];M&&(S+=e[M.field]||100,at(y,h,M.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+N-1,o.length-1)}))}at(y,h,v.field,{spannedByColSpan:!1,cellProps:{colSpan:N,width:S}}),g+=N-1}l(y)},[r,o,e]),p=i.useCallback((h,j)=>{const P={},k={},E={};o.forEach((y,g)=>{if(y.rowSpan)for(let v=h;v<j;v++){const N=t[v];if(!N||k[N.id]?.[y.field])continue;const S=y.valueGetter?y.valueGetter({row:N,field:y.field,value:N[y.field]}):N[y.field];let I=1;if(typeof y.rowSpan=="function"){const M={row:N,value:S,field:y.field,colDef:y,rowIndex:v,colIndex:g};I=y.rowSpan(M)}else typeof y.rowSpan=="number"&&(I=y.rowSpan);if(I>1){P[N.id]||(P[N.id]={}),P[N.id][y.field]=I;for(let M=1;M<I;M++){const C=v+M;if(C<j&&t[C]){const W=t[C];k[W.id]||(k[W.id]={}),k[W.id][y.field]=!0,E[C]||(E[C]={}),E[C][y.field]=v}}}}}),d({caches:{spannedCells:P,hiddenCells:k,hiddenCellOriginMap:E},processedRange:{firstRowIndex:h,lastRowIndex:j}})},[t,o]),m=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const h=new Map;t.forEach((E,y)=>{for(let g=0;g<o.length;g++){const v=o[g];if(!v)continue;let N=1;if(v.colSpan)if(typeof v.colSpan=="function"){const I={row:E,value:E[v.field],field:v.field,colDef:v,rowIndex:y,colIndex:g};N=v.colSpan(I)}else N=v.colSpan;if(N<=1){const I=e[v.field]||(typeof v.width=="number"?v.width:100);at(h,E.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:I}});continue}let S=e[v.field]||(typeof v.width=="number"?v.width:100);for(let I=1;I<N;I++)if(g+I<o.length){const M=o[g+I];if(M){const C=e[M.field]||(typeof M.width=="number"?M.width:100);S+=C,at(h,E.id,M.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+N-1,o.length-1)})}}at(h,E.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:N,width:S}}),g+=N-1}}),l(h);const j={},P={},k={};o.forEach((E,y)=>{if(E.rowSpan)for(let g=0;g<t.length;g++){const v=t[g];if(!v||P[v.id]?.[E.field])continue;const N=E.valueGetter?E.valueGetter({row:v,field:E.field,value:v[E.field]}):v[E.field];let S=1;if(typeof E.rowSpan=="function"){const I={row:v,value:N,field:E.field,colDef:E,rowIndex:g,colIndex:y};S=E.rowSpan(I)}else typeof E.rowSpan=="number"&&(S=E.rowSpan);if(S>1){j[v.id]||(j[v.id]={}),j[v.id][E.field]=S;for(let I=1;I<S;I++){const M=g+I;if(M<t.length&&t[M]){const C=t[M];P[C.id]||(P[C.id]={}),P[C.id][E.field]=!0,k[M]||(k[M]={}),k[M][E.field]=g}}}}}),d({caches:{spannedCells:j,hiddenCells:P,hiddenCellOriginMap:k},processedRange:{firstRowIndex:0,lastRowIndex:t.length}})},[t,o,e]);const b=i.useCallback(()=>a.caches.spannedCells,[a]),x=i.useCallback(()=>a.caches.hiddenCells,[a]),w=i.useCallback(()=>a.caches.hiddenCellOriginMap,[a]);return{colspanMap:r,resetColSpan:s,getCellColSpanInfo:f,calculateColSpan:c,rowSpanningState:a,calculateRowSpan:p,resetRowSpan:m,getSpannedCells:b,getHiddenCells:x,getHiddenCellOriginMap:w}}function at(t,o,e,r){let l=t.get(o);l||(l={},t.set(o,l)),l[e]=r}function cr(t){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:l,paginationMode:a,sortingMode:d,filterMode:s,aggregationModel:f,setRows:c,setRowCount:p,setDataSourceLoading:m,setDataSourceError:b,onAggregationResults:x}=t,w=i.useRef(null),h=i.useRef(0),j=i.useCallback(async()=>{if(!o)return;const k=++h.current;m(!0),b(null);const E=l.page*l.pageSize,y=E+l.pageSize,g={startRow:E,endRow:y,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:f};try{const v=await o.getRows(g);if(k!==h.current)return;let N=!1;if(a==="infinite"){const S=w.current;if(S){const I=JSON.stringify(S.sortModel)!==JSON.stringify(e),M=JSON.stringify(S.filterModel)!==JSON.stringify(r),C=S.pageSize!==l.pageSize;!I&&!M&&!C&&l.page>S.page&&(N=!0)}}c(N?S=>[...S,...v.rows]:v.rows,!0),v.aggregationResults&&x&&x(v.aggregationResults),v.rowCount!==void 0&&p(v.rowCount),w.current={sortModel:e,filterModel:r,page:l.page,pageSize:l.pageSize}}catch(v){k===h.current&&(b(v),console.error("Data Source Error:",v))}finally{k===h.current&&m(!1)}},[o,l.page,l.pageSize,e,r,a,f,x,c,p,m,b]);i.useEffect(()=>{if(o&&(a==="server"||a==="infinite"||d==="server"||s==="server")){const E=setTimeout(()=>{j()},300);return()=>clearTimeout(E)}},[j,o,a,d,s]);const P=i.useCallback(async(k,E)=>{if(o){m(!0);try{const y=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:E});y.rows.length>0&&c(g=>{const v=new Set(g.map(S=>S.id)),N=y.rows.filter(S=>!v.has(S.id));return[...g,...N]})}catch(y){b(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[o,e,r,c,m,b]);return{fetchRows:j,fetchChildren:P}}const ur={sum:t=>t.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,r)=>e+Number(r),0),avg:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e)));return o.length===0?null:o.reduce((e,r)=>e+Number(r),0)/o.length},count:t=>t.filter(o=>o!=null).length,min:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.min(...o):null},max:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.max(...o):null},unique:t=>new Set(t.filter(o=>o!=null)).size};function qe(t,o){return t==null?"—":typeof t=="number"?o==="avg"?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString():String(t)}function On(t){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:s}=t,f=i.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const k={};for(const[E,y]of Object.entries(e)){const g=ur[y];if(!g){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const v=o.map(N=>N[E]);k[E]=g(v)}return k},[o,e,r]),[c,p]=i.useState({}),[m,b]=i.useState(!1),[x,w]=i.useState(null),h=i.useRef(0),j=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const k=++h.current;b(!0),w(null);try{const E=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:e});k===h.current&&p(E)}catch(E){k===h.current&&(w(E),console.error("[useAggregation] Server aggregation error:",E))}finally{k===h.current&&b(!1)}},[l,e,a,d]);return i.useEffect(()=>{r&&l?.getAggregations&&!s&&j()},[j,r,l,s]),{aggregationResult:i.useMemo(()=>r?s&&Object.keys(s).length>0?s:c:f,[r,f,s,c]),isLoading:m,error:x}}function fr(t,o){const e=t.filter(r=>r!=null&&!isNaN(r));if(e.length===0)return null;switch(o){case"sum":return e.reduce((r,l)=>r+l,0);case"avg":return e.reduce((r,l)=>r+l,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function rn(t,o){return o.map(e=>String(t[e]??"")).join("\0")}function Fn(t,o,e,r){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return l;const{rowFields:a,columnFields:d,valueFields:s}=e;if(a.length===0||s.length===0)return l;const f=new Map(o.map(j=>[j.field,j])),c=new Set;for(const j of t)c.add(rn(j,d));const p=Array.from(c).sort(),m=new Map;for(const j of t){const P=rn(j,a);if(!m.has(P)){const g={};for(const v of a)g[v]=j[v];m.set(P,{labelValues:g,bucket:new Map})}const k=m.get(P),E=rn(j,d);k.bucket.has(E)||k.bucket.set(E,new Map);const y=k.bucket.get(E);for(const g of s){const v=Number(j[g.field]);y.has(g.field)||y.set(g.field,[]),isNaN(v)||y.get(g.field).push(v)}}let b=0;const x=[];for(const[,j]of m){const P={id:b++,...j.labelValues};for(const k of p){const E=j.bucket.get(k);for(const y of s){const g=d.length>0?`${k}${y.field}${y.aggFn}`:`${y.field}${y.aggFn}`,v=E?.get(y.field)??[];P[g]=v.length>0?fr(v,y.aggFn):null}}x.push(P)}const w={id:"__pivot_grand_total__"};for(let j=0;j<a.length;j++)w[a[j]]=j===0?"Grand Total":"";for(const j of p)for(const P of s){const k=d.length>0?`${j}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,E=x.reduce((y,g)=>{const v=g[k];return y+(v!=null&&!isNaN(Number(v))?Number(v):0)},0);w[k]=E}x.push(w);const h=[];for(const j of a){const P=f.get(j);h.push({field:j,headerName:P?.headerName??j,width:P?.width??140,sortable:!0})}for(const j of p){const P=d.length>0?j.split("\0").map((k,E)=>{const y=f.get(d[E]);return y?.headerName?`${y.headerName}: ${k}`:k}).join(" / "):"";for(const k of s){const E=f.get(k.field),y=d.length>0?`${j}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,g=k.headerName??E?.headerName??k.field,v=P?`${P} — ${g} (${k.aggFn})`:`${g} (${k.aggFn})`;h.push({field:y,headerName:v,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:N})=>{if(N==null)return"—";const S=Number(N);return k.aggFn==="avg"?S.toFixed(2):k.aggFn==="count"?S.toLocaleString():E?.valueFormatter?E.valueFormatter({value:N,row:{},field:k.field}):S.toLocaleString()}})}}return{pivotRows:x,pivotColumns:h,colKeys:p,isValid:!0}},[t,o,e,r])}function gr(t){const o=document.createElement("textarea");o.value=t,o.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(o),o.focus(),o.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(o)}return e}async function hr(t){let o=!1;try{o=gr(t)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(t);return}catch(e){if(o)return;throw e}else if(!o)throw new Error("Clipboard API not available and fallback failed.")}function pr(t){const{selectedRowIds:o,columns:e,getVisibleRows:r,getRowId:l}=t,a=i.useCallback(async()=>{if(o.size===0)return;const s=r().filter(b=>o.has(l(b)));if(s.length===0)return;const f=e.filter(b=>!b.field.startsWith("__")),c=f.map(b=>b.headerName||b.field).join(" "),p=s.map(b=>f.map(x=>{const w=b[x.field];return x.valueFormatter?x.valueFormatter({value:w,row:b,field:x.field}):w??""}).join(" ")).join(`
6
+ <%s key={someKey} {...props} />`,F,D,L,D),K[D+F]=!0)}if(D=null,W!==void 0&&(e(W),D=""+W),d(B)&&(e(B.key),D=""+B.key),"key"in B){W={};for(var Z in B)Z!=="key"&&(W[Z]=B[Z])}else W=B;return D&&a(W,typeof k=="function"?k.displayName||k.name||"Unknown":k),c(k,D,W,i(),V,G)}function m(k){p(k)?k._store&&(k._store.validated=1):typeof k=="object"&&k!==null&&k.$$typeof===M&&(k._payload.status==="fulfilled"?p(k._payload.value)&&k._payload.value._store&&(k._payload.value._store.validated=1):k._store&&(k._store.validated=1))}function p(k){return typeof k=="object"&&k!==null&&k.$$typeof===v}var b=l,v=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),y=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),P=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,T=Array.isArray,A=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(k){return k()}};var H,R={},U=b.react_stack_bottom_frame.bind(b,s)(),q=A(o(s)),K={};it.Fragment=j,it.jsx=function(k,B,W){var F=1e4>P.recentlyCreatedOwnerStacks++;return g(k,B,W,!1,F?Error("react-stack-top-frame"):U,F?A(o(k)):q)},it.jsxs=function(k,B,W){var F=1e4>P.recentlyCreatedOwnerStacks++;return g(k,B,W,!0,F?Error("react-stack-top-frame"):U,F?A(o(k)):q)}})()),it}var un;function Yn(){return un||(un=1,process.env.NODE_ENV==="production"?ht.exports=Un():ht.exports=Kn()),ht.exports}var r=Yn();function pt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function qn(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=pt(s.field,t);d==="left"?e.push(s):d==="right"?i.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),u=t.left.indexOf(d.field);return a-u}),t.right&&i.sort((s,d)=>{const a=t.right.indexOf(s.field),u=t.right.indexOf(d.field);return a-u}),{left:e,center:o,right:i}):{left:e,center:n,right:i}}function fn(n,t,e,o,i,s,d,a){const u={};if(!e)return u;const c=qn(n,e);let g=0;a&&(g+=48),s&&d&&(g+=48),o&&i&&(g+=48),c.left.forEach(p=>{u[p.field]=g;const b=t[p.field]??p.width??100;g+=b});let m=0;return[...c.right].reverse().forEach(p=>{const b=t[p.field]??p.width??100;u[p.field]=m,m+=b}),u}function Wt(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function Xn(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=Wt(s.id,t);d==="top"?e.push(s):d==="bottom"?i.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),u=t.top.indexOf(d.id);return a-u}),t.bottom&&i.sort((s,d)=>{const a=t.bottom.indexOf(s.id),u=t.bottom.indexOf(d.id);return a-u}),{top:e,center:o,bottom:i}):{top:e,center:n,bottom:i}}function Be(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Jn(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:i,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,visibleOrderedColumns:c,pinnedColumns:g,columnWidths:m,viewportWidth:p,checkboxSelection:b,hasDetailPanel:v,rowReordering:_,paginationMode:j,isLoading:I,pageSize:h}=n;return l.useMemo(()=>{const S=e?o:i,y=S.map((z,X)=>{let ee=t;if(s.has(z.id)){const se=d?.({row:z,id:z.id,rowIndex:a+X})??200;ee+=typeof se=="number"?se:parseInt(String(se),10)||200}return ee}),w=y.reduce((z,X,ee)=>(z.push((z[ee-1]||0)+X),z),[]),f=j==="infinite"&&I&&S.length>0?Math.min(h,20):0,x=(w[w.length-1]||0)+f*t,E=a*t,M=u*t,N=[],C=[],P=[],O=[];c.forEach(z=>{const X=pt(z.field,g);X==="left"?N.push(z):X==="right"?C.push(z):P.push(z)});const T=(b?48:0)+(v?48:0)+(_?48:0),A=z=>m[z.field]??z.width,H=N.reduce((z,X)=>{const ee=Be(A(X));return z+(ee.type==="fixed"?ee.value:100)},0),R=C.reduce((z,X)=>{const ee=Be(A(X));return z+(ee.type==="fixed"?ee.value:100)},0),U=P.reduce((z,X)=>{if(!Object.prototype.hasOwnProperty.call(m,X.field)&&X.flex&&X.flex>0){const de=X.minWidth??150,je=typeof X.width=="number"?X.width:150;return z+(de||je)}const se=Be(A(X));return se.type==="fixed"?z+se.value:se.type==="percentage"?z+100:z+(X.minWidth??150)},0),q=Math.max(p-T-H-R,U),K=[],k=[],B=[];P.forEach(z=>{const X=Object.prototype.hasOwnProperty.call(m,z.field),ee=Be(A(z));if(!X&&z.flex&&z.flex>0){B.push({col:z,flex:z.flex});return}ee.type==="fixed"?K.push({col:z,width:ee.value}):ee.type==="percentage"?k.push({col:z,percentage:ee.value}):B.push({col:z,flex:1})});const W=K.reduce((z,{width:X})=>z+X,0);let F=Math.max(0,q-W);const V=new Map;k.forEach(({col:z,percentage:X})=>{const ee=X/100*F;V.set(z.field,ee),F-=ee}),F=Math.max(0,F);const G=new Map,D=B.map(z=>({...z,minWidth:z.col.minWidth??50,maxWidth:z.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let z=0;const X=D.length*2;for(;z<X;){z++;const ee=D.filter(ne=>!ne.frozen);if(ee.length===0)break;const se=ee.reduce((ne,be)=>ne+be.flex,0),de=D.reduce((ne,be)=>be.frozen?ne+be.computedWidth:ne,0),je=Math.max(0,F-de);if(se<=0){ee.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const Ve=je/se;let fe=0;const Ue=[],Ke=[];if(ee.forEach(ne=>{const be=Ve*ne.flex;be<ne.minWidth?(fe+=ne.minWidth-be,Ue.push(ne)):be>ne.maxWidth?(fe+=ne.maxWidth-be,Ke.push(ne)):ne.computedWidth=be}),Ue.length===0&&Ke.length===0){ee.forEach(ne=>ne.frozen=!0);break}fe>0?Ue.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):fe<0?Ke.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(Ue.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),Ke.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),D.forEach(z=>G.set(z.col.field,z.computedWidth));const Z=new Map;P.forEach(z=>{let X;if(G.has(z.field))X=G.get(z.field);else{const ee=K.find(de=>de.col.field===z.field),se=k.find(de=>de.col.field===z.field);if(ee)X=ee.width;else if(se){const de=V.get(z.field)||0;X=Math.max(z.minWidth??50,de||100)}else X=100}O.push(X),Z.set(z.field,X)});const Q=P.map(z=>{const X=D.find(ee=>ee.col.field===z.field);return{...z,width:Z.get(z.field)??(typeof z.width=="number"?z.width:100),flex:X?X.flex:z.flex}}),J=11,ue=N.map((z,X)=>{const ee=Be(A(z));return{...z,width:ee.type==="fixed"?ee.value:100,zIndex:J+X}}),$=11,ae=C.map((z,X)=>{const ee=Be(A(z));return{...z,width:ee.type==="fixed"?ee.value:100,zIndex:$+(C.length-1-X)}}),ie=O.reduce((z,X)=>z+X,0),pe=H+ie+R+T,le=O.reduce((z,X,ee)=>(z.push((z[ee-1]||0)+X),z),[]);return{rowHeights:y,cumulativeHeights:w,unpinnedRowsHeight:x,pinnedTopHeight:E,pinnedBottomHeight:M,leftPinnedCols:ue,rightPinnedCols:ae,unpinnedColsWithWidth:Q,unpinnedColWidths:O,unpinnedAccWidths:le,totalWidth:pe,leftWidth:H,rightWidth:R,unpinnedTotalWidth:ie,systemColumnsWidth:T,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:S.length}},[t,e,o,i,s,d,a,u,c,g,m,p,b,v,_,j,I,h])}function Qn(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:i,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:u,sortModel:c,handleSort:g,isCellEditable:m,pagination:p,pageSize:b,virtualization:v,viewportRef:_}=n,[j,I]=l.useState(null),h=l.useCallback(w=>{w.target===w.currentTarget&&I(f=>{if(f)return f;if(o)return{id:"HEADER",field:"__checkbox_col__"};const x=t[0],E=e[0];return x&&E?{id:x.id,field:E.field}:null})},[t,e,o]),S=l.useCallback(w=>{w.currentTarget.contains(w.relatedTarget)||I(null)},[]),y=l.useCallback(w=>{if(u(!0),!j)return;const{id:f,field:x}=j,E=!!a.editingCell;if(f==="HEADER"&&(w.key==="Enter"||w.key===" ")){w.preventDefault();const R=e.find(U=>U.field===x);if(R&&R.sortable!==!1){const U=c.find(K=>K.field===x);let q="asc";U&&(q=U.sort==="asc"?"desc":null),g(x,q)}return}if(w.key==="Enter"){if(w.preventDefault(),E)a.stopCellEdit();else if(e.find(U=>U.field===x)?.editable){const U=t.find(q=>q.id===f);U&&a.startCellEdit({id:f,field:x,value:U[x]})}return}if((w.key===" "||w.key==="Spacebar")&&!E){if(x==="__checkbox_col__"){w.preventDefault(),s(f,!i.has(f));return}if(x==="__expand_col__"){w.preventDefault(),d(f);return}}if(w.key==="Escape"){E&&(w.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(E&&w.key!=="Tab")return;const M=f==="HEADER",N=M?-1:t.findIndex(R=>R.id===f),C=e.findIndex(R=>R.field===x);if(!M&&N===-1||C===-1)return;const P=(R,U,q,K,k,B=!1)=>{let W=R+q,F=U+K;return k&&K!==0&&(K>0&&F>=e.length?(F=0,W++):K<0&&F<0&&(F=e.length-1,W--)),!k&&(F<0||F>=e.length)||W<(B?-1:0)||W>=t.length?null:{r:W,c:F}},O=(R,U,q,K,k,B=!1)=>{let W=R,F=U,V=0;const G=t.length*e.length+e.length;for(;V<G;){if(V++,W+=q,F+=K,K!==0)K>0?F>=e.length&&(F=0,W++):F<0&&(F=e.length-1,W--);else if(F<0||F>=e.length)return null;if(W<-1||W>=t.length)return null;if(W===-1){if(!B)continue;const J=e[F],ue=J.sortable!==!1;if(["__checkbox_col__"].includes(J.field)||ue)return{r:W,c:F};continue}const D=t[W],L=e[F],Z=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(L.field);let Q=L.editable||Z;if(m&&!Z)try{Q=m({row:D,field:L.field,value:D[L.field],colDef:L,rowIndex:W,colIndex:F})}catch{}if(Q)return{r:W,c:F}}return null};let T=N,A=C,H=!1;if(w.key==="Tab"){const R=w.shiftKey?-1:1,U=O(N,C,0,R,!0,!1);U&&(T=U.r,A=U.c,H=!0)}else if(w.key==="ArrowRight"){const R=P(N,C,0,1,!0,!0);R&&(T=R.r,A=R.c,H=!0)}else if(w.key==="ArrowLeft"){const R=P(N,C,0,-1,!0,!0);R&&(T=R.r,A=R.c,H=!0)}else if(w.key==="ArrowDown"){const R=P(N,C,1,0,!1,!0);R&&(T=R.r,A=R.c,H=!0)}else if(w.key==="ArrowUp"){const R=P(N,C,-1,0,!1,!0);R&&(T=R.r,A=R.c,H=!0)}else if(w.key==="Home")A=0,(w.ctrlKey||w.metaKey)&&(T=-1),H=!0;else if(w.key==="End")A=e.length-1,(w.ctrlKey||w.metaKey)&&(T=t.length-1),H=!0;else if(w.key==="PageUp")T=Math.max(-1,T-(p?b:10)),H=!0;else if(w.key==="PageDown"){const R=p?b:10;T=Math.min(t.length-1,T+R),H=!0}if(H&&(w.preventDefault(),E&&w.key==="Tab"&&a.stopCellEdit(),T>=-1&&T<t.length&&A>=0&&A<e.length)){const R=e[A];I(T===-1?{id:"HEADER",field:R.field}:{id:t[T].id,field:R.field});const U=_.current;if(U){const{cumulativeHeights:q,pinnedTopHeight:K,columnMetrics:k}=v,{clientHeight:B,clientWidth:W,scrollTop:F,scrollLeft:V}=U,G=T<=0?0:q[T-1],D=q[T],L=F+K,Z=F+B;let Q=F;if(G<L?Q=Math.max(0,G-K):D>Z&&(Q=D-B),Q!==F&&(U.scrollTop=Q),k){const{leftPinnedWidth:J,rightPinnedWidth:ue,unpinnedAccWidths:$,unpinnedCols:ae,totalSpecialsWidth:ie,pinnedSpecialsWidth:pe}=k,le=ae.findIndex(z=>z.field===R.field);if(le!==-1){const z=ie+J+(le>0?$[le-1]:0),X=ie+J+$[le],ee=V+pe+J,se=V+W-ue;let de=V;z<ee?de=Math.max(0,z-pe-J):X>se&&(de=X-W+ue),de!==V&&(U.scrollLeft=de)}}}}},[j,t,e,a,v,i,s,d,u,c,g,m,p,b,_]);return{focusedCell:j,setFocusedCell:I,handleFocus:h,handleBlur:S,handleKeyDown:y}}const Zn={rowFields:[],columnFields:[],valueFields:[]};function eo(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:i,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:u,pivotModel:c,onPivotModelChange:g,paginationModel:m={page:0,pageSize:100},onPaginationModelChange:p,rowSelectionModel:b}=n,[v,_]=l.useState(()=>t?.sorting?.sortModel??[]),j=e!==void 0,I=j?e:v,h=o!==void 0,[S,y]=l.useState(()=>o??{}),w=h?o:S,f=l.useCallback(J=>{h||y(J),i?.(J)},[h,i]),x=s!==void 0,[E,M]=l.useState(()=>t?.columns?.columnVisibilityModel??{}),N=x?s:E,C=l.useCallback(J=>{x||M(J),d?.(J)},[x,d]),P=a!==void 0,[O,T]=l.useState(()=>t?.columns?.pinnedColumns??{}),A=P?a:O,H=l.useCallback(J=>{P||T(J),u?.(J)},[P,u]),[R,U]=l.useState(()=>c??Zn),q=c??R,K=l.useCallback(J=>{U(J),g?.(J)},[g]),k=m!==void 0&&n.paginationModel!==void 0,[B,W]=l.useState(()=>t?.pagination?.paginationModel??m),F=k?m:B,V=l.useCallback(J=>{k||W(J),p?.(J)},[k,p]),G=b!==void 0,[D,L]=l.useState([]),Z=G?b:D,Q=l.useMemo(()=>new Set(Z),[Z]);return{sortModel:I,isSortControlled:j,setInternalSortModel:_,aggregationModel:w,handleAggregationModelChange:f,columnVisibilityModel:N,handleColumnVisibilityModelChange:C,pinnedColumns:A,handlePinnedColumnsChange:H,currentPivotModel:q,handlePivotModelChange:K,effectivePaginationModel:F,handlePaginationModelChange:V,rowSelectionModel:Z,selectedRowIds:Q,isSelectionControlled:G,setInternalRowSelectionModel:L}}const to={contains:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().includes(String(t).toLowerCase()),equals:(n,t)=>n==null&&t==null?!0:n==null||t==null?!1:String(n).toLowerCase()===String(t).toLowerCase(),startsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>o},">=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>=o},"<":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<o},"<=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<=o},"!=":(n,t)=>{if(t==null||t==="")return!0;const e=Number(n),o=Number(t);return!isNaN(e)&&!isNaN(o)?e!==o:String(n).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(n,t)=>n==null||!Array.isArray(t)?!1:t.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,t)=>n==null&&t==null?!1:n==null||t==null?!0:String(n).toLowerCase()!==String(t).toLowerCase(),is:(n,t)=>{if(t==null||t==="")return!0;const e=String(n).toLowerCase(),o=String(t).toLowerCase();return e===o},"=":(n,t)=>n==null||t==null||t===""?!1:Number(n)===Number(t)};function no(n,t){const{field:e,operator:o,value:i}=t,s=n[e],d=to[o];return d?d(s,i):(console.warn(`Unknown filter operator: ${o}`),!0)}function oo(n,t){return!t||t.length===0?!0:t.every(e=>{const o=e.toLowerCase();return Object.values(n).some(i=>i==null?!1:String(i).toLowerCase().includes(o))})}function Ft(n,t){const e=t.items??[],o=t.logicOperator??"and",i=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(i.length>0&&!oo(n,i))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,u=a.items;return u.length===0?!0:a.logicOperator==="and"?u.every(s):u.some(s)}else return no(n,d)};return o==="and"?e.every(s):e.some(s)}function ro(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(i=>Ft(i,t))}function io(n){switch(n){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function At(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),i=String(t).toLowerCase();return e==="asc"?o<i?-1:o>i?1:0:o>i?-1:o<i?1:0}function lo(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,i)=>{for(const s of t){const d=o[s.field],a=i[s.field],u=At(d,a,s.sort);if(u!==0)return u}return 0}),e}function so(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:i,dataSource:s,sortModel:d,sortingMode:a,pagination:u,paginationMode:c,effectivePaginationModel:g,pinnedRows:m,isLoading:p,pageSize:b}=n,v=l.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:ro(t,i),[t,i,e,o,s]),{top:_,center:j,bottom:I}=l.useMemo(()=>e?{top:[],center:v,bottom:[]}:Xn(v,m),[v,m,e]),h=l.useMemo(()=>e||a==="server"&&s?j:lo(j,d),[j,d,e,a,s]),S=l.useMemo(()=>{if(!u||c==="server"&&s)return h;const w=g.page*g.pageSize;return h.slice(w,w+g.pageSize)},[h,u,g.page,g.pageSize,c,s]),y=l.useMemo(()=>{if(e)return j;const w=u?S:h,f=[..._,...w,...I];if(c==="infinite"&&p&&f.length>0){const x=Math.min(b,20),E=Array.from({length:x},(M,N)=>({id:`__skeleton_${N}__`,_isSkeleton:!0}));return[...f,...E]}return f},[_,S,h,I,u,e,j,c,p,b]);return{filteredRows:v,pinnedTopRows:_,unpinnedRows:j,pinnedBottomRows:I,sortedUnpinnedRows:h,paginatedUnpinnedRows:S,allRenderableRows:y}}function ao(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:i,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:u,checkboxSelection:c,pinCheckboxColumn:g,pinExpandColumn:m}=n;return l.useMemo(()=>{const{unpinnedAccWidths:p,unpinnedColsWithWidth:b,leftPinnedCols:v,rightPinnedCols:_,totalWidth:j,leftWidth:I,rightWidth:h,unpinnedTotalWidth:S,systemColumnsWidth:y,cumulativeHeights:w,pinnedTopHeight:f,pinnedBottomHeight:x,unpinnedRowsHeight:E,rowHeights:M,unpinnedRowsLength:N}=t,C=i||1e3,P=d?f+E+x+50:s||600,O=6,T=Math.max(0,o-I),A=o+C-I;let H=0,R=b.length-1,U=0,q=p.length-1;for(;U<=q;){const $=U+q>>>1;p[$]<T?U=$+1:q=$-1}H=Math.max(0,U-O);for(let $=H;$<p.length;$++){if(($===0?0:p[$-1])>A){R=Math.min(b.length-1,$+O);break}R=Math.min(b.length-1,$+O)}const K=H>0?p[H-1]:0,k=S-p[R],B=[...v,...K>0?[{field:"__spacer_left__",width:K,isSpacer:!0}]:[],...b.slice(H,R+1),...k>0?[{field:"__spacer_right__",width:k,isSpacer:!0}]:[],..._],F=C>0&&j>C?16:0,V=f+E+x+F+2,G=5;let D=0,L=N-1,Z=0,Q=0,J=w.length-1;for(;Q<=J;){const $=Q+J>>>1;w[$]<e?Q=$+1:J=$-1}D=Math.max(0,Q-G),Z=D>0?w[D-1]:0;for(let $=D;$<w.length;$++)if(w[$]>=e+P){L=Math.min(N-1,$+G);break}const ue=(a?48:0)+(u&&m?48:0)+(c&&g?48:0);return{renderContext:{firstRowIndex:D,lastRowIndex:L,firstColumnIndex:H,lastColumnIndex:R},offsetTop:Z,offsetLeft:0,totalHeight:V,pinnedTopHeight:f,pinnedBottomHeight:x,totalWidth:j,rowHeights:M,cumulativeHeights:w,virtualColumns:B,columnMetrics:{leftPinnedWidth:I,rightPinnedWidth:h,unpinnedAccWidths:p,unpinnedCols:b,totalSpecialsWidth:y,pinnedSpecialsWidth:ue}}},[t,e,o,i,s,d,a,u,c,g,m])}function co(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[i,s]=l.useState(null),[d,a]=l.useState(null),u=l.useRef(-1),c=l.useCallback(b=>v=>{if(o)return;const _=t.findIndex(I=>I.field===b);if(t[_]?.pinnable===!1){v.preventDefault();return}s(b),u.current=_,v.dataTransfer&&(v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",b))},[t,o]),g=l.useCallback(b=>v=>{o||!i||(v.preventDefault(),v.dataTransfer.dropEffect="move",a(b))},[i,o]),m=l.useCallback(b=>v=>{if(v.preventDefault(),o||!i||i===b){s(null),a(null);return}const _=t.findIndex(h=>h.field===i),j=t.findIndex(h=>h.field===b);if(_===-1||j===-1){s(null),a(null);return}const I=t[_];e&&e({column:I,oldIndex:_,targetIndex:j}),s(null),a(null),u.current=-1},[t,i,o,e]),p=l.useCallback(()=>{s(null),a(null),u.current=-1},[]);return{draggedColumn:i,dragOverColumn:d,onDragStart:o?void 0:c,onDragOver:o?void 0:g,onDragEnd:o?void 0:p,onDrop:o?void 0:m}}function gn({isExpanded:n,onClick:t,variant:e="chevron"}){return r.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:o=>{t&&t(o)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:n?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:r.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function uo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:i,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:u,disableColumnReorder:c,pivotMode:g,checkboxSelection:m,hasDetailPanel:p,rowReordering:b,initialState:v,setColumns:_}=n,j=l.useMemo(()=>e?t.map((C,P)=>P===0?{...C,renderCell:O=>{const T=O.row,A=typeof T._treeDepth=="number"?T._treeDepth:0,H=!!T._hasChildren,R=!!T._isExpanded,U=typeof T._groupingField=="string"?T._groupingField:void 0,q=T._groupingValue,K=typeof T._descendantCount=="number"?T._descendantCount:void 0,k=!!T._isGroupRow;let B=C.renderCell?C.renderCell(O):O.value;return i&&H&&k&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[O.value,K!==void 0&&K>0?` (${K})`:""]})),o&&H&&U&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[C.field===U?"":`${U}: `,String(q),K!==void 0?` (${K})`:""]})),r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:A*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?r.jsx("div",{onClick:W=>{W.stopPropagation(),W.preventDefault(),s?.toggleExpansion(O.row.id)},onMouseDown:W=>{W.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(gn,{isExpanded:R,onClick:W=>{W.stopPropagation(),W.preventDefault(),s?.toggleExpansion(O.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B})]})}}:{...C,renderCell:O=>{const T=O.row,A=!!T._hasChildren,H=typeof T._groupingField=="string"?T._groupingField:void 0;return o&&A?C.field===H?null:O.value!==void 0&&O.value!==null?C.renderCell?C.renderCell(O):O.value:null:C.renderCell?C.renderCell(O):O.value}}):t,[t,e,o,i,s]),[I,h]=l.useState(()=>v?.columns?.columnWidths??{}),S=l.useCallback((C,P)=>{h(O=>({...O,[C]:P}))},[]),[y,w]=l.useState(()=>v?.columns?.columnOrder??t.map(C=>C.field)),f=a??y;l.useEffect(()=>{_(t)},[t,_]),l.useEffect(()=>{g&&w(t.map(C=>C.field))},[g,t]);const x=l.useMemo(()=>{if(c)return j;const C=new Map(f.map((P,O)=>[P,O]));return[...j].sort((P,O)=>{const T=C.get(P.field)??j.indexOf(P),A=C.get(O.field)??j.indexOf(O);return T-A})},[j,f,c]),E=l.useMemo(()=>x.filter(C=>d[C.field]!==!1),[x,d]),M=co({columns:x,onColumnOrderChange:l.useCallback(C=>{const{oldIndex:P,targetIndex:O}=C,T=[...f],[A]=T.splice(P,1);T.splice(O,0,A),a||w(T),u?.(C)},[f,a,u]),disableColumnReorder:c}),N=l.useMemo(()=>{const C=[];return b&&C.push({field:"__reorder_col__"}),p&&C.push({field:"__expand_col__"}),m&&C.push({field:"__checkbox_col__"}),[...C,...x]},[x,m,p,b]);return{effectiveColumns:j,orderedColumns:x,visibleOrderedColumns:E,navigationColumns:N,columnWidths:I,effectiveColumnOrder:f,setInternalColumnOrder:w,columnReorderHandlers:M,handleColumnResize:S}}function fo(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:i,sortedUnpinnedRows:s,pagination:d}=n;return l.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,c=d?i:s,g=e.length,m=e.map((h,S)=>({row:h,rowIndex:S})),p=o.map((h,S)=>({row:h,rowIndex:g+c.length+S})),b=Math.max(0,a-g),v=Math.min(c.length,u-g+1),_=c.slice(b,v).map((h,S)=>({row:h,rowIndex:g+b+S})),j=[...m,..._,...p],I=new Set;return j.filter(h=>I.has(h.row.id)?!1:(I.add(h.row.id),!0))},[t,e,o,i,s,d])}function go(n){const{onRowsScrollEnd:t}=n,e=l.useRef({scrollTop:0,scrollLeft:0}),o=l.useRef(null),[i,s]=l.useState({scrollTop:0,scrollLeft:0});l.useEffect(()=>()=>{o.current!==null&&cancelAnimationFrame(o.current)},[]);const d=l.useCallback(a=>{const u=a.currentTarget;if(e.current={scrollTop:u.scrollTop,scrollLeft:u.scrollLeft},o.current!==null&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{o.current=null,s(e.current)}),t){const{scrollTop:c,scrollHeight:g,clientHeight:m}=u;g-c-m<100&&t({visibleTop:c,visibleBottom:c+m,viewportHeight:m})}},[t]);return{scrollTop:i.scrollTop,scrollLeft:i.scrollLeft,handleScroll:d}}function ho(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:i,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:u}=n,c=l.useRef(t);l.useLayoutEffect(()=>{c.current=t}),l.useEffect(()=>{if(!c.current)return;const g={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:i},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:u}};c.current(g)},[e,o,i,s,d,a,u])}const po={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,o)=>e+Number(o),0),avg:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e)));return t.length===0?null:t.reduce((e,o)=>e+Number(o),0)/t.length},count:n=>n.filter(t=>t!=null).length,min:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.min(...t):null},max:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.max(...t):null},unique:n=>new Set(n.filter(t=>t!=null)).size};function Ie(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function hn(n){const{rows:t,aggregationModel:e,isServerSide:o,dataSource:i,filterModel:s,sortModel:d,serverAggregationResults:a}=n,u=l.useMemo(()=>{if(o||Object.keys(e).length===0)return{};const h={};for(const[S,y]of Object.entries(e)){const w=po[y];if(!w){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const f=t.map(x=>x[S]);h[S]=w(f)}return h},[t,e,o]),[c,g]=l.useState({}),[m,p]=l.useState(!1),[b,v]=l.useState(null),_=l.useRef(0),j=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const h=++_.current;p(!0),v(null);try{const S=await i.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});h===_.current&&g(S)}catch(S){h===_.current&&(v(S),console.error("[useAggregation] Server aggregation error:",S))}finally{h===_.current&&p(!1)}},[i,e,s,d]);return l.useEffect(()=>{o&&i?.getAggregations&&!a&&j()},[j,o,i,a]),{aggregationResult:l.useMemo(()=>o?a&&Object.keys(a).length>0?a:c:u,[o,u,a,c]),isLoading:m,error:b}}function xo({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:i,checkboxSelection:s,hasDetailPanel:d,rowReordering:a}){return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(u=>{const c=t[u.field],g=e[u.field],m=o[u.field]??(typeof u.width=="number"?u.width:120);return r.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:m,minWidth:m,maxWidth:m,textAlign:u.align||"left"},children:c?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:c}),r.jsx("span",{className:"ogx__aggregation-value",children:Ie(g,c)})]}):null},u.field)})]})}function mo({noRowsLabel:n,width:t}){return r.jsxs("div",{className:"ogx__empty",style:{width:t},children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),r.jsx("span",{children:n})]})}function bo({error:n}){if(!n)return null;const t=n instanceof Error?n.message:typeof n=="string"?n:"An unexpected error occurred while loading the data.";return r.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[r.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),r.jsx("div",{className:"ogx-error-overlay__message",children:t}),r.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})}const lt=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...i})=>{const s=l.useRef(null),d=l.useCallback(u=>{s.current=u,typeof o=="function"?o(u):o&&(o.current=u)},[o]);l.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),r.jsxs("span",{className:"ogx-checkbox__box",children:[i.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function wo(n){const{field:t,currentWidth:e,onResize:o,minWidth:i=50,maxWidth:s=1e3}=n,[d,a]=l.useState(!1),u=l.useRef(0),c=l.useRef(0),g=l.useCallback(b=>{b.preventDefault(),b.stopPropagation(),a(!0),u.current=b.clientX,c.current=e;let v=0;const _=16,j=h=>{const S=h.clientX-u.current,y=Math.max(i,Math.min(s,c.current+S)),w=Date.now();w-v>=_&&(o(t,y),v=w)},I=h=>{a(!1);const S=h.clientX-u.current,y=Math.max(i,Math.min(s,c.current+S));o(t,y),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",I)},[t,e,o,i,s]),m=l.useCallback(b=>{b.preventDefault(),b.stopPropagation()},[]),p=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:p,onMouseDown:g,onClick:b=>b.stopPropagation(),onDragStart:b=>{b.preventDefault(),b.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function $e(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:r.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function De(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function vo(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function _o(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),r.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Co(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function yo(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function ko(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),r.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function So(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),r.jsx("polyline",{points:"11 8 4 12 11 16"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function jo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),r.jsx("polyline",{points:"13 8 20 12 13 16"}),r.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Eo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function No({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:i,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:u}){const c=l.useRef(null),[g,m]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!u||!c.current)return;const w=u.getBoundingClientRect(),f=c.current.getBoundingClientRect(),x=window.innerWidth,E=window.innerHeight,M=8;let N=w.left;N+f.width+M>x&&(N=x-f.width-M),N<M&&(N=M);let C=w.bottom+4;C+f.height+M>E&&(C=w.top-f.height-4),m({position:"fixed",zIndex:1300,top:C,left:N,visibility:"visible"})},[u]),l.useEffect(()=>{function w(x){c.current&&!c.current.contains(x.target)&&u&&!u.contains(x.target)&&a()}function f(x){x.key==="Escape"&&a()}return document.addEventListener("mousedown",w),document.addEventListener("keydown",f),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",f),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[u,a]);const p=w=>{e?.(n.field,w),a()},b=()=>{o?.(n.field),a()},v=w=>{i?.(n.field,w),a()},_=t?.find(w=>w.field===n.field)?.sort,j=_==null,I=s?.left?.includes(n.field)??!1,h=s?.right?.includes(n.field)??!1,S=!I&&!h,y=n.headerName||n.field;return We.createPortal(r.jsxs("div",{ref:c,className:"ogx-column-menu",style:g,role:"menu","aria-label":`Column options for ${y}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${_==="asc"?" ogx-menu-item--active":""}`,onClick:()=>p("asc"),role:"menuitemradio","aria-checked":_==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_==="asc"?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(_o,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${_==="desc"?" ogx-menu-item--active":""}`,onClick:()=>p("desc"),role:"menuitemradio","aria-checked":_==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_==="desc"?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Co,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>p(null),role:"menuitemradio","aria-checked":j,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(yo,{})}),"Unsort"]}),r.jsx("div",{className:"ogx-menu-divider"})]}),r.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),r.jsxs("button",{className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>v("left"),role:"menuitemradio","aria-checked":I,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(So,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${h?" ogx-menu-item--active":""}`,onClick:()=>v("right"),role:"menuitemradio","aria-checked":h,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(jo,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>v(null),role:"menuitemradio","aria-checked":S,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Eo,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${y} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(ko,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),a()},role:"menuitem","aria-label":"Manage all columns",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(vo,{})}),"Manage columns"]})]}),u?.closest(".ogx-theme-provider")||document.body)}function Mo(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:r.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Io(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:r.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function pn(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...pn(e));return t}function Po(n){let t=0;function e(o,i){t=Math.max(t,i);for(const s of o.children)typeof s!="string"&&e(s,i+1)}return n.forEach(o=>e(o,1)),t}function To(n,t,e){function o(a,u,c){if(!pn(a).includes(u))return null;if(c===e)return a;for(const g of a.children)if(typeof g!="string"){const m=o(g,u,c+1);if(m)return m}return null}const i=new Map;for(const a of t){let u=null;for(const c of n)if(u=o(c,a.field,0),u)break;i.set(a.field,u)}const s=[];let d=0;for(;d<t.length;){const a=t[d],u=i.get(a.field)??null,c=a.width;if(!u)s.push({key:`fg-${a.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let g=0,m=d;for(;m<t.length&&i.get(t[m].field)===u;)g+=t[m].width,m++;s.push({key:`${u.groupId}-${e}`,label:u.headerName,width:g,isGroup:!0}),d=m}}return s}function xn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:i=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:u,sortModel:c=[],onColumnResize:g,columnWidths:m={},pinnedColumns:p,hasDetailPanel:b=!1,pinCheckboxColumn:v=!0,pinExpandColumn:_=!0,rowReordering:j=!1,aggregationModel:I,draggedColumn:h,dragOverColumn:S,onDragStart:y,onDragOver:w,onDragEnd:f,onDrop:x,focusedCell:E,onHeaderClick:M,onHideColumn:N,onPinColumn:C,onManageColumns:P}=n,O=l.useRef({}),[T,A]=l.useState(null),H=L=>Z=>{Z.stopPropagation(),A({colDef:L,anchorEl:Z.currentTarget})},R=()=>{A(null)};l.useLayoutEffect(()=>{if(E?.id==="HEADER"){const L=O.current[E.field];L&&L.focus()}},[E]);const U=L=>()=>{if(L.sortable===!1||!u)return;const Z=c.find(J=>J.field===L.field);let Q="asc";Z&&(Z.sort==="asc"?Q="desc":Q=null),u(L.field,Q)},q=L=>{const Z=c.find(Q=>Q.field===L);return Z?r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${Z.sort}`,"aria-hidden":"true"}):null},K=l.useMemo(()=>fn(t,m,p,i,v,b,_,j),[t,m,p,i,v,b,_,j]),k=o?Po(o):0,W=(e??t).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),D=(j?48:0)+(b?48:0)+(i?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[k>0&&Array.from({length:k},(L,Z)=>{const Q=To(o,W,Z);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[D>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:D,minWidth:D,flexShrink:0},role:"columnheader"}),Q.map(J=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${J.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:J.width,minWidth:J.width,flexShrink:0},title:J.isGroup?J.label:void 0,children:J.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:J.label})},J.key))]},`ogx-grp-${Z}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[j&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),b&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${_?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:_?"sticky":void 0,left:_?j?48:0:void 0,zIndex:_?5:void 0}}),i&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${v?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:v?"sticky":void 0,left:v?(j?48:0)+(b&&_?48:0):void 0},children:r.jsx(lt,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:d,onChange:L=>a?.(L.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:E?.id==="HEADER"&&E.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{O.current.__checkbox_col__=L}})}),t.map((L,Z)=>{if(L.isSpacer)return r.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const Q=L.sortable!==!1,J=c.some(fe=>fe.field===L.field),ue=L.resizable!==!1,$=pt(L.field,p),ae=$!==null,ie=h===L.field,pe=S===L.field,le=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,Q&&"ogx__header-cell--sortable",J&&"ogx__header-cell--sorted",ae&&"ogx__header-cell--pinned",ae&&`ogx__header-cell--pinned-${$}`,ie&&"ogx__header-cell--dragging",pe&&"ogx__header-cell--drag-over",E?.id==="HEADER"&&E.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),z=m[L.field]??L.width??100,X={width:z,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:ae?"sticky":"relative",zIndex:L.zIndex,opacity:ie?.5:1};if(ae&&$){const fe=K[L.field];$==="left"?X.left=fe:X.right=fe}const ee=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:Z}):L.headerName||L.field,se=fe=>{if(fe.target.closest(".ogx-column-resize-handle")){fe.stopPropagation();return}M?.(L.field),Q&&U(L)()},de=y?y(L.field):void 0,je=w?w(L.field):void 0,Ve=x?x(L.field):void 0;return r.jsxs("div",{className:le,style:X,onClick:se,role:"columnheader",draggable:!!y,onDragStart:de,onDragOver:je,onDragEnd:f,onDrop:Ve,"aria-sort":Q?J?c.find(fe=>fe.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":Z+1+(i?1:0),"data-field":L.field,tabIndex:-1,ref:fe=>{O.current[L.field]=fe},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[ie&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Io,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:ee}),I&&I[L.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:I[L.field]})]}),Q&&q(L.field),!L.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:H(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Mo,{})})]}),ue&&g&&r.jsx(wo,{field:L.field,currentWidth:z,onResize:g,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),T&&r.jsx(No,{colDef:T.colDef,sortModel:c,onSort:u,onHide:N,onPin:C,pinnedColumns:p,onManageColumns:P,onClose:R,anchorEl:T.anchorEl})]})]})}const st=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:i="",children:s,...d})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",i].filter(Boolean).join(" ");return r.jsx("button",{className:a,disabled:o,...d,children:s})};function mn(n){const{page:t,pageSize:e,rowCount:o,onPageChange:i,onPageSizeChange:s,pageSizeOptions:d=[10,25,50,100],showFirstButton:a=!0,showLastButton:u=!0}=n,c=Math.max(1,Math.ceil(o/e)),g=Math.min(t,c-1),m=g*e,p=Math.min(m+e,o),b=o===0?0:`${m+1}–${p}`,v=()=>{i(0)},_=()=>{i(Math.max(0,g-1))},j=()=>{i(Math.min(c-1,g+1))},I=()=>{i(c-1)},h=w=>{const f=parseInt(w.target.value,10);s(f)},S=g===0,y=g>=c-1;return r.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[r.jsxs("div",{className:"ogx-pagination__page-size",children:[r.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),r.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:h,"aria-label":"Rows per page",children:d.map(w=>r.jsx("option",{value:w,children:w},w))})]}),r.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[b," of ",o]}),r.jsxs("div",{className:"ogx-pagination__actions",children:[a&&r.jsx(st,{variant:"text",size:"small",onClick:v,disabled:S,"aria-label":"Go to first page",title:"First page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),r.jsx(st,{variant:"text",size:"small",onClick:_,disabled:S,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",g+1," of ",c]}),r.jsx(st,{variant:"text",size:"small",onClick:j,disabled:y,"aria-label":"Go to next page",title:"Next page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&r.jsx(st,{variant:"text",size:"small",onClick:I,disabled:y,"aria-label":"Go to last page",title:"Last page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Lo(n,t,e={}){const o=new Map,i=[];n.forEach(a=>{o.set(a.id,a),i.push(a.id)});const s=new Map,d=[];return t.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:o,allRows:i},columns:{all:t,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Ro(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,i=new Map,s=[];return o.forEach(d=>{i.set(d.id,d),s.push(d.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(i=>{e.set(i.field,i),o.push(i.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function Oo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:i=56,columnVisibilityModel:s,initialState:d}=n,[a]=l.useState(()=>Lo(t,e,s)),[u,c]=l.useReducer(Ro,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:o,headerHeight:i}}),g=l.useRef(u);l.useLayoutEffect(()=>{g.current=u});const m=l.useRef(t);l.useEffect(()=>{t!==m.current&&(m.current=t,c({type:"SET_ROWS",payload:t}))},[t]);const p=l.useCallback((x,E)=>{c({type:"SET_ROWS",payload:x,preserveRowCount:E})},[]),b=l.useCallback(x=>{c({type:"SET_COLUMNS",payload:x})},[]),v=l.useCallback(x=>{c({type:"SET_SORT_MODEL",payload:x})},[]),_=l.useCallback(x=>{c({type:"SET_FILTER_MODEL",payload:x})},[]),j=l.useCallback(x=>{c({type:"SET_PAGINATION_MODEL",payload:x})},[]),I=l.useCallback(x=>{c({type:"SET_SELECTION",payload:x})},[]),h=l.useCallback((x,E)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:x,viewportHeight:E}})},[]),S=l.useCallback(x=>{c({type:"SET_DATASOURCE_LOADING",payload:x})},[]),y=l.useCallback(x=>{c({type:"SET_DATASOURCE_ERROR",payload:x})},[]),w=l.useCallback(x=>{c({type:"SET_ROW_COUNT",payload:x})},[]),f=l.useRef({getRow:x=>g.current.rows.idRowsLookup.get(x)||null,getAllRows:()=>Array.from(g.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(g.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:x=>g.current.columns.lookup.get(x)||null,getAllColumns:()=>g.current.columns.all,getVisibleColumns:()=>g.current.columns.all,selectRow:(x,E=!0)=>{const M=new Set(g.current.selection.selectedRows);E?M.add(x):M.delete(x),I(M)},selectRows:(x,E=!0)=>{const M=new Set(g.current.selection.selectedRows);x.forEach(N=>{E?M.add(N):M.delete(N)}),I(M)},getSelectedRows:()=>Array.from(g.current.selection.selectedRows),sortColumn:(x,E)=>{if(E===null)v(g.current.sorting.sortModel.filter(M=>M.field!==x));else{const M=g.current.sorting.sortModel.findIndex(N=>N.field===x);if(M>=0){const N=[...g.current.sorting.sortModel];N[M]={field:x,sort:E},v(N)}else v([...g.current.sorting.sortModel,{field:x,sort:E}])}},getSortModel:()=>g.current.sorting.sortModel,setFilterModel:_,getFilterModel:()=>g.current.filter.filterModel,setPage:x=>{j({...g.current.pagination.paginationModel,page:x})},setPageSize:x=>{j({...g.current.pagination.paginationModel,pageSize:x,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:u,dispatch:c,apiRef:f,setRows:p,setColumns:b,setSortModel:v,setFilterModel:_,setPaginationModel:j,setSelection:I,setDimensions:h,setDataSourceLoading:S,setDataSourceError:y,setRowCount:w}}function Wo(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:i=!1}=n,[s,d]=l.useState(null),[a,u]=l.useState(null),c=l.useCallback(v=>o?o(v):v.id,[o]),g=l.useCallback(v=>_=>{i&&(d(v),_.dataTransfer.effectAllowed="move")},[i]),m=l.useCallback(v=>_=>{!i||!s||(_.preventDefault(),_.dataTransfer.dropEffect="move",a!==v&&u(v))},[i,s,a]),p=l.useCallback(()=>{d(null),u(null)},[]),b=l.useCallback(v=>_=>{if(_.preventDefault(),!s||!t){p();return}const j=e.findIndex(h=>c(h)===s),I=e.findIndex(h=>c(h)===v);j!==-1&&I!==-1&&j!==I&&t({row:e[j],oldIndex:j,targetIndex:I}),p()},[s,t,e,c,p]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?g:void 0,onDragOver:i?m:void 0,onDragEnd:i?p:void 0,onDrop:i?b:void 0}}function Fo(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:u}=n,{treeNodes:c,rootIds:g,groupingRows:m}=l.useMemo(()=>{if(!i||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,w=[],f=[],x=new Map,E=M=>M.join("/");return t.forEach(M=>{const N=e(M),C=o(M),P=E(C);x.set(P,N),y.set(N,{id:N,parentId:null,depth:C.length-1,groupingKey:C[C.length-1],isExpanded:!1,children:[],serverChildrenCount:M.serverChildrenCount})}),t.forEach(M=>{const N=e(M),C=o(M);if(C.length===1){w.push(N);return}const P=T=>{if(T.length<=1)return;const A=T.slice(0,-1),H=E(A);let R=x.get(H);if(R===void 0&&(R=`auto-group-${H}`,!y.has(R))){const U=A[A.length-1];y.set(R,{id:R,parentId:null,depth:A.length-1,groupingKey:U,isExpanded:!1,children:[],label:U}),x.set(H,R);const q={id:R,name:U,_isGroupRow:!0};f.push(q),A.length===1&&w.push(R),P(A)}return R},O=P(C);if(O!==void 0){const T=y.get(O),A=y.get(N);T&&A&&(A.parentId=O,T.children=T.children||[],T.children.includes(N)||T.children.push(N))}}),f.forEach(M=>{const N=M.id,C=y.get(N);if(!C)return;const O=N.replace("auto-group-","").split("/");if(O.length>1){const T=O.slice(0,-1),A=E(T),H=x.get(A);if(H&&y.has(H)){C.parentId=H;const R=y.get(H);R&&(R.children=R.children||[],R.children.includes(N)||R.children.push(N))}}}),{treeNodes:y,rootIds:w,groupingRows:f}},[t,o,i,e]),p=l.useMemo(()=>{if(!i)return new Set;const y=new Set;return c.forEach(w=>{w.children&&w.children.length>0&&(s===-1||w.depth<s)&&y.add(w.id)}),y},[c,i,s]),[b,v]=l.useState(new Set);l.useEffect(()=>{p.size>0&&v(p)},[p]);const _=l.useCallback(y=>{v(w=>{const f=new Set(w),x=!f.has(y);if(f.has(y)?f.delete(y):f.add(y),x&&u){const E=c.get(y);E&&u(E)}return f})},[c,u]),j=l.useCallback(()=>{if(!i)return null;const y=new Map;t.forEach(P=>y.set(e(P),P)),m.forEach(P=>y.set(P.id,P));const w=P=>Ft(P,d),f=new Map,x=P=>{if(f.has(P))return f.get(P);const O=y.get(P);if(!O)return!1;if(w(O))return f.set(P,!0),!0;const A=c.get(P);return A&&A.children&&A.children.some(R=>x(R))?(f.set(P,!0),!0):(f.set(P,!1),!1)},E=(P,O)=>{if(!a||a.length===0)return 0;const T=y.get(P),A=y.get(O);if(!T||!A)return 0;for(const H of a){const R=T[H.field],U=A[H.field],q=At(R,U,H.sort);if(q!==0)return q}return 0},M=[],N=new Set,C=P=>{const O=P.filter(T=>x(T));O.sort(E),O.forEach(T=>{if(N.has(T))return;const A=y.get(T),H=c.get(T);if(A&&H){N.add(T);const R={...A,_treeDepth:H.depth,_isExpanded:b.has(T),_hasChildren:!!(H.children&&H.children.length>0||H.serverChildrenCount&&H.serverChildrenCount>0),_descendantCount:H.children?H.children.length:0};M.push(R),b.has(T)&&H.children&&H.children.length>0&&C(H.children)}})};return C(g),M},[i,t,m,g,c,b,d,a,e]),I=l.useCallback(y=>b.has(y),[b]),h=l.useCallback(y=>c.get(y),[c]),S=l.useCallback(y=>{const w=[];let f=y;for(;f!==null;){const x=c.get(f);if(!x)break;w.unshift(x.groupingKey),f=x.parentId}return w},[c]);return l.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:_,isGroupExpanded:I,getVisibleRows:j,getNode:h,getNodePath:S}),[c,m,_,I,j,h,S])}const Ao=n=>n?.depth===-1?"footer":"inline";function zo(n){const{rows:t,getRowId:e,rowGroupingModel:o=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:u=Ao}=n,[c,g]=l.useState(new Set),{treeNodes:m,rootIds:p,groupingRows:b}=l.useMemo(()=>{const h=new Map,S=new Map,y=[];if(o.length===0)return{treeNodes:h,rootIds:y,groupingRows:S};const w=(E,M,N)=>`auto-group-${E}-${M}-${N||"root"}`,f=(E,M,N)=>{if(M>=o.length)return E.map(T=>{const A=e(T);return h.set(A,{id:A,parentId:N,depth:M,groupingKey:"",isExpanded:!1}),A});const C=o[M],P=new Map;E.forEach(T=>{const A=T[C],H=String(A);P.has(H)||P.set(H,[]),P.get(H).push(T)});const O=[];return P.forEach((T,A)=>{const R=T[0][C],U=w(C,A,N);O.push(U);const q={};i&&Object.entries(i).forEach(([F,V])=>{const G=T.map(D=>D[F]);if(V==="sum")q[F]=G.reduce((D,L)=>D+(Number(L)||0),0);else if(V==="min")q[F]=Math.min(...G.map(D=>Number(D)||0));else if(V==="max")q[F]=Math.max(...G.map(D=>Number(D)||0));else if(V==="avg"){const D=G.reduce((L,Z)=>L+(Number(Z)||0),0);q[F]=G.length?D/G.length:0}else V==="count"&&(q[F]=G.length)});const K={[C]:R,...q,id:U};S.set(U,K);const k={id:U,parentId:N,depth:M,groupingKey:A,groupingField:C,groupingValue:R,aggregatedValues:q,isExpanded:!1,children:[],label:`${C}: ${String(R)}`};k.aggregationPosition=u(k),h.set(U,k);const B=f(T,M+1,U);h.get(U).children=B;const W=T.length;h.get(U).descendantCount=W}),O},x=f(t,0,null);return y.push(...x),{treeNodes:h,rootIds:y,groupingRows:S}},[t,o,i,e,u]);l.useEffect(()=>{if(s===-1){const h=new Set;m.forEach((S,y)=>{S.children&&S.children.length>0&&h.add(y)}),g(h)}else if(s>0){const h=new Set;m.forEach((S,y)=>{S.depth<s&&S.children&&S.children.length>0&&h.add(y)}),g(h)}else g(new Set)},[o,s,m]);const v=l.useCallback(h=>{g(S=>{const y=new Set(S);return y.has(h)?y.delete(h):y.add(h),y})},[]),_=l.useCallback(h=>c.has(h),[c]),j=l.useCallback(()=>{if(o.length===0)return null;const h=[],S=new Set,y=new Map;t.forEach(E=>y.set(e(E),E));const w=E=>{const M=m.get(E);if(!M)return!1;if(!M.children||M.children.length===0){const N=y.get(E);return!(!N||d&&!Ft(N,d))}return M.children.some(N=>w(N))},f=E=>{let M=E;d&&(M=E.filter(w)),a&&a.length>0&&M.sort((N,C)=>{const P=b.get(N)||y.get(N),O=b.get(C)||y.get(C);if(!P||!O)return 0;for(const T of a){const A=P[T.field],H=O[T.field],R=At(A,H,T.sort);if(R!==0)return R}return 0}),M.forEach(N=>{if(S.has(N))return;const C=m.get(N),P=C?.children&&C.children.length>0,O=P?b.get(N):y.get(N);if(O&&C){S.add(N);const T={...O,_treeDepth:C.depth,_isExpanded:c.has(N),_hasChildren:P,_groupingField:C.groupingField,_groupingValue:C.groupingValue,_descendantCount:C.descendantCount};h.push(T),x.has(N)&&P&&f(C.children)}})},x=c;return f(p),h},[t,e,m,p,b,d,a,c,o]),I=l.useCallback(h=>m.get(h),[m]);return l.useMemo(()=>({treeNodes:m,groupingRows:b,toggleExpansion:v,isGroupExpanded:_,getVisibleRows:j,getNode:I}),[m,b,v,_,j,I])}function Bo(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:i,onRowChange:s}=n,[d,a]=l.useState(null),u=l.useRef(null),c=l.useCallback(b=>{a(b),u.current=typeof b=="function"?b(u.current):b},[]),g=l.useCallback(b=>{c({id:b.id,field:b.field,value:b.value,originalValue:b.value})},[c]),m=l.useCallback(async b=>{const v=u.current;if(!v)return;if(b?.cancel){c(null);return}const{id:_,field:j,value:I,originalValue:h}=v;if(I===h){c(null);return}const S=t.find(w=>e(w)===_);if(!S){c(null);return}const y={...S,[j]:I};try{if(o){const w=await o(y,S);s?.(w)}else s?.(y);c(null)}catch(w){i?.(w)}},[c,t,e,o,s,i]),p=l.useCallback(b=>{d&&d.id===b.id&&d.field===b.field&&c(v=>v?{...v,value:b.value}:null)},[d,c]);return{editingCell:d,startCellEdit:g,stopCellEdit:m,setEditCellValue:p}}function $o(n,t,e){const[o,i]=l.useState(new Map),[s,d]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),u=l.useCallback((_,j)=>o.get(_)?.[j],[o]),c=l.useCallback((_,j,I,h,S)=>{const y=new Map(o);for(let w=h;w<S;w++){const f=t[w];if(!f)continue;let x=1;if(f.colSpan)if(typeof f.colSpan=="function"){const M={row:j,value:j[f.field],field:f.field,colDef:f,rowIndex:I,colIndex:w};x=f.colSpan(M)}else x=f.colSpan;if(x<=1){He(y,_,f.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[f.field]||100}});continue}let E=e[f.field]||100;for(let M=1;M<x;M++)if(w+M<S){const N=t[w+M];N&&(E+=e[N.field]||100,He(y,_,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+x-1,t.length-1)}))}He(y,_,f.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),w+=x-1}i(y)},[o,t,e]),g=l.useCallback((_,j)=>{const I={},h={},S={};t.forEach((y,w)=>{if(y.rowSpan)for(let f=_;f<j;f++){const x=n[f];if(!x||h[x.id]?.[y.field])continue;const E=y.valueGetter?y.valueGetter({row:x,field:y.field,value:x[y.field]}):x[y.field];let M=1;if(typeof y.rowSpan=="function"){const N={row:x,value:E,field:y.field,colDef:y,rowIndex:f,colIndex:w};M=y.rowSpan(N)}else typeof y.rowSpan=="number"&&(M=y.rowSpan);if(M>1){I[x.id]||(I[x.id]={}),I[x.id][y.field]=M;for(let N=1;N<M;N++){const C=f+N;if(C<j&&n[C]){const P=n[C];h[P.id]||(h[P.id]={}),h[P.id][y.field]=!0,S[C]||(S[C]={}),S[C][y.field]=f}}}}}),d({caches:{spannedCells:I,hiddenCells:h,hiddenCellOriginMap:S},processedRange:{firstRowIndex:_,lastRowIndex:j}})},[n,t]),m=l.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const _=new Map;n.forEach((S,y)=>{for(let w=0;w<t.length;w++){const f=t[w];if(!f)continue;let x=1;if(f.colSpan)if(typeof f.colSpan=="function"){const M={row:S,value:S[f.field],field:f.field,colDef:f,rowIndex:y,colIndex:w};x=f.colSpan(M)}else x=f.colSpan;if(x<=1){const M=e[f.field]||(typeof f.width=="number"?f.width:100);He(_,S.id,f.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:M}});continue}let E=e[f.field]||(typeof f.width=="number"?f.width:100);for(let M=1;M<x;M++)if(w+M<t.length){const N=t[w+M];if(N){const C=e[N.field]||(typeof N.width=="number"?N.width:100);E+=C,He(_,S.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+x-1,t.length-1)})}}He(_,S.id,f.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),w+=x-1}}),i(_);const j={},I={},h={};t.forEach((S,y)=>{if(S.rowSpan)for(let w=0;w<n.length;w++){const f=n[w];if(!f||I[f.id]?.[S.field])continue;const x=S.valueGetter?S.valueGetter({row:f,field:S.field,value:f[S.field]}):f[S.field];let E=1;if(typeof S.rowSpan=="function"){const M={row:f,value:x,field:S.field,colDef:S,rowIndex:w,colIndex:y};E=S.rowSpan(M)}else typeof S.rowSpan=="number"&&(E=S.rowSpan);if(E>1){j[f.id]||(j[f.id]={}),j[f.id][S.field]=E;for(let M=1;M<E;M++){const N=w+M;if(N<n.length&&n[N]){const C=n[N];I[C.id]||(I[C.id]={}),I[C.id][S.field]=!0,h[N]||(h[N]={}),h[N][S.field]=w}}}}}),d({caches:{spannedCells:j,hiddenCells:I,hiddenCellOriginMap:h},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const p=l.useCallback(()=>s.caches.spannedCells,[s]),b=l.useCallback(()=>s.caches.hiddenCells,[s]),v=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:u,calculateColSpan:c,rowSpanningState:s,calculateRowSpan:g,resetRowSpan:m,getSpannedCells:p,getHiddenCells:b,getHiddenCellOriginMap:v}}function He(n,t,e,o){let i=n.get(t);i||(i={},n.set(t,i)),i[e]=o}function Do(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:i,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:u,setRows:c,setRowCount:g,setDataSourceLoading:m,setDataSourceError:p,onAggregationResults:b}=n,v=l.useRef(null),_=l.useRef(0),j=l.useCallback(async()=>{if(!t)return;const h=++_.current;m(!0),p(null);const S=i.page*i.pageSize,y=S+i.pageSize,w={startRow:S,endRow:y,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:u};try{const f=await t.getRows(w);if(h!==_.current)return;let x=!1;if(s==="infinite"){const E=v.current;if(E){const M=JSON.stringify(E.sortModel)!==JSON.stringify(e),N=JSON.stringify(E.filterModel)!==JSON.stringify(o),C=E.pageSize!==i.pageSize;!M&&!N&&!C&&i.page>E.page&&(x=!0)}}c(x?E=>[...E,...f.rows]:f.rows,!0),f.aggregationResults&&b&&b(f.aggregationResults),f.rowCount!==void 0&&g(f.rowCount),v.current={sortModel:e,filterModel:o,page:i.page,pageSize:i.pageSize}}catch(f){h===_.current&&(p(f),console.error("Data Source Error:",f))}finally{h===_.current&&m(!1)}},[t,i.page,i.pageSize,e,o,s,u,b,c,g,m,p]);l.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const S=setTimeout(()=>{j()},300);return()=>clearTimeout(S)}},[j,t,s,d,a]);const I=l.useCallback(async(h,S)=>{if(t){m(!0);try{const y=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:S});y.rows.length>0&&c(w=>{const f=new Set(w.map(E=>E.id)),x=y.rows.filter(E=>!f.has(E.id));return[...w,...x]})}catch(y){p(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[t,e,o,c,m,p]);return{fetchRows:j,fetchChildren:I}}const bn="\0",at="";function Ho(n,t){const e=n.filter(o=>o!=null&&!isNaN(o));if(e.length===0)return null;switch(t){case"sum":return e.reduce((o,i)=>o+i,0);case"avg":return e.reduce((o,i)=>o+i,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function xt(n,t){return t.map(e=>String(n[e]??"")).join(bn)}function zt(n,t,e,o){return o?`${n}${at}${t}${at}${e}`:`${t}${at}${e}`}function wn(n,t,e,o){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return i;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return i;const u=d.length>0,c=new Map(t.map(h=>[h.field,h])),g=new Set;for(const h of n)g.add(xt(h,d));const m=Array.from(g).sort(),p=new Map;for(const h of n){const S=xt(h,s);if(!p.has(S)){const x={};for(const E of s)x[E]=h[E];p.set(S,{labelValues:x,bucket:new Map})}const y=p.get(S),w=xt(h,d);y.bucket.has(w)||y.bucket.set(w,new Map);const f=y.bucket.get(w);for(const x of a){const E=h[x.field];f.has(x.field)||f.set(x.field,[]),E!=null&&!isNaN(Number(E))&&f.get(x.field).push(Number(E))}}let b=0;const v=[];for(const[,h]of p){const S={id:b++,...h.labelValues};for(const y of m){const w=h.bucket.get(y);for(const f of a){const x=zt(y,f.field,f.aggFn,u),E=w?.get(f.field)??[];S[x]=E.length>0?Ho(E,f.aggFn):null}}v.push(S)}const _=new Map;for(const h of n){const S=xt(h,d);for(const y of a){if(y.aggFn!=="avg"&&y.aggFn!=="min"&&y.aggFn!=="max")continue;const w=`${S}${at}${y.field}`;_.has(w)||_.set(w,[]);const f=h[y.field];f!=null&&!isNaN(Number(f))&&_.get(w).push(Number(f))}}const j={id:"__pivot_grand_total__"};for(let h=0;h<s.length;h++)j[s[h]]=h===0?"Grand Total":"";for(const h of m)for(const S of a){const y=zt(h,S.field,S.aggFn,u),w=v.map(x=>x[y]).filter(x=>x!=null&&!isNaN(Number(x))).map(Number);if(w.length===0){j[y]=null;continue}const f=`${h}${at}${S.field}`;switch(S.aggFn){case"sum":case"count":j[y]=w.reduce((x,E)=>x+E,0);break;case"avg":{const x=_.get(f)??[];j[y]=x.length>0?x.reduce((E,M)=>E+M,0)/x.length:null;break}case"min":j[y]=Math.min(..._.get(f)??w);break;case"max":j[y]=Math.max(..._.get(f)??w);break}}v.push(j);const I=[];for(const h of s){const S=c.get(h);I.push({field:h,headerName:S?.headerName??h,width:S?.width??140,sortable:!0})}for(const h of m){const S=u?h.split(bn).map((y,w)=>{const f=c.get(d[w]);return f?.headerName?`${f.headerName}: ${y}`:y}).join(" / "):"";for(const y of a){const w=c.get(y.field),f=zt(h,y.field,y.aggFn,u),x=y.headerName??w?.headerName??y.field,E=S?`${S} — ${x} (${y.aggFn})`:`${x} (${y.aggFn})`;I.push({field:f,headerName:E,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const N=Number(M);return y.aggFn==="avg"?N.toFixed(2):y.aggFn==="count"?N.toLocaleString():w?.valueFormatter?w.valueFormatter({value:M,row:{},field:y.field}):N.toLocaleString()}})}}return{pivotRows:v,pivotColumns:I,colKeys:m,isValid:!0}},[n,t,e,o])}function Go(n){const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(t),t.focus(),t.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(t)}return e}async function Vo(n){let t=!1;try{t=Go(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(t)return;throw e}else if(!t)throw new Error("Clipboard API not available and fallback failed.")}function Uo(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:i}=n,s=l.useCallback(async()=>{if(t.size===0)return;const a=o().filter(p=>t.has(i(p)));if(a.length===0)return;const u=e.filter(p=>!p.field.startsWith("__")),c=u.map(p=>p.headerName||p.field).join(" "),g=a.map(p=>u.map(b=>{const v=p[b.field];return b.valueFormatter?b.valueFormatter({value:v,row:p,field:b.field}):v??""}).join(" ")).join(`
7
7
  `),m=`${c}
8
- ${p}`;try{await hr(m)}catch(b){console.error("[OpenGridX] Failed to copy to clipboard:",b)}},[o,e,r,l]);return i.useEffect(()=>{const d=s=>{if(!(s.ctrlKey||s.metaKey)||s.key!=="c")return;const f=document.activeElement,c=f?.tagName.toLowerCase(),p=f?.type;c==="input"&&p!=="checkbox"&&p!=="radio"||c==="textarea"||c==="select"||f?.isContentEditable||a()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a]),{copySelectedRows:a}}function xr(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function mr(){return n.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),n.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function An(t){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d}=t,[s,f]=i.useState(""),[c,p]=i.useState(null),m=i.useRef(null),x=i.useMemo(()=>o.filter(g=>g.hideable!==!1),[o]).every(g=>e.has(g.field)),w=i.useMemo(()=>{if(!s)return o;const g=s.toLowerCase();return o.filter(v=>(v.headerName||v.field).toLowerCase().includes(g))},[o,s]),h=g=>{g.target.checked?l():a()},j=g=>v=>{m.current=g,v.dataTransfer.effectAllowed="move",v.dataTransfer.setDragImage(v.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=g=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",g!==m.current&&p(g)},k=()=>{p(null)},E=g=>v=>{v.preventDefault();const N=m.current;p(null),m.current=null,N&&N!==g&&d&&d(N,g)},y=()=>{p(null),m.current=null};return n.jsxs("div",{className:"ogx-column-visibility-panel",children:[n.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:n.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[n.jsx(xr,{}),n.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:s,onChange:g=>f(g.target.value)})]})}),n.jsx("div",{className:"ogx-column-visibility-panel__list",children:w.map(g=>{const v=e.has(g.field),N=g.hideable!==!1,S=c===g.field,I=!!d&&!s;return n.jsxs("div",{className:["ogx-column-visibility-panel__item",!N&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:I,onDragOver:I?P(g.field):void 0,onDragLeave:I?k:void 0,onDrop:I?E(g.field):void 0,onDragEnd:I?y:void 0,children:[I&&n.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:j(g.field),title:"Drag to reorder",children:n.jsx(mr,{})}),n.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:N?"pointer":"not-allowed"},children:[n.jsx(kt,{checked:v,onChange:M=>r(g.field,M.target.checked),disabled:!N}),n.jsx("span",{className:"ogx-column-visibility-panel__label",children:g.headerName||g.field})]})]},g.field)})}),n.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[n.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[n.jsx(kt,{checked:x,onChange:h}),n.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),n.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:l,children:"Reset"})]})]})}function br(t){const{rows:o,columns:e,getRowId:r,rowHeight:l=52,headerHeight:a=56,autoHeight:d=!1,checkboxSelection:s=!1,rowSelectionModel:f,onRowSelectionModelChange:c,onRowClick:p,onCellClick:m,filterModel:b,onFilterModelChange:x,sortModel:w,onSortModelChange:h,pagination:j=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:k,pageSizeOptions:E=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:g,pinnedRows:v,getDetailPanelContent:N,getDetailPanelHeight:S,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:M,pinCheckboxColumn:C=!0,pinExpandColumn:W=!0,disableColumnReorder:Y=!1,columnOrder:F,onColumnOrderChange:D,height:K,rowReordering:O=!1,onRowOrderChange:V,loading:J=!1,treeData:ee=!1,getTreeDataPath:_,defaultGroupingExpansionDepth:G,rowGroupingModel:B,aggregationModel:z,onAggregationModelChange:L,getAggregationPosition:X,isCellEditable:H,processRowUpdate:R,onProcessRowUpdateError:re,dataSource:Z,sortingMode:se="client",filterMode:me="client",paginationMode:U="client",rowCount:pe,slots:fe,slotProps:je,pivotMode:ge=!1,pivotModel:be,onPivotModelChange:Ce,className:Ge="",style:$,onRowsScrollEnd:q,ariaLabel:te,initialState:he,onStateChange:de,columnVisibilityModel:ct,onColumnVisibilityModelChange:At,listView:Ve=!1,listViewColumn:ot,columnGroupingModel:Re,noRowsLabel:oe="No Data",apiRef:Ee}=t,ri=i.useMemo(()=>({items:[]}),[]),We=b||ri,[ii,li]=i.useState(()=>he?.sorting?.sortModel??[]),sn=w!==void 0,Ae=sn?w:ii,si=i.useMemo(()=>[],[]),an=B||si,dn=z!==void 0,Vn=i.useRef(fe?.toolbar);Vn.current=fe?.toolbar;const ai=i.useRef(u=>{const T=Vn.current;return T?T(u):null}).current,[di,ci]=i.useState(()=>z??{}),ze=dn?z:di,ui=i.useCallback(u=>{dn||ci(u),L?.(u)},[dn,L]),[fi,gi]=i.useState(()=>he?.columns?.columnVisibilityModel??{}),cn=ct!==void 0,Fe=cn?ct:fi,Nt=i.useCallback(u=>{cn||gi(u),At?.(u)},[cn,At]),[hi,pi]=i.useState(()=>he?.columns?.pinnedColumns??{}),un=y!==void 0,Ue=un?y:hi,fn=i.useCallback(u=>{un||pi(u),g?.(u)},[un,g]),xi=i.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[mi,bi]=i.useState(be??xi),Un=be??mi,wi=i.useCallback(u=>{bi(u),Ce?.(u)},[Ce]),zt=Fn(o,e,Un,ge),gn=ge&&zt.isValid?zt.pivotRows:o,Be=ge&&zt.isValid?zt.pivotColumns:e,[vi,Kn]=i.useState(null);i.useEffect(()=>{Kn(null)},[ze]);const[_i,Ci]=i.useState(()=>he?.pagination?.paginationModel??P),hn=t.paginationModel!==void 0,ce=hn?P:_i,Bt=i.useCallback(u=>{hn||Ci(u),k?.(u)},[hn,k]),[yi,Yn]=i.useState([]),It=f!==void 0,Xn=It?f:yi,ye=i.useMemo(()=>new Set(Xn),[Xn]),$t=c,ut=i.useRef(null),ki=i.useRef(null),Dt=i.useRef(null),Si=i.useCallback(u=>u.id,[]),Ht=r||Si,ft=i.useCallback(u=>{Qt.current?.classList.toggle("ogx--kb",u)},[]),qn=i.useRef(Z);qn.current=Z;const Jn=i.useRef(null),Qn=i.useRef(null),ji=i.useCallback(u=>{if(qn.current&&ee&&u.serverChildrenCount>0&&u.children.length===0){const T=Qn.current?.getNodePath(u.id)||[u.groupingKey];Jn.current?.(u.id,T)}},[ee]),Oe=qo({rows:gn,columns:Be,rowHeight:l,headerHeight:a,rowCount:pe,columnVisibilityModel:Fe,initialState:t.initialState}),{state:ae,apiRef:gt,setRows:pn,setColumns:Zn,setScroll:eo,setDimensions:to,setDataSourceLoading:Ei,setDataSourceError:Ni,setRowCount:Ii}=Oe;i.useEffect(()=>{Ee&&(Ee.current=gt.current)},[Ee,gt]);const{copySelectedRows:no}=pr({selectedRowIds:ye,columns:Be,getVisibleRows:()=>gt.current.getVisibleRows(),getRowId:Ht});i.useEffect(()=>{gt.current.copySelectedRows=no,gt.current.getSelectedRows=()=>Array.from(ye)},[no,ye,gt]);const Pi=ae.dataSource.loading,Pt=J||Pi,Mt=i.useMemo(()=>ae.rows.allRows.map(u=>ae.rows.idRowsLookup.get(u)),[ae.rows]),xn=ir({rows:Mt,getRowId:Ht,getTreeDataPath:_,treeData:ee,defaultGroupingExpansionDepth:G,filterModel:We,sortModel:Ae,onRowExpansionChange:ji});i.useEffect(()=>{Qn.current=xn},[xn]);const Mi=sr({rows:Mt,getRowId:Ht,rowGroupingModel:an,aggregationModel:ze,defaultGroupingExpansionDepth:G,filterModel:We,sortModel:Ae,getAggregationPosition:X}),Ke=ar({rows:Mt,getRowId:Ht,processRowUpdate:R,onProcessRowUpdateError:re,onRowChange:u=>{const{dispatch:T}=Oe,Q=Array.from(Oe.state.rows.idRowsLookup.values()).map(ne=>ne.id===u.id?u:ne);T({type:"SET_ROWS",payload:Q})}}),mn=ee,ht=!!(an&&an.length>0),Gt=mn||ht,Ne=mn?xn:ht?Mi:null,Ie=j&&!ht,Vt=i.useCallback(u=>{const{row:T,id:A}=u;if(Gt&&T._hasChildren){Ne?.toggleExpansion(A);return}p?.(u)},[Gt,Ne,p]),ve=i.useMemo(()=>Gt?Be.map((u,T)=>T===0?{...u,renderCell:A=>{const{_treeDepth:Q,_hasChildren:ne,_isExpanded:le,_groupingField:ue,_groupingValue:De,_descendantCount:Pe}=A.row,Xe=(Q||0)*24;let we=u.renderCell?u.renderCell(A):A.value;return mn&&ne&&A.row._isGroupRow&&(we=n.jsxs("div",{className:"ogx__group-cell-content",children:[A.value,Pe!==void 0&&Pe>0?` (${Pe})`:""]})),ht&&ne&&ue&&(we=n.jsxs("div",{className:"ogx__group-cell-content",children:[u.field===ue?"":`${ue}: `,String(De),Pe!==void 0?` (${Pe})`:""]})),n.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:Xe,width:"100%",height:"100%"},children:[n.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:ne?"pointer":"default",flexShrink:0},children:ne?n.jsx("div",{onClick:_e=>{_e.stopPropagation(),_e.preventDefault(),Ne?.toggleExpansion(A.row.id)},onMouseDown:_e=>{_e.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:n.jsx(Rn,{isExpanded:le,onClick:_e=>{_e.stopPropagation(),_e.preventDefault(),Ne?.toggleExpansion(A.row.id)}})}):null}),n.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:we})]})}}:{...u,renderCell:A=>{const{_hasChildren:Q,_groupingField:ne}=A.row;return ht&&Q?u.field===ne?null:A.value!==void 0&&A.value!==null?u.renderCell?u.renderCell(A):A.value:null:u.renderCell?u.renderCell(A):A.value}}):Be,[Be,Gt,ht,Ne]),bn=cr({dataSource:Z,sortModel:Ae,filterModel:We,paginationModel:ce,paginationMode:U,sortingMode:se,filterMode:me,aggregationModel:ze,setRows:pn,setRowCount:Ii,setDataSourceLoading:Ei,setDataSourceError:Ni,onAggregationResults:Kn});i.useEffect(()=>{bn.fetchChildren&&(Jn.current=bn.fetchChildren)},[bn.fetchChildren]);const[Ye,Ti]=i.useState(()=>he?.columns?.columnWidths??{}),[Li,Ut]=i.useState(()=>he?.columns?.columnOrder??Be.map(u=>u.field)),Qe=F||Li;i.useEffect(()=>{Z||pn(gn)},[gn,pn,Z]),i.useEffect(()=>{Zn(Be)},[Be,Zn]),i.useEffect(()=>{ge&&Ut(Be.map(u=>u.field))},[ge,Be]);const pt=i.useMemo(()=>{if(Y)return ve;const u=new Map(Qe.map((T,A)=>[T,A]));return[...ve].sort((T,A)=>{const Q=u.get(T.field)??ve.indexOf(T),ne=u.get(A.field)??ve.indexOf(A);return Q-ne})},[ve,Qe,Y]),Ri=i.useMemo(()=>pt.filter(u=>Fe[u.field]!==!1),[pt,Fe]),xt=Jo({columns:pt,onColumnOrderChange:i.useCallback(u=>{const{oldIndex:T,targetIndex:A}=u,Q=[...Qe],[ne]=Q.splice(T,1);Q.splice(A,0,ne),F||Ut(Q),D?.(u)},[Qe,F,D]),disableColumnReorder:Y}),[Wi,Oi]=i.useState(new Set),mt=I??Wi,$e=!!N,Kt=i.useCallback(u=>{const T=new Set(mt);T.has(u)?T.delete(u):T.add(u),I===void 0&&Oi(T),M?.(T)},[mt,I,M]),oo=i.useMemo(()=>{const u=[];return O&&u.push({field:"__reorder_col__"}),$e&&u.push({field:"__expand_col__"}),s&&u.push({field:"__checkbox_col__"}),[...u,...pt]},[pt,s,$e,O]),Fi=i.useCallback((u,T)=>{Ti(A=>({...A,[u]:T}))},[]),wn=i.useRef(de);wn.current=de,i.useEffect(()=>{if(!wn.current)return;const u={sorting:{sortModel:Ae},filter:{filterModel:We},pagination:{paginationModel:ce},columns:{columnWidths:Ye,columnOrder:Qe,columnVisibilityModel:Fe,pinnedColumns:Ue}};wn.current(u)},[Ae,We,ce,Ye,Qe,Fe,Ue]);const Yt=i.useMemo(()=>Mt,[Mt]),Me=i.useMemo(()=>Ne?Ne.getVisibleRows()||[]:me==="server"&&Z?Yt:nr(Yt,We),[Yt,We,Ne,me,Z]),{top:Ze,center:bt,bottom:rt}=i.useMemo(()=>Ne?{top:[],center:Me,bottom:[]}:vo(Me,v),[Me,v,Ne]),ke=i.useMemo(()=>Ne||se==="server"&&Z?bt:rr(bt,Ae),[bt,Ae,Ne,se,Z]),et=i.useMemo(()=>{if(!Ie||U==="server"&&Z)return ke;const u=ce.page*ce.pageSize,T=u+ce.pageSize;return ke.slice(u,T)},[ke,Ie,ce.page,ce.pageSize,U,Z]);i.useEffect(()=>{Oe.apiRef.current.getVisibleRows=()=>ke,Oe.apiRef.current.getVisibleColumns=()=>ve},[ke,ve,Oe.apiRef]);const wt=Qo({rows:Ie?et:ke,getRowId:u=>u.id,onRowOrderChange:V,rowReordering:O}),Tt=i.useMemo(()=>{if(Ne)return bt;const u=Ie?et:ke,T=[...Ze,...u,...rt];if(U==="infinite"&&ae.dataSource.loading&&T.length>0){const A=Math.min(ce.pageSize,20),Q=Array.from({length:A},(ne,le)=>({id:`__skeleton_${le}__`,_isSkeleton:!0}));return[...T,...Q]}return T},[Ze,et,ke,rt,Ie,Ne,bt,U,ae.dataSource.loading,ce.pageSize]),vt=dr(Tt,oo,Ye),{aggregationResult:vn}=On({rows:Me,aggregationModel:ze,isServerSide:!!(Z&&(U==="server"||se==="server")),dataSource:Z,filterModel:We,sortModel:Ae,serverAggregationResults:vi}),Xt=Object.keys(ze).length>0;i.useEffect(()=>{Oe.apiRef.current.getAggregationResult=()=>Xt?vn:null,Oe.apiRef.current.getAggregationModel=()=>Xt?ze:null},[vn,ze,Xt,Oe.apiRef]);const Te=_o({rowHeight:l,pagination:Ie,paginatedUnpinnedRows:et,sortedUnpinnedRows:ke,expandedRowIds:mt,getDetailPanelHeight:S,pinnedTopRowsLength:Ze.length,pinnedBottomRowsLength:rt.length,visibleOrderedColumns:Ri,pinnedColumns:Ue,columnWidths:Ye,viewportWidth:ae.dimensions.viewportWidth||1e3,checkboxSelection:s,hasDetailPanel:$e,rowReordering:O,pinCheckboxColumn:C,pinExpandColumn:W,autoHeight:d,paginationMode:U,isLoading:ae.dataSource.loading,pageSize:ce.pageSize});i.useEffect(()=>{Oe.apiRef.current.scrollToIndexes=({rowIndex:u,colIndex:T})=>{const A=ut.current;if(A){if(u!==void 0&&u>=0){const Q=u>0?Te.cumulativeHeights[u-1]:0,ne=Te.cumulativeHeights[u]??Q,{scrollTop:le,clientHeight:ue}=A;Q<le?A.scrollTop=Q:ne>le+ue&&(A.scrollTop=ne-ue)}if(T!==void 0&&T>=0){const ne=[...Te.leftPinnedCols,...Te.unpinnedColsWithWidth,...Te.rightPinnedCols][T];if(!ne)return;const le=Te.unpinnedColsWithWidth.findIndex(we=>we.field===ne.field);if(le===-1)return;const ue=le>0?Te.unpinnedAccWidths[le-1]:0,De=Te.unpinnedAccWidths[le]??ue,Pe=Te.leftWidth+De,{scrollLeft:Le,clientWidth:Xe}=A;ue<Le?A.scrollLeft=ue:Pe>Le+Xe&&(A.scrollLeft=Pe-Xe)}}}},[Te,ut,Oe.apiRef]);const Se=i.useMemo(()=>{const{unpinnedAccWidths:u,unpinnedColsWithWidth:T,leftPinnedCols:A,rightPinnedCols:Q,totalWidth:ne,leftWidth:le,rightWidth:ue,unpinnedTotalWidth:De,systemColumnsWidth:Pe,cumulativeHeights:Le,pinnedTopHeight:Xe,pinnedBottomHeight:we,unpinnedRowsHeight:_e,rowHeights:Ui,unpinnedRowsLength:so}=Te,ao=ae.virtualization.scrollLeft,co=ae.virtualization.scrollTop,yn=ae.dimensions.viewportWidth||1e3,Ki=d?Xe+_e+we+50:ae.dimensions.viewportHeight||600,kn=6,Yi=Math.max(0,ao-le),Xi=ao+yn-le;let _t=0,Rt=T.length-1,Zt=0,Sn=u.length-1;for(;Zt<=Sn;){const xe=Zt+Sn>>>1;u[xe]<Yi?Zt=xe+1:Sn=xe-1}_t=Math.max(0,Zt-kn);for(let xe=_t;xe<u.length;xe++){if((xe===0?0:u[xe-1])>Xi){Rt=Math.min(T.length-1,xe+kn);break}Rt=Math.min(T.length-1,xe+kn)}const uo=_t>0?u[_t-1]:0,fo=De-u[Rt],qi=[...A,...uo>0?[{field:"__spacer_left__",width:uo,isSpacer:!0}]:[],...T.slice(_t,Rt+1),...fo>0?[{field:"__spacer_right__",width:fo,isSpacer:!0}]:[],...Q],Ji=yn>0&&ne>yn?16:0,Qi=Xe+_e+we+Ji+2,go=5;let Wt=0,ho=so-1,po=0,en=0,jn=Le.length-1;for(;en<=jn;){const xe=en+jn>>>1;Le[xe]<co?en=xe+1:jn=xe-1}Wt=Math.max(0,en-go),po=Wt>0?Le[Wt-1]:0;for(let xe=Wt;xe<Le.length;xe++)if(Le[xe]>=co+Ki){ho=Math.min(so-1,xe+go);break}return{renderContext:{firstRowIndex:Wt,lastRowIndex:ho,firstColumnIndex:_t,lastColumnIndex:Rt},offsetTop:po,offsetLeft:0,totalHeight:Qi,pinnedTopHeight:Xe,pinnedBottomHeight:we,totalWidth:ne,rowHeights:Ui,cumulativeHeights:Le,virtualColumns:qi,columnMetrics:{leftPinnedWidth:le,rightPinnedWidth:ue,unpinnedAccWidths:u,unpinnedCols:T,totalSpecialsWidth:Pe,pinnedSpecialsWidth:(O?48:0)+($e&&W?48:0)+(s&&C?48:0)}}},[Te,ae.virtualization.scrollTop,ae.virtualization.scrollLeft,ae.dimensions.viewportHeight,ae.dimensions.viewportWidth,d]),Ai=i.useCallback(u=>{const T=u.currentTarget;if(eo(T.scrollTop,T.scrollLeft),q){const{scrollTop:A,scrollHeight:Q,clientHeight:ne}=T;Q-A-ne<100&&q({visibleTop:A,visibleBottom:A+ne,viewportHeight:ne})}},[eo,q]);i.useEffect(()=>{if(!ut.current)return;const u=new ResizeObserver(T=>{for(const A of T){const{width:Q,height:ne}=A.contentRect;to(Q,ne)}});return u.observe(ut.current),()=>{u.disconnect()}},[to]);const Lt=i.useCallback((u,T)=>{const A=new Set(ye);T?A.add(u):A.delete(u);const Q=Array.from(A);It||Yn(Q),$t?.(Q)},[ye,It,$t]),zi=i.useCallback(u=>{let T=[];u&&(T=Yt.map(A=>A.id)),It||Yn(T),$t?.(T)},[o,It,$t]),ro=i.useCallback((u,T)=>{const A=T?[{field:u,sort:T}]:[];sn||li(A),h?.(A)},[sn,h]),{focusedCell:tt,setFocusedCell:_n,handleFocus:Bi,handleBlur:$i,handleKeyDown:Di}=Co({allRenderableRows:Tt,navigationColumns:oo,checkboxSelection:s,selectedRowIds:ye,handleSelectionChange:Lt,handleDetailPanelToggle:Kt,editingHandlers:Ke,setKeyboardMode:ft,sortModel:Ae,handleSort:ro,isCellEditable:H,pagination:Ie,pageSize:ce.pageSize,virtualization:Se,viewportRef:ut}),Cn=i.useCallback(u=>{ft(!1),_n({id:u.row.id,field:u.field}),Dt.current?.focus({preventScroll:!0}),m?.(u)},[m,ft,_n]),io=i.useRef(Ke.editingCell);i.useEffect(()=>{const u=!!io.current,T=!!Ke.editingCell;u&&!T&&Dt.current?.focus({preventScroll:!0}),io.current=Ke.editingCell},[Ke.editingCell]);const lo=i.useMemo(()=>{const{firstRowIndex:u,lastRowIndex:T}=Se.renderContext,A=Ze.length,Q=Ze.map((we,_e)=>({row:we,rowIndex:_e})),ne=rt.map((we,_e)=>({row:we,rowIndex:A+(Ie?et.length:ke.length)+_e})),le=Math.max(0,u-A),ue=Math.min(Ie?et.length:ke.length,T-A+1),De=(Ie?et:ke).slice(le,ue).map((we,_e)=>({row:we,rowIndex:A+le+_e})),Pe=[...Q,...De,...ne],Le=new Set;return Pe.filter(we=>Le.has(we.row.id)?!1:(Le.add(we.row.id),!0))},[Se.renderContext,Ze,rt,et,ke,Ie,U,ae.dataSource.loading,ce.pageSize,l]),Hi=o.length>0&&ye.size===o.length,Gi=ye.size>0&&ye.size<o.length,Vi=i.useMemo(()=>ve.some(u=>!!u.rowSpan),[ve]),[qt,Jt]=i.useState(!1),Qt=i.useRef(null);return i.useEffect(()=>{if(!qt||fe?.toolbar)return;function u(T){const A=document.getElementById("ogx-standalone-col-panel");A&&!A.contains(T.target)&&Jt(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[qt,fe?.toolbar]),n.jsxs("div",{ref:Qt,className:["ogx",Ge,d&&"ogx--auto-height",Vi&&"ogx--row-spanning",Ve&&"ogx--list-view"].filter(Boolean).join(" "),style:{...$,height:K??$?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${a}px`},"aria-busy":Pt,children:[fe?.toolbar&&(()=>{const u={apiRef:Oe.apiRef,columns:ve,baseColumns:e,aggregationModel:ze,onAggregationModelChange:ui,...ge||be||Ce?{pivotModel:Un,onPivotModelChange:wi}:{},filterModel:We,onFilterModelChange:x,columnVisibilityModel:Fe,onColumnVisibilityModelChange:Nt,onColumnReorder:Y?void 0:(T,A)=>{const Q=[...Qe],ne=Q.indexOf(T),le=Q.indexOf(A);if(ne===-1||le===-1)return;const ue=[...Q];ue.splice(ne,1),ue.splice(le,0,T),F||Ut(ue);const De=ve.find(Pe=>Pe.field===T);De&&D?.({oldIndex:ne,targetIndex:le,column:De})},forceColumnsOpen:qt,onColumnsPanelClose:()=>Jt(!1),...je?.toolbar};return n.jsx(ai,{...u})})(),!fe?.toolbar&&qt&&nt.createPortal(n.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const u=Qt.current?.getBoundingClientRect();return{position:"fixed",top:u?u.top+8:16,right:u?window.innerWidth-u.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[n.jsx("button",{onClick:()=>Jt(!1),style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),n.jsx(An,{columns:ve,visibleColumns:new Set(ve.filter(u=>Fe[u.field]!==!1).map(u=>u.field)),onVisibilityChange:(u,T)=>{Nt({...Fe,[u]:T})},onShowAll:()=>{const u={...Fe};ve.forEach(T=>{T.hideable!==!1&&(u[T.field]=!0)}),Nt(u)},onHideAll:()=>{const u={...Fe};ve.forEach(T=>{T.hideable!==!1&&(u[T.field]=!1)}),Nt(u)},onColumnReorder:Y?void 0:(u,T)=>{const A=[...Qe],Q=A.indexOf(u),ne=A.indexOf(T);if(Q===-1||ne===-1)return;const le=[...A];le.splice(Q,1),le.splice(ne,0,u),F||Ut(le),D?.({oldIndex:Q,targetIndex:ne,column:ve.find(ue=>ue.field===u)})}})]}),Qt.current?.closest(".ogx-theme-provider")||document.body),Ve&&ot&&n.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":te||"Data grid list view","aria-rowcount":Tt.length+1,children:[n.jsx("div",{className:"ogx-list-view__toolbar",children:n.jsxs("span",{children:[Me.length," ",Me.length===1?"item":"items",Ie?` · page ${ce.page+1} of ${Math.ceil(Me.length/ce.pageSize)||1}`:"",ye.size>0?` · ${ye.size} selected`:""]})}),n.jsx("div",{className:"ogx-list-view__rows",children:Tt.length===0?n.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("path",{d:"M3 9h18M9 21V9"})]}),oe]}):Tt.map((u,T)=>n.jsx(yo,{row:u,rowIndex:T,listViewColumn:ot,isSelected:ye.has(u.id),checkboxSelection:s,rowHeight:l,onRowClick:A=>Vt({row:A,id:A.id,rowIndex:T}),onSelectionChange:Lt},u.id))}),Ie&&(()=>{const u=fe?.pagination||Wn,T=U==="server"&&Z?ae.pagination.rowCount||0:Me.length,A={page:ce.page,pageSize:ce.pageSize,rowCount:T,pageSizeOptions:E,onPageChange:Q=>Bt({...ce,page:Q}),onPageSizeChange:Q=>Bt({...ce,pageSize:Q,page:0}),...je?.pagination};return n.jsx(u,{...A})})()]}),!Ve&&n.jsx("div",{ref:u=>{ut.current=u,Dt.current=u},className:"ogx__viewport",onScroll:Ai,role:"grid","aria-label":te||"Data grid","aria-rowcount":Me.length+1,"aria-colcount":e.length+(s?1:0)+($e?1:0)+(O?1:0),"aria-busy":Pt,tabIndex:0,onKeyDownCapture:()=>{ft(!0)},onMouseDownCapture:()=>{ft(!1)},onKeyDown:Di,onFocus:Bi,onBlur:$i,children:n.jsxs("div",{ref:ki,className:"ogx__content",style:{width:Se.totalWidth},role:"presentation",children:[n.jsx(Tn,{columns:Se.virtualColumns,allColumns:ve,columnGroupingModel:Re,checkboxSelection:s,allSelected:Hi,someSelected:Gi,onSelectAll:zi,sortModel:Ae,onSort:ro,onColumnResize:Fi,columnWidths:Ye,pinnedColumns:Ue,focusedCell:tt,onHeaderClick:u=>{_n({id:"HEADER",field:u}),ft(!1),Dt.current?.focus({preventScroll:!0})},onDragStart:Re?void 0:xt.onDragStart,onDragOver:Re?void 0:xt.onDragOver,onDragEnd:Re?void 0:xt.onDragEnd,onDrop:Re?void 0:xt.onDrop,draggedColumn:Re?void 0:xt.draggedColumn,dragOverColumn:Re?void 0:xt.dragOverColumn,rowReordering:O,hasDetailPanel:$e,pinCheckboxColumn:C,pinExpandColumn:W,aggregationModel:ze,onHideColumn:u=>{Nt({...Fe,[u]:!1})},onManageColumns:()=>Jt(!0),onPinColumn:(u,T)=>{const A=[...Ue?.left??[]],Q=[...Ue?.right??[]],ne=A.filter(ue=>ue!==u),le=Q.filter(ue=>ue!==u);fn(T==="left"?{left:[...ne,u],right:le}:T==="right"?{left:ne,right:[...le,u]}:{left:ne,right:le})}}),!Pt&&!ae.dataSource.error&&Me.length===0&&n.jsxs("div",{className:"ogx__empty",style:{width:Se.totalWidth},children:[n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("path",{d:"M3 9h18M9 21V9"})]}),n.jsx("span",{children:oe})]}),Ze.length>0&&n.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ze.map((u,T)=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,focusedCellField:tt?.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},u.id))}),n.jsx("div",{className:"ogx__virtual-container",style:{height:`${Se.totalHeight-Se.pinnedTopHeight-Se.pinnedBottomHeight}px`},role:"presentation",children:n.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${Se.renderContext.firstRowIndex*l}px)`},role:"rowgroup",children:[Pt&&lo.length===0?(()=>{const u=e.length>0?e:(()=>{const T=(ae.dimensions.viewportWidth||1e3)-(s?48:0)-(N?48:0)-(O?48:0),A=150,Q=Math.max(1,Math.ceil(T/A));return Array.from({length:Q},(ne,le)=>({field:`placeholder_${le}`,headerName:"",width:A}))})();return Array.from({length:10}).map((T,A)=>n.jsx(Ko,{columns:u,rowHeight:l,checkboxSelection:s,hasDetailPanel:!!N,rowReordering:O},`skeleton-${A}`))})():lo.filter(({row:u})=>!tn(u.id,v)).filter((u,T,A)=>T===A.findIndex(Q=>Q.row.id===u.row.id)).map(({row:u,rowIndex:T})=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,rowReordering:O,onDragStart:wt.onDragStart,onDragOver:wt.onDragOver,onDragEnd:wt.onDragEnd,onDrop:wt.onDrop,isDragging:wt.draggedRowId===u.id,isDragOver:wt.dragOverRowId===u.id,editingCell:Ke.editingCell,onEditStart:Ke.startCellEdit,onEditStop:Ke.stopCellEdit,onEditCellValueChange:Ke.setEditCellValue,focusedCellField:tt!=null&&tt.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},`${u.id}-${Se.totalWidth}`)),U==="infinite"&&ae.dataSource.loading&&ke.length>0&&(()=>{const u=Math.min(ce.pageSize,20),T=Te.unpinnedRowsLength;return n.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:u}).map((A,Q)=>n.jsx(St,{row:{id:`__skeleton_${Q}__`,_isSkeleton:!0},columns:Se.virtualColumns,rowIndex:T+Q,rowHeight:l},`__skeleton_${Q}__`))})})()]})}),rt.length>0&&n.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:rt.map((u,T)=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,focusedCellField:tt?.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},u.id))}),Xt&&!ge&&n.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&n.jsx("div",{style:{width:48,flexShrink:0}}),$e&&n.jsx("div",{style:{width:48,flexShrink:0}}),O&&n.jsx("div",{style:{width:48,flexShrink:0}}),pt.map(u=>{const T=ze[u.field],A=vn[u.field],Q=Ye[u.field]??(typeof u.width=="number"?u.width:120);return n.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:Q,minWidth:Q,maxWidth:Q,textAlign:u.align||"left"},children:T?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ogx__aggregation-label",children:T}),n.jsx("span",{className:"ogx__aggregation-value",children:qe(A,T)})]}):null},u.field)})]})]})}),!Ve&&Ie&&(()=>{const u=fe?.pagination||Wn,T={page:ce.page,pageSize:ce.pageSize,rowCount:ae.pagination.rowCount,pageSizeOptions:E,onPageChange:A=>Bt({...ce,page:A}),onPageSizeChange:A=>Bt({...ce,pageSize:A,page:0}),...je?.pagination};return n.jsx(u,{...T})})(),n.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[Pt?"Loading data...":"",ae.dataSource.error?`Error: ${ae.dataSource.error.message||"Unknown error"}`:"",!J&&!ae.dataSource.error&&(Me.length===0?oe:We&&((We.quickFilterValues?.length||0)>0||(We.items?.length||0)>0)?`${Me.length} ${Me.length===1?"row":"rows"} found`:"")]}),ae.dataSource.error&&n.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[n.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),n.jsx("div",{className:"ogx-error-overlay__message",children:ae.dataSource.error.message||"An unexpected error occurred while loading the data."}),n.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})]})}function wr({rows:t=5,columns:o=5}){return n.jsx("div",{className:"ogx__skeleton",children:Array.from({length:t}).map((e,r)=>n.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:o}).map((l,a)=>n.jsx("div",{className:"ogx__skeleton-cell",children:n.jsx("div",{className:"ogx__skeleton-content"})},a))},r))})}const zn=new Set(["isEmpty","isNotEmpty"]);function vr(t,o){return t.find(e=>"field"in e&&e.field===o)}const _r=({col:t,item:o,onChange:e})=>{const r=or(t.type),l=!!o,a=o?.operator??r[0],[d,s]=i.useState(o?.value??""),f=i.useRef(e);f.current=e;const c=i.useRef(o?.value);i.useEffect(()=>{o?.value!==c.current&&(c.current=o?.value,s(o?.value??""))},[o?.value]),i.useEffect(()=>{const h=setTimeout(()=>{const j=o?.value??"";d!==j&&f.current({id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:a,value:d})},300);return()=>clearTimeout(h)},[d]);const p=h=>{const j=zn.has(h),P={id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:h,value:j?void 0:o?.value??(t.type==="boolean"?"true":"")};e(P)},m=()=>{s(""),e(null)},b=zn.has(String(a)),x=t.type==="boolean",w=!b;return n.jsxs("div",{className:`ogx-filter__row${l?" ogx-filter__row--active":""}`,children:[n.jsx("span",{className:"ogx-filter__col-label",title:t.field,children:t.headerName||t.field}),n.jsxs("div",{className:"ogx-filter__controls",children:[n.jsx("select",{id:`ogx-filter-op-${t.field}`,name:`filter-op-${t.field}`,className:`ogx-filter__op-select${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:h=>p(h.target.value),"aria-label":`Filter operator for ${t.headerName||t.field}`,children:r.map(h=>n.jsx("option",{value:h,children:h},h))}),w&&x&&n.jsxs("select",{id:`ogx-filter-val-${t.field}`,name:`filter-val-${t.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:h=>{s(h.target.value),e({id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:a,value:h.target.value})},"aria-label":`Filter value for ${t.headerName||t.field}`,children:[n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]}),w&&!x&&n.jsx("input",{id:`ogx-filter-val-${t.field}`,name:`filter-val-${t.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:h=>s(h.target.value),placeholder:t.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${t.headerName||t.field}`}),l&&n.jsx("button",{className:"ogx-filter__row-clear",onClick:m,"aria-label":`Clear filter for ${t.headerName||t.field}`,title:"Clear",children:"×"})]})]})},Bn=({filterModel:t,columns:o,onFilterModelChange:e})=>{const r=t.items??[],l=t.logicOperator??"and",a=i.useCallback((f,c)=>{const p=r.filter(b=>"field"in b&&b.field!==f),m=c?[...p,c]:p;e({...t,items:m})},[r,t,e]),d=i.useCallback(f=>{e({...t,logicOperator:f})},[t,e]),s=o.filter(f=>f.filterable!==!1);return n.jsxs(n.Fragment,{children:[r.length>1&&n.jsxs("div",{className:"ogx-filter__logic-bar",children:[n.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),n.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),n.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),s.length===0?n.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):s.map(f=>n.jsx(_r,{col:f,item:vr(r,f.field),onChange:c=>a(f.field,c)},f.field))]})},Cr=["sum","avg","count","min","max"];function $n(){return n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),n.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function yr({anchorRef:t,columns:o,model:e,onChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),[f,c]=i.useState(document.body);i.useLayoutEffect(()=>{c(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const p=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const C=t.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[t]);i.useEffect(()=>{s(p());const C=()=>s(p());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[p]),i.useEffect(()=>{function C(Y){a.current&&!a.current.contains(Y.target)&&t.current&&!t.current.contains(Y.target)&&l()}function W(Y){Y.key==="Escape"&&l()}return document.addEventListener("mousedown",C),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",W)}},[t,l]);const m=new Set(e.rowFields),b=new Set(e.columnFields),x=new Set(e.valueFields.map(C=>C.field)),w=C=>m.has(C)||b.has(C)||x.has(C);function h(C){m.has(C)||r({...e,rowFields:[...e.rowFields,C]})}function j(C){b.has(C)||r({...e,columnFields:[...e.columnFields,C]})}function P(C,W="sum"){x.has(C)||r({...e,valueFields:[...e.valueFields,{field:C,aggFn:W}]})}function k(C){r({...e,rowFields:e.rowFields.filter(W=>W!==C)})}function E(C){r({...e,columnFields:e.columnFields.filter(W=>W!==C)})}function y(C){r({...e,valueFields:e.valueFields.filter(W=>W.field!==C)})}function g(C,W){r({...e,valueFields:e.valueFields.map(Y=>Y.field===C?{...Y,aggFn:W}:Y)})}function v(){r({rowFields:[],columnFields:[],valueFields:[]})}const N=new Set(o.filter(C=>C.type==="number"||C.aggregable).map(C=>C.field)),S=e.rowFields.length+e.columnFields.length+e.valueFields.length,I=C=>o.find(W=>W.field===C)?.headerName??C,M=n.jsxs("div",{ref:a,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[n.jsxs("div",{className:"ogx-pivot-panel__header",children:[n.jsxs("span",{className:"ogx-pivot-panel__title",children:[n.jsx($n,{}),"Pivot Mode"]}),S>0&&n.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:v,title:"Reset pivot",children:"Reset"})]}),n.jsxs("div",{className:"ogx-pivot-panel__body",children:[n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),n.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(C=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[I(C),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>k(C),title:`Remove ${I(C)}`,children:"×"})]},C))})]}),n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),n.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(C=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[I(C),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(C),title:`Remove ${I(C)}`,children:"×"})]},C))})]}),n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),n.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(C=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[I(C.field),n.jsx("select",{className:"ogx-pivot-chip__fn-select",value:C.aggFn,onChange:W=>g(C.field,W.target.value),title:"Aggregation function",children:Cr.map(W=>n.jsx("option",{value:W,children:W.toUpperCase()},W))}),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(C.field),title:`Remove ${I(C.field)}`,children:"×"})]},C.field))})]}),n.jsx("hr",{className:"ogx-pivot-panel__divider"}),n.jsxs("div",{children:[n.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),n.jsxs("div",{className:"ogx-pivot-fields",children:[o.map(C=>{const W=N.has(C.field);return w(C.field)?null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[n.jsx("span",{className:`ogx-pivot-field-btn${W?" ogx-pivot-field-btn--numeric":""}`,children:C.headerName??C.field}),n.jsxs("div",{className:"ogx-pivot-field-actions",children:[n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>h(C.field),title:"Add to Row Fields",children:"Row"}),n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>j(C.field),title:"Add to Column Fields",children:"Col"}),W&&n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>P(C.field),title:"Add to Value Fields",children:"Val"})]})]},C.field)}),o.every(C=>w(C.field))&&n.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return nt.createPortal(M,f)}function kr(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Sr(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function jr({value:t="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[l,a]=i.useState(()=>t.length>0),[d,s]=i.useState(t),f=i.useRef(null),c=i.useRef(null),p=i.useRef(o);i.useLayoutEffect(()=>{p.current=o},[o]);const m=i.useRef(t),b=i.useRef(t),x=i.useRef(!1);i.useLayoutEffect(()=>{x.current&&document.activeElement!==f.current&&f.current?.focus()}),i.useEffect(()=>{t!==b.current&&(b.current=t,t!==m.current&&(s(t),m.current=t,t?a(!0):(x.current=!1,a(!1))))},[t]),i.useEffect(()=>{const k=setTimeout(()=>{d!==m.current&&(m.current=d,p.current(d))},r);return()=>clearTimeout(k)},[d,r]);const w=i.useCallback(()=>{a(!0),requestAnimationFrame(()=>f.current?.focus())},[]),h=i.useCallback(k=>{k.stopPropagation(),s(""),m.current="",p.current(""),f.current?.focus()},[]),j=i.useCallback(()=>{x.current=!0,a(!0)},[]),P=i.useCallback(()=>{x.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){x.current=!0;return}d||a(!1)},150)},[d]);return i.useEffect(()=>{const k=E=>{c.current&&!c.current.contains(E.target)&&(d||a(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d]),n.jsxs("div",{ref:c,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:w,children:[n.jsx("div",{className:"ogx-global-search__icon-wrapper",children:n.jsx(kr,{})}),n.jsx("input",{ref:f,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:k=>s(k.target.value),onFocus:j,onBlur:P,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&n.jsx("button",{className:"ogx-global-search__clear",onClick:h,"aria-label":"Clear search",children:n.jsx(Sr,{})})]})}function Et({title:t,children:o,placement:e="top",enterDelay:r=200,leaveDelay:l=0}){const[a,d]=i.useState(!1),[s,f]=i.useState({top:0,left:0}),c=i.useRef(null),p=i.useRef(null),m=i.useCallback(()=>{if(!p.current)return;const h=p.current.getBoundingClientRect();let j=0,P=0;const k=window.pageXOffset||document.documentElement.scrollLeft,E=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(j=h.top+E-8,P=h.left+k+h.width/2):e==="bottom"&&(j=h.bottom+E+8,P=h.left+k+h.width/2),f({top:j,left:P})},[e]);i.useLayoutEffect(()=>(a&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[a,m]);const b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},r)},x=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},l)},w=i.useCallback(h=>{p.current=h?h.firstElementChild??h:null},[]);return n.jsxs(n.Fragment,{children:[n.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:b,onMouseLeave:x,children:o}),a&&t&&nt.createPortal(n.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:s.top,left:s.left,position:"absolute",zIndex:99999},children:t}),document.body)]})}const Er=["none","sum","avg","count","min","max"];function Dn(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Nr(){return n.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Hn(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Ir({anchorRef:t,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:l,onClose:a,activeCount:d}){const s=i.useRef(null),[f,c]=i.useState({top:0,right:0}),[p,m]=i.useState(document.body);i.useLayoutEffect(()=>{m(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const b=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const w=t.current.getBoundingClientRect();return{top:w.bottom+6,right:window.innerWidth-w.right}},[t]);i.useEffect(()=>{c(b());const w=()=>c(b());return window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[b]),i.useEffect(()=>{function w(h){s.current&&!s.current.contains(h.target)&&t.current&&!t.current.contains(h.target)&&a()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[t,a]),i.useEffect(()=>{function w(h){h.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[a]);const x=n.jsxs("div",{ref:s,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:f.top,right:f.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[n.jsxs("div",{className:"ogx-toolbar__panel-header",children:[n.jsxs("span",{className:"ogx-toolbar__panel-title",children:[n.jsx(Dn,{}),"Summaries"]}),d>0&&n.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),n.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?n.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",n.jsx("br",{}),"Set ",n.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(w=>{const h=o[w.field]||"none";return n.jsxs("div",{className:"ogx-toolbar__agg-row",children:[n.jsx("span",{className:"ogx-toolbar__agg-label",title:w.field,children:w.headerName||w.field}),n.jsx("div",{className:"ogx-toolbar__agg-pills",children:Er.map(j=>n.jsx("button",{className:`ogx-toolbar__pill${h===j?" ogx-toolbar__pill--active":""}`,onClick:()=>r(w.field,j),"aria-pressed":h===j,children:j},j))})]},w.field)})})]});return nt.createPortal(x,p)}function Pr({anchorRef:t,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d,onClose:s}){const f=i.useRef(null),[c,p]=i.useState({top:0,right:0}),[m,b]=i.useState(document.body);i.useLayoutEffect(()=>{b(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const x=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const h=t.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[t]);i.useEffect(()=>{p(x());const h=()=>p(x());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[x]),i.useEffect(()=>{function h(j){f.current&&!f.current.contains(j.target)&&t.current&&!t.current.contains(j.target)&&s()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[t,s]);const w=n.jsx("div",{ref:f,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:c.top,right:c.right,width:280,padding:0},children:n.jsx(An,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d})});return nt.createPortal(w,m)}function Mr({anchorRef:t,columns:o,filterModel:e,onFilterModelChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),f=i.useRef(l);i.useLayoutEffect(()=>{f.current=l},[l]);const[c,p]=i.useState(document.body);i.useLayoutEffect(()=>{p(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const m=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const h=t.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[t]);i.useEffect(()=>{s(m());const h=()=>s(m());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[m]),i.useEffect(()=>{function h(j){j.key==="Escape"&&f.current()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const b=e.items?.length??0,x=()=>{r({...e,items:[],logicOperator:"and"})},w=n.jsxs("div",{ref:a,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[n.jsxs("div",{className:"ogx-toolbar__panel-header",children:[n.jsxs("span",{className:"ogx-toolbar__panel-title",children:[n.jsx(Hn,{}),"Filters",b>0&&n.jsx("span",{className:"ogx-toolbar__panel-count",children:b})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b>0&&n.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:x,title:"Clear all filters",children:"Clear all"}),n.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>f.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),n.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:n.jsx(Bn,{columns:o,filterModel:e,onFilterModelChange:r})})]});return nt.createPortal(w,c)}const Tr={rowFields:[],columnFields:[],valueFields:[]};function Lr({columns:t=[],baseColumns:o,aggregationModel:e={},onAggregationModelChange:r,pivotModel:l,onPivotModelChange:a,filterModel:d,onFilterModelChange:s,columnVisibilityModel:f={},onColumnVisibilityModelChange:c,onColumnReorder:p,forceColumnsOpen:m,onColumnsPanelClose:b,children:x,rightContent:w,style:h}){const[j,P]=i.useState(!1),[k,E]=i.useState(!1),[y,g]=i.useState(!1),[v,N]=i.useState(!1);i.useEffect(()=>{m&&(g(!0),P(!1),E(!1),N(!1))},[m]);const S=i.useRef(null),I=i.useRef(null),M=i.useRef(null),C=i.useRef(null),W=l??Tr,Y=W.rowFields.length>0||W.columnFields.length>0||W.valueFields.length>0,F=t.filter(L=>L.aggregable!==!1&&(L.type==="number"||L.aggregable===!0)),D=Object.keys(e).filter(L=>e[L]&&e[L]!=="none").length,K=i.useCallback((L,X)=>{if(!r)return;const H={...e};X==="none"?delete H[L]:H[L]=X,r(H)},[e,r]),O=i.useCallback(()=>{r?.({})},[r]),V=i.useCallback(L=>{if(!s)return;const H={...d||{},quickFilterValues:L?[L]:[],items:d?.items||[]};s(H)},[d,s]),J=d?.quickFilterValues?.[0]||"",ee=d?.items?.length||0,_=new Set(t.filter(L=>f[L.field]!==!1).map(L=>L.field)),G=i.useCallback((L,X)=>{if(!c)return;const H={...f,[L]:X};c(H)},[f,c]),B=i.useCallback(()=>{if(!c)return;const L={...f};t.forEach(X=>{X.hideable!==!1&&(L[X.field]=!0)}),c(L)},[t,f,c]),z=i.useCallback(()=>{if(!c)return;const L={...f};t.forEach(X=>{X.hideable!==!1&&(L[X.field]=!1)}),c(L)},[t,f,c]);return n.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:h,children:[x&&n.jsx("div",{className:"ogx-toolbar__left",children:x}),n.jsx("div",{className:"ogx-toolbar__spacer"}),n.jsxs("div",{className:"ogx-toolbar__actions",children:[s&&n.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:n.jsx(jr,{value:J,onChange:V,placeholder:"Search..."})}),c&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Columns",children:n.jsx("button",{ref:M,className:`ogx-toolbar__icon-btn${y?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{g(!y),P(!1),E(!1),N(!1)},children:n.jsx(Nr,{})})}),y&&n.jsx(Pr,{anchorRef:M,columns:t,visibleColumns:_,onVisibilityChange:G,onShowAll:B,onHideAll:z,onColumnReorder:p,onClose:()=>{g(!1),b?.()}})]}),s&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Filters",children:n.jsxs("button",{ref:C,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{N(!v),P(!1),E(!1),g(!1)},children:[n.jsx(Hn,{}),ee>0&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),v&&n.jsx(Mr,{anchorRef:C,columns:t,filterModel:d||{items:[]},onFilterModelChange:s,onClose:()=>N(!1)})]}),a&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Pivot",children:n.jsxs("button",{ref:I,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":k,"aria-controls":"ogx-pivot-panel",onClick:()=>{E(!k),P(!1),g(!1),N(!1)},children:[n.jsx($n,{}),Y&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),k&&n.jsx(yr,{anchorRef:I,columns:o??t,model:W,onChange:L=>{a?.(L)},onClose:()=>E(!1)})]}),n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Summaries",children:n.jsxs("button",{ref:S,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${j?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":j,"aria-controls":"ogx-aggregation-panel",onClick:()=>{P(!j),E(!1),g(!1),N(!1)},children:[n.jsx(Dn,{}),D>0&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),j&&n.jsx(Ir,{anchorRef:S,aggregationModel:e,aggregableColumns:F,onFunctionChange:K,onClearAll:O,onClose:()=>P(!1),activeCount:D})]}),w]})]})}function Rr(){return i.useRef(null)}const Wr=({fullWidth:t=!1,error:o=!1,startAdornment:e,endAdornment:r,className:l="",...a})=>{const d=["ogx-input-wrapper",t&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return n.jsxs("div",{className:d,children:[e&&n.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),n.jsx("input",{className:"ogx-input",...a}),r&&n.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})};function Or(t,o,e={}){const{fileName:r="export.csv",includeHeaders:l=!0,delimiter:a=",",selectedRows:d}=e,s=d&&d.length>0?t.filter(p=>d.includes(p.id)):t;if(s.length===0){console.warn("No rows to export");return}const f=o.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c="";if(l){const p=f.map(m=>dt(m.headerName||m.field));c+=p.join(a)+`
9
- `}if(s.forEach(p=>{const m=f.map(b=>{let x=p[b.field];return b.valueGetter&&(x=b.valueGetter({row:p,field:b.field,value:x})),b.valueFormatter&&x!==void 0&&x!==null&&(x=b.valueFormatter({value:x,row:p,field:b.field})),dt(String(x??""))});c+=m.join(a)+`
10
- `}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{},b=f.map(w=>m[w.field]?dt(m[w.field].toUpperCase()):dt(""));c+=b.join(a)+`
11
- `;const x=f.map(w=>{const h=p[w.field];if(h!=null){let j=h;return w.valueFormatter?j=w.valueFormatter({value:h,row:{},field:w.field}):m[w.field]&&(j=qe(h,m[w.field])),dt(String(j))}return dt("")});c+=x.join(a)+`
12
- `}ln(c,r,"text/csv;charset=utf-8;")}function dt(t){return t.includes(",")||t.includes('"')||t.includes(`
13
- `)?`"${t.replace(/"/g,'""')}"`:t}function Fr(t,o,e={}){const{fileName:r="export.xls",sheetName:l="Sheet1",includeHeaders:a=!0,selectedRows:d}=e,s=d&&d.length>0?t.filter(p=>d.includes(p.id)):t;if(s.length===0){console.warn("No rows to export");return}const f=o.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${l}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',a&&(c+="<thead><tr>",f.forEach(p=>{c+=`<th>${He(p.headerName||p.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",s.forEach(p=>{c+="<tr>",f.forEach(m=>{let b=p[m.field];m.valueGetter&&(b=m.valueGetter({row:p,field:m.field,value:b})),m.valueFormatter&&b!==void 0&&b!==null&&(b=m.valueFormatter({value:b,row:p,field:m.field})),c+=`<td>${He(String(b??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(b=>{m[b.field]?c+=`<td style="text-align: right; font-weight: bold;">${He(m[b.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',f.forEach(b=>{const x=p[b.field];if(x!=null){let w=x;b.valueFormatter?w=b.valueFormatter({value:x,row:{},field:b.field}):m[b.field]&&(w=qe(x,m[b.field])),c+=`<td style="text-align: right;">${He(String(w))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",ln(c,r,"application/vnd.ms-excel")}function He(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Ar(t,o,e={}){const{fileName:r="export.json",pretty:l=!0,selectedRows:a}=e,d=a&&a.length>0?t.filter(m=>a.includes(m.id)):t;if(d.length===0){console.warn("No rows to export");return}const s=o.filter(m=>!(m.exportable===!1||m.field==="__check__"||m.field==="__actions__")),f=d.map(m=>{const b={};return s.forEach(x=>{let w=m[x.field];x.valueGetter&&(w=x.valueGetter({row:m,field:x.field,value:w})),b[x.field]=w}),b});let c=f;if(e.aggregationResult){const m=e.aggregationResult,b=e.aggregationModel||{},x={};s.forEach(h=>{b[h.field]&&(x[h.field]=b[h.field].toUpperCase())});const w={};s.forEach(h=>{if(m[h.field]!==void 0&&m[h.field]!==null){let j=m[h.field];h.valueFormatter?j=h.valueFormatter({value:j,row:{},field:h.field}):b[h.field]&&(j=qe(j,b[h.field])),w[h.field]=j}}),c={data:f,aggregation:{labels:x,values:w}}}const p=l?JSON.stringify(c,null,2):JSON.stringify(c);ln(p,r,"application/json;charset=utf-8;")}async function zr(t,o,e){const r=window.open("","_blank");if(!r){console.error("Failed to open print window. Please check your popup blocker settings.");return}r.document.write(`
8
+ ${g}`;try{await Vo(m)}catch(p){console.error("[OpenGridX] Failed to copy to clipboard:",p)}},[t,e,o,i]);return l.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const u=document.activeElement,c=u?.tagName.toLowerCase(),g=u?.type;c==="input"&&g!=="checkbox"&&g!=="radio"||c==="textarea"||c==="select"||u?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function Ko({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},c=g=>{g.stopPropagation(),a?.(n.id,g.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":t+2,"aria-selected":o,children:[i&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:g=>g.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:c,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function Yo({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:i,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:u,rowHeight:c,checkboxSelection:g,paginationMode:m,dataSource:p,serverRowCount:b,paginationSlot:v,paginationSlotProps:_,onRowClick:j,onSelectionChange:I,onPaginationModelChange:h}){const S=v||mn,y=m==="server"&&p?b||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${i.page+1} of ${Math.ceil(e.length/i.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),u]}):t.map((w,f)=>r.jsx(Ko,{row:w,rowIndex:f,listViewColumn:a,isSelected:d.has(w.id),checkboxSelection:g,rowHeight:c,onRowClick:x=>j({row:x,id:x.id,rowIndex:f}),onSelectionChange:I},w.id))}),o&&r.jsx(S,{page:i.page,pageSize:i.pageSize,rowCount:y,pageSizeOptions:s,onPageChange:w=>h({...i,page:w}),onPageSizeChange:w=>h({...i,pageSize:w,page:0}),..._})]})}function qo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function Xo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="number"?n:""),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);s(u),t(u===""?null:u)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function Jo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),o())}})})}function Qo({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),i())},children:d.map(a=>{const u=typeof a=="object"?a.value:a,c=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(u),children:c},String(u))})})}function Zo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="string"?n:String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus()},[]),r.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function er(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Xo,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Jo,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Qo,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Zo,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(qo,{...n})})}}function tr(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:i,row:s,colDef:d,rowIndex:a,colIndex:u,isSelected:c,onClick:g,width:m,pinnedPosition:p,pinnedOffset:b,isFocused:v,isFocusVisible:_,isEditable:j,isEditing:I,onEditStart:h,onEditStop:S,onValueChange:y,colSpanInfo:w,rowSpan:f,isHiddenByRowSpan:x}=n,E=l.useCallback(k=>{o?o(d.field,k):y?.(k)},[o,y,d.field]),M=l.useMemo(()=>d.valueFormatter?d.valueFormatter({value:i,row:s,field:d.field}):i==null?"":String(i),[i,s,d]),N=l.useMemo(()=>I&&(o||y)&&S?d.renderEditCell?d.renderEditCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):r.jsx(er,{value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,onValueChange:E,onCommit:()=>S(),onCancel:()=>S(!0)}):d.renderCell?d.renderCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):M,[i,s,d,a,u,M,I,E,S,o,y]),C=l.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u})||"":d.cellClassName:"",[d,i,s,a,u]),P=l.useRef(null);if(l.useLayoutEffect(()=>{v&&P.current&&P.current.focus({preventScroll:!0})},[v]),w?.spannedByColSpan)return null;if(x)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":u});const O=k=>{t&&t({row:s,field:d.field,value:i,colDef:d,rowIndex:a,colIndex:u}),g?.(k)},T=k=>{j&&(h||e)&&(k.stopPropagation(),e?e(d.field,i):h?.())},A=p!=null,H=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",v&&"ogx__cell--focused",v&&_&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,A&&"ogx__cell--pinned",A&&`ogx__cell--pinned-${p}`,I&&"ogx__cell--editing",f&&f>1&&"ogx__cell--spanned",C].filter(Boolean).join(" "),R=w?.cellProps?.colSpan||1,U=f||1,q=w?.cellProps?.width??m??d.width??100,K={width:"var(--width)","--width":typeof q=="number"?`${q}px`:q,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:A?"sticky":void 0,zIndex:d.zIndex??(A?3:void 0),padding:I?0:void 0};return U>1&&(K.height=`calc(var(--height) * ${U} - var(--border-width, 1px))`,K.zIndex=10,A&&(K.zIndex=40)),A&&b!==void 0&&(p==="left"?K.left=b:K.right=b),r.jsx("div",{ref:P,className:H,style:K,onClick:O,onDoubleClick:T,role:"gridcell","aria-colindex":u+1,"aria-readonly":!j||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":u,...R>1?{"aria-colspan":R}:{},...U>1?{"aria-rowspan":U}:{},children:r.jsx("div",{className:"ogx__cell-content",children:N})})}const vn=l.memo(tr),nr=({className:n="",...t})=>r.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...t,children:r.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function or(n){const{content:t,height:e,isExpanded:o}=n;if(!o)return null;const i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return r.jsx("div",{className:"ogx__detail-panel",style:i,children:r.jsx("div",{className:"ogx__detail-panel-content",children:t})})}function mt(n){const{row:t,columns:e,rowIndex:o,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:u,columnWidths:c={},pinnedColumns:g,pinnedRows:m,hasDetailPanel:p=!1,isDetailPanelExpanded:b=!1,onDetailPanelToggle:v,detailPanelContent:_,detailPanelHeight:j=200,pinCheckboxColumn:I=!0,pinExpandColumn:h=!0,rowReordering:S=!1,onDragStart:y,onDragOver:w,onDragEnd:f,onDrop:x,isDragging:E,isDragOver:M,editingCell:N,onEditStart:C,onEditStop:P,onEditCellValueChange:O,focusedCellField:T,isFocusVisible:A,colspanMap:H,rowSpanningCaches:R,rowHeight:U=52}=n,q=l.useRef(null),K=l.useRef(null);l.useLayoutEffect(()=>{T==="__expand_col__"&&q.current&&q.current.focus({preventScroll:!0}),T==="__checkbox_col__"&&K.current&&K.current.focus({preventScroll:!0})},[T]);const k=l.useMemo(()=>fn(e,c,g,s,I,p,h,S),[e,c,g,s,I,p,h,S]),B=t._hasChildren===!0,W=l.useCallback(($,ae)=>{B||C?.({id:t.id,field:$,value:ae})},[B,t.id,C]),F=l.useCallback(($,ae)=>{O?.({id:t.id,field:$,value:ae})},[O,t.id]),V=l.useCallback($=>{P?.({cancel:$})},[P]);if(t._isSkeleton){const $=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:U,minHeight:U},children:Array.from({length:$}).map((ae,ie)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},ie))})}const G=$=>{$.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},D=$=>{$.stopPropagation(),u?.(t.id,$.target.checked)},L=$=>{$.stopPropagation(),v?.(t.id)},Z=Wt(t.id,m),Q=Z==="top",J=Z==="bottom",ue=["ogx__row",i&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",Q&&"ogx__row--pinned-top",J&&"ogx__row--pinned-bottom",E&&"ogx__row--dragging",M&&"ogx__row--drag-over",B&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ue,onClick:G,role:"row","aria-rowindex":o+1,"aria-selected":i,"data-rowindex":o,onDragOver:w?w(t.id):void 0,onDrop:x?x(t.id):void 0,style:{maxHeight:`${U}px`,minHeight:`${U}px`,"--height":`${U}px`,"--border-width":"1px"},children:[S&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:y?y(t.id):void 0,onDragEnd:f,onClick:$=>$.stopPropagation(),children:r.jsx(nr,{})}),p&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${h?"ogx__cell--pinned-left":""} ${T==="__expand_col__"?"ogx__cell--focused":""} ${T==="__expand_col__"&&A?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":b?"Collapse row details":"Expand row details","aria-expanded":b,style:{position:h?"sticky":void 0,left:h?S?48:0:void 0,zIndex:h?5:void 0},ref:q,tabIndex:-1,onClick:$=>{$.stopPropagation(),a?.({row:t,field:"__expand_col__",value:b,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(gn,{isExpanded:b,onClick:L,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${I?"ogx__cell--pinned-left":""} ${T==="__checkbox_col__"?"ogx__cell--focused":""} ${T==="__checkbox_col__"&&A?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:I?"sticky":void 0,left:I?(S?48:0)+(p&&h?48:0):void 0,zIndex:I?11:void 0},ref:K,tabIndex:-1,onClick:$=>{$.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(lt,{id:`ogx-select-row-${t.id}`,name:`ogx-select-row-${t.id}`,checked:i,onChange:D,onClick:$=>$.stopPropagation(),"aria-label":i?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:$=>$.preventDefault()})}),e.map(($,ae)=>{if($.isSpacer)return r.jsx("div",{style:{width:$.width,minWidth:$.width,flexShrink:0},"aria-hidden":"true"},$.field);const ie=$.valueGetter?$.valueGetter({row:t,field:$.field,value:t[$.field]}):t[$.field],pe=c[$.field]??$.width,le=pt($.field,g),z=le?k[$.field]:void 0,X=N?.id===t.id&&N?.field===$.field,ee=X?N?.value:ie,se=H?.get(t.id)?.[$.field],de=R?.spannedCells[t.id]?.[$.field],je=R?.hiddenCells[t.id]?.[$.field]||!1;return r.jsx(vn,{value:ee,row:t,colDef:$,rowIndex:o,colIndex:ae,isSelected:i,onCellClick:a,width:pe,pinnedPosition:le,pinnedOffset:z,isFocused:T===$.field,isFocusVisible:A,isEditable:$.editable,isEditing:X,onCellEditStart:W,onEditStop:V,onCellValueChange:F,colSpanInfo:se,rowSpan:de,isHiddenByRowSpan:je},$.field)})]}),p&&r.jsx(or,{row:t,rowId:t.id,rowIndex:o,content:_,height:j,isExpanded:b})]})}function _n({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:g,hasDetailPanel:m,expandedRowIds:p,getDetailPanelContent:b,getDetailPanelHeight:v,onDetailPanelToggle:_,pinCheckboxColumn:j,pinExpandColumn:I,focusedCell:h,colspanMap:S,rowSpanningCaches:y,rowHeight:w}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((f,x)=>r.jsx(mt,{row:f,columns:e,rowIndex:x,isSelected:o.has(f.id),checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:g,hasDetailPanel:m,isDetailPanelExpanded:p.has(f.id),detailPanelContent:b?b({row:f,id:f.id,rowIndex:x}):null,detailPanelHeight:v?.({row:f,id:f.id,rowIndex:x})||200,onDetailPanelToggle:_,pinCheckboxColumn:j,pinExpandColumn:I,focusedCellField:h?.id===f.id?h.field:null,colspanMap:S,rowSpanningCaches:y,rowHeight:w},f.id))})}const rr=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:i=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),i&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,u=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:u,height:16,borderRadius:4}})},s.field||d)})]});function ir({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:i,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:u,rowReordering:c,rowHeight:g,pinnedRows:m,selectedRowIds:p,onRowClick:b,onCellClick:v,onSelectionChange:_,columnWidths:j,pinnedColumns:I,expandedRowIds:h,getDetailPanelContent:S,getDetailPanelHeight:y,onDetailPanelToggle:w,pinCheckboxColumn:f,pinExpandColumn:x,rowReorderHandlers:E,editingHandlers:M,focusedCell:N,colspanMap:C,rowSpanningCaches:P,paginationMode:O,dataSourceLoading:T,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:H,unpinnedRowsLength:R}){const U=i.length>0?i:(()=>{const K=(d||1e3)-(a?48:0)-(u?48:0)-(c?48:0),k=150,B=Math.max(1,Math.ceil(K/k));return Array.from({length:B},(W,F)=>({field:`placeholder_${F}`,headerName:"",width:k}))})(),q=o.filter(({row:K})=>!Wt(K.id,m)).filter((K,k,B)=>k===B.findIndex(W=>W.row.id===K.row.id));return r.jsx("div",{className:"ogx__virtual-container",style:{height:`${n}px`},role:"presentation",children:r.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[e&&o.length===0?Array.from({length:10}).map((K,k)=>r.jsx(rr,{columns:U,rowHeight:g,checkboxSelection:a,hasDetailPanel:u,rowReordering:c},`skeleton-${k}`)):q.map(({row:K,rowIndex:k})=>r.jsx(mt,{row:K,columns:s,rowIndex:k,isSelected:p.has(K.id),checkboxSelection:a,onRowClick:b,onCellClick:v,onSelectionChange:_,columnWidths:j,pinnedColumns:I,pinnedRows:m,hasDetailPanel:u,isDetailPanelExpanded:h.has(K.id),detailPanelContent:S?S({row:K,id:K.id,rowIndex:k}):null,detailPanelHeight:y?.({row:K,id:K.id,rowIndex:k})||200,onDetailPanelToggle:w,pinCheckboxColumn:f,pinExpandColumn:x,rowReordering:c,onDragStart:E.onDragStart,onDragOver:E.onDragOver,onDragEnd:E.onDragEnd,onDrop:E.onDrop,isDragging:E.draggedRowId===K.id,isDragOver:E.dragOverRowId===K.id,editingCell:M.editingCell,onEditStart:M.startCellEdit,onEditStop:M.stopCellEdit,onEditCellValueChange:M.setEditCellValue,focusedCellField:N!=null&&N.id===K.id?N.field:null,colspanMap:C,rowSpanningCaches:P,rowHeight:g},K.id)),O==="infinite"&&T&&A>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:H}).map((K,k)=>r.jsx(mt,{row:{id:`__skeleton_${k}__`,_isSkeleton:!0},columns:s,rowIndex:R+k,rowHeight:g},`__skeleton_${k}__`))})]})})}function lr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function sr(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function Cn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a}=n,[u,c]=l.useState(""),[g,m]=l.useState(null),p=l.useRef(null),v=l.useMemo(()=>t.filter(f=>f.hideable!==!1),[t]).every(f=>e.has(f.field)),_=l.useMemo(()=>{if(!u)return t;const f=u.toLowerCase();return t.filter(x=>(x.headerName||x.field).toLowerCase().includes(f))},[t,u]),j=f=>{f.target.checked?i():s()},I=f=>x=>{p.current=f,x.dataTransfer.effectAllowed="move",x.dataTransfer.setDragImage(x.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},h=f=>x=>{x.preventDefault(),x.dataTransfer.dropEffect="move",f!==p.current&&m(f)},S=()=>{m(null)},y=f=>x=>{x.preventDefault();const E=p.current;m(null),p.current=null,E&&E!==f&&d&&d(E,f)},w=()=>{m(null),p.current=null};return r.jsxs("div",{className:"ogx-column-visibility-panel",children:[r.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:r.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[r.jsx(lr,{}),r.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:f=>c(f.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:_.map(f=>{const x=e.has(f.field),E=f.hideable!==!1,M=g===f.field,N=!!d&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!E&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:N,onDragOver:N?h(f.field):void 0,onDragLeave:N?S:void 0,onDrop:N?y(f.field):void 0,onDragEnd:N?w:void 0,children:[N&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:I(f.field),title:"Drag to reorder",children:r.jsx(sr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:E?"pointer":"not-allowed"},children:[r.jsx(lt,{checked:x,onChange:C=>o(f.field,C.target.checked),disabled:!E}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:f.headerName||f.field})]})]},f.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(lt,{checked:v,onChange:j}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{i(),a?.()},children:"Reset"})]})]})}function ar({isOpen:n,containerRef:t,effectiveColumns:e,columnVisibilityModel:o,effectiveColumnOrder:i,columnOrder:s,disableColumnReorder:d,onClose:a,onColumnVisibilityChange:u,onColumnOrderChange:c,setInternalColumnOrder:g}){const[m,p]=l.useState(16),[b,v]=l.useState(16),[_,j]=l.useState(()=>document.body);if(l.useLayoutEffect(()=>{if(!n||!t.current)return;const h=t.current.getBoundingClientRect();p(h.top+8),v(window.innerWidth-h.right+8),j(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const I=d?void 0:(h,S)=>{const y=[...i],w=y.indexOf(h),f=y.indexOf(S);if(w===-1||f===-1)return;const x=[...y];x.splice(w,1),x.splice(f,0,h),s||g(x),c?.({oldIndex:w,targetIndex:f,column:e.find(E=>E.field===h)})};return We.createPortal(r.jsxs("div",{id:"ogx-standalone-col-panel",style:{position:"fixed",top:m,right:b,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:a,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),r.jsx(Cn,{columns:e,visibleColumns:new Set(e.filter(h=>o[h.field]!==!1).map(h=>h.field)),onVisibilityChange:(h,S)=>{u({...o,[h]:S})},onShowAll:()=>{const h={...o};e.forEach(S=>{S.hideable!==!1&&(h[S.field]=!0)}),u(h)},onHideAll:()=>{const h={...o};e.forEach(S=>{S.hideable!==!1&&(h[S.field]=!1)}),u(h)},onColumnReorder:I})]}),_)}function dr(n){const{rows:t,columns:e,getRowId:o,rowHeight:i=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:u,onRowSelectionModelChange:c,onRowClick:g,onCellClick:m,filterModel:p,onFilterModelChange:b,sortModel:v,onSortModelChange:_,pagination:j=!1,paginationModel:I={page:0,pageSize:100},onPaginationModelChange:h,pageSizeOptions:S=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:w,pinnedRows:f,getDetailPanelContent:x,getDetailPanelHeight:E,detailPanelExpandedRowIds:M,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:C=!0,pinExpandColumn:P=!0,disableColumnReorder:O=!1,columnOrder:T,onColumnOrderChange:A,height:H,rowReordering:R=!1,onRowOrderChange:U,loading:q=!1,treeData:K=!1,getTreeDataPath:k,defaultGroupingExpansionDepth:B,rowGroupingModel:W,aggregationModel:F,onAggregationModelChange:V,getAggregationPosition:G,isCellEditable:D,processRowUpdate:L,onProcessRowUpdateError:Z,dataSource:Q,sortingMode:J="client",filterMode:ue="client",paginationMode:$="client",rowCount:ae,slots:ie,slotProps:pe,pivotMode:le=!1,pivotModel:z,onPivotModelChange:X,className:ee="",style:se,onRowsScrollEnd:de,ariaLabel:je,initialState:Ve,onStateChange:fe,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Ke,listView:ne=!1,listViewColumn:be,columnGroupingModel:Fe,noRowsLabel:$t="No Data",apiRef:Dt}=n,qr=l.useMemo(()=>({items:[]}),[]),ke=p||qr,Xr=l.useMemo(()=>[],[]),Ht=W||Xr,Mn=l.useRef(ie?.toolbar);Mn.current=ie?.toolbar;const Jr=l.useRef(Y=>{const te=Mn.current;return te?te(Y):null}).current,Qr=eo({initialState:Ve,sortModel:v,aggregationModel:F,onAggregationModelChange:V,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Ke,pinnedColumns:y,onPinnedColumnsChange:w,pivotModel:z,onPivotModelChange:X,paginationModel:I,onPaginationModelChange:h,rowSelectionModel:u}),{sortModel:Te,isSortControlled:In,setInternalSortModel:Pn,aggregationModel:Se,handleAggregationModelChange:Tn,columnVisibilityModel:Ae,handleColumnVisibilityModelChange:bt,pinnedColumns:Le,handlePinnedColumnsChange:Gt,currentPivotModel:Vt,handlePivotModelChange:Ln,effectivePaginationModel:_e,handlePaginationModelChange:Ut,selectedRowIds:we,isSelectionControlled:wt,setInternalRowSelectionModel:vt}=Qr,_t=c,Ct=wn(t,e,Vt,le),Kt=le&&Ct.isValid?Ct.pivotRows:t,Yt=le&&Ct.isValid?Ct.pivotColumns:e,[Zr,Rn]=l.useState(null);l.useEffect(()=>{Rn(null)},[Se]);const Ye=l.useRef(null),ei=l.useRef(null),yt=l.useRef(null),ti=l.useCallback(Y=>Y.id,[]),kt=o||ti,qe=l.useCallback(Y=>{an.current?.classList.toggle("ogx--kb",Y)},[]),On=l.useRef(Q);On.current=Q;const Wn=l.useRef(null),Fn=l.useRef(null),ni=l.useCallback(Y=>{if(On.current&&K&&(Y.serverChildrenCount??0)>0&&(Y.children??[]).length===0){const te=Fn.current?.getNodePath(Y.id)||[Y.groupingKey];Wn.current?.(Y.id,te)}},[K]),ve=Oo({rows:Kt,columns:Yt,rowHeight:i,headerHeight:s,rowCount:ae,columnVisibilityModel:Ae,initialState:n.initialState}),{state:ce,apiRef:Xe,setRows:qt,setColumns:oi,setDimensions:An,setDataSourceLoading:ri,setDataSourceError:ii,setRowCount:li}=ve,{scrollTop:si,scrollLeft:ai,handleScroll:di}=go({onRowsScrollEnd:de});l.useEffect(()=>{Dt&&(Dt.current=Xe.current)},[Dt,Xe]);const{copySelectedRows:zn}=Uo({selectedRowIds:we,columns:Yt,getVisibleRows:()=>Xe.current.getVisibleRows(),getRowId:kt});l.useEffect(()=>{Xe.current.copySelectedRows=zn,Xe.current.getSelectedRows=()=>Array.from(we)},[zn,we,Xe]);const ci=ce.dataSource.loading,ct=q||ci,Je=l.useMemo(()=>ce.rows.allRows.map(Y=>ce.rows.idRowsLookup.get(Y)),[ce.rows]),Xt=Fo({rows:Je,getRowId:kt,getTreeDataPath:k,treeData:K,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Te,onRowExpansionChange:ni});l.useEffect(()=>{Fn.current=Xt},[Xt]);const ui=zo({rows:Je,getRowId:kt,rowGroupingModel:Ht,aggregationModel:Se,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Te,getAggregationPosition:G}),Qe=Bo({rows:Je,getRowId:kt,processRowUpdate:L,onProcessRowUpdateError:Z,onRowChange:Y=>{const{dispatch:te}=ve,he=Array.from(ve.state.rows.idRowsLookup.values()).map(ge=>ge.id===Y.id?Y:ge);te({type:"SET_ROWS",payload:he})}}),Jt=K,St=!!(Ht&&Ht.length>0),Qt=Jt||St,jt=Jt?Xt:St?ui:null,Ne=j&&!St,Et=l.useCallback(Y=>{const{row:te,id:re}=Y;if(Qt&&te._hasChildren){jt?.toggleExpansion(re);return}g?.(Y)},[Qt,jt,g]),Zt=Do({dataSource:Q,sortModel:Te,filterModel:ke,paginationModel:_e,paginationMode:$,sortingMode:J,filterMode:ue,aggregationModel:Se,setRows:qt,setRowCount:li,setDataSourceLoading:ri,setDataSourceError:ii,onAggregationResults:Rn});l.useEffect(()=>{Zt.fetchChildren&&(Wn.current=Zt.fetchChildren)},[Zt.fetchChildren]),l.useEffect(()=>{Q||qt(Kt)},[Kt,qt,Q]);const Me=!!x,[fi,gi]=l.useState(new Set),Ze=M??fi,Nt=l.useCallback(Y=>{const te=new Set(Ze);te.has(Y)?te.delete(Y):te.add(Y),M===void 0&&gi(te),N?.(te)},[Ze,M,N]),{effectiveColumns:Re,orderedColumns:en,visibleOrderedColumns:hi,navigationColumns:Bn,columnWidths:Oe,effectiveColumnOrder:Mt,setInternalColumnOrder:It,columnReorderHandlers:et,handleColumnResize:pi}=uo({activeColumns:Yt,isHierarchyEnabled:Qt,isRowGrouping:St,isTreeData:Jt,activeHierarchyHandlers:jt,columnVisibilityModel:Ae,columnOrder:T,onColumnOrderChange:A,disableColumnReorder:O,pivotMode:le,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,initialState:Ve,setColumns:oi});ho({onStateChange:fe,sortModel:Te,filterModel:ke,effectivePaginationModel:_e,columnWidths:Oe,effectiveColumnOrder:Mt,columnVisibilityModel:Ae,pinnedColumns:Le});const tt=so({effectiveRows:Je,activeHierarchyHandlers:jt,filterMode:ue,filterModel:ke,dataSource:Q,sortModel:Te,sortingMode:J,pagination:Ne,paginationMode:$,effectivePaginationModel:_e,pinnedRows:f,isLoading:ce.dataSource.loading,pageSize:_e.pageSize}),ze=tt.filteredRows,tn=tt.pinnedTopRows,nn=tt.pinnedBottomRows,nt=tt.sortedUnpinnedRows,ut=tt.paginatedUnpinnedRows,on=tt.allRenderableRows;l.useEffect(()=>{ve.apiRef.current.getVisibleRows=()=>Ne?ut:nt,ve.apiRef.current.getVisibleColumns=()=>Re},[nt,ut,Ne,Re,ve.apiRef]);const xi=Wo({rows:Ne?ut:nt,getRowId:Y=>Y.id,onRowOrderChange:U,rowReordering:R}),ot=$o(on,Bn,Oe),{aggregationResult:rn}=hn({rows:ze,aggregationModel:Se,isServerSide:!!(Q&&($==="server"||J==="server")),dataSource:Q,filterModel:ke,sortModel:Te,serverAggregationResults:Zr}),Pt=Object.keys(Se).length>0;l.useEffect(()=>{ve.apiRef.current.getAggregationResult=()=>Pt?rn:null,ve.apiRef.current.getAggregationModel=()=>Pt?Se:null},[rn,Se,Pt,ve.apiRef]);const Ce=Jn({rowHeight:i,pagination:Ne,paginatedUnpinnedRows:ut,sortedUnpinnedRows:nt,expandedRowIds:Ze,getDetailPanelHeight:E,pinnedTopRowsLength:tn.length,pinnedBottomRowsLength:nn.length,visibleOrderedColumns:hi,pinnedColumns:Le,columnWidths:Oe,viewportWidth:ce.dimensions.viewportWidth||1e3,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,paginationMode:$,isLoading:ce.dataSource.loading,pageSize:_e.pageSize});l.useEffect(()=>{ve.apiRef.current.scrollToIndexes=({rowIndex:Y,colIndex:te})=>{const re=Ye.current;if(re){if(Y!==void 0&&Y>=0){const he=Y>0?Ce.cumulativeHeights[Y-1]:0,ge=Ce.cumulativeHeights[Y]??he,{scrollTop:xe,clientHeight:me}=re;he<xe?re.scrollTop=he:ge>xe+me&&(re.scrollTop=ge-me)}if(te!==void 0&&te>=0){const ge=[...Ce.leftPinnedCols,...Ce.unpinnedColsWithWidth,...Ce.rightPinnedCols][te];if(!ge)return;const xe=Ce.unpinnedColsWithWidth.findIndex(Si=>Si.field===ge.field);if(xe===-1)return;const me=xe>0?Ce.unpinnedAccWidths[xe-1]:0,Rt=Ce.unpinnedAccWidths[xe]??me,Ot=Ce.leftWidth+Rt,{scrollLeft:Gn,clientWidth:Vn}=re;me<Gn?re.scrollLeft=me:Ot>Gn+Vn&&(re.scrollLeft=Ot-Vn)}}}},[Ce,Ye,ve.apiRef]);const ye=ao({layout:Ce,scrollTop:si,scrollLeft:ai,viewportWidth:ce.dimensions.viewportWidth,viewportHeight:ce.dimensions.viewportHeight,autoHeight:d,rowReordering:R,hasDetailPanel:Me,checkboxSelection:a,pinCheckboxColumn:C,pinExpandColumn:P});l.useEffect(()=>{if(!Ye.current)return;const Y=new ResizeObserver(te=>{for(const re of te){const{width:he,height:ge}=re.contentRect;An(he,ge)}});return Y.observe(Ye.current),()=>{Y.disconnect()}},[An]);const ft=l.useCallback((Y,te)=>{const re=new Set(we);te?re.add(Y):re.delete(Y);const he=Array.from(re);wt||vt(he),_t?.(he)},[we,wt,_t,vt]),mi=l.useCallback(Y=>{let te=[];Y&&(te=Je.map(re=>re.id)),wt||vt(te),_t?.(te)},[Je,wt,_t,vt]),$n=l.useCallback((Y,te)=>{const re=te?[{field:Y,sort:te}]:[];In||Pn(re),_?.(re)},[In,_,Pn]),{focusedCell:Tt,setFocusedCell:ln,handleFocus:bi,handleBlur:wi,handleKeyDown:vi}=Qn({allRenderableRows:on,navigationColumns:Bn,checkboxSelection:a,selectedRowIds:we,handleSelectionChange:ft,handleDetailPanelToggle:Nt,editingHandlers:Qe,setKeyboardMode:qe,sortModel:Te,handleSort:$n,isCellEditable:D,pagination:Ne,pageSize:_e.pageSize,virtualization:ye,viewportRef:Ye}),sn=l.useCallback(Y=>{qe(!1),ln({id:Y.row.id,field:Y.field}),yt.current?.focus({preventScroll:!0}),m?.(Y)},[m,qe,ln]),Dn=l.useRef(Qe.editingCell);l.useEffect(()=>{const Y=!!Dn.current,te=!!Qe.editingCell;Y&&!te&&yt.current?.focus({preventScroll:!0}),Dn.current=Qe.editingCell},[Qe.editingCell]);const _i=fo({renderContext:ye.renderContext,pinnedTopRows:tn,pinnedBottomRows:nn,paginatedUnpinnedRows:ut,sortedUnpinnedRows:nt,pagination:Ne}),Ci=t.length>0&&we.size===t.length,yi=we.size>0&&we.size<t.length,ki=l.useMemo(()=>Re.some(Y=>!!Y.rowSpan),[Re]),[gt,Lt]=l.useState(!1),an=l.useRef(null),Hn=l.useMemo(()=>{if(!ie?.toolbar)return null;const Y=O?void 0:(te,re)=>{const he=[...Mt],ge=he.indexOf(te),xe=he.indexOf(re);if(ge===-1||xe===-1)return;const me=[...he];me.splice(ge,1),me.splice(xe,0,te),T||It(me);const Rt=Re.find(Ot=>Ot.field===te);Rt&&A?.({oldIndex:ge,targetIndex:xe,column:Rt})};return{apiRef:ve.apiRef,columns:en,baseColumns:e,aggregationModel:Se,onAggregationModelChange:Tn,...le||z||X?{pivotModel:Vt,onPivotModelChange:Ln}:{},filterModel:ke,onFilterModelChange:b,columnVisibilityModel:Ae,onColumnVisibilityModelChange:bt,onColumnReorder:Y,onColumnOrderReset:O?void 0:()=>It(e.map(te=>te.field)),forceColumnsOpen:gt,onColumnsPanelClose:()=>Lt(!1),...pe?.toolbar}},[ie?.toolbar,O,Mt,en,Re,T,A,It,ve.apiRef,e,Se,Tn,le,z,X,Vt,Ln,ke,b,Ae,bt,gt,pe?.toolbar]);return l.useEffect(()=>{if(!gt||ie?.toolbar)return;function Y(te){const re=document.getElementById("ogx-standalone-col-panel");re&&!re.contains(te.target)&&Lt(!1)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[gt,ie?.toolbar]),r.jsxs("div",{ref:an,className:["ogx",ee,d&&"ogx--auto-height",ki&&"ogx--row-spanning",ne&&"ogx--list-view"].filter(Boolean).join(" "),style:{...se,height:H??se?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":ct,children:[Hn&&r.jsx(Jr,{...Hn}),!ie?.toolbar&&r.jsx(ar,{isOpen:gt,containerRef:an,effectiveColumns:Re,columnVisibilityModel:Ae,effectiveColumnOrder:Mt,columnOrder:T,disableColumnReorder:O,onClose:()=>Lt(!1),onColumnVisibilityChange:bt,onColumnOrderChange:A,setInternalColumnOrder:It}),ne&&be&&r.jsx(Yo,{ariaLabel:je,allRenderableRows:on,filteredRows:ze,pagination:Ne,effectivePaginationModel:_e,pageSizeOptions:S,selectedRowIds:we,listViewColumn:be,noRowsLabel:$t,rowHeight:i,checkboxSelection:a,paginationMode:$,dataSource:Q,serverRowCount:ce.pagination.rowCount||0,paginationSlot:ie?.pagination,paginationSlotProps:pe?.pagination,onRowClick:Et,onSelectionChange:ft,onPaginationModelChange:Ut}),!ne&&r.jsx("div",{ref:Y=>{Ye.current=Y,yt.current=Y},className:"ogx__viewport",onScroll:di,role:"grid","aria-label":je||"Data grid","aria-rowcount":ze.length+1,"aria-colcount":e.length+(a?1:0)+(Me?1:0)+(R?1:0),"aria-busy":ct,tabIndex:0,onKeyDownCapture:()=>{qe(!0)},onMouseDownCapture:()=>{qe(!1)},onKeyDown:vi,onFocus:bi,onBlur:wi,children:r.jsxs("div",{ref:ei,className:"ogx__content",style:{width:ye.totalWidth},role:"presentation",children:[r.jsx(xn,{columns:ye.virtualColumns,allColumns:Re,columnGroupingModel:Fe,checkboxSelection:a,allSelected:Ci,someSelected:yi,onSelectAll:mi,sortModel:Te,onSort:$n,onColumnResize:pi,columnWidths:Oe,pinnedColumns:Le,focusedCell:Tt,onHeaderClick:Y=>{ln({id:"HEADER",field:Y}),qe(!1),yt.current?.focus({preventScroll:!0})},onDragStart:Fe?void 0:et.onDragStart,onDragOver:Fe?void 0:et.onDragOver,onDragEnd:Fe?void 0:et.onDragEnd,onDrop:Fe?void 0:et.onDrop,draggedColumn:Fe?void 0:et.draggedColumn,dragOverColumn:Fe?void 0:et.dragOverColumn,rowReordering:R,hasDetailPanel:Me,pinCheckboxColumn:C,pinExpandColumn:P,aggregationModel:Se,onHideColumn:Y=>{bt({...Ae,[Y]:!1})},onManageColumns:()=>Lt(!0),onPinColumn:(Y,te)=>{const re=[...Le?.left??[]],he=[...Le?.right??[]],ge=re.filter(me=>me!==Y),xe=he.filter(me=>me!==Y);Gt(te==="left"?{left:[...ge,Y],right:xe}:te==="right"?{left:ge,right:[...xe,Y]}:{left:ge,right:xe})}}),!ct&&!ce.dataSource.error&&ze.length===0&&r.jsx(mo,{noRowsLabel:$t,width:ye.totalWidth}),r.jsx(_n,{rows:tn,position:"top",columns:ye.virtualColumns,selectedRowIds:we,checkboxSelection:a,onRowClick:Et,onCellClick:sn,onSelectionChange:ft,columnWidths:Oe,pinnedColumns:Le,pinnedRows:f,hasDetailPanel:Me,expandedRowIds:Ze,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,focusedCell:Tt,colspanMap:ot.colspanMap,rowSpanningCaches:ot.rowSpanningState.caches,rowHeight:i}),r.jsx(ir,{virtualContainerHeight:ye.totalHeight-ye.pinnedTopHeight-ye.pinnedBottomHeight,offsetTop:ye.offsetTop,effectiveLoading:ct,visibleRows:_i,baseColumns:e,virtualColumns:ye.virtualColumns,viewportWidth:ce.dimensions.viewportWidth,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,rowHeight:i,pinnedRows:f,selectedRowIds:we,onRowClick:Et,onCellClick:sn,onSelectionChange:ft,columnWidths:Oe,pinnedColumns:Le,expandedRowIds:Ze,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,rowReorderHandlers:xi,editingHandlers:Qe,focusedCell:Tt,colspanMap:ot.colspanMap,rowSpanningCaches:ot.rowSpanningState.caches,paginationMode:$,dataSourceLoading:ce.dataSource.loading,sortedUnpinnedRowCount:nt.length,infiniteScrollSkeletonCount:Math.min(_e.pageSize,20),unpinnedRowsLength:Ce.unpinnedRowsLength}),r.jsx(_n,{rows:nn,position:"bottom",columns:ye.virtualColumns,selectedRowIds:we,checkboxSelection:a,onRowClick:Et,onCellClick:sn,onSelectionChange:ft,columnWidths:Oe,pinnedColumns:Le,pinnedRows:f,hasDetailPanel:Me,expandedRowIds:Ze,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,focusedCell:Tt,colspanMap:ot.colspanMap,rowSpanningCaches:ot.rowSpanningState.caches,rowHeight:i}),Pt&&!le&&r.jsx(xo,{columns:en,aggregationModel:Se,aggregationResult:rn,columnWidths:Oe,rowHeight:i,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R})]})}),!ne&&Ne&&(()=>{const Y=ie?.pagination||mn;return r.jsx(Y,{page:_e.page,pageSize:_e.pageSize,rowCount:ce.pagination.rowCount,pageSizeOptions:S,onPageChange:te=>Ut({..._e,page:te}),onPageSizeChange:te=>Ut({..._e,pageSize:te,page:0}),...pe?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[ct?"Loading data...":"",ce.dataSource.error?`Error: ${ce.dataSource.error instanceof Error?ce.dataSource.error.message:"Unknown error"}`:"",!q&&!ce.dataSource.error&&(ze.length===0?$t:ke&&((ke.quickFilterValues?.length||0)>0||(ke.items?.length||0)>0)?`${ze.length} ${ze.length===1?"row":"rows"} found`:"")]}),r.jsx(bo,{error:ce.dataSource.error})]})}function cr({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((i,s)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},s))},o))})}const yn=new Set(["isEmpty","isNotEmpty"]);function ur(n,t){return n.find(e=>"field"in e&&e.field===t)}const fr=({col:n,item:t,onChange:e})=>{const o=io(n.type),i=!!t,s=t?.operator??o[0],[d,a]=l.useState(t?.value!=null?String(t.value):""),u=l.useRef(e),c=l.useRef(t),g=l.useRef(n.field),m=l.useRef(s);l.useLayoutEffect(()=>{u.current=e,c.current=t,g.current=n.field,m.current=s});const p=l.useRef(t?.value);l.useEffect(()=>{t?.value!==p.current&&(p.current=t?.value,a(t?.value!=null?String(t.value):""))},[t?.value]),l.useEffect(()=>{const h=setTimeout(()=>{const S=c.current,y=S?.value??"";d!==y&&u.current({id:S?.id??`${g.current}-${Date.now()}`,field:g.current,operator:m.current,value:d})},300);return()=>clearTimeout(h)},[d]);const b=h=>{const S=yn.has(h),y={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:h,value:S?void 0:t?.value??(n.type==="boolean"?"true":"")};e(y)},v=()=>{a(""),e(null)},_=yn.has(String(s)),j=n.type==="boolean",I=!_;return r.jsxs("div",{className:`ogx-filter__row${i?" ogx-filter__row--active":""}`,children:[r.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),r.jsxs("div",{className:"ogx-filter__controls",children:[r.jsx("select",{id:`ogx-filter-op-${n.field}`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${i?" ogx-filter__op-select--active":""}`,value:String(s),onChange:h=>b(h.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:o.map(h=>r.jsx("option",{value:h,children:h},h))}),I&&j&&r.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${i?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:h=>{a(h.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:s,value:h.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),I&&!j&&r.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${i?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:h=>a(h.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),i&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:v,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},kn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=l.useMemo(()=>n.items??[],[n.items]),i=n.logicOperator??"and",s=l.useCallback((u,c)=>{const g=o.filter(p=>"field"in p&&p.field!==u),m=c?[...g,c]:g;e({...n,items:m})},[o,n,e]),d=l.useCallback(u=>{e({...n,logicOperator:u})},[n,e]),a=t.filter(u=>u.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(u=>r.jsx(fr,{col:u,item:ur(o,u.field),onChange:c=>s(u.field,c)},u.field))]})},gr=["sum","avg","count","min","max"];function Sn(){return r.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function hr({anchorRef:n,columns:t,model:e,onChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),[u,c]=l.useState(document.body);l.useLayoutEffect(()=>{c(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const g=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const C=n.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[n]);l.useEffect(()=>{a(g());const C=()=>a(g());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[g]),l.useEffect(()=>{function C(O){s.current&&!s.current.contains(O.target)&&n.current&&!n.current.contains(O.target)&&i()}function P(O){O.key==="Escape"&&i()}return document.addEventListener("mousedown",C),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",P)}},[n,i]);const m=new Set(e.rowFields),p=new Set(e.columnFields),b=new Set(e.valueFields.map(C=>C.field)),v=C=>m.has(C)||p.has(C)||b.has(C);function _(C){m.has(C)||o({...e,rowFields:[...e.rowFields,C]})}function j(C){p.has(C)||o({...e,columnFields:[...e.columnFields,C]})}function I(C,P="sum"){b.has(C)||o({...e,valueFields:[...e.valueFields,{field:C,aggFn:P}]})}function h(C){o({...e,rowFields:e.rowFields.filter(P=>P!==C)})}function S(C){o({...e,columnFields:e.columnFields.filter(P=>P!==C)})}function y(C){o({...e,valueFields:e.valueFields.filter(P=>P.field!==C)})}function w(C,P){o({...e,valueFields:e.valueFields.map(O=>O.field===C?{...O,aggFn:P}:O)})}function f(){o({rowFields:[],columnFields:[],valueFields:[]})}const x=new Set(t.filter(C=>C.type==="number"||C.aggregable).map(C=>C.field)),E=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=C=>t.find(P=>P.field===C)?.headerName??C,N=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Sn,{}),"Pivot Mode"]}),E>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:f,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(C),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>h(C),title:`Remove ${M(C)}`,children:"×"})]},C))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(C),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>S(C),title:`Remove ${M(C)}`,children:"×"})]},C))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),r.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(C.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:C.aggFn,onChange:P=>w(C.field,P.target.value),title:"Aggregation function",children:gr.map(P=>r.jsx("option",{value:P,children:P.toUpperCase()},P))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(C.field),title:`Remove ${M(C.field)}`,children:"×"})]},C.field))})]}),r.jsx("hr",{className:"ogx-pivot-panel__divider"}),r.jsxs("div",{children:[r.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),r.jsxs("div",{className:"ogx-pivot-fields",children:[t.map(C=>{const P=x.has(C.field);return v(C.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${P?" ogx-pivot-field-btn--numeric":""}`,children:C.headerName??C.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>_(C.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>j(C.field),title:"Add to Column Fields",children:"Col"}),P&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>I(C.field),title:"Add to Value Fields",children:"Val"})]})]},C.field)}),t.every(C=>v(C.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return We.createPortal(N,u)}function pr(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function xr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function mr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[i,s]=l.useState(()=>n.length>0),[d,a]=l.useState(n),u=l.useRef(null),c=l.useRef(null),g=l.useRef(t);l.useLayoutEffect(()=>{g.current=t},[t]);const m=l.useRef(n),p=l.useRef(n),b=l.useRef(!1);l.useLayoutEffect(()=>{b.current&&document.activeElement!==u.current&&u.current?.focus()}),l.useEffect(()=>{n!==p.current&&(p.current=n,n!==m.current&&(a(n),m.current=n,n?s(!0):(b.current=!1,s(!1))))},[n]),l.useEffect(()=>{const h=setTimeout(()=>{d!==m.current&&(m.current=d,g.current(d))},o);return()=>clearTimeout(h)},[d,o]);const v=l.useCallback(()=>{s(!0),requestAnimationFrame(()=>u.current?.focus())},[]),_=l.useCallback(h=>{h.stopPropagation(),a(""),m.current="",g.current(""),u.current?.focus()},[]),j=l.useCallback(()=>{b.current=!0,s(!0)},[]),I=l.useCallback(()=>{b.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){b.current=!0;return}d||s(!1)},150)},[d]);return l.useEffect(()=>{const h=S=>{c.current&&!c.current.contains(S.target)&&(d||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[d]),r.jsxs("div",{ref:c,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:i?void 0:v,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(pr,{})}),r.jsx("input",{ref:u,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:h=>a(h.target.value),onFocus:j,onBlur:I,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:_,"aria-label":"Clear search",children:r.jsx(xr,{})})]})}function dt({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:i=0}){const[s,d]=l.useState(!1),[a,u]=l.useState({top:0,left:0}),c=l.useRef(null),g=l.useRef(null),m=l.useCallback(()=>{if(!g.current)return;const _=g.current.getBoundingClientRect();let j=0,I=0;const h=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(j=_.top+S-8,I=_.left+h+_.width/2):e==="bottom"&&(j=_.bottom+S+8,I=_.left+h+_.width/2),u({top:j,left:I})},[e]);l.useLayoutEffect(()=>(s&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[s,m]);const p=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},o)},b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},i)},v=l.useCallback(_=>{g.current=_?_.firstElementChild??_:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:v,style:{display:"inline-block",lineHeight:0},onMouseEnter:p,onMouseLeave:b,children:t}),s&&n&&We.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const br=["none","sum","avg","count","min","max"];function jn(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function wr(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function En(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function vr({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:i,onClose:s,activeCount:d}){const a=l.useRef(null),[u,c]=l.useState({top:0,right:0}),[g,m]=l.useState(document.body);l.useLayoutEffect(()=>{m(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const v=n.current.getBoundingClientRect();return{top:v.bottom+6,right:window.innerWidth-v.right}},[n]);l.useEffect(()=>{c(p());const v=()=>c(p());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[p]),l.useEffect(()=>{function v(_){a.current&&!a.current.contains(_.target)&&n.current&&!n.current.contains(_.target)&&s()}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n,s]),l.useEffect(()=>{function v(_){_.key==="Escape"&&s()}return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);const b=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:u.top,right:u.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(jn,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(v=>{const _=t[v.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:v.field,children:v.headerName||v.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:br.map(j=>r.jsx("button",{className:`ogx-toolbar__pill${_===j?" ogx-toolbar__pill--active":""}`,onClick:()=>o(v.field,j),"aria-pressed":_===j,children:j},j))})]},v.field)})})]});return We.createPortal(b,g)}function _r({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:u}){const c=l.useRef(null),[g,m]=l.useState({top:0,right:0}),[p,b]=l.useState(document.body);l.useLayoutEffect(()=>{b(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const v=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const j=n.current.getBoundingClientRect();return{top:j.bottom+6,right:window.innerWidth-j.right}},[n]);l.useEffect(()=>{m(v());const j=()=>m(v());return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[v]),l.useEffect(()=>{function j(I){c.current&&!c.current.contains(I.target)&&n.current&&!n.current.contains(I.target)&&u()}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,u]);const _=r.jsx("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:g.top,right:g.right,width:280,padding:0},children:r.jsx(Cn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a})});return We.createPortal(_,p)}function Cr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),u=l.useRef(i);l.useLayoutEffect(()=>{u.current=i},[i]);const[c,g]=l.useState(document.body);l.useLayoutEffect(()=>{g(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const m=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const _=n.current.getBoundingClientRect();return{top:_.bottom+6,right:window.innerWidth-_.right}},[n]);l.useEffect(()=>{a(m());const _=()=>a(m());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[m]),l.useEffect(()=>{function _(j){j.key==="Escape"&&u.current()}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[]);const p=e.items?.length??0,b=()=>{o({...e,items:[],logicOperator:"and"})},v=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(En,{}),"Filters",p>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:p})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:b,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(kn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return We.createPortal(v,c)}const yr={rowFields:[],columnFields:[],valueFields:[]};function kr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:i,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:u={},onColumnVisibilityModelChange:c,onColumnReorder:g,onColumnOrderReset:m,forceColumnsOpen:p,onColumnsPanelClose:b,children:v,rightContent:_,style:j}){const[I,h]=l.useState(!1),[S,y]=l.useState(!1),[w,f]=l.useState(!1),[x,E]=l.useState(!1);l.useEffect(()=>{p&&(f(!0),h(!1),y(!1),E(!1))},[p]);const M=l.useRef(null),N=l.useRef(null),C=l.useRef(null),P=l.useRef(null),O=i??yr,T=O.rowFields.length>0||O.columnFields.length>0||O.valueFields.length>0,A=n.filter(G=>G.aggregable!==!1&&(G.type==="number"||G.aggregable===!0)),H=Object.keys(e).filter(G=>e[G]&&e[G]!=="none").length,R=l.useCallback((G,D)=>{if(!o)return;const L={...e};D==="none"?delete L[G]:L[G]=D,o(L)},[e,o]),U=l.useCallback(()=>{o?.({})},[o]),q=l.useCallback(G=>{if(!a)return;const L={...d||{},quickFilterValues:G?[G]:[],items:d?.items||[]};a(L)},[d,a]),K=d?.quickFilterValues?.[0]||"",k=d?.items?.length||0,B=new Set(n.filter(G=>u[G.field]!==!1).map(G=>G.field)),W=l.useCallback((G,D)=>{if(!c)return;const L={...u,[G]:D};c(L)},[u,c]),F=l.useCallback(()=>{if(!c)return;const G={...u};n.forEach(D=>{D.hideable!==!1&&(G[D.field]=!0)}),c(G)},[n,u,c]),V=l.useCallback(()=>{if(!c)return;const G={...u};n.forEach(D=>{D.hideable!==!1&&(G[D.field]=!1)}),c(G)},[n,u,c]);return r.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:j,children:[v&&r.jsx("div",{className:"ogx-toolbar__left",children:v}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:r.jsx(mr,{value:K,onChange:q,placeholder:"Search..."})}),c&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(dt,{title:"Columns",children:r.jsx("button",{ref:C,className:`ogx-toolbar__icon-btn${w?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{f(!w),h(!1),y(!1),E(!1)},children:r.jsx(wr,{})})}),w&&r.jsx(_r,{anchorRef:C,columns:n,visibleColumns:B,onVisibilityChange:W,onShowAll:F,onHideAll:V,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>{f(!1),b?.()}})]}),a&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(dt,{title:"Filters",children:r.jsxs("button",{ref:P,className:`ogx-toolbar__icon-btn${x?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{E(!x),h(!1),y(!1),f(!1)},children:[r.jsx(En,{}),k>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),x&&r.jsx(Cr,{anchorRef:P,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>E(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(dt,{title:"Pivot",children:r.jsxs("button",{ref:N,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":S,"aria-controls":"ogx-pivot-panel",onClick:()=>{y(!S),h(!1),f(!1),E(!1)},children:[r.jsx(Sn,{}),T&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),S&&r.jsx(hr,{anchorRef:N,columns:t??n,model:O,onChange:G=>{s?.(G)},onClose:()=>y(!1)})]}),r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(dt,{title:"Summaries",children:r.jsxs("button",{ref:M,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${I?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":I,"aria-controls":"ogx-aggregation-panel",onClick:()=>{h(!I),y(!1),f(!1),E(!1)},children:[r.jsx(jn,{}),H>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${H} active summaries`})]})}),I&&r.jsx(vr,{anchorRef:M,aggregationModel:e,aggregableColumns:A,onFunctionChange:R,onClearAll:U,onClose:()=>h(!1),activeCount:H})]}),_]})]})}function Sr(){return l.useRef(null)}const jr=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:i="",...s})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return r.jsxs("div",{className:d,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...s}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Er(n,t,e={}){const{fileName:o="export.csv",includeHeaders:i=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(g=>d.includes(g.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(g=>!(g.exportable===!1||g.field==="__check__"||g.field==="__actions__"));let c="";if(i){const g=u.map(m=>Ge(m.headerName||m.field));c+=g.join(s)+`
9
+ `}if(a.forEach(g=>{const m=u.map(p=>{let b=g[p.field];return p.valueGetter&&(b=p.valueGetter({row:g,field:p.field,value:b})),p.valueFormatter&&b!==void 0&&b!==null&&(b=p.valueFormatter({value:b,row:g,field:p.field})),Ge(String(b??""))});c+=m.join(s)+`
10
+ `}),e.aggregationResult){const g=e.aggregationResult,m=e.aggregationModel||{},p=u.map(v=>m[v.field]?Ge(m[v.field].toUpperCase()):Ge(""));c+=p.join(s)+`
11
+ `;const b=u.map(v=>{const _=g[v.field];if(_!=null){let j=_;return v.valueFormatter?j=v.valueFormatter({value:_,row:{},field:v.field}):m[v.field]&&(j=Ie(_,m[v.field])),Ge(String(j))}return Ge("")});c+=b.join(s)+`
12
+ `}Bt(c,o,"text/csv;charset=utf-8;")}function Ge(n){return n.includes(",")||n.includes('"')||n.includes(`
13
+ `)?`"${n.replace(/"/g,'""')}"`:n}function Nr(n,t,e={}){const{fileName:o="export.xls",sheetName:i="Sheet1",includeHeaders:s=!0,selectedRows:d}=e,a=d&&d.length>0?n.filter(g=>d.includes(g.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(g=>!(g.exportable===!1||g.field==="__check__"||g.field==="__actions__"));let c='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${i}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',s&&(c+="<thead><tr>",u.forEach(g=>{c+=`<th>${Ee(g.headerName||g.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",a.forEach(g=>{c+="<tr>",u.forEach(m=>{let p=g[m.field];m.valueGetter&&(p=m.valueGetter({row:g,field:m.field,value:p})),m.valueFormatter&&p!==void 0&&p!==null&&(p=m.valueFormatter({value:p,row:g,field:m.field})),c+=`<td>${Ee(String(p??""))}</td>`})}),e.aggregationResult){const g=e.aggregationResult,m=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(p=>{m[p.field]?c+=`<td style="text-align: right; font-weight: bold;">${Ee(m[p.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(p=>{const b=g[p.field];if(b!=null){let v=b;p.valueFormatter?v=p.valueFormatter({value:b,row:{},field:p.field}):m[p.field]&&(v=Ie(b,m[p.field])),c+=`<td style="text-align: right;">${Ee(String(v))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",Bt(c,o,"application/vnd.ms-excel")}function Ee(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Mr(n,t,e={}){const{fileName:o="export.json",pretty:i=!0,selectedRows:s}=e,d=s&&s.length>0?n.filter(m=>s.includes(m.id)):n;if(d.length===0){console.warn("No rows to export");return}const a=t.filter(m=>!(m.exportable===!1||m.field==="__check__"||m.field==="__actions__")),u=d.map(m=>{const p={};return a.forEach(b=>{let v=m[b.field];b.valueGetter&&(v=b.valueGetter({row:m,field:b.field,value:v})),p[b.field]=v}),p});let c=u;if(e.aggregationResult){const m=e.aggregationResult,p=e.aggregationModel||{},b={};a.forEach(_=>{p[_.field]&&(b[_.field]=p[_.field].toUpperCase())});const v={};a.forEach(_=>{if(m[_.field]!==void 0&&m[_.field]!==null){let j=m[_.field];_.valueFormatter?j=_.valueFormatter({value:j,row:{},field:_.field}):p[_.field]&&(j=Ie(j,p[_.field])),v[_.field]=j}}),c={data:u,aggregation:{labels:b,values:v}}}const g=i?JSON.stringify(c,null,2):JSON.stringify(c);Bt(g,o,"application/json;charset=utf-8;")}async function Ir(n,t,e){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
14
14
  <!DOCTYPE html>
15
15
  <html>
16
16
  <head>
@@ -30,11 +30,11 @@ ${p}`;try{await hr(m)}catch(b){console.error("[OpenGridX] Failed to copy to clip
30
30
  </div>
31
31
  </body>
32
32
  </html>
33
- `),r.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",a,d=null,s=null;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",a=e.selectedRows,d=e.aggregationResult||null,s=e.aggregationModel||null);const f=a&&a.length>0?t.filter(b=>a.includes(b.id)):t;if(f.length===0){r.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=o.filter(b=>!(b.exportable===!1||b.field==="__check__"||b.field==="__actions__"));let p=`
33
+ `),o.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",s,d=null,a=null;typeof e=="string"?i=e:typeof e=="object"&&(i=e.title||"Print",s=e.selectedRows,d=e.aggregationResult||null,a=e.aggregationModel||null);const u=s&&s.length>0?n.filter(p=>s.includes(p.id)):n;if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let g=`
34
34
  <!DOCTYPE html>
35
35
  <html>
36
36
  <head>
37
- <title>${l||"Print"}</title>
37
+ <title>${i||"Print"}</title>
38
38
  <style>
39
39
  body { font-family: Arial, sans-serif; margin: 20px; }
40
40
  h1 { font-size: 24px; margin-bottom: 20px; }
@@ -49,5 +49,5 @@ ${p}`;try{await hr(m)}catch(b){console.error("[OpenGridX] Failed to copy to clip
49
49
  </style>
50
50
  </head>
51
51
  <body>
52
- `;if(l&&(p+=`<h1>${He(l)}</h1>`),p+="<table>",p+="<thead><tr>",c.forEach(b=>{p+=`<th>${He(b.headerName||b.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",f.forEach(b=>{p+="<tr>",c.forEach(x=>{let w=b[x.field];x.valueGetter&&(w=x.valueGetter({row:b,field:x.field,value:w})),x.valueFormatter&&w!==void 0&&w!==null&&(w=x.valueFormatter({value:w,row:b,field:x.field})),x.type==="image"&&w?p+=`<td><div style="display:flex;justify-content:center;"><img src="${w}" alt="${x.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${He(String(w??""))}</td>`}),p+="</tr>"}),d){const b=s||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(x=>{b[x.field]?p+=`<td style="text-align: right; font-weight: bold;">${He(b[x.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(x=>{const w=d[x.field];if(w!=null){let h=w;x.valueFormatter?h=x.valueFormatter({value:w,row:{},field:x.field}):b[x.field]&&(h=qe(w,b[x.field])),p+=`<td style="text-align: right;">${He(String(h))}</td>`}else p+="<td></td>"}),p+="</tr></tfoot>"}p+="</tbody></table></body></html>",r.document.open(),r.document.write(p),r.document.close(),r.document.title=l||"Print Preview",r.focus();let m=!1;r.onload=()=>{m||(m=!0,r.print(),setTimeout(()=>{r.close()},100))},setTimeout(()=>{!m&&r&&!r.closed&&(m=!0,r.print(),setTimeout(()=>{r.closed||r.close()},100))},500)}catch(l){console.error("Print generation failed:",l),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${l.message}</p></div>`)}}function ln(t,o,e){const r=new Blob([t],{type:e}),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=o,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}function Br(t,o){return t.type==="number"?"number":t.type==="boolean"?"boolean":t.type==="date"?"date":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date?"date":"string"}function $r(t){if(t.type==="number")return"#,##0.##";if(t.type==="date")return"yyyy-mm-dd"}function Dr(t,o){if(o!=null)return o;const e=t.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Hr(t,o){const e=o??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const r=t.split("?")[0].toLowerCase();return r.endsWith(".jpg")||r.endsWith(".jpeg")?"jpeg":r.endsWith(".gif")?"gif":"png"}async function Gr(t){const o=await Promise.allSettled(t.map(async r=>{if(r.startsWith("data:")){const s=r.indexOf(","),f=r.slice(0,s),c=r.slice(s+1),p=atob(c),m=new Uint8Array(p.length);for(let h=0;h<p.length;h++)m[h]=p.charCodeAt(h);const x=f.match(/data:([^;,]+)/)?.[1]??"image/png";let w="png";return x.includes("jpeg")||x.includes("jpg")?w="jpeg":x.includes("gif")&&(w="gif"),{url:r,buffer:m.buffer,ext:w}}const l=await fetch(r,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const a=await l.arrayBuffer(),d=Hr(r,l.headers.get("content-type"));return{url:r,buffer:a,ext:d}})),e=new Map;return o.forEach((r,l)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${t[l]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function Vr(t,o,e={}){const{fileName:r="export.xlsx",sheets:l,columnStyles:a={},headerFillColor:d="#f1f5f9",headerTextColor:s="#334155",headerFontSize:f=10,bodyFontSize:c=10,aggregationResult:p=null,aggregationModel:m=null,selectedRows:b}=e,x=(await import("exceljs")).default,w=new x.Workbook;w.creator="OpenGridX",w.created=new Date;const h=o.filter(S=>S.exportable!==!1&&S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),j=t,P=b&&b.length>0?t.filter(S=>b.includes(S.id)):t,k=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],E=new Map;for(const S of k){if("type"in S&&S.type==="summary"){if(!p||!m)continue;const _=w.addWorksheet(S.name??"Summary");_.addRow(["Summary / Aggregation Totals"]),_.getRow(1).font={bold:!0,size:f+2,color:{argb:Je(s)}},_.addRow([]),_.addRow(["Column","Function","Value"]).eachCell(B=>{B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},B.font={bold:!0,size:f,color:{argb:Je(s)}},B.border=Gn()}),h.forEach(B=>{const z=m[B.field],L=p[B.field];if(z==null||L==null)return;let X=L;B.valueFormatter?X=B.valueFormatter({value:L,row:{},field:B.field}):X=qe(L,z);const H=_.addRow([B.headerName??B.field,z.toUpperCase(),X]);H.getCell(3).alignment={horizontal:"right"},H.getCell(3).font={bold:!0,size:c}}),_.getColumn(1).width=20,_.getColumn(2).width=12,_.getColumn(3).width=18;continue}const I=S,{name:M="Data",rows:C="all",includeHeaders:W=!0,includeSummary:Y=!1,autoFilter:F=!0,frozenHeader:D=!0,alternateRowColor:K="#f8fafc"}=I,O=C==="selected"?P:j,V=h.filter(_=>a[_.field]?.embedImage);if(V.length>0){const _=[],G=new Set;if(O.forEach(B=>{V.forEach(z=>{const L=B[z.field];typeof L=="string"&&L&&!E.has(L)&&!G.has(L)&&(_.push(L),G.add(L))})}),_.length>0){const B=await Gr(_);for(const[z,{buffer:L,extension:X}]of B){const H=w.addImage({buffer:L,extension:X});E.set(z,H)}}}const J=w.addWorksheet(M);if(J.columns=h.map(_=>({key:_.field,width:Dr(_,a[_.field]?.width),style:{numFmt:a[_.field]?.numFmt??$r(_)}})),W){const _=h.map(B=>B.headerName??B.field),G=J.addRow(_);G.height=20,G.eachCell((B,z)=>{const L=h[z-1];B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},B.font={bold:!0,size:f,color:{argb:Je(s)}},B.alignment={horizontal:a[L?.field]?.alignment??(L?.type==="number"?"right":"left"),vertical:"middle"},B.border=Gn()}),F&&(J.autoFilter={from:{row:1,column:1},to:{row:1,column:h.length}}),D?J.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:J.views=[{showGridLines:!1}]}let ee=W?1:0;if(O.forEach((_,G)=>{const B=h.map(L=>{if(a[L.field]?.embedImage)return"";let X=_[L.field];return L.valueGetter&&(X=L.valueGetter({row:_,field:L.field,value:X})),Br(L,X)==="string"&&L.valueFormatter&&X!=null&&(X=L.valueFormatter({value:X,row:_,field:L.field})),X}),z=J.addRow(B);if(z.font={size:c},K&&G%2===1&&z.eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(K)}}}),z.eachCell((L,X)=>{const H=h[X-1];H&&(L.alignment={horizontal:a[H.field]?.alignment??(H.type==="number"?"right":"left"),vertical:"middle"},L.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),V.length>0){const L=V.reduce((R,re)=>Math.max(R,a[re.field]?.imageHeight??40),0),X=Math.ceil(L/1.333),H=X*1.333;z.height=X,V.forEach(R=>{const re=h.indexOf(R),Z=_[R.field],se=typeof Z=="string"?E.get(Z):void 0;if(se===void 0){z.getCell(re+1).value=typeof Z=="string"?Z:"";return}const me=a[R.field],U=me?.imageWidth??40,pe=me?.imageHeight??40,je=(J.getColumn(re+1).width??8)*7+5,ge=Math.max(0,je-U)/2,be=Math.max(0,H-pe)/2;J.addImage(se,{tl:{col:re,row:ee,nativeColOff:Math.floor(ge*9525),nativeRowOff:Math.floor(be*9525)},ext:{width:U,height:pe},editAs:"oneCell"})})}else z.height=16;ee++}),Y&&p&&m){const _=h.map(L=>{const X=m[L.field];return X?X.toUpperCase():""}),G=J.addRow(_);G.height=16,G.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},G.eachCell(L=>{L.alignment={horizontal:"right",vertical:"middle"},L.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const B=h.map(L=>{const X=m[L.field],H=p[L.field];return X==null||H==null?"":L.valueFormatter?L.valueFormatter({value:H,row:{},field:L.field}):qe(H,X)}),z=J.addRow(B);z.height=18,z.font={bold:!0,size:c,color:{argb:Je(s)}},z.eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},L.alignment={horizontal:"right",vertical:"middle"},L.border=Ur()})}}const y=await w.xlsx.writeBuffer(),g=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),v=URL.createObjectURL(g),N=document.createElement("a");N.href=v,N.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(v)}function Je(t){const o=t.replace("#","");return o.length===3?"FF"+o.split("").map(e=>e+e).join(""):o.length===6?"FF"+o:"FF"+o.padEnd(6,"0")}function Gn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ur(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const Kr={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-toolbar-background":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function Yr(t){const o={};function e(r,l){l!==void 0&&(o[r]=l)}if(t.colors){const r=t.colors;e("--ogx-color-primary",r.primary),e("--ogx-color-primary-dark",r.primaryDark),e("--ogx-color-primary-light",r.primaryLight),e("--ogx-color-primary-focus",r.primaryFocus),e("--ogx-color-secondary",r.secondary),e("--ogx-color-secondary-dark",r.secondaryDark),e("--ogx-color-secondary-light",r.secondaryLight),e("--ogx-color-success",r.success),e("--ogx-color-warning",r.warning),e("--ogx-color-error",r.error),e("--ogx-color-info",r.info)}if(t.typography){const r=t.typography;e("--ogx-font-family",r.fontFamily),e("--ogx-font-family-mono",r.fontFamilyMono),e("--ogx-font-size-xs",r.fontSizeXs),e("--ogx-font-size-sm",r.fontSizeSm),e("--ogx-font-size-md",r.fontSizeMd),e("--ogx-font-size-lg",r.fontSizeLg),e("--ogx-font-size-xl",r.fontSizeXl)}if(t.spacing){const r=t.spacing;e("--ogx-spacing-xs",r.xs),e("--ogx-spacing-sm",r.sm),e("--ogx-spacing-md",r.md),e("--ogx-spacing-lg",r.lg),e("--ogx-spacing-xl",r.xl),e("--ogx-spacing-xxl",r.xxl)}if(t.borders){const r=t.borders;e("--ogx-border-width-thin",r.widthThin),e("--ogx-border-width-medium",r.widthMedium),e("--ogx-border-width-thick",r.widthThick),e("--ogx-border-radius-sm",r.radiusSm),e("--ogx-border-radius-md",r.radiusMd),e("--ogx-border-radius-lg",r.radiusLg),e("--ogx-border-radius-xl",r.radiusXl),e("--ogx-border-color",r.color),e("--ogx-border-color-hover",r.colorHover)}if(t.shadows){const r=t.shadows;e("--ogx-shadow-sm",r.sm),e("--ogx-shadow-md",r.md),e("--ogx-shadow-lg",r.lg),e("--ogx-shadow-xl",r.xl)}if(t.grid){const r=t.grid;e("--ogx-grid-row-height-compact",r.rowHeightCompact),e("--ogx-grid-row-height-standard",r.rowHeightStandard),e("--ogx-row-height",r.rowHeightStandard),e("--ogx-grid-row-height-comfortable",r.rowHeightComfortable),e("--ogx-grid-header-height",r.headerHeight),e("--ogx-header-height",r.headerHeight),e("--ogx-grid-cell-padding-x",r.cellPaddingX),e("--ogx-grid-cell-padding-y",r.cellPaddingY),e("--ogx-grid-background",r.background),e("--ogx-grid-border-color",r.borderColor),e("--ogx-grid-header-background",r.headerBackground),e("--ogx-grid-header-text",r.headerText),e("--ogx-grid-header-hover-background",r.headerHoverBackground),e("--ogx-grid-header-sorted-background",r.headerSortedBackground),e("--ogx-grid-row-text",r.rowText),e("--ogx-grid-row-hover-background",r.rowHoverBackground),e("--ogx-grid-row-alternate-background",r.rowAlternateBackground),e("--ogx-grid-row-selected-background",r.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",r.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",r.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",r.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",r.pinnedRightShadow),e("--ogx-checkbox-bg",r.checkboxBg),e("--ogx-checkbox-border",r.checkboxBorder)}if(t.transitions){const r=t.transitions;e("--ogx-transition-duration-fast",r.durationFast),e("--ogx-transition-duration-normal",r.durationNormal),e("--ogx-transition-duration-slow",r.durationSlow),e("--ogx-transition-easing",r.easing)}if(t.toolbar){const r=t.toolbar;e("--ogx-toolbar-background",r.background),e("--ogx-toolbar-text",r.text),e("--ogx-toolbar-border",r.border),e("--ogx-toolbar-btn-bg",r.buttonBackground),e("--ogx-toolbar-btn-hover",r.buttonHoverBackground),e("--ogx-toolbar-btn-text",r.buttonText),e("--ogx-toolbar-btn-primary-bg",r.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",r.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",r.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",r.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",r.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",r.buttonDangerText),e("--ogx-toolbar-input-bg",r.inputBackground),e("--ogx-toolbar-input-text",r.inputText),e("--ogx-toolbar-input-border",r.inputBorder),e("--ogx-toolbar-input-focus-border",r.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",r.inputFocusShadow),e("--ogx-toolbar-chip-bg",r.chipBackground),e("--ogx-toolbar-chip-text",r.chipText),e("--ogx-toolbar-chip-active-bg",r.chipActiveBackground),e("--ogx-toolbar-chip-active-text",r.chipActiveText)}if(t.overlays){const r=t.overlays;e("--ogx-overlay-background",r.background),e("--ogx-overlay-text",r.text),e("--ogx-overlay-border",r.border),e("--ogx-overlay-shadow",r.shadow),e("--ogx-overlay-item-hover-bg",r.itemHoverBackground),e("--ogx-overlay-item-hover-text",r.itemHoverText),e("--ogx-overlay-item-selected-bg",r.itemSelectedBackground),e("--ogx-overlay-item-selected-text",r.itemSelectedText),e("--ogx-overlay-item-danger-bg",r.itemDangerBackground),e("--ogx-overlay-item-danger-text",r.itemDangerText)}if(t.scrollbar){const r=t.scrollbar;e("--ogx-scrollbar-thumb",r.thumbColor),e("--ogx-scrollbar-track",r.trackColor),e("--ogx-scrollbar-size",r.size)}if(t.skeleton){const r=t.skeleton;e("--ogx-skeleton-base",r.baseColor),e("--ogx-skeleton-highlight",r.highlightColor),e("--ogx-skeleton-dark-base",r.darkBaseColor),e("--ogx-skeleton-dark-highlight",r.darkHighlightColor)}return o}function Xr({theme:t,children:o,className:e,style:r}){const l=i.useMemo(()=>({...Kr,...Yr(t)}),[t]);return n.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...l},children:o})}const qr={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Jr={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48"}},Qr={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},Zr={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},ei={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function ti(t,o){try{const e=o.getItem(t);return e?JSON.parse(e):void 0}catch{return}}function ni(t,o,e,r){try{const l=e?Object.fromEntries(Object.entries(o).filter(([a])=>e.includes(a))):o;r.setItem(t,JSON.stringify(l))}catch{}}function oi(t){const o=typeof t=="string"?{key:t}:t,{key:e,debounceMs:r=300,include:l,storage:a=typeof window<"u"?window.localStorage:void 0}=o,d=i.useMemo(()=>{if(a)return ti(e,a)},[e]),s=i.useRef(null),f=i.useRef(null),c=i.useCallback(()=>{f.current&&a&&ni(e,f.current,l,a)},[e,l,a]),p=i.useCallback(b=>{f.current=b,s.current&&clearTimeout(s.current),s.current=setTimeout(c,r)},[c,r]);i.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),c())},[c]);const m=i.useCallback(()=>{a&&a.removeItem(e)},[e,a]);return{initialState:d,onStateChange:p,clearState:m}}ie.Button=jt,ie.Cell=Ln,ie.Checkbox=kt,ie.DataGrid=br,ie.DataGridThemeProvider=Xr,ie.FilterPanel=Bn,ie.GridToolbar=Lr,ie.GridTooltip=Et,ie.Header=Tn,ie.Input=Wr,ie.Row=St,ie.Skeleton=wr,ie.amberTheme=Zr,ie.compactTheme=ei,ie.darkTheme=qr,ie.emeraldTheme=Qr,ie.exportToCsv=Or,ie.exportToExcel=Fr,ie.exportToExcelAdvanced=Vr,ie.exportToJson=Ar,ie.formatAggregationValue=qe,ie.printGrid=zr,ie.roseTheme=Jr,ie.useAggregation=On,ie.useGridApiRef=Rr,ie.useGridStateStorage=oi,ie.usePivot=Fn,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
52
+ `;if(i&&(g+=`<h1>${Ee(i)}</h1>`),g+="<table>",g+="<thead><tr>",c.forEach(p=>{g+=`<th>${Ee(p.headerName||p.field)}</th>`}),g+="</tr></thead>",g+="<tbody>",u.forEach(p=>{g+="<tr>",c.forEach(b=>{let v=p[b.field];b.valueGetter&&(v=b.valueGetter({row:p,field:b.field,value:v})),b.valueFormatter&&v!==void 0&&v!==null&&(v=b.valueFormatter({value:v,row:p,field:b.field})),b.type==="image"&&v?g+=`<td><div style="display:flex;justify-content:center;"><img src="${v}" alt="${b.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:g+=`<td>${Ee(String(v??""))}</td>`}),g+="</tr>"}),d){const p=a||{};g+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(b=>{p[b.field]?g+=`<td style="text-align: right; font-weight: bold;">${Ee(p[b.field].toUpperCase())}</td>`:g+="<td></td>"}),g+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(b=>{const v=d[b.field];if(v!=null){let _=v;b.valueFormatter?_=b.valueFormatter({value:v,row:{},field:b.field}):p[b.field]&&(_=Ie(v,p[b.field])),g+=`<td style="text-align: right;">${Ee(String(_))}</td>`}else g+="<td></td>"}),g+="</tr></tfoot>"}g+="</tbody></table></body></html>",o.document.open(),o.document.write(g),o.document.close(),o.document.title=i||"Print Preview",o.focus();let m=!1;o.onload=()=>{m||(m=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!m&&o&&!o.closed&&(m=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(i){if(console.error("Print generation failed:",i),o&&!o.closed){const s=i instanceof Error?i.message:String(i);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${s}</p></div>`}}}function Bt(n,t,e){const o=new Blob([n],{type:e}),i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function Pr(n,t){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function Tr(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function Lr(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Rr(n,t){const e=t??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const o=n.split("?")[0].toLowerCase();return o.endsWith(".jpg")||o.endsWith(".jpeg")?"jpeg":o.endsWith(".gif")?"gif":"png"}async function Or(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),u=o.slice(0,a),c=o.slice(a+1),g=atob(c),m=new Uint8Array(g.length);for(let _=0;_<g.length;_++)m[_]=g.charCodeAt(_);const b=u.match(/data:([^;,]+)/)?.[1]??"image/png";let v="png";return b.includes("jpeg")||b.includes("jpg")?v="jpeg":b.includes("gif")&&(v="gif"),{url:o,buffer:m.buffer,ext:v}}const i=await fetch(o,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),d=Rr(o,i.headers.get("content-type"));return{url:o,buffer:s,ext:d}})),e=new Map;return t.forEach((o,i)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function Wr(n,t,e={}){const{fileName:o="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:u=10,bodyFontSize:c=10,aggregationResult:g=null,aggregationModel:m=null,selectedRows:p}=e,b=(await import("exceljs")).default,v=new b.Workbook;v.creator="OpenGridX",v.created=new Date;const _=t.filter(E=>E.exportable!==!1&&E.field!=="__check__"&&E.field!=="__actions__"&&!E.isSpacer),j=n,I=p&&p.length>0?n.filter(E=>p.includes(E.id)):n,h=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],S=new Map;for(const E of h){if("type"in E&&E.type==="summary"){if(!g||!m)continue;const k=v.addWorksheet(E.name??"Summary");k.addRow(["Summary / Aggregation Totals"]),k.getRow(1).font={bold:!0,size:u+2,color:{argb:Pe(a)}},k.addRow([]),k.addRow(["Column","Function","Value"]).eachCell(W=>{W.fill={type:"pattern",pattern:"solid",fgColor:{argb:Pe(d)}},W.font={bold:!0,size:u,color:{argb:Pe(a)}},W.border=Nn()}),_.forEach(W=>{const F=m[W.field],V=g[W.field];if(F==null||V==null)return;let G=V;W.valueFormatter?G=W.valueFormatter({value:V,row:{},field:W.field}):G=Ie(V,F);const D=k.addRow([W.headerName??W.field,F.toUpperCase(),G]);D.getCell(3).alignment={horizontal:"right"},D.getCell(3).font={bold:!0,size:c}}),k.getColumn(1).width=20,k.getColumn(2).width=12,k.getColumn(3).width=18;continue}const M=E,{name:N="Data",rows:C="all",includeHeaders:P=!0,includeSummary:O=!1,autoFilter:T=!0,frozenHeader:A=!0,alternateRowColor:H="#f8fafc"}=M,R=C==="selected"?I:j,U=_.filter(k=>s[k.field]?.embedImage);if(U.length>0){const k=[],B=new Set;if(R.forEach(W=>{U.forEach(F=>{const V=W[F.field];typeof V=="string"&&V&&!S.has(V)&&!B.has(V)&&(k.push(V),B.add(V))})}),k.length>0){const W=await Or(k);for(const[F,{buffer:V,extension:G}]of W){const D=v.addImage({buffer:V,extension:G});S.set(F,D)}}}const q=v.addWorksheet(N);if(q.columns=_.map(k=>({key:k.field,width:Lr(k,s[k.field]?.width),style:{numFmt:s[k.field]?.numFmt??Tr(k)}})),P){const k=_.map(W=>W.headerName??W.field),B=q.addRow(k);B.height=20,B.eachCell((W,F)=>{const V=_[F-1];W.fill={type:"pattern",pattern:"solid",fgColor:{argb:Pe(d)}},W.font={bold:!0,size:u,color:{argb:Pe(a)}},W.alignment={horizontal:s[V?.field]?.alignment??(V?.type==="number"?"right":"left"),vertical:"middle"},W.border=Nn()}),T&&(q.autoFilter={from:{row:1,column:1},to:{row:1,column:_.length}}),A?q.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:q.views=[{showGridLines:!1}]}let K=P?1:0;if(R.forEach((k,B)=>{const W=_.map(V=>{if(s[V.field]?.embedImage)return"";let G=k[V.field];return V.valueGetter&&(G=V.valueGetter({row:k,field:V.field,value:G})),Pr(V,G)==="string"&&V.valueFormatter&&G!=null&&(G=V.valueFormatter({value:G,row:k,field:V.field})),G}),F=q.addRow(W);if(F.font={size:c},H&&B%2===1&&F.eachCell(V=>{V.fill={type:"pattern",pattern:"solid",fgColor:{argb:Pe(H)}}}),F.eachCell((V,G)=>{const D=_[G-1];D&&(V.alignment={horizontal:s[D.field]?.alignment??(D.type==="number"?"right":"left"),vertical:"middle"},V.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),U.length>0){const V=U.reduce((L,Z)=>Math.max(L,s[Z.field]?.imageHeight??40),0),G=Math.ceil(V/1.333),D=G*1.333;F.height=G,U.forEach(L=>{const Z=_.indexOf(L),Q=k[L.field],J=typeof Q=="string"?S.get(Q):void 0;if(J===void 0){F.getCell(Z+1).value=typeof Q=="string"?Q:"";return}const ue=s[L.field],$=ue?.imageWidth??40,ae=ue?.imageHeight??40,pe=(q.getColumn(Z+1).width??8)*7+5,le=Math.max(0,pe-$)/2,z=Math.max(0,D-ae)/2;q.addImage(J,{tl:{col:Z,row:K,nativeColOff:Math.floor(le*9525),nativeRowOff:Math.floor(z*9525)},ext:{width:$,height:ae},editAs:"oneCell"})})}else F.height=16;K++}),O&&g&&m){const k=_.map(V=>{const G=m[V.field];return G?G.toUpperCase():""}),B=q.addRow(k);B.height=16,B.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},B.eachCell(V=>{V.alignment={horizontal:"right",vertical:"middle"},V.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const W=_.map(V=>{const G=m[V.field],D=g[V.field];return G==null||D==null?"":V.valueFormatter?V.valueFormatter({value:D,row:{},field:V.field}):Ie(D,G)}),F=q.addRow(W);F.height=18,F.font={bold:!0,size:c,color:{argb:Pe(a)}},F.eachCell(V=>{V.fill={type:"pattern",pattern:"solid",fgColor:{argb:Pe(d)}},V.alignment={horizontal:"right",vertical:"middle"},V.border=Fr()})}}const y=await v.xlsx.writeBuffer(),w=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),f=URL.createObjectURL(w),x=document.createElement("a");x.href=f,x.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(f)}function Pe(n){const t=n.replace("#","");return t.length===3?"FF"+t.split("").map(e=>e+e).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Nn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Fr(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const Ar={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-toolbar-background":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function zr(n){const t={};function e(o,i){i!==void 0&&(t[o]=i)}if(n.colors){const o=n.colors;e("--ogx-color-primary",o.primary),e("--ogx-color-primary-dark",o.primaryDark),e("--ogx-color-primary-light",o.primaryLight),e("--ogx-color-primary-focus",o.primaryFocus),e("--ogx-color-secondary",o.secondary),e("--ogx-color-secondary-dark",o.secondaryDark),e("--ogx-color-secondary-light",o.secondaryLight),e("--ogx-color-success",o.success),e("--ogx-color-warning",o.warning),e("--ogx-color-error",o.error),e("--ogx-color-info",o.info)}if(n.typography){const o=n.typography;e("--ogx-font-family",o.fontFamily),e("--ogx-font-family-mono",o.fontFamilyMono),e("--ogx-font-size-xs",o.fontSizeXs),e("--ogx-font-size-sm",o.fontSizeSm),e("--ogx-font-size-md",o.fontSizeMd),e("--ogx-font-size-lg",o.fontSizeLg),e("--ogx-font-size-xl",o.fontSizeXl)}if(n.spacing){const o=n.spacing;e("--ogx-spacing-xs",o.xs),e("--ogx-spacing-sm",o.sm),e("--ogx-spacing-md",o.md),e("--ogx-spacing-lg",o.lg),e("--ogx-spacing-xl",o.xl),e("--ogx-spacing-xxl",o.xxl)}if(n.borders){const o=n.borders;e("--ogx-border-width-thin",o.widthThin),e("--ogx-border-width-medium",o.widthMedium),e("--ogx-border-width-thick",o.widthThick),e("--ogx-border-radius-sm",o.radiusSm),e("--ogx-border-radius-md",o.radiusMd),e("--ogx-border-radius-lg",o.radiusLg),e("--ogx-border-radius-xl",o.radiusXl),e("--ogx-border-color",o.color),e("--ogx-border-color-hover",o.colorHover)}if(n.shadows){const o=n.shadows;e("--ogx-shadow-sm",o.sm),e("--ogx-shadow-md",o.md),e("--ogx-shadow-lg",o.lg),e("--ogx-shadow-xl",o.xl)}if(n.grid){const o=n.grid;e("--ogx-grid-row-height-compact",o.rowHeightCompact),e("--ogx-grid-row-height-standard",o.rowHeightStandard),e("--ogx-row-height",o.rowHeightStandard),e("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),e("--ogx-grid-header-height",o.headerHeight),e("--ogx-header-height",o.headerHeight),e("--ogx-grid-cell-padding-x",o.cellPaddingX),e("--ogx-grid-cell-padding-y",o.cellPaddingY),e("--ogx-grid-background",o.background),e("--ogx-grid-border-color",o.borderColor),e("--ogx-grid-header-background",o.headerBackground),e("--ogx-grid-header-text",o.headerText),e("--ogx-grid-header-hover-background",o.headerHoverBackground),e("--ogx-grid-header-sorted-background",o.headerSortedBackground),e("--ogx-grid-row-text",o.rowText),e("--ogx-grid-row-hover-background",o.rowHoverBackground),e("--ogx-grid-row-alternate-background",o.rowAlternateBackground),e("--ogx-grid-row-selected-background",o.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",o.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),e("--ogx-checkbox-bg",o.checkboxBg),e("--ogx-checkbox-border",o.checkboxBorder)}if(n.transitions){const o=n.transitions;e("--ogx-transition-duration-fast",o.durationFast),e("--ogx-transition-duration-normal",o.durationNormal),e("--ogx-transition-duration-slow",o.durationSlow),e("--ogx-transition-easing",o.easing)}if(n.toolbar){const o=n.toolbar;e("--ogx-toolbar-background",o.background),e("--ogx-toolbar-text",o.text),e("--ogx-toolbar-border",o.border),e("--ogx-toolbar-btn-bg",o.buttonBackground),e("--ogx-toolbar-btn-hover",o.buttonHoverBackground),e("--ogx-toolbar-btn-text",o.buttonText),e("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",o.buttonDangerText),e("--ogx-toolbar-input-bg",o.inputBackground),e("--ogx-toolbar-input-text",o.inputText),e("--ogx-toolbar-input-border",o.inputBorder),e("--ogx-toolbar-input-focus-border",o.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),e("--ogx-toolbar-chip-bg",o.chipBackground),e("--ogx-toolbar-chip-text",o.chipText),e("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),e("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(n.overlays){const o=n.overlays;e("--ogx-overlay-background",o.background),e("--ogx-overlay-text",o.text),e("--ogx-overlay-border",o.border),e("--ogx-overlay-shadow",o.shadow),e("--ogx-overlay-item-hover-bg",o.itemHoverBackground),e("--ogx-overlay-item-hover-text",o.itemHoverText),e("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),e("--ogx-overlay-item-selected-text",o.itemSelectedText),e("--ogx-overlay-item-danger-bg",o.itemDangerBackground),e("--ogx-overlay-item-danger-text",o.itemDangerText)}if(n.scrollbar){const o=n.scrollbar;e("--ogx-scrollbar-thumb",o.thumbColor),e("--ogx-scrollbar-track",o.trackColor),e("--ogx-scrollbar-size",o.size)}if(n.skeleton){const o=n.skeleton;e("--ogx-skeleton-base",o.baseColor),e("--ogx-skeleton-highlight",o.highlightColor),e("--ogx-skeleton-dark-base",o.darkBaseColor),e("--ogx-skeleton-dark-highlight",o.darkHighlightColor)}return t}function Br({theme:n,children:t,className:e,style:o}){const i=l.useMemo(()=>({...Ar,...zr(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...i},children:t})}const $r={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Dr={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48"}},Hr={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},Gr={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},Vr={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Ur(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function Kr(n,t,e,o){try{const i=e?Object.fromEntries(Object.entries(t).filter(([s])=>e.includes(s))):t;o.setItem(n,JSON.stringify(i))}catch{}}function Yr(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=t,d=l.useMemo(()=>{if(s)return Ur(e,s)},[e,s]),a=l.useRef(null),u=l.useRef(null),c=l.useCallback(()=>{u.current&&s&&Kr(e,u.current,i,s)},[e,i,s]),g=l.useCallback(p=>{u.current=p,a.current&&clearTimeout(a.current),a.current=setTimeout(c,o)},[c,o]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),c())},[c]);const m=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:g,clearState:m}}oe.Button=st,oe.Cell=vn,oe.Checkbox=lt,oe.DataGrid=dr,oe.DataGridThemeProvider=Br,oe.FilterPanel=kn,oe.GridToolbar=kr,oe.GridTooltip=dt,oe.Header=xn,oe.Input=jr,oe.Row=mt,oe.Skeleton=cr,oe.amberTheme=Gr,oe.compactTheme=Vr,oe.darkTheme=$r,oe.emeraldTheme=Hr,oe.exportToCsv=Er,oe.exportToExcel=Nr,oe.exportToExcelAdvanced=Wr,oe.exportToJson=Mr,oe.formatAggregationValue=Ie,oe.printGrid=Ir,oe.roseTheme=Dr,oe.useAggregation=hn,oe.useGridApiRef=Sr,oe.useGridStateStorage=Yr,oe.usePivot=wn,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})}));
53
53
  //# sourceMappingURL=opengridx.umd.js.map