@opencorestack/opengridx 0.1.6 → 0.1.8
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.
- package/CHANGELOG.md +30 -1
- package/README.md +9 -0
- package/dist/index.d.ts +12 -1
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +2505 -2450
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +12 -12
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +177 -0
- package/docs/README.md +60 -0
- package/docs/components/cell.md +44 -0
- package/docs/components/column-group-header.md +57 -0
- package/docs/components/column-resize.md +63 -0
- package/docs/components/column-visibility.md +61 -0
- package/docs/components/datagrid.md +70 -0
- package/docs/components/filter-panel.md +26 -0
- package/docs/components/header.md +39 -0
- package/docs/components/pagination.md +34 -0
- package/docs/components/row.md +31 -0
- package/docs/components/toolbar.md +40 -0
- package/docs/components/tooltip.md +68 -0
- package/docs/customization/slots-api.md +227 -0
- package/docs/customization/theming.md +293 -0
- package/docs/features/aggregation-pivot.md +79 -0
- package/docs/features/cell-spanning.md +520 -0
- package/docs/features/clipboard.md +76 -0
- package/docs/features/custom-pagination.md +143 -0
- package/docs/features/data-source.md +72 -0
- package/docs/features/editing-reordering.md +99 -0
- package/docs/features/export-guide.md +434 -0
- package/docs/features/filtering.md +83 -0
- package/docs/features/infinite-scroll.md +87 -0
- package/docs/features/list-view.md +65 -0
- package/docs/features/loading-states.md +68 -0
- package/docs/features/master-detail.md +46 -0
- package/docs/features/pinning.md +67 -0
- package/docs/features/selection.md +70 -0
- package/docs/features/sorting-pagination.md +66 -0
- package/docs/features/state-persistence.md +67 -0
- package/docs/features/tree-data-grouping.md +67 -0
- package/docs/features/virtualization.md +188 -0
- package/docs/roadmap.md +71 -0
- package/lib/components/Cell/Cell.css +119 -0
- package/lib/components/Cell/Cell.tsx +264 -0
- package/lib/components/Cell/GridEditInputCell.css +62 -0
- package/lib/components/Cell/GridEditInputCell.tsx +152 -0
- package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +67 -0
- package/lib/components/ColumnGroupHeader/ColumnGroupHeader.tsx +220 -0
- package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +31 -0
- package/lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx +85 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +137 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +190 -0
- package/lib/components/DataGrid/DataGrid.css +224 -0
- package/lib/components/DataGrid/DataGrid.tsx +2269 -0
- package/lib/components/DetailPanel/DetailPanel.css +36 -0
- package/lib/components/DetailPanel/DetailPanel.tsx +34 -0
- package/lib/components/FilterPanel/FilterPanel.css +196 -0
- package/lib/components/FilterPanel/FilterPanel.tsx +214 -0
- package/lib/components/FilterPanel/index.ts +1 -0
- package/lib/components/Header/ColumnMenu.css +68 -0
- package/lib/components/Header/ColumnMenu.tsx +249 -0
- package/lib/components/Header/Header.css +224 -0
- package/lib/components/Header/Header.tsx +516 -0
- package/lib/components/ListView/ListView.css +112 -0
- package/lib/components/ListView/ListViewRow.tsx +63 -0
- package/lib/components/Pagination/Pagination.css +91 -0
- package/lib/components/Pagination/Pagination.tsx +151 -0
- package/lib/components/QuickFilter/QuickFilter.css +23 -0
- package/lib/components/QuickFilter/QuickFilter.tsx +79 -0
- package/lib/components/Row/Row.css +126 -0
- package/lib/components/Row/Row.tsx +377 -0
- package/lib/components/Skeleton/Skeleton.css +55 -0
- package/lib/components/Skeleton/Skeleton.tsx +22 -0
- package/lib/components/SkeletonRow/SkeletonRow.css +32 -0
- package/lib/components/SkeletonRow/SkeletonRow.tsx +89 -0
- package/lib/components/SkeletonRow/index.ts +1 -0
- package/lib/components/Toolbar/GlobalSearch.css +110 -0
- package/lib/components/Toolbar/GlobalSearch.tsx +167 -0
- package/lib/components/Toolbar/GridToolbar.css +221 -0
- package/lib/components/Toolbar/GridToolbar.tsx +658 -0
- package/lib/components/Toolbar/PivotPanel.css +212 -0
- package/lib/components/Toolbar/PivotPanel.tsx +239 -0
- package/lib/components/Tooltip/Tooltip.css +59 -0
- package/lib/components/Tooltip/Tooltip.tsx +106 -0
- package/lib/components/ui/Button.css +89 -0
- package/lib/components/ui/Button.tsx +39 -0
- package/lib/components/ui/Checkbox.css +71 -0
- package/lib/components/ui/Checkbox.tsx +66 -0
- package/lib/components/ui/DragHandleIcon.css +19 -0
- package/lib/components/ui/DragHandleIcon.tsx +18 -0
- package/lib/components/ui/ExpandIcon.css +38 -0
- package/lib/components/ui/ExpandIcon.tsx +75 -0
- package/lib/components/ui/Input.css +59 -0
- package/lib/components/ui/Input.tsx +45 -0
- package/lib/components/ui/index.ts +15 -0
- package/lib/hooks/core/useDataGrid.ts +392 -0
- package/lib/hooks/core/useGridApiRef.ts +10 -0
- package/lib/hooks/features/useAggregation.ts +143 -0
- package/lib/hooks/features/useGridClipboard.ts +133 -0
- package/lib/hooks/features/useGridDataSource.ts +190 -0
- package/lib/hooks/features/useGridEditing.ts +100 -0
- package/lib/hooks/features/useGridSpanning.ts +349 -0
- package/lib/hooks/features/usePivot.ts +174 -0
- package/lib/hooks/useColumnReorder.ts +114 -0
- package/lib/hooks/useRowGrouping.ts +302 -0
- package/lib/hooks/useRowReorder.ts +83 -0
- package/lib/hooks/useTreeData.ts +323 -0
- package/lib/index.ts +106 -0
- package/lib/state/index.ts +17 -0
- package/lib/state/types.ts +48 -0
- package/lib/state/useGridStateStorage.ts +113 -0
- package/lib/styles/base/reset.css +21 -0
- package/lib/styles/base/variables.css +161 -0
- package/lib/styles/opengridx.css +27 -0
- package/lib/styles/opengridx.css.d.ts +4 -0
- package/lib/theme/DataGridThemeProvider.tsx +276 -0
- package/lib/theme/defaultStyles.ts +0 -0
- package/lib/theme/index.ts +21 -0
- package/lib/theme/presets.ts +148 -0
- package/lib/theme/types.ts +155 -0
- package/lib/types/index.ts +764 -0
- package/lib/utils/export/exportToExcelAdvanced.ts +516 -0
- package/lib/utils/export/index.ts +550 -0
- package/lib/utils/filtering/index.ts +240 -0
- package/lib/utils/pinning/index.ts +282 -0
- package/lib/utils/sorting/index.ts +55 -0
- package/lib/utils/virtualization/index.ts +106 -0
- package/lib/vite-env.d.ts +1 -0
- package/llms.txt +2 -1
- package/package.json +12 -4
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(ie,
|
|
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,St){"use strict";var an={exports:{}},Yt={};var Qn;function Fo(){if(Qn)return Yt;Qn=1;var n=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:n,type:r,key:d,ref:l!==void 0?l:null,props:a}}return Yt.Fragment=o,Yt.jsx=e,Yt.jsxs=e,Yt}var Xt={};var Zn;function Wo(){return Zn||(Zn=1,process.env.NODE_ENV!=="production"&&(function(){function n(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===O?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case E:return"Fragment";case k:return"Profiler";case P:return"StrictMode";case v:return"Suspense";case M:return"SuspenseList";case N: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 b:return"Portal";case y:return _.displayName||"Context";case j:return(_._context.displayName||"Context")+".Consumer";case w:var D=_.render;return _=_.displayName,_||(_=D.displayName||D.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case S:return D=_.displayName||null,D!==null?D:n(_.type)||"Memo";case x:D=_._payload,_=_._init;try{return n(_(D))}catch{}}return null}function o(_){return""+_}function e(_){try{o(_);var D=!1}catch{D=!0}if(D){D=console;var H=D.error,K=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return H.call(D,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),o(_)}}function r(_){if(_===E)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===x)return"<...>";try{var D=n(_);return D?"<"+D+">":"<...>"}catch{return"<...>"}}function l(){var _=W.A;return _===null?null:_.getOwner()}function a(){return Error("react-stack-top-frame")}function d(_){if(X.call(_,"key")){var D=Object.getOwnPropertyDescriptor(_,"key").get;if(D&&D.isReactWarning)return!1}return _.key!==void 0}function s(_,D){function H(){q||(q=!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)",D))}H.isReactWarning=!0,Object.defineProperty(_,"key",{get:H,configurable:!0})}function g(){var _=n(this.type);return G[_]||(G[_]=!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 u(_,D,H,K,R,Y){var $=H.ref;return _={$$typeof:C,type:_,key:D,props:H,_owner:K},($!==void 0?$:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:g}):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:R}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function h(_,D,H,K,R,Y){var $=D.children;if($!==void 0)if(K)if(A($)){for(K=0;K<$.length;K++)m($[K]);Object.freeze&&Object.freeze($)}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($);if(X.call(D,"key")){$=n(_);var L=Object.keys(D).filter(function(oe){return oe!=="key"});K=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",pe[$+K]||(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} />`,W,K,L,K),pe[K+W]=!0)}if(K=null,H!==void 0&&(e(H),K=""+H),c(D)&&(e(D.key),K=""+D.key),"key"in D){H={};for(var ae in D)ae!=="key"&&(H[ae]=D[ae])}else H=D;return K&&a(H,typeof v=="function"?v.displayName||v.name||"Unknown":v),f(v,K,H,i(),F,q)}function m(v){u(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===x&&(v._payload.status==="fulfilled"?u(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function u(v){return typeof v=="object"&&v!==null&&v.$$typeof===w}var h=l,w=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,A=Array.isArray,U=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(v){return v()}};var X,G={},ee=h.react_stack_bottom_frame.bind(h,s)(),Q=U(r(s)),pe={};Xt.Fragment=M,Xt.jsx=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!1,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)},Xt.jsxs=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!0,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)}})()),Xt}var eo;function Ao(){return eo||(eo=1,process.env.NODE_ENV==="production"?an.exports=Wo():an.exports=Fo()),an.exports}var t=Ao();function zo({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:c,onSelectionChange:a}){const g={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},f=p=>{p.stopPropagation(),a?.(n.id,p.target.checked)};return t.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>c?.(n),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[i&&t.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:r,onChange:f,"aria-label":`Select row ${n.id}`})}),t.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(g)})]})}const qt=({indeterminate:n=!1,label:o,className:e="",inputRef:r,...i})=>{const s=l.useRef(null),c=l.useCallback(g=>{s.current=g,typeof r=="function"?r(g):r&&(r.current=g)},[r]);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 t.jsxs("label",{className:a,children:[t.jsx("input",{ref:c,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),t.jsxs("span",{className:"ogx-checkbox__box",children:[i.checked&&!n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),o&&t.jsx("span",{className:"ogx-checkbox__label",children:o})]})};function Bo(n){const{field:o,currentWidth:e,onResize:r,minWidth:i=50,maxWidth:s=1e3}=n,[c,a]=l.useState(!1),g=l.useRef(0),f=l.useRef(0),p=l.useCallback(h=>{h.preventDefault(),h.stopPropagation(),a(!0),g.current=h.clientX,f.current=e;let w=0;const b=16,M=E=>{const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k)),_=Date.now();_-w>=b&&(r(o,C),w=_)},P=E=>{a(!1);const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k));r(o,C),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",P)},[o,e,r,i,s]),m=l.useCallback(h=>{h.preventDefault(),h.stopPropagation()},[]),u=["ogx-column-resize-handle",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return t.jsx("div",{className:u,onMouseDown:p,onClick:h=>h.stopPropagation(),onDragStart:h=>{h.preventDefault(),h.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} column`,children:t.jsx("div",{className:"ogx-column-resize-handle__line"})})}function dn(n,o){return o?o.left?.includes(n)?"left":o.right?.includes(n)?"right":null:null}function $o(n,o){const e=[],r=[],i=[];return o?(n.forEach(s=>{const c=dn(s.field,o);c==="left"?e.push(s):c==="right"?i.push(s):r.push(s)}),o.left&&e.sort((s,c)=>{const a=o.left.indexOf(s.field),g=o.left.indexOf(c.field);return a-g}),o.right&&i.sort((s,c)=>{const a=o.right.indexOf(s.field),g=o.right.indexOf(c.field);return a-g}),{left:e,center:r,right:i}):{left:e,center:n,right:i}}function to(n,o,e,r,i,s,c,a){const g={};if(!e)return g;const f=$o(n,e);let p=0;a&&(p+=48),s&&c&&(p+=48),r&&i&&(p+=48),f.left.forEach(u=>{g[u.field]=p;const h=o[u.field]??u.width??100;p+=h});let m=0;return[...f.right].reverse().forEach(u=>{const h=o[u.field]??u.width??100;g[u.field]=m,m+=h}),g}function En(n,o){return o?o.top?.includes(n)?"top":o.bottom?.includes(n)?"bottom":null:null}function Do(n,o){const e=[],r=[],i=[];return o?(n.forEach(s=>{const c=En(s.id,o);c==="top"?e.push(s):c==="bottom"?i.push(s):r.push(s)}),o.top&&e.sort((s,c)=>{const a=o.top.indexOf(s.id),g=o.top.indexOf(c.id);return a-g}),o.bottom&&i.sort((s,c)=>{const a=o.bottom.indexOf(s.id),g=o.bottom.indexOf(c.id);return a-g}),{top:e,center:r,bottom:i}):{top:e,center:n,bottom:i}}function Mt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:t.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Pt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Ho(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Go(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),t.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Vo(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Uo(){return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Ko(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.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"}),t.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"}),t.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Yo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),t.jsx("polyline",{points:"11 8 4 12 11 16"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Xo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),t.jsx("polyline",{points:"13 8 20 12 13 16"}),t.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function qo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),t.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Jo({colDef:n,sortModel:o,onSort:e,onHide:r,onPin:i,pinnedColumns:s,onManageColumns:c,onClose:a,anchorEl:g}){const f=l.useRef(null),[p,m]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!g||!f.current)return;const _=g.getBoundingClientRect(),y=f.current.getBoundingClientRect(),I=window.innerWidth,S=window.innerHeight,x=8;let j=_.left;j+y.width+x>I&&(j=I-y.width-x),j<x&&(j=x);let R=_.bottom+4;R+y.height+x>S&&(R=_.top-y.height-4),m({position:"fixed",zIndex:1300,top:R,left:j,visibility:"visible"})},[g]),l.useEffect(()=>{function _(I){f.current&&!f.current.contains(I.target)&&g&&!g.contains(I.target)&&a()}function y(I){I.key==="Escape"&&a()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",y),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",y),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[g,a]);const u=_=>{e?.(n.field,_),a()},h=()=>{r?.(n.field),a()},w=_=>{i?.(n.field,_),a()},b=o?.find(_=>_.field===n.field)?.sort,M=b==null,P=s?.left?.includes(n.field)??!1,E=s?.right?.includes(n.field)??!1,k=!P&&!E,C=n.headerName||n.field;return St.createPortal(t.jsxs("div",{ref:f,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${C}`,children:[e&&n.sortable!==!1&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${b==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("asc"),role:"menuitemradio","aria-checked":b==="asc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="asc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Go,{})}),"Sort Ascending"]}),t.jsxs("button",{className:`ogx-menu-item${b==="desc"?" ogx-menu-item--active":""}`,onClick:()=>u("desc"),role:"menuitemradio","aria-checked":b==="desc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="desc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Vo,{})}),"Sort Descending"]}),t.jsxs("button",{className:`ogx-menu-item${M?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":M,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Uo,{})}),"Unsort"]}),t.jsx("div",{className:"ogx-menu-divider"})]}),t.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),t.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:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Yo,{})}),"Pin to Left"]}),t.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>w("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Xo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":k,"aria-label":"Unpin column",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(qo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${C} column`,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ko,{})}),"Hide Column"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:()=>{c?.(),a()},role:"menuitem","aria-label":"Manage all columns",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ho,{})}),"Manage columns"]})]}),g?.closest(".ogx-theme-provider")||document.body)}function Qo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:t.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 Zo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function no(n){const o=[];for(const e of n.children)typeof e=="string"?o.push(e):o.push(...no(e));return o}function er(n){let o=0;function e(r,i){o=Math.max(o,i);for(const s of r.children)typeof s!="string"&&e(s,i+1)}return n.forEach(r=>e(r,1)),o}function tr(n,o,e){function r(a,g,f){if(!no(a).includes(g))return null;if(f===e)return a;for(const p of a.children)if(typeof p!="string"){const m=r(p,g,f+1);if(m)return m}return null}const i=new Map;for(const a of o){let g=null;for(const f of n)if(g=r(f,a.field,0),g)break;i.set(a.field,g)}const s=[];let c=0;for(;c<o.length;){const a=o[c],g=i.get(a.field)??null,f=a.width;if(!g)s.push({key:`fg-${a.field}-${e}`,label:"",width:f,isGroup:!1}),c++;else{let p=0,m=c;for(;m<o.length&&i.get(o[m].field)===g;)p+=o[m].width,m++;s.push({key:`${g.groupId}-${e}`,label:g.headerName,width:p,isGroup:!0}),c=m}}return s}function oo(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:s=!1,someSelected:c=!1,onSelectAll:a,onSort:g,sortModel:f=[],onColumnResize:p,columnWidths:m={},pinnedColumns:u,hasDetailPanel:h=!1,pinCheckboxColumn:w=!0,pinExpandColumn:b=!0,rowReordering:M=!1,aggregationModel:P,draggedColumn:E,dragOverColumn:k,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,focusedCell:S,onHeaderClick:x,onHideColumn:j,onPinColumn:R,onManageColumns:B}=n,Y=l.useRef({}),[A,U]=l.useState(null),X=L=>ae=>{ae.stopPropagation(),U({colDef:L,anchorEl:ae.currentTarget})},G=()=>{U(null)};l.useLayoutEffect(()=>{if(S?.id==="HEADER"){const L=Y.current[S.field];L&&L.focus()}},[S]);const ee=L=>()=>{if(L.sortable===!1||!g)return;const ae=f.find(me=>me.field===L.field);let oe="asc";ae&&(ae.sort==="asc"?oe="desc":oe=null),g(L.field,oe)},Q=L=>{const ae=f.find(oe=>oe.field===L);return ae?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ae.sort}`,"aria-hidden":"true"}):null},pe=l.useMemo(()=>to(o,m,u,i,w,h,b,M),[o,m,u,i,w,h,b,M]),v=r?er(r):0,H=(e??o).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),K=(M?48:0)+(h?48:0)+(i?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[v>0&&Array.from({length:v},(L,ae)=>{const oe=tr(r,H,ae);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[K>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:K,minWidth:K,flexShrink:0},role:"columnheader"}),oe.map(me=>t.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${me.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:me.width,minWidth:me.width,flexShrink:0},title:me.isGroup?me.label:void 0,children:me.isGroup&&t.jsx("span",{className:"ogx-col-group-cell__label",children:me.label})},me.key))]},`ogx-grp-${ae}`)}),t.jsxs("div",{className:"ogx__header",role:"row",children:[M&&t.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}}),h&&t.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${b?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:b?"sticky":void 0,left:b?M?48:0:void 0,zIndex:b?5:void 0}}),i&&t.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?(M?48:0)+(h&&b?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:c,onChange:L=>a?.(L.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{Y.current.__checkbox_col__=L}})}),o.map((L,ae)=>{if(L.isSpacer)return t.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const oe=L.sortable!==!1,me=f.some(ze=>ze.field===L.field),Ze=L.resizable!==!1,z=dn(L.field,u),Ee=z!==null,Ne=E===L.field,gt=k===L.field,De=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,oe&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ee&&"ogx__header-cell--pinned",Ee&&`ogx__header-cell--pinned-${z}`,Ne&&"ogx__header-cell--dragging",gt&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),et=m[L.field]??L.width??100,tt={width:et,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:Ee?"sticky":"relative",zIndex:L.zIndex,opacity:Ne?.5:1};if(Ee&&z){const ze=pe[L.field];z==="left"?tt.left=ze:tt.right=ze}const en=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:ae}):L.headerName||L.field,Rt=ze=>{if(ze.target.closest(".ogx-column-resize-handle")){ze.stopPropagation();return}x?.(L.field),oe&&ee(L)()},jt=C?C(L.field):void 0,Ot=_?_(L.field):void 0,vt=I?I(L.field):void 0;return t.jsxs("div",{className:De,style:tt,onClick:Rt,role:"columnheader",draggable:!!C,onDragStart:jt,onDragOver:Ot,onDragEnd:y,onDrop:vt,"aria-sort":oe?me?f.find(ze=>ze.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":ae+1+(i?1:0),"data-field":L.field,tabIndex:-1,ref:ze=>{Y.current[L.field]=ze},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[Ne&&t.jsx("div",{className:"ogx__header-drag-icon",children:t.jsx(Zo,{})}),t.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[t.jsx("span",{className:"ogx__header-cell-title",children:en}),P&&P[L.field]&&t.jsx("span",{className:"ogx__header-cell-aggregation",children:P[L.field]})]}),oe&&Q(L.field),!L.disableColumnMenu&&t.jsx("button",{className:"ogx__menu-icon-btn",onClick:X(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Qo,{})})]}),Ze&&p&&t.jsx(Bo,{field:L.field,currentWidth:et,onResize:p,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),A&&t.jsx(Jo,{colDef:A.colDef,sortModel:f,onSort:g,onHide:j,onPin:R,pinnedColumns:u,onManageColumns:B,onClose:G,anchorEl:A.anchorEl})]})]})}function nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(String(n??"")),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function or({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const g=a.target.value===""?"":Number(a.target.value);s(g),o(g===""?null:g)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function rr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{o(!n),setTimeout(e,0)};return t.jsx("div",{className:"ogx__edit-boolean",children:t.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),r())}})})}function ir({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const c=o.valueOptions??[];return t.jsx("select",{ref:s,className:"ogx__edit-select",value:n??"",onChange:a=>{e(a.target.value)},onBlur:r,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),r()),a.key==="Escape"&&(a.stopPropagation(),i())},children:c.map(a=>{const g=typeof a=="object"?a.value:a,f=typeof a=="object"?a.label:String(a);return t.jsx("option",{value:String(g),children:f},String(g))})})}function lr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus()},[]),t.jsx("input",{ref:c,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function sr(n){const{colDef:o}=n;switch(o.type){case"number":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(or,{...n})});case"boolean":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(rr,{...n})});case"singleSelect":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(ir,{...n})});case"date":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(lr,{...n})});default:return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(nr,{...n})})}}function ar(n){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:i,row:s,colDef:c,rowIndex:a,colIndex:g,isSelected:f,onClick:p,width:m,pinnedPosition:u,pinnedOffset:h,isFocused:w,isFocusVisible:b,isEditable:M,isEditing:P,onEditStart:E,onEditStop:k,onValueChange:C,colSpanInfo:_,rowSpan:y,isHiddenByRowSpan:I}=n;if(_?.spannedByColSpan)return null;if(I)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??c.width??100},role:"presentation","data-field":c.field,"data-colindex":g});const S=v=>{o&&(v.stopPropagation(),o({row:s,field:c.field,value:i,colDef:c,rowIndex:a,colIndex:g})),p?.(v)},x=l.useCallback(v=>{r?r(c.field,v):C?.(v)},[r,C,c.field]),j=v=>{M&&(E||e)&&(v.stopPropagation(),e?e(c.field,i):E?.())},R=l.useMemo(()=>c.valueFormatter?c.valueFormatter({value:i,row:s,field:c.field}):i==null?"":String(i),[i,s,c]),B=l.useMemo(()=>P&&(r||C)&&k?c.renderEditCell?c.renderEditCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):t.jsx(sr,{value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g,onValueChange:x,onCommit:()=>k(),onCancel:()=>k(!0)}):c.renderCell?c.renderCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):R,[i,s,c,a,g,R,P,x,k,r,C]),Y=u!=null,A=l.useMemo(()=>c.cellClassName?typeof c.cellClassName=="function"?c.cellClassName({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g})||"":c.cellClassName:"",[c,i,s,a,g]),U=["ogx__cell",`ogx__cell--align-${c.align||"left"}`,f&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&b&&"ogx__cell--focus-visible",c.type&&`ogx__cell--type-${c.type}`,Y&&"ogx__cell--pinned",Y&&`ogx__cell--pinned-${u}`,P&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",A].filter(Boolean).join(" "),X=_?.cellProps?.colSpan||1,G=y||1,ee=_?.cellProps?.width??m??c.width??100,Q={width:"var(--width)","--width":typeof ee=="number"?`${ee}px`:ee,flexGrow:c.flex??0,flexShrink:0,flexBasis:(c.flex,"auto"),boxSizing:"border-box",minWidth:c.minWidth,maxWidth:c.maxWidth,position:Y?"sticky":void 0,zIndex:c.zIndex??(Y?3:void 0),padding:P?0:void 0};G>1&&(Q.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,Q.zIndex=10,Y&&(Q.zIndex=40)),Y&&h!==void 0&&(u==="left"?Q.left=h:Q.right=h);const pe=l.useRef(null);return l.useLayoutEffect(()=>{w&&pe.current&&pe.current.focus({preventScroll:!0})},[w]),t.jsx("div",{ref:pe,className:U,style:Q,onClick:S,onDoubleClick:j,role:"gridcell","aria-colindex":g+1,"aria-readonly":!M||void 0,tabIndex:-1,"data-field":c.field,"data-colindex":g,...X>1?{"aria-colspan":X}:{},...G>1?{"aria-rowspan":G}:{},children:t.jsx("div",{className:"ogx__cell-content",children:B})})}const ro=l.memo(ar);function io({isExpanded:n,onClick:o,variant:e="chevron"}){return t.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:r=>{o&&o(r)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.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"}})]}):t.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:t.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const dr=({className:n="",...o})=>t.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...o,children:t.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:t.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 cr(n){const{content:o,height:e,isExpanded:r}=n;if(!r)return null;const i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return t.jsx("div",{className:"ogx__detail-panel",style:i,children:t.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function Jt(n){const{row:o,columns:e,rowIndex:r,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:c,onCellClick:a,onSelectionChange:g,columnWidths:f={},pinnedColumns:p,pinnedRows:m,hasDetailPanel:u=!1,isDetailPanelExpanded:h=!1,onDetailPanelToggle:w,detailPanelContent:b,detailPanelHeight:M=200,pinCheckboxColumn:P=!0,pinExpandColumn:E=!0,rowReordering:k=!1,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,isDragging:S,isDragOver:x,editingCell:j,onEditStart:R,onEditStop:B,onEditCellValueChange:Y,focusedCellField:A,isFocusVisible:U,colspanMap:X,rowSpanningCaches:G,rowHeight:ee=52}=n,Q=l.useRef(null),pe=l.useRef(null);if(o._isSkeleton){const z=Math.max(e.length,5);return t.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ee,minHeight:ee},children:Array.from({length:z}).map((Ee,Ne)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},Ne))})}l.useLayoutEffect(()=>{A==="__expand_col__"&&Q.current&&Q.current.focus({preventScroll:!0}),A==="__checkbox_col__"&&pe.current&&pe.current.focus({preventScroll:!0})},[A]);const v=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||c?.({row:o,id:o.id,rowIndex:r})},D=z=>{z.stopPropagation(),g?.(o.id,z.target.checked)},H=z=>{z.stopPropagation(),w?.(o.id)},W=l.useMemo(()=>to(e,f,p,s,P,u,E,k),[e,f,p,s,P,u,E,k]),F=En(o.id,m),q=F==="top",K=F==="bottom",L=o._hasChildren===!0,ae=l.useCallback((z,Ee)=>{L||R?.({id:o.id,field:z,value:Ee})},[L,o.id,R]),oe=l.useCallback((z,Ee)=>{Y?.({id:o.id,field:z,value:Ee})},[Y,o.id]),me=l.useCallback(z=>{B?.({cancel:z})},[B]),Ze=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",q&&"ogx__row--pinned-top",K&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",x&&"ogx__row--drag-over",L&&"ogx__row--group"].filter(Boolean).join(" ");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Ze,onClick:v,role:"row","aria-rowindex":r+1,"aria-selected":i,"data-rowindex":r,onDragOver:_?_(o.id):void 0,onDrop:I?I(o.id):void 0,style:{maxHeight:`${ee}px`,minHeight:`${ee}px`,"--height":`${ee}px`,"--border-width":"1px"},children:[k&&t.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:C?C(o.id):void 0,onDragEnd:y,onClick:z=>z.stopPropagation(),children:t.jsx(dr,{})}),u&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${E?"ogx__cell--pinned-left":""} ${A==="__expand_col__"?"ogx__cell--focused":""} ${A==="__expand_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":h?"Collapse row details":"Expand row details","aria-expanded":h,style:{position:E?"sticky":void 0,left:E?k?48:0:void 0,zIndex:E?5:void 0},ref:Q,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__expand_col__",value:h,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(io,{isExpanded:h,onClick:H,variant:"plus-minus"})}),s&&t.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${A==="__checkbox_col__"?"ogx__cell--focused":""} ${A==="__checkbox_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(k?48:0)+(u&&E?48:0):void 0,zIndex:P?11:void 0},ref:pe,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(qt,{id:`ogx-select-row-${o.id}`,name:`ogx-select-row-${o.id}`,checked:i,onChange:D,onClick:z=>z.stopPropagation(),"aria-label":i?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Ee)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const Ne=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],gt=f[z.field]??z.width,De=dn(z.field,p),et=De?W[z.field]:void 0,tt=j?.id===o.id&&j?.field===z.field,en=tt?j?.value:Ne,Rt=X?.get(o.id)?.[z.field],jt=G?.spannedCells[o.id]?.[z.field],Ot=G?.hiddenCells[o.id]?.[z.field]||!1;return t.jsx(ro,{value:en,row:o,colDef:z,rowIndex:r,colIndex:Ee,isSelected:i,onCellClick:a,width:gt,pinnedPosition:De,pinnedOffset:et,isFocused:A===z.field,isFocusVisible:U,isEditable:z.editable,isEditing:tt,onCellEditStart:ae,onEditStop:me,onCellValueChange:oe,colSpanInfo:Rt,rowSpan:jt,isHiddenByRowSpan:Ot},z.field)})]}),u&&t.jsx(cr,{row:o,rowId:o.id,rowIndex:r,content:b,height:M,isExpanded:h})]})}const ur=({columns:n,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:i=!1})=>t.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:o},role:"row",children:[e&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),i&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,c)=>{const a=s.width||150,g=Math.min(a*.7,a-20);return t.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&&t.jsx("div",{className:"ogx-skeleton-box",style:{width:g,height:16,borderRadius:4}})},s.field||c)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:i="",children:s,...c})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",i].filter(Boolean).join(" ");return t.jsx("button",{className:a,disabled:r,...c,children:s})};function lo(n){const{page:o,pageSize:e,rowCount:r,onPageChange:i,onPageSizeChange:s,pageSizeOptions:c=[10,25,50,100],showFirstButton:a=!0,showLastButton:g=!0}=n,f=Math.max(1,Math.ceil(r/e)),p=Math.min(o,f-1),m=p*e,u=Math.min(m+e,r),h=r===0?0:`${m+1}–${u}`,w=()=>{i(0)},b=()=>{i(Math.max(0,p-1))},M=()=>{i(Math.min(f-1,p+1))},P=()=>{i(f-1)},E=_=>{const y=parseInt(_.target.value,10);s(y)},k=p===0,C=p>=f-1;return t.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[t.jsxs("div",{className:"ogx-pagination__page-size",children:[t.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),t.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:E,"aria-label":"Rows per page",children:c.map(_=>t.jsx("option",{value:_,children:_},_))})]}),t.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[h," of ",r]}),t.jsxs("div",{className:"ogx-pagination__actions",children:[a&&t.jsx(Qt,{variant:"text",size:"small",onClick:w,disabled:k,"aria-label":"Go to first page",title:"First page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),t.jsx(Qt,{variant:"text",size:"small",onClick:b,disabled:k,"aria-label":"Go to previous page",title:"Previous page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),t.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",p+1," of ",f]}),t.jsx(Qt,{variant:"text",size:"small",onClick:M,disabled:C,"aria-label":"Go to next page",title:"Next page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),g&&t.jsx(Qt,{variant:"text",size:"small",onClick:P,disabled:C,"aria-label":"Go to last page",title:"Last page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function gr(n,o,e={}){const r=new Map,i=[];n.forEach(a=>{const g=a.id;r.set(g,a),i.push(g)});const s=new Map,c=[];return o.forEach(a=>{s.set(a.field,a),c.push(a.field)}),{rows:{idRowsLookup:r,allRows:i},columns:{all:o,lookup:s,orderedFields:c,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},scrollTop:0,scrollLeft:0},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function fr(n,o){switch(o.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),r=typeof o.payload=="function"?o.payload(e):o.payload,i=new Map,s=[];return r.forEach(c=>{i.set(c.id,c),s.push(c.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:o.preserveRowCount?n.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(i=>{e.set(i.field,i),r.push(i.field)}),{...n,columns:{all:o.payload,lookup:e,orderedFields:r,columnVisibilityModel:{}}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:o.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:o.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:o.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:o.payload}};case"SET_SCROLL":return{...n,virtualization:{...n.virtualization,scrollTop:o.payload.scrollTop,scrollLeft:o.payload.scrollLeft}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:o.payload.viewportWidth,viewportHeight:o.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:o.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:o.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:o.payload}};default:return n}}function hr(n){const{rows:o,columns:e,rowHeight:r=52,headerHeight:i=56,columnVisibilityModel:s,initialState:c}=n,a=l.useMemo(()=>gr(o,e,s),[]),[g,f]=l.useReducer(fr,{...a,sorting:c?.sorting||a.sorting,filter:c?.filter||a.filter,dataSource:c?.dataSource?{...a.dataSource,...c.dataSource}:a.dataSource,pagination:{...a.pagination,...c?.pagination||{},rowCount:n.rowCount??c?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:r,headerHeight:i}}),p=l.useRef(g);p.current=g;const m=l.useRef(o);l.useEffect(()=>{o!==m.current&&(m.current=o,f({type:"SET_ROWS",payload:o}))},[o]);const u=l.useCallback((S,x)=>{f({type:"SET_ROWS",payload:S,preserveRowCount:x})},[]),h=l.useCallback(S=>{f({type:"SET_COLUMNS",payload:S})},[]),w=l.useCallback(S=>{f({type:"SET_SORT_MODEL",payload:S})},[]),b=l.useCallback(S=>{f({type:"SET_FILTER_MODEL",payload:S})},[]),M=l.useCallback(S=>{f({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=l.useCallback(S=>{f({type:"SET_SELECTION",payload:S})},[]),E=l.useCallback((S,x)=>{f({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:x}})},[]),k=l.useCallback((S,x)=>{f({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:x}})},[]),C=l.useCallback(S=>{f({type:"SET_DATASOURCE_LOADING",payload:S})},[]),_=l.useCallback(S=>{f({type:"SET_DATASOURCE_ERROR",payload:S})},[]),y=l.useCallback(S=>{f({type:"SET_ROW_COUNT",payload:S})},[]),I=l.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,x=!0)=>{const j=new Set(p.current.selection.selectedRows);x?j.add(S):j.delete(S),P(j)},selectRows:(S,x=!0)=>{const j=new Set(p.current.selection.selectedRows);S.forEach(R=>{x?j.add(R):j.delete(R)}),P(j)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(S,x)=>{if(x===null)w(p.current.sorting.sortModel.filter(j=>j.field!==S));else{const j=p.current.sorting.sortModel.findIndex(R=>R.field===S);if(j>=0){const R=[...p.current.sorting.sortModel];R[j]={field:S,sort:x},w(R)}else w([...p.current.sorting.sortModel,{field:S,sort:x}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:b,getFilterModel:()=>p.current.filter.filterModel,setPage:S=>{M({...p.current.pagination.paginationModel,page:S})},setPageSize:S=>{M({...p.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:g,dispatch:f,apiRef:I,setRows:u,setColumns:h,setSortModel:w,setFilterModel:b,setPaginationModel:M,setSelection:P,setScroll:E,setDimensions:k,setDataSourceLoading:C,setDataSourceError:_,setRowCount:y}}function pr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[i,s]=l.useState(null),[c,a]=l.useState(null),g=l.useRef(-1),f=l.useCallback(h=>w=>{if(r)return;const b=o.findIndex(P=>P.field===h);if(o[b]?.pinnable===!1){w.preventDefault();return}s(h),g.current=b,w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",h))},[o,r]),p=l.useCallback(h=>w=>{r||!i||(w.preventDefault(),w.dataTransfer.dropEffect="move",a(h))},[i,r]),m=l.useCallback(h=>w=>{if(w.preventDefault(),r||!i||i===h){s(null),a(null);return}const b=o.findIndex(E=>E.field===i),M=o.findIndex(E=>E.field===h);if(b===-1||M===-1){s(null),a(null);return}const P=o[b];e&&e({column:P,oldIndex:b,targetIndex:M}),s(null),a(null),g.current=-1},[o,i,r,e]),u=l.useCallback(()=>{s(null),a(null),g.current=-1},[]);return{draggedColumn:i,dragOverColumn:c,onDragStart:r?void 0:f,onDragOver:r?void 0:p,onDragEnd:r?void 0:u,onDrop:r?void 0:m}}function xr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:i=!1}=n,[s,c]=l.useState(null),[a,g]=l.useState(null),f=l.useCallback(w=>r?r(w):w.id,[r]),p=l.useCallback(w=>b=>{i&&(c(w),b.dataTransfer.effectAllowed="move")},[i]),m=l.useCallback(w=>b=>{!i||!s||(b.preventDefault(),b.dataTransfer.dropEffect="move",a!==w&&g(w))},[i,s,a]),u=l.useCallback(()=>{c(null),g(null)},[]),h=l.useCallback(w=>b=>{if(b.preventDefault(),!s||!o){u();return}const M=e.findIndex(E=>f(E)===s),P=e.findIndex(E=>f(E)===w);M!==-1&&P!==-1&&M!==P&&o({row:e[M],oldIndex:M,targetIndex:P}),u()},[s,o,e,f,u]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?p:void 0,onDragOver:i?m:void 0,onDragEnd:i?u:void 0,onDrop:i?h:void 0}}const mr={contains:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().includes(String(o).toLowerCase()),equals:(n,o)=>n==null&&o==null?!0:n==null||o==null?!1:String(n).toLowerCase()===String(o).toLowerCase(),startsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().startsWith(String(o).toLowerCase()),endsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().endsWith(String(o).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>r},">=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>=r},"<":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<r},"<=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<=r},"!=":(n,o)=>{if(o==null||o==="")return!0;const e=Number(n),r=Number(o);return!isNaN(e)&&!isNaN(r)?e!==r:String(n).toLowerCase()!==String(o).toLowerCase()},isAnyOf:(n,o)=>n==null||!Array.isArray(o)?!1:o.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,o)=>n==null&&o==null?!1:n==null||o==null?!0:String(n).toLowerCase()!==String(o).toLowerCase(),is:(n,o)=>{if(o==null||o==="")return!0;const e=String(n).toLowerCase(),r=String(o).toLowerCase();return e===r},"=":(n,o)=>n==null||o==null||o===""?!1:Number(n)===Number(o)};function br(n,o){const{field:e,operator:r,value:i}=o,s=n[e],c=mr[r];return c?c(s,i):(console.warn(`Unknown filter operator: ${r}`),!0)}function wr(n,o){return!o||o.length===0?!0:o.every(e=>{const r=e.toLowerCase();return Object.values(n).some(i=>i==null?!1:String(i).toLowerCase().includes(r))})}function Nn(n,o){const e=o.items||[],r=o.logicOperator||"and",i=o.quickFilterValues||[];if(i.length>0&&!wr(n,i))return!1;if(e.length===0)return!0;const s=c=>{if("logicOperator"in c&&"items"in c){const a=c,g=a.items;return g.length===0?!0:a.logicOperator==="and"?g.every(s):g.some(s)}else return br(n,c)};return r==="and"?e.every(s):e.some(s)}function vr(n,o){if(!o)return n;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?n:n.filter(i=>Nn(i,o))}function _r(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 In(n,o,e){if(n==null&&o==null)return 0;if(n==null)return e==="asc"?1:-1;if(o==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof o=="number")return e==="asc"?n-o:o-n;if(n instanceof Date&&o instanceof Date)return e==="asc"?n.getTime()-o.getTime():o.getTime()-n.getTime();const r=String(n).toLowerCase(),i=String(o).toLowerCase();return e==="asc"?r<i?-1:r>i?1:0:r>i?-1:r<i?1:0}function Cr(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,i)=>{for(const s of o){const c=r[s.field],a=i[s.field],g=In(c,a,s.sort);if(g!==0)return g}return 0}),e}function yr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,onRowExpansionChange:g}=n,{treeNodes:f,rootIds:p,groupingRows:m}=l.useMemo(()=>{if(!i||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const C=new Map,_=[],y=[],I=new Map,S=x=>x.join("/");return o.forEach(x=>{const j=e(x),R=r(x),B=S(R);I.set(B,j),C.set(j,{id:j,parentId:null,depth:R.length-1,groupingKey:R[R.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const j=e(x),R=r(x);if(R.length===1){_.push(j);return}const B=A=>{if(A.length<=1)return;const U=A.slice(0,-1),X=S(U);let G=I.get(X);if(G===void 0&&(G=`auto-group-${X}`,!C.has(G))){const ee=U[U.length-1];C.set(G,{id:G,parentId:null,depth:U.length-1,groupingKey:ee,isExpanded:!1,children:[],label:ee}),I.set(X,G);const Q={id:G,name:ee,_isGroupRow:!0};y.push(Q),U.length===1&&_.push(G),B(U)}return G},Y=B(R);if(Y!==void 0){const A=C.get(Y),U=C.get(j);A&&U&&(U.parentId=Y,A.children=A.children||[],A.children.includes(j)||A.children.push(j))}}),y.forEach(x=>{const j=x.id,R=C.get(j);if(!R)return;const Y=j.replace("auto-group-","").split("/");if(Y.length>1){const A=Y.slice(0,-1),U=S(A),X=I.get(U);if(X&&C.has(X)){R.parentId=X;const G=C.get(X);G&&(G.children=G.children||[],G.children.includes(j)||G.children.push(j))}}}),{treeNodes:C,rootIds:_,groupingRows:y}},[o,r,i,e]),u=l.useMemo(()=>{if(!i)return new Set;const C=new Set;return f.forEach(_=>{_.children&&_.children.length>0&&(s===-1||_.depth<s)&&C.add(_.id)}),C},[f,i,s]),[h,w]=l.useState(new Set);l.useEffect(()=>{u.size>0&&w(u)},[u]);const b=l.useCallback(C=>{w(_=>{const y=new Set(_),I=!y.has(C);if(y.has(C)?y.delete(C):y.add(C),I&&g){const S=f.get(C);S&&g(S)}return y})},[f,g]),M=l.useCallback(()=>{if(!i)return null;const C=new Map;o.forEach(B=>C.set(e(B),B)),m.forEach(B=>C.set(B.id,B));const _=B=>Nn(B,c),y=new Map,I=B=>{if(y.has(B))return y.get(B);const Y=C.get(B);if(!Y)return!1;if(_(Y))return y.set(B,!0),!0;const U=f.get(B);return U&&U.children&&U.children.some(G=>I(G))?(y.set(B,!0),!0):(y.set(B,!1),!1)},S=(B,Y)=>{if(!a||a.length===0)return 0;const A=C.get(B),U=C.get(Y);if(!A||!U)return 0;for(const X of a){const G=A[X.field],ee=U[X.field],Q=In(G,ee,X.sort);if(Q!==0)return Q}return 0},x=[],j=new Set,R=B=>{const Y=B.filter(A=>I(A));Y.sort(S),Y.forEach(A=>{if(j.has(A))return;const U=C.get(A),X=f.get(A);if(U&&X){j.add(A);const G={...U,_treeDepth:X.depth,_isExpanded:h.has(A),_hasChildren:X.children&&X.children.length>0||X.serverChildrenCount&&X.serverChildrenCount>0,_descendantCount:X.children?X.children.length:0};x.push(G),h.has(A)&&X.children&&X.children.length>0&&R(X.children)}})};return R(p),x},[i,o,m,p,f,h,c,a,e]),P=l.useCallback(C=>h.has(C),[h]),E=l.useCallback(C=>f.get(C),[f]),k=l.useCallback(C=>{const _=[];let y=C;for(;y!==null;){const I=f.get(y);if(!I)break;_.unshift(I.groupingKey),y=I.parentId}return _},[f]);return l.useMemo(()=>({treeNodes:f,groupingRows:m,toggleExpansion:b,isGroupExpanded:P,getVisibleRows:M,getNode:E,getNodePath:k}),[f,m,b,P,M,E,k])}const kr=n=>n?.depth===-1?"footer":"inline";function Sr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,getAggregationPosition:g=kr}=n,[f,p]=l.useState(new Set),{treeNodes:m,rootIds:u,groupingRows:h}=l.useMemo(()=>{const E=new Map,k=new Map,C=[];if(r.length===0)return{treeNodes:E,rootIds:C,groupingRows:k};const _=(S,x,j)=>`auto-group-${S}-${x}-${j||"root"}`,y=(S,x,j)=>{if(x>=r.length)return S.map(A=>{const U=e(A);return E.set(U,{id:U,parentId:j,depth:x,groupingKey:"",isExpanded:!1}),U});const R=r[x],B=new Map;S.forEach(A=>{const U=A[R],X=String(U);B.has(X)||B.set(X,[]),B.get(X).push(A)});const Y=[];return B.forEach((A,U)=>{const G=A[0][R],ee=_(R,U,j);Y.push(ee);const Q={};i&&Object.entries(i).forEach(([W,F])=>{const q=A.map(K=>K[W]);if(F==="sum")Q[W]=q.reduce((K,L)=>(Number(K)||0)+(Number(L)||0),0);else if(F==="min")Q[W]=Math.min(...q.map(K=>Number(K)||0));else if(F==="max")Q[W]=Math.max(...q.map(K=>Number(K)||0));else if(F==="avg"){const K=q.reduce((L,ae)=>(Number(L)||0)+(Number(ae)||0),0);Q[W]=q.length?K/q.length:0}else F==="count"&&(Q[W]=q.length)});const pe={[R]:G,...Q,id:ee};k.set(ee,pe);const v={id:ee,parentId:j,depth:x,groupingKey:U,groupingField:R,groupingValue:G,aggregatedValues:Q,isExpanded:!1,children:[],label:`${R}: ${String(G)}`};v.aggregationPosition=g(v),E.set(ee,v);const D=y(A,x+1,ee);E.get(ee).children=D;const H=A.length;E.get(ee).descendantCount=H}),Y},I=y(o,0,null);return C.push(...I),{treeNodes:E,rootIds:C,groupingRows:k}},[o,r,i,e,g]);l.useEffect(()=>{if(s===-1){const E=new Set;m.forEach((k,C)=>{k.children&&k.children.length>0&&E.add(C)}),p(E)}else if(s>0){const E=new Set;m.forEach((k,C)=>{k.depth<s&&k.children&&k.children.length>0&&E.add(C)}),p(E)}else p(new Set)},[r,s]);const w=l.useCallback(E=>{p(k=>{const C=new Set(k);return C.has(E)?C.delete(E):C.add(E),C})},[]),b=l.useCallback(E=>f.has(E),[f]),M=l.useCallback(()=>{if(r.length===0)return null;const E=[],k=new Set,C=new Map;o.forEach(S=>C.set(e(S),S));const _=S=>{const x=m.get(S);if(!x)return!1;if(!x.children||x.children.length===0){const j=C.get(S);return!(!j||c&&!Nn(j,c))}return x.children.some(j=>_(j))},y=S=>{let x=S;c&&(x=S.filter(_)),a&&a.length>0&&x.sort((j,R)=>{const B=h.get(j)||C.get(j),Y=h.get(R)||C.get(R);if(!B||!Y)return 0;for(const A of a){const U=B[A.field],X=Y[A.field],G=In(U,X,A.sort);if(G!==0)return G}return 0}),x.forEach(j=>{if(k.has(j))return;const R=m.get(j),B=R?.children&&R.children.length>0,Y=B?h.get(j):C.get(j);if(Y&&R){k.add(j);const A={...Y,_treeDepth:R.depth,_isExpanded:f.has(j),_hasChildren:B,_groupingField:R.groupingField,_groupingValue:R.groupingValue,_descendantCount:R.descendantCount};E.push(A),I.has(j)&&B&&y(R.children)}})},I=f;return y(u),E},[o,e,m,u,h,c,a,f]),P=l.useCallback(E=>m.get(E),[m]);return l.useMemo(()=>({treeNodes:m,groupingRows:h,toggleExpansion:w,isGroupExpanded:b,getVisibleRows:M,getNode:P}),[m,h,w,b,M,P])}function jr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:i,onRowChange:s}=n,[c,a]=l.useState(null),g=l.useRef(null),f=l.useCallback(h=>{a(h),g.current=typeof h=="function"?h(g.current):h},[]),p=l.useCallback(h=>{f({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[]),m=l.useCallback(async h=>{const w=g.current;if(!w)return;if(h?.cancel){f(null);return}const{id:b,field:M,value:P,originalValue:E}=w;if(P===E){f(null);return}const k=o.find(_=>e(_)===b);if(!k){f(null);return}const C={...k,[M]:P};try{if(r){const _=await r(C,k);s?.(_)}else s?.(C);f(null)}catch(_){i&&i(_)}},[c,o,e,r,s,i]),u=l.useCallback(h=>{c&&c.id===h.id&&c.field===h.field&&f(w=>w?{...w,value:h.value}:null)},[c]);return{editingCell:c,startCellEdit:p,stopCellEdit:m,setEditCellValue:u}}function Er(n,o,e){const[r,i]=l.useState(new Map),[s,c]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),g=l.useCallback((b,M)=>r.get(b)?.[M],[r]),f=l.useCallback((b,M,P,E,k)=>{const C=new Map(r);for(let _=E;_<k;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:M,value:M[y.field],field:y.field,colDef:y,rowIndex:P,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let S=e[y.field]||100;for(let x=1;x<I;x++)if(_+x<k){const j=o[_+x];j&&(S+=e[j.field]||100,Tt(C,b,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)}))}Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}i(C)},[r,o,e]),p=l.useCallback((b,M)=>{const P={},E={},k={};o.forEach((C,_)=>{if(C.rowSpan)for(let y=b;y<M;y++){const I=n[y];if(!I||E[I.id]?.[C.field])continue;const S=C.valueGetter?C.valueGetter({row:I,field:C.field,value:I[C.field]}):I[C.field];let x=1;if(typeof C.rowSpan=="function"){const j={row:I,value:S,field:C.field,colDef:C,rowIndex:y,colIndex:_};x=C.rowSpan(j)}else typeof C.rowSpan=="number"&&(x=C.rowSpan);if(x>1){P[I.id]||(P[I.id]={}),P[I.id][C.field]=x;for(let j=1;j<x;j++){const R=y+j;if(R<M&&n[R]){const B=n[R];E[B.id]||(E[B.id]={}),E[B.id][C.field]=!0,k[R]||(k[R]={}),k[R][C.field]=y}}}}}),c({caches:{spannedCells:P,hiddenCells:E,hiddenCellOriginMap:k},processedRange:{firstRowIndex:b,lastRowIndex:M}})},[n,o]),m=l.useCallback(()=>{c({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const b=new Map;n.forEach((k,C)=>{for(let _=0;_<o.length;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:k,value:k[y.field],field:y.field,colDef:y,rowIndex:C,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){const x=e[y.field]||(typeof y.width=="number"?y.width:100);Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let S=e[y.field]||(typeof y.width=="number"?y.width:100);for(let x=1;x<I;x++)if(_+x<o.length){const j=o[_+x];if(j){const R=e[j.field]||(typeof j.width=="number"?j.width:100);S+=R,Tt(b,k.id,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)})}}Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}}),i(b);const M={},P={},E={};o.forEach((k,C)=>{if(k.rowSpan)for(let _=0;_<n.length;_++){const y=n[_];if(!y||P[y.id]?.[k.field])continue;const I=k.valueGetter?k.valueGetter({row:y,field:k.field,value:y[k.field]}):y[k.field];let S=1;if(typeof k.rowSpan=="function"){const x={row:y,value:I,field:k.field,colDef:k,rowIndex:_,colIndex:C};S=k.rowSpan(x)}else typeof k.rowSpan=="number"&&(S=k.rowSpan);if(S>1){M[y.id]||(M[y.id]={}),M[y.id][k.field]=S;for(let x=1;x<S;x++){const j=_+x;if(j<n.length&&n[j]){const R=n[j];P[R.id]||(P[R.id]={}),P[R.id][k.field]=!0,E[j]||(E[j]={}),E[j][k.field]=_}}}}}),c({caches:{spannedCells:M,hiddenCells:P,hiddenCellOriginMap:E},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,o,e]);const u=l.useCallback(()=>s.caches.spannedCells,[s]),h=l.useCallback(()=>s.caches.hiddenCells,[s]),w=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:r,resetColSpan:a,getCellColSpanInfo:g,calculateColSpan:f,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:m,getSpannedCells:u,getHiddenCells:h,getHiddenCellOriginMap:w}}function Tt(n,o,e,r){let i=n.get(o);i||(i={},n.set(o,i)),i[e]=r}function Nr(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:i,paginationMode:s,sortingMode:c,filterMode:a,aggregationModel:g,setRows:f,setRowCount:p,setDataSourceLoading:m,setDataSourceError:u,onAggregationResults:h}=n,w=l.useRef(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!o)return;const E=++b.current;m(!0),u(null);const k=i.page*i.pageSize,C=k+i.pageSize,_={startRow:k,endRow:C,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:g};try{const y=await o.getRows(_);if(E!==b.current)return;let I=!1;if(s==="infinite"){const S=w.current;if(S){const x=JSON.stringify(S.sortModel)!==JSON.stringify(e),j=JSON.stringify(S.filterModel)!==JSON.stringify(r),R=S.pageSize!==i.pageSize;!x&&!j&&!R&&i.page>S.page&&(I=!0)}}f(I?S=>[...S,...y.rows]:y.rows,!0),y.aggregationResults&&h&&h(y.aggregationResults),y.rowCount!==void 0&&p(y.rowCount),w.current={sortModel:e,filterModel:r,page:i.page,pageSize:i.pageSize}}catch(y){E===b.current&&(u(y),console.error("Data Source Error:",y))}finally{E===b.current&&m(!1)}},[o,i.page,i.pageSize,e,r,s,g,h,f,p,m,u]);l.useEffect(()=>{if(o&&(s==="server"||s==="infinite"||c==="server"||a==="server")){const k=setTimeout(()=>{M()},300);return()=>clearTimeout(k)}},[M,o,s,c,a]);const P=l.useCallback(async(E,k)=>{if(o){m(!0);try{const C=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:k});C.rows.length>0&&f(_=>{const y=new Set(_.map(S=>S.id)),I=C.rows.filter(S=>!y.has(S.id));return[..._,...I]})}catch(C){u(C),console.error("Failed to fetch children:",C)}finally{m(!1)}}},[o,e,r,f,m,u]);return{fetchRows:M,fetchChildren:P}}const Ir={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,r)=>e+Number(r),0),avg:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e)));return o.length===0?null:o.reduce((e,r)=>e+Number(r),0)/o.length},count:n=>n.filter(o=>o!=null).length,min:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.min(...o):null},max:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.max(...o):null},unique:n=>new Set(n.filter(o=>o!=null)).size};function bt(n,o){return n==null?"—":typeof n=="number"?o==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function so(n){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:i,filterModel:s,sortModel:c,serverAggregationResults:a}=n,g=l.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const E={};for(const[k,C]of Object.entries(e)){const _=Ir[C];if(!_){console.warn(`[useAggregation] Unknown aggregation function: "${C}"`);continue}const y=o.map(I=>I[k]);E[k]=_(y)}return E},[o,e,r]),[f,p]=l.useState({}),[m,u]=l.useState(!1),[h,w]=l.useState(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const E=++b.current;u(!0),w(null);try{const k=await i.getAggregations({sortModel:c??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});E===b.current&&p(k)}catch(k){E===b.current&&(w(k),console.error("[useAggregation] Server aggregation error:",k))}finally{E===b.current&&u(!1)}},[i,e,s,c]);return l.useEffect(()=>{r&&i?.getAggregations&&!a&&M()},[M,r,i,a]),{aggregationResult:l.useMemo(()=>r?a&&Object.keys(a).length>0?a:f:g,[r,g,a,f]),isLoading:m,error:h}}function Mr(n,o){const e=n.filter(r=>r!=null&&!isNaN(r));if(e.length===0)return null;switch(o){case"sum":return e.reduce((r,i)=>r+i,0);case"avg":return e.reduce((r,i)=>r+i,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Mn(n,o){return o.map(e=>String(n[e]??"")).join("\0")}function ao(n,o,e,r){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return i;const{rowFields:s,columnFields:c,valueFields:a}=e;if(s.length===0||a.length===0)return i;const g=new Map(o.map(b=>[b.field,b])),f=new Set;for(const b of n)f.add(Mn(b,c));const p=Array.from(f).sort(),m=new Map;for(const b of n){const M=Mn(b,s);if(!m.has(M)){const C={};for(const _ of s)C[_]=b[_];m.set(M,{labelValues:C,bucket:new Map})}const P=m.get(M),E=Mn(b,c);P.bucket.has(E)||P.bucket.set(E,new Map);const k=P.bucket.get(E);for(const C of a){const _=Number(b[C.field]);k.has(C.field)||k.set(C.field,[]),isNaN(_)||k.get(C.field).push(_)}}let u=0;const h=[];for(const[,b]of m){const M={id:u++,...b.labelValues};for(const P of p){const E=b.bucket.get(P);for(const k of a){const C=c.length>0?`${P}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,_=E?.get(k.field)??[];M[C]=_.length>0?Mr(_,k.aggFn):null}}h.push(M)}const w=[];for(const b of s){const M=g.get(b);w.push({field:b,headerName:M?.headerName??b,width:M?.width??140,sortable:!0})}for(const b of p){const M=c.length>0?b.split("\0").map((P,E)=>{const k=g.get(c[E]);return k?.headerName?`${k.headerName}: ${P}`:P}).join(" / "):"";for(const P of a){const E=g.get(P.field),k=c.length>0?`${b}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,C=P.headerName??E?.headerName??P.field,_=M?`${M} — ${C} (${P.aggFn})`:`${C} (${P.aggFn})`;w.push({field:k,headerName:_,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:y})=>{if(y==null)return"—";const I=Number(y);return P.aggFn==="avg"?I.toFixed(2):P.aggFn==="count"?I.toLocaleString():E?.valueFormatter?E.valueFormatter({value:y,row:{},field:P.field}):I.toLocaleString()}})}}return{pivotRows:h,pivotColumns:w,colKeys:p,isValid:!0}},[n,o,e,r])}function Pr(n){const o=document.createElement("textarea");o.value=n,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 Tr(n){let o=!1;try{o=Pr(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(o)return;throw e}else if(!o)throw new Error("Clipboard API not available and fallback failed.")}function Lr(n){const{selectedRowIds:o,columns:e,getVisibleRows:r,getRowId:i}=n,s=l.useCallback(async()=>{if(o.size===0)return;const a=r().filter(u=>o.has(i(u)));if(a.length===0)return;const g=e.filter(u=>!u.field.startsWith("__")),f=g.map(u=>u.headerName||u.field).join(" "),p=a.map(u=>g.map(h=>{const w=u[h.field];return h.valueFormatter?h.valueFormatter({value:w,row:u,field:h.field}):w??""}).join(" ")).join(`
|
|
7
|
-
`),m=`${
|
|
8
|
-
${p}`;try{await Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clipboard:",u)}},[o,e,r,i]);return l.useEffect(()=>{const c=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const g=document.activeElement,f=g?.tagName.toLowerCase(),p=g?.type;f==="input"&&p!=="checkbox"&&p!=="radio"||f==="textarea"||f==="select"||g?.isContentEditable||s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),{copySelectedRows:s}}function Rr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Or(){return t.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function co(n){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c}=n,[a,g]=l.useState(""),[f,p]=l.useState(null),m=l.useRef(null),h=l.useMemo(()=>o.filter(_=>_.hideable!==!1),[o]).every(_=>e.has(_.field)),w=l.useMemo(()=>{if(!a)return o;const _=a.toLowerCase();return o.filter(y=>(y.headerName||y.field).toLowerCase().includes(_))},[o,a]),b=_=>{_.target.checked?i():s()},M=_=>y=>{m.current=_,y.dataTransfer.effectAllowed="move",y.dataTransfer.setDragImage(y.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=_=>y=>{y.preventDefault(),y.dataTransfer.dropEffect="move",_!==m.current&&p(_)},E=()=>{p(null)},k=_=>y=>{y.preventDefault();const I=m.current;p(null),m.current=null,I&&I!==_&&c&&c(I,_)},C=()=>{p(null),m.current=null};return t.jsxs("div",{className:"ogx-column-visibility-panel",children:[t.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:t.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[t.jsx(Rr,{}),t.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:a,onChange:_=>g(_.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:w.map(_=>{const y=e.has(_.field),I=_.hideable!==!1,S=f===_.field,x=!!c&&!a;return t.jsxs("div",{className:["ogx-column-visibility-panel__item",!I&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:x,onDragOver:x?P(_.field):void 0,onDragLeave:x?E:void 0,onDrop:x?k(_.field):void 0,onDragEnd:x?C:void 0,children:[x&&t.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:M(_.field),title:"Drag to reorder",children:t.jsx(Or,{})}),t.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:I?"pointer":"not-allowed"},children:[t.jsx(qt,{checked:y,onChange:j=>r(_.field,j.target.checked),disabled:!I}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:_.headerName||_.field})]})]},_.field)})}),t.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[t.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[t.jsx(qt,{checked:h,onChange:b}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),t.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:i,children:"Reset"})]})]})}function Wr(n){const{rows:o,columns:e,getRowId:r,rowHeight:i=52,headerHeight:s=56,autoHeight:c=!1,checkboxSelection:a=!1,rowSelectionModel:g,onRowSelectionModelChange:f,onRowClick:p,onCellClick:m,filterModel:u,onFilterModelChange:h,sortModel:w,onSortModelChange:b,pagination:M=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:E,pageSizeOptions:k=[10,25,50,100],pinnedColumns:C,onPinnedColumnsChange:_,pinnedRows:y,getDetailPanelContent:I,getDetailPanelHeight:S,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:j,pinCheckboxColumn:R=!0,pinExpandColumn:B=!0,disableColumnReorder:Y=!1,columnOrder:A,onColumnOrderChange:U,height:X,rowReordering:G=!1,onRowOrderChange:ee,loading:Q=!1,treeData:pe=!1,getTreeDataPath:v,defaultGroupingExpansionDepth:D,rowGroupingModel:H,aggregationModel:W,onAggregationModelChange:F,getAggregationPosition:q,isCellEditable:K,processRowUpdate:L,onProcessRowUpdateError:ae,dataSource:oe,sortingMode:me="client",filterMode:Ze="client",paginationMode:z="client",rowCount:Ee,slots:Ne,slotProps:gt,pivotMode:De=!1,pivotModel:et,onPivotModelChange:tt,className:en="",style:Rt,onRowsScrollEnd:jt,ariaLabel:Ot,initialState:vt,onStateChange:ze,columnVisibilityModel:mo,onColumnVisibilityModelChange:bo,listView:cn=!1,listViewColumn:wo,columnGroupingModel:Et,noRowsLabel:Tn="No Data",apiRef:Ln}=n,Ci=l.useMemo(()=>({items:[]}),[]),Ve=u||Ci,[yi,ki]=l.useState(()=>vt?.sorting?.sortModel??[]),Rn=w!==void 0,nt=Rn?w:yi,Si=l.useMemo(()=>[],[]),On=H||Si,Wn=W!==void 0,vo=l.useMemo(()=>Ne?.toolbar,[Ne?.toolbar]),[ji,Ei]=l.useState(()=>W??{}),ot=Wn?W:ji,Ni=l.useCallback(d=>{Wn||Ei(d),F?.(d)},[Wn,F]),[Ii,Mi]=l.useState(()=>vt?.columns?.columnVisibilityModel??{}),Fn=mo!==void 0,Xe=Fn?mo:Ii,tn=l.useCallback(d=>{Fn||Mi(d),bo?.(d)},[Fn,bo]),[Pi,Ti]=l.useState(()=>vt?.columns?.pinnedColumns??{}),An=C!==void 0,rt=An?C:Pi,zn=l.useCallback(d=>{An||Ti(d),_?.(d)},[An,_]),Li=l.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Ri,Oi]=l.useState(et??Li),_o=et??Ri,Wi=l.useCallback(d=>{Oi(d),tt?.(d)},[tt]),un=ao(o,e,_o,De),Bn=De&&un.isValid?un.pivotRows:o,it=De&&un.isValid?un.pivotColumns:e,[Fi,Co]=l.useState(null);l.useEffect(()=>{Co(null)},[ot]);const[Ai,zi]=l.useState(()=>vt?.pagination?.paginationModel??P),$n=n.paginationModel!==void 0,fe=$n?P:Ai,gn=l.useCallback(d=>{$n||zi(d),E?.(d)},[$n,E]),[Bi,yo]=l.useState([]),nn=g!==void 0,ko=nn?g:Bi,Ie=l.useMemo(()=>new Set(ko),[ko]),fn=f,Nt=l.useRef(null),$i=l.useRef(null),hn=l.useRef(null),Di=l.useCallback(d=>d.id,[]),pn=r||Di,[qe,Wt]=l.useState(null),Ft=l.useCallback(d=>{yn.current?.classList.toggle("ogx--kb",d)},[]),So=l.useRef(oe);So.current=oe;const jo=l.useRef(null),Eo=l.useRef(null),Hi=l.useCallback(d=>{if(So.current&&pe&&d.serverChildrenCount>0&&d.children.length===0){const N=Eo.current?.getNodePath(d.id)||[d.groupingKey];jo.current?.(d.id,N)}},[pe]),lt=hr({rows:Bn,columns:it,rowHeight:i,headerHeight:s,rowCount:Ee,columnVisibilityModel:Xe,initialState:n.initialState}),{state:de,apiRef:At,setRows:Dn,setColumns:No,setScroll:Io,setDimensions:Mo,setDataSourceLoading:Gi,setDataSourceError:Vi,setRowCount:Ui}=lt;l.useEffect(()=>{Ln&&(Ln.current=At.current)},[Ln,At]);const{copySelectedRows:Po}=Lr({selectedRowIds:Ie,columns:it,getVisibleRows:()=>At.current.getVisibleRows(),getRowId:pn});l.useEffect(()=>{At.current.copySelectedRows=Po,At.current.getSelectedRows=()=>Array.from(Ie)},[Po,Ie,At]);const Ki=de.dataSource.loading,on=Q||Ki,rn=l.useMemo(()=>de.rows.allRows.map(d=>de.rows.idRowsLookup.get(d)),[de.rows]),Hn=yr({rows:rn,getRowId:pn,getTreeDataPath:v,treeData:pe,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,onRowExpansionChange:Hi});l.useEffect(()=>{Eo.current=Hn},[Hn]);const Yi=Sr({rows:rn,getRowId:pn,rowGroupingModel:On,aggregationModel:ot,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,getAggregationPosition:q}),Be=jr({rows:rn,getRowId:pn,processRowUpdate:L,onProcessRowUpdateError:ae,onRowChange:d=>{const{dispatch:N}=lt,$=Array.from(lt.state.rows.idRowsLookup.values()).map(Z=>Z.id===d.id?d:Z);N({type:"SET_ROWS",payload:$})}}),Gn=pe,zt=!!(On&&On.length>0),xn=Gn||zt,$e=Gn?Hn:zt?Yi:null,Me=M&&!zt,mn=l.useCallback(d=>{const{row:N,id:T}=d;if(xn&&N._hasChildren){$e?.toggleExpansion(T);return}p?.(d)},[xn,$e,p]),ye=l.useMemo(()=>xn?it.map((d,N)=>N===0?{...d,renderCell:T=>{const{_treeDepth:$,_hasChildren:Z,_isExpanded:re,_groupingField:ue,_groupingValue:Oe,_descendantCount:We}=T.row,xe=($||0)*24;let se=d.renderCell?d.renderCell(T):T.value;return Gn&&Z&&T.row._isGroupRow&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[T.value,We!==void 0&&We>0?` (${We})`:""]})),zt&&Z&&ue&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[d.field===ue?"":`${ue}: `,String(Oe),We!==void 0?` (${We})`:""]})),t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:xe,width:"100%",height:"100%"},children:[t.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:Z?"pointer":"default",flexShrink:0},children:Z?t.jsx("div",{onClick:V=>{V.stopPropagation(),V.preventDefault(),$e?.toggleExpansion(T.row.id)},onMouseDown:V=>{V.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:t.jsx(io,{isExpanded:re,onClick:V=>{V.stopPropagation(),V.preventDefault(),$e?.toggleExpansion(T.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se})]})}}:{...d,renderCell:T=>{const{_hasChildren:$,_groupingField:Z}=T.row;return zt&&$?d.field===Z?null:T.value!==void 0&&T.value!==null?d.renderCell?d.renderCell(T):T.value:null:d.renderCell?d.renderCell(T):T.value}}):it,[it,xn,zt,$e]),Vn=Nr({dataSource:oe,sortModel:nt,filterModel:Ve,paginationModel:fe,paginationMode:z,sortingMode:me,filterMode:Ze,aggregationModel:ot,setRows:Dn,setRowCount:Ui,setDataSourceLoading:Gi,setDataSourceError:Vi,onAggregationResults:Co});l.useEffect(()=>{Vn.fetchChildren&&(jo.current=Vn.fetchChildren)},[Vn.fetchChildren]);const[Ue,Xi]=l.useState(()=>vt?.columns?.columnWidths??{}),[qi,bn]=l.useState(()=>vt?.columns?.columnOrder??it.map(d=>d.field)),_t=A||qi;l.useEffect(()=>{oe||Dn(Bn)},[Bn,Dn,oe]),l.useEffect(()=>{No(it)},[it,No]),l.useEffect(()=>{De&&bn(it.map(d=>d.field))},[De,it]);const Bt=l.useMemo(()=>{if(Y)return ye;const d=new Map(_t.map((N,T)=>[N,T]));return[...ye].sort((N,T)=>{const $=d.get(N.field)??ye.indexOf(N),Z=d.get(T.field)??ye.indexOf(T);return $-Z})},[ye,_t,Y]),To=l.useMemo(()=>Bt.filter(d=>Xe[d.field]!==!1),[Bt,Xe]),$t=pr({columns:Bt,onColumnOrderChange:l.useCallback(d=>{const{oldIndex:N,targetIndex:T}=d,$=[..._t],[Z]=$.splice(N,1);$.splice(T,0,Z),A||bn($),U?.(d)},[_t,A,U]),disableColumnReorder:Y}),[Ji,Qi]=l.useState(new Set),Ct=x??Ji,Je=!!I,ln=l.useCallback(d=>{const N=new Set(Ct);N.has(d)?N.delete(d):N.add(d),x===void 0&&Qi(N),j?.(N)},[Ct,x,j]),we=l.useMemo(()=>{const d=[];return G&&d.push({field:"__reorder_col__"}),Je&&d.push({field:"__expand_col__"}),a&&d.push({field:"__checkbox_col__"}),[...d,...Bt]},[Bt,a,Je,G]),Zi=l.useCallback((d,N)=>{Xi(T=>({...T,[d]:N}))},[]),Un=l.useRef(ze);Un.current=ze,l.useEffect(()=>{if(!Un.current)return;const d={sorting:{sortModel:nt},filter:{filterModel:Ve},pagination:{paginationModel:fe},columns:{columnWidths:Ue,columnOrder:_t,columnVisibilityModel:Xe,pinnedColumns:rt}};Un.current(d)},[nt,Ve,fe,Ue,_t,Xe,rt]);const wn=l.useMemo(()=>rn,[rn]),He=l.useMemo(()=>$e?$e.getVisibleRows()||[]:Ze==="server"&&oe?wn:vr(wn,Ve),[wn,Ve,$e,Ze,oe]),{top:Ke,center:Dt,bottom:st}=l.useMemo(()=>$e?{top:[],center:He,bottom:[]}:Do(He,y),[He,y,$e]),Pe=l.useMemo(()=>$e||me==="server"&&oe?Dt:Cr(Dt,nt),[Dt,nt,$e,me,oe]),ft=l.useMemo(()=>{if(!Me||z==="server"&&oe)return Pe;const d=fe.page*fe.pageSize,N=d+fe.pageSize;return Pe.slice(d,N)},[Pe,Me,fe.page,fe.pageSize,z,oe]);l.useEffect(()=>{lt.apiRef.current.getVisibleRows=()=>Pe,lt.apiRef.current.getVisibleColumns=()=>ye},[Pe,ye,lt.apiRef]);const Ht=xr({rows:Me?ft:Pe,getRowId:d=>d.id,onRowOrderChange:ee,rowReordering:G}),ke=l.useMemo(()=>{if($e)return Dt;const d=Me?ft:Pe,N=[...Ke,...d,...st];if(z==="infinite"&&de.dataSource.loading&&N.length>0){const T=Math.min(fe.pageSize,20),$=Array.from({length:T},(Z,re)=>({id:`__skeleton_${re}__`,_isSkeleton:!0}));return[...N,...$]}return N},[Ke,ft,Pe,st,Me,$e,Dt,z,de.dataSource.loading,fe.pageSize]),Gt=Er(ke,we,Ue),{aggregationResult:Kn}=so({rows:He,aggregationModel:ot,isServerSide:!!(oe&&(z==="server"||me==="server")),dataSource:oe,filterModel:Ve,sortModel:nt,serverAggregationResults:Fi}),vn=Object.keys(ot).length>0;l.useEffect(()=>{lt.apiRef.current.getAggregationResult=()=>vn?Kn:null,lt.apiRef.current.getAggregationModel=()=>vn?ot:null},[Kn,ot,vn,lt.apiRef]);const Yn=l.useMemo(()=>{const d=i,N=Me?ft:Pe,T=N.map((O,J)=>{let te=d;if(Ct.has(O.id)){const je=S?.({row:O,id:O.id,rowIndex:Ke.length+J})??200;te+=typeof je=="number"?je:parseInt(String(je),10)||200}return te}),$=T.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]),re=(z==="infinite"&&de.dataSource.loading&&N.length>0?Math.min(fe.pageSize,20):0)*d,ue=($[$.length-1]||0)+re,Oe=Ke.length*d,We=st.length*d,le=[],xe=[],se=[],V=[];To.forEach(O=>{const J=dn(O.field,rt);J==="left"?le.push(O):J==="right"?xe.push(O):se.push(O)});const he=de.dimensions.viewportWidth||1e3,Ce=(a?48:0)+(Je?48:0)+(G?48:0),be=O=>Ue[O.field]??O.width,Te=O=>{if(O===void 0)return{type:"auto",value:0};if(typeof O=="number")return{type:"fixed",value:O};if(typeof O=="string"){if(O.toLowerCase()==="auto")return{type:"auto",value:0};if(O.endsWith("%"))return{type:"percentage",value:parseFloat(O)};const J=parseFloat(O);if(!isNaN(J))return{type:"fixed",value:J}}return{type:"fixed",value:100}},Le=le.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ge=xe.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ce=se.reduce((O,J)=>{if(!Object.prototype.hasOwnProperty.call(Ue,J.field)&&J.flex&&J.flex>0){const mt=J.minWidth??150,qn=typeof J.width=="number"?J.width:150;return O+(mt||qn)}const je=Te(be(J));return je.type==="fixed"?O+je.value:je.type==="percentage"?O+100:O+(J.minWidth??150)},0),ht=Math.max(he-Ce-Le-ge,ce),at=[],Fe=[],Se=[];let Ae=0;se.forEach(O=>{const J=Object.prototype.hasOwnProperty.call(Ue,O.field),te=Te(be(O));if(!J&&O.flex&&O.flex>0){Se.push({col:O,flex:O.flex}),Ae+=O.flex;return}te.type==="fixed"?at.push({col:O,width:te.value}):te.type==="percentage"?Fe.push({col:O,percentage:te.value}):(Se.push({col:O,flex:1}),Ae+=1)});const Ge=at.reduce((O,{width:J})=>O+J,0);let Re=Math.max(0,ht-Ge);const dt=new Map;Fe.forEach(({col:O,percentage:J})=>{const te=J/100*Re;dt.set(O.field,te),Re-=te}),Re=Math.max(0,Re);const yt=new Map,pt=Se.map(O=>({...O,minWidth:O.col.minWidth??50,maxWidth:O.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let O=0;const J=pt.length*2;for(;O<J;){O++;const te=pt.filter(ne=>!ne.frozen);if(te.length===0)break;const je=te.reduce((ne,ct)=>ne+ct.flex,0),mt=pt.reduce((ne,ct)=>ct.frozen?ne+ct.computedWidth:ne,0),qn=Math.max(0,Re-mt);if(je<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const dl=qn/je;let kn=0;const Sn=[],jn=[];if(te.forEach(ne=>{const ct=dl*ne.flex;if(ct<ne.minWidth){const Jn=ne.minWidth-ct;kn+=Jn,Sn.push(ne)}else if(ct>ne.maxWidth){const Jn=ne.maxWidth-ct;kn+=Jn,jn.push(ne)}else ne.computedWidth=ct}),Sn.length===0&&jn.length===0){te.forEach(ne=>ne.frozen=!0);break}kn>0?Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):kn<0?jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),pt.forEach(O=>yt.set(O.col.field,O.computedWidth));const Ut=new Map;se.forEach(O=>{let J;if(yt.has(O.field))J=yt.get(O.field);else{const te=at.find(mt=>mt.col.field===O.field),je=Fe.find(mt=>mt.col.field===O.field);if(te)J=te.width;else if(je){const mt=dt.get(O.field)||0;J=Math.max(O.minWidth??50,mt||100)}else J=100}V.push(J),Ut.set(O.field,J)});const xt=se.map(O=>{const J=pt.find(te=>te.col.field===O.field);return{...O,width:Ut.get(O.field)??(typeof O.width=="number"?O.width:100),flex:J?J.flex:O.flex}}),Ye=11,It=le.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Ye+J}}),Kt=11,kt=xe.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Kt+(xe.length-1-J)}}),Qe=V.reduce((O,J)=>O+J,0),ve=Le+Qe+ge+Ce,al=V.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]);return{rowHeights:T,cumulativeHeights:$,unpinnedRowsHeight:ue,pinnedTopHeight:Oe,pinnedBottomHeight:We,leftPinnedCols:It,rightPinnedCols:kt,unpinnedColsWithWidth:xt,unpinnedColWidths:V,unpinnedAccWidths:al,totalWidth:ve,leftWidth:Le,rightWidth:ge,unpinnedTotalWidth:Qe,systemColumnsWidth:Ce,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,unpinnedRowsLength:N.length}},[i,Me,ft,Pe,Ct,S,Ke.length,st.length,Ct,S,Ke.length,st.length,To,rt,Ue,de.dimensions.viewportWidth,a,Je,G,R,B,c,z,de.dataSource.loading,fe.pageSize]),_e=l.useMemo(()=>{const{unpinnedAccWidths:d,unpinnedColsWithWidth:N,leftPinnedCols:T,rightPinnedCols:$,totalWidth:Z,leftWidth:re,rightWidth:ue,unpinnedTotalWidth:Oe,systemColumnsWidth:We,cumulativeHeights:le,pinnedTopHeight:xe,pinnedBottomHeight:se,unpinnedRowsHeight:V,rowHeights:he,unpinnedRowsLength:Ce}=Yn,be=de.virtualization.scrollLeft,Te=de.virtualization.scrollTop,Le=de.dimensions.viewportWidth||1e3,ge=c?xe+V+se+50:de.dimensions.viewportHeight||600,ce=6,ht=Math.max(0,be-re),at=be+Le-re;let Fe=0,Se=N.length-1,Ae=0,Ge=d.length-1;for(;Ae<=Ge;){const ve=Ae+Ge>>>1;d[ve]<ht?Ae=ve+1:Ge=ve-1}Fe=Math.max(0,Ae-ce);for(let ve=Fe;ve<d.length;ve++){if((ve===0?0:d[ve-1])>at){Se=Math.min(N.length-1,ve+ce);break}Se=Math.min(N.length-1,ve+ce)}const Re=Fe>0?d[Fe-1]:0,dt=Oe-d[Se],yt=[...T,...Re>0?[{field:"__spacer_left__",width:Re,isSpacer:!0}]:[],...N.slice(Fe,Se+1),...dt>0?[{field:"__spacer_right__",width:dt,isSpacer:!0}]:[],...$],sn=Le>0&&Z>Le?16:0,Ut=xe+V+se+sn+2,xt=5;let Ye=0,It=Ce-1,Kt=0,kt=0,Qe=le.length-1;for(;kt<=Qe;){const ve=kt+Qe>>>1;le[ve]<Te?kt=ve+1:Qe=ve-1}Ye=Math.max(0,kt-xt),Kt=Ye>0?le[Ye-1]:0;for(let ve=Ye;ve<le.length;ve++)if(le[ve]>=Te+ge){It=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ye,lastRowIndex:It,firstColumnIndex:Fe,lastColumnIndex:Se},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:xe,pinnedBottomHeight:se,totalWidth:Z,rowHeights:he,cumulativeHeights:le,virtualColumns:yt,columnMetrics:{leftPinnedWidth:re,rightPinnedWidth:ue,unpinnedAccWidths:d,unpinnedCols:N,totalSpecialsWidth:We,pinnedSpecialsWidth:(G?48:0)+(Je&&B?48:0)+(a&&R?48:0)}}},[Yn,de.virtualization.scrollTop,de.virtualization.scrollLeft,de.dimensions.viewportHeight,de.dimensions.viewportWidth,c]),el=l.useCallback(d=>{const N=d.currentTarget;if(Io(N.scrollTop,N.scrollLeft),jt){const{scrollTop:T,scrollHeight:$,clientHeight:Z}=N;$-T-Z<100&&jt({visibleTop:T,visibleBottom:T+Z,viewportHeight:Z})}},[Io,jt]);l.useEffect(()=>{if(!Nt.current)return;const d=new ResizeObserver(N=>{for(const T of N){const{width:$,height:Z}=T.contentRect;Mo($,Z)}});return d.observe(Nt.current),()=>{d.disconnect()}},[Mo]);const Vt=l.useCallback((d,N)=>{const T=new Set(Ie);N?T.add(d):T.delete(d);const $=Array.from(T);nn||yo($),fn?.($)},[Ie,nn,fn]),tl=l.useCallback(d=>{let N=[];d&&(N=wn.map(T=>T.id)),nn||yo(N),fn?.(N)},[o,nn,fn]),Lo=l.useCallback((d,N)=>{const T=N?[{field:d,sort:N}]:[];Rn||ki(T),b?.(T)},[Rn,b]),Xn=l.useCallback(d=>{Ft(!1),Wt({id:d.row.id,field:d.field}),hn.current?.focus({preventScroll:!0}),m?.(d)},[m,Ft]),Ro=l.useRef(Be.editingCell);l.useEffect(()=>{const d=!!Ro.current,N=!!Be.editingCell;d&&!N&&hn.current?.focus({preventScroll:!0}),Ro.current=Be.editingCell},[Be.editingCell]);const Oo=l.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:N}=_e.renderContext,T=Ke.length,$=Ke.map((se,V)=>({row:se,rowIndex:V})),Z=st.map((se,V)=>({row:se,rowIndex:T+(Me?ft.length:Pe.length)+V})),re=Math.max(0,d-T),ue=Math.min(Me?ft.length:Pe.length,N-T+1),Oe=(Me?ft:Pe).slice(re,ue).map((se,V)=>({row:se,rowIndex:T+re+V})),We=[...$,...Oe,...Z],le=new Set;return We.filter(se=>le.has(se.row.id)?!1:(le.add(se.row.id),!0))},[_e.renderContext,Ke,st,ft,Pe,Me,z,de.dataSource.loading,fe.pageSize,i]),nl=o.length>0&&Ie.size===o.length,ol=Ie.size>0&&Ie.size<o.length,rl=l.useCallback(d=>{d.target===d.currentTarget&&Wt(N=>{if(N)return N;if(a)return{id:"HEADER",field:"__checkbox_col__"};const T=ke[0],$=we[0];return T&&$?{id:T.id,field:$.field}:null})},[ke,we]),il=l.useCallback(d=>{d.currentTarget.contains(d.relatedTarget)||Wt(null)},[]),ll=l.useCallback(d=>{if(Ft(!0),!qe)return;const{id:N,field:T}=qe,$=!!Be.editingCell;if(d.key==="Enter"){if(d.preventDefault(),$)Be.stopCellEdit();else if(we.find(he=>he.field===T)?.editable){const he=ke.find(Ce=>Ce.id===N);he&&Be.startCellEdit({id:N,field:T,value:he[T]})}return}if((d.key===" "||d.key==="Spacebar")&&!$){if(T==="__checkbox_col__"){d.preventDefault(),Vt(N,!Ie.has(N));return}if(T==="__expand_col__"){d.preventDefault(),ln(N);return}}if(N==="HEADER"&&(d.key==="Enter"||d.key===" ")){d.preventDefault();const V=we.find(he=>he.field===T);if(V&&V.sortable!==!1){const he=nt.find(be=>be.field===T);let Ce="asc";he&&(he.sort==="asc"?Ce="desc":Ce=null),Lo(T,Ce)}return}if(d.key==="Escape"){$&&(d.preventDefault(),Be.stopCellEdit({cancel:!0}));return}if($&&d.key!=="Tab")return;const Z=N==="HEADER",re=Z?-1:ke.findIndex(V=>V.id===N),ue=we.findIndex(V=>V.field===T);if(!Z&&re===-1||ue===-1)return;const Oe=(V,he,Ce,be,Te,Le=!1)=>{let ge=V+Ce,ce=he+be;return Te&&be!==0&&(be>0&&ce>=we.length?(ce=0,ge++):be<0&&ce<0&&(ce=we.length-1,ge--)),!Te&&(ce<0||ce>=we.length)||ge<(Le?-1:0)||ge>=ke.length?null:{r:ge,c:ce}},We=(V,he,Ce,be,Te,Le=!1)=>{let ge=V,ce=he,ht=0;const at=ke.length*we.length+we.length;for(;ht<at;){if(ht++,ge+=Ce,ce+=be,be!==0)be>0?ce>=we.length&&(ce=0,ge++):ce<0&&(ce=we.length-1,ge--);else if(ce<0||ce>=we.length)return null;if(ge<-1||ge>=ke.length)return null;if(ge===-1){if(!Le)continue;const Re=we[ce],dt=Re.sortable!==!1;if(["__checkbox_col__"].includes(Re.field)||dt)return{r:ge,c:ce};continue}const Fe=ke[ge],Se=we[ce],Ae=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(Se.field);let Ge=Se.editable||Ae;if(K&&!Ae)try{Ge=K({row:Fe,field:Se.field,value:Fe[Se.field],colDef:Se,rowIndex:ge,colIndex:ce})}catch(Re){console.error("Error in isCellEditable:",Re)}if(Ge)return{r:ge,c:ce}}return null};let le=re,xe=ue,se=!1;if(d.key==="Tab"){const V=d.shiftKey?-1:1,he=We(re,ue,0,V,!0,!1);he&&(le=he.r,xe=he.c,se=!0)}else if(d.key==="ArrowRight"){const V=Oe(re,ue,0,1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowLeft"){const V=Oe(re,ue,0,-1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowDown"){const V=Oe(re,ue,1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowUp"){const V=Oe(re,ue,-1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="Home")(d.ctrlKey||d.metaKey)&&(le=-1),xe=0,se=!0;else if(d.key==="End")(d.ctrlKey||d.metaKey)&&(le=ke.length-1),xe=we.length-1,se=!0;else if(d.key==="PageUp"){const V=Me?fe.pageSize:10;le=Math.max(-1,le-V),se=!0}else if(d.key==="PageDown"){const V=Me?fe.pageSize:10;le=Math.min(ke.length-1,le+V),se=!0}if(se&&(d.preventDefault(),$&&d.key==="Tab"&&Be.stopCellEdit(),le>=-1&&le<ke.length&&xe>=0&&xe<we.length)){const V=we[xe];if(le===-1)Wt({id:"HEADER",field:V.field});else{const he=ke[le];Wt({id:he.id,field:V.field})}if(Nt.current){const{cumulativeHeights:he,pinnedTopHeight:Ce}=_e,{clientHeight:be,clientWidth:Te,scrollTop:Le,scrollLeft:ge}=Nt.current,ce=le===0?0:he[le-1],ht=he[le],at=Ce,Fe=Le+at,Se=Le+be;let Ae=Le;if(ce<Fe?Ae=Math.max(0,ce-at):ht>Se&&(Ae=ht-be),Ae!==Le&&(Nt.current.scrollTop=Ae),_e.columnMetrics){const{leftPinnedWidth:Ge,rightPinnedWidth:Re,unpinnedAccWidths:dt,unpinnedCols:yt,totalSpecialsWidth:pt,pinnedSpecialsWidth:sn}=_e.columnMetrics,Ut=V.field,xt=yt.findIndex(Ye=>Ye.field===Ut);if(xt!==-1){const Ye=pt+Ge+(xt>0?dt[xt-1]:0),It=pt+Ge+dt[xt],Kt=ge+sn+Ge,kt=ge+Te-Re;let Qe=ge;Ye<Kt?Qe=Math.max(0,Ye-sn-Ge):It>kt&&(Qe=It-Te+Re),Qe!==ge&&(Nt.current.scrollLeft=Qe)}}}}},[qe,ke,we,Be,_e,Ie,Vt,ln]),sl=l.useMemo(()=>ye.some(d=>!!d.rowSpan),[ye]),[_n,Cn]=l.useState(!1),yn=l.useRef(null);return l.useEffect(()=>{if(!_n||Ne?.toolbar)return;function d(N){const T=document.getElementById("ogx-standalone-col-panel");T&&!T.contains(N.target)&&Cn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[_n,Ne?.toolbar]),t.jsxs("div",{ref:yn,className:`ogx ${en} ${c?"ogx--auto-height":""} ${sl?"ogx--row-spanning":""} ${cn?"ogx--list-view":""}`,style:{...Rt,height:X??Rt?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":on,children:[vo&&(()=>{const d={apiRef:lt.apiRef,columns:ye,aggregationModel:ot,onAggregationModelChange:Ni,...De||et||tt?{pivotModel:_o,onPivotModelChange:Wi}:{},filterModel:Ve,onFilterModelChange:h,columnVisibilityModel:Xe,onColumnVisibilityModelChange:tn,onColumnReorder:Y?void 0:(N,T)=>{const $=[..._t],Z=$.indexOf(N),re=$.indexOf(T);if(Z===-1||re===-1)return;const ue=[...$];ue.splice(Z,1),ue.splice(re,0,N),A||bn(ue);const Oe=ye.find(We=>We.field===N);Oe&&U?.({oldIndex:Z,targetIndex:re,column:Oe})},forceColumnsOpen:_n,onColumnsPanelClose:()=>Cn(!1),...gt?.toolbar};return t.jsx(vo,{...d})})(),!Ne?.toolbar&&_n&&St.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const d=yn.current?.getBoundingClientRect();return{position:"fixed",top:d?d.top+8:16,right:d?window.innerWidth-d.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[t.jsx("button",{onClick:()=>Cn(!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:"×"}),t.jsx(co,{columns:ye,visibleColumns:new Set(ye.filter(d=>Xe[d.field]!==!1).map(d=>d.field)),onVisibilityChange:(d,N)=>{tn({...Xe,[d]:N})},onShowAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!0)}),tn(d)},onHideAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!1)}),tn(d)},onColumnReorder:Y?void 0:(d,N)=>{const T=[..._t],$=T.indexOf(d),Z=T.indexOf(N);if($===-1||Z===-1)return;const re=[...T];re.splice($,1),re.splice(Z,0,d),A||bn(re),U?.({oldIndex:$,targetIndex:Z,column:ye.find(ue=>ue.field===d)})}})]}),yn.current?.closest(".ogx-theme-provider")||document.body),cn&&wo&&t.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":Ot||"Data grid list view","aria-rowcount":ke.length+1,children:[t.jsx("div",{className:"ogx-list-view__toolbar",children:t.jsxs("span",{children:[He.length," ",He.length===1?"item":"items",Me?` · page ${fe.page+1} of ${Math.ceil(He.length/fe.pageSize)||1}`:"",Ie.size>0?` · ${Ie.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:ke.length===0?t.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),Tn]}):ke.map((d,N)=>t.jsx(zo,{row:d,rowIndex:N,listViewColumn:wo,isSelected:Ie.has(d.id),checkboxSelection:a,rowHeight:i,onRowClick:T=>mn({row:T,id:T.id,rowIndex:N}),onSelectionChange:Vt},d.id))}),Me&&(()=>{const d=Ne?.pagination||lo,N=z==="server"&&oe?de.pagination.rowCount||0:He.length,T={page:fe.page,pageSize:fe.pageSize,rowCount:N,pageSizeOptions:k,onPageChange:$=>gn({...fe,page:$}),onPageSizeChange:$=>gn({...fe,pageSize:$,page:0}),...gt?.pagination};return t.jsx(d,{...T})})()]}),!cn&&t.jsx("div",{ref:d=>{Nt.current=d,hn.current=d},className:"ogx__viewport",onScroll:el,role:"grid","aria-label":Ot||"Data grid","aria-rowcount":He.length+1,"aria-colcount":e.length+(a?1:0)+(Je?1:0)+(G?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Ft(!0)},onMouseDownCapture:()=>{Ft(!1)},onKeyDown:ll,onFocus:rl,onBlur:il,children:t.jsxs("div",{ref:$i,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(oo,{columns:_e.virtualColumns,allColumns:ye,columnGroupingModel:Et,checkboxSelection:a,allSelected:nl,someSelected:ol,onSelectAll:tl,sortModel:nt,onSort:Lo,onColumnResize:Zi,columnWidths:Ue,pinnedColumns:rt,focusedCell:qe,onHeaderClick:d=>{Wt({id:"HEADER",field:d}),Ft(!1),hn.current?.focus({preventScroll:!0})},onDragStart:Et?void 0:$t.onDragStart,onDragOver:Et?void 0:$t.onDragOver,onDragEnd:Et?void 0:$t.onDragEnd,onDrop:Et?void 0:$t.onDrop,draggedColumn:Et?void 0:$t.draggedColumn,dragOverColumn:Et?void 0:$t.dragOverColumn,rowReordering:G,hasDetailPanel:Je,pinCheckboxColumn:R,pinExpandColumn:B,aggregationModel:ot,onHideColumn:d=>{tn({...Xe,[d]:!1})},onManageColumns:()=>Cn(!0),onPinColumn:(d,N)=>{const T=[...rt?.left??[]],$=[...rt?.right??[]],Z=T.filter(ue=>ue!==d),re=$.filter(ue=>ue!==d);zn(N==="left"?{left:[...Z,d],right:re}:N==="right"?{left:Z,right:[...re,d]}:{left:Z,right:re})}}),!on&&!de.dataSource.error&&He.length===0&&t.jsxs("div",{className:"ogx__empty",style:{width:_e.totalWidth},children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),t.jsx("span",{children:Tn})]}),Ke.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ke.map((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.id))}),t.jsx("div",{className:"ogx__virtual-container",style:{height:`${_e.totalHeight-_e.pinnedTopHeight-_e.pinnedBottomHeight}px`},role:"presentation",children:t.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${_e.renderContext.firstRowIndex*i}px)`},role:"rowgroup",children:[on&&Oo.length===0?(()=>{const d=e.length>0?e:(()=>{const N=(de.dimensions.viewportWidth||1e3)-(a?48:0)-(I?48:0)-(G?48:0),T=150,$=Math.max(1,Math.ceil(N/T));return Array.from({length:$},(Z,re)=>({field:`placeholder_${re}`,headerName:"",width:T}))})();return Array.from({length:10}).map((N,T)=>t.jsx(ur,{columns:d,rowHeight:i,checkboxSelection:a,hasDetailPanel:!!I,rowReordering:G},`skeleton-${T}`))})():Oo.filter(({row:d})=>!En(d.id,y)).filter((d,N,T)=>N===T.findIndex($=>$.row.id===d.row.id)).map(({row:d,rowIndex:N})=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,rowReordering:G,onDragStart:Ht.onDragStart,onDragOver:Ht.onDragOver,onDragEnd:Ht.onDragEnd,onDrop:Ht.onDrop,isDragging:Ht.draggedRowId===d.id,isDragOver:Ht.dragOverRowId===d.id,editingCell:Be.editingCell,onEditStart:Be.startCellEdit,onEditStop:Be.stopCellEdit,onEditCellValueChange:Be.setEditCellValue,focusedCellField:qe!=null&&qe.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},`${d.id}-${_e.totalWidth}`)),z==="infinite"&&de.dataSource.loading&&Pe.length>0&&(()=>{const d=Math.min(fe.pageSize,20),N=Yn.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:d}).map((T,$)=>t.jsx(Jt,{row:{id:`__skeleton_${$}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:N+$,rowHeight:i},`__skeleton_${$}__`))})})()]})}),st.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:st.map((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.id))}),vn&&t.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[a&&t.jsx("div",{style:{width:48,flexShrink:0}}),Je&&t.jsx("div",{style:{width:48,flexShrink:0}}),G&&t.jsx("div",{style:{width:48,flexShrink:0}}),Bt.map(d=>{const N=ot[d.field],T=Kn[d.field],$=Ue[d.field]??(typeof d.width=="number"?d.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:$,minWidth:$,maxWidth:$,textAlign:d.align||"left"},children:N?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ogx__aggregation-label",children:N}),t.jsx("span",{className:"ogx__aggregation-value",children:bt(T,N)})]}):null},d.field)})]})]})}),!cn&&Me&&(()=>{const d=Ne?.pagination||lo,N={page:fe.page,pageSize:fe.pageSize,rowCount:de.pagination.rowCount,pageSizeOptions:k,onPageChange:T=>gn({...fe,page:T}),onPageSizeChange:T=>gn({...fe,pageSize:T,page:0}),...gt?.pagination};return t.jsx(d,{...N})})(),t.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[on?"Loading data...":"",de.dataSource.error?`Error: ${de.dataSource.error.message||"Unknown error"}`:"",!Q&&!de.dataSource.error&&(He.length===0?Tn:Ve&&((Ve.quickFilterValues?.length||0)>0||(Ve.items?.length||0)>0)?`${He.length} ${He.length===1?"row":"rows"} found`:"")]}),de.dataSource.error&&t.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[t.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:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),t.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),t.jsx("div",{className:"ogx-error-overlay__message",children:de.dataSource.error.message||"An unexpected error occurred while loading the data."}),t.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})]})}function Fr({rows:n=5,columns:o=5}){return t.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,r)=>t.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:o}).map((i,s)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-content"})},s))},r))})}const uo=new Set(["isEmpty","isNotEmpty"]);function Ar(n,o){return n.find(e=>"field"in e&&e.field===o)}const zr=({col:n,item:o,onChange:e})=>{const r=_r(n.type),i=!!o,s=o?.operator??r[0],c=u=>{const h=uo.has(u),w={id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:u,value:h?void 0:o?.value??(n.type==="boolean"?"true":"")};e(w)},a=u=>{e({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:s,value:u})},g=()=>{e(null)},f=uo.has(String(s)),p=n.type==="boolean",m=!f;return t.jsxs("div",{className:`ogx-filter__row${i?" ogx-filter__row--active":""}`,children:[t.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),t.jsxs("div",{className:"ogx-filter__controls",children:[t.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:u=>c(u.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(u=>t.jsx("option",{value:u,children:u},u))}),m&&p&&t.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(o?.value??"true"),onChange:u=>a(u.target.value),"aria-label":`Filter value for ${n.headerName||n.field}`,children:[t.jsx("option",{value:"true",children:"true"}),t.jsx("option",{value:"false",children:"false"})]}),m&&!p&&t.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:n.type==="number"?"number":"text",value:o?.value??"",onChange:u=>a(u.target.value),placeholder:"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),i&&t.jsx("button",{className:"ogx-filter__row-clear",onClick:g,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},go=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],i=n.logicOperator??"and",s=l.useCallback((g,f)=>{const p=r.filter(u=>"field"in u&&u.field!==g),m=f?[...p,f]:p;e({...n,items:m})},[r,n,e]),c=l.useCallback(g=>{e({...n,logicOperator:g})},[n,e]),a=o.filter(g=>g.filterable!==!1);return t.jsxs(t.Fragment,{children:[r.length>1&&t.jsxs("div",{className:"ogx-filter__logic-bar",children:[t.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),t.jsx("button",{className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),t.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(g=>t.jsx(zr,{col:g,item:Ar(r,g.field),onChange:f=>s(g.field,f)},g.field))]})},Br=["sum","avg","count","min","max"];function fo(){return t.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:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),t.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function $r({anchorRef:n,columns:o,model:e,onChange:r,onClose:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const x=n.current.getBoundingClientRect();return{top:x.bottom+6,right:window.innerWidth-x.right}},[n]);l.useEffect(()=>{a(g());const x=()=>a(g());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[g]),l.useEffect(()=>{function x(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&i()}function j(R){R.key==="Escape"&&i()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",j)}},[n,i]);const f=new Set(e.rowFields),p=new Set(e.columnFields),m=new Set(e.valueFields.map(x=>x.field)),u=x=>f.has(x)||p.has(x)||m.has(x);function h(x){f.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function w(x){p.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function b(x,j="sum"){m.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:j}]})}function M(x){r({...e,rowFields:e.rowFields.filter(j=>j!==x)})}function P(x){r({...e,columnFields:e.columnFields.filter(j=>j!==x)})}function E(x){r({...e,valueFields:e.valueFields.filter(j=>j.field!==x)})}function k(x,j){r({...e,valueFields:e.valueFields.map(R=>R.field===x?{...R,aggFn:j}:R)})}function C(){r({rowFields:[],columnFields:[],valueFields:[]})}const _=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),y=e.rowFields.length+e.columnFields.length+e.valueFields.length,I=x=>o.find(j=>j.field===x)?.headerName??x,S=t.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:c.top,right:c.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(fo,{}),"Pivot Mode"]}),y>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:C,title:"Reset pivot",children:"Reset"})]}),t.jsxs("div",{className:"ogx-pivot-panel__body",children:[t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(x),title:`Remove ${I(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>P(x),title:`Remove ${I(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[I(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:j=>k(x.field,j.target.value),title:"Aggregation function",children:Br.map(j=>t.jsx("option",{value:j,children:j.toUpperCase()},j))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x.field),title:`Remove ${I(x.field)}`,children:"×"})]},x.field))})]}),t.jsx("hr",{className:"ogx-pivot-panel__divider"}),t.jsxs("div",{children:[t.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),t.jsxs("div",{className:"ogx-pivot-fields",children:[o.map(x=>{const j=_.has(x.field);return u(x.field)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[t.jsx("span",{className:`ogx-pivot-field-btn${j?" ogx-pivot-field-btn--numeric":""}`,children:x.headerName??x.field}),t.jsxs("div",{className:"ogx-pivot-field-actions",children:[t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>h(x.field),title:"Add to Row Fields",children:"Row"}),t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>w(x.field),title:"Add to Column Fields",children:"Col"}),j&&t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>b(x.field),title:"Add to Value Fields",children:"Val"})]})]},x.field)}),o.every(x=>u(x.field))&&t.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return St.createPortal(S,n.current?.closest(".ogx-theme-provider")||document.body)}function Dr(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Gr({value:n="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[i,s]=l.useState(!1),[c,a]=l.useState(n),g=l.useRef(null),f=l.useRef(null);l.useEffect(()=>{a(n),n&&!i&&s(!0)},[n,i]),l.useEffect(()=>{const h=setTimeout(()=>{c!==n&&o(c)},r);return()=>clearTimeout(h)},[c,o,r,n]);const p=()=>{s(!0)},m=h=>{h.stopPropagation(),a(""),g.current?.focus(),o("")},u=()=>{c||s(!1)};return l.useEffect(()=>{const h=w=>{f.current&&!f.current.contains(w.target)&&(c||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),t.jsxs("div",{ref:f,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:()=>{i||(s(!0),setTimeout(()=>g.current?.focus(),50))},children:[t.jsx("div",{className:"ogx-global-search__icon-wrapper",children:t.jsx(Dr,{})}),t.jsx("input",{ref:g,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:c,onChange:h=>a(h.target.value),onFocus:p,onBlur:u,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),c&&t.jsx("button",{className:"ogx-global-search__clear",onClick:m,"aria-label":"Clear search",children:t.jsx(Hr,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:i=0}){const[s,c]=l.useState(!1),[a,g]=l.useState({top:0,left:0}),f=l.useRef(null),p=l.useRef(null),m=l.useCallback(()=>{if(!p.current)return;const b=p.current.getBoundingClientRect();let M=0,P=0;const E=window.pageXOffset||document.documentElement.scrollLeft,k=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(M=b.top+k-8,P=b.left+E+b.width/2):e==="bottom"&&(M=b.bottom+k+8,P=b.left+E+b.width/2),g({top:M,left:P})},[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 u=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!0)},r)},h=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!1)},i)},w=l.useCallback(b=>{p.current=b?b.firstElementChild??b:null},[]);return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:u,onMouseLeave:h,children:o}),s&&n&&St.createPortal(t.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Vr=["none","sum","avg","count","min","max"];function ho(){return t.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:t.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Ur(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function po(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Kr({anchorRef:n,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:i,onClose:s,activeCount:c}){const a=l.useRef(null),[g,f]=l.useState({top:0,right:0}),p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{f(p());const u=()=>f(p());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[p]),l.useEffect(()=>{function u(h){a.current&&!a.current.contains(h.target)&&n.current&&!n.current.contains(h.target)&&s()}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n,s]),l.useEffect(()=>{function u(h){h.key==="Escape"&&s()}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);const m=t.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:g.top,right:g.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(ho,{}),"Summaries"]}),c>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,title:"Clear all summaries",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?t.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",t.jsx("br",{}),"Set ",t.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(u=>{const h=o[u.field]||"none";return t.jsxs("div",{className:"ogx-toolbar__agg-row",children:[t.jsx("span",{className:"ogx-toolbar__agg-label",title:u.field,children:u.headerName||u.field}),t.jsx("div",{className:"ogx-toolbar__agg-pills",children:Vr.map(w=>t.jsx("button",{className:`ogx-toolbar__pill${h===w?" ogx-toolbar__pill--active":""}`,onClick:()=>r(u.field,w),"aria-pressed":h===w,children:w},w))})]},u.field)})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}function Yr({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c,onClose:a}){const g=l.useRef(null),[f,p]=l.useState({top:0,right:0}),m=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const h=n.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[n]);l.useEffect(()=>{p(m());const h=()=>p(m());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[m]),l.useEffect(()=>{function h(w){g.current&&!g.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&a()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,a]);const u=t.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:f.top,right:f.right,width:280,padding:0},children:t.jsx(co,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c})});return St.createPortal(u,n.current?.closest(".ogx-theme-provider")||document.body)}function Xr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{a(g());const u=()=>a(g());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[g]),l.useEffect(()=>{function u(w){s.current&&!s.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&i()}function h(w){w.key==="Escape"&&i()}return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[n,i]);const f=e.items?.length??0,p=()=>{r({...e,items:[],logicOperator:"and"})},m=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:c.top,right:c.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(po,{}),"Filters",f>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:f})]}),f>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:p,title:"Clear all filters",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:t.jsx(go,{columns:o,filterModel:e,onFilterModelChange:r})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}const qr={rowFields:[],columnFields:[],valueFields:[]};function Jr({columns:n=[],aggregationModel:o={},onAggregationModelChange:e,pivotModel:r,onPivotModelChange:i,filterModel:s,onFilterModelChange:c,columnVisibilityModel:a={},onColumnVisibilityModelChange:g,onColumnReorder:f,forceColumnsOpen:p,onColumnsPanelClose:m,children:u,rightContent:h,style:w}){const[b,M]=l.useState(!1),[P,E]=l.useState(!1),[k,C]=l.useState(!1),[_,y]=l.useState(!1);l.useEffect(()=>{p&&(C(!0),M(!1),E(!1),y(!1))},[p]);const I=l.useRef(null),S=l.useRef(null),x=l.useRef(null),j=l.useRef(null),R=r??qr,B=R.rowFields.length>0||R.columnFields.length>0||R.valueFields.length>0,Y=n.filter(W=>W.aggregable!==!1&&(W.type==="number"||W.aggregable===!0)),A=Object.keys(o).filter(W=>o[W]&&o[W]!=="none").length,U=l.useCallback((W,F)=>{if(!e)return;const q={...o};F==="none"?delete q[W]:q[W]=F,e(q)},[o,e]),X=l.useCallback(()=>{e?.({})},[e]),G=l.useCallback(W=>{if(!c)return;const q={...s||{},quickFilterValues:W?[W]:[],items:s?.items||[]};c(q)},[s,c]),ee=s?.quickFilterValues?.[0]||"",Q=s?.items?.length||0,pe=new Set(n.filter(W=>a[W.field]!==!1).map(W=>W.field)),v=l.useCallback((W,F)=>{if(!g)return;const q={...a,[W]:F};g(q)},[a,g]),D=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!0)}),g(W)},[n,a,g]),H=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!1)}),g(W)},[n,a,g]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:w,children:[u&&t.jsx("div",{className:"ogx-toolbar__left",children:u}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Gr,{value:ee,onChange:G,placeholder:"Search..."})}),g&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:x,className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{C(!k),M(!1),E(!1),y(!1)},children:t.jsx(Ur,{})})}),k&&t.jsx(Yr,{anchorRef:x,columns:n,visibleColumns:pe,onVisibilityChange:v,onShowAll:D,onHideAll:H,onColumnReorder:f,onClose:()=>{C(!1),m?.()}})]}),c&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:j,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{y(!_),M(!1),E(!1),C(!1)},children:[t.jsx(po,{}),Q>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),_&&t.jsx(Xr,{anchorRef:j,columns:n,filterModel:s||{items:[]},onFilterModelChange:c,onClose:()=>y(!1)})]}),i&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:S,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,"aria-controls":"ogx-pivot-panel",onClick:()=>{E(!P),M(!1),C(!1),y(!1)},children:[t.jsx(fo,{}),B&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&t.jsx($r,{anchorRef:S,columns:n,model:R,onChange:W=>{i?.(W)},onClose:()=>E(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:I,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${b?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":b,"aria-controls":"ogx-aggregation-panel",onClick:()=>{M(!b),E(!1),C(!1),y(!1)},children:[t.jsx(ho,{}),A>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${A} active summaries`})]})}),b&&t.jsx(Kr,{anchorRef:I,aggregationModel:o,aggregableColumns:Y,onFunctionChange:U,onClearAll:X,onClose:()=>M(!1),activeCount:A})]}),h]})]})}function Qr(){return l.useRef(null)}const Zr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:i="",...s})=>{const c=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return t.jsxs("div",{className:c,children:[e&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),t.jsx("input",{className:"ogx-input",...s}),r&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})};function ei(n,o,e={}){const{fileName:r="export.csv",includeHeaders:i=!0,delimiter:s=",",selectedRows:c}=e,a=c&&c.length>0?n.filter(p=>c.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const g=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let f="";if(i){const p=g.map(m=>Lt(m.headerName||m.field));f+=p.join(s)+`
|
|
9
|
-
`}if(
|
|
10
|
-
`}),e.aggregationResult){const
|
|
11
|
-
`;const
|
|
12
|
-
`}Pn(
|
|
13
|
-
`)?`"${n.replace(/"/g,'""')}"`:n}function ti(n,o,e={}){const{fileName:r="export.xlsx",sheetName:
|
|
6
|
+
<%s key={someKey} {...props} />`,K,$,L,$),pe[$+K]=!0)}if($=null,H!==void 0&&(e(H),$=""+H),d(D)&&(e(D.key),$=""+D.key),"key"in D){H={};for(var ae in D)ae!=="key"&&(H[ae]=D[ae])}else H=D;return $&&s(H,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,$,H,l(),R,Y)}function m(_){p(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===x&&(_._payload.status==="fulfilled"?p(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function p(_){return typeof _=="object"&&_!==null&&_.$$typeof===C}var f=i,C=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),y=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),W=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,A=Array.isArray,U=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(_){return _()}};var q,G={},ee=f.react_stack_bottom_frame.bind(f,a)(),Q=U(r(a)),pe={};Xt.Fragment=E,Xt.jsx=function(_,D,H){var K=1e4>W.recentlyCreatedOwnerStacks++;return h(_,D,H,!1,K?Error("react-stack-top-frame"):ee,K?U(r(_)):Q)},Xt.jsxs=function(_,D,H){var K=1e4>W.recentlyCreatedOwnerStacks++;return h(_,D,H,!0,K?Error("react-stack-top-frame"):ee,K?U(r(_)):Q)}})()),Xt}var eo;function Ao(){return eo||(eo=1,process.env.NODE_ENV==="production"?an.exports=Fo():an.exports=Wo()),an.exports}var t=Ao();function zo({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:l=!1,rowHeight:a,onRowClick:d,onSelectionChange:s}){const g={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},u=h=>{h.stopPropagation(),s?.(n.id,h.target.checked)};return t.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:a?{minHeight:a}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[l&&t.jsx("div",{className:"ogx-list-view__checkbox",onClick:h=>h.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:r,onChange:u,"aria-label":`Select row ${n.id}`})}),t.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(g)})]})}const qt=({indeterminate:n=!1,label:o,className:e="",inputRef:r,...l})=>{const a=i.useRef(null),d=i.useCallback(g=>{a.current=g,typeof r=="function"?r(g):r&&(r.current=g)},[r]);i.useEffect(()=>{a.current&&(a.current.indeterminate=n)},[n]);const s=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return t.jsxs("label",{className:s,children:[t.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||l["aria-label"]||(n?"Select some":l.checked?"Deselect":"Select"),...l}),t.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),o&&t.jsx("span",{className:"ogx-checkbox__label",children:o})]})};function Bo(n){const{field:o,currentWidth:e,onResize:r,minWidth:l=50,maxWidth:a=1e3}=n,[d,s]=i.useState(!1),g=i.useRef(0),u=i.useRef(0),h=i.useCallback(f=>{f.preventDefault(),f.stopPropagation(),s(!0),g.current=f.clientX,u.current=e;let C=0;const b=16,E=k=>{const j=k.clientX-g.current,y=Math.max(l,Math.min(a,u.current+j)),w=Date.now();w-C>=b&&(r(o,y),C=w)},P=k=>{s(!1);const j=k.clientX-g.current,y=Math.max(l,Math.min(a,u.current+j));r(o,y),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",P)},[o,e,r,l,a]),m=i.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),p=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return t.jsx("div",{className:p,onMouseDown:h,onClick:f=>f.stopPropagation(),onDragStart:f=>{f.preventDefault(),f.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} column`,children:t.jsx("div",{className:"ogx-column-resize-handle__line"})})}function dn(n,o){return o?o.left?.includes(n)?"left":o.right?.includes(n)?"right":null:null}function $o(n,o){const e=[],r=[],l=[];return o?(n.forEach(a=>{const d=dn(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),g=o.left.indexOf(d.field);return s-g}),o.right&&l.sort((a,d)=>{const s=o.right.indexOf(a.field),g=o.right.indexOf(d.field);return s-g}),{left:e,center:r,right:l}):{left:e,center:n,right:l}}function to(n,o,e,r,l,a,d,s){const g={};if(!e)return g;const u=$o(n,e);let h=0;s&&(h+=48),a&&d&&(h+=48),r&&l&&(h+=48),u.left.forEach(p=>{g[p.field]=h;const f=o[p.field]??p.width??100;h+=f});let m=0;return[...u.right].reverse().forEach(p=>{const f=o[p.field]??p.width??100;g[p.field]=m,m+=f}),g}function En(n,o){return o?o.top?.includes(n)?"top":o.bottom?.includes(n)?"bottom":null:null}function Do(n,o){const e=[],r=[],l=[];return o?(n.forEach(a=>{const d=En(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),g=o.top.indexOf(d.id);return s-g}),o.bottom&&l.sort((a,d)=>{const s=o.bottom.indexOf(a.id),g=o.bottom.indexOf(d.id);return s-g}),{top:e,center:r,bottom:l}):{top:e,center:n,bottom:l}}function Mt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:t.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Pt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Ho(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Go(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),t.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Vo(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Uo(){return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Ko(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.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"}),t.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"}),t.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Yo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),t.jsx("polyline",{points:"11 8 4 12 11 16"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Xo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),t.jsx("polyline",{points:"13 8 20 12 13 16"}),t.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function qo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),t.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Jo({colDef:n,sortModel:o,onSort:e,onHide:r,onPin:l,pinnedColumns:a,onManageColumns:d,onClose:s,anchorEl:g}){const u=i.useRef(null),[h,m]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!g||!u.current)return;const w=g.getBoundingClientRect(),v=u.current.getBoundingClientRect(),M=window.innerWidth,S=window.innerHeight,x=8;let N=w.left;N+v.width+x>M&&(N=M-v.width-x),N<x&&(N=x);let O=w.bottom+4;O+v.height+x>S&&(O=w.top-v.height-4),m({position:"fixed",zIndex:1300,top:O,left:N,visibility:"visible"})},[g]),i.useEffect(()=>{function w(M){u.current&&!u.current.contains(M.target)&&g&&!g.contains(M.target)&&s()}function v(M){M.key==="Escape"&&s()}return document.addEventListener("mousedown",w),document.addEventListener("keydown",v),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",v),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[g,s]);const p=w=>{e?.(n.field,w),s()},f=()=>{r?.(n.field),s()},C=w=>{l?.(n.field,w),s()},b=o?.find(w=>w.field===n.field)?.sort,E=b==null,P=a?.left?.includes(n.field)??!1,k=a?.right?.includes(n.field)??!1,j=!P&&!k,y=n.headerName||n.field;return St.createPortal(t.jsxs("div",{ref:u,className:"ogx-column-menu",style:h,role:"menu","aria-label":`Column options for ${y}`,children:[e&&n.sortable!==!1&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${b==="asc"?" ogx-menu-item--active":""}`,onClick:()=>p("asc"),role:"menuitemradio","aria-checked":b==="asc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="asc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Go,{})}),"Sort Ascending"]}),t.jsxs("button",{className:`ogx-menu-item${b==="desc"?" ogx-menu-item--active":""}`,onClick:()=>p("desc"),role:"menuitemradio","aria-checked":b==="desc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="desc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Vo,{})}),"Sort Descending"]}),t.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>p(null),role:"menuitemradio","aria-checked":E,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Uo,{})}),"Unsort"]}),t.jsx("div",{className:"ogx-menu-divider"})]}),t.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),t.jsxs("button",{className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>C("left"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to left",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Yo,{})}),"Pin to Left"]}),t.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>C("right"),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to right",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Xo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>C(null),role:"menuitemradio","aria-checked":j,"aria-label":"Unpin column",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(qo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:f,role:"menuitem","aria-label":`Hide ${y} column`,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ko,{})}),"Hide Column"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),s()},role:"menuitem","aria-label":"Manage all columns",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ho,{})}),"Manage columns"]})]}),g?.closest(".ogx-theme-provider")||document.body)}function Qo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:t.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 Zo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function no(n){const o=[];for(const e of n.children)typeof e=="string"?o.push(e):o.push(...no(e));return o}function er(n){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 n.forEach(r=>e(r,1)),o}function tr(n,o,e){function r(s,g,u){if(!no(s).includes(g))return null;if(u===e)return s;for(const h of s.children)if(typeof h!="string"){const m=r(h,g,u+1);if(m)return m}return null}const l=new Map;for(const s of o){let g=null;for(const u of n)if(g=r(u,s.field,0),g)break;l.set(s.field,g)}const a=[];let d=0;for(;d<o.length;){const s=o[d],g=l.get(s.field)??null,u=s.width;if(!g)a.push({key:`fg-${s.field}-${e}`,label:"",width:u,isGroup:!1}),d++;else{let h=0,m=d;for(;m<o.length&&l.get(o[m].field)===g;)h+=o[m].width,m++;a.push({key:`${g.groupId}-${e}`,label:g.headerName,width:h,isGroup:!0}),d=m}}return a}function oo(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:l=!1,allSelected:a=!1,someSelected:d=!1,onSelectAll:s,onSort:g,sortModel:u=[],onColumnResize:h,columnWidths:m={},pinnedColumns:p,hasDetailPanel:f=!1,pinCheckboxColumn:C=!0,pinExpandColumn:b=!0,rowReordering:E=!1,aggregationModel:P,draggedColumn:k,dragOverColumn:j,onDragStart:y,onDragOver:w,onDragEnd:v,onDrop:M,focusedCell:S,onHeaderClick:x,onHideColumn:N,onPinColumn:O,onManageColumns:W}=n,X=i.useRef({}),[A,U]=i.useState(null),q=L=>ae=>{ae.stopPropagation(),U({colDef:L,anchorEl:ae.currentTarget})},G=()=>{U(null)};i.useLayoutEffect(()=>{if(S?.id==="HEADER"){const L=X.current[S.field];L&&L.focus()}},[S]);const ee=L=>()=>{if(L.sortable===!1||!g)return;const ae=u.find(me=>me.field===L.field);let oe="asc";ae&&(ae.sort==="asc"?oe="desc":oe=null),g(L.field,oe)},Q=L=>{const ae=u.find(oe=>oe.field===L);return ae?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ae.sort}`,"aria-hidden":"true"}):null},pe=i.useMemo(()=>to(o,m,p,l,C,f,b,E),[o,m,p,l,C,f,b,E]),_=r?er(r):0,H=(e??o).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),$=(E?48:0)+(f?48:0)+(l?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[_>0&&Array.from({length:_},(L,ae)=>{const oe=tr(r,H,ae);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[$>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:$,minWidth:$,flexShrink:0},role:"columnheader"}),oe.map(me=>t.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${me.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:me.width,minWidth:me.width,flexShrink:0},title:me.isGroup?me.label:void 0,children:me.isGroup&&t.jsx("span",{className:"ogx-col-group-cell__label",children:me.label})},me.key))]},`ogx-grp-${ae}`)}),t.jsxs("div",{className:"ogx__header",role:"row",children:[E&&t.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}}),f&&t.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${b?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:b?"sticky":void 0,left:b?E?48:0:void 0,zIndex:b?5:void 0}}),l&&t.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${C?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:C?"sticky":void 0,left:C?(E?48:0)+(f&&b?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:a,indeterminate:d,onChange:L=>s?.(L.target.checked),"aria-label":a?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{X.current.__checkbox_col__=L}})}),o.map((L,ae)=>{if(L.isSpacer)return t.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const oe=L.sortable!==!1,me=u.some(Be=>Be.field===L.field),Ze=L.resizable!==!1,z=dn(L.field,p),Ne=z!==null,ye=k===L.field,ft=j===L.field,ze=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,oe&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ne&&"ogx__header-cell--pinned",Ne&&`ogx__header-cell--pinned-${z}`,ye&&"ogx__header-cell--dragging",ft&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),et=m[L.field]??L.width??100,tt={width:et,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:Ne?"sticky":"relative",zIndex:L.zIndex,opacity:ye?.5:1};if(Ne&&z){const Be=pe[L.field];z==="left"?tt.left=Be:tt.right=Be}const en=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:ae}):L.headerName||L.field,Rt=Be=>{if(Be.target.closest(".ogx-column-resize-handle")){Be.stopPropagation();return}x?.(L.field),oe&&ee(L)()},jt=y?y(L.field):void 0,Ot=w?w(L.field):void 0,vt=M?M(L.field):void 0;return t.jsxs("div",{className:ze,style:tt,onClick:Rt,role:"columnheader",draggable:!!y,onDragStart:jt,onDragOver:Ot,onDragEnd:v,onDrop:vt,"aria-sort":oe?me?u.find(Be=>Be.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":ae+1+(l?1:0),"data-field":L.field,tabIndex:-1,ref:Be=>{X.current[L.field]=Be},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[ye&&t.jsx("div",{className:"ogx__header-drag-icon",children:t.jsx(Zo,{})}),t.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[t.jsx("span",{className:"ogx__header-cell-title",children:en}),P&&P[L.field]&&t.jsx("span",{className:"ogx__header-cell-aggregation",children:P[L.field]})]}),oe&&Q(L.field),!L.disableColumnMenu&&t.jsx("button",{className:"ogx__menu-icon-btn",onClick:q(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Qo,{})})]}),Ze&&h&&t.jsx(Bo,{field:L.field,currentWidth:et,onResize:h,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),A&&t.jsx(Jo,{colDef:A.colDef,sortModel:u,onSort:g,onHide:N,onPin:O,pinnedColumns:p,onManageColumns:W,onClose:G,anchorEl:A.anchorEl})]})]})}function nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.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 or({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(n??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:s=>{const g=s.target.value===""?"":Number(s.target.value);a(g),o(g===""?null:g)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function rr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const a=()=>{o(!n),setTimeout(e,0)};return t.jsx("div",{className:"ogx__edit-boolean",children:t.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:a,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),r())}})})}function ir({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:l}){const a=i.useRef(null);i.useEffect(()=>{a.current?.focus()},[]);const d=o.valueOptions??[];return t.jsx("select",{ref:a,className:"ogx__edit-select",value:n??"",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 g=typeof s=="object"?s.value:s,u=typeof s=="object"?s.label:String(s);return t.jsx("option",{value:String(g),children:u},String(g))})})}function lr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(n??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),t.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 sr(n){const{colDef:o}=n;switch(o.type){case"number":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(or,{...n})});case"boolean":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(rr,{...n})});case"singleSelect":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(ir,{...n})});case"date":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(lr,{...n})});default:return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(nr,{...n})})}}function ar(n){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:l,row:a,colDef:d,rowIndex:s,colIndex:g,isSelected:u,onClick:h,width:m,pinnedPosition:p,pinnedOffset:f,isFocused:C,isFocusVisible:b,isEditable:E,isEditing:P,onEditStart:k,onEditStop:j,onValueChange:y,colSpanInfo:w,rowSpan:v,isHiddenByRowSpan:M}=n;if(w?.spannedByColSpan)return null;if(M)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":g});const S=_=>{o&&(_.stopPropagation(),o({row:a,field:d.field,value:l,colDef:d,rowIndex:s,colIndex:g})),h?.(_)},x=i.useCallback(_=>{r?r(d.field,_):y?.(_)},[r,y,d.field]),N=_=>{E&&(k||e)&&(_.stopPropagation(),e?e(d.field,l):k?.())},O=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:a,field:d.field}):l==null?"":String(l),[l,a,d]),W=i.useMemo(()=>P&&(r||y)&&j?d.renderEditCell?d.renderEditCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g}):t.jsx(sr,{value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g,onValueChange:x,onCommit:()=>j(),onCancel:()=>j(!0)}):d.renderCell?d.renderCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g}):O,[l,a,d,s,g,O,P,x,j,r,y]),X=p!=null,A=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g})||"":d.cellClassName:"",[d,l,a,s,g]),U=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,u&&"ogx__cell--selected",C&&"ogx__cell--focused",C&&b&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,X&&"ogx__cell--pinned",X&&`ogx__cell--pinned-${p}`,P&&"ogx__cell--editing",v&&v>1&&"ogx__cell--spanned",A].filter(Boolean).join(" "),q=w?.cellProps?.colSpan||1,G=v||1,ee=w?.cellProps?.width??m??d.width??100,Q={width:"var(--width)","--width":typeof ee=="number"?`${ee}px`:ee,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:X?"sticky":void 0,zIndex:d.zIndex??(X?3:void 0),padding:P?0:void 0};G>1&&(Q.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,Q.zIndex=10,X&&(Q.zIndex=40)),X&&f!==void 0&&(p==="left"?Q.left=f:Q.right=f);const pe=i.useRef(null);return i.useLayoutEffect(()=>{C&&pe.current&&pe.current.focus({preventScroll:!0})},[C]),t.jsx("div",{ref:pe,className:U,style:Q,onClick:S,onDoubleClick:N,role:"gridcell","aria-colindex":g+1,"aria-readonly":!E||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":g,...q>1?{"aria-colspan":q}:{},...G>1?{"aria-rowspan":G}:{},children:t.jsx("div",{className:"ogx__cell-content",children:W})})}const ro=i.memo(ar);function io({isExpanded:n,onClick:o,variant:e="chevron"}){return t.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:r=>{o&&o(r)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.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"}})]}):t.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:t.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const dr=({className:n="",...o})=>t.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...o,children:t.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:t.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 cr(n){const{content:o,height:e,isExpanded:r}=n;if(!r)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return t.jsx("div",{className:"ogx__detail-panel",style:l,children:t.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function Jt(n){const{row:o,columns:e,rowIndex:r,isSelected:l=!1,checkboxSelection:a=!1,onRowClick:d,onCellClick:s,onSelectionChange:g,columnWidths:u={},pinnedColumns:h,pinnedRows:m,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:C,detailPanelContent:b,detailPanelHeight:E=200,pinCheckboxColumn:P=!0,pinExpandColumn:k=!0,rowReordering:j=!1,onDragStart:y,onDragOver:w,onDragEnd:v,onDrop:M,isDragging:S,isDragOver:x,editingCell:N,onEditStart:O,onEditStop:W,onEditCellValueChange:X,focusedCellField:A,isFocusVisible:U,colspanMap:q,rowSpanningCaches:G,rowHeight:ee=52}=n,Q=i.useRef(null),pe=i.useRef(null);if(o._isSkeleton){const z=Math.max(e.length,5);return t.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ee,minHeight:ee},children:Array.from({length:z}).map((Ne,ye)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},ye))})}i.useLayoutEffect(()=>{A==="__expand_col__"&&Q.current&&Q.current.focus({preventScroll:!0}),A==="__checkbox_col__"&&pe.current&&pe.current.focus({preventScroll:!0})},[A]);const _=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:o,id:o.id,rowIndex:r})},D=z=>{z.stopPropagation(),g?.(o.id,z.target.checked)},H=z=>{z.stopPropagation(),C?.(o.id)},K=i.useMemo(()=>to(e,u,h,a,P,p,k,j),[e,u,h,a,P,p,k,j]),R=En(o.id,m),Y=R==="top",$=R==="bottom",L=o._hasChildren===!0,ae=i.useCallback((z,Ne)=>{L||O?.({id:o.id,field:z,value:Ne})},[L,o.id,O]),oe=i.useCallback((z,Ne)=>{X?.({id:o.id,field:z,value:Ne})},[X,o.id]),me=i.useCallback(z=>{W?.({cancel:z})},[W]),Ze=["ogx__row",l&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",Y&&"ogx__row--pinned-top",$&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",x&&"ogx__row--drag-over",L&&"ogx__row--group"].filter(Boolean).join(" ");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Ze,onClick:_,role:"row","aria-rowindex":r+1,"aria-selected":l,"data-rowindex":r,onDragOver:w?w(o.id):void 0,onDrop:M?M(o.id):void 0,style:{maxHeight:`${ee}px`,minHeight:`${ee}px`,"--height":`${ee}px`,"--border-width":"1px"},children:[j&&t.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:z=>z.stopPropagation(),children:t.jsx(dr,{})}),p&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${k?"ogx__cell--pinned-left":""} ${A==="__expand_col__"?"ogx__cell--focused":""} ${A==="__expand_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":f?"Collapse row details":"Expand row details","aria-expanded":f,style:{position:k?"sticky":void 0,left:k?j?48:0:void 0,zIndex:k?5:void 0},ref:Q,tabIndex:-1,onClick:z=>{z.stopPropagation(),s?.({row:o,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(io,{isExpanded:f,onClick:H,variant:"plus-minus"})}),a&&t.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${A==="__checkbox_col__"?"ogx__cell--focused":""} ${A==="__checkbox_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(j?48:0)+(p&&k?48:0):void 0,zIndex:P?11:void 0},ref:pe,tabIndex:-1,onClick:z=>{z.stopPropagation(),s?.({row:o,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(qt,{id:`ogx-select-row-${o.id}`,name:`ogx-select-row-${o.id}`,checked:l,onChange:D,onClick:z=>z.stopPropagation(),"aria-label":l?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Ne)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const ye=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],ft=u[z.field]??z.width,ze=dn(z.field,h),et=ze?K[z.field]:void 0,tt=N?.id===o.id&&N?.field===z.field,en=tt?N?.value:ye,Rt=q?.get(o.id)?.[z.field],jt=G?.spannedCells[o.id]?.[z.field],Ot=G?.hiddenCells[o.id]?.[z.field]||!1;return t.jsx(ro,{value:en,row:o,colDef:z,rowIndex:r,colIndex:Ne,isSelected:l,onCellClick:s,width:ft,pinnedPosition:ze,pinnedOffset:et,isFocused:A===z.field,isFocusVisible:U,isEditable:z.editable,isEditing:tt,onCellEditStart:ae,onEditStop:me,onCellValueChange:oe,colSpanInfo:Rt,rowSpan:jt,isHiddenByRowSpan:Ot},z.field)})]}),p&&t.jsx(cr,{row:o,rowId:o.id,rowIndex:r,content:b,height:E,isExpanded:f})]})}const ur=({columns:n,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:l=!1})=>t.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:o},role:"row",children:[e&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((a,d)=>{const s=a.width||150,g=Math.min(s*.7,s-20);return t.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&&t.jsx("div",{className:"ogx-skeleton-box",style:{width:g,height:16,borderRadius:4}})},a.field||d)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:l="",children:a,...d})=>{const s=["ogx-button",`ogx-button--${n}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",l].filter(Boolean).join(" ");return t.jsx("button",{className:s,disabled:r,...d,children:a})};function lo(n){const{page:o,pageSize:e,rowCount:r,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:s=!0,showLastButton:g=!0}=n,u=Math.max(1,Math.ceil(r/e)),h=Math.min(o,u-1),m=h*e,p=Math.min(m+e,r),f=r===0?0:`${m+1}–${p}`,C=()=>{l(0)},b=()=>{l(Math.max(0,h-1))},E=()=>{l(Math.min(u-1,h+1))},P=()=>{l(u-1)},k=w=>{const v=parseInt(w.target.value,10);a(v)},j=h===0,y=h>=u-1;return t.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[t.jsxs("div",{className:"ogx-pagination__page-size",children:[t.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),t.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:k,"aria-label":"Rows per page",children:d.map(w=>t.jsx("option",{value:w,children:w},w))})]}),t.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[f," of ",r]}),t.jsxs("div",{className:"ogx-pagination__actions",children:[s&&t.jsx(Qt,{variant:"text",size:"small",onClick:C,disabled:j,"aria-label":"Go to first page",title:"First page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),t.jsx(Qt,{variant:"text",size:"small",onClick:b,disabled:j,"aria-label":"Go to previous page",title:"Previous page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),t.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",h+1," of ",u]}),t.jsx(Qt,{variant:"text",size:"small",onClick:E,disabled:y,"aria-label":"Go to next page",title:"Next page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),g&&t.jsx(Qt,{variant:"text",size:"small",onClick:P,disabled:y,"aria-label":"Go to last page",title:"Last page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function fr(n,o,e={}){const r=new Map,l=[];n.forEach(s=>{const g=s.id;r.set(g,s),l.push(g)});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:n.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 gr(n,o){switch(o.type){case"SET_ROWS":{const e=Array.from(n.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)}),{...n,rows:{idRowsLookup:l,allRows:a},pagination:{...n.pagination,rowCount:o.preserveRowCount?n.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)}),{...n,columns:{all:o.payload,lookup:e,orderedFields:r,columnVisibilityModel:{}}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:o.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:o.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:o.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:o.payload}};case"SET_SCROLL":return{...n,virtualization:{...n.virtualization,scrollTop:o.payload.scrollTop,scrollLeft:o.payload.scrollLeft}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:o.payload.viewportWidth,viewportHeight:o.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:o.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:o.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:o.payload}};default:return n}}function hr(n){const{rows:o,columns:e,rowHeight:r=52,headerHeight:l=56,columnVisibilityModel:a,initialState:d}=n,s=i.useMemo(()=>fr(o,e,a),[]),[g,u]=i.useReducer(gr,{...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:n.rowCount??d?.pagination?.rowCount??s.pagination.rowCount},dimensions:{...s.dimensions,rowHeight:r,headerHeight:l}}),h=i.useRef(g);h.current=g;const m=i.useRef(o);i.useEffect(()=>{o!==m.current&&(m.current=o,u({type:"SET_ROWS",payload:o}))},[o]);const p=i.useCallback((S,x)=>{u({type:"SET_ROWS",payload:S,preserveRowCount:x})},[]),f=i.useCallback(S=>{u({type:"SET_COLUMNS",payload:S})},[]),C=i.useCallback(S=>{u({type:"SET_SORT_MODEL",payload:S})},[]),b=i.useCallback(S=>{u({type:"SET_FILTER_MODEL",payload:S})},[]),E=i.useCallback(S=>{u({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=i.useCallback(S=>{u({type:"SET_SELECTION",payload:S})},[]),k=i.useCallback((S,x)=>{u({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:x}})},[]),j=i.useCallback((S,x)=>{u({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:x}})},[]),y=i.useCallback(S=>{u({type:"SET_DATASOURCE_LOADING",payload:S})},[]),w=i.useCallback(S=>{u({type:"SET_DATASOURCE_ERROR",payload:S})},[]),v=i.useCallback(S=>{u({type:"SET_ROW_COUNT",payload:S})},[]),M=i.useRef({getRow:S=>h.current.rows.idRowsLookup.get(S)||null,getAllRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:S=>h.current.columns.lookup.get(S)||null,getAllColumns:()=>h.current.columns.all,getVisibleColumns:()=>h.current.columns.all,selectRow:(S,x=!0)=>{const N=new Set(h.current.selection.selectedRows);x?N.add(S):N.delete(S),P(N)},selectRows:(S,x=!0)=>{const N=new Set(h.current.selection.selectedRows);S.forEach(O=>{x?N.add(O):N.delete(O)}),P(N)},getSelectedRows:()=>Array.from(h.current.selection.selectedRows),sortColumn:(S,x)=>{if(x===null)C(h.current.sorting.sortModel.filter(N=>N.field!==S));else{const N=h.current.sorting.sortModel.findIndex(O=>O.field===S);if(N>=0){const O=[...h.current.sorting.sortModel];O[N]={field:S,sort:x},C(O)}else C([...h.current.sorting.sortModel,{field:S,sort:x}])}},getSortModel:()=>h.current.sorting.sortModel,setFilterModel:b,getFilterModel:()=>h.current.filter.filterModel,setPage:S=>{E({...h.current.pagination.paginationModel,page:S})},setPageSize:S=>{E({...h.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:g,dispatch:u,apiRef:M,setRows:p,setColumns:f,setSortModel:C,setFilterModel:b,setPaginationModel:E,setSelection:P,setScroll:k,setDimensions:j,setDataSourceLoading:y,setDataSourceError:w,setRowCount:v}}function pr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[l,a]=i.useState(null),[d,s]=i.useState(null),g=i.useRef(-1),u=i.useCallback(f=>C=>{if(r)return;const b=o.findIndex(P=>P.field===f);if(o[b]?.pinnable===!1){C.preventDefault();return}a(f),g.current=b,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",f))},[o,r]),h=i.useCallback(f=>C=>{r||!l||(C.preventDefault(),C.dataTransfer.dropEffect="move",s(f))},[l,r]),m=i.useCallback(f=>C=>{if(C.preventDefault(),r||!l||l===f){a(null),s(null);return}const b=o.findIndex(k=>k.field===l),E=o.findIndex(k=>k.field===f);if(b===-1||E===-1){a(null),s(null);return}const P=o[b];e&&e({column:P,oldIndex:b,targetIndex:E}),a(null),s(null),g.current=-1},[o,l,r,e]),p=i.useCallback(()=>{a(null),s(null),g.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:r?void 0:u,onDragOver:r?void 0:h,onDragEnd:r?void 0:p,onDrop:r?void 0:m}}function xr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:l=!1}=n,[a,d]=i.useState(null),[s,g]=i.useState(null),u=i.useCallback(C=>r?r(C):C.id,[r]),h=i.useCallback(C=>b=>{l&&(d(C),b.dataTransfer.effectAllowed="move")},[l]),m=i.useCallback(C=>b=>{!l||!a||(b.preventDefault(),b.dataTransfer.dropEffect="move",s!==C&&g(C))},[l,a,s]),p=i.useCallback(()=>{d(null),g(null)},[]),f=i.useCallback(C=>b=>{if(b.preventDefault(),!a||!o){p();return}const E=e.findIndex(k=>u(k)===a),P=e.findIndex(k=>u(k)===C);E!==-1&&P!==-1&&E!==P&&o({row:e[E],oldIndex:E,targetIndex:P}),p()},[a,o,e,u,p]);return{draggedRowId:a,dragOverRowId:s,onDragStart:l?h:void 0,onDragOver:l?m:void 0,onDragEnd:l?p:void 0,onDrop:l?f:void 0}}const mr={contains:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().includes(String(o).toLowerCase()),equals:(n,o)=>n==null&&o==null?!0:n==null||o==null?!1:String(n).toLowerCase()===String(o).toLowerCase(),startsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().startsWith(String(o).toLowerCase()),endsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().endsWith(String(o).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>r},">=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>=r},"<":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<r},"<=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<=r},"!=":(n,o)=>{if(o==null||o==="")return!0;const e=Number(n),r=Number(o);return!isNaN(e)&&!isNaN(r)?e!==r:String(n).toLowerCase()!==String(o).toLowerCase()},isAnyOf:(n,o)=>n==null||!Array.isArray(o)?!1:o.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,o)=>n==null&&o==null?!1:n==null||o==null?!0:String(n).toLowerCase()!==String(o).toLowerCase(),is:(n,o)=>{if(o==null||o==="")return!0;const e=String(n).toLowerCase(),r=String(o).toLowerCase();return e===r},"=":(n,o)=>n==null||o==null||o===""?!1:Number(n)===Number(o)};function br(n,o){const{field:e,operator:r,value:l}=o,a=n[e],d=mr[r];return d?d(a,l):(console.warn(`Unknown filter operator: ${r}`),!0)}function wr(n,o){return!o||o.length===0?!0:o.every(e=>{const r=e.toLowerCase();return Object.values(n).some(l=>l==null?!1:String(l).toLowerCase().includes(r))})}function Nn(n,o){const e=o.items||[],r=o.logicOperator||"and",l=o.quickFilterValues||[];if(l.length>0&&!wr(n,l))return!1;if(e.length===0)return!0;const a=d=>{if("logicOperator"in d&&"items"in d){const s=d,g=s.items;return g.length===0?!0:s.logicOperator==="and"?g.every(a):g.some(a)}else return br(n,d)};return r==="and"?e.every(a):e.some(a)}function vr(n,o){if(!o)return n;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?n:n.filter(l=>Nn(l,o))}function _r(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 In(n,o,e){if(n==null&&o==null)return 0;if(n==null)return e==="asc"?1:-1;if(o==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof o=="number")return e==="asc"?n-o:o-n;if(n instanceof Date&&o instanceof Date)return e==="asc"?n.getTime()-o.getTime():o.getTime()-n.getTime();const r=String(n).toLowerCase(),l=String(o).toLowerCase();return e==="asc"?r<l?-1:r>l?1:0:r>l?-1:r<l?1:0}function Cr(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,l)=>{for(const a of o){const d=r[a.field],s=l[a.field],g=In(d,s,a.sort);if(g!==0)return g}return 0}),e}function yr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:l=!1,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,onRowExpansionChange:g}=n,{treeNodes:u,rootIds:h,groupingRows:m}=i.useMemo(()=>{if(!l||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,w=[],v=[],M=new Map,S=x=>x.join("/");return o.forEach(x=>{const N=e(x),O=r(x),W=S(O);M.set(W,N),y.set(N,{id:N,parentId:null,depth:O.length-1,groupingKey:O[O.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const N=e(x),O=r(x);if(O.length===1){w.push(N);return}const W=A=>{if(A.length<=1)return;const U=A.slice(0,-1),q=S(U);let G=M.get(q);if(G===void 0&&(G=`auto-group-${q}`,!y.has(G))){const ee=U[U.length-1];y.set(G,{id:G,parentId:null,depth:U.length-1,groupingKey:ee,isExpanded:!1,children:[],label:ee}),M.set(q,G);const Q={id:G,name:ee,_isGroupRow:!0};v.push(Q),U.length===1&&w.push(G),W(U)}return G},X=W(O);if(X!==void 0){const A=y.get(X),U=y.get(N);A&&U&&(U.parentId=X,A.children=A.children||[],A.children.includes(N)||A.children.push(N))}}),v.forEach(x=>{const N=x.id,O=y.get(N);if(!O)return;const X=N.replace("auto-group-","").split("/");if(X.length>1){const A=X.slice(0,-1),U=S(A),q=M.get(U);if(q&&y.has(q)){O.parentId=q;const G=y.get(q);G&&(G.children=G.children||[],G.children.includes(N)||G.children.push(N))}}}),{treeNodes:y,rootIds:w,groupingRows:v}},[o,r,l,e]),p=i.useMemo(()=>{if(!l)return new Set;const y=new Set;return u.forEach(w=>{w.children&&w.children.length>0&&(a===-1||w.depth<a)&&y.add(w.id)}),y},[u,l,a]),[f,C]=i.useState(new Set);i.useEffect(()=>{p.size>0&&C(p)},[p]);const b=i.useCallback(y=>{C(w=>{const v=new Set(w),M=!v.has(y);if(v.has(y)?v.delete(y):v.add(y),M&&g){const S=u.get(y);S&&g(S)}return v})},[u,g]),E=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 w=W=>Nn(W,d),v=new Map,M=W=>{if(v.has(W))return v.get(W);const X=y.get(W);if(!X)return!1;if(w(X))return v.set(W,!0),!0;const U=u.get(W);return U&&U.children&&U.children.some(G=>M(G))?(v.set(W,!0),!0):(v.set(W,!1),!1)},S=(W,X)=>{if(!s||s.length===0)return 0;const A=y.get(W),U=y.get(X);if(!A||!U)return 0;for(const q of s){const G=A[q.field],ee=U[q.field],Q=In(G,ee,q.sort);if(Q!==0)return Q}return 0},x=[],N=new Set,O=W=>{const X=W.filter(A=>M(A));X.sort(S),X.forEach(A=>{if(N.has(A))return;const U=y.get(A),q=u.get(A);if(U&&q){N.add(A);const G={...U,_treeDepth:q.depth,_isExpanded:f.has(A),_hasChildren:q.children&&q.children.length>0||q.serverChildrenCount&&q.serverChildrenCount>0,_descendantCount:q.children?q.children.length:0};x.push(G),f.has(A)&&q.children&&q.children.length>0&&O(q.children)}})};return O(h),x},[l,o,m,h,u,f,d,s,e]),P=i.useCallback(y=>f.has(y),[f]),k=i.useCallback(y=>u.get(y),[u]),j=i.useCallback(y=>{const w=[];let v=y;for(;v!==null;){const M=u.get(v);if(!M)break;w.unshift(M.groupingKey),v=M.parentId}return w},[u]);return i.useMemo(()=>({treeNodes:u,groupingRows:m,toggleExpansion:b,isGroupExpanded:P,getVisibleRows:E,getNode:k,getNodePath:j}),[u,m,b,P,E,k,j])}const kr=n=>n?.depth===-1?"footer":"inline";function Sr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:l={},defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,getAggregationPosition:g=kr}=n,[u,h]=i.useState(new Set),{treeNodes:m,rootIds:p,groupingRows:f}=i.useMemo(()=>{const k=new Map,j=new Map,y=[];if(r.length===0)return{treeNodes:k,rootIds:y,groupingRows:j};const w=(S,x,N)=>`auto-group-${S}-${x}-${N||"root"}`,v=(S,x,N)=>{if(x>=r.length)return S.map(A=>{const U=e(A);return k.set(U,{id:U,parentId:N,depth:x,groupingKey:"",isExpanded:!1}),U});const O=r[x],W=new Map;S.forEach(A=>{const U=A[O],q=String(U);W.has(q)||W.set(q,[]),W.get(q).push(A)});const X=[];return W.forEach((A,U)=>{const G=A[0][O],ee=w(O,U,N);X.push(ee);const Q={};l&&Object.entries(l).forEach(([K,R])=>{const Y=A.map($=>$[K]);if(R==="sum")Q[K]=Y.reduce(($,L)=>(Number($)||0)+(Number(L)||0),0);else if(R==="min")Q[K]=Math.min(...Y.map($=>Number($)||0));else if(R==="max")Q[K]=Math.max(...Y.map($=>Number($)||0));else if(R==="avg"){const $=Y.reduce((L,ae)=>(Number(L)||0)+(Number(ae)||0),0);Q[K]=Y.length?$/Y.length:0}else R==="count"&&(Q[K]=Y.length)});const pe={[O]:G,...Q,id:ee};j.set(ee,pe);const _={id:ee,parentId:N,depth:x,groupingKey:U,groupingField:O,groupingValue:G,aggregatedValues:Q,isExpanded:!1,children:[],label:`${O}: ${String(G)}`};_.aggregationPosition=g(_),k.set(ee,_);const D=v(A,x+1,ee);k.get(ee).children=D;const H=A.length;k.get(ee).descendantCount=H}),X},M=v(o,0,null);return y.push(...M),{treeNodes:k,rootIds:y,groupingRows:j}},[o,r,l,e,g]);i.useEffect(()=>{if(a===-1){const k=new Set;m.forEach((j,y)=>{j.children&&j.children.length>0&&k.add(y)}),h(k)}else if(a>0){const k=new Set;m.forEach((j,y)=>{j.depth<a&&j.children&&j.children.length>0&&k.add(y)}),h(k)}else h(new Set)},[r,a]);const C=i.useCallback(k=>{h(j=>{const y=new Set(j);return y.has(k)?y.delete(k):y.add(k),y})},[]),b=i.useCallback(k=>u.has(k),[u]),E=i.useCallback(()=>{if(r.length===0)return null;const k=[],j=new Set,y=new Map;o.forEach(S=>y.set(e(S),S));const w=S=>{const x=m.get(S);if(!x)return!1;if(!x.children||x.children.length===0){const N=y.get(S);return!(!N||d&&!Nn(N,d))}return x.children.some(N=>w(N))},v=S=>{let x=S;d&&(x=S.filter(w)),s&&s.length>0&&x.sort((N,O)=>{const W=f.get(N)||y.get(N),X=f.get(O)||y.get(O);if(!W||!X)return 0;for(const A of s){const U=W[A.field],q=X[A.field],G=In(U,q,A.sort);if(G!==0)return G}return 0}),x.forEach(N=>{if(j.has(N))return;const O=m.get(N),W=O?.children&&O.children.length>0,X=W?f.get(N):y.get(N);if(X&&O){j.add(N);const A={...X,_treeDepth:O.depth,_isExpanded:u.has(N),_hasChildren:W,_groupingField:O.groupingField,_groupingValue:O.groupingValue,_descendantCount:O.descendantCount};k.push(A),M.has(N)&&W&&v(O.children)}})},M=u;return v(p),k},[o,e,m,p,f,d,s,u]),P=i.useCallback(k=>m.get(k),[m]);return i.useMemo(()=>({treeNodes:m,groupingRows:f,toggleExpansion:C,isGroupExpanded:b,getVisibleRows:E,getNode:P}),[m,f,C,b,E,P])}function jr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:l,onRowChange:a}=n,[d,s]=i.useState(null),g=i.useRef(null),u=i.useCallback(f=>{s(f),g.current=typeof f=="function"?f(g.current):f},[]),h=i.useCallback(f=>{u({id:f.id,field:f.field,value:f.value,originalValue:f.value})},[]),m=i.useCallback(async f=>{const C=g.current;if(!C)return;if(f?.cancel){u(null);return}const{id:b,field:E,value:P,originalValue:k}=C;if(P===k){u(null);return}const j=o.find(w=>e(w)===b);if(!j){u(null);return}const y={...j,[E]:P};try{if(r){const w=await r(y,j);a?.(w)}else a?.(y);u(null)}catch(w){l&&l(w)}},[d,o,e,r,a,l]),p=i.useCallback(f=>{d&&d.id===f.id&&d.field===f.field&&u(C=>C?{...C,value:f.value}:null)},[d]);return{editingCell:d,startCellEdit:h,stopCellEdit:m,setEditCellValue:p}}function Er(n,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)},[]),g=i.useCallback((b,E)=>r.get(b)?.[E],[r]),u=i.useCallback((b,E,P,k,j)=>{const y=new Map(r);for(let w=k;w<j;w++){const v=o[w];if(!v)continue;let M=1;if(v.colSpan)if(typeof v.colSpan=="function"){const x={row:E,value:E[v.field],field:v.field,colDef:v,rowIndex:P,colIndex:w};M=v.colSpan(x)}else M=v.colSpan;if(M<=1){Tt(y,b,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[v.field]||100}});continue}let S=e[v.field]||100;for(let x=1;x<M;x++)if(w+x<j){const N=o[w+x];N&&(S+=e[N.field]||100,Tt(y,b,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+M-1,o.length-1)}))}Tt(y,b,v.field,{spannedByColSpan:!1,cellProps:{colSpan:M,width:S}}),w+=M-1}l(y)},[r,o,e]),h=i.useCallback((b,E)=>{const P={},k={},j={};o.forEach((y,w)=>{if(y.rowSpan)for(let v=b;v<E;v++){const M=n[v];if(!M||k[M.id]?.[y.field])continue;const S=y.valueGetter?y.valueGetter({row:M,field:y.field,value:M[y.field]}):M[y.field];let x=1;if(typeof y.rowSpan=="function"){const N={row:M,value:S,field:y.field,colDef:y,rowIndex:v,colIndex:w};x=y.rowSpan(N)}else typeof y.rowSpan=="number"&&(x=y.rowSpan);if(x>1){P[M.id]||(P[M.id]={}),P[M.id][y.field]=x;for(let N=1;N<x;N++){const O=v+N;if(O<E&&n[O]){const W=n[O];k[W.id]||(k[W.id]={}),k[W.id][y.field]=!0,j[O]||(j[O]={}),j[O][y.field]=v}}}}}),d({caches:{spannedCells:P,hiddenCells:k,hiddenCellOriginMap:j},processedRange:{firstRowIndex:b,lastRowIndex:E}})},[n,o]),m=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const b=new Map;n.forEach((j,y)=>{for(let w=0;w<o.length;w++){const v=o[w];if(!v)continue;let M=1;if(v.colSpan)if(typeof v.colSpan=="function"){const x={row:j,value:j[v.field],field:v.field,colDef:v,rowIndex:y,colIndex:w};M=v.colSpan(x)}else M=v.colSpan;if(M<=1){const x=e[v.field]||(typeof v.width=="number"?v.width:100);Tt(b,j.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let S=e[v.field]||(typeof v.width=="number"?v.width:100);for(let x=1;x<M;x++)if(w+x<o.length){const N=o[w+x];if(N){const O=e[N.field]||(typeof N.width=="number"?N.width:100);S+=O,Tt(b,j.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+M-1,o.length-1)})}}Tt(b,j.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:M,width:S}}),w+=M-1}}),l(b);const E={},P={},k={};o.forEach((j,y)=>{if(j.rowSpan)for(let w=0;w<n.length;w++){const v=n[w];if(!v||P[v.id]?.[j.field])continue;const M=j.valueGetter?j.valueGetter({row:v,field:j.field,value:v[j.field]}):v[j.field];let S=1;if(typeof j.rowSpan=="function"){const x={row:v,value:M,field:j.field,colDef:j,rowIndex:w,colIndex:y};S=j.rowSpan(x)}else typeof j.rowSpan=="number"&&(S=j.rowSpan);if(S>1){E[v.id]||(E[v.id]={}),E[v.id][j.field]=S;for(let x=1;x<S;x++){const N=w+x;if(N<n.length&&n[N]){const O=n[N];P[O.id]||(P[O.id]={}),P[O.id][j.field]=!0,k[N]||(k[N]={}),k[N][j.field]=w}}}}}),d({caches:{spannedCells:E,hiddenCells:P,hiddenCellOriginMap:k},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,o,e]);const p=i.useCallback(()=>a.caches.spannedCells,[a]),f=i.useCallback(()=>a.caches.hiddenCells,[a]),C=i.useCallback(()=>a.caches.hiddenCellOriginMap,[a]);return{colspanMap:r,resetColSpan:s,getCellColSpanInfo:g,calculateColSpan:u,rowSpanningState:a,calculateRowSpan:h,resetRowSpan:m,getSpannedCells:p,getHiddenCells:f,getHiddenCellOriginMap:C}}function Tt(n,o,e,r){let l=n.get(o);l||(l={},n.set(o,l)),l[e]=r}function Nr(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:l,paginationMode:a,sortingMode:d,filterMode:s,aggregationModel:g,setRows:u,setRowCount:h,setDataSourceLoading:m,setDataSourceError:p,onAggregationResults:f}=n,C=i.useRef(null),b=i.useRef(0),E=i.useCallback(async()=>{if(!o)return;const k=++b.current;m(!0),p(null);const j=l.page*l.pageSize,y=j+l.pageSize,w={startRow:j,endRow:y,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:g};try{const v=await o.getRows(w);if(k!==b.current)return;let M=!1;if(a==="infinite"){const S=C.current;if(S){const x=JSON.stringify(S.sortModel)!==JSON.stringify(e),N=JSON.stringify(S.filterModel)!==JSON.stringify(r),O=S.pageSize!==l.pageSize;!x&&!N&&!O&&l.page>S.page&&(M=!0)}}u(M?S=>[...S,...v.rows]:v.rows,!0),v.aggregationResults&&f&&f(v.aggregationResults),v.rowCount!==void 0&&h(v.rowCount),C.current={sortModel:e,filterModel:r,page:l.page,pageSize:l.pageSize}}catch(v){k===b.current&&(p(v),console.error("Data Source Error:",v))}finally{k===b.current&&m(!1)}},[o,l.page,l.pageSize,e,r,a,g,f,u,h,m,p]);i.useEffect(()=>{if(o&&(a==="server"||a==="infinite"||d==="server"||s==="server")){const j=setTimeout(()=>{E()},300);return()=>clearTimeout(j)}},[E,o,a,d,s]);const P=i.useCallback(async(k,j)=>{if(o){m(!0);try{const y=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:j});y.rows.length>0&&u(w=>{const v=new Set(w.map(S=>S.id)),M=y.rows.filter(S=>!v.has(S.id));return[...w,...M]})}catch(y){p(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[o,e,r,u,m,p]);return{fetchRows:E,fetchChildren:P}}const Ir={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,r)=>e+Number(r),0),avg:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e)));return o.length===0?null:o.reduce((e,r)=>e+Number(r),0)/o.length},count:n=>n.filter(o=>o!=null).length,min:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.min(...o):null},max:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.max(...o):null},unique:n=>new Set(n.filter(o=>o!=null)).size};function bt(n,o){return n==null?"—":typeof n=="number"?o==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function so(n){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:s}=n,g=i.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const k={};for(const[j,y]of Object.entries(e)){const w=Ir[y];if(!w){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const v=o.map(M=>M[j]);k[j]=w(v)}return k},[o,e,r]),[u,h]=i.useState({}),[m,p]=i.useState(!1),[f,C]=i.useState(null),b=i.useRef(0),E=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const k=++b.current;p(!0),C(null);try{const j=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:e});k===b.current&&h(j)}catch(j){k===b.current&&(C(j),console.error("[useAggregation] Server aggregation error:",j))}finally{k===b.current&&p(!1)}},[l,e,a,d]);return i.useEffect(()=>{r&&l?.getAggregations&&!s&&E()},[E,r,l,s]),{aggregationResult:i.useMemo(()=>r?s&&Object.keys(s).length>0?s:u:g,[r,g,s,u]),isLoading:m,error:f}}function Mr(n,o){const e=n.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 Mn(n,o){return o.map(e=>String(n[e]??"")).join("\0")}function ao(n,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 g=new Map(o.map(E=>[E.field,E])),u=new Set;for(const E of n)u.add(Mn(E,d));const h=Array.from(u).sort(),m=new Map;for(const E of n){const P=Mn(E,a);if(!m.has(P)){const w={};for(const v of a)w[v]=E[v];m.set(P,{labelValues:w,bucket:new Map})}const k=m.get(P),j=Mn(E,d);k.bucket.has(j)||k.bucket.set(j,new Map);const y=k.bucket.get(j);for(const w of s){const v=Number(E[w.field]);y.has(w.field)||y.set(w.field,[]),isNaN(v)||y.get(w.field).push(v)}}let p=0;const f=[];for(const[,E]of m){const P={id:p++,...E.labelValues};for(const k of h){const j=E.bucket.get(k);for(const y of s){const w=d.length>0?`${k}${y.field}${y.aggFn}`:`${y.field}${y.aggFn}`,v=j?.get(y.field)??[];P[w]=v.length>0?Mr(v,y.aggFn):null}}f.push(P)}const C={id:"__pivot_grand_total__"};for(let E=0;E<a.length;E++)C[a[E]]=E===0?"Grand Total":"";for(const E of h)for(const P of s){const k=d.length>0?`${E}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,j=f.reduce((y,w)=>{const v=w[k];return y+(v!=null&&!isNaN(Number(v))?Number(v):0)},0);C[k]=j}f.push(C);const b=[];for(const E of a){const P=g.get(E);b.push({field:E,headerName:P?.headerName??E,width:P?.width??140,sortable:!0})}for(const E of h){const P=d.length>0?E.split("\0").map((k,j)=>{const y=g.get(d[j]);return y?.headerName?`${y.headerName}: ${k}`:k}).join(" / "):"";for(const k of s){const j=g.get(k.field),y=d.length>0?`${E}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,w=k.headerName??j?.headerName??k.field,v=P?`${P} — ${w} (${k.aggFn})`:`${w} (${k.aggFn})`;b.push({field:y,headerName:v,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const S=Number(M);return k.aggFn==="avg"?S.toFixed(2):k.aggFn==="count"?S.toLocaleString():j?.valueFormatter?j.valueFormatter({value:M,row:{},field:k.field}):S.toLocaleString()}})}}return{pivotRows:f,pivotColumns:b,colKeys:h,isValid:!0}},[n,o,e,r])}function Pr(n){const o=document.createElement("textarea");o.value=n,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 Tr(n){let o=!1;try{o=Pr(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(o)return;throw e}else if(!o)throw new Error("Clipboard API not available and fallback failed.")}function Lr(n){const{selectedRowIds:o,columns:e,getVisibleRows:r,getRowId:l}=n,a=i.useCallback(async()=>{if(o.size===0)return;const s=r().filter(p=>o.has(l(p)));if(s.length===0)return;const g=e.filter(p=>!p.field.startsWith("__")),u=g.map(p=>p.headerName||p.field).join(" "),h=s.map(p=>g.map(f=>{const C=p[f.field];return f.valueFormatter?f.valueFormatter({value:C,row:p,field:f.field}):C??""}).join(" ")).join(`
|
|
7
|
+
`),m=`${u}
|
|
8
|
+
${h}`;try{await Tr(m)}catch(p){console.error("[OpenGridX] Failed to copy to clipboard:",p)}},[o,e,r,l]);return i.useEffect(()=>{const d=s=>{if(!(s.ctrlKey||s.metaKey)||s.key!=="c")return;const g=document.activeElement,u=g?.tagName.toLowerCase(),h=g?.type;u==="input"&&h!=="checkbox"&&h!=="radio"||u==="textarea"||u==="select"||g?.isContentEditable||a()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a]),{copySelectedRows:a}}function Rr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Or(){return t.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function co(n){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d}=n,[s,g]=i.useState(""),[u,h]=i.useState(null),m=i.useRef(null),f=i.useMemo(()=>o.filter(w=>w.hideable!==!1),[o]).every(w=>e.has(w.field)),C=i.useMemo(()=>{if(!s)return o;const w=s.toLowerCase();return o.filter(v=>(v.headerName||v.field).toLowerCase().includes(w))},[o,s]),b=w=>{w.target.checked?l():a()},E=w=>v=>{m.current=w,v.dataTransfer.effectAllowed="move",v.dataTransfer.setDragImage(v.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=w=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",w!==m.current&&h(w)},k=()=>{h(null)},j=w=>v=>{v.preventDefault();const M=m.current;h(null),m.current=null,M&&M!==w&&d&&d(M,w)},y=()=>{h(null),m.current=null};return t.jsxs("div",{className:"ogx-column-visibility-panel",children:[t.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:t.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[t.jsx(Rr,{}),t.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:s,onChange:w=>g(w.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map(w=>{const v=e.has(w.field),M=w.hideable!==!1,S=u===w.field,x=!!d&&!s;return t.jsxs("div",{className:["ogx-column-visibility-panel__item",!M&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:x,onDragOver:x?P(w.field):void 0,onDragLeave:x?k:void 0,onDrop:x?j(w.field):void 0,onDragEnd:x?y:void 0,children:[x&&t.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:E(w.field),title:"Drag to reorder",children:t.jsx(Or,{})}),t.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:M?"pointer":"not-allowed"},children:[t.jsx(qt,{checked:v,onChange:N=>r(w.field,N.target.checked),disabled:!M}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:w.headerName||w.field})]})]},w.field)})}),t.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[t.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[t.jsx(qt,{checked:f,onChange:b}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),t.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:l,children:"Reset"})]})]})}function Fr(n){const{rows:o,columns:e,getRowId:r,rowHeight:l=52,headerHeight:a=56,autoHeight:d=!1,checkboxSelection:s=!1,rowSelectionModel:g,onRowSelectionModelChange:u,onRowClick:h,onCellClick:m,filterModel:p,onFilterModelChange:f,sortModel:C,onSortModelChange:b,pagination:E=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:k,pageSizeOptions:j=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:w,pinnedRows:v,getDetailPanelContent:M,getDetailPanelHeight:S,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:O=!0,pinExpandColumn:W=!0,disableColumnReorder:X=!1,columnOrder:A,onColumnOrderChange:U,height:q,rowReordering:G=!1,onRowOrderChange:ee,loading:Q=!1,treeData:pe=!1,getTreeDataPath:_,defaultGroupingExpansionDepth:D,rowGroupingModel:H,aggregationModel:K,onAggregationModelChange:R,getAggregationPosition:Y,isCellEditable:$,processRowUpdate:L,onProcessRowUpdateError:ae,dataSource:oe,sortingMode:me="client",filterMode:Ze="client",paginationMode:z="client",rowCount:Ne,slots:ye,slotProps:ft,pivotMode:ze=!1,pivotModel:et,onPivotModelChange:tt,className:en="",style:Rt,onRowsScrollEnd:jt,ariaLabel:Ot,initialState:vt,onStateChange:Be,columnVisibilityModel:mo,onColumnVisibilityModelChange:bo,listView:cn=!1,listViewColumn:wo,columnGroupingModel:Et,noRowsLabel:Tn="No Data",apiRef:Ln}=n,Ci=i.useMemo(()=>({items:[]}),[]),Ve=p||Ci,[yi,ki]=i.useState(()=>vt?.sorting?.sortModel??[]),Rn=C!==void 0,nt=Rn?C:yi,Si=i.useMemo(()=>[],[]),On=H||Si,Fn=K!==void 0,vo=i.useRef(ye?.toolbar);vo.current=ye?.toolbar;const ji=i.useRef(c=>{const I=vo.current;return I?I(c):null}).current,[Ei,Ni]=i.useState(()=>K??{}),ot=Fn?K:Ei,Ii=i.useCallback(c=>{Fn||Ni(c),R?.(c)},[Fn,R]),[Mi,Pi]=i.useState(()=>vt?.columns?.columnVisibilityModel??{}),Wn=mo!==void 0,Xe=Wn?mo:Mi,tn=i.useCallback(c=>{Wn||Pi(c),bo?.(c)},[Wn,bo]),[Ti,Li]=i.useState(()=>vt?.columns?.pinnedColumns??{}),An=y!==void 0,rt=An?y:Ti,zn=i.useCallback(c=>{An||Li(c),w?.(c)},[An,w]),Ri=i.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Oi,Fi]=i.useState(et??Ri),_o=et??Oi,Wi=i.useCallback(c=>{Fi(c),tt?.(c)},[tt]),un=ao(o,e,_o,ze),Bn=ze&&un.isValid?un.pivotRows:o,it=ze&&un.isValid?un.pivotColumns:e,[Ai,Co]=i.useState(null);i.useEffect(()=>{Co(null)},[ot]);const[zi,Bi]=i.useState(()=>vt?.pagination?.paginationModel??P),$n=n.paginationModel!==void 0,ge=$n?P:zi,fn=i.useCallback(c=>{$n||Bi(c),k?.(c)},[$n,k]),[$i,yo]=i.useState([]),nn=g!==void 0,ko=nn?g:$i,Ie=i.useMemo(()=>new Set(ko),[ko]),gn=u,Nt=i.useRef(null),Di=i.useRef(null),hn=i.useRef(null),Hi=i.useCallback(c=>c.id,[]),pn=r||Hi,[qe,Ft]=i.useState(null),Wt=i.useCallback(c=>{yn.current?.classList.toggle("ogx--kb",c)},[]),So=i.useRef(oe);So.current=oe;const jo=i.useRef(null),Eo=i.useRef(null),Gi=i.useCallback(c=>{if(So.current&&pe&&c.serverChildrenCount>0&&c.children.length===0){const I=Eo.current?.getNodePath(c.id)||[c.groupingKey];jo.current?.(c.id,I)}},[pe]),lt=hr({rows:Bn,columns:it,rowHeight:l,headerHeight:a,rowCount:Ne,columnVisibilityModel:Xe,initialState:n.initialState}),{state:de,apiRef:At,setRows:Dn,setColumns:No,setScroll:Io,setDimensions:Mo,setDataSourceLoading:Vi,setDataSourceError:Ui,setRowCount:Ki}=lt;i.useEffect(()=>{Ln&&(Ln.current=At.current)},[Ln,At]);const{copySelectedRows:Po}=Lr({selectedRowIds:Ie,columns:it,getVisibleRows:()=>At.current.getVisibleRows(),getRowId:pn});i.useEffect(()=>{At.current.copySelectedRows=Po,At.current.getSelectedRows=()=>Array.from(Ie)},[Po,Ie,At]);const Yi=de.dataSource.loading,on=Q||Yi,rn=i.useMemo(()=>de.rows.allRows.map(c=>de.rows.idRowsLookup.get(c)),[de.rows]),Hn=yr({rows:rn,getRowId:pn,getTreeDataPath:_,treeData:pe,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,onRowExpansionChange:Gi});i.useEffect(()=>{Eo.current=Hn},[Hn]);const Xi=Sr({rows:rn,getRowId:pn,rowGroupingModel:On,aggregationModel:ot,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,getAggregationPosition:Y}),$e=jr({rows:rn,getRowId:pn,processRowUpdate:L,onProcessRowUpdateError:ae,onRowChange:c=>{const{dispatch:I}=lt,B=Array.from(lt.state.rows.idRowsLookup.values()).map(Z=>Z.id===c.id?c:Z);I({type:"SET_ROWS",payload:B})}}),Gn=pe,zt=!!(On&&On.length>0),xn=Gn||zt,De=Gn?Hn:zt?Xi:null,Me=E&&!zt,mn=i.useCallback(c=>{const{row:I,id:T}=c;if(xn&&I._hasChildren){De?.toggleExpansion(T);return}h?.(c)},[xn,De,h]),ke=i.useMemo(()=>xn?it.map((c,I)=>I===0?{...c,renderCell:T=>{const{_treeDepth:B,_hasChildren:Z,_isExpanded:re,_groupingField:ue,_groupingValue:Oe,_descendantCount:Fe}=T.row,xe=(B||0)*24;let se=c.renderCell?c.renderCell(T):T.value;return Gn&&Z&&T.row._isGroupRow&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[T.value,Fe!==void 0&&Fe>0?` (${Fe})`:""]})),zt&&Z&&ue&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[c.field===ue?"":`${ue}: `,String(Oe),Fe!==void 0?` (${Fe})`:""]})),t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:xe,width:"100%",height:"100%"},children:[t.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:Z?"pointer":"default",flexShrink:0},children:Z?t.jsx("div",{onClick:V=>{V.stopPropagation(),V.preventDefault(),De?.toggleExpansion(T.row.id)},onMouseDown:V=>{V.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:t.jsx(io,{isExpanded:re,onClick:V=>{V.stopPropagation(),V.preventDefault(),De?.toggleExpansion(T.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se})]})}}:{...c,renderCell:T=>{const{_hasChildren:B,_groupingField:Z}=T.row;return zt&&B?c.field===Z?null:T.value!==void 0&&T.value!==null?c.renderCell?c.renderCell(T):T.value:null:c.renderCell?c.renderCell(T):T.value}}):it,[it,xn,zt,De]),Vn=Nr({dataSource:oe,sortModel:nt,filterModel:Ve,paginationModel:ge,paginationMode:z,sortingMode:me,filterMode:Ze,aggregationModel:ot,setRows:Dn,setRowCount:Ki,setDataSourceLoading:Vi,setDataSourceError:Ui,onAggregationResults:Co});i.useEffect(()=>{Vn.fetchChildren&&(jo.current=Vn.fetchChildren)},[Vn.fetchChildren]);const[Ue,qi]=i.useState(()=>vt?.columns?.columnWidths??{}),[Ji,bn]=i.useState(()=>vt?.columns?.columnOrder??it.map(c=>c.field)),_t=A||Ji;i.useEffect(()=>{oe||Dn(Bn)},[Bn,Dn,oe]),i.useEffect(()=>{No(it)},[it,No]),i.useEffect(()=>{ze&&bn(it.map(c=>c.field))},[ze,it]);const Bt=i.useMemo(()=>{if(X)return ke;const c=new Map(_t.map((I,T)=>[I,T]));return[...ke].sort((I,T)=>{const B=c.get(I.field)??ke.indexOf(I),Z=c.get(T.field)??ke.indexOf(T);return B-Z})},[ke,_t,X]),To=i.useMemo(()=>Bt.filter(c=>Xe[c.field]!==!1),[Bt,Xe]),$t=pr({columns:Bt,onColumnOrderChange:i.useCallback(c=>{const{oldIndex:I,targetIndex:T}=c,B=[..._t],[Z]=B.splice(I,1);B.splice(T,0,Z),A||bn(B),U?.(c)},[_t,A,U]),disableColumnReorder:X}),[Qi,Zi]=i.useState(new Set),Ct=x??Qi,Je=!!M,ln=i.useCallback(c=>{const I=new Set(Ct);I.has(c)?I.delete(c):I.add(c),x===void 0&&Zi(I),N?.(I)},[Ct,x,N]),we=i.useMemo(()=>{const c=[];return G&&c.push({field:"__reorder_col__"}),Je&&c.push({field:"__expand_col__"}),s&&c.push({field:"__checkbox_col__"}),[...c,...Bt]},[Bt,s,Je,G]),el=i.useCallback((c,I)=>{qi(T=>({...T,[c]:I}))},[]),Un=i.useRef(Be);Un.current=Be,i.useEffect(()=>{if(!Un.current)return;const c={sorting:{sortModel:nt},filter:{filterModel:Ve},pagination:{paginationModel:ge},columns:{columnWidths:Ue,columnOrder:_t,columnVisibilityModel:Xe,pinnedColumns:rt}};Un.current(c)},[nt,Ve,ge,Ue,_t,Xe,rt]);const wn=i.useMemo(()=>rn,[rn]),He=i.useMemo(()=>De?De.getVisibleRows()||[]:Ze==="server"&&oe?wn:vr(wn,Ve),[wn,Ve,De,Ze,oe]),{top:Ke,center:Dt,bottom:st}=i.useMemo(()=>De?{top:[],center:He,bottom:[]}:Do(He,v),[He,v,De]),Pe=i.useMemo(()=>De||me==="server"&&oe?Dt:Cr(Dt,nt),[Dt,nt,De,me,oe]),gt=i.useMemo(()=>{if(!Me||z==="server"&&oe)return Pe;const c=ge.page*ge.pageSize,I=c+ge.pageSize;return Pe.slice(c,I)},[Pe,Me,ge.page,ge.pageSize,z,oe]);i.useEffect(()=>{lt.apiRef.current.getVisibleRows=()=>Pe,lt.apiRef.current.getVisibleColumns=()=>ke},[Pe,ke,lt.apiRef]);const Ht=xr({rows:Me?gt:Pe,getRowId:c=>c.id,onRowOrderChange:ee,rowReordering:G}),Se=i.useMemo(()=>{if(De)return Dt;const c=Me?gt:Pe,I=[...Ke,...c,...st];if(z==="infinite"&&de.dataSource.loading&&I.length>0){const T=Math.min(ge.pageSize,20),B=Array.from({length:T},(Z,re)=>({id:`__skeleton_${re}__`,_isSkeleton:!0}));return[...I,...B]}return I},[Ke,gt,Pe,st,Me,De,Dt,z,de.dataSource.loading,ge.pageSize]),Gt=Er(Se,we,Ue),{aggregationResult:Kn}=so({rows:He,aggregationModel:ot,isServerSide:!!(oe&&(z==="server"||me==="server")),dataSource:oe,filterModel:Ve,sortModel:nt,serverAggregationResults:Ai}),vn=Object.keys(ot).length>0;i.useEffect(()=>{lt.apiRef.current.getAggregationResult=()=>vn?Kn:null,lt.apiRef.current.getAggregationModel=()=>vn?ot:null},[Kn,ot,vn,lt.apiRef]);const Yn=i.useMemo(()=>{const c=l,I=Me?gt:Pe,T=I.map((F,J)=>{let te=c;if(Ct.has(F.id)){const Ee=S?.({row:F,id:F.id,rowIndex:Ke.length+J})??200;te+=typeof Ee=="number"?Ee:parseInt(String(Ee),10)||200}return te}),B=T.reduce((F,J,te)=>(F.push((F[te-1]||0)+J),F),[]),re=(z==="infinite"&&de.dataSource.loading&&I.length>0?Math.min(ge.pageSize,20):0)*c,ue=(B[B.length-1]||0)+re,Oe=Ke.length*c,Fe=st.length*c,le=[],xe=[],se=[],V=[];To.forEach(F=>{const J=dn(F.field,rt);J==="left"?le.push(F):J==="right"?xe.push(F):se.push(F)});const he=de.dimensions.viewportWidth||1e3,Ce=(s?48:0)+(Je?48:0)+(G?48:0),be=F=>Ue[F.field]??F.width,Te=F=>{if(F===void 0)return{type:"auto",value:0};if(typeof F=="number")return{type:"fixed",value:F};if(typeof F=="string"){if(F.toLowerCase()==="auto")return{type:"auto",value:0};if(F.endsWith("%"))return{type:"percentage",value:parseFloat(F)};const J=parseFloat(F);if(!isNaN(J))return{type:"fixed",value:J}}return{type:"fixed",value:100}},Le=le.reduce((F,J)=>{const te=Te(be(J));return F+(te.type==="fixed"?te.value:100)},0),fe=xe.reduce((F,J)=>{const te=Te(be(J));return F+(te.type==="fixed"?te.value:100)},0),ce=se.reduce((F,J)=>{if(!Object.prototype.hasOwnProperty.call(Ue,J.field)&&J.flex&&J.flex>0){const mt=J.minWidth??150,qn=typeof J.width=="number"?J.width:150;return F+(mt||qn)}const Ee=Te(be(J));return Ee.type==="fixed"?F+Ee.value:Ee.type==="percentage"?F+100:F+(J.minWidth??150)},0),ht=Math.max(he-Ce-Le-fe,ce),at=[],We=[],je=[];let Ae=0;se.forEach(F=>{const J=Object.prototype.hasOwnProperty.call(Ue,F.field),te=Te(be(F));if(!J&&F.flex&&F.flex>0){je.push({col:F,flex:F.flex}),Ae+=F.flex;return}te.type==="fixed"?at.push({col:F,width:te.value}):te.type==="percentage"?We.push({col:F,percentage:te.value}):(je.push({col:F,flex:1}),Ae+=1)});const Ge=at.reduce((F,{width:J})=>F+J,0);let Re=Math.max(0,ht-Ge);const dt=new Map;We.forEach(({col:F,percentage:J})=>{const te=J/100*Re;dt.set(F.field,te),Re-=te}),Re=Math.max(0,Re);const yt=new Map,pt=je.map(F=>({...F,minWidth:F.col.minWidth??50,maxWidth:F.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let F=0;const J=pt.length*2;for(;F<J;){F++;const te=pt.filter(ne=>!ne.frozen);if(te.length===0)break;const Ee=te.reduce((ne,ct)=>ne+ct.flex,0),mt=pt.reduce((ne,ct)=>ct.frozen?ne+ct.computedWidth:ne,0),qn=Math.max(0,Re-mt);if(Ee<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const cl=qn/Ee;let kn=0;const Sn=[],jn=[];if(te.forEach(ne=>{const ct=cl*ne.flex;if(ct<ne.minWidth){const Jn=ne.minWidth-ct;kn+=Jn,Sn.push(ne)}else if(ct>ne.maxWidth){const Jn=ne.maxWidth-ct;kn+=Jn,jn.push(ne)}else ne.computedWidth=ct}),Sn.length===0&&jn.length===0){te.forEach(ne=>ne.frozen=!0);break}kn>0?Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):kn<0?jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),pt.forEach(F=>yt.set(F.col.field,F.computedWidth));const Ut=new Map;se.forEach(F=>{let J;if(yt.has(F.field))J=yt.get(F.field);else{const te=at.find(mt=>mt.col.field===F.field),Ee=We.find(mt=>mt.col.field===F.field);if(te)J=te.width;else if(Ee){const mt=dt.get(F.field)||0;J=Math.max(F.minWidth??50,mt||100)}else J=100}V.push(J),Ut.set(F.field,J)});const xt=se.map(F=>{const J=pt.find(te=>te.col.field===F.field);return{...F,width:Ut.get(F.field)??(typeof F.width=="number"?F.width:100),flex:J?J.flex:F.flex}}),Ye=11,It=le.map((F,J)=>{const te=Te(be(F)),Ee=te.type==="fixed"?te.value:100;return{...F,width:Ee,zIndex:Ye+J}}),Kt=11,kt=xe.map((F,J)=>{const te=Te(be(F)),Ee=te.type==="fixed"?te.value:100;return{...F,width:Ee,zIndex:Kt+(xe.length-1-J)}}),Qe=V.reduce((F,J)=>F+J,0),ve=Le+Qe+fe+Ce,dl=V.reduce((F,J,te)=>(F.push((F[te-1]||0)+J),F),[]);return{rowHeights:T,cumulativeHeights:B,unpinnedRowsHeight:ue,pinnedTopHeight:Oe,pinnedBottomHeight:Fe,leftPinnedCols:It,rightPinnedCols:kt,unpinnedColsWithWidth:xt,unpinnedColWidths:V,unpinnedAccWidths:dl,totalWidth:ve,leftWidth:Le,rightWidth:fe,unpinnedTotalWidth:Qe,systemColumnsWidth:Ce,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,unpinnedRowsLength:I.length}},[l,Me,gt,Pe,Ct,S,Ke.length,st.length,Ct,S,Ke.length,st.length,To,rt,Ue,de.dimensions.viewportWidth,s,Je,G,O,W,d,z,de.dataSource.loading,ge.pageSize]),_e=i.useMemo(()=>{const{unpinnedAccWidths:c,unpinnedColsWithWidth:I,leftPinnedCols:T,rightPinnedCols:B,totalWidth:Z,leftWidth:re,rightWidth:ue,unpinnedTotalWidth:Oe,systemColumnsWidth:Fe,cumulativeHeights:le,pinnedTopHeight:xe,pinnedBottomHeight:se,unpinnedRowsHeight:V,rowHeights:he,unpinnedRowsLength:Ce}=Yn,be=de.virtualization.scrollLeft,Te=de.virtualization.scrollTop,Le=de.dimensions.viewportWidth||1e3,fe=d?xe+V+se+50:de.dimensions.viewportHeight||600,ce=6,ht=Math.max(0,be-re),at=be+Le-re;let We=0,je=I.length-1,Ae=0,Ge=c.length-1;for(;Ae<=Ge;){const ve=Ae+Ge>>>1;c[ve]<ht?Ae=ve+1:Ge=ve-1}We=Math.max(0,Ae-ce);for(let ve=We;ve<c.length;ve++){if((ve===0?0:c[ve-1])>at){je=Math.min(I.length-1,ve+ce);break}je=Math.min(I.length-1,ve+ce)}const Re=We>0?c[We-1]:0,dt=Oe-c[je],yt=[...T,...Re>0?[{field:"__spacer_left__",width:Re,isSpacer:!0}]:[],...I.slice(We,je+1),...dt>0?[{field:"__spacer_right__",width:dt,isSpacer:!0}]:[],...B],sn=Le>0&&Z>Le?16:0,Ut=xe+V+se+sn+2,xt=5;let Ye=0,It=Ce-1,Kt=0,kt=0,Qe=le.length-1;for(;kt<=Qe;){const ve=kt+Qe>>>1;le[ve]<Te?kt=ve+1:Qe=ve-1}Ye=Math.max(0,kt-xt),Kt=Ye>0?le[Ye-1]:0;for(let ve=Ye;ve<le.length;ve++)if(le[ve]>=Te+fe){It=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ye,lastRowIndex:It,firstColumnIndex:We,lastColumnIndex:je},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:xe,pinnedBottomHeight:se,totalWidth:Z,rowHeights:he,cumulativeHeights:le,virtualColumns:yt,columnMetrics:{leftPinnedWidth:re,rightPinnedWidth:ue,unpinnedAccWidths:c,unpinnedCols:I,totalSpecialsWidth:Fe,pinnedSpecialsWidth:(G?48:0)+(Je&&W?48:0)+(s&&O?48:0)}}},[Yn,de.virtualization.scrollTop,de.virtualization.scrollLeft,de.dimensions.viewportHeight,de.dimensions.viewportWidth,d]),tl=i.useCallback(c=>{const I=c.currentTarget;if(Io(I.scrollTop,I.scrollLeft),jt){const{scrollTop:T,scrollHeight:B,clientHeight:Z}=I;B-T-Z<100&&jt({visibleTop:T,visibleBottom:T+Z,viewportHeight:Z})}},[Io,jt]);i.useEffect(()=>{if(!Nt.current)return;const c=new ResizeObserver(I=>{for(const T of I){const{width:B,height:Z}=T.contentRect;Mo(B,Z)}});return c.observe(Nt.current),()=>{c.disconnect()}},[Mo]);const Vt=i.useCallback((c,I)=>{const T=new Set(Ie);I?T.add(c):T.delete(c);const B=Array.from(T);nn||yo(B),gn?.(B)},[Ie,nn,gn]),nl=i.useCallback(c=>{let I=[];c&&(I=wn.map(T=>T.id)),nn||yo(I),gn?.(I)},[o,nn,gn]),Lo=i.useCallback((c,I)=>{const T=I?[{field:c,sort:I}]:[];Rn||ki(T),b?.(T)},[Rn,b]),Xn=i.useCallback(c=>{Wt(!1),Ft({id:c.row.id,field:c.field}),hn.current?.focus({preventScroll:!0}),m?.(c)},[m,Wt]),Ro=i.useRef($e.editingCell);i.useEffect(()=>{const c=!!Ro.current,I=!!$e.editingCell;c&&!I&&hn.current?.focus({preventScroll:!0}),Ro.current=$e.editingCell},[$e.editingCell]);const Oo=i.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:I}=_e.renderContext,T=Ke.length,B=Ke.map((se,V)=>({row:se,rowIndex:V})),Z=st.map((se,V)=>({row:se,rowIndex:T+(Me?gt.length:Pe.length)+V})),re=Math.max(0,c-T),ue=Math.min(Me?gt.length:Pe.length,I-T+1),Oe=(Me?gt:Pe).slice(re,ue).map((se,V)=>({row:se,rowIndex:T+re+V})),Fe=[...B,...Oe,...Z],le=new Set;return Fe.filter(se=>le.has(se.row.id)?!1:(le.add(se.row.id),!0))},[_e.renderContext,Ke,st,gt,Pe,Me,z,de.dataSource.loading,ge.pageSize,l]),ol=o.length>0&&Ie.size===o.length,rl=Ie.size>0&&Ie.size<o.length,il=i.useCallback(c=>{c.target===c.currentTarget&&Ft(I=>{if(I)return I;if(s)return{id:"HEADER",field:"__checkbox_col__"};const T=Se[0],B=we[0];return T&&B?{id:T.id,field:B.field}:null})},[Se,we]),ll=i.useCallback(c=>{c.currentTarget.contains(c.relatedTarget)||Ft(null)},[]),sl=i.useCallback(c=>{if(Wt(!0),!qe)return;const{id:I,field:T}=qe,B=!!$e.editingCell;if(c.key==="Enter"){if(c.preventDefault(),B)$e.stopCellEdit();else if(we.find(he=>he.field===T)?.editable){const he=Se.find(Ce=>Ce.id===I);he&&$e.startCellEdit({id:I,field:T,value:he[T]})}return}if((c.key===" "||c.key==="Spacebar")&&!B){if(T==="__checkbox_col__"){c.preventDefault(),Vt(I,!Ie.has(I));return}if(T==="__expand_col__"){c.preventDefault(),ln(I);return}}if(I==="HEADER"&&(c.key==="Enter"||c.key===" ")){c.preventDefault();const V=we.find(he=>he.field===T);if(V&&V.sortable!==!1){const he=nt.find(be=>be.field===T);let Ce="asc";he&&(he.sort==="asc"?Ce="desc":Ce=null),Lo(T,Ce)}return}if(c.key==="Escape"){B&&(c.preventDefault(),$e.stopCellEdit({cancel:!0}));return}if(B&&c.key!=="Tab")return;const Z=I==="HEADER",re=Z?-1:Se.findIndex(V=>V.id===I),ue=we.findIndex(V=>V.field===T);if(!Z&&re===-1||ue===-1)return;const Oe=(V,he,Ce,be,Te,Le=!1)=>{let fe=V+Ce,ce=he+be;return Te&&be!==0&&(be>0&&ce>=we.length?(ce=0,fe++):be<0&&ce<0&&(ce=we.length-1,fe--)),!Te&&(ce<0||ce>=we.length)||fe<(Le?-1:0)||fe>=Se.length?null:{r:fe,c:ce}},Fe=(V,he,Ce,be,Te,Le=!1)=>{let fe=V,ce=he,ht=0;const at=Se.length*we.length+we.length;for(;ht<at;){if(ht++,fe+=Ce,ce+=be,be!==0)be>0?ce>=we.length&&(ce=0,fe++):ce<0&&(ce=we.length-1,fe--);else if(ce<0||ce>=we.length)return null;if(fe<-1||fe>=Se.length)return null;if(fe===-1){if(!Le)continue;const Re=we[ce],dt=Re.sortable!==!1;if(["__checkbox_col__"].includes(Re.field)||dt)return{r:fe,c:ce};continue}const We=Se[fe],je=we[ce],Ae=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(je.field);let Ge=je.editable||Ae;if($&&!Ae)try{Ge=$({row:We,field:je.field,value:We[je.field],colDef:je,rowIndex:fe,colIndex:ce})}catch(Re){console.error("Error in isCellEditable:",Re)}if(Ge)return{r:fe,c:ce}}return null};let le=re,xe=ue,se=!1;if(c.key==="Tab"){const V=c.shiftKey?-1:1,he=Fe(re,ue,0,V,!0,!1);he&&(le=he.r,xe=he.c,se=!0)}else if(c.key==="ArrowRight"){const V=Oe(re,ue,0,1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowLeft"){const V=Oe(re,ue,0,-1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowDown"){const V=Oe(re,ue,1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowUp"){const V=Oe(re,ue,-1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="Home")(c.ctrlKey||c.metaKey)&&(le=-1),xe=0,se=!0;else if(c.key==="End")(c.ctrlKey||c.metaKey)&&(le=Se.length-1),xe=we.length-1,se=!0;else if(c.key==="PageUp"){const V=Me?ge.pageSize:10;le=Math.max(-1,le-V),se=!0}else if(c.key==="PageDown"){const V=Me?ge.pageSize:10;le=Math.min(Se.length-1,le+V),se=!0}if(se&&(c.preventDefault(),B&&c.key==="Tab"&&$e.stopCellEdit(),le>=-1&&le<Se.length&&xe>=0&&xe<we.length)){const V=we[xe];if(le===-1)Ft({id:"HEADER",field:V.field});else{const he=Se[le];Ft({id:he.id,field:V.field})}if(Nt.current){const{cumulativeHeights:he,pinnedTopHeight:Ce}=_e,{clientHeight:be,clientWidth:Te,scrollTop:Le,scrollLeft:fe}=Nt.current,ce=le===0?0:he[le-1],ht=he[le],at=Ce,We=Le+at,je=Le+be;let Ae=Le;if(ce<We?Ae=Math.max(0,ce-at):ht>je&&(Ae=ht-be),Ae!==Le&&(Nt.current.scrollTop=Ae),_e.columnMetrics){const{leftPinnedWidth:Ge,rightPinnedWidth:Re,unpinnedAccWidths:dt,unpinnedCols:yt,totalSpecialsWidth:pt,pinnedSpecialsWidth:sn}=_e.columnMetrics,Ut=V.field,xt=yt.findIndex(Ye=>Ye.field===Ut);if(xt!==-1){const Ye=pt+Ge+(xt>0?dt[xt-1]:0),It=pt+Ge+dt[xt],Kt=fe+sn+Ge,kt=fe+Te-Re;let Qe=fe;Ye<Kt?Qe=Math.max(0,Ye-sn-Ge):It>kt&&(Qe=It-Te+Re),Qe!==fe&&(Nt.current.scrollLeft=Qe)}}}}},[qe,Se,we,$e,_e,Ie,Vt,ln]),al=i.useMemo(()=>ke.some(c=>!!c.rowSpan),[ke]),[_n,Cn]=i.useState(!1),yn=i.useRef(null);return i.useEffect(()=>{if(!_n||ye?.toolbar)return;function c(I){const T=document.getElementById("ogx-standalone-col-panel");T&&!T.contains(I.target)&&Cn(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_n,ye?.toolbar]),t.jsxs("div",{ref:yn,className:["ogx",en,d&&"ogx--auto-height",al&&"ogx--row-spanning",cn&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Rt,height:q??Rt?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${a}px`},"aria-busy":on,children:[ye?.toolbar&&(()=>{const c={apiRef:lt.apiRef,columns:ke,baseColumns:e,aggregationModel:ot,onAggregationModelChange:Ii,...ze||et||tt?{pivotModel:_o,onPivotModelChange:Wi}:{},filterModel:Ve,onFilterModelChange:f,columnVisibilityModel:Xe,onColumnVisibilityModelChange:tn,onColumnReorder:X?void 0:(I,T)=>{const B=[..._t],Z=B.indexOf(I),re=B.indexOf(T);if(Z===-1||re===-1)return;const ue=[...B];ue.splice(Z,1),ue.splice(re,0,I),A||bn(ue);const Oe=ke.find(Fe=>Fe.field===I);Oe&&U?.({oldIndex:Z,targetIndex:re,column:Oe})},forceColumnsOpen:_n,onColumnsPanelClose:()=>Cn(!1),...ft?.toolbar};return t.jsx(ji,{...c})})(),!ye?.toolbar&&_n&&St.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const c=yn.current?.getBoundingClientRect();return{position:"fixed",top:c?c.top+8:16,right:c?window.innerWidth-c.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[t.jsx("button",{onClick:()=>Cn(!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:"×"}),t.jsx(co,{columns:ke,visibleColumns:new Set(ke.filter(c=>Xe[c.field]!==!1).map(c=>c.field)),onVisibilityChange:(c,I)=>{tn({...Xe,[c]:I})},onShowAll:()=>{const c={...Xe};ke.forEach(I=>{I.hideable!==!1&&(c[I.field]=!0)}),tn(c)},onHideAll:()=>{const c={...Xe};ke.forEach(I=>{I.hideable!==!1&&(c[I.field]=!1)}),tn(c)},onColumnReorder:X?void 0:(c,I)=>{const T=[..._t],B=T.indexOf(c),Z=T.indexOf(I);if(B===-1||Z===-1)return;const re=[...T];re.splice(B,1),re.splice(Z,0,c),A||bn(re),U?.({oldIndex:B,targetIndex:Z,column:ke.find(ue=>ue.field===c)})}})]}),yn.current?.closest(".ogx-theme-provider")||document.body),cn&&wo&&t.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":Ot||"Data grid list view","aria-rowcount":Se.length+1,children:[t.jsx("div",{className:"ogx-list-view__toolbar",children:t.jsxs("span",{children:[He.length," ",He.length===1?"item":"items",Me?` · page ${ge.page+1} of ${Math.ceil(He.length/ge.pageSize)||1}`:"",Ie.size>0?` · ${Ie.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:Se.length===0?t.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),Tn]}):Se.map((c,I)=>t.jsx(zo,{row:c,rowIndex:I,listViewColumn:wo,isSelected:Ie.has(c.id),checkboxSelection:s,rowHeight:l,onRowClick:T=>mn({row:T,id:T.id,rowIndex:I}),onSelectionChange:Vt},c.id))}),Me&&(()=>{const c=ye?.pagination||lo,I=z==="server"&&oe?de.pagination.rowCount||0:He.length,T={page:ge.page,pageSize:ge.pageSize,rowCount:I,pageSizeOptions:j,onPageChange:B=>fn({...ge,page:B}),onPageSizeChange:B=>fn({...ge,pageSize:B,page:0}),...ft?.pagination};return t.jsx(c,{...T})})()]}),!cn&&t.jsx("div",{ref:c=>{Nt.current=c,hn.current=c},className:"ogx__viewport",onScroll:tl,role:"grid","aria-label":Ot||"Data grid","aria-rowcount":He.length+1,"aria-colcount":e.length+(s?1:0)+(Je?1:0)+(G?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Wt(!0)},onMouseDownCapture:()=>{Wt(!1)},onKeyDown:sl,onFocus:il,onBlur:ll,children:t.jsxs("div",{ref:Di,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(oo,{columns:_e.virtualColumns,allColumns:ke,columnGroupingModel:Et,checkboxSelection:s,allSelected:ol,someSelected:rl,onSelectAll:nl,sortModel:nt,onSort:Lo,onColumnResize:el,columnWidths:Ue,pinnedColumns:rt,focusedCell:qe,onHeaderClick:c=>{Ft({id:"HEADER",field:c}),Wt(!1),hn.current?.focus({preventScroll:!0})},onDragStart:Et?void 0:$t.onDragStart,onDragOver:Et?void 0:$t.onDragOver,onDragEnd:Et?void 0:$t.onDragEnd,onDrop:Et?void 0:$t.onDrop,draggedColumn:Et?void 0:$t.draggedColumn,dragOverColumn:Et?void 0:$t.dragOverColumn,rowReordering:G,hasDetailPanel:Je,pinCheckboxColumn:O,pinExpandColumn:W,aggregationModel:ot,onHideColumn:c=>{tn({...Xe,[c]:!1})},onManageColumns:()=>Cn(!0),onPinColumn:(c,I)=>{const T=[...rt?.left??[]],B=[...rt?.right??[]],Z=T.filter(ue=>ue!==c),re=B.filter(ue=>ue!==c);zn(I==="left"?{left:[...Z,c],right:re}:I==="right"?{left:Z,right:[...re,c]}:{left:Z,right:re})}}),!on&&!de.dataSource.error&&He.length===0&&t.jsxs("div",{className:"ogx__empty",style:{width:_e.totalWidth},children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),t.jsx("span",{children:Tn})]}),Ke.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ke.map((c,I)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,focusedCellField:qe?.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},c.id))}),t.jsx("div",{className:"ogx__virtual-container",style:{height:`${_e.totalHeight-_e.pinnedTopHeight-_e.pinnedBottomHeight}px`},role:"presentation",children:t.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${_e.renderContext.firstRowIndex*l}px)`},role:"rowgroup",children:[on&&Oo.length===0?(()=>{const c=e.length>0?e:(()=>{const I=(de.dimensions.viewportWidth||1e3)-(s?48:0)-(M?48:0)-(G?48:0),T=150,B=Math.max(1,Math.ceil(I/T));return Array.from({length:B},(Z,re)=>({field:`placeholder_${re}`,headerName:"",width:T}))})();return Array.from({length:10}).map((I,T)=>t.jsx(ur,{columns:c,rowHeight:l,checkboxSelection:s,hasDetailPanel:!!M,rowReordering:G},`skeleton-${T}`))})():Oo.filter(({row:c})=>!En(c.id,v)).filter((c,I,T)=>I===T.findIndex(B=>B.row.id===c.row.id)).map(({row:c,rowIndex:I})=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,rowReordering:G,onDragStart:Ht.onDragStart,onDragOver:Ht.onDragOver,onDragEnd:Ht.onDragEnd,onDrop:Ht.onDrop,isDragging:Ht.draggedRowId===c.id,isDragOver:Ht.dragOverRowId===c.id,editingCell:$e.editingCell,onEditStart:$e.startCellEdit,onEditStop:$e.stopCellEdit,onEditCellValueChange:$e.setEditCellValue,focusedCellField:qe!=null&&qe.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},`${c.id}-${_e.totalWidth}`)),z==="infinite"&&de.dataSource.loading&&Pe.length>0&&(()=>{const c=Math.min(ge.pageSize,20),I=Yn.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:c}).map((T,B)=>t.jsx(Jt,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:I+B,rowHeight:l},`__skeleton_${B}__`))})})()]})}),st.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:st.map((c,I)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,focusedCellField:qe?.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},c.id))}),vn&&!ze&&t.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&t.jsx("div",{style:{width:48,flexShrink:0}}),Je&&t.jsx("div",{style:{width:48,flexShrink:0}}),G&&t.jsx("div",{style:{width:48,flexShrink:0}}),Bt.map(c=>{const I=ot[c.field],T=Kn[c.field],B=Ue[c.field]??(typeof c.width=="number"?c.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:B,minWidth:B,maxWidth:B,textAlign:c.align||"left"},children:I?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ogx__aggregation-label",children:I}),t.jsx("span",{className:"ogx__aggregation-value",children:bt(T,I)})]}):null},c.field)})]})]})}),!cn&&Me&&(()=>{const c=ye?.pagination||lo,I={page:ge.page,pageSize:ge.pageSize,rowCount:de.pagination.rowCount,pageSizeOptions:j,onPageChange:T=>fn({...ge,page:T}),onPageSizeChange:T=>fn({...ge,pageSize:T,page:0}),...ft?.pagination};return t.jsx(c,{...I})})(),t.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[on?"Loading data...":"",de.dataSource.error?`Error: ${de.dataSource.error.message||"Unknown error"}`:"",!Q&&!de.dataSource.error&&(He.length===0?Tn:Ve&&((Ve.quickFilterValues?.length||0)>0||(Ve.items?.length||0)>0)?`${He.length} ${He.length===1?"row":"rows"} found`:"")]}),de.dataSource.error&&t.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[t.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:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),t.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),t.jsx("div",{className:"ogx-error-overlay__message",children:de.dataSource.error.message||"An unexpected error occurred while loading the data."}),t.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})]})}function Wr({rows:n=5,columns:o=5}){return t.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,r)=>t.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:o}).map((l,a)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-content"})},a))},r))})}const uo=new Set(["isEmpty","isNotEmpty"]);function Ar(n,o){return n.find(e=>"field"in e&&e.field===o)}const zr=({col:n,item:o,onChange:e})=>{const r=_r(n.type),l=!!o,a=o?.operator??r[0],[d,s]=i.useState(o?.value??""),g=i.useRef(e);g.current=e;const u=i.useRef(o?.value);i.useEffect(()=>{o?.value!==u.current&&(u.current=o?.value,s(o?.value??""))},[o?.value]),i.useEffect(()=>{const b=setTimeout(()=>{const E=o?.value??"";d!==E&&g.current({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:d})},300);return()=>clearTimeout(b)},[d]);const h=b=>{const E=uo.has(b),P={id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:b,value:E?void 0:o?.value??(n.type==="boolean"?"true":"")};e(P)},m=()=>{s(""),e(null)},p=uo.has(String(a)),f=n.type==="boolean",C=!p;return t.jsxs("div",{className:`ogx-filter__row${l?" ogx-filter__row--active":""}`,children:[t.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),t.jsxs("div",{className:"ogx-filter__controls",children:[t.jsx("select",{id:`ogx-filter-op-${n.field}`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:b=>h(b.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(b=>t.jsx("option",{value:b,children:b},b))}),C&&f&&t.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:b=>{s(b.target.value),e({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:b.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[t.jsx("option",{value:"true",children:"true"}),t.jsx("option",{value:"false",children:"false"})]}),C&&!f&&t.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:b=>s(b.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),l&&t.jsx("button",{className:"ogx-filter__row-clear",onClick:m,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},fo=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],l=n.logicOperator??"and",a=i.useCallback((g,u)=>{const h=r.filter(p=>"field"in p&&p.field!==g),m=u?[...h,u]:h;e({...n,items:m})},[r,n,e]),d=i.useCallback(g=>{e({...n,logicOperator:g})},[n,e]),s=o.filter(g=>g.filterable!==!1);return t.jsxs(t.Fragment,{children:[r.length>1&&t.jsxs("div",{className:"ogx-filter__logic-bar",children:[t.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),t.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),t.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?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):s.map(g=>t.jsx(zr,{col:g,item:Ar(r,g.field),onChange:u=>a(g.field,u)},g.field))]})},Br=["sum","avg","count","min","max"];function go(){return t.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:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),t.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function $r({anchorRef:n,columns:o,model:e,onChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),g=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const x=n.current.getBoundingClientRect();return{top:x.bottom+6,right:window.innerWidth-x.right}},[n]);i.useEffect(()=>{s(g());const x=()=>s(g());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[g]),i.useEffect(()=>{function x(O){a.current&&!a.current.contains(O.target)&&n.current&&!n.current.contains(O.target)&&l()}function N(O){O.key==="Escape"&&l()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",N)}},[n,l]);const u=new Set(e.rowFields),h=new Set(e.columnFields),m=new Set(e.valueFields.map(x=>x.field)),p=x=>u.has(x)||h.has(x)||m.has(x);function f(x){u.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function C(x){h.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function b(x,N="sum"){m.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:N}]})}function E(x){r({...e,rowFields:e.rowFields.filter(N=>N!==x)})}function P(x){r({...e,columnFields:e.columnFields.filter(N=>N!==x)})}function k(x){r({...e,valueFields:e.valueFields.filter(N=>N.field!==x)})}function j(x,N){r({...e,valueFields:e.valueFields.map(O=>O.field===x?{...O,aggFn:N}:O)})}function y(){r({rowFields:[],columnFields:[],valueFields:[]})}const w=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),v=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=x=>o.find(N=>N.field===x)?.headerName??x,S=t.jsxs("div",{ref:a,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(go,{}),"Pivot Mode"]}),v>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:y,title:"Reset pivot",children:"Reset"})]}),t.jsxs("div",{className:"ogx-pivot-panel__body",children:[t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x),title:`Remove ${M(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>P(x),title:`Remove ${M(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:N=>j(x.field,N.target.value),title:"Aggregation function",children:Br.map(N=>t.jsx("option",{value:N,children:N.toUpperCase()},N))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>k(x.field),title:`Remove ${M(x.field)}`,children:"×"})]},x.field))})]}),t.jsx("hr",{className:"ogx-pivot-panel__divider"}),t.jsxs("div",{children:[t.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),t.jsxs("div",{className:"ogx-pivot-fields",children:[o.map(x=>{const N=w.has(x.field);return p(x.field)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[t.jsx("span",{className:`ogx-pivot-field-btn${N?" ogx-pivot-field-btn--numeric":""}`,children:x.headerName??x.field}),t.jsxs("div",{className:"ogx-pivot-field-actions",children:[t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>f(x.field),title:"Add to Row Fields",children:"Row"}),t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>C(x.field),title:"Add to Column Fields",children:"Col"}),N&&t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>b(x.field),title:"Add to Value Fields",children:"Val"})]})]},x.field)}),o.every(x=>p(x.field))&&t.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return St.createPortal(S,n.current?.closest(".ogx-theme-provider")||document.body)}function Dr(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Gr({value:n="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[l,a]=i.useState(()=>n.length>0),[d,s]=i.useState(n),g=i.useRef(null),u=i.useRef(null),h=i.useRef(o);h.current=o;const m=i.useRef(n),p=i.useRef(n),f=i.useRef(!1);i.useLayoutEffect(()=>{f.current&&document.activeElement!==g.current&&g.current?.focus()}),i.useEffect(()=>{n!==p.current&&(p.current=n,n!==m.current&&(s(n),m.current=n,n?a(!0):(f.current=!1,a(!1))))},[n]),i.useEffect(()=>{const k=setTimeout(()=>{d!==m.current&&(m.current=d,h.current(d))},r);return()=>clearTimeout(k)},[d,r]);const C=i.useCallback(()=>{a(!0),requestAnimationFrame(()=>g.current?.focus())},[]),b=i.useCallback(k=>{k.stopPropagation(),s(""),m.current="",h.current(""),g.current?.focus()},[]),E=i.useCallback(()=>{f.current=!0,a(!0)},[]),P=i.useCallback(()=>{f.current=!1,setTimeout(()=>{if(u.current&&document.activeElement&&u.current.contains(document.activeElement)){f.current=!0;return}d||a(!1)},150)},[d]);return i.useEffect(()=>{const k=j=>{u.current&&!u.current.contains(j.target)&&(d||a(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d]),t.jsxs("div",{ref:u,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:C,children:[t.jsx("div",{className:"ogx-global-search__icon-wrapper",children:t.jsx(Dr,{})}),t.jsx("input",{ref:g,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:k=>s(k.target.value),onFocus:E,onBlur:P,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&t.jsx("button",{className:"ogx-global-search__clear",onClick:b,"aria-label":"Clear search",children:t.jsx(Hr,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:l=0}){const[a,d]=i.useState(!1),[s,g]=i.useState({top:0,left:0}),u=i.useRef(null),h=i.useRef(null),m=i.useCallback(()=>{if(!h.current)return;const b=h.current.getBoundingClientRect();let E=0,P=0;const k=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(E=b.top+j-8,P=b.left+k+b.width/2):e==="bottom"&&(E=b.bottom+j+8,P=b.left+k+b.width/2),g({top:E,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 p=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(!0)},r)},f=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(!1)},l)},C=i.useCallback(b=>{h.current=b?b.firstElementChild??b:null},[]);return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:C,style:{display:"inline-block",lineHeight:0},onMouseEnter:p,onMouseLeave:f,children:o}),a&&n&&St.createPortal(t.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:s.top,left:s.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Vr=["none","sum","avg","count","min","max"];function ho(){return t.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:t.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Ur(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function po(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Kr({anchorRef:n,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:l,onClose:a,activeCount:d}){const s=i.useRef(null),[g,u]=i.useState({top:0,right:0}),h=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const p=n.current.getBoundingClientRect();return{top:p.bottom+6,right:window.innerWidth-p.right}},[n]);i.useEffect(()=>{u(h());const p=()=>u(h());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[h]),i.useEffect(()=>{function p(f){s.current&&!s.current.contains(f.target)&&n.current&&!n.current.contains(f.target)&&a()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[n,a]),i.useEffect(()=>{function p(f){f.key==="Escape"&&a()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[a]);const m=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:g.top,right:g.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(ho,{}),"Summaries"]}),d>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?t.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",t.jsx("br",{}),"Set ",t.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(p=>{const f=o[p.field]||"none";return t.jsxs("div",{className:"ogx-toolbar__agg-row",children:[t.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),t.jsx("div",{className:"ogx-toolbar__agg-pills",children:Vr.map(C=>t.jsx("button",{className:`ogx-toolbar__pill${f===C?" ogx-toolbar__pill--active":""}`,onClick:()=>r(p.field,C),"aria-pressed":f===C,children:C},C))})]},p.field)})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}function Yr({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d,onClose:s}){const g=i.useRef(null),[u,h]=i.useState({top:0,right:0}),m=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);i.useEffect(()=>{h(m());const f=()=>h(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),i.useEffect(()=>{function f(C){g.current&&!g.current.contains(C.target)&&n.current&&!n.current.contains(C.target)&&s()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n,s]);const p=t.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:u.top,right:u.right,width:280,padding:0},children:t.jsx(co,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d})});return St.createPortal(p,n.current?.closest(".ogx-theme-provider")||document.body)}function Xr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),g=i.useRef(l);g.current=l;const u=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);i.useEffect(()=>{s(u());const f=()=>s(u());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[u]),i.useEffect(()=>{function f(C){C.key==="Escape"&&g.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const h=e.items?.length??0,m=()=>{r({...e,items:[],logicOperator:"and"})},p=t.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:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(po,{}),"Filters",h>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:h})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:m,title:"Clear all filters",children:"Clear all"}),t.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>g.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),t.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:t.jsx(fo,{columns:o,filterModel:e,onFilterModelChange:r})})]});return St.createPortal(p,n.current?.closest(".ogx-theme-provider")||document.body)}const qr={rowFields:[],columnFields:[],valueFields:[]};function Jr({columns:n=[],baseColumns:o,aggregationModel:e={},onAggregationModelChange:r,pivotModel:l,onPivotModelChange:a,filterModel:d,onFilterModelChange:s,columnVisibilityModel:g={},onColumnVisibilityModelChange:u,onColumnReorder:h,forceColumnsOpen:m,onColumnsPanelClose:p,children:f,rightContent:C,style:b}){const[E,P]=i.useState(!1),[k,j]=i.useState(!1),[y,w]=i.useState(!1),[v,M]=i.useState(!1);i.useEffect(()=>{m&&(w(!0),P(!1),j(!1),M(!1))},[m]);const S=i.useRef(null),x=i.useRef(null),N=i.useRef(null),O=i.useRef(null),W=l??qr,X=W.rowFields.length>0||W.columnFields.length>0||W.valueFields.length>0,A=n.filter(R=>R.aggregable!==!1&&(R.type==="number"||R.aggregable===!0)),U=Object.keys(e).filter(R=>e[R]&&e[R]!=="none").length,q=i.useCallback((R,Y)=>{if(!r)return;const $={...e};Y==="none"?delete $[R]:$[R]=Y,r($)},[e,r]),G=i.useCallback(()=>{r?.({})},[r]),ee=i.useCallback(R=>{if(!s)return;const $={...d||{},quickFilterValues:R?[R]:[],items:d?.items||[]};s($)},[d,s]),Q=d?.quickFilterValues?.[0]||"",pe=d?.items?.length||0,_=new Set(n.filter(R=>g[R.field]!==!1).map(R=>R.field)),D=i.useCallback((R,Y)=>{if(!u)return;const $={...g,[R]:Y};u($)},[g,u]),H=i.useCallback(()=>{if(!u)return;const R={...g};n.forEach(Y=>{Y.hideable!==!1&&(R[Y.field]=!0)}),u(R)},[n,g,u]),K=i.useCallback(()=>{if(!u)return;const R={...g};n.forEach(Y=>{Y.hideable!==!1&&(R[Y.field]=!1)}),u(R)},[n,g,u]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:b,children:[f&&t.jsx("div",{className:"ogx-toolbar__left",children:f}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[s&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Gr,{value:Q,onChange:ee,placeholder:"Search..."})}),u&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:N,className:`ogx-toolbar__icon-btn${y?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{w(!y),P(!1),j(!1),M(!1)},children:t.jsx(Ur,{})})}),y&&t.jsx(Yr,{anchorRef:N,columns:n,visibleColumns:_,onVisibilityChange:D,onShowAll:H,onHideAll:K,onColumnReorder:h,onClose:()=>{w(!1),p?.()}})]}),s&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:O,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{M(!v),P(!1),j(!1),w(!1)},children:[t.jsx(po,{}),pe>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),v&&t.jsx(Xr,{anchorRef:O,columns:n,filterModel:d||{items:[]},onFilterModelChange:s,onClose:()=>M(!1)})]}),a&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:x,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:()=>{j(!k),P(!1),w(!1),M(!1)},children:[t.jsx(go,{}),X&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),k&&t.jsx($r,{anchorRef:x,columns:o??n,model:W,onChange:R=>{a?.(R)},onClose:()=>j(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:S,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${E?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":E,"aria-controls":"ogx-aggregation-panel",onClick:()=>{P(!E),j(!1),w(!1),M(!1)},children:[t.jsx(ho,{}),U>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${U} active summaries`})]})}),E&&t.jsx(Kr,{anchorRef:S,aggregationModel:e,aggregableColumns:A,onFunctionChange:q,onClearAll:G,onClose:()=>P(!1),activeCount:U})]}),C]})]})}function Qr(){return i.useRef(null)}const Zr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:l="",...a})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return t.jsxs("div",{className:d,children:[e&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),t.jsx("input",{className:"ogx-input",...a}),r&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})};function ei(n,o,e={}){const{fileName:r="export.csv",includeHeaders:l=!0,delimiter:a=",",selectedRows:d}=e,s=d&&d.length>0?n.filter(h=>d.includes(h.id)):n;if(s.length===0){console.warn("No rows to export");return}const g=o.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let u="";if(l){const h=g.map(m=>Lt(m.headerName||m.field));u+=h.join(a)+`
|
|
9
|
+
`}if(s.forEach(h=>{const m=g.map(p=>{let f=h[p.field];return p.valueGetter&&(f=p.valueGetter({row:h,field:p.field,value:f})),p.valueFormatter&&f!==void 0&&f!==null&&(f=p.valueFormatter({value:f,row:h,field:p.field})),Lt(String(f??""))});u+=m.join(a)+`
|
|
10
|
+
`}),e.aggregationResult){const h=e.aggregationResult,m=e.aggregationModel||{},p=g.map(C=>m[C.field]?Lt(m[C.field].toUpperCase()):Lt(""));u+=p.join(a)+`
|
|
11
|
+
`;const f=g.map(C=>{const b=h[C.field];if(b!=null){let E=b;return C.valueFormatter?E=C.valueFormatter({value:b,row:{},field:C.field}):m[C.field]&&(E=bt(b,m[C.field])),Lt(String(E))}return Lt("")});u+=f.join(a)+`
|
|
12
|
+
`}Pn(u,r,"text/csv;charset=utf-8;")}function Lt(n){return n.includes(",")||n.includes('"')||n.includes(`
|
|
13
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}function ti(n,o,e={}){const{fileName:r="export.xlsx",sheetName:l="Sheet1",includeHeaders:a=!0,selectedRows:d}=e,s=d&&d.length>0?n.filter(h=>d.includes(h.id)):n;if(s.length===0){console.warn("No rows to export");return}const g=o.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let u='<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(u+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",u+=`<x:Name>${l}</x:Name>`,u+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",u+='<meta charset="UTF-8"></head><body>',u+='<table border="1">',a&&(u+="<thead><tr>",g.forEach(h=>{u+=`<th>${ut(h.headerName||h.field)}</th>`}),u+="</tr></thead>"),u+="<tbody>",s.forEach(h=>{u+="<tr>",g.forEach(m=>{let p=h[m.field];m.valueGetter&&(p=m.valueGetter({row:h,field:m.field,value:p})),m.valueFormatter&&p!==void 0&&p!==null&&(p=m.valueFormatter({value:p,row:h,field:m.field})),u+=`<td>${ut(String(p??""))}</td>`})}),e.aggregationResult){const h=e.aggregationResult,m=e.aggregationModel||{};u+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',g.forEach(p=>{m[p.field]?u+=`<td style="text-align: right; font-weight: bold;">${ut(m[p.field].toUpperCase())}</td>`:u+="<td></td>"}),u+="</tr>",u+='<tr style="font-weight: bold; background-color: #f5f5f5;">',g.forEach(p=>{const f=h[p.field];if(f!=null){let C=f;p.valueFormatter?C=p.valueFormatter({value:f,row:{},field:p.field}):m[p.field]&&(C=bt(f,m[p.field])),u+=`<td style="text-align: right;">${ut(String(C))}</td>`}else u+="<td></td>"}),u+="</tr>"}u+="</tbody></table></body></html>",Pn(u,r,"application/vnd.ms-excel")}function ut(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ni(n,o,e={}){const{fileName:r="export.json",pretty:l=!0,selectedRows:a}=e,d=a&&a.length>0?n.filter(m=>a.includes(m.id)):n;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__")),g=d.map(m=>{const p={};return s.forEach(f=>{let C=m[f.field];f.valueGetter&&(C=f.valueGetter({row:m,field:f.field,value:C})),p[f.field]=C}),p});let u=g;if(e.aggregationResult){const m=e.aggregationResult,p=e.aggregationModel||{},f={};s.forEach(b=>{p[b.field]&&(f[b.field]=p[b.field].toUpperCase())});const C={};s.forEach(b=>{if(m[b.field]!==void 0&&m[b.field]!==null){let E=m[b.field];b.valueFormatter?E=b.valueFormatter({value:E,row:{},field:b.field}):p[b.field]&&(E=bt(E,p[b.field])),C[b.field]=E}}),u={data:g,aggregation:{labels:f,values:C}}}const h=l?JSON.stringify(u,null,2):JSON.stringify(u);Pn(h,r,"application/json;charset=utf-8;")}async function oi(n,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(`
|
|
14
14
|
<!DOCTYPE html>
|
|
15
15
|
<html>
|
|
16
16
|
<head>
|
|
@@ -30,11 +30,11 @@ ${p}`;try{await Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clip
|
|
|
30
30
|
</div>
|
|
31
31
|
</body>
|
|
32
32
|
</html>
|
|
33
|
-
`),r.document.close(),await new Promise(
|
|
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 g=a&&a.length>0?n.filter(p=>a.includes(p.id)):n;if(g.length===0){r.document.body.innerHTML="<h3>No rows to export</h3>";return}const u=o.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let h=`
|
|
34
34
|
<!DOCTYPE html>
|
|
35
35
|
<html>
|
|
36
36
|
<head>
|
|
37
|
-
<title>${
|
|
37
|
+
<title>${l||"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 Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clip
|
|
|
49
49
|
</style>
|
|
50
50
|
</head>
|
|
51
51
|
<body>
|
|
52
|
-
`;if(i&&(p+=`<h1>${ut(i)}</h1>`),p+="<table>",p+="<thead><tr>",f.forEach(u=>{p+=`<th>${ut(u.headerName||u.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",g.forEach(u=>{p+="<tr>",f.forEach(h=>{let w=u[h.field];h.valueGetter&&(w=h.valueGetter({row:u,field:h.field,value:w})),h.valueFormatter&&w!==void 0&&w!==null&&(w=h.valueFormatter({value:w,row:u,field:h.field})),h.type==="image"&&w?p+=`<td><div style="display:flex;justify-content:center;"><img src="${w}" alt="${h.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${ut(String(w??""))}</td>`}),p+="</tr>"}),c){const u=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(h=>{u[h.field]?p+=`<td style="text-align: right; font-weight: bold;">${ut(u[h.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',f.forEach(h=>{const w=c[h.field];if(w!=null){let b=w;h.valueFormatter?b=h.valueFormatter({value:w,row:{},field:h.field}):u[h.field]&&(b=bt(w,u[h.field])),p+=`<td style="text-align: right;">${ut(String(b))}</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=i||"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(i){console.error("Print generation failed:",i),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${i.message}</p></div>`)}}function Pn(n,o,e){const r=new Blob([n],{type:e}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=o,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function ri(n,o){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date?"date":"string"}function ii(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function li(n,o){if(o!=null)return o;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function si(n,o){const e=o??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const r=n.split("?")[0].toLowerCase();return r.endsWith(".jpg")||r.endsWith(".jpeg")?"jpeg":r.endsWith(".gif")?"gif":"png"}async function ai(n){const o=await Promise.allSettled(n.map(async r=>{if(r.startsWith("data:")){const a=r.indexOf(","),g=r.slice(0,a),f=r.slice(a+1),p=atob(f),m=new Uint8Array(p.length);for(let b=0;b<p.length;b++)m[b]=p.charCodeAt(b);const h=g.match(/data:([^;,]+)/)?.[1]??"image/png";let w="png";return h.includes("jpeg")||h.includes("jpg")?w="jpeg":h.includes("gif")&&(w="gif"),{url:r,buffer:m.buffer,ext:w}}const i=await fetch(r,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),c=si(r,i.headers.get("content-type"));return{url:r,buffer:s,ext:c}})),e=new Map;return o.forEach((r,i)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function di(n,o,e={}){const{fileName:r="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:c="#f1f5f9",headerTextColor:a="#334155",headerFontSize:g=10,bodyFontSize:f=10,aggregationResult:p=null,aggregationModel:m=null,selectedRows:u}=e,h=(await import("exceljs")).default,w=new h.Workbook;w.creator="OpenGridX",w.created=new Date;const b=o.filter(S=>S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),M=n,P=u&&u.length>0?n.filter(S=>u.includes(S.id)):n,E=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],k=new Map;for(const S of E){if("type"in S&&S.type==="summary"){if(!p||!m)continue;const v=w.addWorksheet(S.name??"Summary");v.addRow(["Summary / Aggregation Totals"]),v.getRow(1).font={bold:!0,size:g+2,color:{argb:wt(a)}},v.addRow([]),v.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.border=xo()}),b.forEach(H=>{const W=m[H.field],F=p[H.field];if(W==null||F==null)return;let q=F;H.valueFormatter?q=H.valueFormatter({value:F,row:{},field:H.field}):q=bt(F,W);const K=v.addRow([H.headerName??H.field,W.toUpperCase(),q]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:f}}),v.getColumn(1).width=20,v.getColumn(2).width=12,v.getColumn(3).width=18;continue}const x=S,{name:j="Data",rows:R="all",includeHeaders:B=!0,includeSummary:Y=!1,autoFilter:A=!0,frozenHeader:U=!0,alternateRowColor:X="#f8fafc"}=x,G=R==="selected"?P:M,ee=b.filter(v=>s[v.field]?.embedImage);if(ee.length>0){const v=[],D=new Set;if(G.forEach(H=>{ee.forEach(W=>{const F=H[W.field];typeof F=="string"&&F&&!k.has(F)&&!D.has(F)&&(v.push(F),D.add(F))})}),v.length>0){const H=await ai(v);for(const[W,{buffer:F,extension:q}]of H){const K=w.addImage({buffer:F,extension:q});k.set(W,K)}}}const Q=w.addWorksheet(j);if(Q.columns=b.map(v=>({key:v.field,width:li(v,s[v.field]?.width),style:{numFmt:s[v.field]?.numFmt??ii(v)}})),B){const v=b.map(H=>H.headerName??H.field),D=Q.addRow(v);D.height=20,D.eachCell((H,W)=>{const F=b[W-1];H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.alignment={horizontal:s[F?.field]?.alignment??(F?.type==="number"?"right":"left"),vertical:"middle"},H.border=xo()}),A&&(Q.autoFilter={from:{row:1,column:1},to:{row:1,column:b.length}}),U?Q.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Q.views=[{showGridLines:!1}]}let pe=B?1:0;if(G.forEach((v,D)=>{const H=b.map(F=>{if(s[F.field]?.embedImage)return"";let q=v[F.field];return F.valueGetter&&(q=F.valueGetter({row:v,field:F.field,value:q})),ri(F,q)==="string"&&F.valueFormatter&&q!=null&&(q=F.valueFormatter({value:q,row:v,field:F.field})),q}),W=Q.addRow(H);if(W.font={size:f},X&&D%2===1&&W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(X)}}}),W.eachCell((F,q)=>{const K=b[q-1];K&&(F.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},F.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),ee.length>0){const F=ee.reduce((L,ae)=>Math.max(L,s[ae.field]?.imageHeight??40),0),q=Math.ceil(F/1.333),K=q*1.333;W.height=q,ee.forEach(L=>{const ae=b.indexOf(L),oe=v[L.field],me=typeof oe=="string"?k.get(oe):void 0;if(me===void 0){W.getCell(ae+1).value=typeof oe=="string"?oe:"";return}const Ze=s[L.field],z=Ze?.imageWidth??40,Ee=Ze?.imageHeight??40,gt=(Q.getColumn(ae+1).width??8)*7+5,De=Math.max(0,gt-z)/2,et=Math.max(0,K-Ee)/2;Q.addImage(me,{tl:{col:ae,row:pe,nativeColOff:Math.floor(De*9525),nativeRowOff:Math.floor(et*9525)},ext:{width:z,height:Ee},editAs:"oneCell"})})}else W.height=16;pe++}),Y&&p&&m){const v=b.map(F=>{const q=m[F.field];return q?q.toUpperCase():""}),D=Q.addRow(v);D.height=16,D.font={size:f-1,italic:!0,color:{argb:"FF94a3b8"}},D.eachCell(F=>{F.alignment={horizontal:"right",vertical:"middle"},F.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=b.map(F=>{const q=m[F.field],K=p[F.field];return q==null||K==null?"":F.valueFormatter?F.valueFormatter({value:K,row:{},field:F.field}):bt(K,q)}),W=Q.addRow(H);W.height=18,W.font={bold:!0,size:f,color:{argb:wt(a)}},W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},F.alignment={horizontal:"right",vertical:"middle"},F.border=ci()})}}const C=await w.xlsx.writeBuffer(),_=new Blob([C],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(_),I=document.createElement("a");I.href=y,I.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(y)}function wt(n){const o=n.replace("#","");return o.length===3?"FF"+o.split("").map(e=>e+e).join(""):o.length===6?"FF"+o:"FF"+o.padEnd(6,"0")}function xo(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function ci(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ui={"--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 gi(n){const o={};function e(r,i){i!==void 0&&(o[r]=i)}if(n.colors){const r=n.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(n.typography){const r=n.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(n.spacing){const r=n.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(n.borders){const r=n.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(n.shadows){const r=n.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(n.grid){const r=n.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(n.transitions){const r=n.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(n.toolbar){const r=n.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(n.overlays){const r=n.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(n.scrollbar){const r=n.scrollbar;e("--ogx-scrollbar-thumb",r.thumbColor),e("--ogx-scrollbar-track",r.trackColor),e("--ogx-scrollbar-size",r.size)}if(n.skeleton){const r=n.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 fi({theme:n,children:o,className:e,style:r}){const i=l.useMemo(()=>({...ui,...gi(n)}),[n]);return t.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...i},children:o})}const hi={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"}},pi={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"}},xi={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"}},mi={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"}},bi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function wi(n,o){try{const e=o.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function vi(n,o,e,r){try{const i=e?Object.fromEntries(Object.entries(o).filter(([s])=>e.includes(s))):o;r.setItem(n,JSON.stringify(i))}catch{}}function _i(n){const o=typeof n=="string"?{key:n}:n,{key:e,debounceMs:r=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=o,c=l.useMemo(()=>{if(s)return wi(e,s)},[e]),a=l.useRef(null),g=l.useRef(null),f=l.useCallback(()=>{g.current&&s&&vi(e,g.current,i,s)},[e,i,s]),p=l.useCallback(u=>{g.current=u,a.current&&clearTimeout(a.current),a.current=setTimeout(f,r)},[f,r]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),f())},[f]);const m=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:c,onStateChange:p,clearState:m}}ie.Button=Qt,ie.Cell=ro,ie.Checkbox=qt,ie.DataGrid=Wr,ie.DataGridThemeProvider=fi,ie.FilterPanel=go,ie.GridToolbar=Jr,ie.GridTooltip=Zt,ie.Header=oo,ie.Input=Zr,ie.Row=Jt,ie.Skeleton=Fr,ie.amberTheme=mi,ie.compactTheme=bi,ie.darkTheme=hi,ie.emeraldTheme=xi,ie.exportToCsv=ei,ie.exportToExcel=ti,ie.exportToExcelAdvanced=di,ie.exportToJson=ni,ie.formatAggregationValue=bt,ie.printGrid=oi,ie.roseTheme=pi,ie.useAggregation=so,ie.useGridApiRef=Qr,ie.useGridStateStorage=_i,ie.usePivot=ao,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
|
|
52
|
+
`;if(l&&(h+=`<h1>${ut(l)}</h1>`),h+="<table>",h+="<thead><tr>",u.forEach(p=>{h+=`<th>${ut(p.headerName||p.field)}</th>`}),h+="</tr></thead>",h+="<tbody>",g.forEach(p=>{h+="<tr>",u.forEach(f=>{let C=p[f.field];f.valueGetter&&(C=f.valueGetter({row:p,field:f.field,value:C})),f.valueFormatter&&C!==void 0&&C!==null&&(C=f.valueFormatter({value:C,row:p,field:f.field})),f.type==="image"&&C?h+=`<td><div style="display:flex;justify-content:center;"><img src="${C}" alt="${f.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:h+=`<td>${ut(String(C??""))}</td>`}),h+="</tr>"}),d){const p=s||{};h+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(f=>{p[f.field]?h+=`<td style="text-align: right; font-weight: bold;">${ut(p[f.field].toUpperCase())}</td>`:h+="<td></td>"}),h+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(f=>{const C=d[f.field];if(C!=null){let b=C;f.valueFormatter?b=f.valueFormatter({value:C,row:{},field:f.field}):p[f.field]&&(b=bt(C,p[f.field])),h+=`<td style="text-align: right;">${ut(String(b))}</td>`}else h+="<td></td>"}),h+="</tr></tfoot>"}h+="</tbody></table></body></html>",r.document.open(),r.document.write(h),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 Pn(n,o,e){const r=new Blob([n],{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 ri(n,o){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date?"date":"string"}function ii(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function li(n,o){if(o!=null)return o;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function si(n,o){const e=o??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const r=n.split("?")[0].toLowerCase();return r.endsWith(".jpg")||r.endsWith(".jpeg")?"jpeg":r.endsWith(".gif")?"gif":"png"}async function ai(n){const o=await Promise.allSettled(n.map(async r=>{if(r.startsWith("data:")){const s=r.indexOf(","),g=r.slice(0,s),u=r.slice(s+1),h=atob(u),m=new Uint8Array(h.length);for(let b=0;b<h.length;b++)m[b]=h.charCodeAt(b);const f=g.match(/data:([^;,]+)/)?.[1]??"image/png";let C="png";return f.includes("jpeg")||f.includes("jpg")?C="jpeg":f.includes("gif")&&(C="gif"),{url:r,buffer:m.buffer,ext:C}}const l=await fetch(r,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const a=await l.arrayBuffer(),d=si(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 "${n[l]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function di(n,o,e={}){const{fileName:r="export.xlsx",sheets:l,columnStyles:a={},headerFillColor:d="#f1f5f9",headerTextColor:s="#334155",headerFontSize:g=10,bodyFontSize:u=10,aggregationResult:h=null,aggregationModel:m=null,selectedRows:p}=e,f=(await import("exceljs")).default,C=new f.Workbook;C.creator="OpenGridX",C.created=new Date;const b=o.filter(S=>S.exportable!==!1&&S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),E=n,P=p&&p.length>0?n.filter(S=>p.includes(S.id)):n,k=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],j=new Map;for(const S of k){if("type"in S&&S.type==="summary"){if(!h||!m)continue;const _=C.addWorksheet(S.name??"Summary");_.addRow(["Summary / Aggregation Totals"]),_.getRow(1).font={bold:!0,size:g+2,color:{argb:wt(s)}},_.addRow([]),_.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},H.font={bold:!0,size:g,color:{argb:wt(s)}},H.border=xo()}),b.forEach(H=>{const K=m[H.field],R=h[H.field];if(K==null||R==null)return;let Y=R;H.valueFormatter?Y=H.valueFormatter({value:R,row:{},field:H.field}):Y=bt(R,K);const $=_.addRow([H.headerName??H.field,K.toUpperCase(),Y]);$.getCell(3).alignment={horizontal:"right"},$.getCell(3).font={bold:!0,size:u}}),_.getColumn(1).width=20,_.getColumn(2).width=12,_.getColumn(3).width=18;continue}const x=S,{name:N="Data",rows:O="all",includeHeaders:W=!0,includeSummary:X=!1,autoFilter:A=!0,frozenHeader:U=!0,alternateRowColor:q="#f8fafc"}=x,G=O==="selected"?P:E,ee=b.filter(_=>a[_.field]?.embedImage);if(ee.length>0){const _=[],D=new Set;if(G.forEach(H=>{ee.forEach(K=>{const R=H[K.field];typeof R=="string"&&R&&!j.has(R)&&!D.has(R)&&(_.push(R),D.add(R))})}),_.length>0){const H=await ai(_);for(const[K,{buffer:R,extension:Y}]of H){const $=C.addImage({buffer:R,extension:Y});j.set(K,$)}}}const Q=C.addWorksheet(N);if(Q.columns=b.map(_=>({key:_.field,width:li(_,a[_.field]?.width),style:{numFmt:a[_.field]?.numFmt??ii(_)}})),W){const _=b.map(H=>H.headerName??H.field),D=Q.addRow(_);D.height=20,D.eachCell((H,K)=>{const R=b[K-1];H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},H.font={bold:!0,size:g,color:{argb:wt(s)}},H.alignment={horizontal:a[R?.field]?.alignment??(R?.type==="number"?"right":"left"),vertical:"middle"},H.border=xo()}),A&&(Q.autoFilter={from:{row:1,column:1},to:{row:1,column:b.length}}),U?Q.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Q.views=[{showGridLines:!1}]}let pe=W?1:0;if(G.forEach((_,D)=>{const H=b.map(R=>{if(a[R.field]?.embedImage)return"";let Y=_[R.field];return R.valueGetter&&(Y=R.valueGetter({row:_,field:R.field,value:Y})),ri(R,Y)==="string"&&R.valueFormatter&&Y!=null&&(Y=R.valueFormatter({value:Y,row:_,field:R.field})),Y}),K=Q.addRow(H);if(K.font={size:u},q&&D%2===1&&K.eachCell(R=>{R.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(q)}}}),K.eachCell((R,Y)=>{const $=b[Y-1];$&&(R.alignment={horizontal:a[$.field]?.alignment??($.type==="number"?"right":"left"),vertical:"middle"},R.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),ee.length>0){const R=ee.reduce((L,ae)=>Math.max(L,a[ae.field]?.imageHeight??40),0),Y=Math.ceil(R/1.333),$=Y*1.333;K.height=Y,ee.forEach(L=>{const ae=b.indexOf(L),oe=_[L.field],me=typeof oe=="string"?j.get(oe):void 0;if(me===void 0){K.getCell(ae+1).value=typeof oe=="string"?oe:"";return}const Ze=a[L.field],z=Ze?.imageWidth??40,Ne=Ze?.imageHeight??40,ft=(Q.getColumn(ae+1).width??8)*7+5,ze=Math.max(0,ft-z)/2,et=Math.max(0,$-Ne)/2;Q.addImage(me,{tl:{col:ae,row:pe,nativeColOff:Math.floor(ze*9525),nativeRowOff:Math.floor(et*9525)},ext:{width:z,height:Ne},editAs:"oneCell"})})}else K.height=16;pe++}),X&&h&&m){const _=b.map(R=>{const Y=m[R.field];return Y?Y.toUpperCase():""}),D=Q.addRow(_);D.height=16,D.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},D.eachCell(R=>{R.alignment={horizontal:"right",vertical:"middle"},R.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=b.map(R=>{const Y=m[R.field],$=h[R.field];return Y==null||$==null?"":R.valueFormatter?R.valueFormatter({value:$,row:{},field:R.field}):bt($,Y)}),K=Q.addRow(H);K.height=18,K.font={bold:!0,size:u,color:{argb:wt(s)}},K.eachCell(R=>{R.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},R.alignment={horizontal:"right",vertical:"middle"},R.border=ci()})}}const y=await C.xlsx.writeBuffer(),w=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),v=URL.createObjectURL(w),M=document.createElement("a");M.href=v,M.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(M),M.click(),document.body.removeChild(M),URL.revokeObjectURL(v)}function wt(n){const o=n.replace("#","");return o.length===3?"FF"+o.split("").map(e=>e+e).join(""):o.length===6?"FF"+o:"FF"+o.padEnd(6,"0")}function xo(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function ci(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ui={"--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 fi(n){const o={};function e(r,l){l!==void 0&&(o[r]=l)}if(n.colors){const r=n.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(n.typography){const r=n.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(n.spacing){const r=n.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(n.borders){const r=n.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(n.shadows){const r=n.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(n.grid){const r=n.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(n.transitions){const r=n.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(n.toolbar){const r=n.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(n.overlays){const r=n.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(n.scrollbar){const r=n.scrollbar;e("--ogx-scrollbar-thumb",r.thumbColor),e("--ogx-scrollbar-track",r.trackColor),e("--ogx-scrollbar-size",r.size)}if(n.skeleton){const r=n.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 gi({theme:n,children:o,className:e,style:r}){const l=i.useMemo(()=>({...ui,...fi(n)}),[n]);return t.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...l},children:o})}const hi={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"}},pi={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"}},xi={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"}},mi={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"}},bi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function wi(n,o){try{const e=o.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function vi(n,o,e,r){try{const l=e?Object.fromEntries(Object.entries(o).filter(([a])=>e.includes(a))):o;r.setItem(n,JSON.stringify(l))}catch{}}function _i(n){const o=typeof n=="string"?{key:n}:n,{key:e,debounceMs:r=300,include:l,storage:a=typeof window<"u"?window.localStorage:void 0}=o,d=i.useMemo(()=>{if(a)return wi(e,a)},[e]),s=i.useRef(null),g=i.useRef(null),u=i.useCallback(()=>{g.current&&a&&vi(e,g.current,l,a)},[e,l,a]),h=i.useCallback(p=>{g.current=p,s.current&&clearTimeout(s.current),s.current=setTimeout(u,r)},[u,r]);i.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),u())},[u]);const m=i.useCallback(()=>{a&&a.removeItem(e)},[e,a]);return{initialState:d,onStateChange:h,clearState:m}}ie.Button=Qt,ie.Cell=ro,ie.Checkbox=qt,ie.DataGrid=Fr,ie.DataGridThemeProvider=gi,ie.FilterPanel=fo,ie.GridToolbar=Jr,ie.GridTooltip=Zt,ie.Header=oo,ie.Input=Zr,ie.Row=Jt,ie.Skeleton=Wr,ie.amberTheme=mi,ie.compactTheme=bi,ie.darkTheme=hi,ie.emeraldTheme=xi,ie.exportToCsv=ei,ie.exportToExcel=ti,ie.exportToExcelAdvanced=di,ie.exportToJson=ni,ie.formatAggregationValue=bt,ie.printGrid=oi,ie.roseTheme=pi,ie.useAggregation=so,ie.useGridApiRef=Qr,ie.useGridStateStorage=_i,ie.usePivot=ao,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
|
|
53
53
|
//# sourceMappingURL=opengridx.umd.js.map
|