@opencorestack/opengridx 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +4 -1
- package/dist/ai.cjs +1 -0
- package/dist/ai.cjs.map +1 -0
- package/dist/ai.d.ts +166 -0
- package/dist/ai.es.js +1 -0
- package/dist/ai.es.js.map +1 -0
- package/dist/index.d.ts +148 -2
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +6084 -5523
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +17 -15
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +98 -1
- package/docs/README.md +3 -1
- package/docs/architecture/datagrid-orchestration.md +10 -1
- package/docs/customization/theming.md +9 -0
- package/docs/features/ai-toolkit.md +119 -0
- package/docs/features/clipboard.md +88 -0
- package/docs/features/editing-reordering.md +50 -0
- package/docs/features/keyboard-navigation.md +11 -0
- package/docs/features/undo-redo.md +79 -0
- package/docs/roadmap.md +1 -1
- package/lib/ai/coerce.ts +90 -0
- package/lib/ai/columns.ts +90 -0
- package/lib/ai/index.ts +16 -0
- package/lib/ai/schema.ts +214 -0
- package/lib/ai/types.ts +88 -0
- package/lib/ai/validate.ts +286 -0
- package/lib/components/Cell/Cell.css +5 -0
- package/lib/components/Cell/GridEditInputCell.css +12 -4
- package/lib/components/Cell/GridEditInputCell.tsx +19 -12
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +14 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +3 -2
- package/lib/components/DataGrid/DataGrid.tsx +62 -2
- package/lib/components/FilterPanel/FilterPanel.css +14 -0
- package/lib/components/FilterPanel/FilterPanel.tsx +3 -2
- package/lib/components/ListView/ListView.css +2 -4
- package/lib/components/ListView/ListViewRow.tsx +2 -2
- package/lib/components/Toolbar/GlobalSearch.css +16 -0
- package/lib/components/Toolbar/GlobalSearch.tsx +3 -2
- package/lib/components/ui/Checkbox.tsx +16 -5
- package/lib/components/ui/Input.css +43 -0
- package/lib/components/ui/Input.tsx +24 -5
- package/lib/hooks/core/gridApiPlaceholder.ts +8 -1
- package/lib/hooks/core/useDataGrid.ts +27 -0
- package/lib/hooks/core/useGridCellSelection.ts +30 -2
- package/lib/hooks/core/useGridClipboardPaste.ts +283 -0
- package/lib/hooks/core/useGridUndoRedo.ts +220 -0
- package/lib/hooks/features/useGridBatchEdit.ts +217 -0
- package/lib/hooks/features/useGridEditing.ts +24 -45
- package/lib/index.ts +7 -0
- package/lib/styles/opengridx.css +2 -1
- package/lib/types/index.ts +124 -0
- package/lib/utils/editing/commit.ts +69 -0
- package/lib/utils/editing/targets.ts +109 -0
- package/lib/utils/parsing.ts +252 -0
- package/llms.txt +55 -1
- package/package.json +8 -2
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
(function(xe,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],a):(xe=typeof globalThis<"u"?globalThis:xe||self,a(xe.OpenGridX={},xe.ReactJSXRuntime,xe.React,xe.ReactDOM))})(this,(function(xe,a,s,ut){"use strict";function eo(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function ft(e,t,n=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const o=t[e.field]??e.width,r=typeof o=="number"&&Number.isFinite(o)?o:n;return eo(r,e.minWidth,e.maxWidth)}const Ye=48;function et(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function ls(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=et(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const d=t.left.indexOf(i.field),c=t.left.indexOf(l.field);return d-c}),t.right&&r.sort((i,l)=>{const d=t.right.indexOf(i.field),c=t.right.indexOf(l.field);return d-c}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function to(e,t,n,o,r,i,l,d){const c={};if(!n)return c;let f=(d?Ye:0)+(i&&l?Ye:0)+(o&&r?Ye:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const C=et(x.field,n);C==="left"?(c[x.field]=f,f+=ft(x,t)):C==="right"&&g.push(x)});let h=0;for(let x=g.length-1;x>=0;x--)c[g[x].field]=h,h+=ft(g[x],t);return c}function no(e,t){let n=null,o=null;if(!t)return{lastLeft:n,firstRight:o};for(const r of e){if(r.isSpacer)continue;const i=et(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function hr(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function ss(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const d=hr(n(l),t);d==="top"?o.push(l):d==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,d)=>{const c=t.top.indexOf(n(l)),f=t.top.indexOf(n(d));return c-f}),t.bottom&&i.sort((l,d)=>{const c=t.bottom.indexOf(n(l)),f=t.bottom.indexOf(n(d));return c-f}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function as(e,t,n){const o=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return n==="left"?{left:[...o,t],right:r}:n==="right"?{left:o,right:[...r,t]}:{left:o,right:r}}const mr=new Set;function Cn(e,t,n){process.env.NODE_ENV==="production"||mr.has(e)||(mr.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function vn(e,t,n,o){try{return e()}catch(r){return Cn(n,o,r),t}}function wr(e,t,n){const o=e[t];if(!n?.valueGetter)return{value:o};try{return{value:n.valueGetter({row:e,field:t,value:o})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Le(e,t,n){const{value:o,error:r}=wr(e,t,n);return r!==void 0&&Cn(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function oo(e,t,n,o){const r=o?.valueFormatter;if(r)return vn(()=>r({value:n,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function gt(e){if(e==null)return null;if(typeof e=="number")return Number.isNaN(e)?null:e;if(typeof e=="string"){const t=e.trim();if(t==="")return null;const n=Number(t);return Number.isNaN(n)?null:n}if(typeof e=="boolean")return null;if(e instanceof Date){const t=e.getTime();return Number.isNaN(t)?null:t}return typeof e=="bigint"?Number(e):null}const cs=/^(\d{4})-(\d{2})-(\d{2})$/;function yn(e){if(e==null)return null;let t;if(e instanceof Date)t=e;else if(typeof e=="number")t=new Date(e);else if(typeof e=="string"){const n=e.trim();if(n==="")return null;const o=cs.exec(n);if(o){const r=Number(o[1]),i=Number(o[2])-1,l=Number(o[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else t=new Date(n)}else return null;return Number.isNaN(t.getTime())?null:t}function Sn(e){const t=yn(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function xr(e){const t=yn(e);if(!t)return"";const n=String(t.getFullYear()).padStart(4,"0"),o=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${r}`}let br=null;function Cr(e){return br??=new Intl.DateTimeFormat,br.format(e)}function ds(e,t){if(!e)return;const n=i=>typeof i=="object"?i.value:i,o=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(n(i),t))??e.find(i=>String(n(i))===String(t));return r===void 0?void 0:o(r)}function ro(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=yn(e);return n?Cr(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return ds(t.valueOptions,e)??String(e);default:return String(e)}}const io=200;function lo(e){if(e==="auto")return"auto";const t=typeof e=="string"?Number.parseFloat(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:io}function so(e,t){if(e)return vn(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function us(e,t){const n=lo(e);return n==="auto"?t??io:n}function fs(e,t){if(t.size===0||e.size===0)return e;let n=!1;const o=new Set;for(const r of e)t.get(r)?.isGroupRow?n=!0:o.add(r);return n?o:e}const gs=e=>e.id;function ps(e){if(e===void 0)return{type:"auto",value:0};if(typeof e=="number")return{type:"fixed",value:e};if(typeof e=="string"){if(e.toLowerCase()==="auto")return{type:"auto",value:0};if(e.endsWith("%"))return{type:"percentage",value:parseFloat(e)};const t=parseFloat(e);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function hs(e,t,n){const o=new Map;e.forEach(u=>{if(!Object.prototype.hasOwnProperty.call(t,u.field)&&u.flex&&u.flex>0){o.set(u.field,{kind:"flex",flex:u.flex});return}const b=ps(t[u.field]??u.width);b.type==="fixed"?o.set(u.field,{kind:"fixed",width:eo(b.value,u.minWidth,u.maxWidth)}):b.type==="percentage"?o.set(u.field,{kind:"percentage",percentage:b.value}):o.set(u.field,{kind:"flex",flex:1})});const r=e.reduce((u,m)=>{const b=o.get(m.field);if(b.kind==="fixed")return u+b.width;if(b.kind==="percentage")return u+100;if(m.flex&&m.flex>0){const w=m.minWidth??150;return u+(w||(typeof m.width=="number"?m.width:150))}return u+(m.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((u,m)=>{const b=o.get(m.field);return b.kind==="fixed"?u+b.width:u},0),d=new Map,c=Math.max(0,i-l);let f=0;e.forEach(u=>{const m=o.get(u.field);if(m.kind==="fixed")d.set(u.field,m.width);else if(m.kind==="percentage"){const b=m.percentage/100*c,w=eo(b>0?b:100,u.minWidth??50,u.maxWidth);d.set(u.field,w),f+=w}});const g=Math.max(0,c-f),h=new Map,x=e.flatMap(u=>{const m=o.get(u.field);return m.kind!=="flex"?[]:(h.set(u.field,m.flex),[{field:u.field,flex:m.flex,minWidth:u.minWidth??50,maxWidth:u.maxWidth??1/0,frozen:!1,computedWidth:0}])});let C=0;const p=x.length*2;for(;C<p;){C++;const u=x.filter(P=>!P.frozen);if(u.length===0)break;const m=u.reduce((P,F)=>P+F.flex,0),b=x.reduce((P,F)=>F.frozen?P+F.computedWidth:P,0),w=Math.max(0,g-b);if(m<=0){u.forEach(P=>{P.computedWidth=P.minWidth,P.frozen=!0});break}const v=w/m;let E=0;const I=[],D=[];if(u.forEach(P=>{const F=v*P.flex;F<P.minWidth?(E+=P.minWidth-F,I.push(P)):F>P.maxWidth?(E+=P.maxWidth-F,D.push(P)):P.computedWidth=F}),I.length===0&&D.length===0){u.forEach(P=>{P.frozen=!0});break}E>0?I.forEach(P=>{P.computedWidth=P.minWidth,P.frozen=!0}):E<0?D.forEach(P=>{P.computedWidth=P.maxWidth,P.frozen=!0}):(I.forEach(P=>{P.computedWidth=P.minWidth,P.frozen=!0}),D.forEach(P=>{P.computedWidth=P.maxWidth,P.frozen=!0}))}return x.forEach(u=>d.set(u.field,u.computedWidth)),{widths:d,flexByField:h}}function ms(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:d,pinnedTopRowsLength:c,pinnedBottomRowsLength:f,pinnedTopRows:g,pinnedBottomRows:h,visibleOrderedColumns:x,pinnedColumns:C,columnWidths:p,viewportWidth:u,checkboxSelection:m,hasDetailPanel:b,rowReordering:w,pinCheckboxColumn:v,pinExpandColumn:E,paginationMode:I,isLoading:D,pageSize:P,getRowId:F=gs}=e;return s.useMemo(()=>{const H=n?o:r,B=(N,L)=>{const q=F(N);if(!i.has(q))return t;const Y=so(l,{row:N,id:q,rowIndex:L});return t+us(Y,d?.get(q))},U=H.map((N,L)=>B(N,c+L)),_=U.reduce((N,L,q)=>(N.push((N[q-1]||0)+L),N),[]),T=I==="infinite"&&D&&H.length>0?Math.min(P,20):0,O=(_[_.length-1]||0)+T*t,S=(N,L)=>N?N.reduce((q,Y,G)=>q+B(Y,G),0):L*t,K=S(g,c),j=S(h,f),{left:Q,center:$,right:z}=ls(x,C),Z=(m?Ye:0)+(b?Ye:0)+(w?Ye:0),ie=(w?Ye:0)+(b&&E?Ye:0)+(m&&v?Ye:0),{widths:oe,flexByField:fe}=hs([...Q,...$,...z],p,u-Z),de=N=>oe.get(N.field)??100,ge=N=>({...N,width:de(N),flex:fe.get(N.field)??N.flex}),re=11,ae=Q.map((N,L)=>({...ge(N),zIndex:re+L})),ee=11,ne=z.map((N,L)=>({...ge(N),zIndex:ee+(z.length-1-L)})),V=$.map(ge),J=V.map(N=>N.width),te=ae.reduce((N,L)=>N+L.width,0),se=ne.reduce((N,L)=>N+L.width,0),y=J.reduce((N,L)=>N+L,0),M=te+y+se+Z,A=J.reduce((N,L,q)=>(N.push((N[q-1]||0)+L),N),[]);return{rowHeights:U,cumulativeHeights:_,unpinnedRowsHeight:O,pinnedTopHeight:K,pinnedBottomHeight:j,leftPinnedCols:ae,rightPinnedCols:ne,unpinnedColsWithWidth:V,unpinnedColWidths:J,unpinnedAccWidths:A,totalWidth:M,leftWidth:te,rightWidth:se,unpinnedTotalWidth:y,systemColumnsWidth:Z,pinnedSystemColumnsWidth:ie,pinnedTopRowsLength:c,pinnedBottomRowsLength:f,unpinnedRowsLength:H.length}},[t,n,o,r,i,l,d,c,f,g,h,x,C,p,u,m,b,w,v,E,I,D,P,F])}function ws(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function ao(e,t,n,o,r){if(t<0||t>=n.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:d}=e,c=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,f=Math.max(o,ws(e)),g=c+(t===0?0:n[t-1]),h=r!==void 0?Math.min(g+r,c+n[t]):c+n[t];g<l+c?e.scrollTop=Math.max(0,g-c):h>l+d-f&&(e.scrollTop=h-d+f)}function vr(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:d}=n;if(t<0||t>=o.length)return;const c=l+r,f=c+(t>0?o[t-1]:0),g=c+o[t],h=d+r,{scrollLeft:x,clientWidth:C}=e;f<x+h?e.scrollLeft=Math.max(0,f-h):g>x+C-i&&(e.scrollLeft=g-C+i)}function yr(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:d,rowMeta:c}=e;if(!i.editable||c?.isGroupRow||n._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:d})}catch{return!1}}const xs={},co=e=>e==null||typeof e=="string"&&e.trim()==="",Sr=e=>{const t=[];for(const n of e){const o=gt(n);o!==null&&t.push(o)}return t},_r=(e,t)=>{let n=null,o=null;for(const r of e){const i=gt(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},pt={sum:e=>Sr(e).reduce((t,n)=>t+n,0),avg:e=>{const t=Sr(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!co(t)).length,min:e=>_r(e,(t,n)=>t<n),max:e=>_r(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!co(t))).size};function uo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function _n(e,t,n,o){const r={};for(const[i,l]of Object.entries(t)){const d=n.get(i);if(!uo(d,l))continue;const c=pt[l];if(!c){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=c(e.map(f=>Le(f,i,d)))}return r}function qt(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const bs=new Set(["count","unique"]);function kr(e){return e!==void 0&&bs.has(e)}function Er(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function kn(e,t,n,o){if(e==null)return"—";if(kr(t))return qt(e,t);const r=Er(n,t,e);if(n?.valueFormatter)try{return String(n.valueFormatter({value:r,row:o??{},field:n.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Cr(r):qt(r,t)}const fo=new Set(["isEmpty","isNotEmpty"]);function Mr(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Cs(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Xt=e=>(t,n)=>{const o=gt(t),r=gt(n);return o===null||r===null?!1:e(o,r)},Yt=e=>(t,n)=>{const o=Sn(t),r=Sn(n);return o===null||r===null?!1:e(o,r)},Nr=Yt((e,t)=>e===t),Ir=(e,t)=>{const n=Sn(e),o=Sn(t);return n===null||o===null?!0:n!==o},Pr={contains:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase()),equals:(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:String(e).toLowerCase()===String(t).toLowerCase(),startsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:e=>e==null||String(e).trim()==="",isNotEmpty:e=>e!=null&&String(e).trim()!=="","=":Xt((e,t)=>e===t),">":Xt((e,t)=>e>t),">=":Xt((e,t)=>e>=t),"<":Xt((e,t)=>e<t),"<=":Xt((e,t)=>e<=t),"!=":(e,t)=>{if(Mr(t))return!0;const n=gt(e),o=gt(t);return n!==null&&o!==null?n!==o:Cs(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const n=Array.isArray(t)?t:[t],o=String(e).toLowerCase();return n.some(r=>r!=null&&String(r).toLowerCase()===o)},not:(e,t)=>e instanceof Date?Ir(e,t):e==null&&t==null?!1:e==null||t==null?!0:String(e).toLowerCase()!==String(t).toLowerCase(),is:(e,t)=>t==null||t===""?!0:e instanceof Date?Nr(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:Yt((e,t)=>e>t),onOrAfter:Yt((e,t)=>e>=t),before:Yt((e,t)=>e<t),onOrBefore:Yt((e,t)=>e<=t)},vs={is:Nr,not:Ir};function ys(e,t){if(!Object.prototype.hasOwnProperty.call(Pr,e))return;const n=e;if(t?.type==="date"){const o=vs[n];if(o)return o}return Pr[n]}function Ss(e){return"items"in e&&Array.isArray(e.items)}function _s(e,t){const{field:n,operator:o,value:r}=e;if(!fo.has(o)&&Mr(r))return null;const i=t.columns?.byField.get(n),l=ys(o,i);return l?d=>l(Le(d,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function Tr(e,t,n){const o=[];for(const r of e){const i=Ss(r)?Tr(r.items,r.logicOperator,n):_s(r,n);i&&o.push(i)}return o.length===0?null:o.length===1?o[0]:t==="or"?r=>o.some(i=>i(r)):r=>o.every(i=>i(r))}function go(e,t){if(t!=null){switch(typeof t){case"string":e.push(t.toLowerCase());return;case"number":Number.isNaN(t)||e.push(String(t));return;case"boolean":case"bigint":e.push(String(t));return}if(t instanceof Date){const n=xr(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&go(e,n)}}function Lr(e,t){const n=[];if(!t){for(const o of Object.values(e))go(n,o);return n}for(const o of t.quickFilterColumns){const r=Le(e,o.field,o),i=oo(e,o.field,r,o);i!=null&&i!==""&&n.push(String(i).toLowerCase()),go(n,r)}return n}const Fr=new WeakMap;function ks(e,t){if(!t)return Lr(e,t);let n=Fr.get(t);n||(n=new WeakMap,Fr.set(t,n));let o=n.get(e);return o||(o=Lr(e,t),n.set(e,o)),o}function Es(e,t){const n=(e??[]).map(o=>String(o??"").trim().toLowerCase()).filter(o=>o!=="");return n.length===0?null:o=>{const r=ks(o,t);return n.every(i=>r.some(l=>l.includes(i)))}}function En(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=Es(o,t),i=Tr(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function po(e,t,n){const o=En(t,n);return o?e.filter(r=>o(r)):e}function Ms(e){switch(e){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"]}}const Ns=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),ho=0,Ar=1,Is=2,Or=3,Dr=4;function kt(e,t){return{rank:e,num:t,str:""}}function mo(e,t){if(e==null)return null;if(t==="number"){const n=gt(e);return n===null?null:kt(ho,n)}if(t==="date"){const n=yn(e);return n?kt(Ar,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:kt(ho,e);case"bigint":return kt(ho,Number(e));case"boolean":return kt(Is,e?1:0);case"string":return{rank:Or,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:kt(Ar,n)}return{rank:Dr,num:0,str:String(e)}}function $r(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===Or||e.rank===Dr?Ns.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function wo(e,t){return e===0?0:t==="asc"?e:-e}function Ps(e,t,n,o){return wo($r(mo(e,o),mo(t,o)),n)}function Gr(e,t,n){let o;try{o=e(t.value,n.value,t,n)}catch(r){return Cn(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof o!="number"||Number.isNaN(o)?(Cn(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(o)}; the values are treated as equal`,void 0),0):o}const Ts=e=>e.id;function Ls(e,t,n,o=Ts){return t.length===0?e:xo(e,t,(r,i)=>{const l=n?.byField.get(i.field),d=Le(r,i.field,l);return{value:d,type:l?.type,comparator:l?.sortComparator,params:l?.sortComparator?{id:o(r),field:i.field,row:r,value:d}:void 0}})}function xo(e,t,n){if(t.length===0||e.length<2)return[...e];const o=t.map(l=>e.map(d=>n(d,l))),r=o.map(l=>l.map(({value:d,type:c})=>mo(d,c))),i=e.map((l,d)=>d);return i.sort((l,d)=>{for(let c=0;c<t.length;c++){const f=o[c][l],g=o[c][d],h=f.comparator&&f.comparator===g.comparator&&f.params&&g.params?Gr(f.comparator,f.params,g.params):$r(r[c][l],r[c][d]),x=wo(h,t[c].sort);if(x!==0)return x}return l-d}),i.map(l=>e[l])}function Fs(e,t,n){if(!n)return e.filter(r=>r.field!==t);const o=e.findIndex(r=>r.field===t);return o===-1?[...e,{field:t,sort:n}]:e.map((r,i)=>i===o?{field:t,sort:n}:r)}function bo(e,t={}){const n=new Map,o=[];for(const r of e)n.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&o.push(r);return{byField:n,quickFilterColumns:o}}const Et="__pivot_grand_total__",As="__pivot_row__:",Wr=e=>`${As}${JSON.stringify(e.split(Hr))}`,Os="Grand Total",Hr="\0",Mt="",Co=`${Mt}id`,Br=e=>e==="id"?Co:e,vo={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},zr=e=>e.map(t=>String(t??"")).join(Hr),Vr=e=>e===void 0||e===""?null:e;function Ds(e,t){const n=e==null,o=t==null;return n||o?n===o?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e=="boolean"&&typeof t=="boolean"?Number(e)-Number(t):String(e).localeCompare(String(t),void 0,{numeric:!0})}function $s(e,t){for(let n=0;n<e.length;n++){const o=Ds(e[n],t[n]);if(o!==0)return o}return 0}function Kr(e,t){if(!e||e.length===0)return null;const n=pt[t](e);return typeof n=="number"||n instanceof Date?n:null}const Gs=e=>"logicOperator"in e&&"items"in e,Ws=e=>!!(e&&e.items&&e.items.length>0);function Hs(e,t){const n=l=>!t.has(l)&&l.includes(Mt),o=l=>Gs(l)?l.items.length>0&&l.items.every(o):n(l.field),r=[],i=[];for(const l of e.items??[])(o(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function Ur(e,t,n,o={}){const r=new Map(t.map(_=>[_.field,_])),i=_=>r.get(_)?.groupable!==!1,l=n.rowFields.filter(i),d=n.columnFields.filter(i),c=new Set,f=n.valueFields.filter(_=>{if(!uo(r.get(_.field),_.aggFn))return!1;const T=`${_.field}${Mt}${_.aggFn}`;return c.has(T)?!1:(c.add(T),!0)});if(l.length===0||f.length===0)return vo;const g=d.length>0,h=Array.from(new Set(f.map(_=>_.field))),x=(_,T)=>Le(_,T,r.get(T)),C=new Map,p=new Map(g?[]:[["",{values:[]}]]);for(const _ of e){const T=l.map(z=>x(_,z)),O=zr(T);let S=C.get(O);S||(S={labels:T.map(Vr),sample:_,cells:new Map},C.set(O,S));const K=d.map(z=>x(_,z)),j=g?zr(K):"",Q=p.get(j);Q?Q.sample||(Q.sample=_):p.set(j,{values:K.map(Vr),sample:_});let $=S.cells.get(j);$||($=new Map,S.cells.set(j,$));for(const z of h){const Z=x(_,z);if(co(Z))continue;let ie=$.get(z);ie||(ie=[],$.set(z,ie)),ie.push(Z)}}const u=Array.from(p.keys()).sort((_,T)=>$s(p.get(_).values,p.get(T).values)),m=(_,T)=>g?`${_}${Mt}${T.field}${Mt}${T.aggFn}`:`${T.field}${Mt}${T.aggFn}`,b=new Map;let w=[];for(const[_,T]of C){const O={id:Wr(_)};l.forEach((S,K)=>{O[Br(S)]=T.labels[K]}),O.id=Wr(_);for(const S of u){const K=T.cells.get(S);for(const j of f)O[m(S,j)]=Kr(K?.get(j.field),j.aggFn)}b.set(O.id,T),w.push({row:O,entry:T})}const v=_=>l.includes(_),E=_=>v(_)?r.get(_)?.type:"number",{outputFilterModel:I,sortModel:D}=o;if(Ws(I)){const _=[];for(const O of u)for(const S of f)_.push({field:m(O,S),type:"number"});const T=En(I,bo(_));T&&(w=w.filter(({row:O})=>T(O)))}const P=(_,T)=>T==="id"&&v("id")?_[Co]:_[T];D&&D.length>0&&(w=[...w].sort((_,T)=>{for(const O of D){const S=P(_.row,O.field),K=P(T.row,O.field),j=v(O.field)?r.get(O.field)?.sortComparator:void 0,Q=j?wo(Gr(j,{id:_.row.id,field:O.field,row:_.row,value:S},{id:T.row.id,field:O.field,row:T.row,value:K}),O.sort):Ps(S,K,O.sort,E(O.field));if(Q!==0)return Q}return 0}));const F=w.map(_=>_.row);if(w.length>0){const _={id:Et};l.forEach((T,O)=>{_[Br(T)]=O===0?Os:""}),_.id=Et;for(const T of u)for(const O of h){const S=[];for(const{entry:K}of w){const j=K.cells.get(T)?.get(O);if(j)for(const Q of j)S.push(Q)}for(const K of f)K.field===O&&(_[m(T,K)]=Kr(S,K.aggFn))}F.push(_)}const H=w[0]?.entry.sample,B=_=>_===Et?H:_===void 0?void 0:b.get(_)?.sample,U=l.map(_=>zs(_,r.get(_),B));for(const _ of u){const T=p.get(_),O=g?d.map((S,K)=>{const j=r.get(S),Q=Bs(j,S,T.values[K],T.sample);return j?.headerName?`${j.headerName}: ${Q}`:Q}).join(" / "):"";for(const S of f){const K=r.get(S.field),j=S.headerName??K?.headerName??S.field;U.push({field:m(_,S),headerName:O?`${O} — ${j} (${S.aggFn})`:`${j} (${S.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:Q,row:$})=>kn(Q,S.aggFn,K,$)})}}return{pivotRows:F,pivotColumns:U,colKeys:u,isValid:!0}}function Bs(e,t,n,o){const r=o?oo(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function zs(e,t,n){const o={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(o.type=t.type),t.align!==void 0&&(o.align=t.align),t.headerAlign!==void 0&&(o.headerAlign=t.headerAlign),t.description!==void 0&&(o.description=t.description),t.minWidth!==void 0&&(o.minWidth=t.minWidth),t.maxWidth!==void 0&&(o.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(o.valueOptions=t.valueOptions)),e==="id"&&(o.valueGetter=({row:d})=>d[Co]);const r=d=>d?.id===Et,i=t?.valueFormatter;i&&(o.valueFormatter=({value:d,row:c})=>r(c)?String(d??""):i({value:d,row:n(c?.id)??c,field:e}));const l=t?.renderCell;return l&&(o.renderCell=d=>r(d.row)?d.formattedValue??String(d.value??""):l({...d,row:n(d.row.id)??d.row})),o}function Je(e,t){return e===Et||t?.get(e)?.isGroupRow===!0}const Jt="__reorder_col__",Qt="__expand_col__",tt="__checkbox_col__",nt=e=>e===Jt||e===Qt||e===tt,yo=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,Vs=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),Ks=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function jr(e){const t=e.tagName;if(t==="INPUT")return!Vs.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const n=e.getAttribute("role");return n!==null&&Ks.has(n)}const Rr=e=>e!==null&&e.nodeType===1;function qr(e,t){const n=e.closest(".ogx__detail-panel");if(n&&t.contains(n))return null;const o=e.closest('[role="gridcell"], [role="columnheader"]');return!o||o.closest(".ogx__viewport")!==t?null:o}function Us(e,t){if(e===t)return"grid";if(!Rr(e)||!t.contains(e))return"foreign";const n=qr(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":jr(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function js(e,t,n,o){if(!Rr(e))return null;const r=qr(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader")return r.parentElement?.classList.contains("ogx__header")?{id:null,field:i}:null;const l=Number(r.parentElement?.getAttribute("data-rowindex")),d=Number.isInteger(l)?n[l]:void 0;return d?{id:o(d),field:i,rowIndex:l}:null}function Xr(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function So(e,t,n){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Xr(r,t.field);return i&&t.field===tt?i.querySelector("input")??i:i}if(n<0)return null;const o=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${n}"]`);return Xr(o,t.field)}const Yr="__group__";function ot(e){return!nt(e)&&e!==Yr}const rt=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.field===t.field;function Rs(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>rt(n.anchor,t[o].anchor)&&rt(n.head,t[o].head))}function Mn(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:d}=n,c={top:e,bottom:e,left:t,right:t};if(!d)return c;const f=o[e],g=r[t],h=d.getSpanOrigin(f,g)??{rowId:f,field:g},x=i.get(h.rowId),C=l.get(h.field);if(x===void 0||C===void 0)return c;const p=Math.max(1,d.getRowSpan(h.rowId,h.field)),u=Math.max(1,d.getColSpan(h.rowId,h.field));return{top:x,bottom:Math.min(o.length-1,x+p-1),left:C,right:Math.min(r.length-1,C+u-1)}}function qs(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const d=c=>{c.top<n&&(n=c.top,l=!0),c.bottom>o&&(o=c.bottom,l=!0),c.left<r&&(r=c.left,l=!0),c.right>i&&(i=c.right,l=!0)};for(;l;){l=!1;for(let c=n;c<=o;c++)d(Mn(c,r,t)),i!==r&&d(Mn(c,i,t));for(let c=r+1;c<i;c++)d(Mn(n,c,t)),o!==n&&d(Mn(o,c,t))}return{top:n,bottom:o,left:r,right:i}}function Nn(e,t){const n=t.rowIndexById.get(e.anchor.id),o=t.rowIndexById.get(e.head.id),r=t.colIndexByField.get(e.anchor.field),i=t.colIndexByField.get(e.head.field);return n===void 0||o===void 0||r===void 0||i===void 0?null:{...qs({top:Math.min(n,o),bottom:Math.max(n,o),left:Math.min(r,i),right:Math.max(r,i)},t),anchorRow:n,anchorCol:r,headRow:o,headCol:i}}const In=e=>(e.bottom-e.top+1)*(e.right-e.left+1);function Xs(e,t,n,o,r,i){const{headRow:l,headCol:d,anchorRow:c,anchorCol:f,top:g,bottom:h,left:x,right:C}=e;let p=l,u=d;switch(t){case"ArrowRight":u=d>=f?C+1:d+1;break;case"ArrowLeft":u=d<=f?x-1:d-1;break;case"ArrowDown":p=l>=c?h+1:l+1;break;case"ArrowUp":p=l<=c?g-1:l-1;break;case"Home":u=0,n&&(p=0);break;case"End":u=i,n&&(p=r);break;case"PageUp":p=l-o;break;case"PageDown":p=l+o;break;default:return null}return p=Math.min(Math.max(p,0),r),u=Math.min(Math.max(u,0),i),p===l&&u===d?null:{row:p,col:u}}function Jr(e,t,n){return!e||t<e.top||t>e.bottom?null:{left:e.left,right:e.right,isTop:t===e.top,isBottom:t===e.bottom,bottomOffset:n?e.bottom-t:0}}const Ys=(e,t)=>e===t||!!e&&!!t&&e.left===t.left&&e.right===t.right&&e.isTop===t.isTop&&e.isBottom===t.isBottom&&e.bottomOffset===t.bottomOffset,_o=1,Qr=2,Zr=4,ei=8,ti=16;function Js(e,t,n,o){if(!e)return 0;const r=t+Math.max(1,n)-1;if(t<e.left||r>e.right)return 0;let i=_o;return e.isTop&&(i|=Qr),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(i|=Zr),t===e.left&&(i|=ei),r===e.right&&(i|=ti),i}function Qs(e,t,n){const o=(r,i,l)=>`${r} ${r===1?i:l}`;return`${o(e,"cell","cells")} selected, ${o(t,"row","rows")} by ${o(n,"column","columns")}`}const Zs=1e5,ea=e=>e.id,ni=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function ta(e,t,n,o){if(!e||n.length===0)return{cell:null,rowIndex:-1};const r=(n.find(c=>!nt(c.field))??n[0]).field,i=n.some(c=>c.field===e.field)?e.field:r;if(e.id===null)return{cell:i===e.field?e:{id:null,field:i},rowIndex:-1};const l=e.rowIndex;let d=l!==void 0&&t[l]&&o(t[l])===e.id?l:t.findIndex(c=>o(c)===e.id);return d===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(d=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:o(t[d]),field:i,rowIndex:d},rowIndex:d}):{cell:i===e.field?e:{...e,field:i},rowIndex:d}}function na(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:d,setKeyboardMode:c,sortModel:f,handleSort:g,handleSortAdd:h,multiSort:x=!1,isCellEditable:C,pagination:p,pageSize:u,virtualization:m,viewportRef:b,pinnedTopRowCount:w=0,getRowId:v=ea,rowMetaMap:E,onRowActivate:I,toggleRowExpansion:D,handleSelectAll:P,rowSelectionEnabled:F=!0,multipleRowSelectionEnabled:H=!0,pinCheckboxColumn:B=!0,pinExpandColumn:U=!0,rowHeight:_,getSpanOrigin:T,cellSelection:O}=e,[S,K]=s.useState(null),[j,Q]=s.useState(!1),$=s.useMemo(()=>ta(S,t,n,v),[S,t,n,v]),z=$.cell,Z=$.rowIndex,ie=s.useRef(!1),oe=s.useRef(!1),fe=s.useRef(!1),de=s.useRef(null),ge=s.useCallback(y=>{oe.current=!0,y.focus({preventScroll:!0}),oe.current=!1},[]),re=s.useCallback(()=>{const y=b.current;y&&!y.contains(y.ownerDocument.activeElement)&&ge(y)},[b,ge]),ae=s.useMemo(()=>n.find(y=>!nt(y.field))??n[0],[n]),ee=s.useCallback(()=>{if(o)return{id:null,field:tt};if(!ae)return null;const y=t[0];return y?{id:v(y),field:ae.field,rowIndex:0}:{id:null,field:ae.field}},[o,ae,t,v]),ne=s.useCallback((y,M)=>{const A=b.current;if(!A)return;const{cumulativeHeights:N,pinnedBottomHeight:L,columnMetrics:q}=m;if(y>=0&&ao(A,y-w,N,L,_),nt(M)){!(M===Jt||M===Qt&&U||M===tt&&B)&&A.scrollLeft>0&&(A.scrollLeft=0);return}if(!q)return;const{clientWidth:Y,scrollLeft:G}=A,{leftPinnedWidth:k,rightPinnedWidth:W,unpinnedAccWidths:R,unpinnedCols:X,totalSpecialsWidth:ue,pinnedSpecialsWidth:pe}=q,he=X.findIndex(be=>be.field===M);if(he===-1)return;const ve=ue+k+(he>0?R[he-1]:0),ye=ue+k+R[he],_e=G+pe+k,ke=G+Y-W;let le=G;ve<_e?le=Math.max(0,ve-pe-k):ye>ke&&(le=ye-Y+W),le!==G&&(A.scrollLeft=le)},[b,m,w,_,B,U]);s.useLayoutEffect(()=>{const y=b.current,M=!yo(de.current,z);if(de.current=z,!y||!z)return;const A=y.ownerDocument,N=A.activeElement;let L;if(N===y?L=!0:!N||N===A.body?L=ie.current:y.contains(N)?L=M:L=!1,!L)return;const q=So(y,z,Z);q?q.contains(N)||q.focus({preventScroll:!0}):N!==y&&ge(y)});const V=s.useCallback(()=>{fe.current=!0,c(!1)},[c]),J=s.useCallback(y=>{const M=y.currentTarget,A=y.relatedTarget,N=!(A instanceof Node&&M.contains(A)),L=fe.current;if(fe.current=!1,ie.current=!0,Q(!0),oe.current)return;if(y.target===M){if(!N)return;if(L||c(!0),z){const G=So(M,z,Z);G?G.focus({preventScroll:!0}):ne(Z,z.field);return}const Y=ee();Y&&(K(G=>G??Y),ne(Y.rowIndex??-1,Y.field));return}const q=js(y.target,M,t,v);q&&!yo(q,z)&&K(q)},[z,Z,ee,ne,c,t,v]),te=s.useCallback(y=>{const M=y.relatedTarget;M instanceof Node&&y.currentTarget.contains(M)||(ie.current=!1,fe.current=!1,Q(!1),c(!1))},[c]),se=s.useCallback(y=>{const M=y.currentTarget,A=Us(y.target,M);if(A==="foreign"||(c(!0),y.nativeEvent?.isComposing||y.keyCode===229))return;const{key:N}=y,L=N===" "||N==="Spacebar",q=!!d.editingCell,Y=(ce,we)=>{const Ce=n[we];!Ce||ce<-1||ce>=t.length||(K(ce===-1?{id:null,field:Ce.field}:{id:v(t[ce]),field:Ce.field,rowIndex:ce}),ne(ce,Ce.field))};if(!z){if(!ni.has(N))return;const ce=ee();if(!ce)return;y.preventDefault(),K(ce),ne(ce.rowIndex??-1,ce.field);return}const{id:G,field:k}=z,W=Z,R=n.findIndex(ce=>ce.field===k),X=n.filter(ce=>nt(ce.field)).length,ue=ce=>Je(ce,E),pe=(ce,we,Ce)=>{const Ee=n[Ce];return nt(Ee.field)?!1:yr({row:ce,field:Ee.field,value:Le(ce,Ee.field,Ee),colDef:Ee,rowIndex:we,colIndex:Ce-X,rowMeta:E?.get(v(ce))},C)},he=ce=>{let we=W,Ce=R;const Ee=(t.length+1)*n.length;for(let Ge=0;Ge<Ee;Ge++){if(Ce+=ce,Ce>=n.length?(Ce=0,we++):Ce<0&&(Ce=n.length-1,we--),we<0||we>=t.length)return null;const Oe=t[we];if(!T?.(v(Oe),n[Ce].field)&&pe(Oe,we,Ce))return{r:we,c:Ce}}return null};if(q){if(N==="Enter")y.preventDefault(),d.stopCellEdit();else if(N==="Escape")y.preventDefault(),d.stopCellEdit({cancel:!0});else if(N==="Tab"&&G!==null){const ce=he(y.shiftKey?-1:1);ce&&(y.preventDefault(),d.stopCellEdit(),Y(ce.r,ce.c))}return}if(N==="Escape"&&O?.collapseSelection()){y.preventDefault();return}if(N==="Tab"||N==="Escape"||A==="control"&&(N==="Enter"||L))return;if((y.ctrlKey||y.metaKey)&&(N==="a"||N==="A")){if(O){O.selectAllCells()&&y.preventDefault();return}if(!F||!H||!P)return;y.preventDefault(),P(!0);return}if(G===null){if(N==="Enter"||L){if(y.preventDefault(),k===tt){So(M,z,-1)?.click();return}const ce=n[R];if(!ce||nt(k)||ce.sortable===!1)return;const we=f.find(Ee=>Ee.field===k),Ce=we?we.sort==="asc"?"desc":null:"asc";(x||y.shiftKey)&&h?h(k,Ce):g(k,Ce);return}}else if(N==="Enter"||L){y.preventDefault();const ce=t[W];if(k===tt){i(G,!r.has(G));return}if(k===Qt){y.shiftKey||l(G);return}if(L){y.shiftKey&&F&&!ue(G)&&i(G,!r.has(G));return}if(k===Jt)return;if(pe(ce,W,R)){d.startCellEdit({id:G,field:k,value:Le(ce,k,n[R])});return}if(D&&E?.get(G)?.hasChildren){D(G);return}I?.({row:ce,id:G,rowIndex:W});return}if(y.altKey&&(N==="ArrowRight"||N==="ArrowLeft")&&D&&G!==null){y.preventDefault();const ce=E?.get(G);ce?.hasChildren&&!!ce.isExpanded!=(N==="ArrowRight")&&D(G);return}if(!ni.has(N))return;y.preventDefault();const ve=t.length-1,ye=n.length-1,_e=y.ctrlKey||y.metaKey,ke=p?u:10;if(O&&y.shiftKey&&G!==null&&ot(k)&&O.extendSelection(N,_e,ke,z))return;const le=(ce,we)=>{switch(N){case"ArrowRight":return we+1>ye?{r:ce+1,c:0}:{r:ce,c:we+1};case"ArrowLeft":return we-1<0?{r:ce-1,c:ye}:{r:ce,c:we-1};case"ArrowDown":return{r:ce+1,c:we};case"ArrowUp":return{r:ce-1,c:we};case"Home":return{r:_e?-1:ce,c:0};case"End":return{r:_e?ve:ce,c:ye};case"PageUp":return{r:Math.max(-1,ce-ke),c:we};default:return{r:Math.min(ve,ce+ke),c:we}}},be=({r:ce,c:we})=>ce>=-1&&ce<=ve&&we>=0&&we<=ye,Me=({r:ce,c:we})=>ce>=0?T?.(v(t[ce]),n[we].field)??null:null;let Se=le(W,R);if(N.startsWith("Arrow"))for(let ce=be(Se)?Me(Se):null;ce&&ce.rowId===G&&ce.field===k;ce=be(Se)?Me(Se):null)Se=le(Se.r,Se.c);if(!be(Se))return;const me=Me(Se);if(me){const ce=t.findIndex(Ce=>v(Ce)===me.rowId),we=n.findIndex(Ce=>Ce.field===me.field);ce!==-1&&we!==-1&&(Se={r:ce,c:we})}Se.r===W&&Se.c===R||Y(Se.r,Se.c)},[z,Z,t,n,d,r,i,l,c,f,g,h,x,C,p,u,E,I,D,P,F,H,ee,ne,T,v,O]);return{focusedCell:z,setFocusedCell:K,viewportTabIndex:j?-1:0,ensureGridFocus:re,handleFocus:J,handleBlur:te,handleKeyDown:se,handleMouseDownCapture:V}}const oa=[],ra={rowFields:[],columnFields:[],valueFields:[]},oi=100;function ia(e){return!e||e.length===0||e.includes(oi)?oi:e[0]}function la(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:d,columnVisibilityModel:c,onColumnVisibilityModelChange:f,pinnedColumns:g,onPinnedColumnsChange:h,pivotModel:x,onPivotModelChange:C,paginationModel:p,onPaginationModelChange:u,pageSizeOptions:m,rowSelectionModel:b,onRowSelectionModelChange:w,density:v,cellSelectionModel:E,onCellSelectionModelChange:I}=e,[D,P]=s.useState(()=>t?.sorting?.sortModel??[]),F=n!==void 0,H=F?n:D,B=s.useCallback(me=>{F||P(me),o?.(me)},[F,o]),[U,_]=s.useState(()=>t?.filter?.filterModel??{items:[]}),T=r!=null,O=T?r:U,S=s.useCallback(me=>{T||_(me),i?.(me)},[T,i]),K=l!==void 0,[j,Q]=s.useState(()=>l??{}),$=JSON.stringify(K?l:j),z=s.useMemo(()=>JSON.parse($),[$]),Z=s.useCallback(me=>{K||Q(me),d?.(me)},[K,d]),ie=c!==void 0,[oe,fe]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),de=ie?c:oe,ge=s.useCallback(me=>{ie||fe(me),f?.(me)},[ie,f]),re=g!==void 0,[ae,ee]=s.useState(()=>t?.columns?.pinnedColumns??{}),ne=re?g:ae,V=s.useCallback(me=>{re||ee(me),h?.(me)},[re,h]),[J,te]=s.useState(()=>x??ra),se=x??J,y=s.useCallback(me=>{te(me),C?.(me)},[C]),M=p!==void 0,[A,N]=s.useState(()=>t?.pagination?.paginationModel??p??{page:0,pageSize:ia(m)}),L=M?p:A,q=s.useCallback(me=>{M||N(me),u?.(me)},[M,u]),Y=b!==void 0,[G,k]=s.useState([]),W=Y?b:G,R=s.useMemo(()=>new Set(W),[W]),X=s.useRef(null);s.useLayoutEffect(()=>{X.current=null});const ue=s.useCallback(()=>X.current,[]),pe=s.useCallback(me=>{X.current=me,Y||k(me),w?.(me)},[Y,w]),[he]=s.useState(()=>t?.density?.density??"standard"),ve=v??he,ye=E!==void 0,[_e,ke]=s.useState(oa),le=ye?E:_e,be=s.useRef(null);s.useLayoutEffect(()=>{be.current=null});const Me=s.useCallback(()=>be.current,[]),Se=s.useCallback((me,ce)=>{be.current=me,ye||ke(me),I?.(me,{reason:ce})},[ye,I]);return{sortModel:H,isSortControlled:F,setInternalSortModel:P,handleSortModelChange:B,filterModel:O,isFilterControlled:T,handleFilterModelChange:S,aggregationModel:z,handleAggregationModelChange:Z,columnVisibilityModel:de,handleColumnVisibilityModelChange:ge,pinnedColumns:ne,handlePinnedColumnsChange:V,currentPivotModel:se,handlePivotModelChange:y,effectivePaginationModel:L,handlePaginationModelChange:q,rowSelectionModel:W,selectedRowIds:R,isSelectionControlled:Y,setInternalRowSelectionModel:k,handleRowSelectionModelChange:pe,getPendingRowSelectionModel:ue,density:ve,cellSelectionModel:le,handleCellSelectionModelChange:Se,getPendingCellSelectionModel:Me}}const ri=s.createContext(null),sa=52,aa=56,ca=32,da=72;function Pn(e){if(e===void 0)return;const t=/^(\d+(?:\.\d+)?)(?:\s*px)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);return n>0?n:void 0}function ua(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(ri)?.grid;let i;return o==="compact"?i=Pn(r?.rowHeightCompact)??ca:o==="comfortable"?i=Pn(r?.rowHeightComfortable)??da:i=t??Pn(r?.rowHeightStandard)??sa,{rowHeight:i,headerHeight:n??Pn(r?.headerHeight)??aa}}function Tn(e){return e>=1?Math.floor(e):1}function ko(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/Tn(t)))}function fa(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function ii(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function li(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function ga(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:d,paginationMode:c,effectivePaginationModel:f,pinnedRows:g,getRowId:h,columnLookup:x,hierarchyField:C}=e,p=s.useMemo(()=>n?n.getVisibleRows({labelField:C})||[]:o==="server"?t:po(t,r,x),[t,r,n,C,o,x]),u=s.useMemo(()=>n?o==="server"?t:po(t,r,x):p,[n,p,o,t,r,x]),{top:m,center:b,bottom:w}=s.useMemo(()=>n?{top:[],center:p,bottom:[]}:ss(p,g,h),[p,g,n,h]),v=s.useMemo(()=>n||l==="server"?b:Ls(b,i,x,h),[b,i,n,l,x,h]),E=d&&c!=="server",I=Tn(f.pageSize),D=E?li(f.page,ko(v.length,I)):f.page,P=s.useMemo(()=>{if(!E)return v;const H=D*I;return v.slice(H,H+I)},[v,E,D,I]),F=s.useMemo(()=>{const H=d?P:v;return[...m,...H,...w]},[m,P,v,w,d]);return{filteredRows:p,dataRows:u,pinnedTopRows:m,unpinnedRows:b,pinnedBottomRows:w,sortedUnpinnedRows:v,paginatedUnpinnedRows:P,currentPage:D,allRenderableRows:F}}function pa(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:d,hasDetailPanel:c,checkboxSelection:f,pinCheckboxColumn:g,pinExpandColumn:h,overscanRows:x=5}=e;return s.useMemo(()=>{const{unpinnedAccWidths:C,unpinnedColsWithWidth:p,leftPinnedCols:u,rightPinnedCols:m,totalWidth:b,leftWidth:w,rightWidth:v,unpinnedTotalWidth:E,systemColumnsWidth:I,cumulativeHeights:D,pinnedTopHeight:P,pinnedBottomHeight:F,unpinnedRowsHeight:H,rowHeights:B,unpinnedRowsLength:U}=t,_=r||1e3,T=l?P+H+F+50:i||600,O=6,S=Math.max(0,o-w),K=o+_-w;let j=0,Q=p.length-1,$=0,z=C.length-1;for(;$<=z;){const te=$+z>>>1;C[te]<S?$=te+1:z=te-1}j=Math.max(0,$-O);for(let te=j;te<C.length;te++){if((te===0?0:C[te-1])>K){Q=Math.min(p.length-1,te+O);break}Q=Math.min(p.length-1,te+O)}const Z=j>0?C[j-1]:0,ie=E-C[Q],oe=[...u,...Z>0?[{field:"__spacer_left__",width:Z,isSpacer:!0}]:[],...p.slice(j,Q+1),...ie>0?[{field:"__spacer_right__",width:ie,isSpacer:!0}]:[],...m],de=_>0&&b>_?16:0,ge=P+H+F+de+2;let re=0,ae=U-1,ee=0,ne=0,V=D.length-1;for(;ne<=V;){const te=ne+V>>>1;D[te]<n?ne=te+1:V=te-1}re=Math.max(0,ne-x),ee=re>0?D[re-1]:0;for(let te=re;te<D.length;te++)if(D[te]>=n+T){ae=Math.min(U-1,te+x);break}const J=(d?48:0)+(c&&h?48:0)+(f&&g?48:0);return{renderContext:{firstRowIndex:re,lastRowIndex:ae,firstColumnIndex:j,lastColumnIndex:Q},offsetTop:ee,offsetLeft:0,totalHeight:ge,pinnedTopHeight:P,pinnedBottomHeight:F,totalWidth:b,rowHeights:B,cumulativeHeights:D,virtualColumns:oe,columnMetrics:{leftPinnedWidth:w,rightPinnedWidth:v,unpinnedAccWidths:C,unpinnedCols:p,totalSpecialsWidth:I,pinnedSpecialsWidth:J}}},[t,n,o,r,i,l,d,c,f,g,h,x])}const Eo="application/x-ogx-row",Mo="application/x-ogx-column";function si(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function Ln(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function ai(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function ha(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,d]=s.useState(null),c=s.useRef(()=>{}),f=s.useCallback(()=>{c.current(),c.current=()=>{},i(null),d(null)},[]);s.useEffect(()=>()=>c.current(),[]);const g=s.useCallback(C=>p=>{if(!o){if(!t.some(u=>u.field===C)){p.preventDefault();return}c.current(),c.current=ai(p.currentTarget,f),i(C),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",si(p,Mo,C))}},[t,o,f]),h=s.useCallback(C=>p=>{if(!(o||r===null)){if(!Ln(p,Mo)){f();return}p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),d(C)}},[r,o,f]),x=s.useCallback(C=>p=>{if(p.preventDefault(),o||r===null||!Ln(p,Mo)){f();return}const u=t.findIndex(b=>b.field===r),m=t.findIndex(b=>b.field===C);f(),!(u===-1||m===-1||u===m)&&n?.({column:t[u],oldIndex:u,targetIndex:m})},[t,r,o,n,f]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:g,onDragOver:o?void 0:h,onDragEnd:o?void 0:f,onDrop:o?void 0:x}}function No({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){return a.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",type:"button",tabIndex:o,children:n==="plus-minus"?a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:a.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function ma({renderFn:e}){"use no memo";return a.jsx(a.Fragment,{children:e()})}function wa(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>Object.is(n,t[o])):Object.is(e,t)}class ht extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,n){return wa(t.resetKey,n.resetKey)?null:n.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,n.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):a.jsx(ma,{renderFn:this.props.renderFn})}}function xa(e,t,n){if(!t||!n)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const o=l=>n.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>o(l.row)?l.value:r(l):void 0,valueFormatter:l=>o(l.row)?kn(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function ci(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=et(i.field,t);return l==="left"?n.indexOf(i.field)-n.length:l==="right"?1+o.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const Fn=e=>e.formattedValue??e.value;function di(e,t,n){const o=e.renderCell;if(!o)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!n){const l=o(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=o(t)}catch(l){return{useDefault:!1,content:a.jsx(ht,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:a.jsx(ht,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function ba(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return Fn(e);if(o.isGroupFooter)return null;const r=o.descendantCount;if(t&&o.hasChildren){const i=o.groupLabel??`${o.groupingField}: ${String(o.groupingValue)}`;return a.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return n?a.jsxs("div",{className:"ogx__group-cell-content",children:[o.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):Fn(e)}const Ca=e=>e.id;function va(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:d,onColumnOrderChange:c,onColumnOrderModelChange:f,disableColumnReorder:g,pivotMode:h,checkboxSelection:x,hasDetailPanel:C,rowReordering:p,initialState:u,setColumns:m,pinnedColumns:b,getRowId:w=Ca,aggregationModel:v,groupingRows:E}=e,I=s.useMemo(()=>t.map(V=>V.field),[t]),[D,P]=s.useState(()=>u?.columns?.columnOrder??null),F=h?I.join("\0"):"",[H,B]=s.useState(null),U=H&&H.key===F?H.order:I,T=h?U:d??(D??I),O=s.useCallback(V=>{if(h){B(J=>{const te=J&&J.key===F?J.order:I;return{key:F,order:typeof V=="function"?V(te):V}});return}P(J=>typeof V=="function"?V(J??I):V)},[h,F,I]),S=s.useCallback(V=>h&&V.hideable===!1||l[V.field]!==!1,[h,l]),K=s.useMemo(()=>{if(!n)return;const V=new Map(T.map((y,M)=>[y,M])),J=y=>V.get(y.field)??t.indexOf(y),te=[...t].sort((y,M)=>J(y)-J(M));return(ci(te.filter(y=>l[y.field]!==!1),b)[0]??t[0])?.field},[n,T,t,l,b]),j=s.useMemo(()=>{if(!n)return t;const V=o?E:void 0;return t.map(J=>{const te=xa(J,v?.[J.field],V);return J.field===K?{...J,...te,renderCell:se=>{const y=se.rowMeta,M=y?.treeDepth??0,A=!!y?.hasChildren,N=!!y?.isExpanded,L=di(J,se,!0),q=L.useDefault?ba(se,o,r):L.content;return a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:M*24,width:"100%",height:"100%"},children:[a.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:A?"pointer":"default",flexShrink:0},children:A?a.jsx("div",{onClick:Y=>{Y.stopPropagation(),Y.preventDefault(),i?.toggleExpansion(w(se.row))},onMouseDown:Y=>{Y.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:a.jsx(No,{isExpanded:N,tabIndex:-1,onClick:Y=>{Y.stopPropagation(),Y.preventDefault(),i?.toggleExpansion(w(se.row))}})}):null}),a.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:q})]})}}:{...J,...te,renderCell:se=>{const y=se.rowMeta;if(!y?.isGroupRow)return J.renderCell?J.renderCell(se):Fn(se);const M=di(J,se,!1);return M.useDefault?J.field===y.groupingField&&!y.isGroupFooter||se.value==null?null:Fn(se):M.content}}})},[t,n,o,r,i,K,w,v,E]),[Q,$]=s.useState(()=>u?.columns?.columnWidths??{}),z=s.useCallback((V,J)=>{$(te=>({...te,[V]:J}))},[]);s.useEffect(()=>{m(t)},[t,m]);const Z=s.useMemo(()=>{const V=new Map(T.map((J,te)=>[J,te]));return[...j].sort((J,te)=>{const se=V.get(J.field)??j.indexOf(J),y=V.get(te.field)??j.indexOf(te);return se-y})},[j,T]),ie=s.useMemo(()=>Z.filter(S),[Z,S]),oe=s.useCallback((V,J)=>{(h||!d)&&O(V),J&&c?.(J),h||f?.(V)},[h,d,O,c,f]),fe=s.useCallback((V,J)=>{const te=Z.map(y=>y.field),[se]=te.splice(V,1);te.splice(J,0,se),oe(te,{column:Z[V],oldIndex:V,targetIndex:J})},[Z,oe]),de=ha({columns:Z,onColumnOrderChange:s.useCallback(({oldIndex:V,targetIndex:J})=>fe(V,J),[fe]),disableColumnReorder:g}),ge=s.useCallback((V,J)=>{const te=Z.findIndex(y=>y.field===V),se=Z.findIndex(y=>y.field===J);te===-1||se===-1||te===se||fe(te,se)},[Z,fe]),re=s.useCallback(()=>{oe(I)},[oe,I]),ae=s.useMemo(()=>ci(ie,b),[ie,b]),ee=s.useMemo(()=>{const V=[];return p&&V.push({field:Jt,sortable:!1,editable:!1}),C&&V.push({field:Qt,sortable:!1,editable:!1}),x&&V.push({field:tt,sortable:!1,editable:!1}),[...V,...ae]},[ae,x,C,p]),ne=s.useMemo(()=>new Map(ae.map((V,J)=>[V.field,J])),[ae]);return{effectiveColumns:j,hierarchyField:K,orderedColumns:Z,visibleOrderedColumns:ie,renderOrderedColumns:ae,navigationColumns:ee,columnIndexMap:ne,columnWidths:Q,effectiveColumnOrder:T,setInternalColumnOrder:O,columnReorderHandlers:de,moveColumn:ge,resetColumnOrder:re,handleColumnResize:z}}const ya=e=>e.id;function Sa(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:d=ya}=e;return s.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:f}=t,g=l?r:i,h=n.length,x=n.map((v,E)=>({row:v,id:d(v),rowIndex:E,pinned:"top"})),C=o.map((v,E)=>({row:v,id:d(v),rowIndex:h+g.length+E,pinned:"bottom"})),p=Math.max(0,c),u=Math.min(g.length,f+1),m=g.slice(p,u).map((v,E)=>({row:v,id:d(v),rowIndex:h+p+E})),b=[...x,...m,...C],w=new Set;return b.filter(v=>w.has(v.id)?!1:(w.add(v.id),!0))},[t,n,o,r,i,l,d])}const _a=100;function ui(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=_a?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function ka(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Ea(e){const{onRowsScrollEnd:t,overscanRowCount:n=3,rowCount:o=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),d=s.useRef(null),c=s.useRef(null),f=s.useRef(null),g=s.useRef(!0),h=s.useRef(t),[x,C]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{h.current=t},[t]),s.useEffect(()=>()=>{d.current!==null&&cancelAnimationFrame(d.current),c.current!==null&&clearTimeout(c.current)},[]);const p=s.useCallback(b=>{const w=ui(b);if(!w){g.current=!0;return}if(!g.current)return;const v=h.current;v&&(g.current=!1,v(w))},[]),u=s.useCallback(b=>{const w=b.currentTarget,v=performance.now(),E=Math.abs(w.scrollTop-l.current.scrollTop)+Math.abs(w.scrollLeft-l.current.scrollLeft),I=v-l.current.time,D=I>0?E/I:0,P=w.scrollTop!==l.current.scrollTop;l.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,time:v},i.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,velocity:D},d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;const{scrollTop:F,scrollLeft:H,velocity:B}=i.current;C({scrollTop:F,scrollLeft:H,velocityOverscan:ka(B)})}),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,C(F=>F.velocityOverscan===0?F:{...F,velocityOverscan:0})},200),P&&p(w)},[p]);s.useEffect(()=>{g.current=!0;const b=f.current;!b||r||o<=0||b.clientHeight===0||p(b)},[o,r,p]);const m=s.useCallback(b=>{if(f.current=b,!b)return;const{scrollTop:w,scrollLeft:v}=i.current;if(w===0&&v===0)return;b.scrollTop=w,b.scrollLeft=v;const E={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft};(E.scrollTop!==w||E.scrollLeft!==v)&&(i.current={...i.current,...E},l.current={...l.current,...E},C(I=>({...I,...E})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,n),handleScroll:u,attachViewport:m}}function Ma(e){const t=s.useRef(null);return s.useCallback(n=>{if(t.current?.disconnect(),t.current=null,!n||typeof ResizeObserver>"u")return;const o=new ResizeObserver(r=>{for(const i of r){const{width:l,height:d}=i.contentRect;e(l,d)}});o.observe(n),t.current=o},[e])}function Na(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,attachViewport:c}=Ea(o),f=Ma(t),g=s.useCallback(h=>{n.current=h,f(h),c(h)},[n,f,c]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,setViewportElement:g}}function Ia(){const[e,t]=s.useState(()=>new Map),n=s.useCallback((o,r)=>{t(i=>{if(i.get(o)===r)return i;const l=new Map(i);return l.set(o,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:n}}function Pa(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),d=n??i,c=s.useMemo(()=>fs(d,r),[d,r]),f=s.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const C=new Set(d);C.has(x)?C.delete(x):C.add(x),n===void 0&&l(C),o?.(C)},[d,r,n,o]),{detailPanelHeights:g,reportDetailPanelHeight:h}=Ia();return{hasDetailPanel:t,expandedRowIds:c,handleDetailPanelToggle:f,detailPanelHeights:g,reportDetailPanelHeight:h}}const Ta=new Set(["__group__"]),Zt=e=>!Ta.has(e);function fi(e){return Object.keys(e).every(Zt)?e:Object.fromEntries(Object.entries(e).filter(([n])=>Zt(n)))}function La(e){const t={...e};return e.left&&(t.left=e.left.filter(Zt)),e.right&&(t.right=e.right.filter(Zt)),t}function Fa(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:d,pinnedColumns:c,density:f}=e,g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t});const h=s.useRef(null);s.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:fi(i),columnOrder:l.filter(Zt),columnVisibilityModel:fi(d),pinnedColumns:La(c)},density:{density:f}},C=JSON.stringify(x);C!==h.current&&(h.current=C,g.current(x))},[n,o,r,i,l,d,c,f])}const Aa=200,Oa=2e3,Da=178e5;function $a(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:d=!1,scrollHeight:c=0,listViewWithoutColumn:f=!1,listViewRowCount:g=0}=e,h=s.useRef(!1),x=s.useRef(!1),C=s.useRef(!1),p=s.useRef(!1),u=s.useRef(!1),m=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||m.current||g<=Oa||(m.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${g} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[g]),s.useEffect(()=>{process.env.NODE_ENV==="production"||u.current||!f||(u.current=!0,console.warn("[OpenGridX] `listView` is set without a `listViewColumn`, so the grid view is shown instead. Pass `listViewColumn` to render list items. See docs/features/list-view.md."))},[f]),s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||!d||(C.current=!0,console.warn("[OpenGridX] `pinnedRows` is ignored while treeData or rowGroupingModel is active: the rows stay in their place in the hierarchy. See docs/features/pinning.md."))},[d]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||c<=Da||(p.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(c)}px tall. Browsers cap element heights (about 17.9M px in Firefox, 33.5M px in Chrome and Safari), so the last rows may not be reachable by scrolling. Use pagination, server-side or infinite loading, or a smaller rowHeight. See docs/features/virtualization.md.`))},[c]),s.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||t&&n&&(h.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,n]),s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||o||r>0&&l>Aa&&i>=l&&r>=c&&(x.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off: the grid fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[o,r,i,l,c])}function Ga(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let gi=!1;function Wa(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||gi)return;const t=e.current;!t||!Ga(t)||(gi=!0,console.warn("[OpenGridX] The grid stylesheet is not loaded, so the grid is unstyled and renders every row (its viewport does not scroll). Add `import '@opencorestack/opengridx/styles'` once in your app root. See README.md, Getting Started."))},[e])}function An(e,t,n,o){if(n&&o)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>n?r.add(i):r.delete(i)),Array.from(r)}function Ha(e,t,n){return n?e.has(t)?[]:[t]:An(e,[t],!e.has(t),!1)}function pi(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function Ba(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(h=>{pi(t,h)||n(h)},[t,n]),l=s.useCallback((h,x)=>{i(An(t,[h],x,o))},[i,t,o]),d=s.useCallback(h=>{i(Ha(t,h,o))},[i,t,o]),c=s.useCallback(h=>{i(An(t,r,h,!1))},[i,t,r]),{allSelected:f,someSelected:g}=s.useMemo(()=>{let h=0;for(const C of r)t.has(C)&&h++;const x=r.length>0&&h===r.length;return{allSelected:x,someSelected:!x&&h>0}},[r,t]);return{toggleRow:l,clickRow:d,selectAll:o?void 0:c,allSelected:f,someSelected:g}}function za(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:d,isHierarchyEnabled:c,rowMetaMap:f,activeHierarchyHandlers:g,onRowClick:h}=e,x=s.useMemo(()=>{const w=t.map(n);return o?w.filter(v=>v!==Et):w},[t,n,o]),C=Ba({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),{clickRow:p,toggleRow:u}=C,m=s.useCallback(w=>{const{id:v}=w,E=c?f.get(v):void 0;if(E?.isGroupRow){E.hasChildren&&g?.toggleExpansion(v);return}h?.(w),!d&&!Je(v,f)&&p(v)},[c,g,h,f,d,p]),b=s.useCallback((w,v)=>{Je(w,f)||u(w,v)},[f,u]);return{rowSelection:C,handleRowClick:m,handleSelectionChange:b}}const hi=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Va(e){const{selectedRowIds:t,rowsLookup:n,rowMetaMap:o,enabled:r,onSelectionModelChange:i}=e,l=s.useMemo(()=>{if(!r||t.size===0)return t;let f=!1;const g=new Set;for(const h of t)n.has(h)||o.has(h)?g.add(h):f=!0;return f?g:t},[r,t,n,o]),d=s.useRef(i);s.useLayoutEffect(()=>{d.current=i});const c=s.useRef(null);return s.useEffect(()=>{if(l===t){c.current=null;return}const f=`${hi(t)}|${hi(l)}`;c.current!==f&&(c.current=f,d.current(Array.from(l)))},[l,t]),l}function Io(e,t,n,o){return o?Fs(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function Ka(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(Io(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(Io(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function Ua(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:n,pinnedColumns:o,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:o});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:o}});const l=s.useCallback(c=>{const f={...i.current.columnVisibilityModel,[c]:!1};i.current={...i.current,columnVisibilityModel:f},n(f)},[n]),d=s.useCallback((c,f)=>{const g=as(i.current.pinnedColumns,c,f);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:d}}function ja(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=t.current,r=()=>n.current;o.getSortModel=()=>r().sortModel,o.sortColumn=(c,f)=>{const{sortModel:g,multiSort:h,onSortModelChange:x}=r(),C=Io(g,c,f,h);n.current={...r(),sortModel:C},x(C)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=c=>{n.current={...r(),filterModel:c},r().onFilterModelChange(c)};const i=c=>{n.current={...r(),paginationModel:c},r().onPaginationModelChange(c)};o.setPage=c=>i({...r().paginationModel,page:c}),o.setPageSize=c=>i({...r().paginationModel,pageSize:c,page:0});const l=()=>{const c=r().getPendingRowSelectionModel?.();return c?new Set(c):r().selectedRowIds},d=(c,f)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:h,isSyntheticRowId:x}=r(),C=x?c.filter(m=>!x(m)):c;if(C.length===0)return;const p=l(),u=An(p,C,f,g);pi(p,u)||(n.current={...r(),selectedRowIds:new Set(u)},h(u))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(c,f=!0)=>d([c],f),o.selectRows=(c,f=!0)=>d(c,f),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns},[t])}const mi="\0";function Ra(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(mi);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(mi))o[r]=!1;return bo(e,o)},[e,n])}function qa({paginationModel:e,currentPage:t,enabled:n,onPaginationModelChange:o}){const r=s.useRef({paginationModel:e,onPaginationModelChange:o});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:o}});const i=e.page,l=s.useRef(null);s.useEffect(()=>{if(!n)return;if(t===i){l.current=null;return}const d=`${i}>${t}`;if(l.current===d)return;l.current=d;const{paginationModel:c,onPaginationModelChange:f}=r.current;f({...c,page:t})},[n,t,i])}function Xa(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),l=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),d=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),c=s.useCallback(()=>t(!1),[]),f=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function g(x){r.current&&!r.current.contains(x.target)&&o(!1)}function h(x){x.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",h)}},[n]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:c,standalonePanelOpen:n,closeStandalonePanel:f,standalonePanelRef:r,openColumnsPanel:d}}const wi=s.createContext(null);function Ya(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function Ja({render:e,toolbarProps:t}){"use no memo";return a.jsx(a.Fragment,{children:e(t)})}function Qa({component:e,toolbarProps:t}){if(Ya(e))return a.jsx(Ja,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return a.jsx(n,{...t})}const xi=48;function Za({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:d,pinCheckboxColumn:c=!0,pinExpandColumn:f=!0,pinnedColumns:g,loading:h=!1}){const x=s.useMemo(()=>to(e,o,g,i,c,l,f,d),[e,o,g,i,c,l,f,d]),{lastLeft:C,firstRight:p}=s.useMemo(()=>no(e,g),[e,g]),u=d?xi:0,m=u+(l&&f?xi:0),b=(w,v,E)=>a.jsx("div",{className:`ogx__aggregation-spacer${v?" ogx__aggregation-spacer--pinned":""}`,style:v?{left:E}:void 0,"aria-hidden":"true"},w);return a.jsxs("div",{className:`ogx__aggregation-footer${h?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":h||void 0,style:{minHeight:`${r}px`},children:[d&&b("__reorder_col__",!0,0),l&&b("__expand_col__",f,u),i&&b("__checkbox_col__",c,m),e.map(w=>{if(w.isSpacer){const U=typeof w.width=="number"?w.width:0;return a.jsx("div",{style:{width:U,minWidth:U,flexShrink:0},"aria-hidden":"true"},w.field)}const v=t[w.field],E=v&&uo(w,v)?v:void 0,I=n[w.field],D=ft(w,o,120),P=et(w.field,g),F=P?x[w.field]:void 0,H=["ogx__aggregation-cell",P==="left"&&"ogx__aggregation-cell--pinned-left",P==="right"&&"ogx__aggregation-cell--pinned-right",P==="left"&&w.field===C&&"ogx__aggregation-cell--pinned-left-last",P==="right"&&w.field===p&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),B={width:D,minWidth:D,maxWidth:D,textAlign:w.align||"left"};return P==="left"&&F!==void 0&&(B.left=F),P==="right"&&F!==void 0&&(B.right=F),a.jsx("div",{className:H,role:"gridcell",style:B,children:E?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"ogx__aggregation-label",children:E}),a.jsx("span",{className:"ogx__aggregation-value",children:kn(I,E,w,n)})]}):null},w.field)})]})}function ec({noRowsLabel:e,width:t,overlay:n}){return n?a.jsx("div",{className:"ogx__empty",style:{width:t},children:n}):a.jsxs("div",{className:"ogx__empty",style:{width:t},children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),a.jsx("span",{children:e})]})}function bi({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const Ci=Number.MAX_SAFE_INTEGER,tc="An unexpected error occurred while loading the data.";function vi(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:tc}function nc({error:e,onRetry:t}){if(!e)return null;const n=vi(e);return a.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[a.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:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),a.jsx("div",{className:"ogx-error-overlay__message",children:n}),t&&a.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}function oc(e,t){typeof e=="function"?e(t):e&&(e.current=t)}const en=({indeterminate:e=!1,label:t,className:n="",inputRef:o,...r})=>{const i=s.useRef(null),l=s.useCallback(c=>{i.current=c,oc(o,c)},[o]);s.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const d=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",n].filter(Boolean).join(" ");return a.jsxs("label",{className:d,children:[a.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),a.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&a.jsx("span",{className:"ogx-checkbox__label",children:t})]})},yi=50;function Po(e,t,n,o){const r=Math.min(n??yi,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const rc=16;function ic(e){e.preventDefault(),e.stopPropagation()}function lc(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function sc(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:d="end"}=e,[c,f]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>()=>{g.current=null},[]);const h=s.useCallback((w,v)=>{const E=v-w.startX,I=w.startWidth+(d==="start"?-E:E);return Po(I,w.startWidth,i,l)},[d,i,l]),x=s.useCallback(w=>{if(w.button===0){w.stopPropagation(),g.current={pointerId:w.pointerId,startX:w.clientX,startWidth:n,lastUpdate:0,moved:!1},f(!0);try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}}},[n]),C=s.useCallback(w=>{const v=g.current;if(!v||w.pointerId!==v.pointerId||(w.clientX!==v.startX&&(v.moved=!0),!v.moved))return;const E=Date.now();E-v.lastUpdate>=rc&&(v.lastUpdate=E,o(t,h(v,w.clientX)))},[t,o,h]),p=s.useCallback((w,v)=>{const E=g.current;!E||w.pointerId!==E.pointerId||(g.current=null,f(!1),(E.moved||w.clientX!==E.startX)&&(lc(),v&&o(t,h(E,w.clientX))))},[t,o,h]),u=s.useCallback(w=>{if(w.key==="Enter"&&r){w.preventDefault(),w.stopPropagation(),r(t);return}if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault(),w.stopPropagation();const v=(w.shiftKey?50:10)*(w.key==="ArrowRight"?1:-1);o(t,Po(n+v,n,i,l))},[t,n,o,r,i,l]),m=s.useCallback(w=>{w.preventDefault(),w.stopPropagation(),r?.(t)},[t,r]),b=["ogx-column-resize-handle",d==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return a.jsx("div",{className:b,onPointerDown:x,onMouseDown:ic,onPointerMove:C,onPointerUp:w=>p(w,!0),onPointerCancel:w=>p(w,!1),onClick:w=>w.stopPropagation(),onDragStart:w=>{w.preventDefault(),w.stopPropagation()},onDoubleClick:m,onKeyDown:u,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(n),"aria-valuemin":Math.round(Math.min(i??50,n)),"aria-valuemax":l,tabIndex:-1,children:a.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Si(e){if(!e)return 0;let t=0;const n=(o,r)=>{t=Math.max(t,r);for(const i of o.children)typeof i!="string"&&n(i,r+1)};return e.forEach(o=>n(o,1)),t}function _i(e){const t=new Map;if(!e)return t;const n=(o,r)=>{const i=[...r,o];for(const l of o.children)typeof l=="string"?t.has(l)||t.set(l,i):n(l,i)};return e.forEach(o=>n(o,[])),t}function To(e,t,n){if(!e||e.length===0)return!0;const o=_i(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function ac(e,t,n){const o=[];let r=0,i=null,l=null;for(const d of e){const c=d.isSpacer?null:t.get(d.field)?.[n]??null;(i===null||l!==c||i.pinned!==d.pinned)&&(i={key:`${c?c.groupId:"filler"}-${n}-${d.field}`,isGroup:c!==null,label:c?.headerName??"",headerClassName:c?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:d.pinned},l=c,o.push(i)),i.width+=d.width,i.flexGrow+=d.flex??0,d.isSpacer||(i.fields.push(d.field),r++)}return o}function Nt(){return document.documentElement.clientWidth||window.innerWidth}function cc(){return document.documentElement.clientHeight||window.innerHeight}function It(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:a.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Pt(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:a.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function dc(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function uc(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function fc(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function gc(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function pc(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.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"}),a.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"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function hc(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),a.jsx("polyline",{points:"11 8 4 12 11 16"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function mc(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),a.jsx("polyline",{points:"13 8 20 12 13 16"}),a.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function wc(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),a.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const ki=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function xc({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:d,anchorEl:c}){const f=s.useRef(null),g=s.useCallback(B=>{B&&(c?.closest('[role="columnheader"]')??c)?.focus({preventScroll:!0}),d()},[c,d]),h=B=>{const U=ki(f.current),_=U.indexOf(B.target);let T=-1;if(B.key==="ArrowDown")T=_+1>=U.length?0:_+1;else if(B.key==="ArrowUp")T=_<=0?U.length-1:_-1;else if(B.key==="Home")T=0;else if(B.key==="End")T=U.length-1;else if(B.key==="Tab"){B.preventDefault(),g(!0);return}else return;B.preventDefault(),U[T]?.focus()},[x,C]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!f.current)return;const B=c.getBoundingClientRect(),U=f.current.getBoundingClientRect(),_=Nt(),T=cc(),O=8;let S=B.left;S+U.width+O>_&&(S=_-U.width-O),S<O&&(S=O);let K=B.bottom+4;K+U.height+O>T&&(K=B.top-U.height-4),C({position:"fixed",zIndex:1300,top:K,left:S,visibility:"visible"})},[c]);const p=x.visibility==="visible";s.useLayoutEffect(()=>{p&&ki(f.current)[0]?.focus({preventScroll:!0})},[p]),s.useEffect(()=>{function B(_){f.current&&!f.current.contains(_.target)&&c&&!c.contains(_.target)&&d()}function U(_){_.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",B),document.addEventListener("keydown",U),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",U),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[c,d,g]);const u=B=>{n?.(e.field,B),g(!0)},m=!!o&&e.hideable!==!1,b=!!r&&e.pinnable!==!1,w=()=>{m&&o?.(e.field),g(!0)},v=B=>{b&&r?.(e.field,B),g(!0)},E=t?.find(B=>B.field===e.field)?.sort,I=E==null,D=i?.left?.includes(e.field)??!1,P=i?.right?.includes(e.field)??!1,F=!D&&!P,H=e.headerName||e.field;return ut.createPortal(a.jsxs("div",{ref:f,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${H}`,onKeyDown:h,children:[n&&e.sortable!==!1&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:`ogx-menu-item${E==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("asc"),role:"menuitemradio","aria-checked":E==="asc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="asc"?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(uc,{})}),"Sort Ascending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${E==="desc"?" ogx-menu-item--active":""}`,onClick:()=>u("desc"),role:"menuitemradio","aria-checked":E==="desc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="desc"?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(fc,{})}),"Sort Descending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":I,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(gc,{})}),"Unsort"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),a.jsxs("button",{type:"button",className:`ogx-menu-item${D?" ogx-menu-item--active":""}`,onClick:()=>v("left"),role:"menuitemradio","aria-checked":D,"aria-label":"Pin to left",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:D?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(hc,{})}),"Pin to Left"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>v("right"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to right",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(mc,{})}),"Pin to Right"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${F?" ogx-menu-item--active":""}`,onClick:()=>v(null),role:"menuitemradio","aria-checked":F,"aria-label":"Unpin column",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:F?a.jsx(It,{}):a.jsx(Pt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(wc,{})}),"Unpin"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),m&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:w,role:"menuitem","aria-label":`Hide ${H} column`,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(pc,{})}),"Hide Column"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(dc,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}const bc=16,Cc=16;function vc(e,t=!1){const n=Number.isFinite(e)?e-Cc:0,o=Math.floor(n/bc)-(t?1:0);return Math.max(1,o)}function yc(e,t){return e??t??!1}function Sc(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:a.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 _c(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:a.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Ei(e){const{columns:t,allColumns:n,columnGroupingModel:o,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:d,onSort:c,sortModel:f=[],onColumnResize:g,onColumnAutosize:h,columnWidths:x={},pinnedColumns:C,hasDetailPanel:p=!1,pinCheckboxColumn:u=!0,pinExpandColumn:m=!0,rowReordering:b=!1,aggregationModel:w,draggedColumn:v,dragOverColumn:E,onDragStart:I,onDragOver:D,onDragEnd:P,onDrop:F,focusedCell:H,onHeaderClick:B,onSortAdd:U,multiSort:_=!1,onHideColumn:T,onPinColumn:O,onManageColumns:S,columnIndexMap:K,wrapHeaderText:j=!1,headerHeight:Q=56}=e,$=s.useId(),[z,Z]=s.useState(null),ie=k=>W=>{W.stopPropagation(),Z({colDef:k,anchorEl:W.currentTarget})},oe=s.useCallback(()=>{Z(null)},[]),fe=k=>W=>{if(W.altKey&&(W.key==="ArrowLeft"||W.key==="ArrowRight")&&W.target===W.currentTarget){if(k.resizable===!1||!g)return;W.preventDefault(),W.stopPropagation();const pe=ft(k,x),he=(W.shiftKey?50:10)*(W.key==="ArrowRight"?1:-1);g(k.field,Po(pe+he,pe,k.minWidth,k.maxWidth));return}if(!(W.altKey&&W.key==="ArrowDown"||(W.ctrlKey||W.metaKey)&&W.key==="Enter")||k.disableColumnMenu||W.target!==W.currentTarget)return;W.preventDefault(),W.stopPropagation();const ue=W.currentTarget.querySelector(".ogx__menu-icon-btn")??W.currentTarget;Z({colDef:k,anchorEl:ue})},de=k=>H?.id===null&&H.field===k,ge=b?1:0,re=p?ge+1:ge,ae=r?re+1:re,ee=k=>W=>{if(k.sortable===!1)return;const R=f.find(ue=>ue.field===k.field);let X="asc";R&&(R.sort==="asc"?X="desc":X=null),(W.shiftKey||_)&&U?U(k.field,X):c&&c(k.field,X)},ne=(k,W)=>{const R=f.some(ue=>ue.field===k);U&&(W===null||R||_||!c)?U(k,W):c?.(k,W)},V=k=>{const W=f.find(X=>X.field===k);if(!W)return null;const R=f.length>1?f.indexOf(W)+1:null;return a.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${W.sort}`,"aria-hidden":"true",children:R!==null&&a.jsx("span",{className:"ogx__sort-badge",children:R})})},J=s.useMemo(()=>to(t,x,C,r,u,p,m,b),[t,x,C,r,u,p,m,b]),te=s.useMemo(()=>no(t,C),[t,C]),se=Si(o),y=s.useMemo(()=>_i(o),[o]),M=s.useMemo(()=>se===0?[]:(n??t).map(k=>({field:k.field,width:ft(k,x),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:et(k.field,C),isSpacer:k.isSpacer})),[se,n,t,x,C]),q=(b?48:0)+(p?48:0)+(r?48:0),Y=(b||p||r)&&(!p||m)&&(!r||u),G=(b?1:0)+(p?1:0)+(r?1:0);return a.jsxs("div",{className:"ogx__header-wrap",children:[se>0&&Array.from({length:se},(k,W)=>{const R=ac(M,y,W);return a.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":W+1,children:[q>0&&a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${Y?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:q,minWidth:q,flexShrink:0,position:Y?"sticky":void 0,left:Y?0:void 0},"aria-hidden":"true"}),R.map((X,ue)=>{const pe=X.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${X.pinned}`:"",he={width:X.width,minWidth:X.width,flexShrink:0,flexGrow:X.flexGrow};return X.pinned==="left"?(he.position="sticky",he.left=J[X.fields[0]]):X.pinned==="right"&&(he.position="sticky",he.right=J[X.fields[X.fields.length-1]],R[ue-1]?.pinned!=="right"&&(he.marginLeft="auto")),X.isGroup?a.jsx("div",{role:"columnheader","aria-colspan":X.fields.length,"aria-colindex":G+X.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${pe}${X.headerClassName?` ${X.headerClassName}`:""}`,style:he,title:X.label,children:a.jsx("span",{className:"ogx-col-group-cell__label",children:X.label})},X.key):a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${pe}`,style:he,"aria-hidden":"true"},X.key)})]},`ogx-grp-${W}`)}),a.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":se+1,children:[b&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${de("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":ge,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),p&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${de("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":re,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,left:m?b?48:0:void 0}}),r&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${u?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${de("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:u?"sticky":void 0,left:u?(b?48:0)+(p&&m?48:0):void 0},children:d&&a.jsx(en,{id:$,name:$,checked:i,indeterminate:l,onChange:k=>d(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,W)=>{if(k.isSpacer)return a.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const R=k.sortable!==!1,X=f.findIndex(We=>We.field===k.field),ue=X!==-1,pe=ue?f[X].sort:null,he=K?.get(k.field)??W,ve=R?X===0?pe==="asc"?"ascending":"descending":"none":void 0,ye=ue&&f.length>1?`Sorted ${pe==="asc"?"ascending":"descending"}, sort priority ${X+1} of ${f.length}`:void 0,_e=k.resizable!==!1,ke=et(k.field,C),le=ke!==null,be=v===k.field,Me=E===k.field,Se=yc(k.wrapHeaderText,j),me=w?.[k.field],ce=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,R&&"ogx__header-cell--sortable",ue&&"ogx__header-cell--sorted",le&&"ogx__header-cell--pinned",le&&`ogx__header-cell--pinned-${ke}`,ke==="left"&&k.field===te.lastLeft&&"ogx__header-cell--pinned-left-last",ke==="right"&&k.field===te.firstRight&&"ogx__header-cell--pinned-right-first",be&&"ogx__header-cell--dragging",Me&&"ogx__header-cell--drag-over",Se&&"ogx__header-cell--wrap",de(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),Ce={width:x[k.field]??k.width??100,minWidth:k.minWidth,maxWidth:k.maxWidth,flexGrow:k.flex??0,flexShrink:0,flexBasis:(k.flex,"auto"),boxSizing:"border-box",position:le?"sticky":"relative",zIndex:k.zIndex,opacity:be?.5:1};if(le&&ke){const We=J[k.field];ke==="left"?Ce.left=We:Ce.right=We}const Ee=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:he}):k.headerName||k.field,Ge=We=>{if(We.target.closest(".ogx-column-resize-handle")){We.stopPropagation();return}B?.(k.field),R&&ee(k)(We)},Oe=I&&!le?I(k.field):void 0,Fe=D&&!le?D(k.field):void 0,Wt=F&&!le?F(k.field):void 0;return a.jsxs("div",{className:ce,style:Ce,title:k.description??(Se&&typeof Ee=="string"?Ee:void 0),onClick:Ge,role:"columnheader",draggable:!!Oe,onDragStart:Oe,onDragOver:Fe,onDragEnd:P,onDrop:Wt,onKeyDown:fe(k),"aria-sort":ve,"aria-description":ye,"aria-colindex":G+he+1,"data-field":k.field,tabIndex:-1,children:[a.jsxs("div",{className:"ogx__header-cell-content",children:[be&&a.jsx("div",{className:"ogx__header-drag-icon",children:a.jsx(_c,{})}),a.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[a.jsx("span",{className:"ogx__header-cell-title",style:Se?{WebkitLineClamp:vc(Q,!!me)}:void 0,children:Ee}),me&&a.jsx("span",{className:"ogx__header-cell-aggregation",children:me})]}),R&&V(k.field),!k.disableColumnMenu&&a.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:ie(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:a.jsx(Sc,{})})]}),_e&&g&&a.jsx(sc,{field:k.field,currentWidth:ft(k,x),onResize:g,onAutosize:h,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:ke==="right"?"start":"end"})]},k.field)}),z&&a.jsx(xc,{colDef:z.colDef,sortModel:f,onSort:c||U?ne:void 0,onHide:T,onPin:O,pinnedColumns:C,onManageColumns:S,onClose:oe,anchorEl:z.anchorEl})]})]})}const De=()=>{};function Mi(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:De,selectRows:De,getSelectedRows:()=>[],sortColumn:De,getSortModel:()=>[],setFilterModel:De,getFilterModel:()=>({items:[]}),setPage:De,setPageSize:De,scrollToIndexes:De,autosizeColumn:De,autosizeColumns:De,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:De,selectCellRange:De,clearCellSelection:De,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve()}}const kc=e=>e.id;let Ni=!1;function Ii(e,t,n){const o=new Map,r=new Map,i=[],l=[];return e.forEach(d=>{const c=n?.get(d)??t(d);if(o.has(c)){l.push(c);return}o.set(c,d),r.set(d,c),i.push(c)}),l.length>0&&!Ni&&process.env.NODE_ENV!=="production"&&(Ni=!0,console.warn(`[OpenGridX] ${l.length} row(s) reuse the id of an earlier row and were ignored (ids: ${l.slice(0,5).map(String).join(", ")}${l.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:i,idByRow:r}}function Ec(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Ii(e,t),columns:{all:n,lookup:r,orderedFields:i,columnVisibilityModel:o},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Mc(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:Ii(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const n=e.rows.idRowsLookup.get(t.id);if(n===void 0)return e;const o=new Map(e.rows.idRowsLookup);o.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(n),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}}case"SET_COLUMNS":{const n=new Map,o=[];return t.payload.forEach(r=>{n.set(r.field,r),o.push(r.field)}),{...e,columns:{all:t.payload,lookup:n,orderedFields:o,columnVisibilityModel:e.columns.columnVisibilityModel}}}case"SET_DIMENSIONS":return{...e,dimensions:{...e.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...e,dataSource:{...e.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...e,dataSource:{...e.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...e,pagination:{...e.pagination,rowCount:t.payload}};default:return e}}function Nc(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:d=!1}=e,c=e.getRowId??kc,f=s.useRef(c);s.useLayoutEffect(()=>{f.current=c});const[g]=s.useState(()=>Ec(t,c,n,i)),[h,x]=s.useReducer(Mc,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:o,headerHeight:r}}),[C,p]=s.useState({rows:t,syncRows:d});(C.rows!==t||C.syncRows!==d)&&(p({rows:t,syncRows:d}),d&&x({type:"SET_ROWS",payload:t,getRowId:c}));const u=s.useRef(h);s.useLayoutEffect(()=>{u.current=h});const m=s.useCallback((H,B)=>{x({type:"SET_ROWS",payload:H,getRowId:f.current})},[]),b=s.useCallback((H,B)=>{x({type:"REPLACE_ROW",id:H,row:B})},[]),w=s.useCallback(H=>{x({type:"SET_COLUMNS",payload:H})},[]),v=s.useCallback((H,B)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:H,viewportHeight:B}})},[]),E=s.useCallback(H=>{x({type:"SET_DATASOURCE_LOADING",payload:H})},[]),I=s.useCallback(H=>{x({type:"SET_DATASOURCE_ERROR",payload:H})},[]),D=s.useCallback(H=>{x({type:"SET_ROW_COUNT",payload:H})},[]),[P]=s.useState(()=>({...Mi(),getRow:H=>u.current.rows.idRowsLookup.get(H)||null,getAllRows:()=>u.current.rows.allRows.map(H=>u.current.rows.idRowsLookup.get(H)),getColumn:H=>u.current.columns.lookup.get(H)||null,getAllColumns:()=>u.current.columns.all})),F=s.useRef(P);return{state:h,dispatch:x,apiRef:F,setRows:m,replaceRow:b,setColumns:w,setDimensions:v,setDataSourceLoading:E,setDataSourceError:I,setRowCount:D}}function Ic(e){const{onRowOrderChange:t,rows:n,getRowId:o,rowReordering:r=!1}=e,[i,l]=s.useState(null),[d,c]=s.useState(null),f=s.useRef(()=>{}),g=s.useMemo(()=>{const m=new Map;return n.forEach((b,w)=>m.set(o?o(b):b.id,w)),m},[n,o]),h=s.useCallback(m=>g.has(m),[g]),x=s.useCallback(()=>{f.current(),f.current=()=>{},l(null),c(null)},[]);s.useEffect(()=>()=>f.current(),[]);const C=s.useCallback(m=>b=>{if(r){if(!g.has(m)){b.preventDefault();return}f.current(),f.current=ai(b.currentTarget,x),l(m),b.dataTransfer&&(b.dataTransfer.effectAllowed="move",si(b,Eo,String(m)))}},[r,g,x]),p=s.useCallback(m=>b=>{if(!(!r||i===null)){if(!Ln(b,Eo)){x();return}g.has(m)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),d!==m&&c(m))}},[r,i,d,g,x]),u=s.useCallback(m=>b=>{if(b.preventDefault(),i===null||!Ln(b,Eo)){x();return}const w=g.get(i),v=g.get(m);x(),t&&w!==void 0&&v!==void 0&&w!==v&&t({row:n[w],oldIndex:w,targetIndex:v})},[i,t,n,g,x]);return{draggedRowId:i,dragOverRowId:d,canReorderRow:h,onDragStart:r?C:void 0,onDragOver:r?p:void 0,onDragEnd:r?x:void 0,onDrop:r?u:void 0}}const Pi=new Map,Ti=e=>JSON.stringify(e),Pc=e=>`auto-group-${e}`,Li=5,Fi=e=>e.slice(0,Li).map(t=>JSON.stringify(t)).join(", ")+(e.length>Li?", …":""),Tc={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Lc(e,t,n){const o=new Map,r=[],i=[],l=new Set,d=new Map,c=new Map,f=[],g=new Array(e.length),h=new Array(e.length),x=[],C=new Map;e.forEach((u,m)=>{const b=t(u),w=n(u),v=Array.isArray(w)?w.map(E=>String(E)):[];if(g[m]=b,h[m]=v,d.set(b,u),v.length===0)x.push(b);else{const E=Ti(v),I=c.get(E);if(I===void 0)c.set(E,b);else{const D=C.get(E)??[I];D.push(b),C.set(E,D)}}o.set(b,{id:b,parentId:null,depth:Math.max(v.length-1,0),groupingKey:v[v.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:u.serverChildrenCount})});const p=u=>{const m=Ti(u),b=c.get(m);if(b!==void 0)return b;const w=Pc(m),v=u[u.length-1],E={id:w,parentId:null,depth:u.length-1,groupingKey:v,isExpanded:!1,children:[],label:v};o.set(w,E),c.set(m,w),l.add(w);const I={id:w};if(i.push(I),d.set(w,I),u.length===1)r.push(w);else{const D=p(u.slice(0,-1));E.parentId=D,o.get(D)?.children?.push(w)}return w};return e.forEach((u,m)=>{const b=g[m],w=h[m];if(w.length<=1){r.push(b);return}const v=p(w.slice(0,-1)),E=o.get(b);E&&(E.parentId=v),o.get(v)?.children?.push(b)}),x.length>0&&f.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${Fi(x)}. They are shown as top-level rows.`),C.forEach((u,m)=>{f.push(`[OpenGridX] treeData: rows ${Fi(u)} have the same path ${m}. Rows under that path are attached to row ${JSON.stringify(u[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:d,issues:f}}function Fc(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,d=new Map,c=new Map,f=g=>{const h=n.get(g);if(!h)return!1;const x=[];let C=0;for(const b of h.children??[])f(b)&&(x.push(b),C+=(r.has(b)?0:1)+(c.get(b)??0));d.set(g,x),c.set(g,C);const p=i.get(g),m=!r.has(g)&&p!==void 0&&(t?t(p):!0)||x.length>0;return m&&l.add(g),m};return o.forEach(f),{visible:l,visibleChildren:d,descendantCounts:c}}function Ac(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:d,onRowExpansionChange:c,columnLookup:f,filterMode:g="client",sortingMode:h="client"}=e,x=r&&!!o,C=s.useMemo(()=>!r||!o?Tc:Lc(t,n,o),[t,o,r,n]),{treeNodes:p,rootIds:u,groupingRows:m,syntheticIds:b,rowLookup:w}=C,v=C.issues.join(`
|
|
2
|
-
`);s.useEffect(()=>{process.env.NODE_ENV==="production"||!
|
|
3
|
-
`).forEach(z=>console.warn(z))},[v]);const E=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!E||console.warn("[OpenGridX] treeData is set without getTreeDataPath, so the rows are shown as a flat list. Pass getTreeDataPath={(row) => row.path} to build the tree.")},[E]);const I=s.useMemo(()=>g==="server"?null:En(l,f),[g,l,f]),D=s.useMemo(()=>Fc(C,I),[C,I]),P=`${r}|${i}`,[F,H]=s.useState(()=>({configKey:P,overrides:new Map})),B=F.configKey===P?F.overrides:Pi,U=s.useCallback(z=>((z?.children?.length??0)>0||(z?.serverChildrenCount??0)>0)&&(i===-1||(z?.depth??0)<i),[i]),_=s.useMemo(()=>{const z=new Set;return x&&p.forEach((Z,ie)=>{(B.get(ie)??U(Z))&&z.add(ie)}),z},[x,p,B,U]),T=s.useCallback(z=>{const Z=!_.has(z);if(H(ie=>{const oe=ie.configKey===P?ie.overrides:Pi,fe=new Map(oe);return fe.set(z,Z),{configKey:P,overrides:fe}}),Z&&c){const ie=p.get(z);ie&&c(ie)}},[_,P,p,c]),O=h!=="server"&&!!(d&&d.length>0),S=s.useCallback(z=>{if(!x)return null;const Z=z?.labelField,ie=z?.expandAll??!1,{visible:oe,visibleChildren:fe}=D,de=O&&d?d:[],ge=(ne,V)=>{if(b.has(ne))return{value:V.field===Z?p.get(ne)?.label:void 0};const J=w.get(ne),te=f?.byField.get(V.field),se=J?Le(J,V.field,te):void 0,y=te?.sortComparator;return{value:se,type:te?.type,comparator:y,params:y&&J?{id:ne,field:V.field,row:J,value:se}:void 0}},re=[],ae=new Set,ee=ne=>{const V=ne.filter(te=>oe.has(te)),J=de.length>0?xo(V,de,ge):V;for(const te of J){if(ae.has(te))continue;const se=w.get(te);if(!se)continue;ae.add(te),re.push(se);const y=fe.get(te);y&&y.length>0&&(ie||_.has(te))&&ee(y)}};return ee(u),re},[x,D,O,d,b,p,w,f,u,_]),K=s.useCallback(z=>_.has(z),[_]),j=s.useCallback(z=>p.get(z),[p]),Q=s.useCallback(z=>{const Z=[];let ie=z;for(;ie!==null;){const oe=p.get(ie);if(!oe)break;Z.unshift(oe.groupingKey),ie=oe.parentId}return Z},[p]),$=s.useMemo(()=>{const z=new Map,{visibleChildren:Z,descendantCounts:ie}=D;return p.forEach((oe,fe)=>{const de=(oe.children?.length??0)===0&&(oe.serverChildrenCount??0)>0,ge=b.has(fe),re={hasChildren:(Z.get(fe)?.length??0)>0||de,treeDepth:oe.depth,descendantCount:de?void 0:ie.get(fe)??0,isGroupRow:ge,isExpanded:_.has(fe)};ge&&(re.groupLabel=oe.label),z.set(fe,re)}),z},[p,b,D,_]);return s.useMemo(()=>({treeNodes:p,groupingRows:m,toggleExpansion:T,isGroupExpanded:K,getVisibleRows:S,getNode:j,getNodePath:Q,rowMetaMap:$}),[p,m,T,K,S,j,Q,$])}const Ai=e=>e===null?"footer":"inline";function Oi(e,t){return vn(()=>e(t),Ai(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Oc(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?vn(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const Dc=[],$c={},Di=new Map,je="";function Gc(e){if(typeof e=="string")return e;if(e===null)return`${je}null`;if(e===void 0)return`${je}undefined`;if(e instanceof Date)return`${je}date:${e.getTime()}`;if(typeof e=="object")try{return`${je}object:${JSON.stringify(e)}`}catch{return`${je}object:${String(e)}`}return`${je}${typeof e}:${String(e)}`}const Wc=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,Hc=e=>`${e}${je}footer`,Bc=e=>e==="footer"?"f":e===null?"n":"i",zc=e=>e==="f"?"footer":e==="n"?null:"inline";function Vc(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=Dc,aggregationModel:i=$c,defaultGroupingExpansionDepth:l=0,filterModel:d,sortModel:c,getAggregationPosition:f=Ai,columnLookup:g,filterMode:h="client",sortingMode:x="client"}=e,C=r.join(je),p=s.useMemo(()=>C===""?[]:C.split(je),[C]),u=JSON.stringify(Object.entries(i)),m=s.useMemo(()=>Object.fromEntries(JSON.parse(u)),[u]),b=Object.keys(m).length>0,w=s.useMemo(()=>{const ee=new Map;return(o??[]).forEach(ne=>ee.set(ne.field,ne)),ee},[o]),v=p.length>0,E=s.useMemo(()=>p.filter(ee=>w.get(ee)?.groupable!==!1),[p,w]),D=`${E.join(je)}|${l}`,[P,F]=s.useState(()=>({configKey:D,overrides:new Map})),H=P.configKey===D?P.overrides:Di,B=s.useMemo(()=>{if(!v||h==="server")return null;const ee=En(d,g);return ee?new Set(t.filter(ne=>ee(ne))):null},[v,t,h,d,g]),U=s.useMemo(()=>{const ee=new Map,ne=[],V=[],J=new Map,te=new Map,se=new Map;if(!v)return{treeNodes:ee,rootIds:ne,groupIds:V,groupRowVariants:J,groupingRows:te,rowLookup:se};const y=(M,A,N)=>{if(A>=E.length)return(B?M.filter(W=>B.has(W)):M).map(W=>{const R=n(W);return se.set(R,W),ee.set(R,{id:R,parentId:N,depth:A,groupingKey:"",isExpanded:!1}),R});const L=E[A],q=w.get(L),Y=new Map;for(const k of M){const W=Le(k,L,q),R=Gc(W);let X=Y.get(R);X||(X={value:W,rows:[]},Y.set(R,X)),X.rows.push(k)}const G=[];return Y.forEach((k,W)=>{const R=B?k.rows.filter(_e=>B.has(_e)):k.rows;if(R.length===0)return;const X=Wc(L,W,N);G.push(X),V.push(X);const ue=b?_n(R,m,w,"useRowGrouping"):{},pe={[L]:k.value,...ue,id:X},he={[L]:k.value,id:X},ve=b?{...ue,id:Hc(X)}:null;J.set(X,{inline:pe,bare:he,footer:ve}),te.set(X,pe),ve&&te.set(ve.id,ve);const ye={id:X,parentId:N,depth:A,groupingKey:String(k.value),groupingField:L,groupingValue:k.value,aggregatedValues:ue,isExpanded:!1,children:[],label:Oc(q,L,k.value),descendantCount:R.length};ee.set(X,ye),ye.children=y(k.rows,A+1,X)}),G};return ne.push(...y(t,0,null)),{treeNodes:ee,rootIds:ne,groupIds:V,groupRowVariants:J,groupingRows:te,rowLookup:se}},[v,t,B,E,b,m,n,w]),{treeNodes:_,rootIds:T,groupIds:O,groupRowVariants:S,groupingRows:K,rowLookup:j}=U,Q=s.useCallback(ee=>!!(ee?.children&&ee.children.length>0)&&(l===-1||(ee?.depth??0)<l),[l]),$=s.useMemo(()=>{const ee=new Set;return _.forEach((ne,V)=>{!ne.children||ne.children.length===0||(H.get(V)??Q(ne))&&ee.add(V)}),ee},[_,H,Q]),z=s.useCallback(ee=>{F(ne=>{const V=ne.configKey===D?ne.overrides:Di,J=V.get(ee)??Q(_.get(ee)),te=new Map(V);return te.set(ee,!J),{configKey:D,overrides:te}})},[D,_,Q]),Z=s.useCallback(ee=>$.has(ee),[$]),ie=b?O.map(ee=>{const ne=_.get(ee);return ne?Bc(Oi(f,{...ne,isExpanded:$.has(ee)})):"i"}).join(""):"",oe=s.useMemo(()=>{const ee=new Map;return O.forEach((ne,V)=>ee.set(ne,zc(ie[V]))),ee},[O,ie]),fe=b?Oi(f,null):"footer",de=x!=="server"&&!!(c&&c.length>0),ge=s.useCallback(ee=>{if(!v)return null;const ne=ee?.labelField,V=ee?.expandAll??!1,J=de&&c?c:[],te=(A,N)=>{const L=_.get(A),q=S.get(A);if(L&&q){const R=L.groupingField??"";if(N.field===R||N.field===ne){const X=g?.byField.get(R),ue=X?.sortComparator;return{value:L.groupingValue,type:X?.type,comparator:ue,params:ue?{id:A,field:R,row:q.inline,value:L.groupingValue}:void 0}}return L.aggregatedValues&&Object.prototype.hasOwnProperty.call(L.aggregatedValues,N.field)?{value:L.aggregatedValues[N.field],type:g?.byField.get(N.field)?.type}:{value:void 0}}const Y=j.get(A),G=g?.byField.get(N.field),k=Y?Le(Y,N.field,G):void 0,W=G?.sortComparator;return{value:k,type:G?.type,comparator:W,params:W&&Y?{id:A,field:N.field,row:Y,value:k}:void 0}},se=[],y=new Set,M=A=>{const N=J.length>0?xo(A,J,te):A;for(const L of N){if(y.has(L))continue;y.add(L);const q=S.get(L);if(!q){const R=j.get(L);R&&se.push(R);continue}const Y=_.get(L),G=$.has(L),k=oe.has(L)?oe.get(L)??null:"inline",W=k==="inline"||k==="footer"&&!G;se.push(W?q.inline:q.bare),(G||V)&&Y?.children&&(M(Y.children),G&&!V&&k==="footer"&&q.footer&&se.push(q.footer))}};return M(T),se},[v,de,c,_,S,j,g,$,oe,T]),re=s.useCallback(ee=>_.get(ee),[_]),ae=s.useMemo(()=>{const ee=new Map;return _.forEach((ne,V)=>{const J=S.get(V);if(!J){ee.set(V,{hasChildren:!1,treeDepth:ne.depth,isGroupRow:!1});return}const te={hasChildren:!0,treeDepth:ne.depth,groupingField:ne.groupingField,groupingValue:ne.groupingValue,groupLabel:ne.label,descendantCount:ne.descendantCount,isGroupRow:!0,isExpanded:$.has(V)};ee.set(V,te),J.footer&&oe.get(V)==="footer"&&ee.set(J.footer.id,{...te,hasChildren:!1,treeDepth:ne.depth+1,isExpanded:void 0,isGroupFooter:!0})}),ee},[_,S,$,oe]);return s.useMemo(()=>({treeNodes:_,groupingRows:K,toggleExpansion:z,isGroupExpanded:Z,getVisibleRows:ge,getNode:re,rowMetaMap:ae,aggregationPositions:oe,rootAggregationPosition:fe}),[_,K,z,Z,ge,re,ae,oe,fe])}const Kc=new Map;function Uc(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:d,isRowGrouping:c,aggregationModel:f,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,getAggregationPosition:C,columnLookup:p,filterMode:u,sortingMode:m}=e,b=Ac({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,columnLookup:p,filterMode:u,sortingMode:m}),w=Vc({rows:t,getRowId:n,columns:l,rowGroupingModel:d,aggregationModel:f,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,getAggregationPosition:C,columnLookup:p,filterMode:u,sortingMode:m}),v=i?b:c?w:null,E=s.useMemo(()=>i?b.rowMetaMap:c?w.rowMetaMap:Kc,[i,b.rowMetaMap,c,w.rowMetaMap]);return{treeDataHandlers:b,rowGroupingHandlers:w,activeHierarchyHandlers:v,rowMetaMap:E}}function Lo(e){try{return{ok:!0,value:e()}}catch(t){return{ok:!1,error:t}}}const Tt=Promise.resolve();class $i extends Error{}function On(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function jc(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Rc(e){const[t,n]=s.useState(null),o=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),d=s.useRef(!1),c=s.useRef(e);s.useLayoutEffect(()=>{c.current=e}),s.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const f=s.useCallback(u=>{o.current=u,n(u)},[]),g=s.useRef(null),h=s.useCallback((u,m)=>{const b=i.current.get(u);if(b)return On(b.value,m.value)?b.promise:b.promise.then(()=>{const $=o.current;if(!(r.current!==u||!$||On($.value,b.value)))return g.current?.(u,$)});const w=()=>r.current===u&&o.current!==null;if(On(m.value,m.originalValue))return w()&&f(null),Tt;const{rows:v,getRowId:E,columns:I,processRowUpdate:D}=c.current,P=v.find($=>E($)===m.id);if(!P)return w()&&f(null),Tt;const F=$=>{const z=c.current.onProcessRowUpdateError;z?z($):process.env.NODE_ENV!=="production"&&$ instanceof $i&&console.error($.message)},H=$=>{if(typeof $!="object"||$===null){F(new $i(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${$===null?"null":typeof $}. The edit was not saved and the editor stays open.`));return}c.current.onRowChange?.($,m.id);const z=o.current;r.current!==u||!z||(On(z.value,m.value)?f(null):f({...z,originalValue:m.value}))};let B,U;const _=new Promise(($,z)=>{B=$,U=z}),T={value:m.value,promise:_};i.current.set(u,T);const O=()=>{i.current.get(u)===T&&i.current.delete(u)},S=I?.find($=>$.field===m.field),K=Lo(()=>{const $=qc(P,m,S,l.current);return D?D($,P):$});if(!K.ok)return O(),F(K.error),B(),_;const j=K.value,Q=$=>{O();try{H($),B()}catch(z){U(z)}};return jc(j)?Promise.resolve(j).then(Q,$=>{O(),F($),B()}):Q(j),_},[f]);s.useLayoutEffect(()=>{g.current=h},[h]);const x=s.useCallback(u=>{const m=o.current;if(m){if(m.id===u.id&&m.field===u.field)return;h(r.current,m)}r.current+=1,f({id:u.id,field:u.field,value:u.value,originalValue:u.value})},[h,f]),C=s.useCallback(u=>{const m=o.current;return!m||!d.current||u?.id!==void 0&&u.id!==m.id||u?.field!==void 0&&u.field!==m.field?Tt:u?.cancel?(f(null),Tt):h(r.current,m)},[h,f]),p=s.useCallback(u=>{const m=o.current;!m||m.id!==u.id||m.field!==u.field||f({...m,value:u.value})},[f]);return s.useMemo(()=>({editingCell:t,startCellEdit:x,stopCellEdit:C,setEditCellValue:p}),[t,x,C,p])}function qc(e,t,n,o){return n?.valueSetter?n.valueSetter({value:t.value,row:e,field:t.field}):(n?.valueGetter&&process.env.NODE_ENV!=="production"&&!o.has(t.field)&&(o.add(t.field),console.warn(`[OpenGridX] Column "${t.field}" is editable and has a valueGetter but no valueSetter. The edited value was written to row["${t.field}"], which the valueGetter may ignore, so the cell can keep showing the old value. Add a valueSetter that maps the value back onto the row.`)),{...e,[t.field]:t.value})}const Xc=e=>e.id,Yc={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},Gi="\0",Wi="";function Hi(e){if(typeof e!="number"||Number.isNaN(e))return 1;if(e===1/0)return Number.MAX_SAFE_INTEGER;if(!Number.isFinite(e))return 1;const t=Math.floor(e);return t<1?1:t}function Jc(e){return e.map(t=>t.field).join(Gi)}function Qc(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:d,expandedRowIds:c,rowMetaMap:f,getRowId:g=Xc}=e,h=s.useMemo(()=>r.some(b=>b.colSpan!==void 0&&b.colSpan!==null),[r]),x=s.useMemo(()=>r.some(b=>b.rowSpan!==void 0&&b.rowSpan!==null),[r]),C=h||x,p=C?[i,l,d].map(Jc).join(Wi):"",u=s.useMemo(()=>{if(!p)return{columns:[],leftCount:0,unpinnedCount:0};const b=new Map(r.map(I=>[I.field,I])),w=p.split(Wi).map(I=>I?I.split(Gi):[]),v=[];let E=0;for(const I of w){E+=I.length;for(const D of I){const P=b.get(D)??{field:D};v.push({colDef:P,field:D,sectionEnd:E,hasColSpan:P.colSpan!==void 0&&P.colSpan!==null,hasRowSpan:P.rowSpan!==void 0&&P.rowSpan!==null})}}return{columns:v,leftCount:w[0].length,unpinnedCount:w[1].length}},[p,r]),m=s.useMemo(()=>{if(!C||u.columns.length===0)return null;const b={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},v={spanColumns:u,expandedRowIds:c,rowMetaMap:f,getRowId:g,warned:new Set,out:b};return Fo(t,0,!1,v),Fo(n,t.length,!0,v),Fo(o,t.length+n.length,!1,v),b},[C,u,t,n,o,c,f,g]);return s.useMemo(()=>{if(!m)return Yc;const{colspanMap:b,rowSpanningCaches:w,hiddenOriginFields:v,unpinnedRanges:E,centerRowSpanStart:I}=m,D=u.columns;return{hasColSpan:h,hasRowSpan:x,colspanMap:b,rowSpanningCaches:w,getSpanOrigin:(P,F)=>{const H=b.get(P)?.[F];if(H?.spannedByColSpan)return{rowId:P,field:D[H.leftVisibleCellIndex].field};const B=w.hiddenCellOriginMap[P]?.[F];return B===void 0?null:{rowId:B,field:v.get(P)?.[F]??F}},getUnpinnedColSpanRanges:P=>E.get(P),getCenterRowSpanStart:P=>I.get(P)??P}},[m,h,x,u])}function Fo(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:d,warned:c,out:f}=o,{columns:g,leftCount:h,unpinnedCount:x}=r,C=g.length,{colspanMap:p,rowSpanningCaches:u,hiddenOriginFields:m,unpinnedRanges:b,centerRowSpanStart:w}=f,v=new Int32Array(C),E=new Array(C),I=new Array(C),D=new Int32Array(C);let P=0;const F=[];g.forEach((U,_)=>{(U.hasColSpan||U.hasRowSpan)&&F.push(_)});const H=(U,_,T)=>{const O=g[T].field;if(Lt(u.hiddenCells,U,O,!0),Lt(u.hiddenCellOriginMap,U,O,E[T]),I[T]!==O&&Lt(m,U,O,I[T]),n){const S=w.get(_);(S===void 0||D[T]<S)&&w.set(_,D[T])}},B=(U,_,T)=>{const O=g[T],S=d(U),K=Zc(U,S,O.colDef,t+_,T,l,c);let j=1;if(O.hasColSpan){const $=Math.min(Bi(O.colDef.colSpan,K,"colSpan",O.field,c),O.sectionEnd-T);for(;j<$&&v[T+j]<=_;)j++}let Q=1;if(O.hasRowSpan){Q=Math.min(Bi(O.colDef.rowSpan,K,"rowSpan",O.field,c),e.length-_);for(let $=1;$<Q;$++)if(Je(d(e[_+$]),l)){Q=$;break}if(Q>1&&i&&i.size>0){for(let $=0;$<Q-1;$++)if(i.has(d(e[_+$]))){Q=$+1;break}}}if(j>1){Lt(p,S,O.field,{spannedByColSpan:!1,cellProps:{colSpan:j}});for(let $=1;$<j;$++){const z=g[T+$];Lt(p,S,z.field,{spannedByColSpan:!0,leftVisibleCellIndex:T,rightVisibleCellIndex:T+j-1})}if(T>=h&&T<h+x){let $=b.get(S);$||($=[],b.set(S,$)),$.push(T-h,T+j-1-h)}}if(Q>1){Lt(u.spannedCells,S,O.field,Q);for(let $=T;$<T+j;$++)v[$]=_+Q,E[$]=S,I[$]=O.field,D[$]=_;_+Q>P&&(P=_+Q)}return j};for(let U=0;U<e.length;U++){const _=e[U];if(!_||_._isSkeleton||Je(d(_),l))continue;if(P<=U){let O=0;for(const S of F)S>=O&&(O=S+B(_,U,S));continue}let T=0;for(;T<C;)v[T]>U?(H(d(_),U,T),T++):g[T].hasColSpan||g[T].hasRowSpan?T+=B(_,U,T):T++}}function Zc(e,t,n,o,r,i,l){const d=e[n.field];let c=d;if(n.valueGetter)try{c=n.valueGetter({row:e,field:n.field,value:d})}catch(f){zi(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,f),c=void 0}return{row:e,value:c,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function Bi(e,t,n,o,r){if(typeof e=="number")return Hi(e);if(typeof e!="function")return 1;try{return Hi(e(t))}catch(i){return zi(r,`${n}:${o}`,`${n} for column "${o}" threw; the cell is rendered without a span`,i),1}}function zi(e,t,n,o){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${n}.`,o))}function Lt(e,t,n,o){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[n]=o;return}let r=e[t];r||(r={},e[t]=r),r[n]=o}function ed(e){const{spanning:t,renderContext:n,offsetTop:o,cumulativeHeights:r}=e;return s.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:n,offsetTop:o};let i=Math.max(0,n.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=n.firstRowIndex?{renderContext:n,offsetTop:o}:{renderContext:{...n,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,n,o,r])}function td(e){const{spanning:t,firstColumnIndex:n,lastColumnIndex:o,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let d=n,c=o,f=!0;for(;f;){f=!1;for(const{row:b,id:w}of l){const v=t.getUnpinnedColSpanRanges(w??b.id);if(v)for(let E=0;E<v.length;E+=2){const I=v[E],D=v[E+1];D<d||I>c||(I<d&&(d=I,f=!0),D>c&&(c=D,f=!0))}}}if(d===n&&c===o)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:h,rightPinnedCols:x,unpinnedAccWidths:C,unpinnedTotalWidth:p}=i,u=d>0?C[d-1]:0,m=p-C[c];return[...g,...u>0?[{field:"__spacer_left__",width:u,isSpacer:!0}]:[],...h.slice(d,c+1),...m>0?[{field:"__spacer_right__",width:m,isSpacer:!0}]:[],...x]},[t,n,o,r,i,l])}function nd(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const d=c=>n===null||To(e,n,c);return{onDragOver:o&&(c=>d(c)?o(c):()=>{}),onDrop:r&&(c=>d(c)?r(c):f=>{f.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}const od=300,Vi=e=>e.id;function rd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function Ki(e,t){const n=new Set,o=[];return e.forEach(r=>{const i=t(r);n.has(i)||(n.add(i),o.push({id:i,row:r}))}),o}function Ui(e,t,n){const o=new Set(e.map(n)),r=t.filter(i=>!o.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function id(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:d,aggregationModel:c,rowGroupingActive:f=!1}=e,g=rd(i,f),h=!!t&&i==="server"&&f,x=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!h||(x.current=!0,console.warn("[OpenGridX] `rowGroupingModel` turns pagination off, so the dataSource with `paginationMode: 'server'` is asked for every row (startRow 0, endRow Number.MAX_SAFE_INTEGER) instead of one page. See docs/features/data-source.md."))},[h]);const C=t?.getRows,p=bi({dataSource:t,paginationMode:i,sortingMode:l,filterMode:d}),u=JSON.stringify([g,g!=="all"||l==="server"?n:null,g!=="all"||d==="server"?o:null,p?c??null:null,g==="all"?null:r.pageSize]),m=g==="all"?0:r.page,b=g==="all"?0:r.pageSize,w=s.useRef({params:e,kind:g});s.useLayoutEffect(()=>{w.current={params:e,kind:g}});const v=s.useRef(0),E=s.useRef(0),I=s.useRef(null),D=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),P=s.useRef(null),F=s.useRef(!1),H=s.useRef(0),B=s.useRef(!1),U=s.useRef(new Set),_=s.useCallback(()=>{const z=F.current||H.current>0;z!==B.current&&(B.current=z,w.current.params.setDataSourceLoading(z))},[]),T=s.useCallback(()=>{P.current!==null&&(clearTimeout(P.current),P.current=null)},[]),O=s.useCallback(()=>{v.current++,D.current.inFlightEnd=null,F.current=!1},[]),S=s.useCallback(()=>{E.current++,U.current.clear(),H.current=0},[]),K=s.useCallback(async()=>{const{params:z,kind:Z}=w.current,ie=z.dataSource;if(!ie)return!1;const oe=D.current,fe=z.paginationModel.pageSize;let de,ge;if(Z==="infinite"){if(oe.inFlightEnd!==null)return!1;if(de=oe.loadedEnd,ge=(oe.page+1)*fe,ge<=de)return F.current=!1,_(),!1;oe.inFlightEnd=ge}else Z==="page"?(de=z.paginationModel.page*fe,ge=de+fe):(de=0,ge=Ci);const re=++v.current;F.current=!0,_(),z.setDataSourceError(null);let ae;try{ae=await ie.getRows({startRow:de,endRow:ge,sortModel:z.sortModel,filterModel:z.filterModel,groupKeys:[],aggregationModel:z.aggregationModel})}catch(ee){return re!==v.current||(oe.inFlightEnd=null,F.current=!1,w.current.params.setDataSourceError(ee),console.error("Data Source Error:",ee),_()),!1}if(re!==v.current)return!1;try{const{params:ee}=w.current,ne=ee.getRowId??Vi,V=Ki(ae.rows,ne);if(Z==="infinite"&&de>0?ee.setRows(J=>Ui(J,V,ne),!0):(ee.setRows(V.map(J=>J.row),!0),S()),ae.aggregationResults&&ee.onAggregationResults?.(ae.aggregationResults),ae.rowCount!==void 0&&ee.setRowCount(ae.rowCount),Z==="infinite"&&(oe.inFlightEnd=null,oe.loadedEnd=de+ae.rows.length,ae.rows.length>=ge-de&&(oe.page+1)*fe>ge))return!0}catch(ee){return oe.inFlightEnd=null,F.current=!1,w.current.params.setDataSourceError(ee),console.error("Data Source Error:",ee),_(),!1}return F.current=!1,_(),!1},[_,S]),j=s.useCallback(async()=>{for(;await K(););},[K]);s.useLayoutEffect(()=>{if(!C){I.current&&(I.current=null,T(),O(),S(),w.current.params.setDataSourceError(null),_());return}const z=I.current,Z=D.current;if(!z||z.key!==u||z.getRows!==C){I.current={key:u,getRows:C},O(),S();const ie=g==="infinite"&&z!==null&&m!==0;if(Z.page=ie?0:m,Z.loadedEnd=0,ie){const{params:oe}=w.current;oe.onPaginationModelChange?.({...oe.paginationModel,page:0})}}else g==="infinite"?(m<Z.page&&(O(),Z.loadedEnd=0),Z.page=m):O();if(g==="infinite"){const ie=Z.inFlightEnd!==null;if(ie||(Z.page+1)*b<=Z.loadedEnd){F.current=ie,_();return}}return F.current=!0,_(),P.current=setTimeout(()=>{P.current=null,j()},od),T},[C,u,g,m,b,T,O,S,_,j]),s.useEffect(()=>()=>{O(),S()},[O,S]);const Q=s.useCallback(()=>(T(),j()),[T,j]),$=s.useCallback(async(z,Z,ie)=>{const{params:oe}=w.current,fe=oe.dataSource;if(!fe)return;const de=JSON.stringify(Z),ge=U.current;if(ge.has(de))return;const re=E.current;ge.add(de),H.current++,_();try{const ae=await fe.getRows({startRow:0,endRow:Ci,sortModel:oe.sortModel,filterModel:oe.filterModel,groupKeys:Z,aggregationModel:oe.aggregationModel});if(re!==E.current)return;if(ae.rows.length>0){const{params:ee}=w.current,ne=ee.getRowId??Vi,V=Ki(ae.rows,ne);ee.setRows(J=>Ui(J,V,ne),!0)}}catch(ae){if(re!==E.current)return;ge.delete(de),console.error("Failed to fetch children:",ae),ie?.(ae)}finally{re===E.current&&(H.current--,_())}},[_]);return{fetchRows:Q,fetchChildren:$}}function ld(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function sd({enabled:e,treeNodes:t,isGroupExpanded:n,getNodePath:o,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:n,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:n,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((d,c)=>{!ld(d)||!n(c)||i(c,o(c),()=>{const{isGroupExpanded:f,toggleExpansion:g}=l.current;f(c)&&g(c)})})},[e,t,n,o,i])}const ji={};function ad(e){const t=JSON.stringify(e),[n,o]=s.useState(null),r=s.useCallback(i=>o({modelKey:t,results:i}),[t]);return[n&&n.modelKey===t?n.results:null,r]}function Ri(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:d,serverAggregationResults:c}=e,f=Object.keys(o).length>0,g=s.useMemo(()=>{const I=new Map;return(n??[]).forEach(D=>I.set(D.field,D)),I},[n]),h=s.useMemo(()=>r||!f?ji:_n(t,o,g,"useAggregation"),[t,g,o,r,f]),x=JSON.stringify([o,l??null,d??[]]),C=r&&f&&!!i?.getAggregations&&!c,p=s.useRef({aggregationModel:o,filterModel:l,sortModel:d});s.useEffect(()=>{p.current={aggregationModel:o,filterModel:l,sortModel:d}});const[u,m]=s.useState(null);s.useEffect(()=>{const I=i?.getAggregations;if(!C||!I)return;let D=!1;const P=p.current,F={sortModel:P.sortModel??[],filterModel:P.filterModel??{items:[]},groupKeys:[],aggregationModel:P.aggregationModel};let H;try{H=Promise.resolve(I(F))}catch(B){H=Promise.reject(B)}return H.then(B=>{D||m({key:x,result:B,error:null})},B=>{D||(console.error("[useAggregation] Server aggregation error:",B),m({key:x,result:null,error:B}))}),()=>{D=!0}},[C,i,x]);const b=u&&u.key===x?u:null,w=C&&b===null,v=C?b?.error??null:null;return{aggregationResult:s.useMemo(()=>r?c&&Object.keys(c).length>0?c:b?.result??ji:h,[r,h,c,b]),isLoading:w,error:v}}const cd={items:[]},dd=[];function ud(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:d,hierarchyRequested:c}=e,f=o&&!d,g=s.useMemo(()=>new Set(n.map(b=>b.field)),[n]),h=s.useMemo(()=>bo(n),[n]),x=s.useMemo(()=>Hs(i,g),[i,g]),C=s.useMemo(()=>f?po(t,x.source,h):t,[f,t,x.source,h]),p=s.useMemo(()=>f?Ur(C,n,r,{outputFilterModel:x.output,sortModel:l}):vo,[f,C,n,r,x.output,l]),u=f&&p.isValid,m=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&d&&!m.current.dataSource&&(m.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),u&&c&&!m.current.hierarchy&&(m.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[o,d,u,c]),{isActive:u,rows:u?p.pivotRows:t,columns:u?p.pivotColumns:n,pipelineFilterModel:u?cd:i,pipelineSortModel:u?dd:l}}const tn=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...d})=>{const c=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${n}`,o&&"ogx-button--disabled",r].filter(Boolean).join(" ");return a.jsx("button",{type:i,className:c,disabled:o,...d,children:l})};function Ao(e){const t=s.useId(),{page:n,pageSize:o,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:d=[10,25,50,100],showFirstButton:c=!0,showLastButton:f=!0,localeText:g}=e,h=Tn(o),x=ko(r,h),C=li(n,x),p=d.includes(h)?d:[...d,h].sort((_,T)=>_-T),u=C*h,m=Math.min(u+h,r),b=r===0?0:`${u+1}–${m}`,w=g?.paginationRowsPerPage??"Rows per page:",v=g?.paginationOf?g.paginationOf(r===0?0:u+1,m,r):`${b} of ${r}`,E=g?.paginationPage?g.paginationPage(C+1,x):`Page ${C+1} of ${x}`,I=()=>{i(0)},D=()=>{i(Math.max(0,C-1))},P=()=>{i(Math.min(x-1,C+1))},F=()=>{i(x-1)},H=_=>{const T=parseInt(_.target.value,10);l(T)},B=C===0,U=C>=x-1;return a.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[a.jsxs("div",{className:"ogx-pagination__page-size",children:[a.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:w}),a.jsx("select",{id:t,className:"ogx-pagination__select",value:h,onChange:H,children:p.map(_=>a.jsx("option",{value:_,children:_},_))})]}),a.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:v}),a.jsxs("div",{className:"ogx-pagination__actions",children:[c&&a.jsx(tn,{variant:"text",size:"small",onClick:I,disabled:B,"aria-label":"Go to first page",title:"First page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),a.jsx(tn,{variant:"text",size:"small",onClick:D,disabled:B,"aria-label":"Go to previous page",title:"Previous page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),a.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:E}),a.jsx(tn,{variant:"text",size:"small",onClick:P,disabled:U,"aria-label":"Go to next page",title:"Next page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&a.jsx(tn,{variant:"text",size:"small",onClick:F,disabled:U,"aria-label":"Go to last page",title:"Last page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function fd({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:d=!1,checkboxSelection:c=!1,rowHeight:f,onRowClick:g,onRowDoubleClick:h,onSelectionChange:x,tabIndex:C=-1,onFocus:p,onToggleExpansion:u}){const m=t??e.id,b=r.field,w=Le(e,b,i),v=oo(e,b,w,i)??ro(w,i),E=l?.isGroupRow===!0||Je(m),I={row:e,value:w,formattedValue:v,field:b,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},D=P=>{P.stopPropagation(),x?.(m,P.target.checked)};return a.jsxs("div",{className:`ogx-list-view__row${d?" ogx-list-view__row--selected":""}`,style:f?{minHeight:f}:void 0,onClick:()=>g?.(e),onDoubleClick:h?()=>h(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":d,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":n,tabIndex:C,onFocus:p?P=>{P.target===P.currentTarget&&p(n)}:void 0,children:[c&&a.jsx("div",{className:"ogx-list-view__checkbox",onClick:P=>P.stopPropagation(),children:!E&&a.jsx("input",{type:"checkbox",checked:d,onChange:D,"aria-label":`Select row ${m}`,tabIndex:-1})}),l&&u&&a.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:P=>P.stopPropagation(),onDoubleClick:P=>P.stopPropagation(),children:l.hasChildren&&a.jsx(No,{isExpanded:l.isExpanded===!0,onClick:()=>u(m),tabIndex:-1})}),a.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:a.jsx(ht,{field:b,resetKey:e,renderFn:()=>{const P=r.renderCell(I);return P===void 0&&E?l?.groupLabel:P}})})]})}function gd(e,t){const n=s.useRef(!0),o=s.useRef(e);s.useEffect(()=>{o.current=e},[e]),s.useEffect(()=>{n.current=!0},[t]);const r=s.useCallback(i=>{const l=ui(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const d=o.current;d&&(n.current=!1,d(l))},[]);return e?r:void 0}const pd=e=>e.id;function hd({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:d,currentPage:c,pageSizeOptions:f,selectedRowIds:g,listViewColumn:h,columnsByField:x,rowMetaMap:C,noRowsLabel:p,rowHeight:u,checkboxSelection:m,paginationMode:b,serverRowCount:w,paginationSlot:v,paginationSlotProps:E,localeText:I,onRowClick:D,onRowDoubleClick:P,onSelectionChange:F,onPaginationModelChange:H,onRowsScrollEnd:B,getRowId:U=pd,multiselectable:_=!1,loading:T=!1,loadingOverlay:O,noRowsOverlay:S,showPaginationControls:K=!0,selectable:j=!1,onToggleExpansion:Q}){const $=v||Ao,z=s.useRef(null),[Z,ie]=s.useState(null),oe=Z===null?-1:t.findIndex(M=>U(M)===Z),fe=oe===-1?0:oe,de=M=>{const A=t[M];A&&(ie(U(A)),z.current?.querySelector(`:scope > [role="row"][data-rowindex="${M}"]`)?.focus())},ge=M=>{const A=M.target;if(A.getAttribute("role")!=="row"||A.parentElement!==z.current)return;const N=Number(A.getAttribute("data-rowindex")),L=t[N];if(!L)return;const q=U(L),Y=t.length-1,G=C.get(q),k=!!(G?.hasChildren&&Q);if(M.altKey&&(M.key==="ArrowRight"||M.key==="ArrowLeft")){M.preventDefault(),k&&M.key==="ArrowRight"!=(G?.isExpanded===!0)&&Q?.(q);return}switch(M.key){case"ArrowDown":M.preventDefault(),de(Math.min(N+1,Y));return;case"ArrowUp":M.preventDefault(),de(Math.max(N-1,0));return;case"Home":M.preventDefault(),de(0);return;case"End":M.preventDefault(),de(Y);return;case"PageDown":M.preventDefault(),de(Math.min(N+10,Y));return;case"PageUp":M.preventDefault(),de(Math.max(N-10,0));return;case"Enter":case" ":if(M.preventDefault(),M.key===" "&&M.shiftKey){j&&!G?.isGroupRow&&F(q,!g.has(q));return}k?Q?.(q):D({row:L,id:q,rowIndex:N});return}},re=b==="server",ae=re?w||0:i,ee=re?w||0:n,ne=Tn(d.pageSize),V=ko(ae,ne),J=l?c*ne:0,te=t.length-o-r,se=M=>{if(M<o)return M+1;const A=M-o;return A<te?o+J+A+1:o+ae+(A-te)+1},y=gd(B,t.length);return a.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":ee,"aria-multiselectable":_,children:[a.jsx("div",{className:"ogx-list-view__toolbar",children:a.jsxs("span",{children:[ee," ",ee===1?"item":"items",l?` · page ${c+1} of ${V}`:"",g.size>0?` · ${g.size} selected`:""]})}),a.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:y,onKeyDown:ge,ref:z,children:t.length===0&&T?a.jsx("div",{className:"ogx-list-view__loading",children:O??a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&S?a.jsx("div",{className:"ogx-list-view__empty",children:S}):t.length===0?a.jsxs("div",{className:"ogx-list-view__empty",children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),p]}):t.map((M,A)=>{const N=U(M);return a.jsx(fd,{row:M,rowId:N,rowIndex:A,ariaRowIndex:se(A),listViewColumn:h,gridColumn:x.get(h.field),rowMeta:C.get(N),isSelected:g.has(N),checkboxSelection:m,rowHeight:u,onRowClick:L=>D({row:L,id:N,rowIndex:A}),onRowDoubleClick:P?L=>P({row:L,id:N,rowIndex:A}):void 0,onSelectionChange:F,tabIndex:A===fe?0:-1,onToggleExpansion:Q,onFocus:L=>ie(U(t[L]))},N)})}),l&&K&&a.jsx($,{page:c,pageSize:d.pageSize,rowCount:ae,pageSizeOptions:f,onPageChange:M=>H({...d,page:M}),onPageSizeChange:M=>H({...d,pageSize:M,page:0}),localeText:I,...E})]})}function md({overlay:e}){return e?a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function nn(e){return e.headerName||e.field}function wd(e){return e.nativeEvent.isComposing||e.keyCode===229}function on(e,t,n=!0){return o=>{if(wd(o)){o.stopPropagation();return}n&&o.key==="Enter"&&(o.stopPropagation(),e()),o.key==="Escape"&&(o.stopPropagation(),t())}}function xd({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(String(e??"")),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),a.jsx("input",{ref:d,type:"text",className:"ogx__edit-input","aria-label":nn(t),value:i,onChange:c=>{l(c.target.value),n(c.target.value)},onBlur:o,onKeyDown:on(o,r)})}function bd({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),a.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":nn(t),value:i,onChange:c=>{const f=c.target.value===""?"":Number(c.target.value);l(f),n(f===""?null:f)},onBlur:o,onKeyDown:on(o,r)})}function Cd({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{n(!e),o()};return a.jsx("div",{className:"ogx__edit-boolean",children:a.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":nn(t),checked:!!e,onChange:l,onMouseDown:d=>d.preventDefault(),onBlur:o,onKeyDown:on(o,r,!1)})})}const Oo=e=>typeof e=="object"?e.value:e,vd=e=>typeof e=="object"?e.label:String(e);function yd(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Sd({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],d=l.map(g=>String(Oo(g)));let c=l.findIndex(g=>yd(Oo(g),e));c===-1&&e!==null&&e!==void 0&&(c=d.indexOf(String(e)));const f=c===-1;return a.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":nn(t),value:f?"":d[c],onChange:g=>{const h=d.indexOf(g.target.value);n(h===-1?null:Oo(l[h]))},onBlur:o,onKeyDown:on(o,r),children:[f&&a.jsx("option",{value:""}),l.map((g,h)=>a.jsx("option",{value:d[h],children:vd(g)},h))]})}const qi=e=>String(e).padStart(2,"0"),Xi=/^(\d{4}-\d{2}-\d{2})/;function Do(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${qi(e.getMonth()+1)}-${qi(e.getDate())}`;if(typeof e=="string"){const t=Xi.exec(e);return t?t[1]:e===""?"":Do(new Date(e))}return typeof e=="number"?Do(new Date(e)):""}function _d(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const d=new Date(l.getTime());return d.setFullYear(n,o-1,r),d};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&Xi.test(t)&&t.length>10?e+t.slice(10):e}function kd({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i]=s.useState(e),[l,d]=s.useState(()=>Do(e)),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus()},[]),a.jsx("input",{ref:c,type:"date",className:"ogx__edit-input","aria-label":nn(t),value:l,onChange:f=>{d(f.target.value),n(_d(f.target.value,i))},onBlur:o,onKeyDown:on(o,r)})}function Ed(e){const{colDef:t}=e;switch(t.type){case"number":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(bd,{...e})});case"boolean":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Cd,{...e})});case"singleSelect":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Sd,{...e})});case"date":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(kd,{...e})});default:return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(xd,{...e})})}}function Md(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:d,colIndex:c,ariaColIndex:f,isSelected:g,onClick:h,width:x,pinnedPosition:C,pinnedOffset:p,isPinnedEdge:u,isFocused:m,isFocusVisible:b,isEditable:w,isEditing:v,onEditStart:E,onEditStop:I,onValueChange:D,colSpanInfo:P,rowSpan:F,isHiddenByRowSpan:H,rowMeta:B,valueError:U,rangeFlags:_=0}=e,T=s.useCallback(y=>{o?o(l.field,y):D?.(y)},[o,D,l.field]),O=B?.isGroupRow===!0,{formattedValue:S,error:K}=s.useMemo(()=>{const y=l.valueFormatter;if(y&&!(O&&r==null)){const M=Lo(()=>y({value:r,row:i,field:l.field}));return M.ok?{formattedValue:M.value}:{formattedValue:"",error:M.error??new Error("valueFormatter failed")}}return{formattedValue:ro(r,l)}},[r,i,l,O]),j=s.useMemo(()=>{if(!l.cellClassName)return"";const y=l.cellClassName;if(typeof y=="function"){const M=Lo(()=>y({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:B}));return M.ok&&M.value||""}return l.cellClassName},[l,r,S,i,d,c,B]),Q=U??K,$=l.field,z=s.useCallback(()=>{I?.(!1,$)},[I,$]),Z=s.useCallback(()=>{I?.(!0,$)},[I,$]),ie=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),oe=s.useRef(!1);if(s.useEffect(()=>{if(!(!v||!I))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.current||I(!1,$)})}},[v,I,$]),P?.spannedByColSpan)return null;const fe=P?.cellProps.colSpan??1,de=fe>1,ge=(de?P?.cellProps.width:void 0)??x??l.width??100,re={width:"var(--width)","--width":typeof ge=="number"?`${ge}px`:ge,flexGrow:(de?P?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:de?void 0:l.minWidth,maxWidth:de?void 0:l.maxWidth};if(H)return a.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:re,role:"presentation","data-field":l.field,"data-colindex":c});const ae=y=>{v||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:d,colIndex:c}),h?.(y))},ee=()=>{v||!w||(n?n(l.field,r):E?.())},ne=l.renderEditCell,V=C!=null,J=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",m&&"ogx__cell--focused",m&&b&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,V&&"ogx__cell--pinned",V&&`ogx__cell--pinned-${C}`,V&&u&&`ogx__cell--pinned-${C}-${C==="left"?"last":"first"}`,v&&"ogx__cell--editing",F&&F>1&&"ogx__cell--spanned",(_&_o)!==0&&"ogx__cell--range",(_&Qr)!==0&&"ogx__cell--range-top",(_&Zr)!==0&&"ogx__cell--range-bottom",(_&ei)!==0&&"ogx__cell--range-left",(_&ti)!==0&&"ogx__cell--range-right",j].filter(Boolean).join(" "),te=F||1,se={...re,position:V?"sticky":void 0,zIndex:l.zIndex??(V?3:void 0),padding:v?0:void 0};return te>1&&(se.height=`calc(var(--height) * ${te} - var(--border-width, 1px))`,se.zIndex=10,V&&(se.zIndex=40)),V&&p!==void 0&&(C==="left"?se.left=p:se.right=p),a.jsx("div",{className:J,style:se,onClick:ae,onDoubleClick:ee,role:"gridcell","aria-colindex":f??c+1,"aria-readonly":!w||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":c,...fe>1?{"aria-colspan":fe}:{},...te>1?{"aria-rowspan":te}:{},...(_&_o)!==0?{"aria-selected":!0}:{},children:a.jsx("div",{className:"ogx__cell-content",children:v&&(o||D)&&I?ne?a.jsx(ht,{field:l.field,resetKey:i,renderFn:()=>ne({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:B,onValueChange:T,onCommit:z,onCancel:Z})}):a.jsx(Ed,{value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:B,onValueChange:T,onCommit:z,onCancel:Z}):Q!==void 0?a.jsx(ht,{field:l.field,resetKey:i,renderFn:()=>{throw Q}}):l.renderCell?a.jsx(ht,{field:l.field,resetKey:ie,renderFn:()=>l.renderCell({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:B})}):l.type==="image"&&typeof r=="string"&&r!==""?a.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):S})})}const Yi=s.memo(Md),Nd=({className:e="",...t})=>a.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:a.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:a.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 Id(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:d}=e,c=s.useRef(null),f=o==="auto";if(s.useLayoutEffect(()=>{const h=c.current;if(!h||!f||!r||!i)return;const x=()=>{h.getClientRects().length!==0&&i(t,h.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(x);return C.observe(h),()=>C.disconnect()},[f,r,i,t]),!r)return null;const g={height:f?"auto":`${o}px`,overflow:f?"visible":"auto"};return a.jsx("div",{ref:c,className:"ogx__detail-panel",style:g,role:"row",id:l,children:a.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":d,children:n})})}const $o=12;function Pd(e,t,n,o){let r=0,i=0,l=0;for(let d=t;d<e.length&&l<n;d++){const c=e[d];if(c.isSpacer)break;r+=ft(c,o),i+=c.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function Td(e){const{row:t,rowId:n,columns:o,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:d,onRowDoubleClick:c,onCellClick:f,onSelectionChange:g,columnWidths:h={},pinnedColumns:x,pinnedRows:C,hasDetailPanel:p=!1,isDetailPanelExpanded:u=!1,onDetailPanelToggle:m,detailPanelContent:b,detailPanelHeight:w=io,onDetailPanelHeightChange:v,pinCheckboxColumn:E=!0,pinExpandColumn:I=!0,rowReordering:D=!1,onDragStart:P,onDragOver:F,onDragEnd:H,onDrop:B,isDragging:U,isDragOver:_,editingCell:T,onEditStart:O,onEditStop:S,onEditCellValueChange:K,isCellEditable:j,focusedCellField:Q,isFocusVisible:$,colspanMap:z,rowSpanningCaches:Z,rowHeight:ie=52,rowMeta:oe,columnIndexMap:fe,ariaRowIndex:de,cellRange:ge}=e,re=n??t.id,ae=s.useId(),ee=s.useId(),ne=s.useMemo(()=>to(o,h,x,l,E,p,I,D),[o,h,x,l,E,p,I,D]),V=s.useMemo(()=>no(o,x),[o,x]),J=oe?.hasChildren===!0,te=oe?.isGroupRow===!0,se=p&&!te,y=!te&&!Je(re),M=s.useCallback((le,be)=>{O?.({id:re,field:le,value:be})},[re,O]),A=s.useCallback((le,be)=>{K?.({id:re,field:le,value:be})},[K,re]),N=s.useCallback((le,be)=>{S?.({cancel:le,id:re,field:be})},[S,re]);if(t._isSkeleton){const le=Math.max(o.length,5);return a.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ie,minHeight:ie},children:Array.from({length:le}).map((be,Me)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-bar"})},Me))})}const L=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:re,rowIndex:r})},q=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:re,rowIndex:r})},Y=le=>{le.stopPropagation(),g?.(re,le.target.checked)},G=le=>{le.stopPropagation(),m?.(re)},k=D?1:0,W=p?k+1:k,R=l?W+1:W,X=R,ue=fe?.size??o.filter(le=>!le.isSpacer).length,pe=oe!==void 0,he=oe?.hasChildren===!0,ve=hr(re,C),ye=ve==="top",_e=ve==="bottom",ke=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",ye&&"ogx__row--pinned-top",_e&&"ogx__row--pinned-bottom",U&&"ogx__row--dragging",_&&"ogx__row--drag-over",J&&"ogx__row--group",oe?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ke,onClick:L,onDoubleClick:c?q:void 0,role:"row","aria-rowindex":de??r+2,"aria-selected":i,"aria-level":pe?(oe?.treeDepth??0)+1:void 0,"aria-expanded":he?oe?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:F?F(re):void 0,onDrop:B?B(re):void 0,style:{maxHeight:`${ie}px`,minHeight:`${ie}px`,"--height":`${ie}px`,"--border-width":"1px"},children:[D&&a.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${Q==="__reorder_col__"?"ogx__cell--focused":""} ${Q==="__reorder_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":P?"Drag to reorder row":void 0,"aria-colindex":k,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:$o},draggable:!!P,onDragStart:P?P(re):void 0,onDragEnd:H,onClick:le=>le.stopPropagation(),children:P&&a.jsx(Nd,{})}),p&&a.jsx("div",{className:`ogx__cell ogx__cell--expand ${I?"ogx__cell--pinned-left":""} ${Q==="__expand_col__"?"ogx__cell--focused":""} ${Q==="__expand_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":se?u?"Collapse row details":"Expand row details":void 0,"aria-expanded":se?u:void 0,"aria-controls":se&&u?ee:void 0,"aria-colindex":W,"data-field":"__expand_col__",style:{position:I?"sticky":void 0,left:I?D?48:0:void 0,zIndex:I?$o:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),f?.({row:t,field:"__expand_col__",value:u,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:se&&a.jsx(No,{isExpanded:u,onClick:G,variant:"plus-minus",tabIndex:-1})}),l&&a.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${Q==="__checkbox_col__"?"ogx__cell--focused":""} ${Q==="__checkbox_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":R,"data-field":"__checkbox_col__",style:{position:E?"sticky":void 0,left:E?(D?48:0)+(p&&I?48:0):void 0,zIndex:E?$o:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),f?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:y&&a.jsx(en,{id:ae,name:`ogx-select-row-${re}`,checked:i,onChange:Y,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${re}`:`Select row ${re}`,tabIndex:-1,onMouseDown:le=>le.preventDefault()})}),o.map((le,be)=>{if(le.isSpacer)return a.jsx("div",{style:{width:le.width,minWidth:le.width,flexShrink:0},"aria-hidden":"true"},le.field);let Me,Se;te?Me=t[le.field]:{value:Me,error:Se}=wr(t,le.field,le);const me=fe?.get(le.field)??be,ce=h[le.field]??le.width,we=et(le.field,x),Ce=!!O&&yr({row:t,field:le.field,value:Me,colDef:le,rowIndex:r,colIndex:me,rowMeta:oe},j),Ee=T?.id===re&&T?.field===le.field,Ge=Ee?T?.value:Me,Oe=z?.get(re)?.[le.field],Fe=Oe&&!Oe.spannedByColSpan&&Oe.cellProps.colSpan>1?Pd(o,me,Oe.cellProps.colSpan,h):Oe,Wt=Fe&&!Fe.spannedByColSpan?o[me+Fe.cellProps.colSpan-1]?.field??le.field:le.field,We=we==="right"?Wt:le.field,fn=we?ne[We]:void 0,gn=we==="left"&&Wt===V.lastLeft||we==="right"&&le.field===V.firstRight,pn=Z?.spannedCells[re]?.[le.field],Re=Z?.hiddenCells[re]?.[le.field]||!1,Ve=ge&&!Re&&le.field!==Yr?Js(ge,me,Fe&&!Fe.spannedByColSpan?Fe.cellProps.colSpan:1,pn??1):void 0;return a.jsx(Yi,{value:Ge,row:t,colDef:le,rowIndex:r,colIndex:me,ariaColIndex:X+me+1,isSelected:i,onCellClick:f,width:ce,pinnedPosition:we,pinnedOffset:fn,isPinnedEdge:gn,isFocused:Q===le.field,isFocusVisible:$,isEditable:Ce,isEditing:Ee,onCellEditStart:M,onEditStop:N,onCellValueChange:A,colSpanInfo:Fe,rowSpan:pn,isHiddenByRowSpan:Re,rowMeta:oe,valueError:Se,rangeFlags:Ve},le.field)})]}),se&&a.jsx(Id,{id:ee,colSpan:X+ue,row:t,rowId:re,rowIndex:r,content:b,height:w,isExpanded:u,onHeightChange:v})]})}function Ld(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(o==="cellRange"){if(!Ys(e.cellRange,t.cellRange))return!1}else if(!Object.is(e[o],t[o]))return!1;return!0}const Dn=s.memo(Td,Ld);function Ji({getContent:e,params:t}){return a.jsx(ht,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Fd=e=>e.id;function Qi({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:c,columnWidths:f,pinnedColumns:g,pinnedRows:h,hasDetailPanel:x,expandedRowIds:C,getDetailPanelContent:p,getDetailPanelHeight:u,onDetailPanelToggle:m,onDetailPanelHeightChange:b,pinCheckboxColumn:w,pinExpandColumn:v,focusedCell:E,colspanMap:I,rowSpanningCaches:D,rowHeight:P,rowMetaMap:F,getRowId:H=Fd,rowIndexOffset:B=0,ariaRowIndexBase:U,columnIndexMap:_,editingHandlers:T,isCellEditable:O,rowReordering:S=!1,cellRange:K,cellRangeHasRowSpan:j=!1}){return e.length===0?null:a.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((Q,$)=>{const z=H(Q),Z=B+$;return a.jsx(Dn,{row:Q,rowId:z,columns:n,rowIndex:Z,ariaRowIndex:U!==void 0?U+$:void 0,columnIndexMap:_,isSelected:o.has(z),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:c,columnWidths:f,pinnedColumns:g,pinnedRows:h,hasDetailPanel:x,isDetailPanelExpanded:C.has(z),detailPanelContent:C.has(z)&&p?a.jsx(Ji,{getContent:p,params:{row:Q,id:z,rowIndex:Z}}):null,detailPanelHeight:C.has(z)?lo(so(u,{row:Q,id:z,rowIndex:Z})):void 0,onDetailPanelHeightChange:b,onDetailPanelToggle:m,pinCheckboxColumn:w,pinExpandColumn:v,focusedCellField:E?.id===z?E.field:null,colspanMap:I,rowSpanningCaches:D,rowHeight:P,rowMeta:F.get(z),editingCell:T?.editingCell,onEditStart:T?.startCellEdit,onEditStop:T?.stopCellEdit,onEditCellValueChange:T?.setEditCellValue,isCellEditable:O,rowReordering:S,cellRange:Jr(K,Z,j)},z)})})}const Ad=({columns:e,rowHeight:t,checkboxSelection:n=!1,hasDetailPanel:o=!1,rowReordering:r=!1})=>a.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[n&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const d=typeof i.width=="number"?i.width:150,c=Math.min(d*.7,d-20);return a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:d,minWidth:i.minWidth,maxWidth:i.maxWidth,left:i.left,right:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&a.jsx("div",{className:"ogx-skeleton-box",style:{width:c,height:16,borderRadius:4}})},i.field||l)})]});function Od({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:d,hasDetailPanel:c,rowReordering:f,rowHeight:g,selectedRowIds:h,onRowClick:x,onRowDoubleClick:C,onCellClick:p,onSelectionChange:u,columnWidths:m,pinnedColumns:b,expandedRowIds:w,getDetailPanelContent:v,getDetailPanelHeight:E,onDetailPanelToggle:I,onDetailPanelHeightChange:D,pinCheckboxColumn:P,pinExpandColumn:F,rowReorderHandlers:H,editingHandlers:B,isCellEditable:U,focusedCell:_,colspanMap:T,rowSpanningCaches:O,paginationMode:S,dataSourceLoading:K,sortedUnpinnedRowCount:j,infiniteScrollSkeletonCount:Q,unpinnedRowsLength:$,lastRenderedRowIndex:z,rowMetaMap:Z,loadingOverlay:ie,ariaRowIndexOffset:oe,columnIndexMap:fe,cellRange:de,cellRangeHasRowSpan:ge=!1}){const re=r.length>0?r:(()=>{const ne=(l||1e3)-(d?48:0)-(c?48:0)-(f?48:0),V=150,J=Math.max(1,Math.ceil(ne/V));return Array.from({length:J},(te,se)=>({field:`placeholder_${se}`,headerName:"",width:V}))})(),ae=o.filter(ne=>!ne.pinned),ee=S==="infinite"&&K&&j>0&&z>=$-1;return a.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:a.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[n&&o.length===0&&ie?a.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ie}):n&&o.length===0?Array.from({length:10}).map((ne,V)=>a.jsx(Ad,{columns:re,rowHeight:g,checkboxSelection:d,hasDetailPanel:c,rowReordering:f},`skeleton-${V}`)):ae.map(({row:ne,id:V,rowIndex:J})=>a.jsx(Dn,{row:ne,rowId:V,columns:i,rowIndex:J,ariaRowIndex:oe!==void 0?J+oe:void 0,columnIndexMap:fe,isSelected:h.has(V),checkboxSelection:d,onRowClick:x,onRowDoubleClick:C,onCellClick:p,onSelectionChange:u,columnWidths:m,pinnedColumns:b,hasDetailPanel:c,isDetailPanelExpanded:w.has(V),detailPanelContent:w.has(V)&&v?a.jsx(Ji,{getContent:v,params:{row:ne,id:V,rowIndex:J}}):null,detailPanelHeight:w.has(V)?lo(so(E,{row:ne,id:V,rowIndex:J})):void 0,onDetailPanelHeightChange:D,onDetailPanelToggle:I,pinCheckboxColumn:P,pinExpandColumn:F,rowReordering:f,onDragStart:H.canReorderRow(V)?H.onDragStart:void 0,onDragOver:H.onDragOver,onDragEnd:H.onDragEnd,onDrop:H.onDrop,isDragging:H.draggedRowId===V,isDragOver:H.dragOverRowId===V,editingCell:B.editingCell,onEditStart:B.startCellEdit,onEditStop:B.stopCellEdit,onEditCellValueChange:B.setEditCellValue,isCellEditable:U,focusedCellField:_!=null&&_.id===V?_.field:null,colspanMap:T,rowSpanningCaches:O,rowHeight:g,rowMeta:Z.get(V),cellRange:Jr(de,J,ge)},V)),ee&&a.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:Q}).map((ne,V)=>a.jsx(Dn,{row:{id:`__skeleton_${V}__`,_isSkeleton:!0},columns:i,rowIndex:$+V,rowHeight:g},`__skeleton_${V}__`))})]})})}function Dd(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function $d(){return a.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[a.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function Go(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:c}=e,[f,g]=s.useState(""),h=s.useId(),[x,C]=s.useState(null),p=s.useRef(null),u=s.useMemo(()=>t.filter(F=>F.hideable!==!1),[t]),m=u.every(F=>n.has(F.field)),b=s.useMemo(()=>{const F=c?t:u;if(!f)return F;const H=f.toLowerCase();return F.filter(B=>(B.headerName||B.field).toLowerCase().includes(H))},[t,u,f,c]),w=F=>{F.target.checked?r():i()},v=F=>H=>{p.current=F,H.dataTransfer.effectAllowed="move",H.dataTransfer.setDragImage(H.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},E=F=>H=>{H.preventDefault(),H.dataTransfer.dropEffect="move",F!==p.current&&C(F)},I=()=>{C(null)},D=F=>H=>{H.preventDefault();const B=p.current;C(null),p.current=null,B&&B!==F&&l&&l(B,F)},P=()=>{C(null),p.current=null};return a.jsxs("div",{className:"ogx-column-visibility-panel",children:[a.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:a.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[a.jsx(Dd,{}),a.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:f,onChange:F=>g(F.target.value)})]})}),a.jsx("div",{className:"ogx-column-visibility-panel__list",children:b.map((F,H)=>{const B=`${h}-col-${H}`,U=n.has(F.field),_=F.hideable!==!1,T=x===F.field,O=!!l&&!f;return a.jsxs("div",{className:["ogx-column-visibility-panel__item",!_&&"ogx-column-visibility-panel__item--disabled",T&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:O,onDragOver:O?E(F.field):void 0,onDragLeave:O?I:void 0,onDrop:O?D(F.field):void 0,onDragEnd:O?P:void 0,children:[O&&a.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:v(F.field),title:"Drag to reorder",children:a.jsx($d,{})}),a.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:_?"pointer":"not-allowed"},children:[a.jsx(en,{id:B,checked:U,onChange:S=>o(F.field,S.target.checked),disabled:!_}),a.jsx("label",{htmlFor:B,className:"ogx-column-visibility-panel__label",children:F.headerName||F.field})]})]},F.field)})}),a.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[a.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[a.jsx(en,{id:`${h}-all`,checked:m,onChange:w}),a.jsx("label",{htmlFor:`${h}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),a.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),d?.()},children:"Reset"})]})]})}function Gd({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:d,onColumnMove:c,onColumnOrderReset:f,columnGroupingModel:g}){const[h,x]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const p=t.current.getBoundingClientRect();x({top:p.top+8,right:Nt()-p.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!h)return null;const C=i?void 0:(p,u)=>{To(g,p,u)&&c(p,u)};return ut.createPortal(a.jsxs("div",{ref:n,style:{position:"fixed",top:h.top,right:h.right,zIndex:9999,display:"inline-block"},children:[a.jsx("button",{type:"button",onClick:l,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:"×"}),a.jsx(Go,{columns:o,visibleColumns:new Set(o.filter(p=>r[p.field]!==!1).map(p=>p.field)),onVisibilityChange:(p,u)=>{d({...r,[p]:u})},onShowAll:()=>{const p={...r};o.forEach(u=>{u.hideable!==!1&&(p[u.field]=!0)}),d(p)},onHideAll:()=>{const p={...r};o.forEach(u=>{u.hideable!==!1&&(p[u.field]=!1)}),d(p)},onColumnReorder:C,onColumnOrderReset:i?void 0:f})]}),h.target)}const Zi=[];function Wd(e){const{isPivotActive:t}=e,n=t?Zi:e.rowGroupingModel,o=e.treeData&&!t,r=o&&e.hasTreeDataPath,i=n.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:n,isTreeDataRequested:o,isTreeData:r,isRowGrouping:i,isHierarchyEnabled:r||i,hasGroupingColumn:e.hasGroupingColDef&&(i||r),pagination:e.pagination&&!i&&e.paginationMode!=="infinite",listView:e.listView&&e.hasListViewColumn}}function Hd(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,d=s.useMemo(()=>o?{...n,left:["__group__",...(n?.left??[]).filter(f=>f!=="__group__")]}:n,[o,n]);return{activeColumns:s.useMemo(()=>o?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:f})=>{const g=l(f);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:d}}function Bd(e){return e.id}function zd(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),n=s.useRef(t);s.useLayoutEffect(()=>{n.current=t});const o=s.useCallback(r=>n.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:o}}function Vd(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Kd(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:d,dataRows:c}=e,f=t?.getVisibleRows({expandAll:!0,labelField:d});if(!f)return[...n,...o,...r];const g=c?new Set(c):null;return f.filter(h=>!i.get(l(h))?.isGroupRow&&(!g||g.has(h)))}function Ud(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;const o=e,r=t;return n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(o[i],r[i]))}function jd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>Ud(n,t[o]))}function Rd(e){const[t,n]=s.useState(e),o=jd(t,e);return o||n(e),o?t:e}function qd(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:d}=e,c=Object.keys(i).length>0,f=new Map(r.map(C=>[C.field,C])),g=[],h=[],x=C=>{for(;h.length>0&&h[h.length-1].header.depth>=C;){const p=h.pop();c&&!d?.(p.id)&&g.push({type:"group-subtotal",depth:p.header.depth,groupField:p.header.groupField,groupValue:p.header.groupValue,groupLabel:p.header.groupLabel,aggregatedValues:_n(p.leaves,i,f,"getGroupedExportRows")})}};for(const C of t){const p=n(C),u=o.get(p);if(!u?.isGroupFooter)if(u?.isGroupRow){const m=u.treeDepth??0;x(m);const b={type:"group-header",depth:m,groupField:u.groupingField,groupValue:u.groupingValue,groupLabel:u.groupLabel};g.push(b),h.push({id:p,header:b,leaves:[]})}else g.push({type:"leaf",depth:u?.treeDepth??h.length,row:C}),h.forEach(m=>m.leaves.push(C))}return x(0),c&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Xd(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=()=>n.current;t.current.getAggregationResult=()=>o().hasAggregation?o().aggregationResult:null,t.current.getAggregationModel=()=>o().hasAggregation?o().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:d,rowGroupingHandlers:c,rowMetaMap:f,columns:g,getRowId:h,hierarchyField:x}=o();return d?qd({rows:c.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:h,rowMetaMap:f,columns:g,aggregationModel:l,aggregationResult:r&&c.rootAggregationPosition!==null?i:null,isSubtotalHidden:C=>c.aggregationPositions.get(C)===null}):null}},[t])}const Yd=new Set(["__group__","__check__","__actions__"]);function mt(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!nt(t.field)&&!Yd.has(t.field))}function it(e){return!!e&&e.length>0}function el(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function rn(e,t,n){return it(t)?el(e,t,n):e}function ln(e,t){return!!e&&e.length>0&&!it(t)}function Ft(e,t,n,o,r){if(!o)return null;if(!t||!r||Object.keys(r).length===0)return o;const i=new Map(n.map(l=>[l.field,l]));return _n(e,r,i,"export")}function sn(e,t){const n=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:n}):n}function an(e,t,n){if(!t.valueFormatter)return ro(n,t);if(n==null)try{return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}function Wo(e,t,n,o){return n==null?"":kn(n,t??"",e,o)}function At(e,t){return t?`${e}: ${t}`:e}function tl(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const Jd=/^[=+\-@\t\r]/,Qd=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function $n(e,t=!1){return t||!Jd.test(e)||Qd.test(e)?e:`'${e}`}function lt(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Ne(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zd(e){let t=0,n=e.length;for(;t<n&&e[t]==="'";)t++;for(;n>t&&e[n-1]==="'";)n--;return e.slice(t,n)}const eu=/[\\/?*:[\]]/g,nl=31;function Ho(e,t=new Set){let n=Zd(String(e??"").replace(eu,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,nl).trim();const o=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=n;for(let i=2;o(r);i++){const l=` (${i})`;r=`${n.slice(0,nl-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const tu=new Set([tt,Qt,Jt]),nu=/[\t\n\r"]/;function Bo(e){return nu.test(e)?`"${e.replace(/"/g,'""')}"`:e}function ou(e){return mt(e).filter(t=>!tu.has(t.field))}function ru(e,t){const n=t.map(r=>Bo(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>Bo(an(r,i,Le(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
4
|
-
|
|
5
|
-
`)}function ol(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.getSelection(),o=[];if(n)for(let l=0;l<n.rangeCount;l++)o.push(n.getRangeAt(l));const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.setAttribute("aria-hidden","true"),r.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(r);let i=!1;try{r.focus({preventScroll:!0}),r.select(),i=document.execCommand("copy")}finally{document.body.removeChild(r),t&&t.isConnected&&t.focus({preventScroll:!0}),n&&(n.removeAllRanges(),o.forEach(l=>n.addRange(l)))}return i}async function zo(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(n){if(ol(e))return;throw n}if(!ol(e))throw new Error("Clipboard API not available and fallback failed.")}function su(e){if(!(e.ctrlKey||e.metaKey)||e.altKey||e.shiftKey)return!1;const t=e.key??"";return t.toLowerCase()==="c"?!0:e.code==="KeyC"&&!/^[a-z]$/i.test(t)}function au(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const n=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:d}=t.current,c=new Set(r());if(c.size===0)return;const f=l().filter(h=>c.has(d(h)));if(f.length===0)return;const g=ru(f,ou(i()));await zo(g)},[]),o=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(o)return;const r=i=>{if(i.defaultPrevented||!su(i))return;const l=document.activeElement,d=l?.tagName.toLowerCase(),c=l?.type;if(d==="input"&&c!=="checkbox"&&c!=="radio"||d==="textarea"||d==="select"||l?.isContentEditable)return;const{getRootElement:f}=t.current;if(f){const C=f();if(!C||!l||!C.contains(l))return}const g=window.getSelection();if(g&&!g.isCollapsed&&g.toString()!=="")return;const{getShortcutText:h}=t.current;(h?()=>{const C=h();return C===null?Promise.resolve():zo(C)}:n)().catch(C=>{console.error("[OpenGridX] Failed to copy to clipboard:",C)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n,o]),{copySelectedRows:n}}function cu(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,d=s.useCallback(()=>r.current,[r]),{copySelectedRows:c}=au({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:d,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function du(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:o,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:d}=n.current,c=i.current;if(c&&(o!==void 0&&o>=0&&ao(c,o,l.cumulativeHeights,l.pinnedBottomHeight,d),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;vr(c,l.unpinnedColsWithWidth.findIndex(h=>h.field===g.field),l)}}},[t])}const uu=".ogx";function rl(e,t){const n=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const o=t.getBoundingClientRect().width;t.style.cssText=n;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,d)=>l+(parseFloat(d)||0),0);return o+i}function fu(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(uu)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${n}"]`).forEach(l=>{if(!o(l))return;const d=l.querySelector(".ogx__header-cell-content");d&&i(rl(l,d))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const d=l.querySelector(":scope > .ogx__cell-content");d&&i(rl(l,d))}),r===null?null:Math.ceil(r)}function gu(e,t,n){return Math.max(t??yi,Math.min(n??1/0,e))}function pu(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:d,onColumnResize:c}=n.current,f=l.current;if(!f)return;const g=[];for(const h of i??d.map(x=>x.field)){const x=d.find(p=>p.field===h);if(!x||x.resizable===!1)continue;const C=fu(f,h);C!==null&&g.push([h,gu(C,x.minWidth,x.maxWidth)])}for(const[h,x]of g)c(h,x)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}const il="ogx--range-dragging",st=32,hu=40,mu=300;function ll(e,t){if(!e||e.nodeType!==1)return null;const n=e.closest(".ogx__cell[data-field]");if(!n||n.closest(".ogx__viewport")!==t)return null;const o=n.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const r=n.closest('[role="row"][data-rowindex]');if(!r)return null;const i=Number(r.getAttribute("data-rowindex")),l=n.dataset.field;return!Number.isInteger(i)||!l?null:{rowIndex:i,field:l,element:n}}function Vo(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const sl=(e,t,n)=>Math.min(Math.max(e,t),n),Gn=e=>Math.min(hu,Math.max(2,Math.round(e/2)));function wu(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function xu(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:d,rowMetaMap:c,localeText:f,showStats:g}=e,h=t&&n.length>0?n[0]:null,x=s.useMemo(()=>t?i.filter(y=>ot(y.field)):[],[t,i]),C=s.useMemo(()=>{if(!d.hasColSpan&&!d.hasRowSpan)return;const{colspanMap:y,rowSpanningCaches:M,getSpanOrigin:A}=d;return{getSpanOrigin:A,getColSpan:(N,L)=>{const q=y.get(N)?.[L];return q&&!q.spannedByColSpan?q.cellProps.colSpan:1},getRowSpan:(N,L)=>M.spannedCells[N]?.[L]??1}},[d]),p=s.useMemo(()=>{if(!t)return null;const y=o.map(r),M=new Map;y.forEach((N,L)=>{M.has(N)||M.set(N,L)});const A=x.map(N=>N.field);return{rowIds:y,rowIndexById:M,fields:A,colIndexByField:new Map(A.map((N,L)=>[N,L])),spans:C}},[t,o,r,x,C]),u=s.useMemo(()=>h&&p?Nn(h,p):null,[h,p]),m=u!==null&&In(u)>1,b=s.useMemo(()=>{if(!u||!m||!p)return null;const y=l.get(p.fields[u.left]),M=l.get(p.fields[u.right]);return y===void 0||M===void 0?null:{top:u.top,bottom:u.bottom,left:y,right:M}},[u,m,p,l]),w=s.useCallback(y=>Je(y,c),[c]),v=s.useCallback((y,M,A)=>{if(p)for(let N=y.top;N<=y.bottom;N++){const L=o[N],q=p.rowIds[N];if(!(!L||w(q))){M(L,q);for(let Y=y.left;Y<=y.right;Y++){const G=x[Y],k=C?.getSpanOrigin(q,G.field);A(L,q,G,k!=null&&(k.rowId!==q||k.field!==G.field))}}}},[p,o,x,C,w]),E={...e,range:h,resolved:u,context:p,rangeColumns:x,forEachCell:v},I=s.useRef(E);s.useLayoutEffect(()=>{I.current=E});const D=s.useRef(null),P=s.useCallback(y=>{D.current=y},[]),F=s.useCallback(()=>{const{getPendingModel:y,model:M}=I.current;return y()??M},[]),H=s.useCallback(()=>{const{context:y,range:M,resolved:A,enabled:N}=I.current,L=N?F()[0]??null:null;return!L||!y?{range:null,resolved:null}:L===M?{range:L,resolved:A}:{range:L,resolved:Nn(L,y)}},[F]),B=s.useCallback((y,M)=>{if(!I.current.enabled)return;const A=y.length>1?y.slice(0,1):y;Rs(A,F())||I.current.onModelChange(A,M)},[F]),U=s.useCallback((y,M,A)=>{B([{anchor:y,head:M}],A)},[B]),_=s.useCallback((y,M)=>{const{viewportRef:A,layout:N,rowHeight:L,pinnedTopRowCount:q}=I.current,Y=A.current;Y&&(ao(Y,y-q,N.cumulativeHeights,N.pinnedBottomHeight,L),vr(Y,N.unpinnedColsWithWidth.findIndex(G=>G.field===M),N))},[]),T=s.useCallback((y,M,A,N)=>{const{context:L}=I.current,{range:q,resolved:Y}=H();if(!L||N.id===null||!ot(N.field))return!1;const G=L.rowIndexById.get(N.id),k=L.colIndexByField.get(N.field);if(G===void 0||k===void 0)return!1;const W=q&&Y&&rt(q.anchor,{id:N.id,field:N.field})?{range:q,resolved:Y}:null,R=W?W.range.anchor:{id:N.id,field:N.field},X=W?.resolved??Nn({anchor:R,head:R},L);if(!X)return!1;const ue=Xs(X,y,M,A,L.rowIds.length-1,L.fields.length-1);if(!ue)return!0;const pe={id:L.rowIds[ue.row],field:L.fields[ue.col]};return U(R,pe,"keyboard"),_(ue.row,pe.field),!0},[H,U,_]),O=s.useCallback(()=>{const{range:y,resolved:M}=H();return!y||!M||In(M)<=1?!1:(U(y.anchor,y.anchor,"keyboard"),!0)},[H,U]),S=s.useCallback(()=>{const{context:y}=I.current;return!y||y.rowIds.length===0||y.fields.length===0?!1:(U({id:y.rowIds[0],field:y.fields[0]},{id:y.rowIds[y.rowIds.length-1],field:y.fields[y.fields.length-1]},"selectAll"),!0)},[U]),K=s.useCallback(()=>{const{context:y}=I.current,{range:M,resolved:A}=H();if(!y)return null;if(A)return A;if(M)return null;const N=D.current;return!N||N.id===null||!ot(N.field)?null:Nn({anchor:{id:N.id,field:N.field},head:{id:N.id,field:N.field}},y)},[H]),j=s.useCallback(()=>{const y=K();if(!y)return null;const{rangeColumns:M,forEachCell:A}=I.current,N=In(y);N>Zs&&wu(N);const L=[];if(A(y,W=>{L.push(W)},()=>{}),L.length===0)return null;const q=M.slice(y.left,y.right+1),Y=I.current.context?.spans,G=I.current.getRowId;return lu(L,q,Y?(W,R)=>{const X=G(W),ue=Y.getSpanOrigin(X,R.field);return ue!==null&&(ue.rowId!==X||ue.field!==R.field)}:void 0)},[K]),Q=s.useCallback(()=>{const{forEachCell:y}=I.current,{resolved:M}=H();if(!M)return[];const A=[];return y(M,()=>{},(N,L,q,Y)=>{Y||A.push({id:L,field:q.field,value:Le(N,q.field,q)})}),A},[H]),$=s.useRef(null),z=s.useRef(!1);s.useEffect(()=>()=>$.current?.stop(),[]);const Z=s.useCallback((y,M,A)=>{const N=I.current.context;if(!N)return null;const L=y.ownerDocument;if(typeof L.elementFromPoint!="function")return null;const q=ll(L.elementFromPoint(M,A),y);if(!q)return null;const Y=N.rowIds[q.rowIndex];if(Y===void 0)return null;const G=ot(q.field)?q.field:N.fields[0];return G===void 0?null:{id:Y,field:G}},[]),ie=s.useRef(()=>{}),oe=s.useCallback(y=>{const M=$.current,A=I.current.viewportRef.current;if(!M||!A)return;M.frame=0;const{layout:N}=I.current,L=A.getBoundingClientRect(),q=A.clientWidth,Y=A.clientHeight,G=A.querySelector(":scope > .ogx__content > .ogx__sticky-top"),k=A.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),W=G?.querySelector(":scope > .ogx__header-wrap"),R=G?G.getBoundingClientRect().bottom:L.top,X=Math.min(L.top+Y,k?k.getBoundingClientRect().top:L.top+Y),ue=W?W.getBoundingClientRect().bottom:R,pe=L.left+N.pinnedSystemColumnsWidth+N.leftWidth,he=L.left+q-N.rightWidth,ve=sl(M.x,L.left+1,L.left+q-2);let ye=M.y;(ye<L.top||ye>L.top+Y||ye<ue)&&(ye=sl(ye,R+1,Math.max(R+1,X-2)));const _e=Z(A,ve,ye);if(_e&&!rt(_e,M.head)&&(M.head=_e,!M.moved&&!rt(_e,M.anchor)&&(M.moved=!0,I.current.containerRef.current?.classList.add(il),Vo(A.ownerDocument)),U(M.anchor,_e,"pointer")),!y)return;const ke=M.y<R||M.y>X||M.x<L.left||M.x>L.left+q;if(!M.moved&&!ke)return;let le=0,be=0;M.y<R+st?le=-Gn(R+st-M.y):M.y>X-st&&(le=Gn(M.y-(X-st))),M.x<pe+st?be=-Gn(pe+st-M.x):M.x>he-st&&(be=Gn(M.x-(he-st)));const Me=le<0&&A.scrollTop>0||le>0&&A.scrollTop+Y<A.scrollHeight-1,Se=be<0&&A.scrollLeft>0||be>0&&A.scrollLeft+q<A.scrollWidth-1;!Me&&!Se||(Me&&(A.scrollTop+=le),Se&&(A.scrollLeft+=be),M.frame=requestAnimationFrame(()=>ie.current(!0)))},[Z,U]);s.useLayoutEffect(()=>{ie.current=oe},[oe]);const fe=s.useCallback((y,M,A,N,L)=>{$.current?.stop();const q=R=>{const X=$.current;if(X){if(R.buttons===0){X.stop();return}X.x=R.clientX,X.y=R.clientY,X.moved&&(R.preventDefault(),Vo(L)),X.frame||(X.frame=requestAnimationFrame(()=>oe(!0)))}},Y=R=>{const X=$.current;if(!X)return;X.x=R.clientX,X.y=R.clientY,oe(!1);const ue=X.moved;X.stop(),ue&&Vo(L),ue&&(z.current=!0,setTimeout(()=>{z.current=!1},0))},G=L.defaultView,k=()=>$.current?.stop(),W={anchor:y,head:M,x:A,y:N,frame:0,moved:!1,stop:()=>{W.frame&&cancelAnimationFrame(W.frame),W.frame=0,L.removeEventListener("mousemove",q,!0),L.removeEventListener("mouseup",Y,!0),G?.removeEventListener("blur",k),I.current.containerRef.current?.classList.remove(il),$.current===W&&($.current=null)}};$.current=W,L.addEventListener("mousemove",q,!0),L.addEventListener("mouseup",Y,!0),G?.addEventListener("blur",k)},[oe]),de=s.useCallback(y=>{if(y.button!==0||y.defaultPrevented)return;const{context:M}=I.current;if(!M)return;const A=y.currentTarget,N=ll(y.target,A);if(!N||!ot(N.field)||N.element.classList.contains("ogx__cell--editing")||jr(y.target))return;const L=M.rowIds[N.rowIndex];if(L===void 0)return;const q={id:L,field:N.field};let Y=q;if(y.shiftKey){const G=F()[0],k=D.current;G&&M.rowIndexById.has(G.anchor.id)&&M.colIndexByField.has(G.anchor.field)?Y=G.anchor:k&&k.id!==null&&ot(k.field)&&(Y={id:k.id,field:k.field}),y.preventDefault(),z.current=!0;const W=A.ownerDocument;A.contains(W.activeElement)||A.focus({preventScroll:!0})}if(U(Y,q,"pointer"),fe(Y,q,y.clientX,y.clientY,A.ownerDocument),y.shiftKey){const G=$.current;G&&!rt(Y,q)&&(G.moved=!0)}},[F,U,fe]),ge=s.useCallback(y=>{z.current&&(z.current=!1,y.stopPropagation(),y.preventDefault())},[]),re=u?u.right-u.left+1:0,ae=u?u.bottom-u.top+1:0,ee=f?.cellSelectionAnnouncement??Qs,ne=m?ee(ae*re,ae,re):"",[V,J]=s.useState("");s.useEffect(()=>{if(!t)return;const y=setTimeout(()=>J(ne),mu);return()=>clearTimeout(y)},[t,ne]);const te=s.useMemo(()=>{if(!g||!u||!m)return null;const y=[];v(u,()=>{},(A,N,L,q)=>{q||y.push(Le(A,L.field,L))});const M=y.filter(A=>typeof A=="number"&&!Number.isNaN(A));return{cellCount:In(u),rowCount:u.bottom-u.top+1,columnCount:u.right-u.left+1,count:pt.count(y),numericCount:M.length,sum:M.length?pt.sum(M):null,average:M.length?pt.avg(M):null}},[g,u,m,v]),se=s.useMemo(()=>t?{extendSelection:T,collapseSelection:O,selectAllCells:S}:void 0,[t,T,O,S]);return{enabled:t,range:h,resolved:u,displayRange:b,hasRowSpan:d.hasRowSpan,handleMouseDown:t?de:void 0,handleClickCapture:t?ge:void 0,extendSelection:T,collapseSelection:O,selectAllCells:S,keyboard:se,getCopyText:j,getSelectedCells:Q,announcement:t?V:"",stats:te,reportFocus:P,setModel:B}}function bu(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useRef(null),r=s.useRef(null),i=s.useRef(null),{selection:l,model:d,focusedCell:c,setFocusedCell:f,containerRef:g}=e,h=l.range?.anchor??null,x=l.resolved?.anchorRow;s.useLayoutEffect(()=>{l.reportFocus(c);const C=!rt(o.current,h),p=!yo(r.current,c);if(o.current=h,r.current=c,!!l.enabled){if(l.range&&!l.resolved){i.current!==d&&(i.current=d,l.setModel([],"dataChange"));return}if(C&&h){(!c||c.id!==h.id||c.field!==h.field)&&f({id:h.id,field:h.field,rowIndex:x});return}if(p&&c&&c.id!==null&&ot(c.field)&&!rt(h,{id:c.id,field:c.field})){const u={id:c.id,field:c.field},m=g.current?.classList.contains("ogx--kb")??!1;l.setModel([{anchor:u,head:u}],m?"keyboard":"pointer")}}},[l,d,h,x,c,f,g]),s.useLayoutEffect(()=>{const C=t.current,p=()=>n.current;C.getCellSelectionModel=()=>{const{selection:u,getPendingModel:m,model:b}=p();return u.enabled?m()??b:[]},C.setCellSelectionModel=u=>{p().selection.setModel(u,"api")},C.selectCellRange=(u,m)=>{p().selection.setModel([{anchor:u,head:m}],"api")},C.clearCellSelection=()=>{p().selection.setModel([],"clear")},C.getSelectedCells=()=>p().selection.getSelectedCells(),C.copySelectedCells=async()=>{const{selection:u}=p();if(!u.enabled)return;const m=u.getCopyText();m!==null&&await zo(m)}},[t])}function al({count:e,sum:t,average:n}){return a.jsxs("div",{className:"ogx__cell-selection-stats",children:[a.jsxs("span",{className:"ogx__cell-selection-stat",children:[a.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Count"}),a.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"count",children:e.toLocaleString()})]}),t!==null&&a.jsxs("span",{className:"ogx__cell-selection-stat",children:[a.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Sum"}),a.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:qt(t,"sum")})]}),n!==null&&a.jsxs("span",{className:"ogx__cell-selection-stat",children:[a.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Average"}),a.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:qt(n,"avg")})]})]})}function Cu({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??al;return a.jsx("div",{className:"ogx__cell-selection-stats-area","aria-hidden":e?void 0:!0,children:e&&a.jsx(r,{apiRef:t,...e,...o})})}function vu(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function yu(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(c=>{t(),n(!1),o({id:r(c.row),field:c.field,rowIndex:c.rowIndex}),i?.(c)},[i,n,o,t,r]),d=s.useCallback(c=>{t(),o({id:null,field:c}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:d}}function Su({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:d}){const c=e||Ao;return a.jsx(c,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:f=>l({...o,page:f}),onPageSizeChange:f=>l({...o,pageSize:f,page:0}),localeText:ii(d),...t})}function _u({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l}){return a.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${vi(t)}`:"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:""),l?a.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null]})}function ku(e){const{headerRowCount:t,pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+n+i+o,topBase:t+1,centerOffset:t+l+1,bottomBase:t+n+i+1,bottomRowIndexOffset:n+r}}function Eu(e){const{columnGroupingModel:t,pinnedTopCount:n,pinnedBottomCount:o,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:d,paginatedUnpinnedRowCount:c,sortedUnpinnedRowCount:f}=e,{page:g,pageSize:h}=l;return s.useMemo(()=>ku({headerRowCount:1+Si(t),pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r?c:f,totalCenterRowCount:r&&i==="server"?Math.max(d,c):f,pageOffset:r?g*h:0}),[t,n,o,r,c,f,i,d,g,h])}function Mu(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,pivotMode:c,pivotModelProp:f,onPivotModelChangeProp:g,pivotModel:h,onPivotModelChange:x,filterModel:C,onFilterModelChange:p,columnVisibilityModel:u,onColumnVisibilityModelChange:m,disableColumnReorder:b,columnGroupingModel:w,moveColumn:v,resetColumnOrder:E,forceColumnsOpen:I,onColumnsPanelClose:D}=e;return s.useMemo(()=>t?{apiRef:o,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,...c||f||g?{pivotModel:h,onPivotModelChange:x}:{},filterModel:C,onFilterModelChange:p,columnVisibilityModel:u,onColumnVisibilityModelChange:m,onColumnReorder:b?void 0:(F,H)=>{To(w,F,H)&&v(F,H)},onColumnOrderReset:b?void 0:E,forceColumnsOpen:I,onColumnsPanelClose:D,...n}:null,[t,b,v,E,r,o,i,l,d,c,f,g,h,x,C,p,u,m,I,D,n,w])}function Nu(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,autoHeight:d=!1,density:c,checkboxSelection:f=!1,disableRowSelectionOnClick:g=!1,disableMultipleRowSelection:h=!1,disableClipboardCopy:x=!1,cellSelection:C=!1,cellSelectionModel:p,onCellSelectionModelChange:u,showCellSelectionStats:m=!1,rowSelectionModel:b,onRowSelectionModelChange:w,onRowClick:v,onRowDoubleClick:E,onCellClick:I,filterModel:D,onFilterModelChange:P,sortModel:F,onSortModelChange:H,pagination:B=!1,paginationModel:U,onPaginationModelChange:_,pageSizeOptions:T=[10,25,50,100],pinnedColumns:O,onPinnedColumnsChange:S,pinnedRows:K,getDetailPanelContent:j,getDetailPanelHeight:Q,detailPanelExpandedRowIds:$,onDetailPanelExpandedRowIdsChange:z,pinCheckboxColumn:Z=!0,pinExpandColumn:ie=!0,disableColumnReorder:oe=!1,columnOrder:fe,onColumnOrderChange:de,onColumnOrderModelChange:ge,height:re,rowReordering:ae=!1,onRowOrderChange:ee,loading:ne=!1,treeData:V=!1,getTreeDataPath:J,defaultGroupingExpansionDepth:te,groupingColDef:se,rowGroupingModel:y,aggregationModel:M,onAggregationModelChange:A,getAggregationPosition:N,isCellEditable:L,processRowUpdate:q,onProcessRowUpdateError:Y,dataSource:G,multiSort:k=!1,sortingMode:W="client",filterMode:R="client",paginationMode:X="client",rowCount:ue,slots:pe,slotProps:he,pivotMode:ve=!1,pivotModel:ye,onPivotModelChange:_e,className:ke="",style:le,onRowsScrollEnd:be,ariaLabel:Me,initialState:Se,onStateChange:me,columnVisibilityModel:ce,onColumnVisibilityModelChange:we,listView:Ce=!1,listViewColumn:Ee,columnGroupingModel:Ge,noRowsLabel:Oe="No Data",localeText:Fe,apiRef:Wt,overscanRowCount:We=3}=e,fn=Rd(n),gn=Fe?.noRowsLabel??Oe,pn=y||Zi,Re=la({initialState:Se,sortModel:F,onSortModelChange:H,filterModel:D,onFilterModelChange:P,aggregationModel:M,onAggregationModelChange:A,columnVisibilityModel:ce,onColumnVisibilityModelChange:we,pinnedColumns:O,onPinnedColumnsChange:S,pivotModel:ye,onPivotModelChange:_e,paginationModel:U,onPaginationModelChange:_,pageSizeOptions:T,rowSelectionModel:b,onRowSelectionModelChange:w,density:c,cellSelectionModel:p,onCellSelectionModelChange:u}),{sortModel:Ve,handleSortModelChange:$l,filterModel:at,handleFilterModelChange:Gl,aggregationModel:Ke,handleAggregationModelChange:qf,columnVisibilityModel:wt,handleColumnVisibilityModelChange:jo,pinnedColumns:Ro,handlePinnedColumnsChange:Xf,currentPivotModel:Wl,handlePivotModelChange:Yf,effectivePaginationModel:He,handlePaginationModelChange:Ht,selectedRowIds:Jf,handleRowSelectionModelChange:qo,density:Hl}=Re,hn=ud({rows:t,columns:fn,pivotMode:ve,pivotModel:Wl,filterModel:at,sortModel:Ve,hasDataSource:!!G,hierarchyRequested:V||pn.length>0}),xt=hn.isActive,{rowReordering:bt,hierarchyRowGroupingModel:Qf,isTreeDataRequested:Zf,isTreeData:zn,isRowGrouping:Bt,isHierarchyEnabled:Vn,hasGroupingColumn:eg,pagination:qe,listView:zt}=Wd({rowGroupingModel:pn,treeData:V,hasTreeDataPath:!!J,isPivotActive:xt,rowReordering:ae,hasGroupingColDef:!!se,pagination:B,paginationMode:X,listView:Ce,hasListViewColumn:!!Ee}),{rowHeight:Qe,headerHeight:Xo}=ua({rowHeight:r,headerHeight:i,density:Hl}),tg=hn.rows,ng=hn.columns,{activeColumns:Ct,effectivePinnedColumns:Vt}=Hd({baseColumns:ng,pinnedColumns:Ro,hasGroupingColumn:eg,groupingColDef:se,isTreeData:zn,getTreeDataPath:J}),Yo=Ra(Ct,wt),[og,rg]=ad(Ke),ct=s.useRef(null),Kn=s.useRef(null),Bl=!xt&&o||Bd,Jo=vu(ct),Un=Nc({rows:tg,getRowId:Bl,columns:Ct,rowHeight:Qe,headerHeight:Xo,columnVisibilityModel:wt,initialState:e.initialState,syncRows:!G}),{state:Ie,apiRef:vt,setRows:ig,replaceRow:lg,setColumns:sg,setDimensions:ag,setDataSourceLoading:cg,setDataSourceError:dg,setRowCount:ug}=Un,{getRowIdOf:Pe,getRowIdOfInEvents:fg}=zd(Ie.rows.idByRow);Vd(Wt,vt);const gg=Ie.dataSource.loading,dt=ne||gg,jn=s.useMemo(()=>Ie.rows.allRows.map(_t=>Ie.rows.idRowsLookup.get(_t)),[Ie.rows]),{treeDataHandlers:Rn,rowGroupingHandlers:Qo,activeHierarchyHandlers:Kt,rowMetaMap:Ue}=Uc({rows:jn,getRowId:Pe,getTreeDataPath:J,isTreeDataRequested:Zf,isTreeData:zn,columns:Ct,rowGroupingModel:Qf,isRowGrouping:Bt,aggregationModel:Ke,defaultGroupingExpansionDepth:te,filterModel:at,sortModel:Ve,getAggregationPosition:N,columnLookup:Yo,filterMode:R,sortingMode:W}),zl=Rc({rows:jn,getRowId:Pe,columns:Ct,processRowUpdate:q,onProcessRowUpdateError:Y,onRowChange:(_t,Bg)=>{lg(Bg,_t)}}),mn=Va({selectedRowIds:Jf,rowsLookup:Ie.rows.idRowsLookup,rowMetaMap:Ue,enabled:!G&&!xt&&X==="client"&&R==="client",onSelectionModelChange:qo}),Vl=id({dataSource:G,sortModel:Ve,filterModel:at,paginationModel:He,paginationMode:X,sortingMode:W,filterMode:R,aggregationModel:Ke,rowGroupingActive:Bt,getRowId:Bl,setRows:ig,setRowCount:ug,setDataSourceLoading:cg,setDataSourceError:dg,onAggregationResults:rg,onPaginationModelChange:Ht});sd({enabled:zn&&!!G,treeNodes:Rn.treeNodes,isGroupExpanded:Rn.isGroupExpanded,getNodePath:Rn.getNodePath,toggleExpansion:Rn.toggleExpansion,fetchChildren:Vl.fetchChildren});const{hasDetailPanel:yt,expandedRowIds:Zo,handleDetailPanelToggle:Kl,detailPanelHeights:pg,reportDetailPanelHeight:hg}=Pa({hasDetailPanel:!!j,controlledExpandedRowIds:$,onDetailPanelExpandedRowIdsChange:z,rowMetaMap:Ue}),{effectiveColumns:Ul,hierarchyField:er,orderedColumns:tr,visibleOrderedColumns:jl,renderOrderedColumns:mg,navigationColumns:nr,columnIndexMap:or,columnWidths:wn,effectiveColumnOrder:wg,columnReorderHandlers:xg,moveColumn:Rl,resetColumnOrder:ql,handleColumnResize:Xl}=va({activeColumns:Ct,isHierarchyEnabled:Vn,isRowGrouping:Bt,isTreeData:zn,activeHierarchyHandlers:Kt,columnVisibilityModel:wt,columnOrder:fe,onColumnOrderChange:de,onColumnOrderModelChange:ge,disableColumnReorder:oe,pivotMode:xt,checkboxSelection:f,hasDetailPanel:yt,rowReordering:bt,initialState:Se,setColumns:sg,pinnedColumns:Vt,getRowId:fg,aggregationModel:Ke,groupingRows:Bt?Qo.groupingRows:void 0});Fa({onStateChange:me,sortModel:Ve,filterModel:at,effectivePaginationModel:He,columnWidths:wn,effectiveColumnOrder:wg,columnVisibilityModel:wt,pinnedColumns:Ro,density:Hl});const qn=ga({effectiveRows:jn,activeHierarchyHandlers:Kt,filterMode:R,filterModel:hn.pipelineFilterModel,sortModel:hn.pipelineSortModel,sortingMode:W,pagination:qe,paginationMode:X,effectivePaginationModel:He,pinnedRows:K,getRowId:Pe,columnLookup:Yo,hierarchyField:er}),{filteredRows:Yl,dataRows:Ut,pinnedTopRows:Be,pinnedBottomRows:Xe,sortedUnpinnedRows:Ze,paginatedUnpinnedRows:Xn,allRenderableRows:xn}=qn,rr=qe?Xn:Ze;qa({paginationModel:He,currentPage:qn.currentPage,enabled:qe&&!dt&&Ze.length>0,onPaginationModelChange:Ht});const Yn=fa({paginationMode:X,hasDataSource:!!G,dataSourceRowCount:Ie.pagination.rowCount,rowCountProp:ue,clientRowCount:Ze.length}),{rowSelection:ir,handleRowClick:lr,handleSelectionChange:sr}=za({dataRows:Ut,getRowId:Pe,isPivotActive:xt,selectedRowIds:mn,onSelectionModelChange:qo,disableMultipleRowSelection:h,disableRowSelectionOnClick:g,isHierarchyEnabled:Vn,rowMetaMap:Ue,activeHierarchyHandlers:Kt,onRowClick:v});ja({apiRef:Un.apiRef,sortModel:Ve,multiSort:k,onSortModelChange:$l,filterModel:at,onFilterModelChange:Gl,paginationModel:He,onPaginationModelChange:Ht,selectedRowIds:mn,getPendingRowSelectionModel:Re.getPendingRowSelectionModel,onRowSelectionModelChange:qo,disableMultipleRowSelection:h,isSyntheticRowId:_t=>Je(_t,Ue),getVisibleRows:()=>[...Be,...rr,...Xe],getAllFilteredRows:()=>Kd({hierarchyHandlers:Kt,pinnedTopRows:Be,sortedUnpinnedRows:Ze,pinnedBottomRows:Xe,rowMetaMap:Ue,getRowId:Pe,hierarchyField:er,dataRows:Ut}),visibleColumns:mg});const bg=Ic({rows:jn,getRowId:Pe,onRowOrderChange:ee,rowReordering:bt}),{aggregationResult:ar,isLoading:Cg}=Ri({rows:Ut,columns:Ct,aggregationModel:xt?xs:Ke,isServerSide:bi({dataSource:G,paginationMode:X,sortingMode:W,filterMode:R}),dataSource:G,filterModel:at,sortModel:Ve,serverAggregationResults:og}),cr=Object.keys(Ke).length>0&&!xt;Xd({apiRef:vt,hasAggregation:cr,aggregationResult:ar,aggregationModel:Ke,isRowGrouping:Bt,rowGroupingHandlers:Qo,rowMetaMap:Ue,columns:Ct,getRowId:Pe,hierarchyField:er});const Te=ms({rowHeight:Qe,pagination:qe,paginatedUnpinnedRows:Xn,sortedUnpinnedRows:Ze,expandedRowIds:Zo,getDetailPanelHeight:Q,detailPanelHeights:pg,pinnedTopRowsLength:Be.length,pinnedBottomRowsLength:Xe.length,pinnedTopRows:Be,pinnedBottomRows:Xe,visibleOrderedColumns:jl,pinnedColumns:Vt,columnWidths:wn,viewportWidth:Ie.dimensions.viewportWidth||1e3,checkboxSelection:f,hasDetailPanel:yt,rowReordering:bt,pinCheckboxColumn:Z,pinExpandColumn:ie,paginationMode:X,isLoading:Ie.dataSource.loading,pageSize:He.pageSize,getRowId:Pe}),jt=Qc({pinnedTopRows:Be,centerRows:rr,pinnedBottomRows:Xe,columns:jl,leftPinnedColumns:Te.leftPinnedCols,unpinnedColumns:Te.unpinnedColsWithWidth,rightPinnedColumns:Te.rightPinnedCols,expandedRowIds:yt?Zo:void 0,rowMetaMap:Ue,getRowId:Pe}),Jl=s.useMemo(()=>[...Te.leftPinnedCols,...Te.unpinnedColsWithWidth,...Te.rightPinnedCols],[Te.leftPinnedCols,Te.unpinnedColsWithWidth,Te.rightPinnedCols]),ze=xu({enabled:C&&!zt,model:Re.cellSelectionModel,onModelChange:Re.handleCellSelectionModelChange,getPendingModel:Re.getPendingCellSelectionModel,allRenderableRows:xn,getRowId:Pe,navigationColumns:nr,columnIndexMap:or,spanning:jt,rowMetaMap:Ue,layout:Te,rowHeight:Qe,pinnedTopRowCount:Be.length,viewportRef:Kn,containerRef:ct,localeText:Fe,showStats:m});cu({apiRef:vt,columns:Jl,getRowId:Pe,containerRef:ct,disableKeyboardShortcut:x,getCellRangeCopyText:ze.enabled?ze.getCopyText:void 0}),du({apiRef:vt,viewportRef:Kn,layout:Te,rowHeight:Qe});const vg=pu({apiRef:vt,containerRef:ct,columns:tr,onColumnResize:Xl}),{scrollTop:yg,scrollLeft:Sg,overscanRows:_g,handleScroll:kg,setViewportElement:Eg}=Na({onRowsScrollEnd:be,overscanRowCount:We,rowCount:Te.unpinnedRowsLength,autoHeight:d,setDimensions:ag,viewportRef:Kn}),Ae=pa({layout:Te,scrollTop:yg,scrollLeft:Sg,viewportWidth:Ie.dimensions.viewportWidth,viewportHeight:Ie.dimensions.viewportHeight,autoHeight:d,rowReordering:bt,hasDetailPanel:yt,checkboxSelection:f,pinCheckboxColumn:Z,pinExpandColumn:ie,overscanRows:_g}),{handleSort:Ql,handleSortAdd:Zl}=Ka({sortModel:Ve,onSortModelChange:$l}),Jn=f||!g,{focusedCell:dr,setFocusedCell:es,viewportTabIndex:Mg,ensureGridFocus:Ng,handleFocus:Ig,handleBlur:Pg,handleKeyDown:Tg,handleMouseDownCapture:Lg}=na({allRenderableRows:xn,navigationColumns:nr,checkboxSelection:f,selectedRowIds:mn,handleSelectionChange:sr,handleDetailPanelToggle:Kl,editingHandlers:zl,setKeyboardMode:Jo,sortModel:Ve,handleSort:Ql,handleSortAdd:Zl,multiSort:k,isCellEditable:L,pagination:qe,pageSize:He.pageSize,virtualization:Ae,viewportRef:Kn,pinnedTopRowCount:Be.length,getRowId:Pe,rowMetaMap:Ue,getSpanOrigin:jt.getSpanOrigin,onRowActivate:lr,toggleRowExpansion:Kt?.toggleExpansion,handleSelectAll:ir.selectAll,rowSelectionEnabled:Jn,multipleRowSelectionEnabled:!h,pinCheckboxColumn:Z,pinExpandColumn:ie,rowHeight:Qe,cellSelection:ze.keyboard}),{handleCellClick:Fg,handleHeaderClick:Ag}=yu({ensureGridFocus:Ng,setKeyboardMode:Jo,setFocusedCell:es,getRowId:Pe,onCellClick:I});bu({apiRef:vt,selection:ze,model:Re.cellSelectionModel,getPendingModel:Re.getPendingCellSelectionModel,focusedCell:dr,setFocusedCell:es,containerRef:ct});const{handleHideColumn:Og,handlePinColumn:Dg}=Ua({columnVisibilityModel:wt,onColumnVisibilityModelChange:jo,pinnedColumns:Ro,onPinnedColumnsChange:Xf}),bn=Eu({columnGroupingModel:Ge,pinnedTopCount:Be.length,pinnedBottomCount:Xe.length,pagination:qe,paginationMode:X,paginationModel:He,paginationRowCount:Yn,paginatedUnpinnedRowCount:Xn.length,sortedUnpinnedRowCount:Ze.length}),ur=ed({spanning:jt,renderContext:Ae.renderContext,offsetTop:Ae.offsetTop,cumulativeHeights:Te.cumulativeHeights}),fr=Sa({renderContext:ur.renderContext,pinnedTopRows:Be,pinnedBottomRows:Xe,paginatedUnpinnedRows:Xn,sortedUnpinnedRows:Ze,pagination:qe,getRowId:Pe}),Qn=td({spanning:jt,firstColumnIndex:Ae.renderContext.firstColumnIndex,lastColumnIndex:Ae.renderContext.lastColumnIndex,virtualColumns:Ae.virtualColumns,layout:Te,rows:fr});$a({paginationRequested:B,isRowGrouping:Bt,autoHeight:d,viewportHeight:Ie.dimensions.viewportHeight,renderedRowCount:fr.length,totalRowCount:Be.length+rr.length+Xe.length,pinnedRowsIgnored:Vn&&!!(K?.top?.length||K?.bottom?.length),scrollHeight:Ae.totalHeight,listViewWithoutColumn:Ce&&!Ee,listViewRowCount:zt&&Ee?xn.length:0});const{allSelected:$g,someSelected:Gg}=ir,Rt=nd(Ge,xg),Wg=s.useMemo(()=>Ul.some(_t=>!!_t.rowSpan),[Ul]),St=Xa();Wa(ct);const ts=pe?.noRowsOverlay,ns=pe?.loadingOverlay,gr=ns?a.jsx(ns,{...he?.loadingOverlay}):void 0,os=ts?a.jsx(ts,{...he?.noRowsOverlay}):void 0,Zn=pe?.footer,Hg=dt&&xn.length>0&&X!=="infinite",rs=pe?.toolbar,is=Mu({toolbar:pe?.toolbar,toolbarSlotProps:he?.toolbar,apiRef:vt,orderedColumns:tr,baseColumns:fn,aggregationModel:Ke,onAggregationModelChange:qf,pivotMode:ve,pivotModelProp:ye,onPivotModelChangeProp:_e,pivotModel:Wl,onPivotModelChange:Yf,filterModel:at,onFilterModelChange:Gl,columnVisibilityModel:wt,onColumnVisibilityModelChange:jo,disableColumnReorder:oe,columnGroupingModel:Ge,moveColumn:Rl,resetColumnOrder:ql,forceColumnsOpen:St.toolbarPanelRequested,onColumnsPanelClose:St.closeToolbarPanel}),pr={rowReordering:bt,columnIndexMap:or,editingHandlers:zl,isCellEditable:L,selectedRowIds:mn,checkboxSelection:f,onRowClick:lr,onRowDoubleClick:E,onCellClick:Fg,onSelectionChange:sr,columnWidths:wn,pinnedColumns:Vt,hasDetailPanel:yt,expandedRowIds:Zo,getDetailPanelContent:j,getDetailPanelHeight:Q,onDetailPanelToggle:Kl,onDetailPanelHeightChange:hg,pinCheckboxColumn:Z,pinExpandColumn:ie,focusedCell:dr,colspanMap:jt.colspanMap,rowSpanningCaches:jt.rowSpanningCaches,rowHeight:Qe,rowMetaMap:Ue,cellRange:ze.displayRange,cellRangeHasRowSpan:ze.hasRowSpan};return a.jsxs("div",{ref:ct,className:["ogx",ke,d&&"ogx--auto-height",!d&&re===void 0&&le?.height===void 0&&"ogx--fill",Wg&&"ogx--row-spanning",zt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...le,height:re??le?.height,"--ogx-row-height":`${Qe}px`,"--ogx-header-height":`${Xo}px`},"aria-busy":dt,children:[rs&&is&&a.jsx(wi.Provider,{value:St.toolbarHost,children:a.jsx(Qa,{component:rs,toolbarProps:is})}),a.jsx(Gd,{isOpen:St.standalonePanelOpen,containerRef:ct,panelRef:St.standalonePanelRef,columns:tr,columnVisibilityModel:wt,disableColumnReorder:oe,onClose:St.closeStandalonePanel,onColumnVisibilityChange:jo,onColumnMove:Rl,onColumnOrderReset:ql,columnGroupingModel:Ge}),zt&&Ee&&a.jsx(hd,{ariaLabel:Me,allRenderableRows:xn,dataRowCount:Ut.length,pinnedTopRowCount:Be.length,pinnedBottomRowCount:Xe.length,unpinnedRowCount:Ze.length,pagination:qe,effectivePaginationModel:He,currentPage:qn.currentPage,pageSizeOptions:T,selectedRowIds:mn,listViewColumn:Ee,columnsByField:Yo.byField,rowMetaMap:Ue,noRowsLabel:gn,rowHeight:Qe,checkboxSelection:f,paginationMode:X,serverRowCount:Yn,paginationSlot:pe?.pagination,paginationSlotProps:he?.pagination,localeText:ii(Fe),onRowClick:lr,onRowDoubleClick:E,onSelectionChange:sr,onPaginationModelChange:Ht,onRowsScrollEnd:be,getRowId:Pe,multiselectable:Jn&&!h,selectable:Jn,onToggleExpansion:Kt?.toggleExpansion,loading:dt,loadingOverlay:gr,noRowsOverlay:os,showPaginationControls:!Zn}),!zt&&a.jsx("div",{ref:Eg,className:"ogx__viewport",onScroll:kg,role:"grid","aria-label":Me||"Data grid","aria-rowcount":bn.rowCount,"aria-colcount":nr.length,"aria-multiselectable":Jn&&!h||ze.enabled,"aria-busy":dt,tabIndex:Mg,onKeyDownCapture:()=>{Jo(!0)},onMouseDownCapture:Lg,onMouseDown:ze.handleMouseDown,onClickCapture:ze.handleClickCapture,onKeyDown:Tg,onFocus:Ig,onBlur:Pg,children:a.jsxs("div",{className:"ogx__content",style:{width:Vt?.right?.length?`max(100%, ${Ae.totalWidth}px)`:Ae.totalWidth},role:"presentation",children:[a.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[a.jsx(Ei,{columns:Qn,allColumns:Jl,columnGroupingModel:Ge,checkboxSelection:f,allSelected:$g,someSelected:Gg,onSelectAll:ir.selectAll,sortModel:Ve,onSort:Ql,onSortAdd:Zl,multiSort:k,onColumnResize:Xl,onColumnAutosize:vg,columnWidths:wn,pinnedColumns:Vt,focusedCell:dr,columnIndexMap:or,onHeaderClick:Ag,onDragStart:Rt.onDragStart,onDragOver:Rt.onDragOver,onDragEnd:Rt.onDragEnd,onDrop:Rt.onDrop,draggedColumn:Rt.draggedColumn,dragOverColumn:Rt.dragOverColumn,rowReordering:bt,hasDetailPanel:yt,pinCheckboxColumn:Z,pinExpandColumn:ie,aggregationModel:Ke,onHideColumn:Og,onManageColumns:St.openColumnsPanel,onPinColumn:Dg,wrapHeaderText:l,headerHeight:Xo}),a.jsx(Qi,{...pr,rows:Be,position:"top",ariaRowIndexBase:bn.topBase,columns:Qn,pinnedRows:K,getRowId:Pe})]}),!dt&&!Ie.dataSource.error&&Yl.length===0&&a.jsx(ec,{noRowsLabel:gn,width:Ae.totalWidth,overlay:os}),a.jsx(Od,{...pr,virtualContainerHeight:Ae.totalHeight-Ae.pinnedTopHeight-Ae.pinnedBottomHeight,offsetTop:ur.offsetTop,effectiveLoading:dt,visibleRows:fr,baseColumns:fn,virtualColumns:Qn,viewportWidth:Ie.dimensions.viewportWidth,rowReorderHandlers:bg,paginationMode:X,dataSourceLoading:Ie.dataSource.loading,sortedUnpinnedRowCount:Ze.length,infiniteScrollSkeletonCount:Math.min(He.pageSize,20),unpinnedRowsLength:Te.unpinnedRowsLength,lastRenderedRowIndex:ur.renderContext.lastRowIndex,ariaRowIndexOffset:bn.centerOffset,loadingOverlay:gr}),a.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[a.jsx(Qi,{...pr,rows:Xe,position:"bottom",rowIndexOffset:bn.bottomRowIndexOffset,ariaRowIndexBase:bn.bottomBase,columns:Qn,pinnedRows:K,getRowId:Pe}),cr&&Qo.rootAggregationPosition!==null&&a.jsx(Za,{columns:Ae.virtualColumns,aggregationModel:Ke,aggregationResult:ar,columnWidths:wn,rowHeight:Qe,checkboxSelection:f,hasDetailPanel:yt,rowReordering:bt,pinCheckboxColumn:Z,pinExpandColumn:ie,pinnedColumns:Vt,loading:Cg})]})]})}),ze.enabled&&m&&a.jsx(Cu,{stats:ze.stats,apiRef:Un.apiRef,slot:pe?.cellSelectionStats,slotProps:he?.cellSelectionStats}),Zn&&a.jsx(Zn,{apiRef:Un.apiRef,aggregationModel:Ke,aggregationResult:cr?ar:null,rowCount:Vn&&X!=="server"?Ut.length:Yn,pagination:qe,paginationModel:He,pageSizeOptions:T,onPaginationModelChange:Ht,...he?.footer}),!zt&&!Zn&&qe&&a.jsx(Su,{paginationSlot:pe?.pagination,paginationSlotProps:he?.pagination,page:qn.currentPage,paginationModel:He,rowCount:Yn,pageSizeOptions:T,onPaginationModelChange:Ht,localeText:Fe}),a.jsx(_u,{loading:dt,error:Ie.dataSource.error,noRowsLabel:gn,filteredRowCount:Yl.length,dataRowCount:Ut.length,filterModel:at,cellSelectionAnnouncement:ze.announcement}),Hg&&a.jsx(md,{overlay:gr}),a.jsx(nc,{error:Ie.dataSource.error,onRetry:G?Vl.fetchRows:void 0})]})}function Iu({rows:e=5,columns:t=5}){return a.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((n,o)=>a.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-content"})},i))},o))})}const Pu=300;function Ot(e){return"field"in e&&!("items"in e)}function cl(e,t){return e.find(n=>Ot(n)&&n.field===t)}function dl(e,t){return Object.is(e,t)?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>dl(n,t[o])):!1}function Tu(e,t){return e===t?!0:Ot(e)&&Ot(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&dl(e.value,t.value):!Ot(e)&&!Ot(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&Ko(e.items,t.items):!1}function Ko(e,t){return e===t?!0:e.length===t.length&&e.every((n,o)=>Tu(n,t[o]))}function Lu(e){return(e.valueOptions??[]).map((t,n)=>t!==null&&typeof t=="object"?{key:String(n),value:t.value,label:t.label}:{key:String(n),value:t,label:String(t)})}function ul(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function fl(e,t){return e==null?"":t.type==="date"||e instanceof Date?xr(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}function gl(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function Fu(e,t){if(!fo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Au=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=s.useMemo(()=>Ms(e.type),[e.type]),l=i[0],d=t?.operator??l,c=i.includes(d)?i:[d,...i],f=!!t,g=e.headerName||e.field,[h,x]=s.useState(null),[C,p]=s.useState(n);C!==n&&(p(n),x(null));const u=s.useRef(o),m=s.useRef(t),b=s.useRef(e);s.useLayoutEffect(()=>{u.current=o,m.current=t,b.current=e});const w=s.useCallback((T,O)=>({id:m.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:T,value:O}),[e.field]),v=s.useCallback(T=>{const O=m.current;if(O?T===fl(O.value,b.current):T.trim()==="")return;const K=O?.operator??l;u.current(w(K,gl(T,K)))},[l,w]),E=s.useRef(null),I=s.useRef(v);s.useLayoutEffect(()=>{E.current=h,I.current=v}),s.useEffect(()=>()=>{const T=E.current;E.current=null,T!==null&&I.current(T)},[]),s.useEffect(()=>{if(h===null)return;const T=setTimeout(()=>{E.current=null,v(h),x(null)},Pu);return()=>clearTimeout(T)},[h,v]);const D=T=>{const O=h!==null?gl(h,T):t?.value;x(null),o(w(T,Fu(O,T)))},P=()=>{x(null),o(null)},F=!fo.has(d),H=Lu(e),B=`ogx-filter__value-input${f?" ogx-filter__value-input--active":""}`,U=`Filter value for ${g}`;let _=null;if(F&&e.type==="boolean")_=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${B} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:T=>{T.target.value===""?o(null):o(w(d,T.target.value))},"aria-label":U,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"true",children:"true"}),a.jsx("option",{value:"false",children:"false"})]});else if(F&&e.type==="singleSelect"&&H.length>0&&d==="isAnyOf"){const T=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];_=a.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${B} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(H.length,4),value:H.filter(O=>T.some(S=>ul(O,S))).map(O=>O.key),onChange:O=>{const S=new Set(Array.from(O.target.selectedOptions,K=>K.value));o(w("isAnyOf",H.filter(K=>S.has(K.key)).map(K=>K.value)))},"aria-label":U,children:H.map(O=>a.jsx("option",{value:O.key,children:O.label},O.key))})}else if(F&&e.type==="singleSelect"&&H.length>0&&(d==="is"||d==="not")){const T=H.find(O=>ul(O,t?.value));_=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${B} ogx-filter__value-select`,value:T?.key??"",onChange:O=>{const S=H.find(K=>K.key===O.target.value);o(w(d,S?S.value:""))},"aria-label":U,children:[a.jsx("option",{value:"",children:"Any"}),H.map(O=>a.jsx("option",{value:O.key,children:O.label},O.key))]})}else F&&(_=a.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:B,type:e.type==="date"?"date":"text",value:h??fl(t?.value,e),onChange:T=>x(T.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":U}));return a.jsxs("div",{className:`ogx-filter__row${f?" ogx-filter__row--active":""}`,children:[a.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),a.jsxs("div",{className:"ogx-filter__controls",children:[a.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${f?" ogx-filter__op-select--active":""}`,value:d,onChange:T=>D(T.target.value),"aria-label":`Filter operator for ${g}`,children:c.map(T=>a.jsx("option",{value:T,children:T},T))}),_,f&&a.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:P,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},pl=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[d,c]=s.useState(o),[f,g]=s.useState(0);if(d!==o){c(o);const m=!Ko(d,o),b=i!==null&&Ko(i,o);m&&!b&&g(w=>w+1)}const h=s.useCallback((m,b)=>{const w=o.findIndex(E=>Ot(E)&&E.field===m);let v;if(w===-1){if(!b)return;v=[...o,b]}else b?v=o.map((E,I)=>I===w?b:E):v=o.filter((E,I)=>I!==w);l(v),n({...e,items:v})},[o,e,n]),x=s.useCallback(m=>{n({...e,logicOperator:m})},[e,n]),C=t.filter(m=>m.filterable!==!1),p=C.filter(m=>cl(o,m.field)).length,u=o.length-p;return a.jsxs(a.Fragment,{children:[o.length>1&&a.jsxs("div",{className:"ogx-filter__logic-bar",children:[a.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),u>0&&a.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:u===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${u} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),C.length===0?a.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):C.map(m=>a.jsx(Au,{col:m,item:cl(o,m.field),resetToken:f,onChange:b=>h(m.field,b)},m.field))]})},hl=["sum","avg","count","min","max"];function ml(){return a.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:[a.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),a.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Ou({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),[c,f]=s.useState(null);s.useLayoutEffect(()=>{f(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const S=e.current.getBoundingClientRect();return{top:S.bottom+6,right:Nt()-S.right}},[e]);s.useEffect(()=>{d(g());const S=()=>d(g());return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[g]),s.useEffect(()=>{function S(j){i.current&&!i.current.contains(j.target)&&e.current&&!e.current.contains(j.target)&&r()}function K(j){j.key==="Escape"&&r()}return document.addEventListener("mousedown",S),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",K)}},[e,r]);const h=new Set(n.rowFields),x=new Set(n.columnFields),C=new Set(n.valueFields.map(S=>S.field)),p=S=>h.has(S)||x.has(S)||C.has(S),u=S=>t.find(K=>K.field===S),m=S=>u(S)?.headerName??S,b=S=>{const K=u(S)?.availableAggregationFunctions;return K?hl.filter(j=>K.includes(j)):hl},w=S=>S.aggregable!==!1&&(S.type==="number"||S.aggregable===!0)&&b(S.field).length>0,v=S=>S.groupable!==!1;function E(S){h.has(S)||o({...n,rowFields:[...n.rowFields,S]})}function I(S){x.has(S)||o({...n,columnFields:[...n.columnFields,S]})}function D(S){C.has(S)||o({...n,valueFields:[...n.valueFields,{field:S,aggFn:b(S)[0]??"sum"}]})}function P(S){o({...n,rowFields:n.rowFields.filter((K,j)=>j!==S)})}function F(S){o({...n,columnFields:n.columnFields.filter((K,j)=>j!==S)})}function H(S){o({...n,valueFields:n.valueFields.filter((K,j)=>j!==S)})}function B(S,K){o({...n,valueFields:n.valueFields.map((j,Q)=>Q===S?{...j,aggFn:K}:j)})}function U(){o({rowFields:[],columnFields:[],valueFields:[]})}const _=n.rowFields.length+n.columnFields.length+n.valueFields.length,T=t.filter(S=>!p(S.field)&&(v(S)||w(S))),O=a.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[a.jsxs("div",{className:"ogx-pivot-panel__header",children:[a.jsxs("span",{className:"ogx-pivot-panel__title",children:[a.jsx(ml,{}),"Pivot Mode"]}),_>0&&a.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:U,title:"Reset pivot",children:"Reset"})]}),a.jsxs("div",{className:"ogx-pivot-panel__body",children:[a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:n.rowFields.map((S,K)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[m(S),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(K),title:`Remove ${m(S)}`,"aria-label":`Remove ${m(S)} from Row Fields`,children:"×"})]},`${K}:${S}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:n.columnFields.map((S,K)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[m(S),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>F(K),title:`Remove ${m(S)}`,"aria-label":`Remove ${m(S)} from Column Fields`,children:"×"})]},`${K}:${S}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),a.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:n.valueFields.map((S,K)=>{const j=b(S.field),Q=j.includes(S.aggFn)?j:[S.aggFn,...j];return a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[m(S.field),a.jsx("select",{className:"ogx-pivot-chip__fn-select",value:S.aggFn,onChange:$=>B(K,$.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${m(S.field)}`,children:Q.map($=>a.jsx("option",{value:$,children:$.toUpperCase()},$))}),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>H(K),title:`Remove ${m(S.field)}`,"aria-label":`Remove ${m(S.field)} (${S.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${K}:${S.field}:${S.aggFn}`)})})]}),a.jsx("hr",{className:"ogx-pivot-panel__divider"}),a.jsxs("div",{children:[a.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),a.jsxs("div",{className:"ogx-pivot-fields",children:[T.map(S=>{const K=w(S),j=v(S),Q=S.headerName??S.field;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[a.jsx("span",{className:`ogx-pivot-field-btn${K?" ogx-pivot-field-btn--numeric":""}`,children:Q}),a.jsxs("div",{className:"ogx-pivot-field-actions",children:[j&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>E(S.field),title:"Add to Row Fields","aria-label":`Add ${Q} to Row Fields`,children:"Row"}),j&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>I(S.field),title:"Add to Column Fields","aria-label":`Add ${Q} to Column Fields`,children:"Col"}),K&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>D(S.field),title:"Add to Value Fields","aria-label":`Add ${Q} to Value Fields`,children:"Val"})]})]},S.field)}),T.length===0&&a.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return c?ut.createPortal(O,c):null}function Du(){return a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function $u(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function wl(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Gu({value:e="",onChange:t,placeholder:n="Search...",debounceMs:o=250}){const[r,i]=s.useState(()=>e.length>0),[l,d]=s.useState(e),c=s.useRef(null),f=s.useRef(null),g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t},[t]);const h=s.useRef(e),x=s.useRef(e);s.useEffect(()=>{e!==x.current&&(x.current=e,wl(e)!==wl(h.current)&&(d(e),h.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const w=setTimeout(()=>{l!==h.current&&(h.current=l,g.current(l))},o);return()=>clearTimeout(w)},[l,o]);const C=s.useRef(l);s.useLayoutEffect(()=>{C.current=l}),s.useEffect(()=>()=>{const w=C.current;w!==h.current&&(h.current=w,g.current(w))},[]);const p=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>c.current?.focus())},[]),u=s.useCallback(w=>{w.stopPropagation(),d(""),h.current="",g.current(""),c.current?.focus()},[]),m=s.useCallback(()=>{i(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{f.current&&document.activeElement&&f.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const w=v=>{f.current&&!f.current.contains(v.target)&&(l||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),a.jsxs("div",{ref:f,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:p,children:[a.jsx("div",{className:"ogx-global-search__icon-wrapper",children:a.jsx(Du,{})}),a.jsx("input",{ref:c,className:"ogx-global-search__input",value:l,onChange:w=>d(w.target.value),onFocus:m,onBlur:b,placeholder:n,"aria-label":"Global Search",autoComplete:"off"}),l&&a.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:u,"aria-label":"Clear search",children:a.jsx($u,{})})]})}const Wn=8;function cn({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[d,c]=s.useState({top:0,left:0}),[f,g]=s.useState(null),h=s.useRef(null),x=s.useRef(null),C=s.useId(),p=s.useCallback(()=>{if(!x.current)return;const I=x.current.getBoundingClientRect(),D=I.left+I.width/2,P=I.top+I.height/2;switch(n){case"bottom":c({top:I.bottom+Wn,left:D});break;case"left":c({top:P,left:I.left-Wn});break;case"right":c({top:P,left:I.right+Wn});break;default:c({top:I.top-Wn,left:D})}},[n]),u=s.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;p();const I=D=>{D.key==="Escape"&&(u(),l(!1))};return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),document.addEventListener("keydown",I),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),document.removeEventListener("keydown",I)}},[i,p,u]),s.useEffect(()=>u,[u]);const m=()=>{u(),h.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},b=()=>{u(),h.current=setTimeout(()=>{l(!1)},r)},w=s.useCallback(I=>{x.current=I?I.firstElementChild??I:null},[]),v=i&&!!e&&f!==null;let E=t;if(v&&s.isValidElement(t)){const I=t,D=I.props["aria-describedby"];E=s.cloneElement(I,{"aria-describedby":D?`${D} ${C}`:C})}return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:m,onMouseLeave:b,onFocus:m,onBlur:b,children:E}),v&&f&&ut.createPortal(a.jsx("div",{id:C,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:d.top,left:d.left,position:"fixed",zIndex:99999},children:e}),f)]})}const Wu=Object.keys(pt);function Hu(e){return Object.prototype.hasOwnProperty.call(pt,e)}function xl(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Hu))):Wu}function bl(){return a.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:a.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Bu(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Cl(){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function zu({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const d=s.useRef(null),[c,f]=s.useState({top:0,right:0}),[g,h]=s.useState(null);s.useLayoutEffect(()=>{h(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:Nt()-p.right}},[e]);s.useEffect(()=>{f(x());const p=()=>f(x());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[x]),s.useEffect(()=>{function p(u){d.current&&!d.current.contains(u.target)&&e.current&&!e.current.contains(u.target)&&i()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,i]),s.useEffect(()=>{function p(u){u.key==="Escape"&&i()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]);const C=a.jsxs("div",{ref:d,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(bl,{}),"Summaries"]}),l>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),a.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?a.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",a.jsx("br",{}),"Set ",a.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):n.map(p=>{const u=t[p.field]||"none";return a.jsxs("div",{className:"ogx-toolbar__agg-row",children:[a.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),a.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...xl(p)].map(m=>a.jsx("button",{type:"button",className:`ogx-toolbar__pill${u===m?" ogx-toolbar__pill--active":""}`,onClick:()=>o(p.field,m),"aria-pressed":u===m,children:m},m))})]},p.field)})})]});return g?ut.createPortal(C,g):null}function Vu({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,onClose:c,showNonHideableColumns:f}){const g=s.useRef(null),[h,x]=s.useState({top:0,right:0}),[C,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const u=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const b=e.current.getBoundingClientRect();return{top:b.bottom+6,right:Nt()-b.right}},[e]);s.useEffect(()=>{x(u());const b=()=>x(u());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[u]),s.useEffect(()=>{function b(w){g.current&&!g.current.contains(w.target)&&e.current&&!e.current.contains(w.target)&&c()}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e,c]),s.useEffect(()=>{function b(w){w.key==="Escape"&&c()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const m=a.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:h.top,right:h.right,width:280,padding:0},children:a.jsx(Go,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:f})});return C?ut.createPortal(m,C):null}function Ku({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),c=s.useRef(r);s.useLayoutEffect(()=>{c.current=r},[r]);const[f,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const h=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const u=e.current.getBoundingClientRect();return{top:u.bottom+6,right:Nt()-u.right}},[e]);s.useEffect(()=>{d(h());const u=()=>d(h());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[h]),s.useEffect(()=>{function u(m){m.key==="Escape"&&c.current()}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const x=n.items?.length??0,C=()=>{o({...n,items:[],logicOperator:"and"})},p=a.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(Cl,{}),"Filters",x>0&&a.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:C,title:"Clear all filters",children:"Clear all"}),a.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>c.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),a.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:a.jsx(pl,{columns:t,filterModel:n,onFilterModelChange:o})})]});return f?ut.createPortal(p,f):null}const Uu={rowFields:[],columnFields:[],valueFields:[]},ju=[];function Ru({columns:e=ju,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:d,columnVisibilityModel:c={},onColumnVisibilityModelChange:f,onColumnReorder:g,onColumnOrderReset:h,forceColumnsOpen:x,onColumnsPanelClose:C,children:p,rightContent:u,style:m,renderColumnsButton:b,renderFilterButton:w,renderAggregationButton:v,renderExportButton:E,renderQuickFilter:I,className:D,showNonHideableColumns:P}){const[F,H]=s.useState(x?"columns":null),B=F==="summaries",U=F==="pivot",_=F==="columns",T=F==="filters",O=G=>{F==="columns"&&G!=="columns"&&C?.(),H(G)},S=G=>O(F===G?null:G),K=G=>{F===G&&O(null)},[j,Q]=s.useState(x);j!==x&&(Q(x),x&&H("columns"));const $=s.useContext(wi),z=x!==void 0&&!!f;s.useEffect(()=>{if(!(!$||!z))return $.registerColumnsPanel()},[$,z]);const Z=s.useRef(null),ie=s.useRef(null),oe=s.useRef(null),fe=s.useRef(null),de=s.useRef(null),ge=s.useRef(null),re=s.useRef(null),ae=r??Uu,ee=ae.rowFields.length>0||ae.columnFields.length>0||ae.valueFields.length>0,ne=t?new Set(t.map(G=>G.field)):null,V=e.filter(G=>G.aggregable!==!1&&(G.type==="number"||G.aggregable===!0)&&xl(G).length>0&&(!ne||ne.has(G.field))),J=Object.keys(n).filter(G=>n[G]&&n[G]!=="none").length,te=s.useCallback((G,k)=>{if(!o)return;const W={...n};k==="none"?delete W[G]:W[G]=k,o(W)},[n,o]),se=s.useCallback(()=>{o?.({})},[o]),y=s.useCallback(G=>{if(!d)return;const k=G.trim().split(/\s+/).filter(Boolean),W={...l||{},quickFilterValues:k,items:l?.items||[]};d(W)},[l,d]),M=(l?.quickFilterValues??[]).join(" "),A=l?.items?.length||0,N=new Set(e.filter(G=>c[G.field]!==!1).map(G=>G.field)),L=s.useCallback((G,k)=>{if(!f)return;const W={...c,[G]:k};f(W)},[c,f]),q=s.useCallback(()=>{if(!f)return;const G={...c};e.forEach(k=>{k.hideable!==!1&&(G[k.field]=!0)}),f(G)},[e,c,f]),Y=s.useCallback(()=>{if(!f)return;const G={...c};e.forEach(k=>{k.hideable!==!1&&(G[k.field]=!1)}),f(G)},[e,c,f]);return a.jsxs("div",{className:["ogx-toolbar",D].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:m,children:[p&&a.jsx("div",{className:"ogx-toolbar__left",children:p}),a.jsx("div",{className:"ogx-toolbar__spacer"}),a.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&a.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:I?I({value:M,onChange:y}):a.jsx(Gu,{value:M,onChange:y,placeholder:"Search..."})}),f&&a.jsxs("div",{ref:de,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>S("columns"),isOpen:_,activeCount:e.length-N.size}):a.jsx(cn,{title:"Columns",children:a.jsx("button",{type:"button",ref:oe,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":_,onClick:()=>S("columns"),children:a.jsx(Bu,{})})}),_&&a.jsx(Vu,{anchorRef:b?de:oe,columns:e,visibleColumns:N,onVisibilityChange:L,onShowAll:q,onHideAll:Y,onColumnReorder:g,onColumnOrderReset:h,onClose:()=>K("columns"),showNonHideableColumns:P})]}),d&&a.jsxs("div",{ref:ge,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[w?w({onClick:()=>S("filters"),isOpen:T,activeCount:A}):a.jsx(cn,{title:"Filters",children:a.jsxs("button",{type:"button",ref:fe,className:`ogx-toolbar__icon-btn${T?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":T,onClick:()=>S("filters"),children:[a.jsx(Cl,{}),A>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),T&&a.jsx(Ku,{anchorRef:w?ge:fe,columns:e,filterModel:l||{items:[]},onFilterModelChange:d,onClose:()=>K("filters")})]}),i&&a.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[a.jsx(cn,{title:"Pivot",children:a.jsxs("button",{type:"button",ref:ie,className:`ogx-toolbar__icon-btn${U?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":U,onClick:()=>S("pivot"),children:[a.jsx(ml,{}),ee&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),U&&a.jsx(Ou,{anchorRef:ie,columns:t??e,model:ae,onChange:G=>{i?.(G)},onClose:()=>K("pivot")})]}),o&&a.jsxs("div",{ref:re,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[v?v({onClick:()=>S("summaries"),isOpen:B,activeCount:J}):a.jsx(cn,{title:"Summaries",children:a.jsxs("button",{type:"button",ref:Z,className:`ogx-toolbar__icon-btn${B?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":B,onClick:()=>S("summaries"),children:[a.jsx(bl,{}),J>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${J} active summaries`})]})}),B&&a.jsx(zu,{anchorRef:v?re:Z,aggregationModel:n,aggregableColumns:V,onFunctionChange:te,onClearAll:se,onClose:()=>K("summaries"),activeCount:J})]}),E&&E(),u]})]})}function qu(){const[e]=s.useState(Mi);return s.useRef(e)}const Xu=({fullWidth:e=!1,error:t=!1,startAdornment:n,endAdornment:o,className:r="",...i})=>{const l=["ogx-input-wrapper",e&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",i.disabled&&"ogx-input-wrapper--disabled",r].filter(Boolean).join(" ");return a.jsxs("div",{className:l,children:[n&&a.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:n}),a.jsx("input",{className:"ogx-input",...i}),o&&a.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Dt(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const n=e.groupField??"",o=t.find(r=>r.field===n)?.groupingValueFormatter;return o?o({field:n,value:e.groupValue}):`${n}: ${String(e.groupValue??"")}`}const Yu=new Set([8364,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,381,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,382,376]);function Ju(e){return e>=8192&&e<=8202||e===8239||e===8287||e===12288?" ":e>=8203&&e<=8205||e===8288||e===65279?"":e===8208||e===8209||e===8210||e===8722?"-":null}function Qu(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||Yu.has(r)){t+=o;continue}const i=Ju(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const Zu={sliceMs:30,renderChunkRows:40},ef=2e4;function vl(){return new Promise(e=>setTimeout(e,0))}function tf(){return new DOMException("PDF export was aborted","AbortError")}const $t=()=>typeof performance<"u"?performance.now():Date.now(),yl=e=>Math.max(2,Math.floor(e/2)*2),nf=[79,70,229],of=[255,255,255];function Sl(e,t){const n=e.trim().replace(/^#/,""),o=/^[a-f\d]{3}$/i.test(n)?n.split("").map(i=>i+i).join(""):n,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function _l(e,t){return an(e,t,sn(e,t))}function kl(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function rf(e,t){const n=e.reduce((r,i)=>r+kl(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:kl(r)/n*t}}),o}const lf=new Set(["isEmpty","isNotEmpty"]);function sf(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(lf.has(e.operator))return`${o} ${e.operator}`;const{value:r}=e;if(r==null||r===""||Array.isArray(r)&&r.length===0)return null;const i=Array.isArray(r)?r.map(String).join(", "):String(r);return`${o} ${e.operator} "${i}"`}function El(e,t,n,o){const r=e.map(l=>"items"in l?El(l.items,l.logicOperator,n,!0):sf(l,n)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return o&&r.length>1?`(${i})`:i}function af(e,t){const n=[],o=El(e.items??[],e.logicOperator??"and",t,!1);o&&n.push(o);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&n.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),n.join(" • ")}const cf=1.15*.3528;function df(e,t,n={}){return uf(e,t,n,Zu)}async function uf(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw tf()};l();let d,c;try{const[k,W]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);d=k.default,c=W.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:f="export",title:g,logoUrl:h,orientation:x="landscape",selectedRows:C,getRowId:p,aggregationResult:u,aggregationModel:m,filterModel:b,alternateRowColor:w=!0,headerBackgroundColor:v="#4f46e5",headerTextColor:E="#ffffff",fontSize:I=9,groupedRows:D,font:P,maxRows:F=ef}=n;l();let H=$t();const B=async()=>{$t()-H<o.sliceMs||(await vl(),l(),H=$t())},U=(k,W,R)=>{i?.({phase:k,done:W,total:R})},_=new d({orientation:x,unit:"mm",format:"a4"}),T=_.internal.pageSize.getWidth(),O=_.internal.pageSize.getHeight(),S=14,K=T-S*2;let j="helvetica";P&&(_.addFileToVFS(`${P.name}-normal.ttf`,P.data),_.addFont(`${P.name}-normal.ttf`,P.name,"normal"),P.boldData&&_.addFileToVFS(`${P.name}-bold.ttf`,P.boldData),_.addFont(P.boldData?`${P.name}-bold.ttf`:`${P.name}-normal.ttf`,P.name,"bold"),j=P.name);let Q=!1;const $=k=>{if(P)return k;const W=Qu(k);return W.lossy&&(Q=!0),W.text},z=(k,W,R,X,ue)=>{const pe=_.splitTextToSize($(k),X);return _.text(pe.length===1?pe[0]:pe,W,R),Math.max(0,pe.length-1)*ue*cf},Z=mt(t),ie=ln(D,C),oe=rn(e,C,p);let fe=S;if(g){let k=S,W=S+8;if(h)try{_.addImage(h,"PNG",k,S,10,10),k+=14}catch{}const R=T-S-k;_.setFontSize(16),_.setFont(j,"bold"),_.setTextColor(30,41,59),W+=z(g,k,W,R,16),W+=6,_.setFontSize(8),_.setFont(j,"normal"),_.setTextColor(100,116,139);const X=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),ue=ie?D.filter(pe=>pe.type==="leaf").length:oe.length;if(_.text($(`Exported: ${X} • ${ue} row${ue!==1?"s":""}`),k,W),W+=5,b){const pe=af(b,t);pe&&(W+=z(`Filters: ${pe}`,k,W,R,8),W+=5)}_.setDrawColor(226,232,240),_.setLineWidth(.3),_.line(S,W+2,T-S,W+2),fe=W+6}const de=[Z.map(k=>$(k.headerName??k.field))],ge=m||{},re=k=>Z.map(W=>Wo(W,ge[W.field],k[W.field],k)),ae=[];let ee;const ne=k=>{ae.push(k.map($))};if(ie){const k=D.length;U("prepare",0,k);for(let W=0;W<k;W++){const R=D[W],X=" ".repeat(R.depth*2);if(R.type==="group-header"){const ue=`${X}${Dt(R,t)}`;ne(Z.map((pe,he)=>he===0?ue:""))}else if(R.type==="leaf"&&R.row){const ue=R.row;ne(Z.map((pe,he)=>(he===0?X:"")+_l(ue,pe)))}else if(R.type==="group-subtotal"&&R.aggregatedValues){const ue=re(R.aggregatedValues);ne(ue.map((pe,he)=>he===0?`${X}${At("Subtotal",pe)}`:pe))}else R.type==="grand-total"&&R.aggregatedValues&&(ee=[re(R.aggregatedValues).map((pe,he)=>he===0?At("Grand Total",pe):pe).map($)]);(W&63)===63&&(U("prepare",W+1,k),await B())}U("prepare",k,k)}else{const k=oe.length;U("prepare",0,k);for(let R=0;R<k;R++)ne(Z.map(X=>_l(oe[R],X))),(R&63)===63&&(U("prepare",R+1,k),await B());const W=m?Ft(oe,it(C),t,u,m):null;if(W&&m){const R=Z.some(ue=>m[ue.field]);ee=[re(W).map((ue,pe)=>pe===0&&R?At("TOTAL",ue):ue).map($)]}U("prepare",k,k)}l(),ae.length>F&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${ae.length} table rows (maxRows: ${F}). PDFs this large are slow to build and open and can reach tens of MB. Prefer exportToCsv or exportToExcelAdvanced for full-dataset exports, or pass a larger \`maxRows\` to silence this warning.`),Q&&console.warn('[exportToPdf] Some characters cannot be drawn with the built-in Helvetica font and were replaced with "?". Pass the `font` option (a Unicode .ttf, e.g. Noto Sans) to draw them.');const V=rf(Z,K),[J,te,se]=Sl(v,nf),[y,M,A]=Sl(E,of),N={head:de,styles:{fontSize:I,cellPadding:3,font:j,overflow:"linebreak"},headStyles:{fillColor:[J,te,se],textColor:[y,M,A],fontStyle:"bold"},...w?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...ee?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:V,showHead:"everyPage",margin:{top:S,left:S,right:S,bottom:S+6}},L=ae.length;U("render",0,L);let q=0,Y=yl(o.renderChunkRows);do{const k=ae.slice(q,q+Y),W=q===0,R=q+k.length>=L,X=W?fe:_.lastAutoTable.finalY;let ue=!0;const pe=$t();c(_,{...N,body:k,...R&&ee?{foot:ee}:{},startY:W?fe:S,showFoot:R&&ee?"lastPage":"never",...W?{}:{willDrawPage:ve=>{ue?(ue=!1,ve.settings.showHead="never",ve.cursor&&(ve.cursor.y=X)):ve.settings.showHead="everyPage"}}}),q+=k.length,U("render",q,L);const he=$t()-pe;Y=yl(he>0?Math.min(Y*4,Y*(o.sliceMs/he)):Y*4),R||(await vl(),l(),H=$t())}while(q<L);const G=_.getNumberOfPages();for(let k=1;k<=G;k++)_.setPage(k),_.setFontSize(8),_.setTextColor(150,150,150),_.text(`Page ${k} of ${G}`,T-S,O-8,{align:"right"}),await B();l(),U("save",0,1),_.save(`${f}.pdf`),U("save",1,1)}function dn(e,t){const n=sn(e,t);return{text:an(e,t,n),raw:n}}function Gt(e,t,n){return e.map(o=>Wo(o,n[o.field],t[o.field],t))}const ff="\uFEFF";function gf(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:d,escapeFormulas:c=!0,bom:f=!0}=n,g=mt(t),h=n.aggregationModel||{},x=(u,m=!1)=>Hn(c?$n(u,m):u,i),C=()=>g.map(u=>x(u.headerName||u.field)).join(i)+`
|
|
6
|
-
|
|
7
|
-
`}else if(u.type==="leaf"&&u.row){const b=u.row,w=g.map((v,E)=>{const I=dn(b,v),D=c?$n(I.text,lt(I.raw)):I.text;return Hn((E===0?m:"")+D,i)});p+=w.join(i)+`
|
|
8
|
-
|
|
9
|
-
`}
|
|
10
|
-
`}
|
|
11
|
-
|
|
12
|
-
`}
|
|
13
|
-
|
|
1
|
+
(function(xe,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],c):(xe=typeof globalThis<"u"?globalThis:xe||self,c(xe.OpenGridX={},xe.ReactJSXRuntime,xe.React,xe.ReactDOM))})(this,(function(xe,c,s,xt){"use strict";function uo(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function bt(e,t,n=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const o=t[e.field]??e.width,r=typeof o=="number"&&Number.isFinite(o)?o:n;return uo(r,e.minWidth,e.maxWidth)}const Ze=48;function lt(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function Ps(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=lt(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const d=t.left.indexOf(i.field),a=t.left.indexOf(l.field);return d-a}),t.right&&r.sort((i,l)=>{const d=t.right.indexOf(i.field),a=t.right.indexOf(l.field);return d-a}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function fo(e,t,n,o,r,i,l,d){const a={};if(!n)return a;let f=(d?Ze:0)+(i&&l?Ze:0)+(o&&r?Ze:0);const p=[];e.forEach(b=>{if(b.isSpacer)return;const C=lt(b.field,n);C==="left"?(a[b.field]=f,f+=bt(b,t)):C==="right"&&p.push(b)});let w=0;for(let b=p.length-1;b>=0;b--)a[p[b].field]=w,w+=bt(p[b],t);return a}function go(e,t){let n=null,o=null;if(!t)return{lastLeft:n,firstRight:o};for(const r of e){if(r.isSpacer)continue;const i=lt(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function Lr(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Ls(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const d=Lr(n(l),t);d==="top"?o.push(l):d==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,d)=>{const a=t.top.indexOf(n(l)),f=t.top.indexOf(n(d));return a-f}),t.bottom&&i.sort((l,d)=>{const a=t.bottom.indexOf(n(l)),f=t.bottom.indexOf(n(d));return a-f}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function Ts(e,t,n){const o=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return n==="left"?{left:[...o,t],right:r}:n==="right"?{left:o,right:[...r,t]}:{left:o,right:r}}const Tr=new Set;function ln(e,t,n){process.env.NODE_ENV==="production"||Tr.has(e)||(Tr.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function Pn(e,t,n,o){try{return e()}catch(r){return ln(n,o,r),t}}function Fr(e,t,n){const o=e[t];if(!n?.valueGetter)return{value:o};try{return{value:n.valueGetter({row:e,field:t,value:o})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function ke(e,t,n){const{value:o,error:r}=Fr(e,t,n);return r!==void 0&&ln(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function po(e,t,n,o){const r=o?.valueFormatter;if(r)return Pn(()=>r({value:n,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function Ct(e){if(e==null)return null;if(typeof e=="number")return Number.isNaN(e)?null:e;if(typeof e=="string"){const t=e.trim();if(t==="")return null;const n=Number(t);return Number.isNaN(n)?null:n}if(typeof e=="boolean")return null;if(e instanceof Date){const t=e.getTime();return Number.isNaN(t)?null:t}return typeof e=="bigint"?Number(e):null}const Fs=/^(\d{4})-(\d{2})-(\d{2})$/;function sn(e){if(e==null)return null;let t;if(e instanceof Date)t=e;else if(typeof e=="number")t=new Date(e);else if(typeof e=="string"){const n=e.trim();if(n==="")return null;const o=Fs.exec(n);if(o){const r=Number(o[1]),i=Number(o[2])-1,l=Number(o[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else t=new Date(n)}else return null;return Number.isNaN(t.getTime())?null:t}function Ln(e){const t=sn(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Ar(e){const t=sn(e);if(!t)return"";const n=String(t.getFullYear()).padStart(4,"0"),o=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${r}`}let Dr=null;function Or(e){return Dr??=new Intl.DateTimeFormat,Dr.format(e)}function As(e,t){if(!e)return;const n=i=>typeof i=="object"?i.value:i,o=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(n(i),t))??e.find(i=>String(n(i))===String(t));return r===void 0?void 0:o(r)}function ho(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=sn(e);return n?Or(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return As(t.valueOptions,e)??String(e);default:return String(e)}}const mo=200;function wo(e){if(e==="auto")return"auto";const t=typeof e=="string"?Number.parseFloat(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:mo}function xo(e,t){if(e)return Pn(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Ds(e,t){const n=wo(e);return n==="auto"?t??mo:n}function Os(e,t){if(t.size===0||e.size===0)return e;let n=!1;const o=new Set;for(const r of e)t.get(r)?.isGroupRow?n=!0:o.add(r);return n?o:e}const $s=e=>e.id;function Gs(e){if(e===void 0)return{type:"auto",value:0};if(typeof e=="number")return{type:"fixed",value:e};if(typeof e=="string"){if(e.toLowerCase()==="auto")return{type:"auto",value:0};if(e.endsWith("%"))return{type:"percentage",value:parseFloat(e)};const t=parseFloat(e);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Ws(e,t,n){const o=new Map;e.forEach(u=>{if(!Object.prototype.hasOwnProperty.call(t,u.field)&&u.flex&&u.flex>0){o.set(u.field,{kind:"flex",flex:u.flex});return}const x=Gs(t[u.field]??u.width);x.type==="fixed"?o.set(u.field,{kind:"fixed",width:uo(x.value,u.minWidth,u.maxWidth)}):x.type==="percentage"?o.set(u.field,{kind:"percentage",percentage:x.value}):o.set(u.field,{kind:"flex",flex:1})});const r=e.reduce((u,h)=>{const x=o.get(h.field);if(x.kind==="fixed")return u+x.width;if(x.kind==="percentage")return u+100;if(h.flex&&h.flex>0){const m=h.minWidth??150;return u+(m||(typeof h.width=="number"?h.width:150))}return u+(h.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((u,h)=>{const x=o.get(h.field);return x.kind==="fixed"?u+x.width:u},0),d=new Map,a=Math.max(0,i-l);let f=0;e.forEach(u=>{const h=o.get(u.field);if(h.kind==="fixed")d.set(u.field,h.width);else if(h.kind==="percentage"){const x=h.percentage/100*a,m=uo(x>0?x:100,u.minWidth??50,u.maxWidth);d.set(u.field,m),f+=m}});const p=Math.max(0,a-f),w=new Map,b=e.flatMap(u=>{const h=o.get(u.field);return h.kind!=="flex"?[]:(w.set(u.field,h.flex),[{field:u.field,flex:h.flex,minWidth:u.minWidth??50,maxWidth:u.maxWidth??1/0,frozen:!1,computedWidth:0}])});let C=0;const g=b.length*2;for(;C<g;){C++;const u=b.filter(N=>!N.frozen);if(u.length===0)break;const h=u.reduce((N,P)=>N+P.flex,0),x=b.reduce((N,P)=>P.frozen?N+P.computedWidth:N,0),m=Math.max(0,p-x);if(h<=0){u.forEach(N=>{N.computedWidth=N.minWidth,N.frozen=!0});break}const y=m/h;let E=0;const v=[],M=[];if(u.forEach(N=>{const P=y*N.flex;P<N.minWidth?(E+=N.minWidth-P,v.push(N)):P>N.maxWidth?(E+=N.maxWidth-P,M.push(N)):N.computedWidth=P}),v.length===0&&M.length===0){u.forEach(N=>{N.frozen=!0});break}E>0?v.forEach(N=>{N.computedWidth=N.minWidth,N.frozen=!0}):E<0?M.forEach(N=>{N.computedWidth=N.maxWidth,N.frozen=!0}):(v.forEach(N=>{N.computedWidth=N.minWidth,N.frozen=!0}),M.forEach(N=>{N.computedWidth=N.maxWidth,N.frozen=!0}))}return b.forEach(u=>d.set(u.field,u.computedWidth)),{widths:d,flexByField:w}}function Bs(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,pinnedTopRows:p,pinnedBottomRows:w,visibleOrderedColumns:b,pinnedColumns:C,columnWidths:g,viewportWidth:u,checkboxSelection:h,hasDetailPanel:x,rowReordering:m,pinCheckboxColumn:y,pinExpandColumn:E,paginationMode:v,isLoading:M,pageSize:N,getRowId:P=$s}=e;return s.useMemo(()=>{const z=n?o:r,F=(L,A)=>{const V=P(L);if(!i.has(V))return t;const R=xo(l,{row:L,id:V,rowIndex:A});return t+Ds(R,d?.get(V))},$=z.map((L,A)=>F(L,a+A)),_=$.reduce((L,A,V)=>(L.push((L[V-1]||0)+A),L),[]),T=v==="infinite"&&M&&z.length>0?Math.min(N,20):0,O=(_[_.length-1]||0)+T*t,S=(L,A)=>L?L.reduce((V,R,B)=>V+F(R,B),0):A*t,j=S(p,a),q=S(w,f),{left:Z,center:W,right:U}=Ps(b,C),Q=(h?Ze:0)+(x?Ze:0)+(m?Ze:0),ie=(m?Ze:0)+(x&&E?Ze:0)+(h&&y?Ze:0),{widths:oe,flexByField:ge}=Ws([...Z,...W,...U],g,u-Q),le=L=>oe.get(L.field)??100,ue=L=>({...L,width:le(L),flex:ge.get(L.field)??L.flex}),te=11,ae=Z.map((L,A)=>({...ue(L),zIndex:te+A})),Y=11,re=U.map((L,A)=>({...ue(L),zIndex:Y+(U.length-1-A)})),K=W.map(ue),J=K.map(L=>L.width),ne=ae.reduce((L,A)=>L+A.width,0),de=re.reduce((L,A)=>L+A.width,0),G=J.reduce((L,A)=>L+A,0),I=ne+G+de+Q,D=J.reduce((L,A,V)=>(L.push((L[V-1]||0)+A),L),[]);return{rowHeights:$,cumulativeHeights:_,unpinnedRowsHeight:O,pinnedTopHeight:j,pinnedBottomHeight:q,leftPinnedCols:ae,rightPinnedCols:re,unpinnedColsWithWidth:K,unpinnedColWidths:J,unpinnedAccWidths:D,totalWidth:I,leftWidth:ne,rightWidth:de,unpinnedTotalWidth:G,systemColumnsWidth:Q,pinnedSystemColumnsWidth:ie,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,unpinnedRowsLength:z.length}},[t,n,o,r,i,l,d,a,f,p,w,b,C,g,u,h,x,m,y,E,v,M,N,P])}function Hs(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Tn(e,t,n,o,r){if(t<0||t>=n.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:d}=e,a=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,f=Math.max(o,Hs(e)),p=a+(t===0?0:n[t-1]),w=r!==void 0?Math.min(p+r,a+n[t]):a+n[t];p<l+a?e.scrollTop=Math.max(0,p-a):w>l+d-f&&(e.scrollTop=w-d+f)}function bo(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:d}=n;if(t<0||t>=o.length)return;const a=l+r,f=a+(t>0?o[t-1]:0),p=a+o[t],w=d+r,{scrollLeft:b,clientWidth:C}=e;f<b+w?e.scrollLeft=Math.max(0,f-w):p>b+C-i&&(e.scrollLeft=p-C+i)}function Co(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:d,rowMeta:a}=e;if(!i.editable||a?.isGroupRow||n._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:d})}catch{return!1}}const zs={},yo=e=>e==null||typeof e=="string"&&e.trim()==="",$r=e=>{const t=[];for(const n of e){const o=Ct(n);o!==null&&t.push(o)}return t},Gr=(e,t)=>{let n=null,o=null;for(const r of e){const i=Ct(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},yt={sum:e=>$r(e).reduce((t,n)=>t+n,0),avg:e=>{const t=$r(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!yo(t)).length,min:e=>Gr(e,(t,n)=>t<n),max:e=>Gr(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!yo(t))).size};function vo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function Fn(e,t,n,o){const r={};for(const[i,l]of Object.entries(t)){const d=n.get(i);if(!vo(d,l))continue;const a=yt[l];if(!a){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=a(e.map(f=>ke(f,i,d)))}return r}function an(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const Vs=new Set(["count","unique"]);function Wr(e){return e!==void 0&&Vs.has(e)}function Br(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function An(e,t,n,o){if(e==null)return"—";if(Wr(t))return an(e,t);const r=Br(n,t,e);if(n?.valueFormatter)try{return String(n.valueFormatter({value:r,row:o??{},field:n.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Or(r):an(r,t)}const So=new Set(["isEmpty","isNotEmpty"]);function Hr(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Ks(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const cn=e=>(t,n)=>{const o=Ct(t),r=Ct(n);return o===null||r===null?!1:e(o,r)},dn=e=>(t,n)=>{const o=Ln(t),r=Ln(n);return o===null||r===null?!1:e(o,r)},zr=dn((e,t)=>e===t),Vr=(e,t)=>{const n=Ln(e),o=Ln(t);return n===null||o===null?!0:n!==o},Kr={contains:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase()),equals:(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:String(e).toLowerCase()===String(t).toLowerCase(),startsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:e=>e==null||String(e).trim()==="",isNotEmpty:e=>e!=null&&String(e).trim()!=="","=":cn((e,t)=>e===t),">":cn((e,t)=>e>t),">=":cn((e,t)=>e>=t),"<":cn((e,t)=>e<t),"<=":cn((e,t)=>e<=t),"!=":(e,t)=>{if(Hr(t))return!0;const n=Ct(e),o=Ct(t);return n!==null&&o!==null?n!==o:Ks(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const n=Array.isArray(t)?t:[t],o=String(e).toLowerCase();return n.some(r=>r!=null&&String(r).toLowerCase()===o)},not:(e,t)=>e instanceof Date?Vr(e,t):e==null&&t==null?!1:e==null||t==null?!0:String(e).toLowerCase()!==String(t).toLowerCase(),is:(e,t)=>t==null||t===""?!0:e instanceof Date?zr(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:dn((e,t)=>e>t),onOrAfter:dn((e,t)=>e>=t),before:dn((e,t)=>e<t),onOrBefore:dn((e,t)=>e<=t)},Us={is:zr,not:Vr};function js(e,t){if(!Object.prototype.hasOwnProperty.call(Kr,e))return;const n=e;if(t?.type==="date"){const o=Us[n];if(o)return o}return Kr[n]}function Rs(e){return"items"in e&&Array.isArray(e.items)}function qs(e,t){const{field:n,operator:o,value:r}=e;if(!So.has(o)&&Hr(r))return null;const i=t.columns?.byField.get(n),l=js(o,i);return l?d=>l(ke(d,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function Ur(e,t,n){const o=[];for(const r of e){const i=Rs(r)?Ur(r.items,r.logicOperator,n):qs(r,n);i&&o.push(i)}return o.length===0?null:o.length===1?o[0]:t==="or"?r=>o.some(i=>i(r)):r=>o.every(i=>i(r))}function _o(e,t){if(t!=null){switch(typeof t){case"string":e.push(t.toLowerCase());return;case"number":Number.isNaN(t)||e.push(String(t));return;case"boolean":case"bigint":e.push(String(t));return}if(t instanceof Date){const n=Ar(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&_o(e,n)}}function jr(e,t){const n=[];if(!t){for(const o of Object.values(e))_o(n,o);return n}for(const o of t.quickFilterColumns){const r=ke(e,o.field,o),i=po(e,o.field,r,o);i!=null&&i!==""&&n.push(String(i).toLowerCase()),_o(n,r)}return n}const Rr=new WeakMap;function Xs(e,t){if(!t)return jr(e,t);let n=Rr.get(t);n||(n=new WeakMap,Rr.set(t,n));let o=n.get(e);return o||(o=jr(e,t),n.set(e,o)),o}function Ys(e,t){const n=(e??[]).map(o=>String(o??"").trim().toLowerCase()).filter(o=>o!=="");return n.length===0?null:o=>{const r=Xs(o,t);return n.every(i=>r.some(l=>l.includes(i)))}}function Dn(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=Ys(o,t),i=Ur(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function ko(e,t,n){const o=Dn(t,n);return o?e.filter(r=>o(r)):e}function Js(e){switch(e){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"]}}const Zs=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Eo=0,qr=1,Qs=2,Xr=3,Yr=4;function Ot(e,t){return{rank:e,num:t,str:""}}function Mo(e,t){if(e==null)return null;if(t==="number"){const n=Ct(e);return n===null?null:Ot(Eo,n)}if(t==="date"){const n=sn(e);return n?Ot(qr,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:Ot(Eo,e);case"bigint":return Ot(Eo,Number(e));case"boolean":return Ot(Qs,e?1:0);case"string":return{rank:Xr,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:Ot(qr,n)}return{rank:Yr,num:0,str:String(e)}}function Jr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===Xr||e.rank===Yr?Zs.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function No(e,t){return e===0?0:t==="asc"?e:-e}function ea(e,t,n,o){return No(Jr(Mo(e,o),Mo(t,o)),n)}function Zr(e,t,n){let o;try{o=e(t.value,n.value,t,n)}catch(r){return ln(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof o!="number"||Number.isNaN(o)?(ln(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(o)}; the values are treated as equal`,void 0),0):o}const ta=e=>e.id;function na(e,t,n,o=ta){return t.length===0?e:Io(e,t,(r,i)=>{const l=n?.byField.get(i.field),d=ke(r,i.field,l);return{value:d,type:l?.type,comparator:l?.sortComparator,params:l?.sortComparator?{id:o(r),field:i.field,row:r,value:d}:void 0}})}function Io(e,t,n){if(t.length===0||e.length<2)return[...e];const o=t.map(l=>e.map(d=>n(d,l))),r=o.map(l=>l.map(({value:d,type:a})=>Mo(d,a))),i=e.map((l,d)=>d);return i.sort((l,d)=>{for(let a=0;a<t.length;a++){const f=o[a][l],p=o[a][d],w=f.comparator&&f.comparator===p.comparator&&f.params&&p.params?Zr(f.comparator,f.params,p.params):Jr(r[a][l],r[a][d]),b=No(w,t[a].sort);if(b!==0)return b}return l-d}),i.map(l=>e[l])}function oa(e,t,n){if(!n)return e.filter(r=>r.field!==t);const o=e.findIndex(r=>r.field===t);return o===-1?[...e,{field:t,sort:n}]:e.map((r,i)=>i===o?{field:t,sort:n}:r)}function Po(e,t={}){const n=new Map,o=[];for(const r of e)n.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&o.push(r);return{byField:n,quickFilterColumns:o}}const $t="__pivot_grand_total__",ra="__pivot_row__:",Qr=e=>`${ra}${JSON.stringify(e.split(ei))}`,ia="Grand Total",ei="\0",Gt="",Lo=`${Gt}id`,ti=e=>e==="id"?Lo:e,To={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},ni=e=>e.map(t=>String(t??"")).join(ei),oi=e=>e===void 0||e===""?null:e;function la(e,t){const n=e==null,o=t==null;return n||o?n===o?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e=="boolean"&&typeof t=="boolean"?Number(e)-Number(t):String(e).localeCompare(String(t),void 0,{numeric:!0})}function sa(e,t){for(let n=0;n<e.length;n++){const o=la(e[n],t[n]);if(o!==0)return o}return 0}function ri(e,t){if(!e||e.length===0)return null;const n=yt[t](e);return typeof n=="number"||n instanceof Date?n:null}const aa=e=>"logicOperator"in e&&"items"in e,ca=e=>!!(e&&e.items&&e.items.length>0);function da(e,t){const n=l=>!t.has(l)&&l.includes(Gt),o=l=>aa(l)?l.items.length>0&&l.items.every(o):n(l.field),r=[],i=[];for(const l of e.items??[])(o(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function ii(e,t,n,o={}){const r=new Map(t.map(_=>[_.field,_])),i=_=>r.get(_)?.groupable!==!1,l=n.rowFields.filter(i),d=n.columnFields.filter(i),a=new Set,f=n.valueFields.filter(_=>{if(!vo(r.get(_.field),_.aggFn))return!1;const T=`${_.field}${Gt}${_.aggFn}`;return a.has(T)?!1:(a.add(T),!0)});if(l.length===0||f.length===0)return To;const p=d.length>0,w=Array.from(new Set(f.map(_=>_.field))),b=(_,T)=>ke(_,T,r.get(T)),C=new Map,g=new Map(p?[]:[["",{values:[]}]]);for(const _ of e){const T=l.map(U=>b(_,U)),O=ni(T);let S=C.get(O);S||(S={labels:T.map(oi),sample:_,cells:new Map},C.set(O,S));const j=d.map(U=>b(_,U)),q=p?ni(j):"",Z=g.get(q);Z?Z.sample||(Z.sample=_):g.set(q,{values:j.map(oi),sample:_});let W=S.cells.get(q);W||(W=new Map,S.cells.set(q,W));for(const U of w){const Q=b(_,U);if(yo(Q))continue;let ie=W.get(U);ie||(ie=[],W.set(U,ie)),ie.push(Q)}}const u=Array.from(g.keys()).sort((_,T)=>sa(g.get(_).values,g.get(T).values)),h=(_,T)=>p?`${_}${Gt}${T.field}${Gt}${T.aggFn}`:`${T.field}${Gt}${T.aggFn}`,x=new Map;let m=[];for(const[_,T]of C){const O={id:Qr(_)};l.forEach((S,j)=>{O[ti(S)]=T.labels[j]}),O.id=Qr(_);for(const S of u){const j=T.cells.get(S);for(const q of f)O[h(S,q)]=ri(j?.get(q.field),q.aggFn)}x.set(O.id,T),m.push({row:O,entry:T})}const y=_=>l.includes(_),E=_=>y(_)?r.get(_)?.type:"number",{outputFilterModel:v,sortModel:M}=o;if(ca(v)){const _=[];for(const O of u)for(const S of f)_.push({field:h(O,S),type:"number"});const T=Dn(v,Po(_));T&&(m=m.filter(({row:O})=>T(O)))}const N=(_,T)=>T==="id"&&y("id")?_[Lo]:_[T];M&&M.length>0&&(m=[...m].sort((_,T)=>{for(const O of M){const S=N(_.row,O.field),j=N(T.row,O.field),q=y(O.field)?r.get(O.field)?.sortComparator:void 0,Z=q?No(Zr(q,{id:_.row.id,field:O.field,row:_.row,value:S},{id:T.row.id,field:O.field,row:T.row,value:j}),O.sort):ea(S,j,O.sort,E(O.field));if(Z!==0)return Z}return 0}));const P=m.map(_=>_.row);if(m.length>0){const _={id:$t};l.forEach((T,O)=>{_[ti(T)]=O===0?ia:""}),_.id=$t;for(const T of u)for(const O of w){const S=[];for(const{entry:j}of m){const q=j.cells.get(T)?.get(O);if(q)for(const Z of q)S.push(Z)}for(const j of f)j.field===O&&(_[h(T,j)]=ri(S,j.aggFn))}P.push(_)}const z=m[0]?.entry.sample,F=_=>_===$t?z:_===void 0?void 0:x.get(_)?.sample,$=l.map(_=>fa(_,r.get(_),F));for(const _ of u){const T=g.get(_),O=p?d.map((S,j)=>{const q=r.get(S),Z=ua(q,S,T.values[j],T.sample);return q?.headerName?`${q.headerName}: ${Z}`:Z}).join(" / "):"";for(const S of f){const j=r.get(S.field),q=S.headerName??j?.headerName??S.field;$.push({field:h(_,S),headerName:O?`${O} — ${q} (${S.aggFn})`:`${q} (${S.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:Z,row:W})=>An(Z,S.aggFn,j,W)})}}return{pivotRows:P,pivotColumns:$,colKeys:u,isValid:!0}}function ua(e,t,n,o){const r=o?po(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function fa(e,t,n){const o={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(o.type=t.type),t.align!==void 0&&(o.align=t.align),t.headerAlign!==void 0&&(o.headerAlign=t.headerAlign),t.description!==void 0&&(o.description=t.description),t.minWidth!==void 0&&(o.minWidth=t.minWidth),t.maxWidth!==void 0&&(o.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(o.valueOptions=t.valueOptions)),e==="id"&&(o.valueGetter=({row:d})=>d[Lo]);const r=d=>d?.id===$t,i=t?.valueFormatter;i&&(o.valueFormatter=({value:d,row:a})=>r(a)?String(d??""):i({value:d,row:n(a?.id)??a,field:e}));const l=t?.renderCell;return l&&(o.renderCell=d=>r(d.row)?d.formattedValue??String(d.value??""):l({...d,row:n(d.row.id)??d.row})),o}function Ue(e,t){return e===$t||t?.get(e)?.isGroupRow===!0}const un="__reorder_col__",fn="__expand_col__",st="__checkbox_col__",Qe=e=>e===un||e===fn||e===st,Fo=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,ga=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),pa=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function li(e){const t=e.tagName;if(t==="INPUT")return!ga.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const n=e.getAttribute("role");return n!==null&&pa.has(n)}const si=e=>e!==null&&e.nodeType===1;function ai(e,t){const n=e.closest(".ogx__detail-panel");if(n&&t.contains(n))return null;const o=e.closest('[role="gridcell"], [role="columnheader"]');return!o||o.closest(".ogx__viewport")!==t?null:o}function Ao(e,t){if(e===t)return"grid";if(!si(e)||!t.contains(e))return"foreign";const n=ai(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":li(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function ha(e,t,n,o){if(!si(e))return null;const r=ai(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader")return r.parentElement?.classList.contains("ogx__header")?{id:null,field:i}:null;const l=Number(r.parentElement?.getAttribute("data-rowindex")),d=Number.isInteger(l)?n[l]:void 0;return d?{id:o(d),field:i,rowIndex:l}:null}function ci(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function Do(e,t,n){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=ci(r,t.field);return i&&t.field===st?i.querySelector("input")??i:i}if(n<0)return null;const o=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${n}"]`);return ci(o,t.field)}const di="__group__";function je(e){return!Qe(e)&&e!==di}const at=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.field===t.field;function ma(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>at(n.anchor,t[o].anchor)&&at(n.head,t[o].head))}function On(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:d}=n,a={top:e,bottom:e,left:t,right:t};if(!d)return a;const f=o[e],p=r[t],w=d.getSpanOrigin(f,p)??{rowId:f,field:p},b=i.get(w.rowId),C=l.get(w.field);if(b===void 0||C===void 0)return a;const g=Math.max(1,d.getRowSpan(w.rowId,w.field)),u=Math.max(1,d.getColSpan(w.rowId,w.field));return{top:b,bottom:Math.min(o.length-1,b+g-1),left:C,right:Math.min(r.length-1,C+u-1)}}function wa(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const d=a=>{a.top<n&&(n=a.top,l=!0),a.bottom>o&&(o=a.bottom,l=!0),a.left<r&&(r=a.left,l=!0),a.right>i&&(i=a.right,l=!0)};for(;l;){l=!1;for(let a=n;a<=o;a++)d(On(a,r,t)),i!==r&&d(On(a,i,t));for(let a=r+1;a<i;a++)d(On(n,a,t)),o!==n&&d(On(o,a,t))}return{top:n,bottom:o,left:r,right:i}}function $n(e,t){const n=t.rowIndexById.get(e.anchor.id),o=t.rowIndexById.get(e.head.id),r=t.colIndexByField.get(e.anchor.field),i=t.colIndexByField.get(e.head.field);return n===void 0||o===void 0||r===void 0||i===void 0?null:{...wa({top:Math.min(n,o),bottom:Math.max(n,o),left:Math.min(r,i),right:Math.max(r,i)},t),anchorRow:n,anchorCol:r,headRow:o,headCol:i}}const vt=e=>(e.bottom-e.top+1)*(e.right-e.left+1);function xa(e,t,n,o,r,i){const{headRow:l,headCol:d,anchorRow:a,anchorCol:f,top:p,bottom:w,left:b,right:C}=e;let g=l,u=d;switch(t){case"ArrowRight":u=d>=f?C+1:d+1;break;case"ArrowLeft":u=d<=f?b-1:d-1;break;case"ArrowDown":g=l>=a?w+1:l+1;break;case"ArrowUp":g=l<=a?p-1:l-1;break;case"Home":u=0,n&&(g=0);break;case"End":u=i,n&&(g=r);break;case"PageUp":g=l-o;break;case"PageDown":g=l+o;break;default:return null}return g=Math.min(Math.max(g,0),r),u=Math.min(Math.max(u,0),i),g===l&&u===d?null:{row:g,col:u}}function ui(e,t,n){return!e||t<e.top||t>e.bottom?null:{left:e.left,right:e.right,isTop:t===e.top,isBottom:t===e.bottom,bottomOffset:n?e.bottom-t:0}}const ba=(e,t)=>e===t||!!e&&!!t&&e.left===t.left&&e.right===t.right&&e.isTop===t.isTop&&e.isBottom===t.isBottom&&e.bottomOffset===t.bottomOffset,Oo=1,fi=2,gi=4,pi=8,hi=16;function Ca(e,t,n,o){if(!e)return 0;const r=t+Math.max(1,n)-1;if(t<e.left||r>e.right)return 0;let i=Oo;return e.isTop&&(i|=fi),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(i|=gi),t===e.left&&(i|=pi),r===e.right&&(i|=hi),i}function ya(e,t,n){const o=(r,i,l)=>`${r} ${r===1?i:l}`;return`${o(e,"cell","cells")} selected, ${o(t,"row","rows")} by ${o(n,"column","columns")}`}const va=1e5,Sa=e=>e.id,mi=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function _a(e,t,n,o){if(!e||n.length===0)return{cell:null,rowIndex:-1};const r=(n.find(a=>!Qe(a.field))??n[0]).field,i=n.some(a=>a.field===e.field)?e.field:r;if(e.id===null)return{cell:i===e.field?e:{id:null,field:i},rowIndex:-1};const l=e.rowIndex;let d=l!==void 0&&t[l]&&o(t[l])===e.id?l:t.findIndex(a=>o(a)===e.id);return d===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(d=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:o(t[d]),field:i,rowIndex:d},rowIndex:d}):{cell:i===e.field?e:{...e,field:i},rowIndex:d}}function ka(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:d,setKeyboardMode:a,sortModel:f,handleSort:p,handleSortAdd:w,multiSort:b=!1,isCellEditable:C,pagination:g,pageSize:u,virtualization:h,viewportRef:x,pinnedTopRowCount:m=0,getRowId:y=Sa,rowMetaMap:E,onRowActivate:v,toggleRowExpansion:M,handleSelectAll:N,rowSelectionEnabled:P=!0,multipleRowSelectionEnabled:z=!0,pinCheckboxColumn:F=!0,pinExpandColumn:$=!0,rowHeight:_,getSpanOrigin:T,cellSelection:O}=e,[S,j]=s.useState(null),[q,Z]=s.useState(!1),W=s.useMemo(()=>_a(S,t,n,y),[S,t,n,y]),U=W.cell,Q=W.rowIndex,ie=s.useRef(!1),oe=s.useRef(!1),ge=s.useRef(!1),le=s.useRef(null),ue=s.useCallback(G=>{oe.current=!0,G.focus({preventScroll:!0}),oe.current=!1},[]),te=s.useCallback(()=>{const G=x.current;G&&!G.contains(G.ownerDocument.activeElement)&&ue(G)},[x,ue]),ae=s.useMemo(()=>n.find(G=>!Qe(G.field))??n[0],[n]),Y=s.useCallback(()=>{if(o)return{id:null,field:st};if(!ae)return null;const G=t[0];return G?{id:y(G),field:ae.field,rowIndex:0}:{id:null,field:ae.field}},[o,ae,t,y]),re=s.useCallback((G,I)=>{const D=x.current;if(!D)return;const{cumulativeHeights:L,pinnedBottomHeight:A,columnMetrics:V}=h;if(G>=0&&Tn(D,G-m,L,A,_),Qe(I)){!(I===un||I===fn&&$||I===st&&F)&&D.scrollLeft>0&&(D.scrollLeft=0);return}if(!V)return;const{clientWidth:R,scrollLeft:B}=D,{leftPinnedWidth:k,rightPinnedWidth:H,unpinnedAccWidths:X,unpinnedCols:ee,totalSpecialsWidth:ce,pinnedSpecialsWidth:pe}=V,me=ee.findIndex(be=>be.field===I);if(me===-1)return;const ye=ce+k+(me>0?X[me-1]:0),_e=ce+k+X[me],Ce=B+pe+k,Ee=B+R-H;let se=B;ye<Ce?se=Math.max(0,ye-pe-k):_e>Ee&&(se=_e-R+H),se!==B&&(D.scrollLeft=se)},[x,h,m,_,F,$]);s.useLayoutEffect(()=>{const G=x.current,I=!Fo(le.current,U);if(le.current=U,!G||!U)return;const D=G.ownerDocument,L=D.activeElement;let A;if(L===G?A=!0:!L||L===D.body?A=ie.current:G.contains(L)?A=I:A=!1,!A)return;const V=Do(G,U,Q);V?V.contains(L)||V.focus({preventScroll:!0}):L!==G&&ue(G)});const K=s.useCallback(()=>{ge.current=!0,a(!1)},[a]),J=s.useCallback(G=>{const I=G.currentTarget,D=G.relatedTarget,L=!(D instanceof Node&&I.contains(D)),A=ge.current;if(ge.current=!1,ie.current=!0,Z(!0),oe.current)return;if(G.target===I){if(!L)return;if(A||a(!0),U){const B=Do(I,U,Q);B?B.focus({preventScroll:!0}):re(Q,U.field);return}const R=Y();R&&(j(B=>B??R),re(R.rowIndex??-1,R.field));return}const V=ha(G.target,I,t,y);V&&!Fo(V,U)&&j(V)},[U,Q,Y,re,a,t,y]),ne=s.useCallback(G=>{const I=G.relatedTarget;I instanceof Node&&G.currentTarget.contains(I)||(ie.current=!1,ge.current=!1,Z(!1),a(!1))},[a]),de=s.useCallback(G=>{const I=G.currentTarget,D=Ao(G.target,I);if(D==="foreign"||(a(!0),G.nativeEvent?.isComposing||G.keyCode===229))return;const{key:L}=G,A=L===" "||L==="Spacebar",V=!!d.editingCell,R=(fe,we)=>{const Se=n[we];!Se||fe<-1||fe>=t.length||(j(fe===-1?{id:null,field:Se.field}:{id:y(t[fe]),field:Se.field,rowIndex:fe}),re(fe,Se.field))};if(!U){if(!mi.has(L))return;const fe=Y();if(!fe)return;G.preventDefault(),j(fe),re(fe.rowIndex??-1,fe.field);return}const{id:B,field:k}=U,H=Q,X=n.findIndex(fe=>fe.field===k),ee=n.filter(fe=>Qe(fe.field)).length,ce=fe=>Ue(fe,E),pe=(fe,we,Se)=>{const Ne=n[Se];return Qe(Ne.field)?!1:Co({row:fe,field:Ne.field,value:ke(fe,Ne.field,Ne),colDef:Ne,rowIndex:we,colIndex:Se-ee,rowMeta:E?.get(y(fe))},C)},me=fe=>{let we=H,Se=X;const Ne=(t.length+1)*n.length;for(let tt=0;tt<Ne;tt++){if(Se+=fe,Se>=n.length?(Se=0,we++):Se<0&&(Se=n.length-1,we--),we<0||we>=t.length)return null;const $e=t[we];if(!T?.(y($e),n[Se].field)&&pe($e,we,Se))return{r:we,c:Se}}return null};if(V){if(L==="Enter")G.preventDefault(),d.stopCellEdit();else if(L==="Escape")G.preventDefault(),d.stopCellEdit({cancel:!0});else if(L==="Tab"&&B!==null){const fe=me(G.shiftKey?-1:1);fe&&(G.preventDefault(),d.stopCellEdit(),R(fe.r,fe.c))}return}if(L==="Escape"&&O?.collapseSelection()){G.preventDefault();return}if(L==="Tab"||L==="Escape"||D==="control"&&(L==="Enter"||A))return;if((G.ctrlKey||G.metaKey)&&(L==="a"||L==="A")){if(O){O.selectAllCells()&&G.preventDefault();return}if(!P||!z||!N)return;G.preventDefault(),N(!0);return}if(B===null){if(L==="Enter"||A){if(G.preventDefault(),k===st){Do(I,U,-1)?.click();return}const fe=n[X];if(!fe||Qe(k)||fe.sortable===!1)return;const we=f.find(Ne=>Ne.field===k),Se=we?we.sort==="asc"?"desc":null:"asc";(b||G.shiftKey)&&w?w(k,Se):p(k,Se);return}}else if(L==="Enter"||A){G.preventDefault();const fe=t[H];if(k===st){i(B,!r.has(B));return}if(k===fn){G.shiftKey||l(B);return}if(A){G.shiftKey&&P&&!ce(B)&&i(B,!r.has(B));return}if(k===un)return;if(pe(fe,H,X)){d.startCellEdit({id:B,field:k,value:ke(fe,k,n[X])});return}if(M&&E?.get(B)?.hasChildren){M(B);return}v?.({row:fe,id:B,rowIndex:H});return}if(G.altKey&&(L==="ArrowRight"||L==="ArrowLeft")&&M&&B!==null){G.preventDefault();const fe=E?.get(B);fe?.hasChildren&&!!fe.isExpanded!=(L==="ArrowRight")&&M(B);return}if(!mi.has(L))return;G.preventDefault();const ye=t.length-1,_e=n.length-1,Ce=G.ctrlKey||G.metaKey,Ee=g?u:10;if(O&&G.shiftKey&&B!==null&&je(k)&&O.extendSelection(L,Ce,Ee,U))return;const se=(fe,we)=>{switch(L){case"ArrowRight":return we+1>_e?{r:fe+1,c:0}:{r:fe,c:we+1};case"ArrowLeft":return we-1<0?{r:fe-1,c:_e}:{r:fe,c:we-1};case"ArrowDown":return{r:fe+1,c:we};case"ArrowUp":return{r:fe-1,c:we};case"Home":return{r:Ce?-1:fe,c:0};case"End":return{r:Ce?ye:fe,c:_e};case"PageUp":return{r:Math.max(-1,fe-Ee),c:we};default:return{r:Math.min(ye,fe+Ee),c:we}}},be=({r:fe,c:we})=>fe>=-1&&fe<=ye&&we>=0&&we<=_e,Me=({r:fe,c:we})=>fe>=0?T?.(y(t[fe]),n[we].field)??null:null;let ve=se(H,X);if(L.startsWith("Arrow"))for(let fe=be(ve)?Me(ve):null;fe&&fe.rowId===B&&fe.field===k;fe=be(ve)?Me(ve):null)ve=se(ve.r,ve.c);if(!be(ve))return;const he=Me(ve);if(he){const fe=t.findIndex(Se=>y(Se)===he.rowId),we=n.findIndex(Se=>Se.field===he.field);fe!==-1&&we!==-1&&(ve={r:fe,c:we})}ve.r===H&&ve.c===X||R(ve.r,ve.c)},[U,Q,t,n,d,r,i,l,a,f,p,w,b,C,g,u,E,v,M,N,P,z,Y,re,T,y,O]);return{focusedCell:U,setFocusedCell:j,viewportTabIndex:q?-1:0,ensureGridFocus:te,handleFocus:J,handleBlur:ne,handleKeyDown:de,handleMouseDownCapture:K}}const Ea=[],Ma={rowFields:[],columnFields:[],valueFields:[]},wi=100;function Na(e){return!e||e.length===0||e.includes(wi)?wi:e[0]}function Ia(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:d,columnVisibilityModel:a,onColumnVisibilityModelChange:f,pinnedColumns:p,onPinnedColumnsChange:w,pivotModel:b,onPivotModelChange:C,paginationModel:g,onPaginationModelChange:u,pageSizeOptions:h,rowSelectionModel:x,onRowSelectionModelChange:m,density:y,cellSelectionModel:E,onCellSelectionModelChange:v}=e,[M,N]=s.useState(()=>t?.sorting?.sortModel??[]),P=n!==void 0,z=P?n:M,F=s.useCallback(he=>{P||N(he),o?.(he)},[P,o]),[$,_]=s.useState(()=>t?.filter?.filterModel??{items:[]}),T=r!=null,O=T?r:$,S=s.useCallback(he=>{T||_(he),i?.(he)},[T,i]),j=l!==void 0,[q,Z]=s.useState(()=>l??{}),W=JSON.stringify(j?l:q),U=s.useMemo(()=>JSON.parse(W),[W]),Q=s.useCallback(he=>{j||Z(he),d?.(he)},[j,d]),ie=a!==void 0,[oe,ge]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),le=ie?a:oe,ue=s.useCallback(he=>{ie||ge(he),f?.(he)},[ie,f]),te=p!==void 0,[ae,Y]=s.useState(()=>t?.columns?.pinnedColumns??{}),re=te?p:ae,K=s.useCallback(he=>{te||Y(he),w?.(he)},[te,w]),[J,ne]=s.useState(()=>b??Ma),de=b??J,G=s.useCallback(he=>{ne(he),C?.(he)},[C]),I=g!==void 0,[D,L]=s.useState(()=>t?.pagination?.paginationModel??g??{page:0,pageSize:Na(h)}),A=I?g:D,V=s.useCallback(he=>{I||L(he),u?.(he)},[I,u]),R=x!==void 0,[B,k]=s.useState([]),H=R?x:B,X=s.useMemo(()=>new Set(H),[H]),ee=s.useRef(null);s.useLayoutEffect(()=>{ee.current=null});const ce=s.useCallback(()=>ee.current,[]),pe=s.useCallback(he=>{ee.current=he,R||k(he),m?.(he)},[R,m]),[me]=s.useState(()=>t?.density?.density??"standard"),ye=y??me,_e=E!==void 0,[Ce,Ee]=s.useState(Ea),se=_e?E:Ce,be=s.useRef(null);s.useLayoutEffect(()=>{be.current=null});const Me=s.useCallback(()=>be.current,[]),ve=s.useCallback((he,fe)=>{be.current=he,_e||Ee(he),v?.(he,{reason:fe})},[_e,v]);return{sortModel:z,isSortControlled:P,setInternalSortModel:N,handleSortModelChange:F,filterModel:O,isFilterControlled:T,handleFilterModelChange:S,aggregationModel:U,handleAggregationModelChange:Q,columnVisibilityModel:le,handleColumnVisibilityModelChange:ue,pinnedColumns:re,handlePinnedColumnsChange:K,currentPivotModel:de,handlePivotModelChange:G,effectivePaginationModel:A,handlePaginationModelChange:V,rowSelectionModel:H,selectedRowIds:X,isSelectionControlled:R,setInternalRowSelectionModel:k,handleRowSelectionModelChange:pe,getPendingRowSelectionModel:ce,density:ye,cellSelectionModel:se,handleCellSelectionModelChange:ve,getPendingCellSelectionModel:Me}}const xi=s.createContext(null),Pa=52,La=56,Ta=32,Fa=72;function Gn(e){if(e===void 0)return;const t=/^(\d+(?:\.\d+)?)(?:\s*px)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);return n>0?n:void 0}function Aa(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(xi)?.grid;let i;return o==="compact"?i=Gn(r?.rowHeightCompact)??Ta:o==="comfortable"?i=Gn(r?.rowHeightComfortable)??Fa:i=t??Gn(r?.rowHeightStandard)??Pa,{rowHeight:i,headerHeight:n??Gn(r?.headerHeight)??La}}function Wn(e){return e>=1?Math.floor(e):1}function $o(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/Wn(t)))}function Da(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function bi(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Ci(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Oa(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:d,paginationMode:a,effectivePaginationModel:f,pinnedRows:p,getRowId:w,columnLookup:b,hierarchyField:C}=e,g=s.useMemo(()=>n?n.getVisibleRows({labelField:C})||[]:o==="server"?t:ko(t,r,b),[t,r,n,C,o,b]),u=s.useMemo(()=>n?o==="server"?t:ko(t,r,b):g,[n,g,o,t,r,b]),{top:h,center:x,bottom:m}=s.useMemo(()=>n?{top:[],center:g,bottom:[]}:Ls(g,p,w),[g,p,n,w]),y=s.useMemo(()=>n||l==="server"?x:na(x,i,b,w),[x,i,n,l,b,w]),E=d&&a!=="server",v=Wn(f.pageSize),M=E?Ci(f.page,$o(y.length,v)):f.page,N=s.useMemo(()=>{if(!E)return y;const z=M*v;return y.slice(z,z+v)},[y,E,M,v]),P=s.useMemo(()=>{const z=d?N:y;return[...h,...z,...m]},[h,N,y,m,d]);return{filteredRows:g,dataRows:u,pinnedTopRows:h,unpinnedRows:x,pinnedBottomRows:m,sortedUnpinnedRows:y,paginatedUnpinnedRows:N,currentPage:M,allRenderableRows:P}}function $a(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:d,hasDetailPanel:a,checkboxSelection:f,pinCheckboxColumn:p,pinExpandColumn:w,overscanRows:b=5}=e;return s.useMemo(()=>{const{unpinnedAccWidths:C,unpinnedColsWithWidth:g,leftPinnedCols:u,rightPinnedCols:h,totalWidth:x,leftWidth:m,rightWidth:y,unpinnedTotalWidth:E,systemColumnsWidth:v,cumulativeHeights:M,pinnedTopHeight:N,pinnedBottomHeight:P,unpinnedRowsHeight:z,rowHeights:F,unpinnedRowsLength:$}=t,_=r||1e3,T=l?N+z+P+50:i||600,O=6,S=Math.max(0,o-m),j=o+_-m;let q=0,Z=g.length-1,W=0,U=C.length-1;for(;W<=U;){const ne=W+U>>>1;C[ne]<S?W=ne+1:U=ne-1}q=Math.max(0,W-O);for(let ne=q;ne<C.length;ne++){if((ne===0?0:C[ne-1])>j){Z=Math.min(g.length-1,ne+O);break}Z=Math.min(g.length-1,ne+O)}const Q=q>0?C[q-1]:0,ie=E-C[Z],oe=[...u,...Q>0?[{field:"__spacer_left__",width:Q,isSpacer:!0}]:[],...g.slice(q,Z+1),...ie>0?[{field:"__spacer_right__",width:ie,isSpacer:!0}]:[],...h],le=_>0&&x>_?16:0,ue=N+z+P+le+2;let te=0,ae=$-1,Y=0,re=0,K=M.length-1;for(;re<=K;){const ne=re+K>>>1;M[ne]<n?re=ne+1:K=ne-1}te=Math.max(0,re-b),Y=te>0?M[te-1]:0;for(let ne=te;ne<M.length;ne++)if(M[ne]>=n+T){ae=Math.min($-1,ne+b);break}const J=(d?48:0)+(a&&w?48:0)+(f&&p?48:0);return{renderContext:{firstRowIndex:te,lastRowIndex:ae,firstColumnIndex:q,lastColumnIndex:Z},offsetTop:Y,offsetLeft:0,totalHeight:ue,pinnedTopHeight:N,pinnedBottomHeight:P,totalWidth:x,rowHeights:F,cumulativeHeights:M,virtualColumns:oe,columnMetrics:{leftPinnedWidth:m,rightPinnedWidth:y,unpinnedAccWidths:C,unpinnedCols:g,totalSpecialsWidth:v,pinnedSpecialsWidth:J}}},[t,n,o,r,i,l,d,a,f,p,w,b])}const Go="application/x-ogx-row",Wo="application/x-ogx-column";function yi(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function Bn(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function vi(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function Ga(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,d]=s.useState(null),a=s.useRef(()=>{}),f=s.useCallback(()=>{a.current(),a.current=()=>{},i(null),d(null)},[]);s.useEffect(()=>()=>a.current(),[]);const p=s.useCallback(C=>g=>{if(!o){if(!t.some(u=>u.field===C)){g.preventDefault();return}a.current(),a.current=vi(g.currentTarget,f),i(C),g.dataTransfer&&(g.dataTransfer.effectAllowed="move",yi(g,Wo,C))}},[t,o,f]),w=s.useCallback(C=>g=>{if(!(o||r===null)){if(!Bn(g,Wo)){f();return}g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="move"),d(C)}},[r,o,f]),b=s.useCallback(C=>g=>{if(g.preventDefault(),o||r===null||!Bn(g,Wo)){f();return}const u=t.findIndex(x=>x.field===r),h=t.findIndex(x=>x.field===C);f(),!(u===-1||h===-1||u===h)&&n?.({column:t[u],oldIndex:u,targetIndex:h})},[t,r,o,n,f]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:p,onDragOver:o?void 0:w,onDragEnd:o?void 0:f,onDrop:o?void 0:b}}function Bo({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){return c.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",type:"button",tabIndex:o,children:n==="plus-minus"?c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:c.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Wa({renderFn:e}){"use no memo";return c.jsx(c.Fragment,{children:e()})}function Ba(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>Object.is(n,t[o])):Object.is(e,t)}class St extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,n){return Ba(t.resetKey,n.resetKey)?null:n.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,n.componentStack)}render(){return this.state.hasError?c.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):c.jsx(Wa,{renderFn:this.props.renderFn})}}function Ha(e,t,n){if(!t||!n)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const o=l=>n.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>o(l.row)?l.value:r(l):void 0,valueFormatter:l=>o(l.row)?An(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Si(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=lt(i.field,t);return l==="left"?n.indexOf(i.field)-n.length:l==="right"?1+o.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const Hn=e=>e.formattedValue??e.value;function _i(e,t,n){const o=e.renderCell;if(!o)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!n){const l=o(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=o(t)}catch(l){return{useDefault:!1,content:c.jsx(St,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:c.jsx(St,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function za(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return Hn(e);if(o.isGroupFooter)return null;const r=o.descendantCount;if(t&&o.hasChildren){const i=o.groupLabel??`${o.groupingField}: ${String(o.groupingValue)}`;return c.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return n?c.jsxs("div",{className:"ogx__group-cell-content",children:[o.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):Hn(e)}const Va=e=>e.id;function Ka(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:d,onColumnOrderChange:a,onColumnOrderModelChange:f,disableColumnReorder:p,pivotMode:w,checkboxSelection:b,hasDetailPanel:C,rowReordering:g,initialState:u,setColumns:h,pinnedColumns:x,getRowId:m=Va,aggregationModel:y,groupingRows:E}=e,v=s.useMemo(()=>t.map(K=>K.field),[t]),[M,N]=s.useState(()=>u?.columns?.columnOrder??null),P=w?v.join("\0"):"",[z,F]=s.useState(null),$=z&&z.key===P?z.order:v,T=w?$:d??(M??v),O=s.useCallback(K=>{if(w){F(J=>{const ne=J&&J.key===P?J.order:v;return{key:P,order:typeof K=="function"?K(ne):K}});return}N(J=>typeof K=="function"?K(J??v):K)},[w,P,v]),S=s.useCallback(K=>w&&K.hideable===!1||l[K.field]!==!1,[w,l]),j=s.useMemo(()=>{if(!n)return;const K=new Map(T.map((G,I)=>[G,I])),J=G=>K.get(G.field)??t.indexOf(G),ne=[...t].sort((G,I)=>J(G)-J(I));return(Si(ne.filter(G=>l[G.field]!==!1),x)[0]??t[0])?.field},[n,T,t,l,x]),q=s.useMemo(()=>{if(!n)return t;const K=o?E:void 0;return t.map(J=>{const ne=Ha(J,y?.[J.field],K);return J.field===j?{...J,...ne,renderCell:de=>{const G=de.rowMeta,I=G?.treeDepth??0,D=!!G?.hasChildren,L=!!G?.isExpanded,A=_i(J,de,!0),V=A.useDefault?za(de,o,r):A.content;return c.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:I*24,width:"100%",height:"100%"},children:[c.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:D?"pointer":"default",flexShrink:0},children:D?c.jsx("div",{onClick:R=>{R.stopPropagation(),R.preventDefault(),i?.toggleExpansion(m(de.row))},onMouseDown:R=>{R.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:c.jsx(Bo,{isExpanded:L,tabIndex:-1,onClick:R=>{R.stopPropagation(),R.preventDefault(),i?.toggleExpansion(m(de.row))}})}):null}),c.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V})]})}}:{...J,...ne,renderCell:de=>{const G=de.rowMeta;if(!G?.isGroupRow)return J.renderCell?J.renderCell(de):Hn(de);const I=_i(J,de,!1);return I.useDefault?J.field===G.groupingField&&!G.isGroupFooter||de.value==null?null:Hn(de):I.content}}})},[t,n,o,r,i,j,m,y,E]),[Z,W]=s.useState(()=>u?.columns?.columnWidths??{}),U=s.useCallback((K,J)=>{W(ne=>({...ne,[K]:J}))},[]);s.useEffect(()=>{h(t)},[t,h]);const Q=s.useMemo(()=>{const K=new Map(T.map((J,ne)=>[J,ne]));return[...q].sort((J,ne)=>{const de=K.get(J.field)??q.indexOf(J),G=K.get(ne.field)??q.indexOf(ne);return de-G})},[q,T]),ie=s.useMemo(()=>Q.filter(S),[Q,S]),oe=s.useCallback((K,J)=>{(w||!d)&&O(K),J&&a?.(J),w||f?.(K)},[w,d,O,a,f]),ge=s.useCallback((K,J)=>{const ne=Q.map(G=>G.field),[de]=ne.splice(K,1);ne.splice(J,0,de),oe(ne,{column:Q[K],oldIndex:K,targetIndex:J})},[Q,oe]),le=Ga({columns:Q,onColumnOrderChange:s.useCallback(({oldIndex:K,targetIndex:J})=>ge(K,J),[ge]),disableColumnReorder:p}),ue=s.useCallback((K,J)=>{const ne=Q.findIndex(G=>G.field===K),de=Q.findIndex(G=>G.field===J);ne===-1||de===-1||ne===de||ge(ne,de)},[Q,ge]),te=s.useCallback(()=>{oe(v)},[oe,v]),ae=s.useMemo(()=>Si(ie,x),[ie,x]),Y=s.useMemo(()=>{const K=[];return g&&K.push({field:un,sortable:!1,editable:!1}),C&&K.push({field:fn,sortable:!1,editable:!1}),b&&K.push({field:st,sortable:!1,editable:!1}),[...K,...ae]},[ae,b,C,g]),re=s.useMemo(()=>new Map(ae.map((K,J)=>[K.field,J])),[ae]);return{effectiveColumns:q,hierarchyField:j,orderedColumns:Q,visibleOrderedColumns:ie,renderOrderedColumns:ae,navigationColumns:Y,columnIndexMap:re,columnWidths:Z,effectiveColumnOrder:T,setInternalColumnOrder:O,columnReorderHandlers:le,moveColumn:ue,resetColumnOrder:te,handleColumnResize:U}}const Ua=e=>e.id;function ja(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:d=Ua}=e;return s.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:f}=t,p=l?r:i,w=n.length,b=n.map((y,E)=>({row:y,id:d(y),rowIndex:E,pinned:"top"})),C=o.map((y,E)=>({row:y,id:d(y),rowIndex:w+p.length+E,pinned:"bottom"})),g=Math.max(0,a),u=Math.min(p.length,f+1),h=p.slice(g,u).map((y,E)=>({row:y,id:d(y),rowIndex:w+g+E})),x=[...b,...h,...C],m=new Set;return x.filter(y=>m.has(y.id)?!1:(m.add(y.id),!0))},[t,n,o,r,i,l,d])}const Ra=100;function ki(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=Ra?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function qa(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Xa(e){const{onRowsScrollEnd:t,overscanRowCount:n=3,rowCount:o=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),d=s.useRef(null),a=s.useRef(null),f=s.useRef(null),p=s.useRef(!0),w=s.useRef(t),[b,C]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{w.current=t},[t]),s.useEffect(()=>()=>{d.current!==null&&cancelAnimationFrame(d.current),a.current!==null&&clearTimeout(a.current)},[]);const g=s.useCallback(x=>{const m=ki(x);if(!m){p.current=!0;return}if(!p.current)return;const y=w.current;y&&(p.current=!1,y(m))},[]),u=s.useCallback(x=>{const m=x.currentTarget,y=performance.now(),E=Math.abs(m.scrollTop-l.current.scrollTop)+Math.abs(m.scrollLeft-l.current.scrollLeft),v=y-l.current.time,M=v>0?E/v:0,N=m.scrollTop!==l.current.scrollTop;l.current={scrollTop:m.scrollTop,scrollLeft:m.scrollLeft,time:y},i.current={scrollTop:m.scrollTop,scrollLeft:m.scrollLeft,velocity:M},d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;const{scrollTop:P,scrollLeft:z,velocity:F}=i.current;C({scrollTop:P,scrollLeft:z,velocityOverscan:qa(F)})}),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,C(P=>P.velocityOverscan===0?P:{...P,velocityOverscan:0})},200),N&&g(m)},[g]);s.useEffect(()=>{p.current=!0;const x=f.current;!x||r||o<=0||x.clientHeight===0||g(x)},[o,r,g]);const h=s.useCallback(x=>{if(f.current=x,!x)return;const{scrollTop:m,scrollLeft:y}=i.current;if(m===0&&y===0)return;x.scrollTop=m,x.scrollLeft=y;const E={scrollTop:x.scrollTop,scrollLeft:x.scrollLeft};(E.scrollTop!==m||E.scrollLeft!==y)&&(i.current={...i.current,...E},l.current={...l.current,...E},C(v=>({...v,...E})))},[]);return{scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,overscanRows:Math.max(b.velocityOverscan,n),handleScroll:u,attachViewport:h}}function Ya(e){const t=s.useRef(null);return s.useCallback(n=>{if(t.current?.disconnect(),t.current=null,!n||typeof ResizeObserver>"u")return;const o=new ResizeObserver(r=>{for(const i of r){const{width:l,height:d}=i.contentRect;e(l,d)}});o.observe(n),t.current=o},[e])}function Ja(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,attachViewport:a}=Xa(o),f=Ya(t),p=s.useCallback(w=>{n.current=w,f(w),a(w)},[n,f,a]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,setViewportElement:p}}function Za(){const[e,t]=s.useState(()=>new Map),n=s.useCallback((o,r)=>{t(i=>{if(i.get(o)===r)return i;const l=new Map(i);return l.set(o,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:n}}function Qa(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),d=n??i,a=s.useMemo(()=>Os(d,r),[d,r]),f=s.useCallback(b=>{if(r.get(b)?.isGroupRow)return;const C=new Set(d);C.has(b)?C.delete(b):C.add(b),n===void 0&&l(C),o?.(C)},[d,r,n,o]),{detailPanelHeights:p,reportDetailPanelHeight:w}=Za();return{hasDetailPanel:t,expandedRowIds:a,handleDetailPanelToggle:f,detailPanelHeights:p,reportDetailPanelHeight:w}}const ec=new Set(["__group__"]),gn=e=>!ec.has(e);function Ei(e){return Object.keys(e).every(gn)?e:Object.fromEntries(Object.entries(e).filter(([n])=>gn(n)))}function tc(e){const t={...e};return e.left&&(t.left=e.left.filter(gn)),e.right&&(t.right=e.right.filter(gn)),t}function nc(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:d,pinnedColumns:a,density:f}=e,p=s.useRef(t);s.useLayoutEffect(()=>{p.current=t});const w=s.useRef(null);s.useEffect(()=>{if(!p.current)return;const b={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:Ei(i),columnOrder:l.filter(gn),columnVisibilityModel:Ei(d),pinnedColumns:tc(a)},density:{density:f}},C=JSON.stringify(b);C!==w.current&&(w.current=C,p.current(b))},[n,o,r,i,l,d,a,f])}const oc=200,rc=2e3,ic=178e5;function lc(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:d=!1,scrollHeight:a=0,listViewWithoutColumn:f=!1,listViewRowCount:p=0}=e,w=s.useRef(!1),b=s.useRef(!1),C=s.useRef(!1),g=s.useRef(!1),u=s.useRef(!1),h=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||p<=rc||(h.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${p} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[p]),s.useEffect(()=>{process.env.NODE_ENV==="production"||u.current||!f||(u.current=!0,console.warn("[OpenGridX] `listView` is set without a `listViewColumn`, so the grid view is shown instead. Pass `listViewColumn` to render list items. See docs/features/list-view.md."))},[f]),s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||!d||(C.current=!0,console.warn("[OpenGridX] `pinnedRows` is ignored while treeData or rowGroupingModel is active: the rows stay in their place in the hierarchy. See docs/features/pinning.md."))},[d]),s.useEffect(()=>{process.env.NODE_ENV==="production"||g.current||a<=ic||(g.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(a)}px tall. Browsers cap element heights (about 17.9M px in Firefox, 33.5M px in Chrome and Safari), so the last rows may not be reachable by scrolling. Use pagination, server-side or infinite loading, or a smaller rowHeight. See docs/features/virtualization.md.`))},[a]),s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||t&&n&&(w.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,n]),s.useEffect(()=>{process.env.NODE_ENV==="production"||b.current||o||r>0&&l>oc&&i>=l&&r>=a&&(b.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off: the grid fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[o,r,i,l,a])}function sc(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Mi=!1;function ac(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||Mi)return;const t=e.current;!t||!sc(t)||(Mi=!0,console.warn("[OpenGridX] The grid stylesheet is not loaded, so the grid is unstyled and renders every row (its viewport does not scroll). Add `import '@opencorestack/opengridx/styles'` once in your app root. See README.md, Getting Started."))},[e])}function zn(e,t,n,o){if(n&&o)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>n?r.add(i):r.delete(i)),Array.from(r)}function cc(e,t,n){return n?e.has(t)?[]:[t]:zn(e,[t],!e.has(t),!1)}function Ni(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function dc(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(w=>{Ni(t,w)||n(w)},[t,n]),l=s.useCallback((w,b)=>{i(zn(t,[w],b,o))},[i,t,o]),d=s.useCallback(w=>{i(cc(t,w,o))},[i,t,o]),a=s.useCallback(w=>{i(zn(t,r,w,!1))},[i,t,r]),{allSelected:f,someSelected:p}=s.useMemo(()=>{let w=0;for(const C of r)t.has(C)&&w++;const b=r.length>0&&w===r.length;return{allSelected:b,someSelected:!b&&w>0}},[r,t]);return{toggleRow:l,clickRow:d,selectAll:o?void 0:a,allSelected:f,someSelected:p}}function uc(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:d,isHierarchyEnabled:a,rowMetaMap:f,activeHierarchyHandlers:p,onRowClick:w}=e,b=s.useMemo(()=>{const m=t.map(n);return o?m.filter(y=>y!==$t):m},[t,n,o]),C=dc({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:b}),{clickRow:g,toggleRow:u}=C,h=s.useCallback(m=>{const{id:y}=m,E=a?f.get(y):void 0;if(E?.isGroupRow){E.hasChildren&&p?.toggleExpansion(y);return}w?.(m),!d&&!Ue(y,f)&&g(y)},[a,p,w,f,d,g]),x=s.useCallback((m,y)=>{Ue(m,f)||u(m,y)},[f,u]);return{rowSelection:C,handleRowClick:h,handleSelectionChange:x}}const Ii=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function fc(e){const{selectedRowIds:t,rowsLookup:n,rowMetaMap:o,enabled:r,onSelectionModelChange:i}=e,l=s.useMemo(()=>{if(!r||t.size===0)return t;let f=!1;const p=new Set;for(const w of t)n.has(w)||o.has(w)?p.add(w):f=!0;return f?p:t},[r,t,n,o]),d=s.useRef(i);s.useLayoutEffect(()=>{d.current=i});const a=s.useRef(null);return s.useEffect(()=>{if(l===t){a.current=null;return}const f=`${Ii(t)}|${Ii(l)}`;a.current!==f&&(a.current=f,d.current(Array.from(l)))},[l,t]),l}function Ho(e,t,n,o){return o?oa(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function gc(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(Ho(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(Ho(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function pc(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:n,pinnedColumns:o,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:o});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:o}});const l=s.useCallback(a=>{const f={...i.current.columnVisibilityModel,[a]:!1};i.current={...i.current,columnVisibilityModel:f},n(f)},[n]),d=s.useCallback((a,f)=>{const p=Ts(i.current.pinnedColumns,a,f);i.current={...i.current,pinnedColumns:p},r(p)},[r]);return{handleHideColumn:l,handlePinColumn:d}}function hc(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=t.current,r=()=>n.current;o.getSortModel=()=>r().sortModel,o.sortColumn=(a,f)=>{const{sortModel:p,multiSort:w,onSortModelChange:b}=r(),C=Ho(p,a,f,w);n.current={...r(),sortModel:C},b(C)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=a=>{n.current={...r(),filterModel:a},r().onFilterModelChange(a)};const i=a=>{n.current={...r(),paginationModel:a},r().onPaginationModelChange(a)};o.setPage=a=>i({...r().paginationModel,page:a}),o.setPageSize=a=>i({...r().paginationModel,pageSize:a,page:0});const l=()=>{const a=r().getPendingRowSelectionModel?.();return a?new Set(a):r().selectedRowIds},d=(a,f)=>{const{disableMultipleRowSelection:p,onRowSelectionModelChange:w,isSyntheticRowId:b}=r(),C=b?a.filter(h=>!b(h)):a;if(C.length===0)return;const g=l(),u=zn(g,C,f,p);Ni(g,u)||(n.current={...r(),selectedRowIds:new Set(u)},w(u))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(a,f=!0)=>d([a],f),o.selectRows=(a,f=!0)=>d(a,f),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns},[t])}const Pi="\0";function mc(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(Pi);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(Pi))o[r]=!1;return Po(e,o)},[e,n])}function wc({paginationModel:e,currentPage:t,enabled:n,onPaginationModelChange:o}){const r=s.useRef({paginationModel:e,onPaginationModelChange:o});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:o}});const i=e.page,l=s.useRef(null);s.useEffect(()=>{if(!n)return;if(t===i){l.current=null;return}const d=`${i}>${t}`;if(l.current===d)return;l.current=d;const{paginationModel:a,onPaginationModelChange:f}=r.current;f({...a,page:t})},[n,t,i])}function xc(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),l=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),d=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),a=s.useCallback(()=>t(!1),[]),f=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function p(b){r.current&&!r.current.contains(b.target)&&o(!1)}function w(b){b.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",w)}},[n]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:a,standalonePanelOpen:n,closeStandalonePanel:f,standalonePanelRef:r,openColumnsPanel:d}}const Li=s.createContext(null);function bc(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function Cc({render:e,toolbarProps:t}){"use no memo";return c.jsx(c.Fragment,{children:e(t)})}function yc({component:e,toolbarProps:t}){if(bc(e))return c.jsx(Cc,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return c.jsx(n,{...t})}const Ti=48;function vc({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:d,pinCheckboxColumn:a=!0,pinExpandColumn:f=!0,pinnedColumns:p,loading:w=!1}){const b=s.useMemo(()=>fo(e,o,p,i,a,l,f,d),[e,o,p,i,a,l,f,d]),{lastLeft:C,firstRight:g}=s.useMemo(()=>go(e,p),[e,p]),u=d?Ti:0,h=u+(l&&f?Ti:0),x=(m,y,E)=>c.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:E}:void 0,"aria-hidden":"true"},m);return c.jsxs("div",{className:`ogx__aggregation-footer${w?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":w||void 0,style:{minHeight:`${r}px`},children:[d&&x("__reorder_col__",!0,0),l&&x("__expand_col__",f,u),i&&x("__checkbox_col__",a,h),e.map(m=>{if(m.isSpacer){const $=typeof m.width=="number"?m.width:0;return c.jsx("div",{style:{width:$,minWidth:$,flexShrink:0},"aria-hidden":"true"},m.field)}const y=t[m.field],E=y&&vo(m,y)?y:void 0,v=n[m.field],M=bt(m,o,120),N=lt(m.field,p),P=N?b[m.field]:void 0,z=["ogx__aggregation-cell",N==="left"&&"ogx__aggregation-cell--pinned-left",N==="right"&&"ogx__aggregation-cell--pinned-right",N==="left"&&m.field===C&&"ogx__aggregation-cell--pinned-left-last",N==="right"&&m.field===g&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),F={width:M,minWidth:M,maxWidth:M,textAlign:m.align||"left"};return N==="left"&&P!==void 0&&(F.left=P),N==="right"&&P!==void 0&&(F.right=P),c.jsx("div",{className:z,role:"gridcell",style:F,children:E?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"ogx__aggregation-label",children:E}),c.jsx("span",{className:"ogx__aggregation-value",children:An(v,E,m,n)})]}):null},m.field)})]})}function Sc({noRowsLabel:e,width:t,overlay:n}){return n?c.jsx("div",{className:"ogx__empty",style:{width:t},children:n}):c.jsxs("div",{className:"ogx__empty",style:{width:t},children:[c.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("path",{d:"M3 9h18M9 21V9"})]}),c.jsx("span",{children:e})]})}function Fi({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const Ai=Number.MAX_SAFE_INTEGER,_c="An unexpected error occurred while loading the data.";function Di(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:_c}function kc({error:e,onRetry:t}){if(!e)return null;const n=Di(e);return c.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[c.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:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),c.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),c.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),c.jsx("div",{className:"ogx-error-overlay__message",children:n}),t&&c.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}function Oi(e,t){typeof e=="function"?e(t):e&&(e.current=t)}const ct=s.forwardRef(function({indeterminate:t=!1,label:n,className:o="",inputClassName:r="",inputRef:i,...l},d){const a=s.useRef(null),f=s.useCallback(w=>{a.current=w,Oi(i,w),Oi(d,w)},[i,d]);s.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]);const p=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return c.jsxs("label",{className:p,children:[c.jsx("input",{ref:f,type:"checkbox",className:["ogx-checkbox__input",r].filter(Boolean).join(" "),...l}),c.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!t&&c.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:c.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),t&&c.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:c.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),n&&c.jsx("span",{className:"ogx-checkbox__label",children:n})]})});ct.displayName="Checkbox";const $i=50;function zo(e,t,n,o){const r=Math.min(n??$i,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const Ec=16;function Mc(e){e.preventDefault(),e.stopPropagation()}function Nc(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function Ic(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:d="end"}=e,[a,f]=s.useState(!1),p=s.useRef(null);s.useEffect(()=>()=>{p.current=null},[]);const w=s.useCallback((m,y)=>{const E=y-m.startX,v=m.startWidth+(d==="start"?-E:E);return zo(v,m.startWidth,i,l)},[d,i,l]),b=s.useCallback(m=>{if(m.button===0){m.stopPropagation(),p.current={pointerId:m.pointerId,startX:m.clientX,startWidth:n,lastUpdate:0,moved:!1},f(!0);try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}}},[n]),C=s.useCallback(m=>{const y=p.current;if(!y||m.pointerId!==y.pointerId||(m.clientX!==y.startX&&(y.moved=!0),!y.moved))return;const E=Date.now();E-y.lastUpdate>=Ec&&(y.lastUpdate=E,o(t,w(y,m.clientX)))},[t,o,w]),g=s.useCallback((m,y)=>{const E=p.current;!E||m.pointerId!==E.pointerId||(p.current=null,f(!1),(E.moved||m.clientX!==E.startX)&&(Nc(),y&&o(t,w(E,m.clientX))))},[t,o,w]),u=s.useCallback(m=>{if(m.key==="Enter"&&r){m.preventDefault(),m.stopPropagation(),r(t);return}if(m.key!=="ArrowLeft"&&m.key!=="ArrowRight")return;m.preventDefault(),m.stopPropagation();const y=(m.shiftKey?50:10)*(m.key==="ArrowRight"?1:-1);o(t,zo(n+y,n,i,l))},[t,n,o,r,i,l]),h=s.useCallback(m=>{m.preventDefault(),m.stopPropagation(),r?.(t)},[t,r]),x=["ogx-column-resize-handle",d==="start"&&"ogx-column-resize-handle--start",a&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return c.jsx("div",{className:x,onPointerDown:b,onMouseDown:Mc,onPointerMove:C,onPointerUp:m=>g(m,!0),onPointerCancel:m=>g(m,!1),onClick:m=>m.stopPropagation(),onDragStart:m=>{m.preventDefault(),m.stopPropagation()},onDoubleClick:h,onKeyDown:u,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(n),"aria-valuemin":Math.round(Math.min(i??50,n)),"aria-valuemax":l,tabIndex:-1,children:c.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Gi(e){if(!e)return 0;let t=0;const n=(o,r)=>{t=Math.max(t,r);for(const i of o.children)typeof i!="string"&&n(i,r+1)};return e.forEach(o=>n(o,1)),t}function Wi(e){const t=new Map;if(!e)return t;const n=(o,r)=>{const i=[...r,o];for(const l of o.children)typeof l=="string"?t.has(l)||t.set(l,i):n(l,i)};return e.forEach(o=>n(o,[])),t}function Vo(e,t,n){if(!e||e.length===0)return!0;const o=Wi(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function Pc(e,t,n){const o=[];let r=0,i=null,l=null;for(const d of e){const a=d.isSpacer?null:t.get(d.field)?.[n]??null;(i===null||l!==a||i.pinned!==d.pinned)&&(i={key:`${a?a.groupId:"filler"}-${n}-${d.field}`,isGroup:a!==null,label:a?.headerName??"",headerClassName:a?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:d.pinned},l=a,o.push(i)),i.width+=d.width,i.flexGrow+=d.flex??0,d.isSpacer||(i.fields.push(d.field),r++)}return o}function Wt(){return document.documentElement.clientWidth||window.innerWidth}function Lc(){return document.documentElement.clientHeight||window.innerHeight}function Bt(){return c.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:c.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Ht(){return c.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:c.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Tc(){return c.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[c.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),c.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),c.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fc(){return c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),c.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ac(){return c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),c.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Dc(){return c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:c.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Oc(){return c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.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"}),c.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"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function $c(){return c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),c.jsx("polyline",{points:"11 8 4 12 11 16"}),c.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Gc(){return c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),c.jsx("polyline",{points:"13 8 20 12 13 16"}),c.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Wc(){return c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),c.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),c.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Bi=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Bc({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:d,anchorEl:a}){const f=s.useRef(null),p=s.useCallback(F=>{F&&(a?.closest('[role="columnheader"]')??a)?.focus({preventScroll:!0}),d()},[a,d]),w=F=>{const $=Bi(f.current),_=$.indexOf(F.target);let T=-1;if(F.key==="ArrowDown")T=_+1>=$.length?0:_+1;else if(F.key==="ArrowUp")T=_<=0?$.length-1:_-1;else if(F.key==="Home")T=0;else if(F.key==="End")T=$.length-1;else if(F.key==="Tab"){F.preventDefault(),p(!0);return}else return;F.preventDefault(),$[T]?.focus()},[b,C]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!a||!f.current)return;const F=a.getBoundingClientRect(),$=f.current.getBoundingClientRect(),_=Wt(),T=Lc(),O=8;let S=F.left;S+$.width+O>_&&(S=_-$.width-O),S<O&&(S=O);let j=F.bottom+4;j+$.height+O>T&&(j=F.top-$.height-4),C({position:"fixed",zIndex:1300,top:j,left:S,visibility:"visible"})},[a]);const g=b.visibility==="visible";s.useLayoutEffect(()=>{g&&Bi(f.current)[0]?.focus({preventScroll:!0})},[g]),s.useEffect(()=>{function F(_){f.current&&!f.current.contains(_.target)&&a&&!a.contains(_.target)&&d()}function $(_){_.key==="Escape"&&p(!0)}return document.addEventListener("mousedown",F),document.addEventListener("keydown",$),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",$),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[a,d,p]);const u=F=>{n?.(e.field,F),p(!0)},h=!!o&&e.hideable!==!1,x=!!r&&e.pinnable!==!1,m=()=>{h&&o?.(e.field),p(!0)},y=F=>{x&&r?.(e.field,F),p(!0)},E=t?.find(F=>F.field===e.field)?.sort,v=E==null,M=i?.left?.includes(e.field)??!1,N=i?.right?.includes(e.field)??!1,P=!M&&!N,z=e.headerName||e.field;return xt.createPortal(c.jsxs("div",{ref:f,className:"ogx-column-menu",style:b,role:"menu","aria-label":`Column options for ${z}`,onKeyDown:w,children:[n&&e.sortable!==!1&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:`ogx-menu-item${E==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("asc"),role:"menuitemradio","aria-checked":E==="asc",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="asc"?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Fc,{})}),"Sort Ascending"]}),c.jsxs("button",{type:"button",className:`ogx-menu-item${E==="desc"?" ogx-menu-item--active":""}`,onClick:()=>u("desc"),role:"menuitemradio","aria-checked":E==="desc",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="desc"?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Ac,{})}),"Sort Descending"]}),c.jsxs("button",{type:"button",className:`ogx-menu-item${v?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":v,children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Dc,{})}),"Unsort"]}),c.jsx("div",{className:"ogx-menu-divider"})]}),x&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),c.jsxs("button",{type:"button",className:`ogx-menu-item${M?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":M,"aria-label":"Pin to left",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx($c,{})}),"Pin to Left"]}),c.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>y("right"),role:"menuitemradio","aria-checked":N,"aria-label":"Pin to right",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Gc,{})}),"Pin to Right"]}),c.jsxs("button",{type:"button",className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>y(null),role:"menuitemradio","aria-checked":P,"aria-label":"Unpin column",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?c.jsx(Bt,{}):c.jsx(Ht,{})}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Wc,{})}),"Unpin"]}),c.jsx("div",{className:"ogx-menu-divider"})]}),h&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:m,role:"menuitem","aria-label":`Hide ${z} column`,children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Oc,{})}),"Hide Column"]}),c.jsx("div",{className:"ogx-menu-divider"})]}),c.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),p(!1)},role:"menuitem","aria-label":"Manage all columns",children:[c.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),c.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:c.jsx(Tc,{})}),"Manage columns"]})]}),a?.closest(".ogx-theme-provider")||document.body)}const Hc=16,zc=16;function Vc(e,t=!1){const n=Number.isFinite(e)?e-zc:0,o=Math.floor(n/Hc)-(t?1:0);return Math.max(1,o)}function Kc(e,t){return e??t??!1}function Uc(){return c.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:c.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 jc(){return c.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:c.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Hi(e){const{columns:t,allColumns:n,columnGroupingModel:o,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:d,onSort:a,sortModel:f=[],onColumnResize:p,onColumnAutosize:w,columnWidths:b={},pinnedColumns:C,hasDetailPanel:g=!1,pinCheckboxColumn:u=!0,pinExpandColumn:h=!0,rowReordering:x=!1,aggregationModel:m,draggedColumn:y,dragOverColumn:E,onDragStart:v,onDragOver:M,onDragEnd:N,onDrop:P,focusedCell:z,onHeaderClick:F,onSortAdd:$,multiSort:_=!1,onHideColumn:T,onPinColumn:O,onManageColumns:S,columnIndexMap:j,wrapHeaderText:q=!1,headerHeight:Z=56}=e,W=s.useId(),[U,Q]=s.useState(null),ie=k=>H=>{H.stopPropagation(),Q({colDef:k,anchorEl:H.currentTarget})},oe=s.useCallback(()=>{Q(null)},[]),ge=k=>H=>{if(H.altKey&&(H.key==="ArrowLeft"||H.key==="ArrowRight")&&H.target===H.currentTarget){if(k.resizable===!1||!p)return;H.preventDefault(),H.stopPropagation();const pe=bt(k,b),me=(H.shiftKey?50:10)*(H.key==="ArrowRight"?1:-1);p(k.field,zo(pe+me,pe,k.minWidth,k.maxWidth));return}if(!(H.altKey&&H.key==="ArrowDown"||(H.ctrlKey||H.metaKey)&&H.key==="Enter")||k.disableColumnMenu||H.target!==H.currentTarget)return;H.preventDefault(),H.stopPropagation();const ce=H.currentTarget.querySelector(".ogx__menu-icon-btn")??H.currentTarget;Q({colDef:k,anchorEl:ce})},le=k=>z?.id===null&&z.field===k,ue=x?1:0,te=g?ue+1:ue,ae=r?te+1:te,Y=k=>H=>{if(k.sortable===!1)return;const X=f.find(ce=>ce.field===k.field);let ee="asc";X&&(X.sort==="asc"?ee="desc":ee=null),(H.shiftKey||_)&&$?$(k.field,ee):a&&a(k.field,ee)},re=(k,H)=>{const X=f.some(ce=>ce.field===k);$&&(H===null||X||_||!a)?$(k,H):a?.(k,H)},K=k=>{const H=f.find(ee=>ee.field===k);if(!H)return null;const X=f.length>1?f.indexOf(H)+1:null;return c.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${H.sort}`,"aria-hidden":"true",children:X!==null&&c.jsx("span",{className:"ogx__sort-badge",children:X})})},J=s.useMemo(()=>fo(t,b,C,r,u,g,h,x),[t,b,C,r,u,g,h,x]),ne=s.useMemo(()=>go(t,C),[t,C]),de=Gi(o),G=s.useMemo(()=>Wi(o),[o]),I=s.useMemo(()=>de===0?[]:(n??t).map(k=>({field:k.field,width:bt(k,b),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:lt(k.field,C),isSpacer:k.isSpacer})),[de,n,t,b,C]),V=(x?48:0)+(g?48:0)+(r?48:0),R=(x||g||r)&&(!g||h)&&(!r||u),B=(x?1:0)+(g?1:0)+(r?1:0);return c.jsxs("div",{className:"ogx__header-wrap",children:[de>0&&Array.from({length:de},(k,H)=>{const X=Pc(I,G,H);return c.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":H+1,children:[V>0&&c.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${R?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:V,minWidth:V,flexShrink:0,position:R?"sticky":void 0,left:R?0:void 0},"aria-hidden":"true"}),X.map((ee,ce)=>{const pe=ee.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ee.pinned}`:"",me={width:ee.width,minWidth:ee.width,flexShrink:0,flexGrow:ee.flexGrow};return ee.pinned==="left"?(me.position="sticky",me.left=J[ee.fields[0]]):ee.pinned==="right"&&(me.position="sticky",me.right=J[ee.fields[ee.fields.length-1]],X[ce-1]?.pinned!=="right"&&(me.marginLeft="auto")),ee.isGroup?c.jsx("div",{role:"columnheader","aria-colspan":ee.fields.length,"aria-colindex":B+ee.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${pe}${ee.headerClassName?` ${ee.headerClassName}`:""}`,style:me,title:ee.label,children:c.jsx("span",{className:"ogx-col-group-cell__label",children:ee.label})},ee.key):c.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${pe}`,style:me,"aria-hidden":"true"},ee.key)})]},`ogx-grp-${H}`)}),c.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":de+1,children:[x&&c.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${le("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":ue,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),g&&c.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${le("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":te,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,left:h?x?48:0:void 0}}),r&&c.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${u?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${le("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:u?"sticky":void 0,left:u?(x?48:0)+(g&&h?48:0):void 0},children:d&&c.jsx(ct,{id:W,name:W,checked:i,indeterminate:l,onChange:k=>d(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,H)=>{if(k.isSpacer)return c.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const X=k.sortable!==!1,ee=f.findIndex(Ge=>Ge.field===k.field),ce=ee!==-1,pe=ce?f[ee].sort:null,me=j?.get(k.field)??H,ye=X?ee===0?pe==="asc"?"ascending":"descending":"none":void 0,_e=ce&&f.length>1?`Sorted ${pe==="asc"?"ascending":"descending"}, sort priority ${ee+1} of ${f.length}`:void 0,Ce=k.resizable!==!1,Ee=lt(k.field,C),se=Ee!==null,be=y===k.field,Me=E===k.field,ve=Kc(k.wrapHeaderText,q),he=m?.[k.field],fe=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,X&&"ogx__header-cell--sortable",ce&&"ogx__header-cell--sorted",se&&"ogx__header-cell--pinned",se&&`ogx__header-cell--pinned-${Ee}`,Ee==="left"&&k.field===ne.lastLeft&&"ogx__header-cell--pinned-left-last",Ee==="right"&&k.field===ne.firstRight&&"ogx__header-cell--pinned-right-first",be&&"ogx__header-cell--dragging",Me&&"ogx__header-cell--drag-over",ve&&"ogx__header-cell--wrap",le(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),Se={width:b[k.field]??k.width??100,minWidth:k.minWidth,maxWidth:k.maxWidth,flexGrow:k.flex??0,flexShrink:0,flexBasis:(k.flex,"auto"),boxSizing:"border-box",position:se?"sticky":"relative",zIndex:k.zIndex,opacity:be?.5:1};if(se&&Ee){const Ge=J[k.field];Ee==="left"?Se.left=Ge:Se.right=Ge}const Ne=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:me}):k.headerName||k.field,tt=Ge=>{if(Ge.target.closest(".ogx-column-resize-handle")){Ge.stopPropagation();return}F?.(k.field),X&&Y(k)(Ge)},$e=v&&!se?v(k.field):void 0,Ve=M&&!se?M(k.field):void 0,Yt=P&&!se?P(k.field):void 0;return c.jsxs("div",{className:fe,style:Se,title:k.description??(ve&&typeof Ne=="string"?Ne:void 0),onClick:tt,role:"columnheader",draggable:!!$e,onDragStart:$e,onDragOver:Ve,onDragEnd:N,onDrop:Yt,onKeyDown:ge(k),"aria-sort":ye,"aria-description":_e,"aria-colindex":B+me+1,"data-field":k.field,tabIndex:-1,children:[c.jsxs("div",{className:"ogx__header-cell-content",children:[be&&c.jsx("div",{className:"ogx__header-drag-icon",children:c.jsx(jc,{})}),c.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[c.jsx("span",{className:"ogx__header-cell-title",style:ve?{WebkitLineClamp:Vc(Z,!!he)}:void 0,children:Ne}),he&&c.jsx("span",{className:"ogx__header-cell-aggregation",children:he})]}),X&&K(k.field),!k.disableColumnMenu&&c.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:ie(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:c.jsx(Uc,{})})]}),Ce&&p&&c.jsx(Ic,{field:k.field,currentWidth:bt(k,b),onResize:p,onAutosize:w,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:Ee==="right"?"start":"end"})]},k.field)}),U&&c.jsx(Bc,{colDef:U.colDef,sortModel:f,onSort:a||$?re:void 0,onHide:T,onPin:O,pinnedColumns:C,onManageColumns:S,onClose:oe,anchorEl:U.anchorEl})]})]})}const Oe=()=>{},Ko=()=>Promise.resolve({updated:[],failed:[],skipped:[]});function zi(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:Oe,selectRows:Oe,getSelectedRows:()=>[],sortColumn:Oe,getSortModel:()=>[],setFilterModel:Oe,getFilterModel:()=>({items:[]}),setPage:Oe,setPageSize:Oe,scrollToIndexes:Oe,autosizeColumn:Oe,autosizeColumns:Oe,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:Oe,selectCellRange:Oe,clearCellSelection:Oe,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve(),pasteText:Ko,undo:Ko,redo:Ko,canUndo:()=>!1,canRedo:()=>!1,clearHistory:Oe}}const Rc=e=>e.id;let Vi=!1;function Ki(e,t,n){const o=new Map,r=new Map,i=[],l=[];return e.forEach(d=>{const a=n?.get(d)??t(d);if(o.has(a)){l.push(a);return}o.set(a,d),r.set(d,a),i.push(a)}),l.length>0&&!Vi&&process.env.NODE_ENV!=="production"&&(Vi=!0,console.warn(`[OpenGridX] ${l.length} row(s) reuse the id of an earlier row and were ignored (ids: ${l.slice(0,5).map(String).join(", ")}${l.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:i,idByRow:r}}function qc(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Ki(e,t),columns:{all:n,lookup:r,orderedFields:i,columnVisibilityModel:o},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Xc(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:Ki(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const n=e.rows.idRowsLookup.get(t.id);if(n===void 0)return e;const o=new Map(e.rows.idRowsLookup);o.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(n),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}}case"REPLACE_ROWS":{let n=!1;const o=new Map(e.rows.idRowsLookup),r=new Map(e.rows.idByRow);for(const[i,l]of t.rows){const d=o.get(i);d!==void 0&&(n=!0,o.set(i,l),r.delete(d),r.set(l,i))}return n?{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}:e}case"SET_COLUMNS":{const n=new Map,o=[];return t.payload.forEach(r=>{n.set(r.field,r),o.push(r.field)}),{...e,columns:{all:t.payload,lookup:n,orderedFields:o,columnVisibilityModel:e.columns.columnVisibilityModel}}}case"SET_DIMENSIONS":return{...e,dimensions:{...e.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...e,dataSource:{...e.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...e,dataSource:{...e.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...e,pagination:{...e.pagination,rowCount:t.payload}};default:return e}}function Yc(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:d=!1}=e,a=e.getRowId??Rc,f=s.useRef(a);s.useLayoutEffect(()=>{f.current=a});const[p]=s.useState(()=>qc(t,a,n,i)),[w,b]=s.useReducer(Xc,{...p,dataSource:l?.dataSource?{...p.dataSource,...l.dataSource}:p.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...p.dimensions,rowHeight:o,headerHeight:r}}),[C,g]=s.useState({rows:t,syncRows:d});(C.rows!==t||C.syncRows!==d)&&(g({rows:t,syncRows:d}),d&&b({type:"SET_ROWS",payload:t,getRowId:a}));const u=s.useRef(w);s.useLayoutEffect(()=>{u.current=w});const h=s.useCallback((F,$)=>{b({type:"SET_ROWS",payload:F,getRowId:f.current})},[]),x=s.useCallback((F,$)=>{b({type:"REPLACE_ROW",id:F,row:$})},[]),m=s.useCallback(F=>{F.size>0&&b({type:"REPLACE_ROWS",rows:F})},[]),y=s.useCallback(F=>{b({type:"SET_COLUMNS",payload:F})},[]),E=s.useCallback((F,$)=>{b({type:"SET_DIMENSIONS",payload:{viewportWidth:F,viewportHeight:$}})},[]),v=s.useCallback(F=>{b({type:"SET_DATASOURCE_LOADING",payload:F})},[]),M=s.useCallback(F=>{b({type:"SET_DATASOURCE_ERROR",payload:F})},[]),N=s.useCallback(F=>{b({type:"SET_ROW_COUNT",payload:F})},[]),[P]=s.useState(()=>({...zi(),getRow:F=>u.current.rows.idRowsLookup.get(F)||null,getAllRows:()=>u.current.rows.allRows.map(F=>u.current.rows.idRowsLookup.get(F)),getColumn:F=>u.current.columns.lookup.get(F)||null,getAllColumns:()=>u.current.columns.all})),z=s.useRef(P);return{state:w,dispatch:b,apiRef:z,setRows:h,replaceRow:x,replaceRows:m,setColumns:y,setDimensions:E,setDataSourceLoading:v,setDataSourceError:M,setRowCount:N}}function Jc(e){const{onRowOrderChange:t,rows:n,getRowId:o,rowReordering:r=!1}=e,[i,l]=s.useState(null),[d,a]=s.useState(null),f=s.useRef(()=>{}),p=s.useMemo(()=>{const h=new Map;return n.forEach((x,m)=>h.set(o?o(x):x.id,m)),h},[n,o]),w=s.useCallback(h=>p.has(h),[p]),b=s.useCallback(()=>{f.current(),f.current=()=>{},l(null),a(null)},[]);s.useEffect(()=>()=>f.current(),[]);const C=s.useCallback(h=>x=>{if(r){if(!p.has(h)){x.preventDefault();return}f.current(),f.current=vi(x.currentTarget,b),l(h),x.dataTransfer&&(x.dataTransfer.effectAllowed="move",yi(x,Go,String(h)))}},[r,p,b]),g=s.useCallback(h=>x=>{if(!(!r||i===null)){if(!Bn(x,Go)){b();return}p.has(h)&&(x.preventDefault(),x.dataTransfer&&(x.dataTransfer.dropEffect="move"),d!==h&&a(h))}},[r,i,d,p,b]),u=s.useCallback(h=>x=>{if(x.preventDefault(),i===null||!Bn(x,Go)){b();return}const m=p.get(i),y=p.get(h);b(),t&&m!==void 0&&y!==void 0&&m!==y&&t({row:n[m],oldIndex:m,targetIndex:y})},[i,t,n,p,b]);return{draggedRowId:i,dragOverRowId:d,canReorderRow:w,onDragStart:r?C:void 0,onDragOver:r?g:void 0,onDragEnd:r?b:void 0,onDrop:r?u:void 0}}const Ui=new Map,ji=e=>JSON.stringify(e),Zc=e=>`auto-group-${e}`,Ri=5,qi=e=>e.slice(0,Ri).map(t=>JSON.stringify(t)).join(", ")+(e.length>Ri?", …":""),Qc={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function ed(e,t,n){const o=new Map,r=[],i=[],l=new Set,d=new Map,a=new Map,f=[],p=new Array(e.length),w=new Array(e.length),b=[],C=new Map;e.forEach((u,h)=>{const x=t(u),m=n(u),y=Array.isArray(m)?m.map(E=>String(E)):[];if(p[h]=x,w[h]=y,d.set(x,u),y.length===0)b.push(x);else{const E=ji(y),v=a.get(E);if(v===void 0)a.set(E,x);else{const M=C.get(E)??[v];M.push(x),C.set(E,M)}}o.set(x,{id:x,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:u.serverChildrenCount})});const g=u=>{const h=ji(u),x=a.get(h);if(x!==void 0)return x;const m=Zc(h),y=u[u.length-1],E={id:m,parentId:null,depth:u.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};o.set(m,E),a.set(h,m),l.add(m);const v={id:m};if(i.push(v),d.set(m,v),u.length===1)r.push(m);else{const M=g(u.slice(0,-1));E.parentId=M,o.get(M)?.children?.push(m)}return m};return e.forEach((u,h)=>{const x=p[h],m=w[h];if(m.length<=1){r.push(x);return}const y=g(m.slice(0,-1)),E=o.get(x);E&&(E.parentId=y),o.get(y)?.children?.push(x)}),b.length>0&&f.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${qi(b)}. They are shown as top-level rows.`),C.forEach((u,h)=>{f.push(`[OpenGridX] treeData: rows ${qi(u)} have the same path ${h}. Rows under that path are attached to row ${JSON.stringify(u[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:d,issues:f}}function td(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,d=new Map,a=new Map,f=p=>{const w=n.get(p);if(!w)return!1;const b=[];let C=0;for(const x of w.children??[])f(x)&&(b.push(x),C+=(r.has(x)?0:1)+(a.get(x)??0));d.set(p,b),a.set(p,C);const g=i.get(p),h=!r.has(p)&&g!==void 0&&(t?t(g):!0)||b.length>0;return h&&l.add(p),h};return o.forEach(f),{visible:l,visibleChildren:d,descendantCounts:a}}function nd(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:d,onRowExpansionChange:a,columnLookup:f,filterMode:p="client",sortingMode:w="client"}=e,b=r&&!!o,C=s.useMemo(()=>!r||!o?Qc:ed(t,n,o),[t,o,r,n]),{treeNodes:g,rootIds:u,groupingRows:h,syntheticIds:x,rowLookup:m}=C,y=C.issues.join(`
|
|
2
|
+
`);s.useEffect(()=>{process.env.NODE_ENV==="production"||!y||y.split(`
|
|
3
|
+
`).forEach(U=>console.warn(U))},[y]);const E=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!E||console.warn("[OpenGridX] treeData is set without getTreeDataPath, so the rows are shown as a flat list. Pass getTreeDataPath={(row) => row.path} to build the tree.")},[E]);const v=s.useMemo(()=>p==="server"?null:Dn(l,f),[p,l,f]),M=s.useMemo(()=>td(C,v),[C,v]),N=`${r}|${i}`,[P,z]=s.useState(()=>({configKey:N,overrides:new Map})),F=P.configKey===N?P.overrides:Ui,$=s.useCallback(U=>((U?.children?.length??0)>0||(U?.serverChildrenCount??0)>0)&&(i===-1||(U?.depth??0)<i),[i]),_=s.useMemo(()=>{const U=new Set;return b&&g.forEach((Q,ie)=>{(F.get(ie)??$(Q))&&U.add(ie)}),U},[b,g,F,$]),T=s.useCallback(U=>{const Q=!_.has(U);if(z(ie=>{const oe=ie.configKey===N?ie.overrides:Ui,ge=new Map(oe);return ge.set(U,Q),{configKey:N,overrides:ge}}),Q&&a){const ie=g.get(U);ie&&a(ie)}},[_,N,g,a]),O=w!=="server"&&!!(d&&d.length>0),S=s.useCallback(U=>{if(!b)return null;const Q=U?.labelField,ie=U?.expandAll??!1,{visible:oe,visibleChildren:ge}=M,le=O&&d?d:[],ue=(re,K)=>{if(x.has(re))return{value:K.field===Q?g.get(re)?.label:void 0};const J=m.get(re),ne=f?.byField.get(K.field),de=J?ke(J,K.field,ne):void 0,G=ne?.sortComparator;return{value:de,type:ne?.type,comparator:G,params:G&&J?{id:re,field:K.field,row:J,value:de}:void 0}},te=[],ae=new Set,Y=re=>{const K=re.filter(ne=>oe.has(ne)),J=le.length>0?Io(K,le,ue):K;for(const ne of J){if(ae.has(ne))continue;const de=m.get(ne);if(!de)continue;ae.add(ne),te.push(de);const G=ge.get(ne);G&&G.length>0&&(ie||_.has(ne))&&Y(G)}};return Y(u),te},[b,M,O,d,x,g,m,f,u,_]),j=s.useCallback(U=>_.has(U),[_]),q=s.useCallback(U=>g.get(U),[g]),Z=s.useCallback(U=>{const Q=[];let ie=U;for(;ie!==null;){const oe=g.get(ie);if(!oe)break;Q.unshift(oe.groupingKey),ie=oe.parentId}return Q},[g]),W=s.useMemo(()=>{const U=new Map,{visibleChildren:Q,descendantCounts:ie}=M;return g.forEach((oe,ge)=>{const le=(oe.children?.length??0)===0&&(oe.serverChildrenCount??0)>0,ue=x.has(ge),te={hasChildren:(Q.get(ge)?.length??0)>0||le,treeDepth:oe.depth,descendantCount:le?void 0:ie.get(ge)??0,isGroupRow:ue,isExpanded:_.has(ge)};ue&&(te.groupLabel=oe.label),U.set(ge,te)}),U},[g,x,M,_]);return s.useMemo(()=>({treeNodes:g,groupingRows:h,toggleExpansion:T,isGroupExpanded:j,getVisibleRows:S,getNode:q,getNodePath:Z,rowMetaMap:W}),[g,h,T,j,S,q,Z,W])}const Xi=e=>e===null?"footer":"inline";function Yi(e,t){return Pn(()=>e(t),Xi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function od(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?Pn(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const rd=[],id={},Ji=new Map,Re="";function ld(e){if(typeof e=="string")return e;if(e===null)return`${Re}null`;if(e===void 0)return`${Re}undefined`;if(e instanceof Date)return`${Re}date:${e.getTime()}`;if(typeof e=="object")try{return`${Re}object:${JSON.stringify(e)}`}catch{return`${Re}object:${String(e)}`}return`${Re}${typeof e}:${String(e)}`}const sd=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,ad=e=>`${e}${Re}footer`,cd=e=>e==="footer"?"f":e===null?"n":"i",dd=e=>e==="f"?"footer":e==="n"?null:"inline";function ud(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=rd,aggregationModel:i=id,defaultGroupingExpansionDepth:l=0,filterModel:d,sortModel:a,getAggregationPosition:f=Xi,columnLookup:p,filterMode:w="client",sortingMode:b="client"}=e,C=r.join(Re),g=s.useMemo(()=>C===""?[]:C.split(Re),[C]),u=JSON.stringify(Object.entries(i)),h=s.useMemo(()=>Object.fromEntries(JSON.parse(u)),[u]),x=Object.keys(h).length>0,m=s.useMemo(()=>{const Y=new Map;return(o??[]).forEach(re=>Y.set(re.field,re)),Y},[o]),y=g.length>0,E=s.useMemo(()=>g.filter(Y=>m.get(Y)?.groupable!==!1),[g,m]),M=`${E.join(Re)}|${l}`,[N,P]=s.useState(()=>({configKey:M,overrides:new Map})),z=N.configKey===M?N.overrides:Ji,F=s.useMemo(()=>{if(!y||w==="server")return null;const Y=Dn(d,p);return Y?new Set(t.filter(re=>Y(re))):null},[y,t,w,d,p]),$=s.useMemo(()=>{const Y=new Map,re=[],K=[],J=new Map,ne=new Map,de=new Map;if(!y)return{treeNodes:Y,rootIds:re,groupIds:K,groupRowVariants:J,groupingRows:ne,rowLookup:de};const G=(I,D,L)=>{if(D>=E.length)return(F?I.filter(H=>F.has(H)):I).map(H=>{const X=n(H);return de.set(X,H),Y.set(X,{id:X,parentId:L,depth:D,groupingKey:"",isExpanded:!1}),X});const A=E[D],V=m.get(A),R=new Map;for(const k of I){const H=ke(k,A,V),X=ld(H);let ee=R.get(X);ee||(ee={value:H,rows:[]},R.set(X,ee)),ee.rows.push(k)}const B=[];return R.forEach((k,H)=>{const X=F?k.rows.filter(Ce=>F.has(Ce)):k.rows;if(X.length===0)return;const ee=sd(A,H,L);B.push(ee),K.push(ee);const ce=x?Fn(X,h,m,"useRowGrouping"):{},pe={[A]:k.value,...ce,id:ee},me={[A]:k.value,id:ee},ye=x?{...ce,id:ad(ee)}:null;J.set(ee,{inline:pe,bare:me,footer:ye}),ne.set(ee,pe),ye&&ne.set(ye.id,ye);const _e={id:ee,parentId:L,depth:D,groupingKey:String(k.value),groupingField:A,groupingValue:k.value,aggregatedValues:ce,isExpanded:!1,children:[],label:od(V,A,k.value),descendantCount:X.length};Y.set(ee,_e),_e.children=G(k.rows,D+1,ee)}),B};return re.push(...G(t,0,null)),{treeNodes:Y,rootIds:re,groupIds:K,groupRowVariants:J,groupingRows:ne,rowLookup:de}},[y,t,F,E,x,h,n,m]),{treeNodes:_,rootIds:T,groupIds:O,groupRowVariants:S,groupingRows:j,rowLookup:q}=$,Z=s.useCallback(Y=>!!(Y?.children&&Y.children.length>0)&&(l===-1||(Y?.depth??0)<l),[l]),W=s.useMemo(()=>{const Y=new Set;return _.forEach((re,K)=>{!re.children||re.children.length===0||(z.get(K)??Z(re))&&Y.add(K)}),Y},[_,z,Z]),U=s.useCallback(Y=>{P(re=>{const K=re.configKey===M?re.overrides:Ji,J=K.get(Y)??Z(_.get(Y)),ne=new Map(K);return ne.set(Y,!J),{configKey:M,overrides:ne}})},[M,_,Z]),Q=s.useCallback(Y=>W.has(Y),[W]),ie=x?O.map(Y=>{const re=_.get(Y);return re?cd(Yi(f,{...re,isExpanded:W.has(Y)})):"i"}).join(""):"",oe=s.useMemo(()=>{const Y=new Map;return O.forEach((re,K)=>Y.set(re,dd(ie[K]))),Y},[O,ie]),ge=x?Yi(f,null):"footer",le=b!=="server"&&!!(a&&a.length>0),ue=s.useCallback(Y=>{if(!y)return null;const re=Y?.labelField,K=Y?.expandAll??!1,J=le&&a?a:[],ne=(D,L)=>{const A=_.get(D),V=S.get(D);if(A&&V){const X=A.groupingField??"";if(L.field===X||L.field===re){const ee=p?.byField.get(X),ce=ee?.sortComparator;return{value:A.groupingValue,type:ee?.type,comparator:ce,params:ce?{id:D,field:X,row:V.inline,value:A.groupingValue}:void 0}}return A.aggregatedValues&&Object.prototype.hasOwnProperty.call(A.aggregatedValues,L.field)?{value:A.aggregatedValues[L.field],type:p?.byField.get(L.field)?.type}:{value:void 0}}const R=q.get(D),B=p?.byField.get(L.field),k=R?ke(R,L.field,B):void 0,H=B?.sortComparator;return{value:k,type:B?.type,comparator:H,params:H&&R?{id:D,field:L.field,row:R,value:k}:void 0}},de=[],G=new Set,I=D=>{const L=J.length>0?Io(D,J,ne):D;for(const A of L){if(G.has(A))continue;G.add(A);const V=S.get(A);if(!V){const X=q.get(A);X&&de.push(X);continue}const R=_.get(A),B=W.has(A),k=oe.has(A)?oe.get(A)??null:"inline",H=k==="inline"||k==="footer"&&!B;de.push(H?V.inline:V.bare),(B||K)&&R?.children&&(I(R.children),B&&!K&&k==="footer"&&V.footer&&de.push(V.footer))}};return I(T),de},[y,le,a,_,S,q,p,W,oe,T]),te=s.useCallback(Y=>_.get(Y),[_]),ae=s.useMemo(()=>{const Y=new Map;return _.forEach((re,K)=>{const J=S.get(K);if(!J){Y.set(K,{hasChildren:!1,treeDepth:re.depth,isGroupRow:!1});return}const ne={hasChildren:!0,treeDepth:re.depth,groupingField:re.groupingField,groupingValue:re.groupingValue,groupLabel:re.label,descendantCount:re.descendantCount,isGroupRow:!0,isExpanded:W.has(K)};Y.set(K,ne),J.footer&&oe.get(K)==="footer"&&Y.set(J.footer.id,{...ne,hasChildren:!1,treeDepth:re.depth+1,isExpanded:void 0,isGroupFooter:!0})}),Y},[_,S,W,oe]);return s.useMemo(()=>({treeNodes:_,groupingRows:j,toggleExpansion:U,isGroupExpanded:Q,getVisibleRows:ue,getNode:te,rowMetaMap:ae,aggregationPositions:oe,rootAggregationPosition:ge}),[_,j,U,Q,ue,te,ae,oe,ge])}const fd=new Map;function gd(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:d,isRowGrouping:a,aggregationModel:f,defaultGroupingExpansionDepth:p,filterModel:w,sortModel:b,getAggregationPosition:C,columnLookup:g,filterMode:u,sortingMode:h}=e,x=nd({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:p,filterModel:w,sortModel:b,columnLookup:g,filterMode:u,sortingMode:h}),m=ud({rows:t,getRowId:n,columns:l,rowGroupingModel:d,aggregationModel:f,defaultGroupingExpansionDepth:p,filterModel:w,sortModel:b,getAggregationPosition:C,columnLookup:g,filterMode:u,sortingMode:h}),y=i?x:a?m:null,E=s.useMemo(()=>i?x.rowMetaMap:a?m.rowMetaMap:fd,[i,x.rowMetaMap,a,m.rowMetaMap]);return{treeDataHandlers:x,rowGroupingHandlers:m,activeHierarchyHandlers:y,rowMetaMap:E}}function pn(e){try{return{ok:!0,value:e()}}catch(t){return{ok:!1,error:t}}}class Zi extends Error{}function dt(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Qi(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function el(e,t){t?t(e):process.env.NODE_ENV!=="production"&&e instanceof Zi&&console.error(e.message)}function tl(e,t){return new Zi(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${e===null?"null":typeof e}. ${t}`)}function nl(e,t,n,o){return n?.valueSetter?n.valueSetter({value:t.value,row:e,field:t.field}):(n?.valueGetter&&process.env.NODE_ENV!=="production"&&!o.has(t.field)&&(o.add(t.field),console.warn(`[OpenGridX] Column "${t.field}" is editable and has a valueGetter but no valueSetter. The edited value was written to row["${t.field}"], which the valueGetter may ignore, so the cell can keep showing the old value. Add a valueSetter that maps the value back onto the row.`)),{...e,[t.field]:t.value})}const zt=Promise.resolve();function pd(e){const[t,n]=s.useState(null),o=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),d=s.useRef(!1),a=s.useRef(e);s.useLayoutEffect(()=>{a.current=e}),s.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const f=s.useCallback(u=>{o.current=u,n(u)},[]),p=s.useRef(null),w=s.useCallback((u,h)=>{const x=i.current.get(u);if(x)return dt(x.value,h.value)?x.promise:x.promise.then(()=>{const W=o.current;if(!(r.current!==u||!W||dt(W.value,x.value)))return p.current?.(u,W)});const m=()=>r.current===u&&o.current!==null;if(dt(h.value,h.originalValue))return m()&&f(null),zt;const{rows:y,getRowId:E,columns:v,processRowUpdate:M}=a.current,N=y.find(W=>E(W)===h.id);if(!N)return m()&&f(null),zt;const P=W=>el(W,a.current.onProcessRowUpdateError),z=v?.find(W=>W.field===h.field),F=W=>{if(typeof W!="object"||W===null){P(tl(W,"The edit was not saved and the editor stays open."));return}a.current.onRowChange?.(W,h.id);const{onCommitted:U}=a.current;if(U){const ie=ke(N,h.field,z),oe=ke(W,h.field,z);dt(ie,oe)||U([{id:h.id,field:h.field,before:ie,after:oe}])}const Q=o.current;r.current!==u||!Q||(dt(Q.value,h.value)?f(null):f({...Q,originalValue:h.value}))};let $,_;const T=new Promise((W,U)=>{$=W,_=U}),O={value:h.value,promise:T};i.current.set(u,O);const S=()=>{i.current.get(u)===O&&i.current.delete(u)},j=pn(()=>{const W=nl(N,h,z,l.current);return M?M(W,N):W});if(!j.ok)return S(),P(j.error),$(),T;const q=j.value,Z=W=>{S();try{F(W),$()}catch(U){_(U)}};return Qi(q)?Promise.resolve(q).then(Z,W=>{S(),P(W),$()}):Z(q),T},[f]);s.useLayoutEffect(()=>{p.current=w},[w]);const b=s.useCallback(u=>{const h=o.current;if(h){if(h.id===u.id&&h.field===u.field)return;w(r.current,h)}r.current+=1,f({id:u.id,field:u.field,value:u.value,originalValue:u.value})},[w,f]),C=s.useCallback(u=>{const h=o.current;return!h||!d.current||u?.id!==void 0&&u.id!==h.id||u?.field!==void 0&&u.field!==h.field?zt:u?.cancel?(f(null),zt):w(r.current,h)},[w,f]),g=s.useCallback(u=>{const h=o.current;!h||h.id!==u.id||h.field!==u.field||f({...h,value:u.value})},[f]);return s.useMemo(()=>({editingCell:t,startCellEdit:b,stopCellEdit:C,setEditCellValue:g}),[t,b,C,g])}function hd(e){const t=s.useRef(e),n=s.useRef(new Map),o=s.useRef(new Set);s.useLayoutEffect(()=>{t.current=e,n.current.clear()});const r=s.useCallback(a=>{const f=n.current.get(a);return f===void 0?t.current.rowsLookup.get(a):f},[]),i=s.useCallback(a=>{a.size!==0&&(a.forEach((f,p)=>{n.current.set(p,f)}),t.current.replaceRows(a))},[]),l=s.useCallback((a,f)=>{i(new Map([[a,f]]))},[i]),d=s.useCallback((a,f)=>{const{columns:p,processRowUpdate:w}=t.current,b=v=>el(v,t.current.onProcessRowUpdateError),C=new Map,g=new Map;p.forEach((v,M)=>{C.set(v.field,M),g.set(v.field,v)});const u=[],h=new Map;for(const v of a){const M=r(v.id);if(M===void 0){u.push({id:v.id,field:v.field,reason:"missing"});continue}const N=g.get(v.field);if(v.expect&&!dt(ke(M,v.field,N),v.expect.value)){u.push({id:v.id,field:v.field,reason:"changed"});continue}let P=h.get(v.id);P||(P={id:v.id,row:M,cells:[]},h.set(v.id,P));const z=C.get(v.field)??Number.MAX_SAFE_INTEGER,F=P.cells.findIndex(_=>_.field===v.field),$={field:v.field,value:v.value,colDef:N,order:z};F===-1?P.cells.push($):P.cells[F]=$}const x=[],m=[],y=o.current;h.forEach(v=>{const{id:M,row:N}=v,P=v.cells.filter($=>!dt(ke(N,$.field,$.colDef),$.value)).sort(($,_)=>$.order-_.order);if(v.cells=P,P.length===0)return;const z=pn(()=>{let $=N;for(const _ of P)$=nl($,_,_.colDef,y);return w?w($,N):$});if(!z.ok){x.push({id:M,ok:!1,error:z.error});return}const F=z.value;Qi(F)?m.push(Promise.resolve(F).then($=>({id:M,ok:!0,processed:$}),$=>({id:M,ok:!1,error:$}))):x.push({id:M,ok:!0,processed:F})});const E=v=>{const M=new Map;v.forEach($=>{M.set($.id,$)});const N=[],P=[],z=[],F=new Map;return h.forEach($=>{const _=M.get($.id);if(!_)return;if(!_.ok){P.push({id:$.id,error:_.error}),b(_.error);return}const T=_.processed;if(typeof T!="object"||T===null){const S=tl(T,"The row was not saved.");P.push({id:$.id,error:S}),b(S);return}const O=T;F.set($.id,O),N.push($.id);for(const S of $.cells){const j=ke($.row,S.field,S.colDef),q=ke(O,S.field,S.colDef);dt(j,q)||z.push({id:$.id,field:S.field,before:j,after:q})}}),i(F),z.length>0&&f!=="undo"&&f!=="redo"&&t.current.onCommitted?.(z,f),{result:{updated:N,failed:P,skipped:u},committed:z}};return m.length===0?Promise.resolve(E(x)):Promise.all(m).then(v=>E([...x,...v]))},[r,i]);return s.useMemo(()=>({applyEdits:d,getRow:r,storeRow:l}),[d,r,l])}const et={ok:!1},Fe=e=>({ok:!0,value:e});function md(e){const t=[];if(e==="")return t;let n=[],o="",r=0;const i=e.length;let l=!0;for(;r<i;){const d=e[r];if(l&&d==='"'){let a=r+1,f="",p=!1;for(;a<i;){const w=e[a];if(w==='"'){if(e[a+1]==='"'){f+='"',a+=2;continue}p=!0,a+=1;break}f+=w,a+=1}if(!p){o+=d,r+=1,l=!1;continue}o+=f,r=a,l=!1;continue}l=!1,d===" "?(n.push(o),o="",l=!0,r+=1):d===`
|
|
4
|
+
`||d==="\r"?(n.push(o),t.push(n),n=[],o="",l=!0,r+=d==="\r"&&e[r+1]===`
|
|
5
|
+
`?2:1):(o+=d,r+=1)}return(!l||n.length>0||o!=="")&&(n.push(o),t.push(n)),t}const wd=/^\d+(?:\.\d*)?(?:e[+-]?\d+)?$/i,xd=/^\.\d+(?:e[+-]?\d+)?$/i,bd=/^\d{1,3}(?:,\d{3})+(?:\.\d*)?$/,Cd=/[\p{Sc}\s]/gu;function yd(e){let t=e.replace(Cd,"");if(t==="")return e.trim()===""?Fe(null):et;let n=!1;t.startsWith("(")&&t.endsWith(")")&&(n=!0,t=t.slice(1,-1)),(t.startsWith("-")||t.startsWith("+")||t.startsWith("−"))&&(t[0]!=="+"&&(n=!n),t=t.slice(1));let o=!1;if(t.endsWith("%")&&(o=!0,t=t.slice(0,-1)),bd.test(t))t=t.split(",").join("");else if(!wd.test(t)&&!xd.test(t))return et;let r=Number(t);return Number.isFinite(r)?(o&&(r/=100),n&&(r=-r),Fe(r)):et}const vd=/^(\d{4}-\d{2}-\d{2})/,ol=e=>String(e).padStart(2,"0"),Sd=e=>`${e.getFullYear()}-${ol(e.getMonth()+1)}-${ol(e.getDate())}`;function _d(e,t){const n=e.trim();if(n==="")return Fe(null);const o=sn(n);if(!o)return et;if(typeof t=="number")return Fe(o.getTime());if(typeof t=="string"){const r=Sd(o);return Fe(vd.test(t)&&t.length>10?r+t.slice(10):r)}return Fe(o)}const kd=new Set(["true","yes","1"]),Ed=new Set(["false","no","0"]);function Md(e,t){const n=e.trim().toLowerCase();return n===""?Fe(null):t?.trueLabel!==void 0&&n===t.trueLabel.trim().toLowerCase()?Fe(!0):t?.falseLabel!==void 0&&n===t.falseLabel.trim().toLowerCase()?Fe(!1):kd.has(n)?Fe(!0):Ed.has(n)?Fe(!1):et}function Nd(e,t){const n=e.trim();if(n==="")return Fe(null);if(!t||t.length===0)return et;const o=n.toLowerCase();for(const r of t){const i=typeof r=="object"?r.value:r;if(String(i).toLowerCase()===o)return Fe(i)}for(const r of t)if(typeof r=="object"&&r.label.toLowerCase()===o)return Fe(r.value);return et}function Id(e,t,n){switch(t?.type){case"number":return yd(e);case"date":return _d(e,n?.current);case"boolean":return Md(e,n?.booleanLabels);case"singleSelect":return Nd(e,t.valueOptions);default:return Fe(e)}}function Pd(e,t,n,o){const{valueParser:r}=t;if(!r)return Id(e,t,o);let i;try{i=r(e,{row:n,field:t.field,colDef:t})}catch{return et}return i===void 0?et:Fe(i)}function rl(e,t,n){const o=e.map(t),r=new Map;o.forEach((a,f)=>{r.has(a)||r.set(a,f)});const i=n.filter(a=>je(a.field)),l=new Map;i.forEach((a,f)=>{l.set(a.field,f)});const d=n.filter(a=>Qe(a.field)).length;return{rows:e,rowIds:o,rowIndexById:r,columns:i,colIndexByField:l,dataColumnOffset:d}}function il(e,t,n,o,r){const i=e.rowIds[o],l=e.columns[r];if(!l||Ue(i,t.rowMetaMap))return!1;const d=t.getSpanOrigin?.(i,l.field);return d&&(d.rowId!==i||d.field!==l.field)?!1:Co({row:n,field:l.field,value:ke(n,l.field,l),colDef:l,rowIndex:o,colIndex:e.dataColumnOffset+r,rowMeta:t.rowMetaMap?.get(i)},t.isCellEditable)}function Ld(e,t){let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const l of t){const d=e.rowIndexById.get(l.id),a=e.colIndexByField.get(l.field);d===void 0||a===void 0||(d<n&&(n=d),d>o&&(o=d),a<r&&(r=a),a>i&&(i=a))}return n===1/0?null:{top:n,bottom:o,left:r,right:i}}function ll(e,t){return{anchor:{id:e.rowIds[t.top],field:e.columns[t.left].field},head:{id:e.rowIds[t.bottom],field:e.columns[t.right].field}}}function Td(e){const t=e?.type;return t===void 0||t==="string"||t==="image"}const sl=1e4,Vn=()=>({updated:[],failed:[],skipped:[]});function Fd(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Pasting ${e} cells. Pastes above ${sl} cells can be slow; consider importing the data instead.`)}function Ad(e){const{apiRef:t,containerRef:n,selection:o,disableClipboardPaste:r,disableRangeClear:i}=e,l=s.useRef(e);s.useLayoutEffect(()=>{l.current=e});const d=s.useCallback(()=>{const{allRenderableRows:g,getRowId:u,navigationColumns:h}=l.current;return rl(g,u,h)},[]),a=s.useCallback(()=>{const{selection:g}=l.current;return g.enabled?g.getCurrentRange().resolved:null},[]),f=s.useCallback(g=>{const u=a();if(u&&g.rowIds[u.top]!==void 0&&g.columns[u.left])return{id:g.rowIds[u.top],field:g.columns[u.left].field};const h=l.current.focusedCell;return h&&h.id!==null&&je(h.field)?{id:h.id,field:h.field}:null},[a]),p=s.useCallback(async(g,u,h)=>{const x=d(),m=u??f(x);let y=g;const{onBeforeClipboardPaste:E}=l.current;if(E){const le=pn(()=>E({text:y,anchor:m}));if(!le.ok)return ln("onBeforeClipboardPaste","onBeforeClipboardPaste threw; the paste was cancelled",le.error),Vn();if(le.value===!1)return Vn();typeof le.value=="string"&&(y=le.value)}if(!m)return Vn();const v=md(y),M=x.rowIndexById.get(m.id),N=x.colIndexByField.get(m.field);if(v.length===0||M===void 0||N===void 0)return Vn();const P=x.rowIds.length-1,z=x.columns.length-1,F=u?null:a(),$=F&&vt(F)>1?F:null,_=v.length===1&&v[0].length===1,T=v.reduce((le,ue)=>Math.max(le,ue.length),0);let O;_&&$?O=$:O={top:M,left:N,bottom:Math.min(M+v.length-1,P,$?$.bottom:P),right:Math.min(N+T-1,z,$?$.right:z)};const S=vt(O);S>sl&&Fd(S);const{batchEdit:j,isCellEditable:q,rowMetaMap:Z,getSpanOrigin:W}=l.current,U={isCellEditable:q,rowMetaMap:Z,getSpanOrigin:W},Q=[],ie=[];for(let le=O.top;le<=O.bottom;le++){const ue=x.rowIds[le],te=j.getRow(ue)??x.rows[le],ae=_?v[0]:v[le-O.top];for(let Y=O.left;Y<=O.right;Y++){const re=_?v[0][0]:ae?.[Y-O.left];if(re===void 0)continue;const K=x.columns[Y];if(!il(x,U,te,le,Y)){ie.push({id:ue,field:K.field,reason:"notEditable"});continue}const J=Pd(re,K,te,{current:ke(te,K.field,K)});if(!J.ok){ie.push({id:ue,field:K.field,reason:"invalidValue"});continue}Q.push({id:ue,field:K.field,value:J.value})}}if(l.current.selection.enabled){const{anchor:le,head:ue}=ll(x,O);l.current.selection.setModel([{anchor:le,head:ue}],h?"keyboard":"api")}const oe=await j.applyEdits(Q,"paste"),ge={updated:oe.result.updated,failed:oe.result.failed,skipped:[...ie,...oe.result.skipped]};return l.current.onClipboardPaste?.({...ge,text:y}),ge},[d,f,a]),w=s.useCallback(()=>{const g=a();if(!g||vt(g)<=1)return!1;const u=d(),{batchEdit:h,isCellEditable:x,rowMetaMap:m,getSpanOrigin:y}=l.current,E={isCellEditable:x,rowMetaMap:m,getSpanOrigin:y},v=[];for(let M=g.top;M<=g.bottom;M++){const N=u.rowIds[M];if(N===void 0)continue;const P=h.getRow(N)??u.rows[M];for(let z=g.left;z<=g.right;z++){const F=u.columns[z];!F||!il(u,E,P,M,z)||v.push({id:N,field:F.field,value:Td(F)?"":null})}}return h.applyEdits(v,"clear"),!0},[a,d]),b=o.enabled&&!r,C=o.enabled&&!i;s.useEffect(()=>{const g=n.current;if(!g||!b&&!C)return;const u=M=>{const N=l.current.viewportRef.current;if(!N||M.defaultPrevented||l.current.isEditing)return!1;const P=Ao(M.target,N);return P==="grid"||P==="control"};let h=null;const x=()=>{if(!h)return;const{textarea:M,restore:N,timer:P}=h;h=null,window.clearTimeout(P);const z=document.activeElement===M;M.remove(),z&&N&&N.isConnected&&N.focus({preventScroll:!0})},m=()=>{x();const M=document.createElement("textarea");M.setAttribute("aria-hidden","true"),M.tabIndex=-1,M.className="ogx__paste-capture",M.style.cssText="position:fixed;top:0;left:-10000px;width:1px;height:1px;opacity:0;",g.appendChild(M);const N=document.activeElement instanceof HTMLElement?document.activeElement:null;h={textarea:M,restore:N,timer:window.setTimeout(x,250)},M.focus({preventScroll:!0})},y=M=>h!==null&&M.target===h.textarea,E=M=>{if(y(M)){const P=M.clipboardData?M.clipboardData.getData("text/plain"):"";M.preventDefault(),x(),P!==""&&p(P,void 0,!0);return}if(!b||!u(M)||!l.current.navigationColumns.some(P=>P.editable))return;const N=M.clipboardData?M.clipboardData.getData("text/plain"):"";N!==""&&(M.preventDefault(),p(N,void 0,!0))},v=M=>{if((M.ctrlKey||M.metaKey)&&!M.altKey&&!M.shiftKey&&(M.key==="v"||M.key==="V"||M.code==="KeyV")){b&&u(M)&&l.current.navigationColumns.some(N=>N.editable)&&m();return}!C||M.key!=="Delete"&&M.key!=="Backspace"||M.ctrlKey||M.metaKey||M.altKey||M.shiftKey||u(M)&&w()&&M.preventDefault()};return g.addEventListener("paste",E),g.addEventListener("keydown",v),()=>{x(),g.removeEventListener("paste",E),g.removeEventListener("keydown",v)}},[n,b,C,p,w]),s.useLayoutEffect(()=>{t.current.pasteText=(g,u)=>p(g,u,!1)},[t,p])}const Dd=100;function Od(){const e=s.useRef(null),t=s.useCallback((o,r)=>{const i=e.current;i&&i(o,r)},[]),n=s.useCallback(o=>{e.current=o},[]);return s.useMemo(()=>({emit:t,setListener:n}),[t,n])}const al=()=>({updated:[],failed:[],skipped:[]});function $d(e){if(e.altKey||!(e.ctrlKey||e.metaKey))return null;const t=(e.key??"").toLowerCase(),n=/^[a-z]$/.test(t),o=t==="z"||!n&&e.code==="KeyZ",r=t==="y"||!n&&e.code==="KeyY";return o?e.shiftKey?"redo":"undo":r&&e.ctrlKey&&!e.shiftKey?"redo":null}function Gd(e){const{apiRef:t,enabled:n,channel:o,containerRef:r}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e});const l=s.useRef([]),d=s.useRef([]),a=s.useRef({canUndo:!1,canRedo:!1,size:0}),f=s.useRef(Promise.resolve()),p=s.useCallback(()=>{const x={canUndo:l.current.length>0,canRedo:d.current.length>0,size:l.current.length},m=a.current;m.canUndo===x.canUndo&&m.canRedo===x.canRedo&&m.size===x.size||(a.current=x,i.current.onHistoryChange?.(x))},[]),w=s.useCallback(x=>{if(!i.current.enabled||x.length===0)return;const m=l.current;m.push(x);const y=Math.max(1,i.current.limit);m.length>y&&m.splice(0,m.length-y),d.current=[],p()},[p]);s.useLayoutEffect(()=>(o.setListener(n?w:null),()=>o.setListener(null)),[o,n,w]);const b=s.useCallback(()=>{l.current=[],d.current=[],p()},[p]);s.useEffect(()=>{n||b()},[n,b]);const C=s.useCallback(x=>{const m=i.current,y=rl(m.allRenderableRows,m.getRowId,m.navigationColumns),E=Ld(y,x);if(!E)return;const{anchor:v,head:M}=ll(y,E);m.selection.enabled?m.selection.setModel([{anchor:v,head:M}],"keyboard"):m.setFocusedCell({id:v.id,field:v.field,rowIndex:E.top});const N=m.viewportRef.current;N&&(Tn(N,E.top-m.pinnedTopRowCount,m.layout.cumulativeHeights,m.layout.pinnedBottomHeight,m.rowHeight),bo(N,m.layout.unpinnedColsWithWidth.findIndex(P=>P.field===v.field),m.layout))},[]),g=s.useCallback(x=>{const m=async()=>{if(!i.current.enabled)return al();const E=x==="undo"?l:d,v=x==="undo"?d:l,M=E.current.pop();if(!M)return al();p();const N=M.map(F=>x==="undo"?{id:F.id,field:F.field,value:F.before,expect:{value:F.after}}:{id:F.id,field:F.field,value:F.after,expect:{value:F.before}}),P=await i.current.batchEdit.applyEdits(N,x);P.committed.length>0&&v.current.push(x==="undo"?P.committed.map(F=>({id:F.id,field:F.field,before:F.after,after:F.before})):P.committed);const z=new Set(P.result.failed.map(F=>F.id));if(z.size>0){const F=M.filter($=>z.has($.id));F.length>0&&E.current.push(F)}return p(),P.committed.length>0&&C(P.committed),P.result},y=f.current.then(m,m);return f.current=y,y},[p,C]),u=s.useCallback(()=>g("undo"),[g]),h=s.useCallback(()=>g("redo"),[g]);s.useEffect(()=>{const x=r.current;if(!x||!n)return;const m=y=>{if(y.defaultPrevented)return;const E=$d(y);if(!E)return;const v=i.current.viewportRef.current;if(!v||i.current.isEditing)return;const M=Ao(y.target,v);M!=="grid"&&M!=="control"||(y.preventDefault(),E==="undo"?u():h())};return x.addEventListener("keydown",m),()=>x.removeEventListener("keydown",m)},[r,n,u,h]),s.useLayoutEffect(()=>{const x=t.current;x.undo=u,x.redo=h,x.canUndo=()=>i.current.enabled&&l.current.length>0,x.canRedo=()=>i.current.enabled&&d.current.length>0,x.clearHistory=b},[t,u,h,b])}const Wd=e=>e.id,Bd={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},cl="\0",dl="";function ul(e){if(typeof e!="number"||Number.isNaN(e))return 1;if(e===1/0)return Number.MAX_SAFE_INTEGER;if(!Number.isFinite(e))return 1;const t=Math.floor(e);return t<1?1:t}function Hd(e){return e.map(t=>t.field).join(cl)}function zd(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:d,expandedRowIds:a,rowMetaMap:f,getRowId:p=Wd}=e,w=s.useMemo(()=>r.some(x=>x.colSpan!==void 0&&x.colSpan!==null),[r]),b=s.useMemo(()=>r.some(x=>x.rowSpan!==void 0&&x.rowSpan!==null),[r]),C=w||b,g=C?[i,l,d].map(Hd).join(dl):"",u=s.useMemo(()=>{if(!g)return{columns:[],leftCount:0,unpinnedCount:0};const x=new Map(r.map(v=>[v.field,v])),m=g.split(dl).map(v=>v?v.split(cl):[]),y=[];let E=0;for(const v of m){E+=v.length;for(const M of v){const N=x.get(M)??{field:M};y.push({colDef:N,field:M,sectionEnd:E,hasColSpan:N.colSpan!==void 0&&N.colSpan!==null,hasRowSpan:N.rowSpan!==void 0&&N.rowSpan!==null})}}return{columns:y,leftCount:m[0].length,unpinnedCount:m[1].length}},[g,r]),h=s.useMemo(()=>{if(!C||u.columns.length===0)return null;const x={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:u,expandedRowIds:a,rowMetaMap:f,getRowId:p,warned:new Set,out:x};return Uo(t,0,!1,y),Uo(n,t.length,!0,y),Uo(o,t.length+n.length,!1,y),x},[C,u,t,n,o,a,f,p]);return s.useMemo(()=>{if(!h)return Bd;const{colspanMap:x,rowSpanningCaches:m,hiddenOriginFields:y,unpinnedRanges:E,centerRowSpanStart:v}=h,M=u.columns;return{hasColSpan:w,hasRowSpan:b,colspanMap:x,rowSpanningCaches:m,getSpanOrigin:(N,P)=>{const z=x.get(N)?.[P];if(z?.spannedByColSpan)return{rowId:N,field:M[z.leftVisibleCellIndex].field};const F=m.hiddenCellOriginMap[N]?.[P];return F===void 0?null:{rowId:F,field:y.get(N)?.[P]??P}},getUnpinnedColSpanRanges:N=>E.get(N),getCenterRowSpanStart:N=>v.get(N)??N}},[h,w,b,u])}function Uo(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:d,warned:a,out:f}=o,{columns:p,leftCount:w,unpinnedCount:b}=r,C=p.length,{colspanMap:g,rowSpanningCaches:u,hiddenOriginFields:h,unpinnedRanges:x,centerRowSpanStart:m}=f,y=new Int32Array(C),E=new Array(C),v=new Array(C),M=new Int32Array(C);let N=0;const P=[];p.forEach(($,_)=>{($.hasColSpan||$.hasRowSpan)&&P.push(_)});const z=($,_,T)=>{const O=p[T].field;if(Vt(u.hiddenCells,$,O,!0),Vt(u.hiddenCellOriginMap,$,O,E[T]),v[T]!==O&&Vt(h,$,O,v[T]),n){const S=m.get(_);(S===void 0||M[T]<S)&&m.set(_,M[T])}},F=($,_,T)=>{const O=p[T],S=d($),j=Vd($,S,O.colDef,t+_,T,l,a);let q=1;if(O.hasColSpan){const W=Math.min(fl(O.colDef.colSpan,j,"colSpan",O.field,a),O.sectionEnd-T);for(;q<W&&y[T+q]<=_;)q++}let Z=1;if(O.hasRowSpan){Z=Math.min(fl(O.colDef.rowSpan,j,"rowSpan",O.field,a),e.length-_);for(let W=1;W<Z;W++)if(Ue(d(e[_+W]),l)){Z=W;break}if(Z>1&&i&&i.size>0){for(let W=0;W<Z-1;W++)if(i.has(d(e[_+W]))){Z=W+1;break}}}if(q>1){Vt(g,S,O.field,{spannedByColSpan:!1,cellProps:{colSpan:q}});for(let W=1;W<q;W++){const U=p[T+W];Vt(g,S,U.field,{spannedByColSpan:!0,leftVisibleCellIndex:T,rightVisibleCellIndex:T+q-1})}if(T>=w&&T<w+b){let W=x.get(S);W||(W=[],x.set(S,W)),W.push(T-w,T+q-1-w)}}if(Z>1){Vt(u.spannedCells,S,O.field,Z);for(let W=T;W<T+q;W++)y[W]=_+Z,E[W]=S,v[W]=O.field,M[W]=_;_+Z>N&&(N=_+Z)}return q};for(let $=0;$<e.length;$++){const _=e[$];if(!_||_._isSkeleton||Ue(d(_),l))continue;if(N<=$){let O=0;for(const S of P)S>=O&&(O=S+F(_,$,S));continue}let T=0;for(;T<C;)y[T]>$?(z(d(_),$,T),T++):p[T].hasColSpan||p[T].hasRowSpan?T+=F(_,$,T):T++}}function Vd(e,t,n,o,r,i,l){const d=e[n.field];let a=d;if(n.valueGetter)try{a=n.valueGetter({row:e,field:n.field,value:d})}catch(f){gl(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,f),a=void 0}return{row:e,value:a,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function fl(e,t,n,o,r){if(typeof e=="number")return ul(e);if(typeof e!="function")return 1;try{return ul(e(t))}catch(i){return gl(r,`${n}:${o}`,`${n} for column "${o}" threw; the cell is rendered without a span`,i),1}}function gl(e,t,n,o){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${n}.`,o))}function Vt(e,t,n,o){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[n]=o;return}let r=e[t];r||(r={},e[t]=r),r[n]=o}function Kd(e){const{spanning:t,renderContext:n,offsetTop:o,cumulativeHeights:r}=e;return s.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:n,offsetTop:o};let i=Math.max(0,n.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=n.firstRowIndex?{renderContext:n,offsetTop:o}:{renderContext:{...n,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,n,o,r])}function Ud(e){const{spanning:t,firstColumnIndex:n,lastColumnIndex:o,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let d=n,a=o,f=!0;for(;f;){f=!1;for(const{row:x,id:m}of l){const y=t.getUnpinnedColSpanRanges(m??x.id);if(y)for(let E=0;E<y.length;E+=2){const v=y[E],M=y[E+1];M<d||v>a||(v<d&&(d=v,f=!0),M>a&&(a=M,f=!0))}}}if(d===n&&a===o)return r;const{leftPinnedCols:p,unpinnedColsWithWidth:w,rightPinnedCols:b,unpinnedAccWidths:C,unpinnedTotalWidth:g}=i,u=d>0?C[d-1]:0,h=g-C[a];return[...p,...u>0?[{field:"__spacer_left__",width:u,isSpacer:!0}]:[],...w.slice(d,a+1),...h>0?[{field:"__spacer_right__",width:h,isSpacer:!0}]:[],...b]},[t,n,o,r,i,l])}function jd(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const d=a=>n===null||Vo(e,n,a);return{onDragOver:o&&(a=>d(a)?o(a):()=>{}),onDrop:r&&(a=>d(a)?r(a):f=>{f.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}const Rd=300,pl=e=>e.id;function qd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function hl(e,t){const n=new Set,o=[];return e.forEach(r=>{const i=t(r);n.has(i)||(n.add(i),o.push({id:i,row:r}))}),o}function ml(e,t,n){const o=new Set(e.map(n)),r=t.filter(i=>!o.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function Xd(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:d,aggregationModel:a,rowGroupingActive:f=!1}=e,p=qd(i,f),w=!!t&&i==="server"&&f,b=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||b.current||!w||(b.current=!0,console.warn("[OpenGridX] `rowGroupingModel` turns pagination off, so the dataSource with `paginationMode: 'server'` is asked for every row (startRow 0, endRow Number.MAX_SAFE_INTEGER) instead of one page. See docs/features/data-source.md."))},[w]);const C=t?.getRows,g=Fi({dataSource:t,paginationMode:i,sortingMode:l,filterMode:d}),u=JSON.stringify([p,p!=="all"||l==="server"?n:null,p!=="all"||d==="server"?o:null,g?a??null:null,p==="all"?null:r.pageSize]),h=p==="all"?0:r.page,x=p==="all"?0:r.pageSize,m=s.useRef({params:e,kind:p});s.useLayoutEffect(()=>{m.current={params:e,kind:p}});const y=s.useRef(0),E=s.useRef(0),v=s.useRef(null),M=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),N=s.useRef(null),P=s.useRef(!1),z=s.useRef(0),F=s.useRef(!1),$=s.useRef(new Set),_=s.useCallback(()=>{const U=P.current||z.current>0;U!==F.current&&(F.current=U,m.current.params.setDataSourceLoading(U))},[]),T=s.useCallback(()=>{N.current!==null&&(clearTimeout(N.current),N.current=null)},[]),O=s.useCallback(()=>{y.current++,M.current.inFlightEnd=null,P.current=!1},[]),S=s.useCallback(()=>{E.current++,$.current.clear(),z.current=0},[]),j=s.useCallback(async()=>{const{params:U,kind:Q}=m.current,ie=U.dataSource;if(!ie)return!1;const oe=M.current,ge=U.paginationModel.pageSize;let le,ue;if(Q==="infinite"){if(oe.inFlightEnd!==null)return!1;if(le=oe.loadedEnd,ue=(oe.page+1)*ge,ue<=le)return P.current=!1,_(),!1;oe.inFlightEnd=ue}else Q==="page"?(le=U.paginationModel.page*ge,ue=le+ge):(le=0,ue=Ai);const te=++y.current;P.current=!0,_(),U.setDataSourceError(null);let ae;try{ae=await ie.getRows({startRow:le,endRow:ue,sortModel:U.sortModel,filterModel:U.filterModel,groupKeys:[],aggregationModel:U.aggregationModel})}catch(Y){return te!==y.current||(oe.inFlightEnd=null,P.current=!1,m.current.params.setDataSourceError(Y),console.error("Data Source Error:",Y),_()),!1}if(te!==y.current)return!1;try{const{params:Y}=m.current,re=Y.getRowId??pl,K=hl(ae.rows,re);if(Q==="infinite"&&le>0?Y.setRows(J=>ml(J,K,re),!0):(Y.setRows(K.map(J=>J.row),!0),S()),ae.aggregationResults&&Y.onAggregationResults?.(ae.aggregationResults),ae.rowCount!==void 0&&Y.setRowCount(ae.rowCount),Q==="infinite"&&(oe.inFlightEnd=null,oe.loadedEnd=le+ae.rows.length,ae.rows.length>=ue-le&&(oe.page+1)*ge>ue))return!0}catch(Y){return oe.inFlightEnd=null,P.current=!1,m.current.params.setDataSourceError(Y),console.error("Data Source Error:",Y),_(),!1}return P.current=!1,_(),!1},[_,S]),q=s.useCallback(async()=>{for(;await j(););},[j]);s.useLayoutEffect(()=>{if(!C){v.current&&(v.current=null,T(),O(),S(),m.current.params.setDataSourceError(null),_());return}const U=v.current,Q=M.current;if(!U||U.key!==u||U.getRows!==C){v.current={key:u,getRows:C},O(),S();const ie=p==="infinite"&&U!==null&&h!==0;if(Q.page=ie?0:h,Q.loadedEnd=0,ie){const{params:oe}=m.current;oe.onPaginationModelChange?.({...oe.paginationModel,page:0})}}else p==="infinite"?(h<Q.page&&(O(),Q.loadedEnd=0),Q.page=h):O();if(p==="infinite"){const ie=Q.inFlightEnd!==null;if(ie||(Q.page+1)*x<=Q.loadedEnd){P.current=ie,_();return}}return P.current=!0,_(),N.current=setTimeout(()=>{N.current=null,q()},Rd),T},[C,u,p,h,x,T,O,S,_,q]),s.useEffect(()=>()=>{O(),S()},[O,S]);const Z=s.useCallback(()=>(T(),q()),[T,q]),W=s.useCallback(async(U,Q,ie)=>{const{params:oe}=m.current,ge=oe.dataSource;if(!ge)return;const le=JSON.stringify(Q),ue=$.current;if(ue.has(le))return;const te=E.current;ue.add(le),z.current++,_();try{const ae=await ge.getRows({startRow:0,endRow:Ai,sortModel:oe.sortModel,filterModel:oe.filterModel,groupKeys:Q,aggregationModel:oe.aggregationModel});if(te!==E.current)return;if(ae.rows.length>0){const{params:Y}=m.current,re=Y.getRowId??pl,K=hl(ae.rows,re);Y.setRows(J=>ml(J,K,re),!0)}}catch(ae){if(te!==E.current)return;ue.delete(le),console.error("Failed to fetch children:",ae),ie?.(ae)}finally{te===E.current&&(z.current--,_())}},[_]);return{fetchRows:Z,fetchChildren:W}}function Yd(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function Jd({enabled:e,treeNodes:t,isGroupExpanded:n,getNodePath:o,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:n,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:n,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((d,a)=>{!Yd(d)||!n(a)||i(a,o(a),()=>{const{isGroupExpanded:f,toggleExpansion:p}=l.current;f(a)&&p(a)})})},[e,t,n,o,i])}const wl={};function Zd(e){const t=JSON.stringify(e),[n,o]=s.useState(null),r=s.useCallback(i=>o({modelKey:t,results:i}),[t]);return[n&&n.modelKey===t?n.results:null,r]}function xl(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:d,serverAggregationResults:a}=e,f=Object.keys(o).length>0,p=s.useMemo(()=>{const v=new Map;return(n??[]).forEach(M=>v.set(M.field,M)),v},[n]),w=s.useMemo(()=>r||!f?wl:Fn(t,o,p,"useAggregation"),[t,p,o,r,f]),b=JSON.stringify([o,l??null,d??[]]),C=r&&f&&!!i?.getAggregations&&!a,g=s.useRef({aggregationModel:o,filterModel:l,sortModel:d});s.useEffect(()=>{g.current={aggregationModel:o,filterModel:l,sortModel:d}});const[u,h]=s.useState(null);s.useEffect(()=>{const v=i?.getAggregations;if(!C||!v)return;let M=!1;const N=g.current,P={sortModel:N.sortModel??[],filterModel:N.filterModel??{items:[]},groupKeys:[],aggregationModel:N.aggregationModel};let z;try{z=Promise.resolve(v(P))}catch(F){z=Promise.reject(F)}return z.then(F=>{M||h({key:b,result:F,error:null})},F=>{M||(console.error("[useAggregation] Server aggregation error:",F),h({key:b,result:null,error:F}))}),()=>{M=!0}},[C,i,b]);const x=u&&u.key===b?u:null,m=C&&x===null,y=C?x?.error??null:null;return{aggregationResult:s.useMemo(()=>r?a&&Object.keys(a).length>0?a:x?.result??wl:w,[r,w,a,x]),isLoading:m,error:y}}const Qd={items:[]},eu=[];function tu(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:d,hierarchyRequested:a}=e,f=o&&!d,p=s.useMemo(()=>new Set(n.map(x=>x.field)),[n]),w=s.useMemo(()=>Po(n),[n]),b=s.useMemo(()=>da(i,p),[i,p]),C=s.useMemo(()=>f?ko(t,b.source,w):t,[f,t,b.source,w]),g=s.useMemo(()=>f?ii(C,n,r,{outputFilterModel:b.output,sortModel:l}):To,[f,C,n,r,b.output,l]),u=f&&g.isValid,h=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&d&&!h.current.dataSource&&(h.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),u&&a&&!h.current.hierarchy&&(h.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[o,d,u,a]),{isActive:u,rows:u?g.pivotRows:t,columns:u?g.pivotColumns:n,pipelineFilterModel:u?Qd:i,pipelineSortModel:u?eu:l}}const hn=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...d})=>{const a=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${n}`,o&&"ogx-button--disabled",r].filter(Boolean).join(" ");return c.jsx("button",{type:i,className:a,disabled:o,...d,children:l})};function jo(e){const t=s.useId(),{page:n,pageSize:o,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:d=[10,25,50,100],showFirstButton:a=!0,showLastButton:f=!0,localeText:p}=e,w=Wn(o),b=$o(r,w),C=Ci(n,b),g=d.includes(w)?d:[...d,w].sort((_,T)=>_-T),u=C*w,h=Math.min(u+w,r),x=r===0?0:`${u+1}–${h}`,m=p?.paginationRowsPerPage??"Rows per page:",y=p?.paginationOf?p.paginationOf(r===0?0:u+1,h,r):`${x} of ${r}`,E=p?.paginationPage?p.paginationPage(C+1,b):`Page ${C+1} of ${b}`,v=()=>{i(0)},M=()=>{i(Math.max(0,C-1))},N=()=>{i(Math.min(b-1,C+1))},P=()=>{i(b-1)},z=_=>{const T=parseInt(_.target.value,10);l(T)},F=C===0,$=C>=b-1;return c.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[c.jsxs("div",{className:"ogx-pagination__page-size",children:[c.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:m}),c.jsx("select",{id:t,className:"ogx-pagination__select",value:w,onChange:z,children:g.map(_=>c.jsx("option",{value:_,children:_},_))})]}),c.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),c.jsxs("div",{className:"ogx-pagination__actions",children:[a&&c.jsx(hn,{variant:"text",size:"small",onClick:v,disabled:F,"aria-label":"Go to first page",title:"First page",children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:c.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),c.jsx(hn,{variant:"text",size:"small",onClick:M,disabled:F,"aria-label":"Go to previous page",title:"Previous page",children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:c.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),c.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:E}),c.jsx(hn,{variant:"text",size:"small",onClick:N,disabled:$,"aria-label":"Go to next page",title:"Next page",children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:c.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&c.jsx(hn,{variant:"text",size:"small",onClick:P,disabled:$,"aria-label":"Go to last page",title:"Last page",children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:c.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function nu({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:d=!1,checkboxSelection:a=!1,rowHeight:f,onRowClick:p,onRowDoubleClick:w,onSelectionChange:b,tabIndex:C=-1,onFocus:g,onToggleExpansion:u}){const h=t??e.id,x=r.field,m=ke(e,x,i),y=po(e,x,m,i)??ho(m,i),E=l?.isGroupRow===!0||Ue(h),v={row:e,value:m,formattedValue:y,field:x,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},M=N=>{N.stopPropagation(),b?.(h,N.target.checked)};return c.jsxs("div",{className:`ogx-list-view__row${d?" ogx-list-view__row--selected":""}`,style:f?{minHeight:f}:void 0,onClick:()=>p?.(e),onDoubleClick:w?()=>w(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":d,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":n,tabIndex:C,onFocus:g?N=>{N.target===N.currentTarget&&g(n)}:void 0,children:[a&&c.jsx("div",{className:"ogx-list-view__checkbox",onClick:N=>N.stopPropagation(),children:!E&&c.jsx(ct,{checked:d,onChange:M,"aria-label":`Select row ${h}`,tabIndex:-1})}),l&&u&&c.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:N=>N.stopPropagation(),onDoubleClick:N=>N.stopPropagation(),children:l.hasChildren&&c.jsx(Bo,{isExpanded:l.isExpanded===!0,onClick:()=>u(h),tabIndex:-1})}),c.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:c.jsx(St,{field:x,resetKey:e,renderFn:()=>{const N=r.renderCell(v);return N===void 0&&E?l?.groupLabel:N}})})]})}function ou(e,t){const n=s.useRef(!0),o=s.useRef(e);s.useEffect(()=>{o.current=e},[e]),s.useEffect(()=>{n.current=!0},[t]);const r=s.useCallback(i=>{const l=ki(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const d=o.current;d&&(n.current=!1,d(l))},[]);return e?r:void 0}const ru=e=>e.id;function iu({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:d,currentPage:a,pageSizeOptions:f,selectedRowIds:p,listViewColumn:w,columnsByField:b,rowMetaMap:C,noRowsLabel:g,rowHeight:u,checkboxSelection:h,paginationMode:x,serverRowCount:m,paginationSlot:y,paginationSlotProps:E,localeText:v,onRowClick:M,onRowDoubleClick:N,onSelectionChange:P,onPaginationModelChange:z,onRowsScrollEnd:F,getRowId:$=ru,multiselectable:_=!1,loading:T=!1,loadingOverlay:O,noRowsOverlay:S,showPaginationControls:j=!0,selectable:q=!1,onToggleExpansion:Z}){const W=y||jo,U=s.useRef(null),[Q,ie]=s.useState(null),oe=Q===null?-1:t.findIndex(I=>$(I)===Q),ge=oe===-1?0:oe,le=I=>{const D=t[I];D&&(ie($(D)),U.current?.querySelector(`:scope > [role="row"][data-rowindex="${I}"]`)?.focus())},ue=I=>{const D=I.target;if(D.getAttribute("role")!=="row"||D.parentElement!==U.current)return;const L=Number(D.getAttribute("data-rowindex")),A=t[L];if(!A)return;const V=$(A),R=t.length-1,B=C.get(V),k=!!(B?.hasChildren&&Z);if(I.altKey&&(I.key==="ArrowRight"||I.key==="ArrowLeft")){I.preventDefault(),k&&I.key==="ArrowRight"!=(B?.isExpanded===!0)&&Z?.(V);return}switch(I.key){case"ArrowDown":I.preventDefault(),le(Math.min(L+1,R));return;case"ArrowUp":I.preventDefault(),le(Math.max(L-1,0));return;case"Home":I.preventDefault(),le(0);return;case"End":I.preventDefault(),le(R);return;case"PageDown":I.preventDefault(),le(Math.min(L+10,R));return;case"PageUp":I.preventDefault(),le(Math.max(L-10,0));return;case"Enter":case" ":if(I.preventDefault(),I.key===" "&&I.shiftKey){q&&!B?.isGroupRow&&P(V,!p.has(V));return}k?Z?.(V):M({row:A,id:V,rowIndex:L});return}},te=x==="server",ae=te?m||0:i,Y=te?m||0:n,re=Wn(d.pageSize),K=$o(ae,re),J=l?a*re:0,ne=t.length-o-r,de=I=>{if(I<o)return I+1;const D=I-o;return D<ne?o+J+D+1:o+ae+(D-ne)+1},G=ou(F,t.length);return c.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":Y,"aria-multiselectable":_,children:[c.jsx("div",{className:"ogx-list-view__toolbar",children:c.jsxs("span",{children:[Y," ",Y===1?"item":"items",l?` · page ${a+1} of ${K}`:"",p.size>0?` · ${p.size} selected`:""]})}),c.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:G,onKeyDown:ue,ref:U,children:t.length===0&&T?c.jsx("div",{className:"ogx-list-view__loading",children:O??c.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&S?c.jsx("div",{className:"ogx-list-view__empty",children:S}):t.length===0?c.jsxs("div",{className:"ogx-list-view__empty",children:[c.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("path",{d:"M3 9h18M9 21V9"})]}),g]}):t.map((I,D)=>{const L=$(I);return c.jsx(nu,{row:I,rowId:L,rowIndex:D,ariaRowIndex:de(D),listViewColumn:w,gridColumn:b.get(w.field),rowMeta:C.get(L),isSelected:p.has(L),checkboxSelection:h,rowHeight:u,onRowClick:A=>M({row:A,id:L,rowIndex:D}),onRowDoubleClick:N?A=>N({row:A,id:L,rowIndex:D}):void 0,onSelectionChange:P,tabIndex:D===ge?0:-1,onToggleExpansion:Z,onFocus:A=>ie($(t[A]))},L)})}),l&&j&&c.jsx(W,{page:a,pageSize:d.pageSize,rowCount:ae,pageSizeOptions:f,onPageChange:I=>z({...d,page:I}),onPageSizeChange:I=>z({...d,pageSize:I,page:0}),localeText:v,...E})]})}function lu({overlay:e}){return e?c.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):c.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:c.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}const ut=s.forwardRef(function({fullWidth:t=!1,error:n=!1,startAdornment:o,endAdornment:r,className:i="",inputClassName:l="",variant:d="field",...a},f){const p=["ogx-input-wrapper",d==="cell"&&"ogx-input-wrapper--cell",t&&"ogx-input-wrapper--full-width",n&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" "),w=["ogx-input",l].filter(Boolean).join(" ");return c.jsxs("div",{className:p,children:[o&&c.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),c.jsx("input",{ref:f,className:w,"aria-invalid":n?!0:void 0,...a}),r&&c.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})});ut.displayName="Input";function mn(e){return e.headerName||e.field}function su(e){return e.nativeEvent.isComposing||e.keyCode===229}function wn(e,t,n=!0){return o=>{if(su(o)){o.stopPropagation();return}n&&o.key==="Enter"&&(o.stopPropagation(),e()),o.key==="Escape"&&(o.stopPropagation(),t())}}function au({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(String(e??"")),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),c.jsx(ut,{ref:d,variant:"cell",type:"text",inputClassName:"ogx__edit-input","aria-label":mn(t),value:i,onChange:a=>{l(a.target.value),n(a.target.value)},onBlur:o,onKeyDown:wn(o,r)})}function cu({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),c.jsx(ut,{ref:d,variant:"cell",type:"number",inputClassName:"ogx__edit-input ogx__edit-input--number","aria-label":mn(t),value:i,onChange:a=>{const f=a.target.value===""?"":Number(a.target.value);l(f),n(f===""?null:f)},onBlur:o,onKeyDown:wn(o,r)})}function du({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{n(!e),o()};return c.jsx("div",{className:"ogx__edit-boolean",onMouseDown:d=>d.preventDefault(),children:c.jsx(ct,{ref:i,inputClassName:"ogx__edit-checkbox","aria-label":mn(t),checked:!!e,onChange:l,onMouseDown:d=>d.preventDefault(),onBlur:o,onKeyDown:wn(o,r,!1)})})}const Ro=e=>typeof e=="object"?e.value:e,uu=e=>typeof e=="object"?e.label:String(e);function fu(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function gu({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],d=l.map(p=>String(Ro(p)));let a=l.findIndex(p=>fu(Ro(p),e));a===-1&&e!==null&&e!==void 0&&(a=d.indexOf(String(e)));const f=a===-1;return c.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":mn(t),value:f?"":d[a],onChange:p=>{const w=d.indexOf(p.target.value);n(w===-1?null:Ro(l[w]))},onBlur:o,onKeyDown:wn(o,r),children:[f&&c.jsx("option",{value:""}),l.map((p,w)=>c.jsx("option",{value:d[w],children:uu(p)},w))]})}const bl=e=>String(e).padStart(2,"0"),Cl=/^(\d{4}-\d{2}-\d{2})/;function qo(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${bl(e.getMonth()+1)}-${bl(e.getDate())}`;if(typeof e=="string"){const t=Cl.exec(e);return t?t[1]:e===""?"":qo(new Date(e))}return typeof e=="number"?qo(new Date(e)):""}function pu(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const d=new Date(l.getTime());return d.setFullYear(n,o-1,r),d};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&Cl.test(t)&&t.length>10?e+t.slice(10):e}function hu({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i]=s.useState(e),[l,d]=s.useState(()=>qo(e)),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus()},[]),c.jsx(ut,{ref:a,variant:"cell",type:"date",inputClassName:"ogx__edit-input","aria-label":mn(t),value:l,onChange:f=>{d(f.target.value),n(pu(f.target.value,i))},onBlur:o,onKeyDown:wn(o,r)})}function mu(e){const{colDef:t}=e;switch(t.type){case"number":return c.jsx("div",{className:"ogx__edit-cell",children:c.jsx(cu,{...e})});case"boolean":return c.jsx("div",{className:"ogx__edit-cell",children:c.jsx(du,{...e})});case"singleSelect":return c.jsx("div",{className:"ogx__edit-cell",children:c.jsx(gu,{...e})});case"date":return c.jsx("div",{className:"ogx__edit-cell",children:c.jsx(hu,{...e})});default:return c.jsx("div",{className:"ogx__edit-cell",children:c.jsx(au,{...e})})}}function wu(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:d,colIndex:a,ariaColIndex:f,isSelected:p,onClick:w,width:b,pinnedPosition:C,pinnedOffset:g,isPinnedEdge:u,isFocused:h,isFocusVisible:x,isEditable:m,isEditing:y,onEditStart:E,onEditStop:v,onValueChange:M,colSpanInfo:N,rowSpan:P,isHiddenByRowSpan:z,rowMeta:F,valueError:$,rangeFlags:_=0}=e,T=s.useCallback(G=>{o?o(l.field,G):M?.(G)},[o,M,l.field]),O=F?.isGroupRow===!0,{formattedValue:S,error:j}=s.useMemo(()=>{const G=l.valueFormatter;if(G&&!(O&&r==null)){const I=pn(()=>G({value:r,row:i,field:l.field}));return I.ok?{formattedValue:I.value}:{formattedValue:"",error:I.error??new Error("valueFormatter failed")}}return{formattedValue:ho(r,l)}},[r,i,l,O]),q=s.useMemo(()=>{if(!l.cellClassName)return"";const G=l.cellClassName;if(typeof G=="function"){const I=pn(()=>G({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:a,rowMeta:F}));return I.ok&&I.value||""}return l.cellClassName},[l,r,S,i,d,a,F]),Z=$??j,W=l.field,U=s.useCallback(()=>{v?.(!1,W)},[v,W]),Q=s.useCallback(()=>{v?.(!0,W)},[v,W]),ie=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),oe=s.useRef(!1);if(s.useEffect(()=>{if(!(!y||!v))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.current||v(!1,W)})}},[y,v,W]),N?.spannedByColSpan)return null;const ge=N?.cellProps.colSpan??1,le=ge>1,ue=(le?N?.cellProps.width:void 0)??b??l.width??100,te={width:"var(--width)","--width":typeof ue=="number"?`${ue}px`:ue,flexGrow:(le?N?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:le?void 0:l.minWidth,maxWidth:le?void 0:l.maxWidth};if(z)return c.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:te,role:"presentation","data-field":l.field,"data-colindex":a});const ae=G=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:d,colIndex:a}),w?.(G))},Y=()=>{y||!m||(n?n(l.field,r):E?.())},re=l.renderEditCell,K=C!=null,J=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,p&&"ogx__cell--selected",h&&"ogx__cell--focused",h&&x&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,K&&"ogx__cell--pinned",K&&`ogx__cell--pinned-${C}`,K&&u&&`ogx__cell--pinned-${C}-${C==="left"?"last":"first"}`,y&&"ogx__cell--editing",P&&P>1&&"ogx__cell--spanned",(_&Oo)!==0&&"ogx__cell--range",(_&fi)!==0&&"ogx__cell--range-top",(_&gi)!==0&&"ogx__cell--range-bottom",(_&pi)!==0&&"ogx__cell--range-left",(_&hi)!==0&&"ogx__cell--range-right",q].filter(Boolean).join(" "),ne=P||1,de={...te,position:K?"sticky":void 0,zIndex:l.zIndex??(K?3:void 0),padding:y?0:void 0};return ne>1&&(de.height=`calc(var(--height) * ${ne} - var(--border-width, 1px))`,de.zIndex=10,K&&(de.zIndex=40)),K&&g!==void 0&&(C==="left"?de.left=g:de.right=g),c.jsx("div",{className:J,style:de,onClick:ae,onDoubleClick:Y,role:"gridcell","aria-colindex":f??a+1,"aria-readonly":!m||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":a,...ge>1?{"aria-colspan":ge}:{},...ne>1?{"aria-rowspan":ne}:{},...(_&Oo)!==0?{"aria-selected":!0}:{},children:c.jsx("div",{className:"ogx__cell-content",children:y&&(o||M)&&v?re?c.jsx(St,{field:l.field,resetKey:i,renderFn:()=>re({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:a,rowMeta:F,onValueChange:T,onCommit:U,onCancel:Q})}):c.jsx(mu,{value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:a,rowMeta:F,onValueChange:T,onCommit:U,onCancel:Q}):Z!==void 0?c.jsx(St,{field:l.field,resetKey:i,renderFn:()=>{throw Z}}):l.renderCell?c.jsx(St,{field:l.field,resetKey:ie,renderFn:()=>l.renderCell({value:r,formattedValue:S,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:a,rowMeta:F})}):l.type==="image"&&typeof r=="string"&&r!==""?c.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):S})})}const yl=s.memo(wu),xu=({className:e="",...t})=>c.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:c.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:c.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 bu(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:d}=e,a=s.useRef(null),f=o==="auto";if(s.useLayoutEffect(()=>{const w=a.current;if(!w||!f||!r||!i)return;const b=()=>{w.getClientRects().length!==0&&i(t,w.offsetHeight)};if(b(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(b);return C.observe(w),()=>C.disconnect()},[f,r,i,t]),!r)return null;const p={height:f?"auto":`${o}px`,overflow:f?"visible":"auto"};return c.jsx("div",{ref:a,className:"ogx__detail-panel",style:p,role:"row",id:l,children:c.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":d,children:n})})}const Xo=12;function Cu(e,t,n,o){let r=0,i=0,l=0;for(let d=t;d<e.length&&l<n;d++){const a=e[d];if(a.isSpacer)break;r+=bt(a,o),i+=a.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function yu(e){const{row:t,rowId:n,columns:o,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:d,onRowDoubleClick:a,onCellClick:f,onSelectionChange:p,columnWidths:w={},pinnedColumns:b,pinnedRows:C,hasDetailPanel:g=!1,isDetailPanelExpanded:u=!1,onDetailPanelToggle:h,detailPanelContent:x,detailPanelHeight:m=mo,onDetailPanelHeightChange:y,pinCheckboxColumn:E=!0,pinExpandColumn:v=!0,rowReordering:M=!1,onDragStart:N,onDragOver:P,onDragEnd:z,onDrop:F,isDragging:$,isDragOver:_,editingCell:T,onEditStart:O,onEditStop:S,onEditCellValueChange:j,isCellEditable:q,focusedCellField:Z,isFocusVisible:W,colspanMap:U,rowSpanningCaches:Q,rowHeight:ie=52,rowMeta:oe,columnIndexMap:ge,ariaRowIndex:le,cellRange:ue}=e,te=n??t.id,ae=s.useId(),Y=s.useId(),re=s.useMemo(()=>fo(o,w,b,l,E,g,v,M),[o,w,b,l,E,g,v,M]),K=s.useMemo(()=>go(o,b),[o,b]),J=oe?.hasChildren===!0,ne=oe?.isGroupRow===!0,de=g&&!ne,G=!ne&&!Ue(te),I=s.useCallback((se,be)=>{O?.({id:te,field:se,value:be})},[te,O]),D=s.useCallback((se,be)=>{j?.({id:te,field:se,value:be})},[j,te]),L=s.useCallback((se,be)=>{S?.({cancel:se,id:te,field:be})},[S,te]);if(t._isSkeleton){const se=Math.max(o.length,5);return c.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ie,minHeight:ie},children:Array.from({length:se}).map((be,Me)=>c.jsx("div",{className:"ogx__skeleton-cell",children:c.jsx("div",{className:"ogx__skeleton-bar"})},Me))})}const A=se=>{se.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:te,rowIndex:r})},V=se=>{se.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||a?.({row:t,id:te,rowIndex:r})},R=se=>{se.stopPropagation(),p?.(te,se.target.checked)},B=se=>{se.stopPropagation(),h?.(te)},k=M?1:0,H=g?k+1:k,X=l?H+1:H,ee=X,ce=ge?.size??o.filter(se=>!se.isSpacer).length,pe=oe!==void 0,me=oe?.hasChildren===!0,ye=Lr(te,C),_e=ye==="top",Ce=ye==="bottom",Ee=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",_e&&"ogx__row--pinned-top",Ce&&"ogx__row--pinned-bottom",$&&"ogx__row--dragging",_&&"ogx__row--drag-over",J&&"ogx__row--group",oe?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:Ee,onClick:A,onDoubleClick:a?V:void 0,role:"row","aria-rowindex":le??r+2,"aria-selected":i,"aria-level":pe?(oe?.treeDepth??0)+1:void 0,"aria-expanded":me?oe?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:P?P(te):void 0,onDrop:F?F(te):void 0,style:{maxHeight:`${ie}px`,minHeight:`${ie}px`,"--height":`${ie}px`,"--border-width":"1px"},children:[M&&c.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${Z==="__reorder_col__"?"ogx__cell--focused":""} ${Z==="__reorder_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":N?"Drag to reorder row":void 0,"aria-colindex":k,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:Xo},draggable:!!N,onDragStart:N?N(te):void 0,onDragEnd:z,onClick:se=>se.stopPropagation(),children:N&&c.jsx(xu,{})}),g&&c.jsx("div",{className:`ogx__cell ogx__cell--expand ${v?"ogx__cell--pinned-left":""} ${Z==="__expand_col__"?"ogx__cell--focused":""} ${Z==="__expand_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":de?u?"Collapse row details":"Expand row details":void 0,"aria-expanded":de?u:void 0,"aria-controls":de&&u?Y:void 0,"aria-colindex":H,"data-field":"__expand_col__",style:{position:v?"sticky":void 0,left:v?M?48:0:void 0,zIndex:v?Xo:void 0},tabIndex:-1,onClick:se=>{se.stopPropagation(),f?.({row:t,field:"__expand_col__",value:u,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:de&&c.jsx(Bo,{isExpanded:u,onClick:B,variant:"plus-minus",tabIndex:-1})}),l&&c.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${Z==="__checkbox_col__"?"ogx__cell--focused":""} ${Z==="__checkbox_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":X,"data-field":"__checkbox_col__",style:{position:E?"sticky":void 0,left:E?(M?48:0)+(g&&v?48:0):void 0,zIndex:E?Xo:void 0},tabIndex:-1,onClick:se=>{se.stopPropagation(),f?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:G&&c.jsx(ct,{id:ae,name:`ogx-select-row-${te}`,checked:i,onChange:R,onClick:se=>se.stopPropagation(),"aria-label":i?`Deselect row ${te}`:`Select row ${te}`,tabIndex:-1,onMouseDown:se=>se.preventDefault()})}),o.map((se,be)=>{if(se.isSpacer)return c.jsx("div",{style:{width:se.width,minWidth:se.width,flexShrink:0},"aria-hidden":"true"},se.field);let Me,ve;ne?Me=t[se.field]:{value:Me,error:ve}=Fr(t,se.field,se);const he=ge?.get(se.field)??be,fe=w[se.field]??se.width,we=lt(se.field,b),Se=!!O&&Co({row:t,field:se.field,value:Me,colDef:se,rowIndex:r,colIndex:he,rowMeta:oe},q),Ne=T?.id===te&&T?.field===se.field,tt=Ne?T?.value:Me,$e=U?.get(te)?.[se.field],Ve=$e&&!$e.spannedByColSpan&&$e.cellProps.colSpan>1?Cu(o,he,$e.cellProps.colSpan,w):$e,Yt=Ve&&!Ve.spannedByColSpan?o[he+Ve.cellProps.colSpan-1]?.field??se.field:se.field,Ge=we==="right"?Yt:se.field,kt=we?re[Ge]:void 0,Et=we==="left"&&Yt===K.lastLeft||we==="right"&&se.field===K.firstRight,Yn=Q?.spannedCells[te]?.[se.field],Mt=Q?.hiddenCells[te]?.[se.field]||!1,rr=ue&&!Mt&&se.field!==di?Ca(ue,he,Ve&&!Ve.spannedByColSpan?Ve.cellProps.colSpan:1,Yn??1):void 0;return c.jsx(yl,{value:tt,row:t,colDef:se,rowIndex:r,colIndex:he,ariaColIndex:ee+he+1,isSelected:i,onCellClick:f,width:fe,pinnedPosition:we,pinnedOffset:kt,isPinnedEdge:Et,isFocused:Z===se.field,isFocusVisible:W,isEditable:Se,isEditing:Ne,onCellEditStart:I,onEditStop:L,onCellValueChange:D,colSpanInfo:Ve,rowSpan:Yn,isHiddenByRowSpan:Mt,rowMeta:oe,valueError:ve,rangeFlags:rr},se.field)})]}),de&&c.jsx(bu,{id:Y,colSpan:ee+ce,row:t,rowId:te,rowIndex:r,content:x,height:m,isExpanded:u,onHeightChange:y})]})}function vu(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(o==="cellRange"){if(!ba(e.cellRange,t.cellRange))return!1}else if(!Object.is(e[o],t[o]))return!1;return!0}const Kn=s.memo(yu,vu);function vl({getContent:e,params:t}){return c.jsx(St,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Su=e=>e.id;function Sl({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:w,hasDetailPanel:b,expandedRowIds:C,getDetailPanelContent:g,getDetailPanelHeight:u,onDetailPanelToggle:h,onDetailPanelHeightChange:x,pinCheckboxColumn:m,pinExpandColumn:y,focusedCell:E,colspanMap:v,rowSpanningCaches:M,rowHeight:N,rowMetaMap:P,getRowId:z=Su,rowIndexOffset:F=0,ariaRowIndexBase:$,columnIndexMap:_,editingHandlers:T,isCellEditable:O,rowReordering:S=!1,cellRange:j,cellRangeHasRowSpan:q=!1}){return e.length===0?null:c.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((Z,W)=>{const U=z(Z),Q=F+W;return c.jsx(Kn,{row:Z,rowId:U,columns:n,rowIndex:Q,ariaRowIndex:$!==void 0?$+W:void 0,columnIndexMap:_,isSelected:o.has(U),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:w,hasDetailPanel:b,isDetailPanelExpanded:C.has(U),detailPanelContent:C.has(U)&&g?c.jsx(vl,{getContent:g,params:{row:Z,id:U,rowIndex:Q}}):null,detailPanelHeight:C.has(U)?wo(xo(u,{row:Z,id:U,rowIndex:Q})):void 0,onDetailPanelHeightChange:x,onDetailPanelToggle:h,pinCheckboxColumn:m,pinExpandColumn:y,focusedCellField:E?.id===U?E.field:null,colspanMap:v,rowSpanningCaches:M,rowHeight:N,rowMeta:P.get(U),editingCell:T?.editingCell,onEditStart:T?.startCellEdit,onEditStop:T?.stopCellEdit,onEditCellValueChange:T?.setEditCellValue,isCellEditable:O,rowReordering:S,cellRange:ui(j,Q,q)},U)})})}const _u=({columns:e,rowHeight:t,checkboxSelection:n=!1,hasDetailPanel:o=!1,rowReordering:r=!1})=>c.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[n&&c.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:c.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&c.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:c.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&c.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:c.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const d=typeof i.width=="number"?i.width:150,a=Math.min(d*.7,d-20);return c.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:d,minWidth:i.minWidth,maxWidth:i.maxWidth,left:i.left,right:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&c.jsx("div",{className:"ogx-skeleton-box",style:{width:a,height:16,borderRadius:4}})},i.field||l)})]});function ku({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:d,hasDetailPanel:a,rowReordering:f,rowHeight:p,selectedRowIds:w,onRowClick:b,onRowDoubleClick:C,onCellClick:g,onSelectionChange:u,columnWidths:h,pinnedColumns:x,expandedRowIds:m,getDetailPanelContent:y,getDetailPanelHeight:E,onDetailPanelToggle:v,onDetailPanelHeightChange:M,pinCheckboxColumn:N,pinExpandColumn:P,rowReorderHandlers:z,editingHandlers:F,isCellEditable:$,focusedCell:_,colspanMap:T,rowSpanningCaches:O,paginationMode:S,dataSourceLoading:j,sortedUnpinnedRowCount:q,infiniteScrollSkeletonCount:Z,unpinnedRowsLength:W,lastRenderedRowIndex:U,rowMetaMap:Q,loadingOverlay:ie,ariaRowIndexOffset:oe,columnIndexMap:ge,cellRange:le,cellRangeHasRowSpan:ue=!1}){const te=r.length>0?r:(()=>{const re=(l||1e3)-(d?48:0)-(a?48:0)-(f?48:0),K=150,J=Math.max(1,Math.ceil(re/K));return Array.from({length:J},(ne,de)=>({field:`placeholder_${de}`,headerName:"",width:K}))})(),ae=o.filter(re=>!re.pinned),Y=S==="infinite"&&j&&q>0&&U>=W-1;return c.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:c.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[n&&o.length===0&&ie?c.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ie}):n&&o.length===0?Array.from({length:10}).map((re,K)=>c.jsx(_u,{columns:te,rowHeight:p,checkboxSelection:d,hasDetailPanel:a,rowReordering:f},`skeleton-${K}`)):ae.map(({row:re,id:K,rowIndex:J})=>c.jsx(Kn,{row:re,rowId:K,columns:i,rowIndex:J,ariaRowIndex:oe!==void 0?J+oe:void 0,columnIndexMap:ge,isSelected:w.has(K),checkboxSelection:d,onRowClick:b,onRowDoubleClick:C,onCellClick:g,onSelectionChange:u,columnWidths:h,pinnedColumns:x,hasDetailPanel:a,isDetailPanelExpanded:m.has(K),detailPanelContent:m.has(K)&&y?c.jsx(vl,{getContent:y,params:{row:re,id:K,rowIndex:J}}):null,detailPanelHeight:m.has(K)?wo(xo(E,{row:re,id:K,rowIndex:J})):void 0,onDetailPanelHeightChange:M,onDetailPanelToggle:v,pinCheckboxColumn:N,pinExpandColumn:P,rowReordering:f,onDragStart:z.canReorderRow(K)?z.onDragStart:void 0,onDragOver:z.onDragOver,onDragEnd:z.onDragEnd,onDrop:z.onDrop,isDragging:z.draggedRowId===K,isDragOver:z.dragOverRowId===K,editingCell:F.editingCell,onEditStart:F.startCellEdit,onEditStop:F.stopCellEdit,onEditCellValueChange:F.setEditCellValue,isCellEditable:$,focusedCellField:_!=null&&_.id===K?_.field:null,colspanMap:T,rowSpanningCaches:O,rowHeight:p,rowMeta:Q.get(K),cellRange:ui(le,J,ue)},K)),Y&&c.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:Z}).map((re,K)=>c.jsx(Kn,{row:{id:`__skeleton_${K}__`,_isSkeleton:!0},columns:i,rowIndex:W+K,rowHeight:p},`__skeleton_${K}__`))})]})})}function Eu(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"11",cy:"11",r:"8"}),c.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Mu(){return c.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[c.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),c.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),c.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),c.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),c.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),c.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function Yo(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:a}=e,[f,p]=s.useState(""),w=s.useId(),[b,C]=s.useState(null),g=s.useRef(null),u=s.useMemo(()=>t.filter(P=>P.hideable!==!1),[t]),h=u.every(P=>n.has(P.field)),x=s.useMemo(()=>{const P=a?t:u;if(!f)return P;const z=f.toLowerCase();return P.filter(F=>(F.headerName||F.field).toLowerCase().includes(z))},[t,u,f,a]),m=P=>{P.target.checked?r():i()},y=P=>z=>{g.current=P,z.dataTransfer.effectAllowed="move",z.dataTransfer.setDragImage(z.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},E=P=>z=>{z.preventDefault(),z.dataTransfer.dropEffect="move",P!==g.current&&C(P)},v=()=>{C(null)},M=P=>z=>{z.preventDefault();const F=g.current;C(null),g.current=null,F&&F!==P&&l&&l(F,P)},N=()=>{C(null),g.current=null};return c.jsxs("div",{className:"ogx-column-visibility-panel",children:[c.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:c.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[c.jsx(Eu,{}),c.jsx(ut,{autoComplete:"off",inputClassName:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:f,onChange:P=>p(P.target.value)})]})}),c.jsx("div",{className:"ogx-column-visibility-panel__list",children:x.map((P,z)=>{const F=`${w}-col-${z}`,$=n.has(P.field),_=P.hideable!==!1,T=b===P.field,O=!!l&&!f;return c.jsxs("div",{className:["ogx-column-visibility-panel__item",!_&&"ogx-column-visibility-panel__item--disabled",T&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:O,onDragOver:O?E(P.field):void 0,onDragLeave:O?v:void 0,onDrop:O?M(P.field):void 0,onDragEnd:O?N:void 0,children:[O&&c.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(P.field),title:"Drag to reorder",children:c.jsx(Mu,{})}),c.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:_?"pointer":"not-allowed"},children:[c.jsx(ct,{id:F,checked:$,onChange:S=>o(P.field,S.target.checked),disabled:!_}),c.jsx("label",{htmlFor:F,className:"ogx-column-visibility-panel__label",children:P.headerName||P.field})]})]},P.field)})}),c.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[c.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[c.jsx(ct,{id:`${w}-all`,checked:h,onChange:m}),c.jsx("label",{htmlFor:`${w}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),c.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),d?.()},children:"Reset"})]})]})}function Nu({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:d,onColumnMove:a,onColumnOrderReset:f,columnGroupingModel:p}){const[w,b]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const g=t.current.getBoundingClientRect();b({top:g.top+8,right:Wt()-g.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!w)return null;const C=i?void 0:(g,u)=>{Vo(p,g,u)&&a(g,u)};return xt.createPortal(c.jsxs("div",{ref:n,style:{position:"fixed",top:w.top,right:w.right,zIndex:9999,display:"inline-block"},children:[c.jsx("button",{type:"button",onClick:l,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:"×"}),c.jsx(Yo,{columns:o,visibleColumns:new Set(o.filter(g=>r[g.field]!==!1).map(g=>g.field)),onVisibilityChange:(g,u)=>{d({...r,[g]:u})},onShowAll:()=>{const g={...r};o.forEach(u=>{u.hideable!==!1&&(g[u.field]=!0)}),d(g)},onHideAll:()=>{const g={...r};o.forEach(u=>{u.hideable!==!1&&(g[u.field]=!1)}),d(g)},onColumnReorder:C,onColumnOrderReset:i?void 0:f})]}),w.target)}const _l=[];function Iu(e){const{isPivotActive:t}=e,n=t?_l:e.rowGroupingModel,o=e.treeData&&!t,r=o&&e.hasTreeDataPath,i=n.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:n,isTreeDataRequested:o,isTreeData:r,isRowGrouping:i,isHierarchyEnabled:r||i,hasGroupingColumn:e.hasGroupingColDef&&(i||r),pagination:e.pagination&&!i&&e.paginationMode!=="infinite",listView:e.listView&&e.hasListViewColumn}}function Pu(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,d=s.useMemo(()=>o?{...n,left:["__group__",...(n?.left??[]).filter(f=>f!=="__group__")]}:n,[o,n]);return{activeColumns:s.useMemo(()=>o?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:f})=>{const p=l(f);return p[p.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:d}}function Lu(e){return e.id}function Tu(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),n=s.useRef(t);s.useLayoutEffect(()=>{n.current=t});const o=s.useCallback(r=>n.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:o}}function Fu(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Au(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:d,dataRows:a}=e,f=t?.getVisibleRows({expandAll:!0,labelField:d});if(!f)return[...n,...o,...r];const p=a?new Set(a):null;return f.filter(w=>!i.get(l(w))?.isGroupRow&&(!p||p.has(w)))}function Du(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;const o=e,r=t;return n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(o[i],r[i]))}function Ou(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>Du(n,t[o]))}function $u(e){const[t,n]=s.useState(e),o=Ou(t,e);return o||n(e),o?t:e}function Gu(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:d}=e,a=Object.keys(i).length>0,f=new Map(r.map(C=>[C.field,C])),p=[],w=[],b=C=>{for(;w.length>0&&w[w.length-1].header.depth>=C;){const g=w.pop();a&&!d?.(g.id)&&p.push({type:"group-subtotal",depth:g.header.depth,groupField:g.header.groupField,groupValue:g.header.groupValue,groupLabel:g.header.groupLabel,aggregatedValues:Fn(g.leaves,i,f,"getGroupedExportRows")})}};for(const C of t){const g=n(C),u=o.get(g);if(!u?.isGroupFooter)if(u?.isGroupRow){const h=u.treeDepth??0;b(h);const x={type:"group-header",depth:h,groupField:u.groupingField,groupValue:u.groupingValue,groupLabel:u.groupLabel};p.push(x),w.push({id:g,header:x,leaves:[]})}else p.push({type:"leaf",depth:u?.treeDepth??w.length,row:C}),w.forEach(h=>h.leaves.push(C))}return b(0),a&&l&&p.push({type:"grand-total",depth:0,aggregatedValues:l}),p}function Wu(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=()=>n.current;t.current.getAggregationResult=()=>o().hasAggregation?o().aggregationResult:null,t.current.getAggregationModel=()=>o().hasAggregation?o().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:d,rowGroupingHandlers:a,rowMetaMap:f,columns:p,getRowId:w,hierarchyField:b}=o();return d?Gu({rows:a.getVisibleRows({expandAll:!0,labelField:b})??[],getRowId:w,rowMetaMap:f,columns:p,aggregationModel:l,aggregationResult:r&&a.rootAggregationPosition!==null?i:null,isSubtotalHidden:C=>a.aggregationPositions.get(C)===null}):null}},[t])}const Bu=new Set(["__group__","__check__","__actions__"]);function _t(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!Qe(t.field)&&!Bu.has(t.field))}function ft(e){return!!e&&e.length>0}function kl(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function xn(e,t,n){return ft(t)?kl(e,t,n):e}function bn(e,t){return!!e&&e.length>0&&!ft(t)}function Kt(e,t,n,o,r){if(!o)return null;if(!t||!r||Object.keys(r).length===0)return o;const i=new Map(n.map(l=>[l.field,l]));return Fn(e,r,i,"export")}function Cn(e,t){const n=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:n}):n}function yn(e,t,n){if(!t.valueFormatter)return ho(n,t);if(n==null)try{return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}function Jo(e,t,n,o){return n==null?"":An(n,t??"",e,o)}function Ut(e,t){return t?`${e}: ${t}`:e}function El(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const Hu=/^[=+\-@\t\r]/,zu=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function Un(e,t=!1){return t||!Hu.test(e)||zu.test(e)?e:`'${e}`}function gt(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Pe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Vu(e){let t=0,n=e.length;for(;t<n&&e[t]==="'";)t++;for(;n>t&&e[n-1]==="'";)n--;return e.slice(t,n)}const Ku=/[\\/?*:[\]]/g,Ml=31;function Zo(e,t=new Set){let n=Vu(String(e??"").replace(Ku,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,Ml).trim();const o=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=n;for(let i=2;o(r);i++){const l=` (${i})`;r=`${n.slice(0,Ml-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const Uu=new Set([st,fn,un]),ju=/[\t\n\r"]/;function Qo(e){return ju.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Ru(e){return _t(e).filter(t=>!Uu.has(t.field))}function qu(e,t){const n=t.map(r=>Qo(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>Qo(yn(r,i,ke(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
6
|
+
`)}function Xu(e,t){const n=ke(e,t.field,t);try{return yn(e,t,n)}catch{return n==null?"":String(n)}}function Yu(e,t,n){const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=e[r],l=new Array(t.length);for(let d=0;d<t.length;d++){const a=t[d];l[d]=n?.(i,a)?"":Qo(Xu(i,a))}o[r]=l.join(" ")}return o.join(`
|
|
7
|
+
`)}function Nl(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.getSelection(),o=[];if(n)for(let l=0;l<n.rangeCount;l++)o.push(n.getRangeAt(l));const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.setAttribute("aria-hidden","true"),r.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(r);let i=!1;try{r.focus({preventScroll:!0}),r.select(),i=document.execCommand("copy")}finally{document.body.removeChild(r),t&&t.isConnected&&t.focus({preventScroll:!0}),n&&(n.removeAllRanges(),o.forEach(l=>n.addRange(l)))}return i}async function er(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(n){if(Nl(e))return;throw n}if(!Nl(e))throw new Error("Clipboard API not available and fallback failed.")}function Ju(e){if(!(e.ctrlKey||e.metaKey)||e.altKey||e.shiftKey)return!1;const t=e.key??"";return t.toLowerCase()==="c"?!0:e.code==="KeyC"&&!/^[a-z]$/i.test(t)}function Zu(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const n=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:d}=t.current,a=new Set(r());if(a.size===0)return;const f=l().filter(w=>a.has(d(w)));if(f.length===0)return;const p=qu(f,Ru(i()));await er(p)},[]),o=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(o)return;const r=i=>{if(i.defaultPrevented||!Ju(i))return;const l=document.activeElement,d=l?.tagName.toLowerCase(),a=l?.type;if(d==="input"&&a!=="checkbox"&&a!=="radio"||d==="textarea"||d==="select"||l?.isContentEditable)return;const{getRootElement:f}=t.current;if(f){const C=f();if(!C||!l||!C.contains(l))return}const p=window.getSelection();if(p&&!p.isCollapsed&&p.toString()!=="")return;const{getShortcutText:w}=t.current;(w?()=>{const C=w();return C===null?Promise.resolve():er(C)}:n)().catch(C=>{console.error("[OpenGridX] Failed to copy to clipboard:",C)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n,o]),{copySelectedRows:n}}function Qu(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,d=s.useCallback(()=>r.current,[r]),{copySelectedRows:a}=Zu({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:d,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=a},[a,t])}function ef(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:o,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:d}=n.current,a=i.current;if(a&&(o!==void 0&&o>=0&&Tn(a,o,l.cumulativeHeights,l.pinnedBottomHeight,d),r!==void 0&&r>=0)){const p=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!p)return;bo(a,l.unpinnedColsWithWidth.findIndex(w=>w.field===p.field),l)}}},[t])}const tf=".ogx";function Il(e,t){const n=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const o=t.getBoundingClientRect().width;t.style.cssText=n;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,d)=>l+(parseFloat(d)||0),0);return o+i}function nf(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(tf)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${n}"]`).forEach(l=>{if(!o(l))return;const d=l.querySelector(".ogx__header-cell-content");d&&i(Il(l,d))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const d=l.querySelector(":scope > .ogx__cell-content");d&&i(Il(l,d))}),r===null?null:Math.ceil(r)}function of(e,t,n){return Math.max(t??$i,Math.min(n??1/0,e))}function rf(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:d,onColumnResize:a}=n.current,f=l.current;if(!f)return;const p=[];for(const w of i??d.map(b=>b.field)){const b=d.find(g=>g.field===w);if(!b||b.resizable===!1)continue;const C=nf(f,w);C!==null&&p.push([w,of(C,b.minWidth,b.maxWidth)])}for(const[w,b]of p)a(w,b)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}const Pl="ogx--range-dragging",pt=32,lf=40,sf=300;function Ll(e,t){if(!e||e.nodeType!==1)return null;const n=e.closest(".ogx__cell[data-field]");if(!n||n.closest(".ogx__viewport")!==t)return null;const o=n.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const r=n.closest('[role="row"][data-rowindex]');if(!r)return null;const i=Number(r.getAttribute("data-rowindex")),l=n.dataset.field;return!Number.isInteger(i)||!l?null:{rowIndex:i,field:l,element:n}}function tr(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const Tl=(e,t,n)=>Math.min(Math.max(e,t),n),jn=e=>Math.min(lf,Math.max(2,Math.round(e/2)));function af(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function cf(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:d,rowMetaMap:a,localeText:f,showStats:p}=e,w=t&&n.length>0?n[0]:null,b=s.useMemo(()=>t?i.filter(I=>je(I.field)):[],[t,i]),C=s.useMemo(()=>{if(!d.hasColSpan&&!d.hasRowSpan)return;const{colspanMap:I,rowSpanningCaches:D,getSpanOrigin:L}=d;return{getSpanOrigin:L,getColSpan:(A,V)=>{const R=I.get(A)?.[V];return R&&!R.spannedByColSpan?R.cellProps.colSpan:1},getRowSpan:(A,V)=>D.spannedCells[A]?.[V]??1}},[d]),g=s.useMemo(()=>{if(!t)return null;const I=o.map(r),D=new Map;I.forEach((A,V)=>{D.has(A)||D.set(A,V)});const L=b.map(A=>A.field);return{rowIds:I,rowIndexById:D,fields:L,colIndexByField:new Map(L.map((A,V)=>[A,V])),spans:C}},[t,o,r,b,C]),u=s.useMemo(()=>w&&g?$n(w,g):null,[w,g]),h=u!==null&&vt(u)>1,x=s.useMemo(()=>{if(!u||!h||!g)return null;const I=l.get(g.fields[u.left]),D=l.get(g.fields[u.right]);return I===void 0||D===void 0?null:{top:u.top,bottom:u.bottom,left:I,right:D}},[u,h,g,l]),m=s.useCallback(I=>Ue(I,a),[a]),y=s.useCallback((I,D,L)=>{if(g)for(let A=I.top;A<=I.bottom;A++){const V=o[A],R=g.rowIds[A];if(!(!V||m(R))){D(V,R);for(let B=I.left;B<=I.right;B++){const k=b[B],H=C?.getSpanOrigin(R,k.field);L(V,R,k,H!=null&&(H.rowId!==R||H.field!==k.field))}}}},[g,o,b,C,m]),E={...e,range:w,resolved:u,context:g,rangeColumns:b,forEachCell:y},v=s.useRef(E);s.useLayoutEffect(()=>{v.current=E});const M=s.useRef(null),N=s.useCallback(I=>{M.current=I},[]),P=s.useCallback(()=>{const{getPendingModel:I,model:D}=v.current;return I()??D},[]),z=s.useCallback(()=>{const{context:I,range:D,resolved:L,enabled:A}=v.current,V=A?P()[0]??null:null;return!V||!I?{range:null,resolved:null}:V===D?{range:V,resolved:L}:{range:V,resolved:$n(V,I)}},[P]),F=s.useCallback((I,D)=>{if(!v.current.enabled)return;const L=I.length>1?I.slice(0,1):I;ma(L,P())||v.current.onModelChange(L,D)},[P]),$=s.useCallback((I,D,L)=>{F([{anchor:I,head:D}],L)},[F]),_=s.useCallback((I,D)=>{const{viewportRef:L,layout:A,rowHeight:V,pinnedTopRowCount:R}=v.current,B=L.current;B&&(Tn(B,I-R,A.cumulativeHeights,A.pinnedBottomHeight,V),bo(B,A.unpinnedColsWithWidth.findIndex(k=>k.field===D),A))},[]),T=s.useCallback((I,D,L,A)=>{const{context:V}=v.current,{range:R,resolved:B}=z();if(!V||A.id===null||!je(A.field))return!1;const k=V.rowIndexById.get(A.id),H=V.colIndexByField.get(A.field);if(k===void 0||H===void 0)return!1;const X=R&&B&&at(R.anchor,{id:A.id,field:A.field})?{range:R,resolved:B}:null,ee=X?X.range.anchor:{id:A.id,field:A.field},ce=X?.resolved??$n({anchor:ee,head:ee},V);if(!ce)return!1;const pe=xa(ce,I,D,L,V.rowIds.length-1,V.fields.length-1);if(!pe)return!0;const me={id:V.rowIds[pe.row],field:V.fields[pe.col]};return $(ee,me,"keyboard"),_(pe.row,me.field),!0},[z,$,_]),O=s.useCallback(()=>{const{range:I,resolved:D}=z();return!I||!D||vt(D)<=1?!1:($(I.anchor,I.anchor,"keyboard"),!0)},[z,$]),S=s.useCallback(()=>{const{context:I}=v.current;return!I||I.rowIds.length===0||I.fields.length===0?!1:($({id:I.rowIds[0],field:I.fields[0]},{id:I.rowIds[I.rowIds.length-1],field:I.fields[I.fields.length-1]},"selectAll"),!0)},[$]),j=s.useCallback(()=>{const{context:I}=v.current,{range:D,resolved:L}=z();if(!I)return null;if(L)return L;if(D)return null;const A=M.current;return!A||A.id===null||!je(A.field)?null:$n({anchor:{id:A.id,field:A.field},head:{id:A.id,field:A.field}},I)},[z]),q=s.useCallback(()=>{const I=j();if(!I)return null;const{rangeColumns:D,forEachCell:L}=v.current,A=vt(I);A>va&&af(A);const V=[];if(L(I,X=>{V.push(X)},()=>{}),V.length===0)return null;const R=D.slice(I.left,I.right+1),B=v.current.context?.spans,k=v.current.getRowId;return Yu(V,R,B?(X,ee)=>{const ce=k(X),pe=B.getSpanOrigin(ce,ee.field);return pe!==null&&(pe.rowId!==ce||pe.field!==ee.field)}:void 0)},[j]),Z=s.useCallback(()=>{const{forEachCell:I}=v.current,{resolved:D}=z();if(!D)return[];const L=[];return I(D,()=>{},(A,V,R,B)=>{B||L.push({id:V,field:R.field,value:ke(A,R.field,R)})}),L},[z]),W=s.useRef(null),U=s.useRef(!1);s.useEffect(()=>()=>W.current?.stop(),[]);const Q=s.useCallback((I,D,L)=>{const A=v.current.context;if(!A)return null;const V=I.ownerDocument;if(typeof V.elementFromPoint!="function")return null;const R=Ll(V.elementFromPoint(D,L),I);if(!R)return null;const B=A.rowIds[R.rowIndex];if(B===void 0)return null;const k=je(R.field)?R.field:A.fields[0];return k===void 0?null:{id:B,field:k}},[]),ie=s.useCallback((I,D)=>{const{context:L,layout:A,pinnedTopRowCount:V}=v.current,R=A.cumulativeHeights;if(!L||R.length===0||I<0)return null;let B=0,k=R.length-1;for(;B<k;){const X=B+k>>1;R[X]>I?k=X:B=X+1}const H=L.rowIds[B+V];return H===void 0?null:{id:H,field:D}},[]),oe=s.useRef(()=>{}),ge=s.useCallback(I=>{const D=W.current,L=v.current.viewportRef.current;if(!D||!L)return;D.frame=0;const{layout:A}=v.current,V=L.getBoundingClientRect(),R=L.clientWidth,B=L.clientHeight,k=L.querySelector(":scope > .ogx__content > .ogx__sticky-top"),H=L.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),X=k?.querySelector(":scope > .ogx__header-wrap"),ee=k?k.getBoundingClientRect().bottom:V.top,ce=Math.min(V.top+B,H?H.getBoundingClientRect().top:V.top+B),pe=X?X.getBoundingClientRect().bottom:ee,me=V.left+A.pinnedSystemColumnsWidth+A.leftWidth,ye=V.left+R-A.rightWidth,_e=Tl(D.x,V.left+1,V.left+R-2);let Ce=D.y;(Ce<V.top||Ce>V.top+B||Ce<pe)&&(Ce=Tl(Ce,ee+1,Math.max(ee+1,ce-2)));const Ee=typeof L.ownerDocument.elementFromPoint=="function",be=Q(L,_e,Ce)??(Ee&&D.moved?ie(Ce-V.top-(k?k.getBoundingClientRect().height:0)+L.scrollTop,D.head.field):null);if(be&&!at(be,D.head)&&(D.head=be,!D.moved&&!at(be,D.anchor)&&(D.moved=!0,v.current.containerRef.current?.classList.add(Pl),tr(L.ownerDocument)),$(D.anchor,be,"pointer")),!I)return;const Me=D.y<ee||D.y>ce||D.x<V.left||D.x>V.left+R;if(!D.moved&&!Me)return;let ve=0,he=0;D.y<ee+pt?ve=-jn(ee+pt-D.y):D.y>ce-pt&&(ve=jn(D.y-(ce-pt))),D.x<me+pt?he=-jn(me+pt-D.x):D.x>ye-pt&&(he=jn(D.x-(ye-pt)));const fe=ve<0&&L.scrollTop>0||ve>0&&L.scrollTop+B<L.scrollHeight-1,we=he<0&&L.scrollLeft>0||he>0&&L.scrollLeft+R<L.scrollWidth-1;!fe&&!we||(fe&&(L.scrollTop+=ve),we&&(L.scrollLeft+=he),D.frame=requestAnimationFrame(()=>oe.current(!0)))},[Q,ie,$]);s.useLayoutEffect(()=>{oe.current=ge},[ge]);const le=s.useCallback((I,D,L,A,V)=>{W.current?.stop();const R=ee=>{const ce=W.current;if(ce){if(ee.buttons===0){ce.stop();return}ce.x=ee.clientX,ce.y=ee.clientY,ce.moved&&(ee.preventDefault(),tr(V)),ce.frame||(ce.frame=requestAnimationFrame(()=>ge(!0)))}},B=ee=>{const ce=W.current;if(!ce)return;ce.x=ee.clientX,ce.y=ee.clientY,ge(!1);const pe=ce.moved;ce.stop(),pe&&tr(V),pe&&(U.current=!0,setTimeout(()=>{U.current=!1},0))},k=V.defaultView,H=()=>W.current?.stop(),X={anchor:I,head:D,x:L,y:A,frame:0,moved:!1,stop:()=>{X.frame&&cancelAnimationFrame(X.frame),X.frame=0,V.removeEventListener("mousemove",R,!0),V.removeEventListener("mouseup",B,!0),k?.removeEventListener("blur",H),v.current.containerRef.current?.classList.remove(Pl),W.current===X&&(W.current=null)}};W.current=X,V.addEventListener("mousemove",R,!0),V.addEventListener("mouseup",B,!0),k?.addEventListener("blur",H)},[ge]),ue=s.useCallback(I=>{if(I.button!==0||I.defaultPrevented)return;const{context:D}=v.current;if(!D)return;const L=I.currentTarget,A=Ll(I.target,L);if(!A||!je(A.field)||A.element.classList.contains("ogx__cell--editing")||li(I.target))return;const V=D.rowIds[A.rowIndex];if(V===void 0)return;const R={id:V,field:A.field};let B=R;if(I.shiftKey){const k=P()[0],H=M.current;k&&D.rowIndexById.has(k.anchor.id)&&D.colIndexByField.has(k.anchor.field)?B=k.anchor:H&&H.id!==null&&je(H.field)&&(B={id:H.id,field:H.field}),I.preventDefault(),U.current=!0;const X=L.ownerDocument;L.contains(X.activeElement)||L.focus({preventScroll:!0})}if($(B,R,"pointer"),le(B,R,I.clientX,I.clientY,L.ownerDocument),I.shiftKey){const k=W.current;k&&!at(B,R)&&(k.moved=!0)}},[P,$,le]),te=s.useCallback(I=>{U.current&&(U.current=!1,I.stopPropagation(),I.preventDefault())},[]),ae=u?u.right-u.left+1:0,Y=u?u.bottom-u.top+1:0,re=f?.cellSelectionAnnouncement??ya,K=h?re(Y*ae,Y,ae):"",[J,ne]=s.useState("");s.useEffect(()=>{if(!t)return;const I=setTimeout(()=>ne(K),sf);return()=>clearTimeout(I)},[t,K]);const de=s.useMemo(()=>{if(!p||!u||!h)return null;const I=[];y(u,()=>{},(L,A,V,R)=>{R||I.push(ke(L,V.field,V))});const D=I.filter(L=>typeof L=="number"&&!Number.isNaN(L));return{cellCount:vt(u),rowCount:u.bottom-u.top+1,columnCount:u.right-u.left+1,count:yt.count(I),numericCount:D.length,sum:D.length?yt.sum(D):null,average:D.length?yt.avg(D):null}},[p,u,h,y]),G=s.useMemo(()=>t?{extendSelection:T,collapseSelection:O,selectAllCells:S}:void 0,[t,T,O,S]);return{enabled:t,range:w,resolved:u,displayRange:x,hasRowSpan:d.hasRowSpan,handleMouseDown:t?ue:void 0,handleClickCapture:t?te:void 0,extendSelection:T,collapseSelection:O,selectAllCells:S,keyboard:G,getCopyText:q,getSelectedCells:Z,announcement:t?J:"",stats:de,reportFocus:N,setModel:F,getCurrentRange:z}}function df(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useRef(null),r=s.useRef(null),i=s.useRef(null),{selection:l,model:d,focusedCell:a,setFocusedCell:f,containerRef:p}=e,w=l.range?.anchor??null,b=l.resolved?.anchorRow;s.useLayoutEffect(()=>{l.reportFocus(a);const C=!at(o.current,w),g=!Fo(r.current,a);if(o.current=w,r.current=a,!!l.enabled){if(l.range&&!l.resolved){i.current!==d&&(i.current=d,l.setModel([],"dataChange"));return}if(C&&w){(!a||a.id!==w.id||a.field!==w.field)&&f({id:w.id,field:w.field,rowIndex:b});return}if(g&&a&&a.id!==null&&je(a.field)&&!at(w,{id:a.id,field:a.field})){const u={id:a.id,field:a.field},h=p.current?.classList.contains("ogx--kb")??!1;l.setModel([{anchor:u,head:u}],h?"keyboard":"pointer")}}},[l,d,w,b,a,f,p]),s.useLayoutEffect(()=>{const C=t.current,g=()=>n.current;C.getCellSelectionModel=()=>{const{selection:u,getPendingModel:h,model:x}=g();return u.enabled?h()??x:[]},C.setCellSelectionModel=u=>{g().selection.setModel(u,"api")},C.selectCellRange=(u,h)=>{g().selection.setModel([{anchor:u,head:h}],"api")},C.clearCellSelection=()=>{g().selection.setModel([],"clear")},C.getSelectedCells=()=>g().selection.getSelectedCells(),C.copySelectedCells=async()=>{const{selection:u}=g();if(!u.enabled)return;const h=u.getCopyText();h!==null&&await er(h)}},[t])}function Fl({count:e,sum:t,average:n}){return c.jsxs("div",{className:"ogx__cell-selection-stats",children:[c.jsxs("span",{className:"ogx__cell-selection-stat",children:[c.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Count"}),c.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"count",children:e.toLocaleString()})]}),t!==null&&c.jsxs("span",{className:"ogx__cell-selection-stat",children:[c.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Sum"}),c.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:an(t,"sum")})]}),n!==null&&c.jsxs("span",{className:"ogx__cell-selection-stat",children:[c.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Average"}),c.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:an(n,"avg")})]})]})}function uf({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??Fl;return c.jsx("div",{className:"ogx__cell-selection-stats-area","aria-hidden":e?void 0:!0,children:e&&c.jsx(r,{apiRef:t,...e,...o})})}function ff(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function gf(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(a=>{t(),n(!1),o({id:r(a.row),field:a.field,rowIndex:a.rowIndex}),i?.(a)},[i,n,o,t,r]),d=s.useCallback(a=>{t(),o({id:null,field:a}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:d}}function pf({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:d}){const a=e||jo;return c.jsx(a,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:f=>l({...o,page:f}),onPageSizeChange:f=>l({...o,pageSize:f,page:0}),localeText:bi(d),...t})}function hf({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l}){return c.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${Di(t)}`:"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:""),l?c.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null]})}function mf(e){const{headerRowCount:t,pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+n+i+o,topBase:t+1,centerOffset:t+l+1,bottomBase:t+n+i+1,bottomRowIndexOffset:n+r}}function wf(e){const{columnGroupingModel:t,pinnedTopCount:n,pinnedBottomCount:o,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:d,paginatedUnpinnedRowCount:a,sortedUnpinnedRowCount:f}=e,{page:p,pageSize:w}=l;return s.useMemo(()=>mf({headerRowCount:1+Gi(t),pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r?a:f,totalCenterRowCount:r&&i==="server"?Math.max(d,a):f,pageOffset:r?p*w:0}),[t,n,o,r,a,f,i,d,p,w])}function xf(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,pivotMode:a,pivotModelProp:f,onPivotModelChangeProp:p,pivotModel:w,onPivotModelChange:b,filterModel:C,onFilterModelChange:g,columnVisibilityModel:u,onColumnVisibilityModelChange:h,disableColumnReorder:x,columnGroupingModel:m,moveColumn:y,resetColumnOrder:E,forceColumnsOpen:v,onColumnsPanelClose:M}=e;return s.useMemo(()=>t?{apiRef:o,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,...a||f||p?{pivotModel:w,onPivotModelChange:b}:{},filterModel:C,onFilterModelChange:g,columnVisibilityModel:u,onColumnVisibilityModelChange:h,onColumnReorder:x?void 0:(P,z)=>{Vo(m,P,z)&&y(P,z)},onColumnOrderReset:x?void 0:E,forceColumnsOpen:v,onColumnsPanelClose:M,...n}:null,[t,x,y,E,r,o,i,l,d,a,f,p,w,b,C,g,u,h,v,M,n,m])}function bf(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,autoHeight:d=!1,density:a,checkboxSelection:f=!1,disableRowSelectionOnClick:p=!1,disableMultipleRowSelection:w=!1,disableClipboardCopy:b=!1,cellSelection:C=!1,cellSelectionModel:g,onCellSelectionModelChange:u,showCellSelectionStats:h=!1,disableClipboardPaste:x=!1,disableRangeClear:m=!1,onClipboardPaste:y,onBeforeClipboardPaste:E,undoRedo:v=!1,onHistoryChange:M,rowSelectionModel:N,onRowSelectionModelChange:P,onRowClick:z,onRowDoubleClick:F,onCellClick:$,filterModel:_,onFilterModelChange:T,sortModel:O,onSortModelChange:S,pagination:j=!1,paginationModel:q,onPaginationModelChange:Z,pageSizeOptions:W=[10,25,50,100],pinnedColumns:U,onPinnedColumnsChange:Q,pinnedRows:ie,getDetailPanelContent:oe,getDetailPanelHeight:ge,detailPanelExpandedRowIds:le,onDetailPanelExpandedRowIdsChange:ue,pinCheckboxColumn:te=!0,pinExpandColumn:ae=!0,disableColumnReorder:Y=!1,columnOrder:re,onColumnOrderChange:K,onColumnOrderModelChange:J,height:ne,rowReordering:de=!1,onRowOrderChange:G,loading:I=!1,treeData:D=!1,getTreeDataPath:L,defaultGroupingExpansionDepth:A,groupingColDef:V,rowGroupingModel:R,aggregationModel:B,onAggregationModelChange:k,getAggregationPosition:H,isCellEditable:X,processRowUpdate:ee,onProcessRowUpdateError:ce,dataSource:pe,multiSort:me=!1,sortingMode:ye="client",filterMode:_e="client",paginationMode:Ce="client",rowCount:Ee,slots:se,slotProps:be,pivotMode:Me=!1,pivotModel:ve,onPivotModelChange:he,className:fe="",style:we,onRowsScrollEnd:Se,ariaLabel:Ne,initialState:tt,onStateChange:$e,columnVisibilityModel:Ve,onColumnVisibilityModelChange:Yt,listView:Ge=!1,listViewColumn:kt,columnGroupingModel:Et,noRowsLabel:Yn="No Data",localeText:Mt,apiRef:rr,overscanRowCount:$g=3}=e,ir=$u(n),lr=Mt?.noRowsLabel??Yn,as=R||_l,Nt=Ia({initialState:tt,sortModel:O,onSortModelChange:S,filterModel:_,onFilterModelChange:T,aggregationModel:B,onAggregationModelChange:k,columnVisibilityModel:Ve,onColumnVisibilityModelChange:Yt,pinnedColumns:U,onPinnedColumnsChange:Q,pivotModel:ve,onPivotModelChange:he,paginationModel:q,onPaginationModelChange:Z,pageSizeOptions:W,rowSelectionModel:N,onRowSelectionModelChange:P,density:a,cellSelectionModel:g,onCellSelectionModelChange:u}),{sortModel:nt,handleSortModelChange:cs,filterModel:ht,handleFilterModelChange:ds,aggregationModel:Ke,handleAggregationModelChange:Gg,columnVisibilityModel:It,handleColumnVisibilityModelChange:sr,pinnedColumns:ar,handlePinnedColumnsChange:Wg,currentPivotModel:us,handlePivotModelChange:Bg,effectivePaginationModel:He,handlePaginationModelChange:Jt,selectedRowIds:Hg,handleRowSelectionModelChange:cr,density:fs}=Nt,kn=tu({rows:t,columns:ir,pivotMode:Me,pivotModel:us,filterModel:ht,sortModel:nt,hasDataSource:!!pe,hierarchyRequested:D||as.length>0}),Pt=kn.isActive,{rowReordering:Lt,hierarchyRowGroupingModel:zg,isTreeDataRequested:Vg,isTreeData:Jn,isRowGrouping:Zt,isHierarchyEnabled:Zn,hasGroupingColumn:Kg,pagination:qe,listView:Qt}=Iu({rowGroupingModel:as,treeData:D,hasTreeDataPath:!!L,isPivotActive:Pt,rowReordering:de,hasGroupingColDef:!!V,pagination:j,paginationMode:Ce,listView:Ge,hasListViewColumn:!!kt}),{rowHeight:Xe,headerHeight:dr}=Aa({rowHeight:r,headerHeight:i,density:fs}),Ug=kn.rows,jg=kn.columns,{activeColumns:mt,effectivePinnedColumns:en}=Pu({baseColumns:jg,pinnedColumns:ar,hasGroupingColumn:Kg,groupingColDef:V,isTreeData:Jn,getTreeDataPath:L}),ur=mc(mt,It),[Rg,qg]=Zd(Ke),Ye=s.useRef(null),tn=s.useRef(null),gs=!Pt&&o||Lu,fr=ff(Ye),Qn=Yc({rows:Ug,getRowId:gs,columns:mt,rowHeight:Xe,headerHeight:dr,columnVisibilityModel:It,initialState:e.initialState,syncRows:!pe}),{state:Le,apiRef:ot,setRows:Xg,replaceRows:Yg,setColumns:Jg,setDimensions:Zg,setDataSourceLoading:Qg,setDataSourceError:ep,setRowCount:tp}=Qn,{getRowIdOf:Ie,getRowIdOfInEvents:np}=Tu(Le.rows.idByRow);Fu(rr,ot);const op=Le.dataSource.loading,wt=I||op,eo=s.useMemo(()=>Le.rows.allRows.map(it=>Le.rows.idRowsLookup.get(it)),[Le.rows]),{treeDataHandlers:to,rowGroupingHandlers:gr,activeHierarchyHandlers:nn,rowMetaMap:ze}=gd({rows:eo,getRowId:Ie,getTreeDataPath:L,isTreeDataRequested:Vg,isTreeData:Jn,columns:mt,rowGroupingModel:zg,isRowGrouping:Zt,aggregationModel:Ke,defaultGroupingExpansionDepth:A,filterModel:ht,sortModel:nt,getAggregationPosition:H,columnLookup:ur,filterMode:_e,sortingMode:ye}),pr=Od(),hr=hd({rowsLookup:Le.rows.idRowsLookup,columns:mt,processRowUpdate:ee,onProcessRowUpdateError:ce,replaceRows:Yg,onCommitted:pr.emit}),no=pd({rows:eo,getRowId:Ie,columns:mt,processRowUpdate:ee,onProcessRowUpdateError:ce,onRowChange:(it,Lp)=>{hr.storeRow(Lp,it)},onCommitted:it=>pr.emit(it,"edit")}),En=fc({selectedRowIds:Hg,rowsLookup:Le.rows.idRowsLookup,rowMetaMap:ze,enabled:!pe&&!Pt&&Ce==="client"&&_e==="client",onSelectionModelChange:cr}),ps=Xd({dataSource:pe,sortModel:nt,filterModel:ht,paginationModel:He,paginationMode:Ce,sortingMode:ye,filterMode:_e,aggregationModel:Ke,rowGroupingActive:Zt,getRowId:gs,setRows:Xg,setRowCount:tp,setDataSourceLoading:Qg,setDataSourceError:ep,onAggregationResults:qg,onPaginationModelChange:Jt});Jd({enabled:Jn&&!!pe,treeNodes:to.treeNodes,isGroupExpanded:to.isGroupExpanded,getNodePath:to.getNodePath,toggleExpansion:to.toggleExpansion,fetchChildren:ps.fetchChildren});const{hasDetailPanel:Tt,expandedRowIds:mr,handleDetailPanelToggle:hs,detailPanelHeights:rp,reportDetailPanelHeight:ip}=Qa({hasDetailPanel:!!oe,controlledExpandedRowIds:le,onDetailPanelExpandedRowIdsChange:ue,rowMetaMap:ze}),{effectiveColumns:ms,hierarchyField:wr,orderedColumns:xr,visibleOrderedColumns:ws,renderOrderedColumns:lp,navigationColumns:Mn,columnIndexMap:br,columnWidths:Nn,effectiveColumnOrder:sp,columnReorderHandlers:ap,moveColumn:xs,resetColumnOrder:bs,handleColumnResize:Cs}=Ka({activeColumns:mt,isHierarchyEnabled:Zn,isRowGrouping:Zt,isTreeData:Jn,activeHierarchyHandlers:nn,columnVisibilityModel:It,columnOrder:re,onColumnOrderChange:K,onColumnOrderModelChange:J,disableColumnReorder:Y,pivotMode:Pt,checkboxSelection:f,hasDetailPanel:Tt,rowReordering:Lt,initialState:tt,setColumns:Jg,pinnedColumns:en,getRowId:np,aggregationModel:Ke,groupingRows:Zt?gr.groupingRows:void 0});nc({onStateChange:$e,sortModel:nt,filterModel:ht,effectivePaginationModel:He,columnWidths:Nn,effectiveColumnOrder:sp,columnVisibilityModel:It,pinnedColumns:ar,density:fs});const oo=Oa({effectiveRows:eo,activeHierarchyHandlers:nn,filterMode:_e,filterModel:kn.pipelineFilterModel,sortModel:kn.pipelineSortModel,sortingMode:ye,pagination:qe,paginationMode:Ce,effectivePaginationModel:He,pinnedRows:ie,getRowId:Ie,columnLookup:ur,hierarchyField:wr}),{filteredRows:ys,dataRows:on,pinnedTopRows:We,pinnedBottomRows:Je,sortedUnpinnedRows:rt,paginatedUnpinnedRows:ro,allRenderableRows:Ft}=oo,Cr=qe?ro:rt;wc({paginationModel:He,currentPage:oo.currentPage,enabled:qe&&!wt&&rt.length>0,onPaginationModelChange:Jt});const io=Da({paginationMode:Ce,hasDataSource:!!pe,dataSourceRowCount:Le.pagination.rowCount,rowCountProp:Ee,clientRowCount:rt.length}),{rowSelection:yr,handleRowClick:vr,handleSelectionChange:Sr}=uc({dataRows:on,getRowId:Ie,isPivotActive:Pt,selectedRowIds:En,onSelectionModelChange:cr,disableMultipleRowSelection:w,disableRowSelectionOnClick:p,isHierarchyEnabled:Zn,rowMetaMap:ze,activeHierarchyHandlers:nn,onRowClick:z});hc({apiRef:Qn.apiRef,sortModel:nt,multiSort:me,onSortModelChange:cs,filterModel:ht,onFilterModelChange:ds,paginationModel:He,onPaginationModelChange:Jt,selectedRowIds:En,getPendingRowSelectionModel:Nt.getPendingRowSelectionModel,onRowSelectionModelChange:cr,disableMultipleRowSelection:w,isSyntheticRowId:it=>Ue(it,ze),getVisibleRows:()=>[...We,...Cr,...Je],getAllFilteredRows:()=>Au({hierarchyHandlers:nn,pinnedTopRows:We,sortedUnpinnedRows:rt,pinnedBottomRows:Je,rowMetaMap:ze,getRowId:Ie,hierarchyField:wr,dataRows:on}),visibleColumns:lp});const cp=Jc({rows:eo,getRowId:Ie,onRowOrderChange:G,rowReordering:Lt}),{aggregationResult:_r,isLoading:dp}=xl({rows:on,columns:mt,aggregationModel:Pt?zs:Ke,isServerSide:Fi({dataSource:pe,paginationMode:Ce,sortingMode:ye,filterMode:_e}),dataSource:pe,filterModel:ht,sortModel:nt,serverAggregationResults:Rg}),kr=Object.keys(Ke).length>0&&!Pt;Wu({apiRef:ot,hasAggregation:kr,aggregationResult:_r,aggregationModel:Ke,isRowGrouping:Zt,rowGroupingHandlers:gr,rowMetaMap:ze,columns:mt,getRowId:Ie,hierarchyField:wr});const Te=Bs({rowHeight:Xe,pagination:qe,paginatedUnpinnedRows:ro,sortedUnpinnedRows:rt,expandedRowIds:mr,getDetailPanelHeight:ge,detailPanelHeights:rp,pinnedTopRowsLength:We.length,pinnedBottomRowsLength:Je.length,pinnedTopRows:We,pinnedBottomRows:Je,visibleOrderedColumns:ws,pinnedColumns:en,columnWidths:Nn,viewportWidth:Le.dimensions.viewportWidth||1e3,checkboxSelection:f,hasDetailPanel:Tt,rowReordering:Lt,pinCheckboxColumn:te,pinExpandColumn:ae,paginationMode:Ce,isLoading:Le.dataSource.loading,pageSize:He.pageSize,getRowId:Ie}),At=zd({pinnedTopRows:We,centerRows:Cr,pinnedBottomRows:Je,columns:ws,leftPinnedColumns:Te.leftPinnedCols,unpinnedColumns:Te.unpinnedColsWithWidth,rightPinnedColumns:Te.rightPinnedCols,expandedRowIds:Tt?mr:void 0,rowMetaMap:ze,getRowId:Ie}),vs=s.useMemo(()=>[...Te.leftPinnedCols,...Te.unpinnedColsWithWidth,...Te.rightPinnedCols],[Te.leftPinnedCols,Te.unpinnedColsWithWidth,Te.rightPinnedCols]),Ae=cf({enabled:C&&!Qt,model:Nt.cellSelectionModel,onModelChange:Nt.handleCellSelectionModelChange,getPendingModel:Nt.getPendingCellSelectionModel,allRenderableRows:Ft,getRowId:Ie,navigationColumns:Mn,columnIndexMap:br,spanning:At,rowMetaMap:ze,layout:Te,rowHeight:Xe,pinnedTopRowCount:We.length,viewportRef:tn,containerRef:Ye,localeText:Mt,showStats:h});Qu({apiRef:ot,columns:vs,getRowId:Ie,containerRef:Ye,disableKeyboardShortcut:b,getCellRangeCopyText:Ae.enabled?Ae.getCopyText:void 0}),ef({apiRef:ot,viewportRef:tn,layout:Te,rowHeight:Xe});const up=rf({apiRef:ot,containerRef:Ye,columns:xr,onColumnResize:Cs}),{scrollTop:fp,scrollLeft:gp,overscanRows:pp,handleScroll:hp,setViewportElement:mp}=Ja({onRowsScrollEnd:Se,overscanRowCount:$g,rowCount:Te.unpinnedRowsLength,autoHeight:d,setDimensions:Zg,viewportRef:tn}),De=$a({layout:Te,scrollTop:fp,scrollLeft:gp,viewportWidth:Le.dimensions.viewportWidth,viewportHeight:Le.dimensions.viewportHeight,autoHeight:d,rowReordering:Lt,hasDetailPanel:Tt,checkboxSelection:f,pinCheckboxColumn:te,pinExpandColumn:ae,overscanRows:pp}),{handleSort:Ss,handleSortAdd:_s}=gc({sortModel:nt,onSortModelChange:cs}),lo=f||!p,{focusedCell:so,setFocusedCell:Er,viewportTabIndex:wp,ensureGridFocus:xp,handleFocus:bp,handleBlur:Cp,handleKeyDown:yp,handleMouseDownCapture:vp}=ka({allRenderableRows:Ft,navigationColumns:Mn,checkboxSelection:f,selectedRowIds:En,handleSelectionChange:Sr,handleDetailPanelToggle:hs,editingHandlers:no,setKeyboardMode:fr,sortModel:nt,handleSort:Ss,handleSortAdd:_s,multiSort:me,isCellEditable:X,pagination:qe,pageSize:He.pageSize,virtualization:De,viewportRef:tn,pinnedTopRowCount:We.length,getRowId:Ie,rowMetaMap:ze,getSpanOrigin:At.getSpanOrigin,onRowActivate:vr,toggleRowExpansion:nn?.toggleExpansion,handleSelectAll:yr.selectAll,rowSelectionEnabled:lo,multipleRowSelectionEnabled:!w,pinCheckboxColumn:te,pinExpandColumn:ae,rowHeight:Xe,cellSelection:Ae.keyboard}),{handleCellClick:Sp,handleHeaderClick:_p}=gf({ensureGridFocus:xp,setKeyboardMode:fr,setFocusedCell:Er,getRowId:Ie,onCellClick:$});df({apiRef:ot,selection:Ae,model:Nt.cellSelectionModel,getPendingModel:Nt.getPendingCellSelectionModel,focusedCell:so,setFocusedCell:Er,containerRef:Ye}),Ad({apiRef:ot,containerRef:Ye,viewportRef:tn,selection:Ae,disableClipboardPaste:x,disableRangeClear:m,focusedCell:so,allRenderableRows:Ft,getRowId:Ie,navigationColumns:Mn,isCellEditable:X,rowMetaMap:ze,getSpanOrigin:At.getSpanOrigin,isEditing:no.editingCell!==null,batchEdit:hr,onClipboardPaste:y,onBeforeClipboardPaste:E}),Gd({apiRef:ot,enabled:!!v,limit:typeof v=="object"&&v.limit||Dd,onHistoryChange:M,channel:pr,batchEdit:hr,isEditing:no.editingCell!==null,containerRef:Ye,viewportRef:tn,selection:Ae,setFocusedCell:Er,allRenderableRows:Ft,getRowId:Ie,navigationColumns:Mn,layout:Te,rowHeight:Xe,pinnedTopRowCount:We.length});const{handleHideColumn:kp,handlePinColumn:Ep}=pc({columnVisibilityModel:It,onColumnVisibilityModelChange:sr,pinnedColumns:ar,onPinnedColumnsChange:Wg}),In=wf({columnGroupingModel:Et,pinnedTopCount:We.length,pinnedBottomCount:Je.length,pagination:qe,paginationMode:Ce,paginationModel:He,paginationRowCount:io,paginatedUnpinnedRowCount:ro.length,sortedUnpinnedRowCount:rt.length}),Mr=Kd({spanning:At,renderContext:De.renderContext,offsetTop:De.offsetTop,cumulativeHeights:Te.cumulativeHeights}),Nr=ja({renderContext:Mr.renderContext,pinnedTopRows:We,pinnedBottomRows:Je,paginatedUnpinnedRows:ro,sortedUnpinnedRows:rt,pagination:qe,getRowId:Ie}),ao=Ud({spanning:At,firstColumnIndex:De.renderContext.firstColumnIndex,lastColumnIndex:De.renderContext.lastColumnIndex,virtualColumns:De.virtualColumns,layout:Te,rows:Nr});lc({paginationRequested:j,isRowGrouping:Zt,autoHeight:d,viewportHeight:Le.dimensions.viewportHeight,renderedRowCount:Nr.length,totalRowCount:We.length+Cr.length+Je.length,pinnedRowsIgnored:Zn&&!!(ie?.top?.length||ie?.bottom?.length),scrollHeight:De.totalHeight,listViewWithoutColumn:Ge&&!kt,listViewRowCount:Qt&&kt?Ft.length:0});const{allSelected:Mp,someSelected:Np}=yr,rn=jd(Et,ap),Ip=s.useMemo(()=>ms.some(it=>!!it.rowSpan),[ms]),Dt=xc();ac(Ye);const ks=se?.noRowsOverlay,Es=se?.loadingOverlay,Ir=Es?c.jsx(Es,{...be?.loadingOverlay}):void 0,Ms=ks?c.jsx(ks,{...be?.noRowsOverlay}):void 0,co=se?.footer,Pp=wt&&Ft.length>0&&Ce!=="infinite",Ns=se?.toolbar,Is=xf({toolbar:se?.toolbar,toolbarSlotProps:be?.toolbar,apiRef:ot,orderedColumns:xr,baseColumns:ir,aggregationModel:Ke,onAggregationModelChange:Gg,pivotMode:Me,pivotModelProp:ve,onPivotModelChangeProp:he,pivotModel:us,onPivotModelChange:Bg,filterModel:ht,onFilterModelChange:ds,columnVisibilityModel:It,onColumnVisibilityModelChange:sr,disableColumnReorder:Y,columnGroupingModel:Et,moveColumn:xs,resetColumnOrder:bs,forceColumnsOpen:Dt.toolbarPanelRequested,onColumnsPanelClose:Dt.closeToolbarPanel}),Pr={rowReordering:Lt,columnIndexMap:br,editingHandlers:no,isCellEditable:X,selectedRowIds:En,checkboxSelection:f,onRowClick:vr,onRowDoubleClick:F,onCellClick:Sp,onSelectionChange:Sr,columnWidths:Nn,pinnedColumns:en,hasDetailPanel:Tt,expandedRowIds:mr,getDetailPanelContent:oe,getDetailPanelHeight:ge,onDetailPanelToggle:hs,onDetailPanelHeightChange:ip,pinCheckboxColumn:te,pinExpandColumn:ae,focusedCell:so,colspanMap:At.colspanMap,rowSpanningCaches:At.rowSpanningCaches,rowHeight:Xe,rowMetaMap:ze,cellRange:Ae.displayRange,cellRangeHasRowSpan:Ae.hasRowSpan};return c.jsxs("div",{ref:Ye,className:["ogx",fe,d&&"ogx--auto-height",!d&&ne===void 0&&we?.height===void 0&&"ogx--fill",Ip&&"ogx--row-spanning",Qt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...we,height:ne??we?.height,"--ogx-row-height":`${Xe}px`,"--ogx-header-height":`${dr}px`},"aria-busy":wt,children:[Ns&&Is&&c.jsx(Li.Provider,{value:Dt.toolbarHost,children:c.jsx(yc,{component:Ns,toolbarProps:Is})}),c.jsx(Nu,{isOpen:Dt.standalonePanelOpen,containerRef:Ye,panelRef:Dt.standalonePanelRef,columns:xr,columnVisibilityModel:It,disableColumnReorder:Y,onClose:Dt.closeStandalonePanel,onColumnVisibilityChange:sr,onColumnMove:xs,onColumnOrderReset:bs,columnGroupingModel:Et}),Qt&&kt&&c.jsx(iu,{ariaLabel:Ne,allRenderableRows:Ft,dataRowCount:on.length,pinnedTopRowCount:We.length,pinnedBottomRowCount:Je.length,unpinnedRowCount:rt.length,pagination:qe,effectivePaginationModel:He,currentPage:oo.currentPage,pageSizeOptions:W,selectedRowIds:En,listViewColumn:kt,columnsByField:ur.byField,rowMetaMap:ze,noRowsLabel:lr,rowHeight:Xe,checkboxSelection:f,paginationMode:Ce,serverRowCount:io,paginationSlot:se?.pagination,paginationSlotProps:be?.pagination,localeText:bi(Mt),onRowClick:vr,onRowDoubleClick:F,onSelectionChange:Sr,onPaginationModelChange:Jt,onRowsScrollEnd:Se,getRowId:Ie,multiselectable:lo&&!w,selectable:lo,onToggleExpansion:nn?.toggleExpansion,loading:wt,loadingOverlay:Ir,noRowsOverlay:Ms,showPaginationControls:!co}),!Qt&&c.jsx("div",{ref:mp,className:"ogx__viewport",onScroll:hp,role:"grid","aria-label":Ne||"Data grid","aria-rowcount":In.rowCount,"aria-colcount":Mn.length,"aria-multiselectable":lo&&!w||Ae.enabled,"aria-busy":wt,tabIndex:wp,onKeyDownCapture:()=>{fr(!0)},onMouseDownCapture:vp,onMouseDown:Ae.handleMouseDown,onClickCapture:Ae.handleClickCapture,onKeyDown:yp,onFocus:bp,onBlur:Cp,children:c.jsxs("div",{className:"ogx__content",style:{width:en?.right?.length?`max(100%, ${De.totalWidth}px)`:De.totalWidth},role:"presentation",children:[c.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[c.jsx(Hi,{columns:ao,allColumns:vs,columnGroupingModel:Et,checkboxSelection:f,allSelected:Mp,someSelected:Np,onSelectAll:yr.selectAll,sortModel:nt,onSort:Ss,onSortAdd:_s,multiSort:me,onColumnResize:Cs,onColumnAutosize:up,columnWidths:Nn,pinnedColumns:en,focusedCell:so,columnIndexMap:br,onHeaderClick:_p,onDragStart:rn.onDragStart,onDragOver:rn.onDragOver,onDragEnd:rn.onDragEnd,onDrop:rn.onDrop,draggedColumn:rn.draggedColumn,dragOverColumn:rn.dragOverColumn,rowReordering:Lt,hasDetailPanel:Tt,pinCheckboxColumn:te,pinExpandColumn:ae,aggregationModel:Ke,onHideColumn:kp,onManageColumns:Dt.openColumnsPanel,onPinColumn:Ep,wrapHeaderText:l,headerHeight:dr}),c.jsx(Sl,{...Pr,rows:We,position:"top",ariaRowIndexBase:In.topBase,columns:ao,pinnedRows:ie,getRowId:Ie})]}),!wt&&!Le.dataSource.error&&ys.length===0&&c.jsx(Sc,{noRowsLabel:lr,width:De.totalWidth,overlay:Ms}),c.jsx(ku,{...Pr,virtualContainerHeight:De.totalHeight-De.pinnedTopHeight-De.pinnedBottomHeight,offsetTop:Mr.offsetTop,effectiveLoading:wt,visibleRows:Nr,baseColumns:ir,virtualColumns:ao,viewportWidth:Le.dimensions.viewportWidth,rowReorderHandlers:cp,paginationMode:Ce,dataSourceLoading:Le.dataSource.loading,sortedUnpinnedRowCount:rt.length,infiniteScrollSkeletonCount:Math.min(He.pageSize,20),unpinnedRowsLength:Te.unpinnedRowsLength,lastRenderedRowIndex:Mr.renderContext.lastRowIndex,ariaRowIndexOffset:In.centerOffset,loadingOverlay:Ir}),c.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[c.jsx(Sl,{...Pr,rows:Je,position:"bottom",rowIndexOffset:In.bottomRowIndexOffset,ariaRowIndexBase:In.bottomBase,columns:ao,pinnedRows:ie,getRowId:Ie}),kr&&gr.rootAggregationPosition!==null&&c.jsx(vc,{columns:De.virtualColumns,aggregationModel:Ke,aggregationResult:_r,columnWidths:Nn,rowHeight:Xe,checkboxSelection:f,hasDetailPanel:Tt,rowReordering:Lt,pinCheckboxColumn:te,pinExpandColumn:ae,pinnedColumns:en,loading:dp})]})]})}),Ae.enabled&&h&&c.jsx(uf,{stats:Ae.stats,apiRef:Qn.apiRef,slot:se?.cellSelectionStats,slotProps:be?.cellSelectionStats}),co&&c.jsx(co,{apiRef:Qn.apiRef,aggregationModel:Ke,aggregationResult:kr?_r:null,rowCount:Zn&&Ce!=="server"?on.length:io,pagination:qe,paginationModel:He,pageSizeOptions:W,onPaginationModelChange:Jt,...be?.footer}),!Qt&&!co&&qe&&c.jsx(pf,{paginationSlot:se?.pagination,paginationSlotProps:be?.pagination,page:oo.currentPage,paginationModel:He,rowCount:io,pageSizeOptions:W,onPaginationModelChange:Jt,localeText:Mt}),c.jsx(hf,{loading:wt,error:Le.dataSource.error,noRowsLabel:lr,filteredRowCount:ys.length,dataRowCount:on.length,filterModel:ht,cellSelectionAnnouncement:Ae.announcement}),Pp&&c.jsx(lu,{overlay:Ir}),c.jsx(kc,{error:Le.dataSource.error,onRetry:pe?ps.fetchRows:void 0})]})}function Cf({rows:e=5,columns:t=5}){return c.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((n,o)=>c.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>c.jsx("div",{className:"ogx__skeleton-cell",children:c.jsx("div",{className:"ogx__skeleton-content"})},i))},o))})}const yf=300;function jt(e){return"field"in e&&!("items"in e)}function Al(e,t){return e.find(n=>jt(n)&&n.field===t)}function Dl(e,t){return Object.is(e,t)?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>Dl(n,t[o])):!1}function vf(e,t){return e===t?!0:jt(e)&&jt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Dl(e.value,t.value):!jt(e)&&!jt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&nr(e.items,t.items):!1}function nr(e,t){return e===t?!0:e.length===t.length&&e.every((n,o)=>vf(n,t[o]))}function Sf(e){return(e.valueOptions??[]).map((t,n)=>t!==null&&typeof t=="object"?{key:String(n),value:t.value,label:t.label}:{key:String(n),value:t,label:String(t)})}function Ol(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function $l(e,t){return e==null?"":t.type==="date"||e instanceof Date?Ar(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}function Gl(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function _f(e,t){if(!So.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const kf=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=s.useMemo(()=>Js(e.type),[e.type]),l=i[0],d=t?.operator??l,a=i.includes(d)?i:[d,...i],f=!!t,p=e.headerName||e.field,[w,b]=s.useState(null),[C,g]=s.useState(n);C!==n&&(g(n),b(null));const u=s.useRef(o),h=s.useRef(t),x=s.useRef(e);s.useLayoutEffect(()=>{u.current=o,h.current=t,x.current=e});const m=s.useCallback((T,O)=>({id:h.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:T,value:O}),[e.field]),y=s.useCallback(T=>{const O=h.current;if(O?T===$l(O.value,x.current):T.trim()==="")return;const j=O?.operator??l;u.current(m(j,Gl(T,j)))},[l,m]),E=s.useRef(null),v=s.useRef(y);s.useLayoutEffect(()=>{E.current=w,v.current=y}),s.useEffect(()=>()=>{const T=E.current;E.current=null,T!==null&&v.current(T)},[]),s.useEffect(()=>{if(w===null)return;const T=setTimeout(()=>{E.current=null,y(w),b(null)},yf);return()=>clearTimeout(T)},[w,y]);const M=T=>{const O=w!==null?Gl(w,T):t?.value;b(null),o(m(T,_f(O,T)))},N=()=>{b(null),o(null)},P=!So.has(d),z=Sf(e),F=`ogx-filter__value-input${f?" ogx-filter__value-input--active":""}`,$=`Filter value for ${p}`;let _=null;if(P&&e.type==="boolean")_=c.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${F} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:T=>{T.target.value===""?o(null):o(m(d,T.target.value))},"aria-label":$,children:[c.jsx("option",{value:"",children:"Any"}),c.jsx("option",{value:"true",children:"true"}),c.jsx("option",{value:"false",children:"false"})]});else if(P&&e.type==="singleSelect"&&z.length>0&&d==="isAnyOf"){const T=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];_=c.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${F} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(z.length,4),value:z.filter(O=>T.some(S=>Ol(O,S))).map(O=>O.key),onChange:O=>{const S=new Set(Array.from(O.target.selectedOptions,j=>j.value));o(m("isAnyOf",z.filter(j=>S.has(j.key)).map(j=>j.value)))},"aria-label":$,children:z.map(O=>c.jsx("option",{value:O.key,children:O.label},O.key))})}else if(P&&e.type==="singleSelect"&&z.length>0&&(d==="is"||d==="not")){const T=z.find(O=>Ol(O,t?.value));_=c.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${F} ogx-filter__value-select`,value:T?.key??"",onChange:O=>{const S=z.find(j=>j.key===O.target.value);o(m(d,S?S.value:""))},"aria-label":$,children:[c.jsx("option",{value:"",children:"Any"}),z.map(O=>c.jsx("option",{value:O.key,children:O.label},O.key))]})}else P&&(_=c.jsx(ut,{id:`${r}-val`,name:`filter-val-${e.field}`,inputClassName:F,type:e.type==="date"?"date":"text",value:w??$l(t?.value,e),onChange:T=>b(T.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":$}));return c.jsxs("div",{className:`ogx-filter__row${f?" ogx-filter__row--active":""}`,children:[c.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:p}),c.jsxs("div",{className:"ogx-filter__controls",children:[c.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${f?" ogx-filter__op-select--active":""}`,value:d,onChange:T=>M(T.target.value),"aria-label":`Filter operator for ${p}`,children:a.map(T=>c.jsx("option",{value:T,children:T},T))}),_,f&&c.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:N,"aria-label":`Clear filter for ${p}`,title:"Clear",children:"×"})]})]})},Wl=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[d,a]=s.useState(o),[f,p]=s.useState(0);if(d!==o){a(o);const h=!nr(d,o),x=i!==null&&nr(i,o);h&&!x&&p(m=>m+1)}const w=s.useCallback((h,x)=>{const m=o.findIndex(E=>jt(E)&&E.field===h);let y;if(m===-1){if(!x)return;y=[...o,x]}else x?y=o.map((E,v)=>v===m?x:E):y=o.filter((E,v)=>v!==m);l(y),n({...e,items:y})},[o,e,n]),b=s.useCallback(h=>{n({...e,logicOperator:h})},[e,n]),C=t.filter(h=>h.filterable!==!1),g=C.filter(h=>Al(o,h.field)).length,u=o.length-g;return c.jsxs(c.Fragment,{children:[o.length>1&&c.jsxs("div",{className:"ogx-filter__logic-bar",children:[c.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),c.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>b("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),c.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>b("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),u>0&&c.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:u===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${u} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),C.length===0?c.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):C.map(h=>c.jsx(kf,{col:h,item:Al(o,h.field),resetToken:f,onChange:x=>w(h.field,x)},h.field))]})},Bl=["sum","avg","count","min","max"];function Hl(){return c.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:[c.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),c.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),c.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),c.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),c.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Ef({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),[a,f]=s.useState(null);s.useLayoutEffect(()=>{f(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const p=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const S=e.current.getBoundingClientRect();return{top:S.bottom+6,right:Wt()-S.right}},[e]);s.useEffect(()=>{d(p());const S=()=>d(p());return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[p]),s.useEffect(()=>{function S(q){i.current&&!i.current.contains(q.target)&&e.current&&!e.current.contains(q.target)&&r()}function j(q){q.key==="Escape"&&r()}return document.addEventListener("mousedown",S),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",j)}},[e,r]);const w=new Set(n.rowFields),b=new Set(n.columnFields),C=new Set(n.valueFields.map(S=>S.field)),g=S=>w.has(S)||b.has(S)||C.has(S),u=S=>t.find(j=>j.field===S),h=S=>u(S)?.headerName??S,x=S=>{const j=u(S)?.availableAggregationFunctions;return j?Bl.filter(q=>j.includes(q)):Bl},m=S=>S.aggregable!==!1&&(S.type==="number"||S.aggregable===!0)&&x(S.field).length>0,y=S=>S.groupable!==!1;function E(S){w.has(S)||o({...n,rowFields:[...n.rowFields,S]})}function v(S){b.has(S)||o({...n,columnFields:[...n.columnFields,S]})}function M(S){C.has(S)||o({...n,valueFields:[...n.valueFields,{field:S,aggFn:x(S)[0]??"sum"}]})}function N(S){o({...n,rowFields:n.rowFields.filter((j,q)=>q!==S)})}function P(S){o({...n,columnFields:n.columnFields.filter((j,q)=>q!==S)})}function z(S){o({...n,valueFields:n.valueFields.filter((j,q)=>q!==S)})}function F(S,j){o({...n,valueFields:n.valueFields.map((q,Z)=>Z===S?{...q,aggFn:j}:q)})}function $(){o({rowFields:[],columnFields:[],valueFields:[]})}const _=n.rowFields.length+n.columnFields.length+n.valueFields.length,T=t.filter(S=>!g(S.field)&&(y(S)||m(S))),O=c.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[c.jsxs("div",{className:"ogx-pivot-panel__header",children:[c.jsxs("span",{className:"ogx-pivot-panel__title",children:[c.jsx(Hl,{}),"Pivot Mode"]}),_>0&&c.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:$,title:"Reset pivot",children:"Reset"})]}),c.jsxs("div",{className:"ogx-pivot-panel__body",children:[c.jsxs("div",{className:"ogx-pivot-zone",children:[c.jsxs("span",{className:"ogx-pivot-zone__label",children:[c.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),c.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:n.rowFields.map((S,j)=>c.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[h(S),c.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>N(j),title:`Remove ${h(S)}`,"aria-label":`Remove ${h(S)} from Row Fields`,children:"×"})]},`${j}:${S}`))})]}),c.jsxs("div",{className:"ogx-pivot-zone",children:[c.jsxs("span",{className:"ogx-pivot-zone__label",children:[c.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),c.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:n.columnFields.map((S,j)=>c.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[h(S),c.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(j),title:`Remove ${h(S)}`,"aria-label":`Remove ${h(S)} from Column Fields`,children:"×"})]},`${j}:${S}`))})]}),c.jsxs("div",{className:"ogx-pivot-zone",children:[c.jsxs("span",{className:"ogx-pivot-zone__label",children:[c.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),c.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:n.valueFields.map((S,j)=>{const q=x(S.field),Z=q.includes(S.aggFn)?q:[S.aggFn,...q];return c.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[h(S.field),c.jsx("select",{className:"ogx-pivot-chip__fn-select",value:S.aggFn,onChange:W=>F(j,W.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${h(S.field)}`,children:Z.map(W=>c.jsx("option",{value:W,children:W.toUpperCase()},W))}),c.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>z(j),title:`Remove ${h(S.field)}`,"aria-label":`Remove ${h(S.field)} (${S.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${j}:${S.field}:${S.aggFn}`)})})]}),c.jsx("hr",{className:"ogx-pivot-panel__divider"}),c.jsxs("div",{children:[c.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),c.jsxs("div",{className:"ogx-pivot-fields",children:[T.map(S=>{const j=m(S),q=y(S),Z=S.headerName??S.field;return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[c.jsx("span",{className:`ogx-pivot-field-btn${j?" ogx-pivot-field-btn--numeric":""}`,children:Z}),c.jsxs("div",{className:"ogx-pivot-field-actions",children:[q&&c.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>E(S.field),title:"Add to Row Fields","aria-label":`Add ${Z} to Row Fields`,children:"Row"}),q&&c.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>v(S.field),title:"Add to Column Fields","aria-label":`Add ${Z} to Column Fields`,children:"Col"}),j&&c.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>M(S.field),title:"Add to Value Fields","aria-label":`Add ${Z} to Value Fields`,children:"Val"})]})]},S.field)}),T.length===0&&c.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return a?xt.createPortal(O,a):null}function Mf(){return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"11",cy:"11",r:"8"}),c.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Nf(){return c.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function zl(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function If({value:e="",onChange:t,placeholder:n="Search...",debounceMs:o=250}){const[r,i]=s.useState(()=>e.length>0),[l,d]=s.useState(e),a=s.useRef(null),f=s.useRef(null),p=s.useRef(t);s.useLayoutEffect(()=>{p.current=t},[t]);const w=s.useRef(e),b=s.useRef(e);s.useEffect(()=>{e!==b.current&&(b.current=e,zl(e)!==zl(w.current)&&(d(e),w.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const m=setTimeout(()=>{l!==w.current&&(w.current=l,p.current(l))},o);return()=>clearTimeout(m)},[l,o]);const C=s.useRef(l);s.useLayoutEffect(()=>{C.current=l}),s.useEffect(()=>()=>{const m=C.current;m!==w.current&&(w.current=m,p.current(m))},[]);const g=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>a.current?.focus())},[]),u=s.useCallback(m=>{m.stopPropagation(),d(""),w.current="",p.current(""),a.current?.focus()},[]),h=s.useCallback(()=>{i(!0)},[]),x=s.useCallback(()=>{setTimeout(()=>{f.current&&document.activeElement&&f.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const m=y=>{f.current&&!f.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),c.jsxs("div",{ref:f,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:g,children:[c.jsx("div",{className:"ogx-global-search__icon-wrapper",children:c.jsx(Mf,{})}),c.jsx(ut,{ref:a,inputClassName:"ogx-global-search__input",value:l,onChange:m=>d(m.target.value),onFocus:h,onBlur:x,placeholder:n,"aria-label":"Global Search",autoComplete:"off"}),l&&c.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:u,"aria-label":"Clear search",children:c.jsx(Nf,{})})]})}const Rn=8;function vn({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[d,a]=s.useState({top:0,left:0}),[f,p]=s.useState(null),w=s.useRef(null),b=s.useRef(null),C=s.useId(),g=s.useCallback(()=>{if(!b.current)return;const v=b.current.getBoundingClientRect(),M=v.left+v.width/2,N=v.top+v.height/2;switch(n){case"bottom":a({top:v.bottom+Rn,left:M});break;case"left":a({top:N,left:v.left-Rn});break;case"right":a({top:N,left:v.right+Rn});break;default:a({top:v.top-Rn,left:M})}},[n]),u=s.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;g();const v=M=>{M.key==="Escape"&&(u(),l(!1))};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),document.addEventListener("keydown",v),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),document.removeEventListener("keydown",v)}},[i,g,u]),s.useEffect(()=>u,[u]);const h=()=>{u(),w.current=setTimeout(()=>{p(b.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},x=()=>{u(),w.current=setTimeout(()=>{l(!1)},r)},m=s.useCallback(v=>{b.current=v?v.firstElementChild??v:null},[]),y=i&&!!e&&f!==null;let E=t;if(y&&s.isValidElement(t)){const v=t,M=v.props["aria-describedby"];E=s.cloneElement(v,{"aria-describedby":M?`${M} ${C}`:C})}return c.jsxs(c.Fragment,{children:[c.jsx("span",{ref:m,style:{display:"inline-block",lineHeight:0},onMouseEnter:h,onMouseLeave:x,onFocus:h,onBlur:x,children:E}),y&&f&&xt.createPortal(c.jsx("div",{id:C,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:d.top,left:d.left,position:"fixed",zIndex:99999},children:e}),f)]})}const Pf=Object.keys(yt);function Lf(e){return Object.prototype.hasOwnProperty.call(yt,e)}function Vl(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Lf))):Pf}function Kl(){return c.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:c.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Tf(){return c.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[c.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),c.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),c.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),c.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ul(){return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Ff({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const d=s.useRef(null),[a,f]=s.useState({top:0,right:0}),[p,w]=s.useState(null);s.useLayoutEffect(()=>{w(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const b=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const g=e.current.getBoundingClientRect();return{top:g.bottom+6,right:Wt()-g.right}},[e]);s.useEffect(()=>{f(b());const g=()=>f(b());return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[b]),s.useEffect(()=>{function g(u){d.current&&!d.current.contains(u.target)&&e.current&&!e.current.contains(u.target)&&i()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[e,i]),s.useEffect(()=>{function g(u){u.key==="Escape"&&i()}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const C=c.jsxs("div",{ref:d,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:a.top,right:a.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[c.jsxs("div",{className:"ogx-toolbar__panel-header",children:[c.jsxs("span",{className:"ogx-toolbar__panel-title",children:[c.jsx(Kl,{}),"Summaries"]}),l>0&&c.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),c.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?c.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",c.jsx("br",{}),"Set ",c.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):n.map(g=>{const u=t[g.field]||"none";return c.jsxs("div",{className:"ogx-toolbar__agg-row",children:[c.jsx("span",{className:"ogx-toolbar__agg-label",title:g.field,children:g.headerName||g.field}),c.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Vl(g)].map(h=>c.jsx("button",{type:"button",className:`ogx-toolbar__pill${u===h?" ogx-toolbar__pill--active":""}`,onClick:()=>o(g.field,h),"aria-pressed":u===h,children:h},h))})]},g.field)})})]});return p?xt.createPortal(C,p):null}function Af({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,onClose:a,showNonHideableColumns:f}){const p=s.useRef(null),[w,b]=s.useState({top:0,right:0}),[C,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const u=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const x=e.current.getBoundingClientRect();return{top:x.bottom+6,right:Wt()-x.right}},[e]);s.useEffect(()=>{b(u());const x=()=>b(u());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[u]),s.useEffect(()=>{function x(m){p.current&&!p.current.contains(m.target)&&e.current&&!e.current.contains(m.target)&&a()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[e,a]),s.useEffect(()=>{function x(m){m.key==="Escape"&&a()}return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[a]);const h=c.jsx("div",{ref:p,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:c.jsx(Yo,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:f})});return C?xt.createPortal(h,C):null}function Df({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),a=s.useRef(r);s.useLayoutEffect(()=>{a.current=r},[r]);const[f,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const w=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const u=e.current.getBoundingClientRect();return{top:u.bottom+6,right:Wt()-u.right}},[e]);s.useEffect(()=>{d(w());const u=()=>d(w());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[w]),s.useEffect(()=>{function u(h){h.key==="Escape"&&a.current()}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const b=n.items?.length??0,C=()=>{o({...n,items:[],logicOperator:"and"})},g=c.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[c.jsxs("div",{className:"ogx-toolbar__panel-header",children:[c.jsxs("span",{className:"ogx-toolbar__panel-title",children:[c.jsx(Ul,{}),"Filters",b>0&&c.jsx("span",{className:"ogx-toolbar__panel-count",children:b})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b>0&&c.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:C,title:"Clear all filters",children:"Clear all"}),c.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>a.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),c.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:c.jsx(Wl,{columns:t,filterModel:n,onFilterModelChange:o})})]});return f?xt.createPortal(g,f):null}const Of={rowFields:[],columnFields:[],valueFields:[]},$f=[];function Gf({columns:e=$f,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:d,columnVisibilityModel:a={},onColumnVisibilityModelChange:f,onColumnReorder:p,onColumnOrderReset:w,forceColumnsOpen:b,onColumnsPanelClose:C,children:g,rightContent:u,style:h,renderColumnsButton:x,renderFilterButton:m,renderAggregationButton:y,renderExportButton:E,renderQuickFilter:v,className:M,showNonHideableColumns:N}){const[P,z]=s.useState(b?"columns":null),F=P==="summaries",$=P==="pivot",_=P==="columns",T=P==="filters",O=B=>{P==="columns"&&B!=="columns"&&C?.(),z(B)},S=B=>O(P===B?null:B),j=B=>{P===B&&O(null)},[q,Z]=s.useState(b);q!==b&&(Z(b),b&&z("columns"));const W=s.useContext(Li),U=b!==void 0&&!!f;s.useEffect(()=>{if(!(!W||!U))return W.registerColumnsPanel()},[W,U]);const Q=s.useRef(null),ie=s.useRef(null),oe=s.useRef(null),ge=s.useRef(null),le=s.useRef(null),ue=s.useRef(null),te=s.useRef(null),ae=r??Of,Y=ae.rowFields.length>0||ae.columnFields.length>0||ae.valueFields.length>0,re=t?new Set(t.map(B=>B.field)):null,K=e.filter(B=>B.aggregable!==!1&&(B.type==="number"||B.aggregable===!0)&&Vl(B).length>0&&(!re||re.has(B.field))),J=Object.keys(n).filter(B=>n[B]&&n[B]!=="none").length,ne=s.useCallback((B,k)=>{if(!o)return;const H={...n};k==="none"?delete H[B]:H[B]=k,o(H)},[n,o]),de=s.useCallback(()=>{o?.({})},[o]),G=s.useCallback(B=>{if(!d)return;const k=B.trim().split(/\s+/).filter(Boolean),H={...l||{},quickFilterValues:k,items:l?.items||[]};d(H)},[l,d]),I=(l?.quickFilterValues??[]).join(" "),D=l?.items?.length||0,L=new Set(e.filter(B=>a[B.field]!==!1).map(B=>B.field)),A=s.useCallback((B,k)=>{if(!f)return;const H={...a,[B]:k};f(H)},[a,f]),V=s.useCallback(()=>{if(!f)return;const B={...a};e.forEach(k=>{k.hideable!==!1&&(B[k.field]=!0)}),f(B)},[e,a,f]),R=s.useCallback(()=>{if(!f)return;const B={...a};e.forEach(k=>{k.hideable!==!1&&(B[k.field]=!1)}),f(B)},[e,a,f]);return c.jsxs("div",{className:["ogx-toolbar",M].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:h,children:[g&&c.jsx("div",{className:"ogx-toolbar__left",children:g}),c.jsx("div",{className:"ogx-toolbar__spacer"}),c.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&c.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:v?v({value:I,onChange:G}):c.jsx(If,{value:I,onChange:G,placeholder:"Search..."})}),f&&c.jsxs("div",{ref:le,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[x?x({onClick:()=>S("columns"),isOpen:_,activeCount:e.length-L.size}):c.jsx(vn,{title:"Columns",children:c.jsx("button",{type:"button",ref:oe,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":_,onClick:()=>S("columns"),children:c.jsx(Tf,{})})}),_&&c.jsx(Af,{anchorRef:x?le:oe,columns:e,visibleColumns:L,onVisibilityChange:A,onShowAll:V,onHideAll:R,onColumnReorder:p,onColumnOrderReset:w,onClose:()=>j("columns"),showNonHideableColumns:N})]}),d&&c.jsxs("div",{ref:ue,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[m?m({onClick:()=>S("filters"),isOpen:T,activeCount:D}):c.jsx(vn,{title:"Filters",children:c.jsxs("button",{type:"button",ref:ge,className:`ogx-toolbar__icon-btn${T?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":T,onClick:()=>S("filters"),children:[c.jsx(Ul,{}),D>0&&c.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),T&&c.jsx(Df,{anchorRef:m?ue:ge,columns:e,filterModel:l||{items:[]},onFilterModelChange:d,onClose:()=>j("filters")})]}),i&&c.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[c.jsx(vn,{title:"Pivot",children:c.jsxs("button",{type:"button",ref:ie,className:`ogx-toolbar__icon-btn${$?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":$,onClick:()=>S("pivot"),children:[c.jsx(Hl,{}),Y&&c.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),$&&c.jsx(Ef,{anchorRef:ie,columns:t??e,model:ae,onChange:B=>{i?.(B)},onClose:()=>j("pivot")})]}),o&&c.jsxs("div",{ref:te,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>S("summaries"),isOpen:F,activeCount:J}):c.jsx(vn,{title:"Summaries",children:c.jsxs("button",{type:"button",ref:Q,className:`ogx-toolbar__icon-btn${F?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":F,onClick:()=>S("summaries"),children:[c.jsx(Kl,{}),J>0&&c.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${J} active summaries`})]})}),F&&c.jsx(Ff,{anchorRef:y?te:Q,aggregationModel:n,aggregableColumns:K,onFunctionChange:ne,onClearAll:de,onClose:()=>j("summaries"),activeCount:J})]}),E&&E(),u]})]})}function Wf(){const[e]=s.useState(zi);return s.useRef(e)}function Rt(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const n=e.groupField??"",o=t.find(r=>r.field===n)?.groupingValueFormatter;return o?o({field:n,value:e.groupValue}):`${n}: ${String(e.groupValue??"")}`}const Bf=new Set([8364,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,381,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,382,376]);function Hf(e){return e>=8192&&e<=8202||e===8239||e===8287||e===12288?" ":e>=8203&&e<=8205||e===8288||e===65279?"":e===8208||e===8209||e===8210||e===8722?"-":null}function zf(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||Bf.has(r)){t+=o;continue}const i=Hf(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const Vf={sliceMs:30,renderChunkRows:40},Kf=2e4;function jl(){return new Promise(e=>setTimeout(e,0))}function Uf(){return new DOMException("PDF export was aborted","AbortError")}const qt=()=>typeof performance<"u"?performance.now():Date.now(),Rl=e=>Math.max(2,Math.floor(e/2)*2),jf=[79,70,229],Rf=[255,255,255];function ql(e,t){const n=e.trim().replace(/^#/,""),o=/^[a-f\d]{3}$/i.test(n)?n.split("").map(i=>i+i).join(""):n,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Xl(e,t){return yn(e,t,Cn(e,t))}function Yl(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function qf(e,t){const n=e.reduce((r,i)=>r+Yl(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:Yl(r)/n*t}}),o}const Xf=new Set(["isEmpty","isNotEmpty"]);function Yf(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(Xf.has(e.operator))return`${o} ${e.operator}`;const{value:r}=e;if(r==null||r===""||Array.isArray(r)&&r.length===0)return null;const i=Array.isArray(r)?r.map(String).join(", "):String(r);return`${o} ${e.operator} "${i}"`}function Jl(e,t,n,o){const r=e.map(l=>"items"in l?Jl(l.items,l.logicOperator,n,!0):Yf(l,n)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return o&&r.length>1?`(${i})`:i}function Jf(e,t){const n=[],o=Jl(e.items??[],e.logicOperator??"and",t,!1);o&&n.push(o);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&n.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),n.join(" • ")}const Zf=1.15*.3528;function Qf(e,t,n={}){return eg(e,t,n,Vf)}async function eg(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw Uf()};l();let d,a;try{const[k,H]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);d=k.default,a=H.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:f="export",title:p,logoUrl:w,orientation:b="landscape",selectedRows:C,getRowId:g,aggregationResult:u,aggregationModel:h,filterModel:x,alternateRowColor:m=!0,headerBackgroundColor:y="#4f46e5",headerTextColor:E="#ffffff",fontSize:v=9,groupedRows:M,font:N,maxRows:P=Kf}=n;l();let z=qt();const F=async()=>{qt()-z<o.sliceMs||(await jl(),l(),z=qt())},$=(k,H,X)=>{i?.({phase:k,done:H,total:X})},_=new d({orientation:b,unit:"mm",format:"a4"}),T=_.internal.pageSize.getWidth(),O=_.internal.pageSize.getHeight(),S=14,j=T-S*2;let q="helvetica";N&&(_.addFileToVFS(`${N.name}-normal.ttf`,N.data),_.addFont(`${N.name}-normal.ttf`,N.name,"normal"),N.boldData&&_.addFileToVFS(`${N.name}-bold.ttf`,N.boldData),_.addFont(N.boldData?`${N.name}-bold.ttf`:`${N.name}-normal.ttf`,N.name,"bold"),q=N.name);let Z=!1;const W=k=>{if(N)return k;const H=zf(k);return H.lossy&&(Z=!0),H.text},U=(k,H,X,ee,ce)=>{const pe=_.splitTextToSize(W(k),ee);return _.text(pe.length===1?pe[0]:pe,H,X),Math.max(0,pe.length-1)*ce*Zf},Q=_t(t),ie=bn(M,C),oe=xn(e,C,g);let ge=S;if(p){let k=S,H=S+8;if(w)try{_.addImage(w,"PNG",k,S,10,10),k+=14}catch{}const X=T-S-k;_.setFontSize(16),_.setFont(q,"bold"),_.setTextColor(30,41,59),H+=U(p,k,H,X,16),H+=6,_.setFontSize(8),_.setFont(q,"normal"),_.setTextColor(100,116,139);const ee=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),ce=ie?M.filter(pe=>pe.type==="leaf").length:oe.length;if(_.text(W(`Exported: ${ee} • ${ce} row${ce!==1?"s":""}`),k,H),H+=5,x){const pe=Jf(x,t);pe&&(H+=U(`Filters: ${pe}`,k,H,X,8),H+=5)}_.setDrawColor(226,232,240),_.setLineWidth(.3),_.line(S,H+2,T-S,H+2),ge=H+6}const le=[Q.map(k=>W(k.headerName??k.field))],ue=h||{},te=k=>Q.map(H=>Jo(H,ue[H.field],k[H.field],k)),ae=[];let Y;const re=k=>{ae.push(k.map(W))};if(ie){const k=M.length;$("prepare",0,k);for(let H=0;H<k;H++){const X=M[H],ee=" ".repeat(X.depth*2);if(X.type==="group-header"){const ce=`${ee}${Rt(X,t)}`;re(Q.map((pe,me)=>me===0?ce:""))}else if(X.type==="leaf"&&X.row){const ce=X.row;re(Q.map((pe,me)=>(me===0?ee:"")+Xl(ce,pe)))}else if(X.type==="group-subtotal"&&X.aggregatedValues){const ce=te(X.aggregatedValues);re(ce.map((pe,me)=>me===0?`${ee}${Ut("Subtotal",pe)}`:pe))}else X.type==="grand-total"&&X.aggregatedValues&&(Y=[te(X.aggregatedValues).map((pe,me)=>me===0?Ut("Grand Total",pe):pe).map(W)]);(H&63)===63&&($("prepare",H+1,k),await F())}$("prepare",k,k)}else{const k=oe.length;$("prepare",0,k);for(let X=0;X<k;X++)re(Q.map(ee=>Xl(oe[X],ee))),(X&63)===63&&($("prepare",X+1,k),await F());const H=h?Kt(oe,ft(C),t,u,h):null;if(H&&h){const X=Q.some(ce=>h[ce.field]);Y=[te(H).map((ce,pe)=>pe===0&&X?Ut("TOTAL",ce):ce).map(W)]}$("prepare",k,k)}l(),ae.length>P&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${ae.length} table rows (maxRows: ${P}). PDFs this large are slow to build and open and can reach tens of MB. Prefer exportToCsv or exportToExcelAdvanced for full-dataset exports, or pass a larger \`maxRows\` to silence this warning.`),Z&&console.warn('[exportToPdf] Some characters cannot be drawn with the built-in Helvetica font and were replaced with "?". Pass the `font` option (a Unicode .ttf, e.g. Noto Sans) to draw them.');const K=qf(Q,j),[J,ne,de]=ql(y,jf),[G,I,D]=ql(E,Rf),L={head:le,styles:{fontSize:v,cellPadding:3,font:q,overflow:"linebreak"},headStyles:{fillColor:[J,ne,de],textColor:[G,I,D],fontStyle:"bold"},...m?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...Y?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:K,showHead:"everyPage",margin:{top:S,left:S,right:S,bottom:S+6}},A=ae.length;$("render",0,A);let V=0,R=Rl(o.renderChunkRows);do{const k=ae.slice(V,V+R),H=V===0,X=V+k.length>=A,ee=H?ge:_.lastAutoTable.finalY;let ce=!0;const pe=qt();a(_,{...L,body:k,...X&&Y?{foot:Y}:{},startY:H?ge:S,showFoot:X&&Y?"lastPage":"never",...H?{}:{willDrawPage:ye=>{ce?(ce=!1,ye.settings.showHead="never",ye.cursor&&(ye.cursor.y=ee)):ye.settings.showHead="everyPage"}}}),V+=k.length,$("render",V,A);const me=qt()-pe;R=Rl(me>0?Math.min(R*4,R*(o.sliceMs/me)):R*4),X||(await jl(),l(),z=qt())}while(V<A);const B=_.getNumberOfPages();for(let k=1;k<=B;k++)_.setPage(k),_.setFontSize(8),_.setTextColor(150,150,150),_.text(`Page ${k} of ${B}`,T-S,O-8,{align:"right"}),await F();l(),$("save",0,1),_.save(`${f}.pdf`),$("save",1,1)}function Sn(e,t){const n=Cn(e,t);return{text:yn(e,t,n),raw:n}}function Xt(e,t,n){return e.map(o=>Jo(o,n[o.field],t[o.field],t))}const tg="\uFEFF";function ng(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:d,escapeFormulas:a=!0,bom:f=!0}=n,p=_t(t),w=n.aggregationModel||{},b=(u,h=!1)=>qn(a?Un(u,h):u,i),C=()=>p.map(u=>b(u.headerName||u.field)).join(i)+`
|
|
8
|
+
`;let g="";if(bn(d,l))r&&(g+=C()),d.forEach(u=>{const h=" ".repeat(u.depth);if(u.type==="group-header"){const x=Rt(u,t),m=qn(h+(a?Un(x):x),i);g+=p.map((y,E)=>E===0?m:"").join(i)+`
|
|
9
|
+
`}else if(u.type==="leaf"&&u.row){const x=u.row,m=p.map((y,E)=>{const v=Sn(x,y),M=a?Un(v.text,gt(v.raw)):v.text;return qn((E===0?h:"")+M,i)});g+=m.join(i)+`
|
|
10
|
+
`}else if((u.type==="group-subtotal"||u.type==="grand-total")&&u.aggregatedValues){const x=u.aggregatedValues,m=u.type==="grand-total"?"Grand Total":`${h}Subtotal`,y=Xt(p,x,w),E=p.map((v,M)=>M===0?qn(Ut(m,y[0]),i):b(y[M],gt(x[v.field])));g+=E.join(i)+`
|
|
11
|
+
`}});else{const u=xn(e,l,n.getRowId);if(u.length===0){console.warn("No rows to export");return}r&&(g+=C()),u.forEach(x=>{const m=p.map(y=>{const E=Sn(x,y);return b(E.text,gt(E.raw))});g+=m.join(i)+`
|
|
12
|
+
`});const h=Kt(u,ft(l),t,n.aggregationResult,n.aggregationModel);if(h){const x=p.map(y=>b(w[y.field]?w[y.field].toUpperCase():""));g+=x.join(i)+`
|
|
13
|
+
`;const m=Xt(p,h,w);g+=p.map((y,E)=>b(m[E],gt(h[y.field]))).join(i)+`
|
|
14
|
+
`}}or((f?tg:"")+g,o,"text/csv;charset=utf-8;")}function qn(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
|
|
15
|
+
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const Xn="ogx-xls-text";function og(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!gt(t)}function rg(e){if(!/\.xlsx$/i.test(e))return e;const t=e.replace(/\.xlsx$/i,".xls");return console.warn(`[exportToExcel] "${e}" renamed to "${t}": exportToExcel writes an HTML table that Excel refuses to open as .xlsx. Use exportToExcelAdvanced for a real .xlsx file.`),t}function ig(e,t,n={}){const{fileName:o="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:d,escapeFormulas:a=!0}=n,f=_t(t),p=n.aggregationModel||{},w=(h,x=!1)=>Pe(a?Un(h,x):h),b=h=>`<td class="${Xn}">${h}</td>`;let g=`<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"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>${Pe(Zo(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${Xn}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(g+="<thead><tr>",f.forEach(h=>{g+=`<th class="${Xn}">${w(h.headerName||h.field)}</th>`}),g+="</tr></thead>"),g+="<tbody>";const u=(h,x,m="")=>{const y=m+w(h.text,gt(h.raw));return og(x,h.raw)?b(y):`<td>${y}</td>`};if(bn(d,l))d.forEach(h=>{const x=" ".repeat(h.depth*2);if(h.type==="group-header")g+='<tr style="font-weight:bold;background:#e8eaf6;">',g+=`<td colspan="${f.length}" class="${Xn}">${Pe(x)}${w(Rt(h,t))}</td>`,g+="</tr>";else if(h.type==="leaf"&&h.row){const m=h.row;g+="<tr>",f.forEach((y,E)=>{g+=u(Sn(m,y),y,E===0?Pe(x):"")}),g+="</tr>"}else if((h.type==="group-subtotal"||h.type==="grand-total")&&h.aggregatedValues){const m=h.aggregatedValues,y=h.type==="grand-total"?"Grand Total":`${x}Subtotal`,E=Xt(f,m,p);g+='<tr style="font-weight:bold;background:#f5f5f5;">',f.forEach((v,M)=>{if(M===0){g+=b(Pe(Ut(y,E[0])));return}g+=E[M]?`<td style="text-align:right;">${w(E[M],gt(m[v.field]))}</td>`:"<td></td>"}),g+="</tr>"}});else{const h=xn(e,l,n.getRowId);if(h.length===0){console.warn("No rows to export");return}h.forEach(m=>{g+="<tr>",f.forEach(y=>{g+=u(Sn(m,y),y)}),g+="</tr>"});const x=Kt(h,ft(l),t,n.aggregationResult,n.aggregationModel);if(x){g+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(y=>{g+=p[y.field]?`<td style="text-align:right;font-weight:bold;">${Pe(p[y.field].toUpperCase())}</td>`:"<td></td>"}),g+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const m=Xt(f,x,p);f.forEach((y,E)=>{g+=m[E]?`<td style="text-align:right;">${w(m[E],gt(x[y.field]))}</td>`:"<td></td>"}),g+="</tr>"}}g+="</tbody></table></body></html>",or(g,rg(o),"application/vnd.ms-excel")}function lg(e,t,n={}){const{fileName:o="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=n,d=_t(t),a=p=>{const w={};return d.forEach(b=>{w[b.field]=Cn(p,b)}),w};let f;if(bn(l,i)){const p=[],w=[];let b;l.forEach(C=>{if(C.type==="group-header"){const g={group:Rt(C,t),field:C.groupField??"",value:C.groupValue,rows:[],children:[]};for(;p.length>C.depth;)p.pop();p.length===0?w.push(g):(p[p.length-1].children??=[]).push(g),p.push(g)}else C.type==="leaf"&&C.row?p.length>0&&p[p.length-1].rows.push(a(C.row)):C.type==="group-subtotal"&&C.aggregatedValues&&p.length>0?(p[p.length-1].subtotals=El(C.aggregatedValues,d),p.pop()):C.type==="grand-total"&&C.aggregatedValues&&(b=El(C.aggregatedValues,d))}),f=b?{groups:w,grandTotal:b}:{groups:w}}else{const p=xn(e,i,n.getRowId);if(p.length===0){console.warn("No rows to export");return}const w=p.map(a),b=Kt(p,ft(i),t,n.aggregationResult,n.aggregationModel);if(b){const C=n.aggregationModel||{},g={};d.forEach(h=>{C[h.field]&&(g[h.field]=C[h.field].toUpperCase())});const u={};d.forEach(h=>{b[h.field]!==void 0&&b[h.field]!==null&&(u[h.field]=b[h.field])}),f={data:w,aggregation:{labels:g,values:u}}}else f=w}or(r?JSON.stringify(f,null,2):JSON.stringify(f),o,"application/json;charset=utf-8;")}const sg=/^(?:https?:|data:image\/|blob:)/i,ag=/^[a-z][a-z\d+.-]*:/i;function cg(e){const t=e.trim();return t?sg.test(t)?t:ag.test(t)?null:t:null}async function dg(e,t,n){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
|
|
14
16
|
<!DOCTYPE html>
|
|
15
17
|
<html>
|
|
16
18
|
<head>
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
</div>
|
|
31
33
|
</body>
|
|
32
34
|
</html>
|
|
33
|
-
`),o.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,d=null,
|
|
35
|
+
`),o.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,d=null,a=null,f;typeof n=="string"?r=n:typeof n=="object"&&(r=n.title||"Print",i=n.selectedRows,l=n.getRowId,d=n.aggregationResult||null,a=n.aggregationModel||null,f=n.groupedRows);const p=_t(t),w=a||{};let b=`<!DOCTYPE html><html><head><title>${Pe(r||"Print")}</title><style>
|
|
34
36
|
body{font-family:Arial,sans-serif;margin:20px;}
|
|
35
37
|
h1{font-size:24px;margin-bottom:20px;}
|
|
36
38
|
table{border-collapse:collapse;width:100%;}
|
|
@@ -41,5 +43,5 @@
|
|
|
41
43
|
tr.group-subtotal{background:#f0f4ff;font-style:italic;}
|
|
42
44
|
tr.grand-total{background:#f5f5f5;font-weight:bold;}
|
|
43
45
|
@media print{body{margin:0;}@page{margin:1cm;}}
|
|
44
|
-
</style></head><body>`;r&&(x+=`<h1>${Ne(r)}</h1>`),x+="<table><thead><tr>",g.forEach(u=>{x+=`<th>${Ne(u.headerName||u.field)}</th>`}),x+="</tr></thead><tbody>";const C=(u,m,b="",w=!1)=>{const{text:v}=dn(u,m),E=m.type==="image"?Cf(v):null;if(E!==null){const I=`<img src="${Ne(E)}" alt="${Ne(m.headerName||m.field)}" style="max-height:40px;border-radius:4px;">`;return w?`<td><div style="display:flex;justify-content:center;">${I}</div></td>`:`<td>${I}</td>`}return`<td>${b}${Ne(v)}</td>`};if(ln(f,i))f.forEach(u=>{const m=" ".repeat(u.depth*4);if(u.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${m}${Ne(Dt(u,t))}</td></tr>`;else if(u.type==="leaf"&&u.row){const b=u.row;x+="<tr>",g.forEach((w,v)=>{x+=C(b,w,v===0?m:"")}),x+="</tr>"}else if((u.type==="group-subtotal"||u.type==="grand-total")&&u.aggregatedValues){const b=u.type==="grand-total",w=Gt(g,u.aggregatedValues,h);x+=`<tr class="${b?"grand-total":"group-subtotal"}">`,g.forEach((v,E)=>{if(E===0){x+=`<td>${b?"":m}${Ne(At(b?"Grand Total":"Subtotal",w[0]))}</td>`;return}x+=w[E]?`<td style="text-align:right;">${Ne(w[E])}</td>`:"<td></td>"}),x+="</tr>"}});else{const u=rn(e,i,l);if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}u.forEach(b=>{x+="<tr>",g.forEach(w=>{x+=C(b,w,"",!0)}),x+="</tr>"});const m=Ft(u,it(i),t,d,c);m&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(b=>{x+=h[b.field]?`<td style="text-align:right;font-weight:bold;">${Ne(h[b.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Gt(g,m,h).forEach(b=>{x+=b?`<td style="text-align:right;">${Ne(b)}</td>`:"<td></td>"}),x+="</tr></tfoot>")}x+="</tbody></table></body></html>",o.document.open(),o.document.write(x),o.document.close(),o.document.title=r||"Print Preview",o.focus();let p=!1;o.onload=()=>{p||(p=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!p&&o&&!o.closed&&(p=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),o&&!o.closed){const i=r instanceof Error?r.message:String(r);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${Ne(i)}</p></div>`}}}function Uo(e,t,n){const o=new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function yf(e,t){return e.type==="number"?"number":e.type==="boolean"?"boolean":e.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function un(e){return Number.isNaN(e.getTime())?null:new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}const Sf=/^(\d{4})-(\d{2})-(\d{2})$/,_f=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,kf=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function Ef(e){if(e instanceof Date)return un(e);if(typeof e=="number")return Number.isFinite(e)?un(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=Sf.exec(t);if(n){const[o,r,i]=[Number(n[1]),Number(n[2]),Number(n[3])],l=new Date(Date.UTC(o,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(_f.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:un(o)}}function Mf(e,t){if(t==null||t==="")return null;if(e==="number"){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="bigint"){const n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof t=="string"&&kf.test(t.trim())){const n=Number(t.trim());return Number.isFinite(n)?n:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1}return}return Ef(t)}function Ml(e){if(e==null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:null;if(e instanceof Date)return un(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function Nf(e,t){const n=sn(e,t),o=yf(t,n);if(o!=="string"){const r=Mf(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:Ml(n)}return t.valueFormatter?an(e,t,n):Ml(n)}const Nl="#,##0",If="#,##0.##";function Pf(e){return Number.isInteger(e)?Nl:If}function Il(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Pl(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return Pf(n)}function Tf(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function Lf(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"jpeg":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"gif":null}function Tl(e,t){const n=sn(e,t);return typeof n=="string"&&n?n:null}async function Ff(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),d=atob(l);r=new Uint8Array(d.length);for(let c=0;c<d.length;c++)r[c]=d.charCodeAt(c)}else{const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=Lf(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:o,buffer:r.slice().buffer,ext:i}})),n=new Map;return t.forEach((o,r)=>{o.status==="fulfilled"?n.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,o.reason)}),n}async function Af(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:d="#334155",headerFontSize:c=10,bodyFontSize:f=10,aggregationResult:g=null,aggregationModel:h=null,selectedRows:x,getRowId:C,groupedRows:p,groupHeaderFillColor:u="#e8eaf6",groupSubtotalFillColor:m="#f0f4ff"}=n,b=(await import("exceljs")).default,w=new b.Workbook;w.creator="OpenGridX",w.created=new Date;const v=t,E=mt(v),I=e,D=it(x)?el(I,x,C):[],P=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],F=new Set,H=new Map,B=(S,K)=>{const j=K[S.field],Q=h?.[S.field];if(j==null)return{value:null};const $=Er(S,Q,j);return typeof $=="number"?Number.isFinite($)?kr(Q)?{value:$,numFmt:Nl}:{value:$,numFmt:Pl(S,i[S.field],$)}:{value:null}:$ instanceof Date?{value:un($)}:{value:Wo(S,Q,j,K)}};for(const S of P){if("type"in S&&S.type==="summary"){if(!g||!h)continue;const y=w.addWorksheet(Ho(S.name??"Summary",F));y.addRow(["Summary / Aggregation Totals"]),y.getRow(1).font={bold:!0,size:c+2,color:{argb:$e(d)}},y.addRow([]),y.addRow(["Column","Function","Value"]).eachCell(A=>{A.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(l)}},A.font={bold:!0,size:c,color:{argb:$e(d)}},A.border=Ll()}),E.forEach(A=>{const N=h[A.field];if(N==null||g[A.field]==null)return;const{value:L,numFmt:q}=B(A,g),G=y.addRow([A.headerName??A.field,N.toUpperCase(),L]).getCell(3),k=q??Il(A,i[A.field]);k&&(G.numFmt=k),G.alignment={horizontal:"right"},G.font={bold:!0,size:f}}),y.getColumn(1).width=20,y.getColumn(2).width=12,y.getColumn(3).width=18;continue}const K=S,{name:j="Data",rows:Q="all",includeHeaders:$=!0,includeSummary:z=!1,autoFilter:Z=!0,frozenHeader:ie=!0,alternateRowColor:oe="#f8fafc"}=K,fe=Q==="all"&&!!(p&&p.length>0),de=Q==="selected"?D:fe?p.flatMap(y=>y.type==="leaf"&&y.row?[y.row]:[]):I,ge=E.filter(y=>i[y.field]?.embedImage);if(ge.length>0){const y=[],M=new Set;if(de.forEach(A=>{ge.forEach(N=>{const L=Tl(A,N);L&&!H.has(L)&&!M.has(L)&&(y.push(L),M.add(L))})}),y.length>0){const A=await Ff(y);for(const[N,{buffer:L,extension:q}]of A){const Y=w.addImage({buffer:L,extension:q});H.set(N,Y)}}}const re=w.addWorksheet(Ho(j,F));re.columns=E.map(y=>({key:y.field,width:Tf(y,i[y.field]?.width),style:{numFmt:Il(y,i[y.field])}}));const ae=(y,M)=>{E.forEach((A,N)=>M(y.getCell(N+1),A,N+1))};if($){const y=E.map(A=>A.headerName??A.field),M=re.addRow(y);M.height=20,ae(M,(A,N)=>{A.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(l)}},A.font={bold:!0,size:c,color:{argb:$e(d)}},A.alignment={horizontal:i[N.field]?.alignment??(N.type==="number"?"right":"left"),vertical:"middle"},A.border=Ll()}),Z&&(re.autoFilter={from:{row:1,column:1},to:{row:1,column:E.length}}),ie?re.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:re.views=[{showGridLines:!1}]}let ee=$?1:0;const ne=(y,M,A)=>{const N=E.map(Y=>i[Y.field]?.embedImage?"":Nf(y,Y)),L=re.addRow(N);L.font={size:f},A>0&&(L.outlineLevel=A);const q=!!oe&&M%2===1;if(ae(L,(Y,G,k)=>{const W=Pl(G,i[G.field],N[k-1]);W&&(Y.numFmt=W),q&&oe&&(Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(oe)}}),Y.alignment={horizontal:i[G.field]?.alignment??(G.type==="number"?"right":"left"),vertical:"middle"},Y.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ge.length>0){const Y=ge.reduce((W,R)=>Math.max(W,i[R.field]?.imageHeight??40),0),G=Math.ceil(Y/1.333),k=G*1.333;L.height=G,ge.forEach(W=>{const R=E.indexOf(W),X=Tl(y,W),ue=X?H.get(X):void 0;if(ue===void 0){L.getCell(R+1).value=X??"";return}const pe=i[W.field],he=pe?.imageWidth??40,ve=pe?.imageHeight??40,_e=(re.getColumn(R+1).width??8)*7+5,ke=Math.max(0,_e-he)/2,le=Math.max(0,k-ve)/2;re.addImage(ue,{tl:{col:R,row:ee,nativeColOff:Math.floor(ke*9525),nativeRowOff:Math.floor(le*9525)},ext:{width:he,height:ve},editAs:"oneCell"})})}else L.height=16;ee++},V=y=>Dt(y,v),J=(y,M,A,N,L)=>{const q=E.map((G,k)=>k===0&&M[G.field]==null?{value:y}:B(G,M)),Y=re.addRow(q.map(G=>G.value));Y.height=18,N>0&&(Y.outlineLevel=N),Y.font={bold:L,italic:!L,size:f,color:{argb:$e(d)}},ae(Y,(G,k,W)=>{const R=q[W-1].numFmt;R&&(G.numFmt=R),G.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(A)}},G.alignment={horizontal:W===1?"left":k.type==="number"?"right":"left",vertical:"middle"},G.border=Fl()}),ee++};let te=!1;if(fe){let y=0;p.forEach(M=>{if(M.type==="group-header"){const A=re.addRow([V(M)]);A.height=18,M.depth>0&&(A.outlineLevel=M.depth),A.font={bold:!0,size:f,color:{argb:$e(d)}};for(let N=1;N<=E.length;N++)A.getCell(N).fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(u)}};A.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:M.depth},ee++,y=0}else M.type==="leaf"&&M.row?ne(M.row,y++,M.depth):M.type==="group-subtotal"&&M.aggregatedValues?J("Subtotal",M.aggregatedValues,m,M.depth,!1):M.type==="grand-total"&&M.aggregatedValues&&(J("Grand Total",M.aggregatedValues,l,0,!0),te=!0)}),re.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else de.forEach((y,M)=>ne(y,M,0));const se=Ft(de,Q==="selected",v,g,h);if(z&&!te&&se&&h){const y=E.map(L=>{const q=h[L.field];return q?q.toUpperCase():""}),M=re.addRow(y);M.height=16,M.font={size:f-1,italic:!0,color:{argb:"FF94a3b8"}},ae(M,L=>{L.alignment={horizontal:"right",vertical:"middle"},L.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const A=E.map(L=>h[L.field]==null?{value:null}:B(L,se)),N=re.addRow(A.map(L=>L.value));N.height=18,N.font={bold:!0,size:f,color:{argb:$e(d)}},ae(N,(L,q,Y)=>{const G=A[Y-1].numFmt;G&&(L.numFmt=G),L.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(l)}},L.alignment={horizontal:"right",vertical:"middle"},L.border=Fl()})}}const U=await w.xlsx.writeBuffer(),_=new Blob([U],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),T=URL.createObjectURL(_),O=document.createElement("a");O.href=T,O.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(T)}function $e(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(n=>n+n).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Ll(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Fl(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Of(e,t,n,o){return s.useMemo(()=>o?Ur(e,t,n):vo,[e,t,n,o])}const Al={"--ogx-grid-row-selected-background":"var(--ogx-color-primary-light)","--ogx-grid-row-selected-hover-background":"color-mix(in srgb, var(--ogx-color-primary) 14%, var(--ogx-color-primary-light))","--ogx-grid-cell-focus-border":"var(--ogx-color-primary)","--ogx-range-background":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-range-border":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-bg":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-hover":"var(--ogx-color-primary-dark)","--ogx-toolbar-input-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-input-focus-shadow":"0 0 0 3px color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-bg":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-text":"var(--ogx-color-primary-dark)","--ogx-overlay-item-selected-bg":"color-mix(in srgb, var(--ogx-color-primary) 8%, transparent)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary-dark)"},Ol={"--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-color-gray-50":"#f8fafc","--ogx-color-gray-100":"#f1f5f9","--ogx-color-gray-200":"#e2e8f0","--ogx-color-gray-300":"#cbd5e1","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#64748b","--ogx-color-gray-600":"#475569","--ogx-color-gray-700":"#334155","--ogx-color-gray-800":"#1e293b","--ogx-color-gray-900":"#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-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":"var(--ogx-grid-header-background)","--ogx-toolbar-text":"var(--ogx-grid-header-text)","--ogx-toolbar-border":"var(--ogx-grid-border-color)","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"var(--ogx-grid-header-hover-background)","--ogx-toolbar-btn-text":"var(--ogx-grid-header-text)","--ogx-toolbar-input-bg":"var(--ogx-grid-background)","--ogx-toolbar-input-text":"var(--ogx-grid-row-text)","--ogx-toolbar-chip-bg":"transparent","--ogx-toolbar-chip-text":"var(--ogx-grid-row-text)"},"--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-border":"#cbd5e1","--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-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"#cbd5e1","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"8px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff",...Al},Df={...Ol,"--ogx-color-primary":"#60a5fa","--ogx-color-primary-dark":"#3b82f6","--ogx-color-primary-light":"#1e3a5f","--ogx-color-primary-focus":"rgba(96, 165, 250, 0.4)","--ogx-color-white":"#0f172a","--ogx-color-black":"#f8fafc","--ogx-color-gray-50":"#1e293b","--ogx-color-gray-100":"#334155","--ogx-color-gray-200":"#475569","--ogx-color-gray-300":"#64748b","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#cbd5e1","--ogx-color-gray-600":"#e2e8f0","--ogx-color-gray-700":"#e2e8f0","--ogx-color-gray-800":"#f1f5f9","--ogx-color-gray-900":"#f8fafc","--ogx-border-color":"#334155","--ogx-border-color-hover":"#475569","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3)","--ogx-grid-background":"#0f172a","--ogx-grid-border-color":"#334155","--ogx-grid-header-background":"#1e293b","--ogx-grid-header-text":"#e2e8f0","--ogx-grid-header-hover-background":"#334155","--ogx-grid-header-sorted-background":"#1e3a5f","--ogx-grid-row-text":"#cbd5e1","--ogx-grid-row-hover-background":"#1e293b","--ogx-grid-row-alternate-background":"#162032","--ogx-checkbox-bg":"#1e293b","--ogx-checkbox-border":"#64748b","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.25)","--ogx-toolbar-btn-danger-text":"#fca5a5","--ogx-toolbar-input-border":"#334155","--ogx-overlay-background":"#1e293b","--ogx-overlay-text":"#cbd5e1","--ogx-overlay-border":"#334155","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.2)","--ogx-overlay-item-hover-bg":"#334155","--ogx-overlay-item-hover-text":"#f1f5f9","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-overlay-item-danger-text":"#fca5a5","--ogx-scrollbar-thumb":"#475569","--ogx-skeleton-base":"#1e293b","--ogx-skeleton-highlight":"#334155",...Al,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},$f=[50,100,200,300,400,500,600,700,800,900];function Gf(e){const t={};function n(o,r){r!==void 0&&(t[o]=r)}if(e.colors){const o=e.colors;if(n("--ogx-color-primary",o.primary),n("--ogx-color-primary-dark",o.primaryDark),n("--ogx-color-primary-light",o.primaryLight),n("--ogx-color-primary-focus",o.primaryFocus),n("--ogx-color-secondary",o.secondary),n("--ogx-color-secondary-dark",o.secondaryDark),n("--ogx-color-secondary-light",o.secondaryLight),n("--ogx-color-success",o.success),n("--ogx-color-warning",o.warning),n("--ogx-color-error",o.error),n("--ogx-color-info",o.info),n("--ogx-color-white",o.white),n("--ogx-color-black",o.black),o.gray)for(const r of $f)n(`--ogx-color-gray-${r}`,o.gray[r])}if(e.typography){const o=e.typography;n("--ogx-font-family",o.fontFamily),n("--ogx-font-family-mono",o.fontFamilyMono),n("--ogx-font-size-xs",o.fontSizeXs),n("--ogx-font-size-sm",o.fontSizeSm),n("--ogx-font-size-md",o.fontSizeMd),n("--ogx-font-size-lg",o.fontSizeLg),n("--ogx-font-size-xl",o.fontSizeXl)}if(e.spacing){const o=e.spacing;n("--ogx-spacing-xs",o.xs),n("--ogx-spacing-sm",o.sm),n("--ogx-spacing-md",o.md),n("--ogx-spacing-lg",o.lg),n("--ogx-spacing-xl",o.xl),n("--ogx-spacing-xxl",o.xxl)}if(e.borders){const o=e.borders;n("--ogx-border-width-thin",o.widthThin),n("--ogx-border-width-medium",o.widthMedium),n("--ogx-border-width-thick",o.widthThick),n("--ogx-border-radius-sm",o.radiusSm),n("--ogx-border-radius-md",o.radiusMd),n("--ogx-border-radius-lg",o.radiusLg),n("--ogx-border-radius-xl",o.radiusXl),n("--ogx-border-color",o.color),n("--ogx-border-color-hover",o.colorHover)}if(e.shadows){const o=e.shadows;n("--ogx-shadow-sm",o.sm),n("--ogx-shadow-md",o.md),n("--ogx-shadow-lg",o.lg),n("--ogx-shadow-xl",o.xl)}if(e.grid){const o=e.grid;n("--ogx-grid-row-height-compact",o.rowHeightCompact),n("--ogx-grid-row-height-standard",o.rowHeightStandard),n("--ogx-row-height",o.rowHeightStandard),n("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),n("--ogx-grid-header-height",o.headerHeight),n("--ogx-header-height",o.headerHeight),n("--ogx-grid-cell-padding-x",o.cellPaddingX),n("--ogx-grid-cell-padding-y",o.cellPaddingY),n("--ogx-grid-cell-font-size",o.cellFontSize),n("--ogx-grid-header-font-size",o.headerFontSize),n("--ogx-grid-background",o.background),n("--ogx-grid-border-color",o.borderColor),n("--ogx-grid-header-background",o.headerBackground),n("--ogx-grid-header-text",o.headerText),n("--ogx-grid-header-hover-background",o.headerHoverBackground),n("--ogx-grid-header-sorted-background",o.headerSortedBackground),n("--ogx-grid-row-text",o.rowText),n("--ogx-grid-row-hover-background",o.rowHoverBackground),n("--ogx-grid-row-alternate-background",o.rowAlternateBackground),n("--ogx-grid-row-selected-background",o.rowSelectedBackground),n("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),n("--ogx-grid-cell-focus-border",o.cellFocusBorder),n("--ogx-range-background",o.rangeBackground),n("--ogx-range-border",o.rangeBorder),n("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),n("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),n("--ogx-checkbox-bg",o.checkboxBg),n("--ogx-checkbox-border",o.checkboxBorder)}if(e.transitions){const o=e.transitions;n("--ogx-transition-duration-fast",o.durationFast),n("--ogx-transition-duration-normal",o.durationNormal),n("--ogx-transition-duration-slow",o.durationSlow),n("--ogx-transition-easing",o.easing)}if(e.toolbar){const o=e.toolbar;n("--ogx-toolbar-background",o.background),n("--ogx-toolbar-text",o.text),n("--ogx-toolbar-border",o.border),n("--ogx-toolbar-btn-bg",o.buttonBackground),n("--ogx-toolbar-btn-hover",o.buttonHoverBackground),n("--ogx-toolbar-btn-text",o.buttonText),n("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),n("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),n("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),n("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),n("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),n("--ogx-toolbar-btn-danger-text",o.buttonDangerText),n("--ogx-toolbar-input-bg",o.inputBackground),n("--ogx-toolbar-input-text",o.inputText),n("--ogx-toolbar-input-border",o.inputBorder),n("--ogx-toolbar-input-focus-border",o.inputFocusBorder),n("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),n("--ogx-toolbar-chip-bg",o.chipBackground),n("--ogx-toolbar-chip-text",o.chipText),n("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),n("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(e.overlays){const o=e.overlays;n("--ogx-overlay-background",o.background),n("--ogx-overlay-text",o.text),n("--ogx-overlay-border",o.border),n("--ogx-overlay-shadow",o.shadow),n("--ogx-overlay-item-hover-bg",o.itemHoverBackground),n("--ogx-overlay-item-hover-text",o.itemHoverText),n("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),n("--ogx-overlay-item-selected-text",o.itemSelectedText),n("--ogx-overlay-item-danger-bg",o.itemDangerBackground),n("--ogx-overlay-item-danger-text",o.itemDangerText)}if(e.scrollbar){const o=e.scrollbar;n("--ogx-scrollbar-thumb",o.thumbColor),n("--ogx-scrollbar-track",o.trackColor),n("--ogx-scrollbar-size",o.size)}if(e.skeleton){const o=e.skeleton;n("--ogx-skeleton-base",o.baseColor),n("--ogx-skeleton-highlight",o.highlightColor)}return t}function Wf({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?Df:Ol,...Gf(e)}),[e]);return a.jsx(ri.Provider,{value:e,children:a.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const Hf={mode:"dark",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",rangeBackground:"rgba(96, 165, 250, 0.18)",rangeBorder:"#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:"#1e293b",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#334155",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"}},Bf={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",rangeBackground:"rgba(225, 29, 72, 0.10)",rangeBorder:"#e11d48"}},zf={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",rangeBackground:"rgba(5, 150, 105, 0.12)",rangeBorder:"#059669"}},Vf={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",rangeBackground:"rgba(217, 119, 6, 0.12)",rangeBorder:"#d97706"}},Kf={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px",cellFontSize:"12px",headerFontSize:"12px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Uf(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Dl(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function jf(e,t,n,o){try{const r=n?Object.fromEntries(Object.entries(t).filter(([i])=>n.includes(i))):t;o.setItem(e,JSON.stringify(r))}catch{}}function Rf(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(Uf),d=i??l,c=s.useRef(r),f=s.useRef(d);s.useLayoutEffect(()=>{c.current=r,f.current=d});const[g,h]=s.useState(()=>({key:n,state:d?Dl(n,d):void 0}));let x=g.state;g.key!==n&&(x=d?Dl(n,d):void 0,h({key:n,state:x}));const C=s.useRef(null),p=s.useRef(null),u=s.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null);const w=p.current;p.current=null;const v=f.current;w&&v&&jf(w.key,w.state,c.current,v)},[]),m=s.useCallback(w=>{p.current&&p.current.key!==n&&u(),p.current={key:n,state:w},C.current&&clearTimeout(C.current),C.current=setTimeout(u,o)},[n,u,o]);s.useEffect(()=>u,[u]);const b=s.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),p.current=null;const w=f.current;if(w)try{w.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:x,onStateChange:m,clearState:b}),[x,m,b])}xe.Button=tn,xe.Cell=Yi,xe.CellSelectionStats=al,xe.Checkbox=en,xe.ColumnVisibilityPanel=Go,xe.DataGrid=Nu,xe.DataGridThemeProvider=Wf,xe.FilterPanel=pl,xe.GridToolbar=Ru,xe.GridTooltip=cn,xe.Header=Ei,xe.Input=Xu,xe.Pagination=Ao,xe.Row=Dn,xe.Skeleton=Iu,xe.amberTheme=Vf,xe.compactTheme=Kf,xe.darkTheme=Hf,xe.emeraldTheme=zf,xe.exportToCsv=gf,xe.exportToExcel=mf,xe.exportToExcelAdvanced=Af,xe.exportToJson=wf,xe.exportToPdf=df,xe.formatAggregationValue=qt,xe.printGrid=vf,xe.roseTheme=Bf,xe.useAggregation=Ri,xe.useGridApiRef=qu,xe.useGridStateStorage=Rf,xe.usePivot=Of,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"})}));
|
|
46
|
+
</style></head><body>`;r&&(b+=`<h1>${Pe(r)}</h1>`),b+="<table><thead><tr>",p.forEach(u=>{b+=`<th>${Pe(u.headerName||u.field)}</th>`}),b+="</tr></thead><tbody>";const C=(u,h,x="",m=!1)=>{const{text:y}=Sn(u,h),E=h.type==="image"?cg(y):null;if(E!==null){const v=`<img src="${Pe(E)}" alt="${Pe(h.headerName||h.field)}" style="max-height:40px;border-radius:4px;">`;return m?`<td><div style="display:flex;justify-content:center;">${v}</div></td>`:`<td>${v}</td>`}return`<td>${x}${Pe(y)}</td>`};if(bn(f,i))f.forEach(u=>{const h=" ".repeat(u.depth*4);if(u.type==="group-header")b+=`<tr class="group-header"><td colspan="${p.length}">${h}${Pe(Rt(u,t))}</td></tr>`;else if(u.type==="leaf"&&u.row){const x=u.row;b+="<tr>",p.forEach((m,y)=>{b+=C(x,m,y===0?h:"")}),b+="</tr>"}else if((u.type==="group-subtotal"||u.type==="grand-total")&&u.aggregatedValues){const x=u.type==="grand-total",m=Xt(p,u.aggregatedValues,w);b+=`<tr class="${x?"grand-total":"group-subtotal"}">`,p.forEach((y,E)=>{if(E===0){b+=`<td>${x?"":h}${Pe(Ut(x?"Grand Total":"Subtotal",m[0]))}</td>`;return}b+=m[E]?`<td style="text-align:right;">${Pe(m[E])}</td>`:"<td></td>"}),b+="</tr>"}});else{const u=xn(e,i,l);if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}u.forEach(x=>{b+="<tr>",p.forEach(m=>{b+=C(x,m,"",!0)}),b+="</tr>"});const h=Kt(u,ft(i),t,d,a);h&&(b+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',p.forEach(x=>{b+=w[x.field]?`<td style="text-align:right;font-weight:bold;">${Pe(w[x.field].toUpperCase())}</td>`:"<td></td>"}),b+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Xt(p,h,w).forEach(x=>{b+=x?`<td style="text-align:right;">${Pe(x)}</td>`:"<td></td>"}),b+="</tr></tfoot>")}b+="</tbody></table></body></html>",o.document.open(),o.document.write(b),o.document.close(),o.document.title=r||"Print Preview",o.focus();let g=!1;o.onload=()=>{g||(g=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!g&&o&&!o.closed&&(g=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),o&&!o.closed){const i=r instanceof Error?r.message:String(r);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${Pe(i)}</p></div>`}}}function or(e,t,n){const o=new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function ug(e,t){return e.type==="number"?"number":e.type==="boolean"?"boolean":e.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function _n(e){return Number.isNaN(e.getTime())?null:new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}const fg=/^(\d{4})-(\d{2})-(\d{2})$/,gg=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,pg=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function hg(e){if(e instanceof Date)return _n(e);if(typeof e=="number")return Number.isFinite(e)?_n(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=fg.exec(t);if(n){const[o,r,i]=[Number(n[1]),Number(n[2]),Number(n[3])],l=new Date(Date.UTC(o,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(gg.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:_n(o)}}function mg(e,t){if(t==null||t==="")return null;if(e==="number"){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="bigint"){const n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof t=="string"&&pg.test(t.trim())){const n=Number(t.trim());return Number.isFinite(n)?n:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1}return}return hg(t)}function Zl(e){if(e==null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:null;if(e instanceof Date)return _n(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function wg(e,t){const n=Cn(e,t),o=ug(t,n);if(o!=="string"){const r=mg(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:Zl(n)}return t.valueFormatter?yn(e,t,n):Zl(n)}const Ql="#,##0",xg="#,##0.##";function bg(e){return Number.isInteger(e)?Ql:xg}function es(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function ts(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return bg(n)}function Cg(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function yg(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"jpeg":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"gif":null}function ns(e,t){const n=Cn(e,t);return typeof n=="string"&&n?n:null}async function vg(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),d=atob(l);r=new Uint8Array(d.length);for(let a=0;a<d.length;a++)r[a]=d.charCodeAt(a)}else{const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=yg(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:o,buffer:r.slice().buffer,ext:i}})),n=new Map;return t.forEach((o,r)=>{o.status==="fulfilled"?n.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,o.reason)}),n}async function Sg(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:d="#334155",headerFontSize:a=10,bodyFontSize:f=10,aggregationResult:p=null,aggregationModel:w=null,selectedRows:b,getRowId:C,groupedRows:g,groupHeaderFillColor:u="#e8eaf6",groupSubtotalFillColor:h="#f0f4ff"}=n,x=(await import("exceljs")).default,m=new x.Workbook;m.creator="OpenGridX",m.created=new Date;const y=t,E=_t(y),v=e,M=ft(b)?kl(v,b,C):[],N=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],P=new Set,z=new Map,F=(S,j)=>{const q=j[S.field],Z=w?.[S.field];if(q==null)return{value:null};const W=Br(S,Z,q);return typeof W=="number"?Number.isFinite(W)?Wr(Z)?{value:W,numFmt:Ql}:{value:W,numFmt:ts(S,i[S.field],W)}:{value:null}:W instanceof Date?{value:_n(W)}:{value:Jo(S,Z,q,j)}};for(const S of N){if("type"in S&&S.type==="summary"){if(!p||!w)continue;const G=m.addWorksheet(Zo(S.name??"Summary",P));G.addRow(["Summary / Aggregation Totals"]),G.getRow(1).font={bold:!0,size:a+2,color:{argb:Be(d)}},G.addRow([]),G.addRow(["Column","Function","Value"]).eachCell(D=>{D.fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(l)}},D.font={bold:!0,size:a,color:{argb:Be(d)}},D.border=os()}),E.forEach(D=>{const L=w[D.field];if(L==null||p[D.field]==null)return;const{value:A,numFmt:V}=F(D,p),B=G.addRow([D.headerName??D.field,L.toUpperCase(),A]).getCell(3),k=V??es(D,i[D.field]);k&&(B.numFmt=k),B.alignment={horizontal:"right"},B.font={bold:!0,size:f}}),G.getColumn(1).width=20,G.getColumn(2).width=12,G.getColumn(3).width=18;continue}const j=S,{name:q="Data",rows:Z="all",includeHeaders:W=!0,includeSummary:U=!1,autoFilter:Q=!0,frozenHeader:ie=!0,alternateRowColor:oe="#f8fafc"}=j,ge=Z==="all"&&!!(g&&g.length>0),le=Z==="selected"?M:ge?g.flatMap(G=>G.type==="leaf"&&G.row?[G.row]:[]):v,ue=E.filter(G=>i[G.field]?.embedImage);if(ue.length>0){const G=[],I=new Set;if(le.forEach(D=>{ue.forEach(L=>{const A=ns(D,L);A&&!z.has(A)&&!I.has(A)&&(G.push(A),I.add(A))})}),G.length>0){const D=await vg(G);for(const[L,{buffer:A,extension:V}]of D){const R=m.addImage({buffer:A,extension:V});z.set(L,R)}}}const te=m.addWorksheet(Zo(q,P));te.columns=E.map(G=>({key:G.field,width:Cg(G,i[G.field]?.width),style:{numFmt:es(G,i[G.field])}}));const ae=(G,I)=>{E.forEach((D,L)=>I(G.getCell(L+1),D,L+1))};if(W){const G=E.map(D=>D.headerName??D.field),I=te.addRow(G);I.height=20,ae(I,(D,L)=>{D.fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(l)}},D.font={bold:!0,size:a,color:{argb:Be(d)}},D.alignment={horizontal:i[L.field]?.alignment??(L.type==="number"?"right":"left"),vertical:"middle"},D.border=os()}),Q&&(te.autoFilter={from:{row:1,column:1},to:{row:1,column:E.length}}),ie?te.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:te.views=[{showGridLines:!1}]}let Y=W?1:0;const re=(G,I,D)=>{const L=E.map(R=>i[R.field]?.embedImage?"":wg(G,R)),A=te.addRow(L);A.font={size:f},D>0&&(A.outlineLevel=D);const V=!!oe&&I%2===1;if(ae(A,(R,B,k)=>{const H=ts(B,i[B.field],L[k-1]);H&&(R.numFmt=H),V&&oe&&(R.fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(oe)}}),R.alignment={horizontal:i[B.field]?.alignment??(B.type==="number"?"right":"left"),vertical:"middle"},R.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ue.length>0){const R=ue.reduce((H,X)=>Math.max(H,i[X.field]?.imageHeight??40),0),B=Math.ceil(R/1.333),k=B*1.333;A.height=B,ue.forEach(H=>{const X=E.indexOf(H),ee=ns(G,H),ce=ee?z.get(ee):void 0;if(ce===void 0){A.getCell(X+1).value=ee??"";return}const pe=i[H.field],me=pe?.imageWidth??40,ye=pe?.imageHeight??40,Ce=(te.getColumn(X+1).width??8)*7+5,Ee=Math.max(0,Ce-me)/2,se=Math.max(0,k-ye)/2;te.addImage(ce,{tl:{col:X,row:Y,nativeColOff:Math.floor(Ee*9525),nativeRowOff:Math.floor(se*9525)},ext:{width:me,height:ye},editAs:"oneCell"})})}else A.height=16;Y++},K=G=>Rt(G,y),J=(G,I,D,L,A)=>{const V=E.map((B,k)=>k===0&&I[B.field]==null?{value:G}:F(B,I)),R=te.addRow(V.map(B=>B.value));R.height=18,L>0&&(R.outlineLevel=L),R.font={bold:A,italic:!A,size:f,color:{argb:Be(d)}},ae(R,(B,k,H)=>{const X=V[H-1].numFmt;X&&(B.numFmt=X),B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(D)}},B.alignment={horizontal:H===1?"left":k.type==="number"?"right":"left",vertical:"middle"},B.border=rs()}),Y++};let ne=!1;if(ge){let G=0;g.forEach(I=>{if(I.type==="group-header"){const D=te.addRow([K(I)]);D.height=18,I.depth>0&&(D.outlineLevel=I.depth),D.font={bold:!0,size:f,color:{argb:Be(d)}};for(let L=1;L<=E.length;L++)D.getCell(L).fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(u)}};D.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:I.depth},Y++,G=0}else I.type==="leaf"&&I.row?re(I.row,G++,I.depth):I.type==="group-subtotal"&&I.aggregatedValues?J("Subtotal",I.aggregatedValues,h,I.depth,!1):I.type==="grand-total"&&I.aggregatedValues&&(J("Grand Total",I.aggregatedValues,l,0,!0),ne=!0)}),te.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else le.forEach((G,I)=>re(G,I,0));const de=Kt(le,Z==="selected",y,p,w);if(U&&!ne&&de&&w){const G=E.map(A=>{const V=w[A.field];return V?V.toUpperCase():""}),I=te.addRow(G);I.height=16,I.font={size:f-1,italic:!0,color:{argb:"FF94a3b8"}},ae(I,A=>{A.alignment={horizontal:"right",vertical:"middle"},A.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const D=E.map(A=>w[A.field]==null?{value:null}:F(A,de)),L=te.addRow(D.map(A=>A.value));L.height=18,L.font={bold:!0,size:f,color:{argb:Be(d)}},ae(L,(A,V,R)=>{const B=D[R-1].numFmt;B&&(A.numFmt=B),A.fill={type:"pattern",pattern:"solid",fgColor:{argb:Be(l)}},A.alignment={horizontal:"right",vertical:"middle"},A.border=rs()})}}const $=await m.xlsx.writeBuffer(),_=new Blob([$],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),T=URL.createObjectURL(_),O=document.createElement("a");O.href=T,O.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(T)}function Be(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(n=>n+n).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function os(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function rs(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function _g(e,t,n,o){return s.useMemo(()=>o?ii(e,t,n):To,[e,t,n,o])}const is={"--ogx-grid-row-selected-background":"var(--ogx-color-primary-light)","--ogx-grid-row-selected-hover-background":"color-mix(in srgb, var(--ogx-color-primary) 14%, var(--ogx-color-primary-light))","--ogx-grid-cell-focus-border":"var(--ogx-color-primary)","--ogx-range-background":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-range-border":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-bg":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-hover":"var(--ogx-color-primary-dark)","--ogx-toolbar-input-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-input-focus-shadow":"0 0 0 3px color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-bg":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-text":"var(--ogx-color-primary-dark)","--ogx-overlay-item-selected-bg":"color-mix(in srgb, var(--ogx-color-primary) 8%, transparent)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary-dark)"},ls={"--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-color-gray-50":"#f8fafc","--ogx-color-gray-100":"#f1f5f9","--ogx-color-gray-200":"#e2e8f0","--ogx-color-gray-300":"#cbd5e1","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#64748b","--ogx-color-gray-600":"#475569","--ogx-color-gray-700":"#334155","--ogx-color-gray-800":"#1e293b","--ogx-color-gray-900":"#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-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":"var(--ogx-grid-header-background)","--ogx-toolbar-text":"var(--ogx-grid-header-text)","--ogx-toolbar-border":"var(--ogx-grid-border-color)","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"var(--ogx-grid-header-hover-background)","--ogx-toolbar-btn-text":"var(--ogx-grid-header-text)","--ogx-toolbar-input-bg":"var(--ogx-grid-background)","--ogx-toolbar-input-text":"var(--ogx-grid-row-text)","--ogx-toolbar-chip-bg":"transparent","--ogx-toolbar-chip-text":"var(--ogx-grid-row-text)"},"--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-border":"#cbd5e1","--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-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"#cbd5e1","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"8px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff",...is},kg={...ls,"--ogx-color-primary":"#60a5fa","--ogx-color-primary-dark":"#3b82f6","--ogx-color-primary-light":"#1e3a5f","--ogx-color-primary-focus":"rgba(96, 165, 250, 0.4)","--ogx-color-white":"#0f172a","--ogx-color-black":"#f8fafc","--ogx-color-gray-50":"#1e293b","--ogx-color-gray-100":"#334155","--ogx-color-gray-200":"#475569","--ogx-color-gray-300":"#64748b","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#cbd5e1","--ogx-color-gray-600":"#e2e8f0","--ogx-color-gray-700":"#e2e8f0","--ogx-color-gray-800":"#f1f5f9","--ogx-color-gray-900":"#f8fafc","--ogx-border-color":"#334155","--ogx-border-color-hover":"#475569","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3)","--ogx-grid-background":"#0f172a","--ogx-grid-border-color":"#334155","--ogx-grid-header-background":"#1e293b","--ogx-grid-header-text":"#e2e8f0","--ogx-grid-header-hover-background":"#334155","--ogx-grid-header-sorted-background":"#1e3a5f","--ogx-grid-row-text":"#cbd5e1","--ogx-grid-row-hover-background":"#1e293b","--ogx-grid-row-alternate-background":"#162032","--ogx-checkbox-bg":"#1e293b","--ogx-checkbox-border":"#64748b","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.25)","--ogx-toolbar-btn-danger-text":"#fca5a5","--ogx-toolbar-input-border":"#334155","--ogx-overlay-background":"#1e293b","--ogx-overlay-text":"#cbd5e1","--ogx-overlay-border":"#334155","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.2)","--ogx-overlay-item-hover-bg":"#334155","--ogx-overlay-item-hover-text":"#f1f5f9","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-overlay-item-danger-text":"#fca5a5","--ogx-scrollbar-thumb":"#475569","--ogx-skeleton-base":"#1e293b","--ogx-skeleton-highlight":"#334155",...is,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Eg=[50,100,200,300,400,500,600,700,800,900];function Mg(e){const t={};function n(o,r){r!==void 0&&(t[o]=r)}if(e.colors){const o=e.colors;if(n("--ogx-color-primary",o.primary),n("--ogx-color-primary-dark",o.primaryDark),n("--ogx-color-primary-light",o.primaryLight),n("--ogx-color-primary-focus",o.primaryFocus),n("--ogx-color-secondary",o.secondary),n("--ogx-color-secondary-dark",o.secondaryDark),n("--ogx-color-secondary-light",o.secondaryLight),n("--ogx-color-success",o.success),n("--ogx-color-warning",o.warning),n("--ogx-color-error",o.error),n("--ogx-color-info",o.info),n("--ogx-color-white",o.white),n("--ogx-color-black",o.black),o.gray)for(const r of Eg)n(`--ogx-color-gray-${r}`,o.gray[r])}if(e.typography){const o=e.typography;n("--ogx-font-family",o.fontFamily),n("--ogx-font-family-mono",o.fontFamilyMono),n("--ogx-font-size-xs",o.fontSizeXs),n("--ogx-font-size-sm",o.fontSizeSm),n("--ogx-font-size-md",o.fontSizeMd),n("--ogx-font-size-lg",o.fontSizeLg),n("--ogx-font-size-xl",o.fontSizeXl)}if(e.spacing){const o=e.spacing;n("--ogx-spacing-xs",o.xs),n("--ogx-spacing-sm",o.sm),n("--ogx-spacing-md",o.md),n("--ogx-spacing-lg",o.lg),n("--ogx-spacing-xl",o.xl),n("--ogx-spacing-xxl",o.xxl)}if(e.borders){const o=e.borders;n("--ogx-border-width-thin",o.widthThin),n("--ogx-border-width-medium",o.widthMedium),n("--ogx-border-width-thick",o.widthThick),n("--ogx-border-radius-sm",o.radiusSm),n("--ogx-border-radius-md",o.radiusMd),n("--ogx-border-radius-lg",o.radiusLg),n("--ogx-border-radius-xl",o.radiusXl),n("--ogx-border-color",o.color),n("--ogx-border-color-hover",o.colorHover)}if(e.shadows){const o=e.shadows;n("--ogx-shadow-sm",o.sm),n("--ogx-shadow-md",o.md),n("--ogx-shadow-lg",o.lg),n("--ogx-shadow-xl",o.xl)}if(e.grid){const o=e.grid;n("--ogx-grid-row-height-compact",o.rowHeightCompact),n("--ogx-grid-row-height-standard",o.rowHeightStandard),n("--ogx-row-height",o.rowHeightStandard),n("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),n("--ogx-grid-header-height",o.headerHeight),n("--ogx-header-height",o.headerHeight),n("--ogx-grid-cell-padding-x",o.cellPaddingX),n("--ogx-grid-cell-padding-y",o.cellPaddingY),n("--ogx-grid-cell-font-size",o.cellFontSize),n("--ogx-grid-header-font-size",o.headerFontSize),n("--ogx-grid-background",o.background),n("--ogx-grid-border-color",o.borderColor),n("--ogx-grid-header-background",o.headerBackground),n("--ogx-grid-header-text",o.headerText),n("--ogx-grid-header-hover-background",o.headerHoverBackground),n("--ogx-grid-header-sorted-background",o.headerSortedBackground),n("--ogx-grid-row-text",o.rowText),n("--ogx-grid-row-hover-background",o.rowHoverBackground),n("--ogx-grid-row-alternate-background",o.rowAlternateBackground),n("--ogx-grid-row-selected-background",o.rowSelectedBackground),n("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),n("--ogx-grid-cell-focus-border",o.cellFocusBorder),n("--ogx-range-background",o.rangeBackground),n("--ogx-range-border",o.rangeBorder),n("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),n("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),n("--ogx-checkbox-bg",o.checkboxBg),n("--ogx-checkbox-border",o.checkboxBorder)}if(e.transitions){const o=e.transitions;n("--ogx-transition-duration-fast",o.durationFast),n("--ogx-transition-duration-normal",o.durationNormal),n("--ogx-transition-duration-slow",o.durationSlow),n("--ogx-transition-easing",o.easing)}if(e.toolbar){const o=e.toolbar;n("--ogx-toolbar-background",o.background),n("--ogx-toolbar-text",o.text),n("--ogx-toolbar-border",o.border),n("--ogx-toolbar-btn-bg",o.buttonBackground),n("--ogx-toolbar-btn-hover",o.buttonHoverBackground),n("--ogx-toolbar-btn-text",o.buttonText),n("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),n("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),n("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),n("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),n("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),n("--ogx-toolbar-btn-danger-text",o.buttonDangerText),n("--ogx-toolbar-input-bg",o.inputBackground),n("--ogx-toolbar-input-text",o.inputText),n("--ogx-toolbar-input-border",o.inputBorder),n("--ogx-toolbar-input-focus-border",o.inputFocusBorder),n("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),n("--ogx-toolbar-chip-bg",o.chipBackground),n("--ogx-toolbar-chip-text",o.chipText),n("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),n("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(e.overlays){const o=e.overlays;n("--ogx-overlay-background",o.background),n("--ogx-overlay-text",o.text),n("--ogx-overlay-border",o.border),n("--ogx-overlay-shadow",o.shadow),n("--ogx-overlay-item-hover-bg",o.itemHoverBackground),n("--ogx-overlay-item-hover-text",o.itemHoverText),n("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),n("--ogx-overlay-item-selected-text",o.itemSelectedText),n("--ogx-overlay-item-danger-bg",o.itemDangerBackground),n("--ogx-overlay-item-danger-text",o.itemDangerText)}if(e.scrollbar){const o=e.scrollbar;n("--ogx-scrollbar-thumb",o.thumbColor),n("--ogx-scrollbar-track",o.trackColor),n("--ogx-scrollbar-size",o.size)}if(e.skeleton){const o=e.skeleton;n("--ogx-skeleton-base",o.baseColor),n("--ogx-skeleton-highlight",o.highlightColor)}return t}function Ng({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?kg:ls,...Mg(e)}),[e]);return c.jsx(xi.Provider,{value:e,children:c.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const Ig={mode:"dark",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",rangeBackground:"rgba(96, 165, 250, 0.18)",rangeBorder:"#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:"#1e293b",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#334155",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"}},Pg={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",rangeBackground:"rgba(225, 29, 72, 0.10)",rangeBorder:"#e11d48"}},Lg={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",rangeBackground:"rgba(5, 150, 105, 0.12)",rangeBorder:"#059669"}},Tg={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",rangeBackground:"rgba(217, 119, 6, 0.12)",rangeBorder:"#d97706"}},Fg={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px",cellFontSize:"12px",headerFontSize:"12px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Ag(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function ss(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function Dg(e,t,n,o){try{const r=n?Object.fromEntries(Object.entries(t).filter(([i])=>n.includes(i))):t;o.setItem(e,JSON.stringify(r))}catch{}}function Og(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(Ag),d=i??l,a=s.useRef(r),f=s.useRef(d);s.useLayoutEffect(()=>{a.current=r,f.current=d});const[p,w]=s.useState(()=>({key:n,state:d?ss(n,d):void 0}));let b=p.state;p.key!==n&&(b=d?ss(n,d):void 0,w({key:n,state:b}));const C=s.useRef(null),g=s.useRef(null),u=s.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null);const m=g.current;g.current=null;const y=f.current;m&&y&&Dg(m.key,m.state,a.current,y)},[]),h=s.useCallback(m=>{g.current&&g.current.key!==n&&u(),g.current={key:n,state:m},C.current&&clearTimeout(C.current),C.current=setTimeout(u,o)},[n,u,o]);s.useEffect(()=>u,[u]);const x=s.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),g.current=null;const m=f.current;if(m)try{m.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:b,onStateChange:h,clearState:x}),[b,h,x])}xe.Button=hn,xe.Cell=yl,xe.CellSelectionStats=Fl,xe.Checkbox=ct,xe.ColumnVisibilityPanel=Yo,xe.DataGrid=bf,xe.DataGridThemeProvider=Ng,xe.FilterPanel=Wl,xe.GridToolbar=Gf,xe.GridTooltip=vn,xe.Header=Hi,xe.Input=ut,xe.Pagination=jo,xe.Row=Kn,xe.Skeleton=Cf,xe.amberTheme=Tg,xe.compactTheme=Fg,xe.darkTheme=Ig,xe.emeraldTheme=Lg,xe.exportToCsv=ng,xe.exportToExcel=ig,xe.exportToExcelAdvanced=Sg,xe.exportToJson=lg,xe.exportToPdf=Qf,xe.formatAggregationValue=an,xe.printGrid=dg,xe.roseTheme=Pg,xe.useAggregation=xl,xe.useGridApiRef=Wf,xe.useGridStateStorage=Og,xe.usePivot=_g,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"})}));
|
|
45
47
|
//# sourceMappingURL=opengridx.umd.js.map
|