@opencorestack/opengridx 3.0.0 → 3.0.1
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 +36 -0
- package/README.md +7 -5
- package/dist/index.d.ts +18 -8
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +1371 -1365
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +10 -10
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +11 -7
- package/docs/components/column-resize.md +1 -1
- package/docs/components/datagrid.md +1 -1
- package/docs/customization/theming.md +1 -1
- package/docs/features/list-view.md +1 -1
- package/docs/features/pdf-export.md +16 -0
- package/docs/features/pinning.md +1 -0
- package/docs/features/virtualization.md +11 -9
- package/docs/migration/v2-to-v3.md +12 -1
- package/docs/roadmap.md +1 -1
- package/lib/components/Cell/Cell.css +4 -0
- package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +5 -3
- package/lib/components/DataGrid/DataGrid.css +8 -0
- package/lib/components/DataGrid/DataGrid.tsx +6 -2
- package/lib/components/DataGrid/GridListView.tsx +2 -1
- package/lib/components/Header/Header.css +3 -0
- package/lib/components/Header/Header.tsx +3 -1
- package/lib/hooks/core/gridApiPlaceholder.ts +2 -2
- package/lib/hooks/core/useGridApiRef.ts +7 -4
- package/lib/hooks/core/useGridDevWarnings.ts +23 -5
- package/lib/types/index.ts +14 -7
- package/llms.txt +6 -6
- package/package.json +1 -1
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(pe,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],s):(pe=typeof globalThis<"u"?globalThis:pe||self,s(pe.OpenGridX={},pe.ReactJSXRuntime,pe.React,pe.ReactDOM))})(this,(function(pe,s,a,tt){"use strict";function $o(e,t,o){return Math.max(t??0,Math.min(o??1/0,e))}function ot(e,t,o=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const n=t[e.field]??e.width,r=typeof n=="number"&&Number.isFinite(n)?n:o;return $o(r,e.minWidth,e.maxWidth)}const je=48;function Xe(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function _l(e,t){const o=[],n=[],r=[];return t?(e.forEach(i=>{const l=Xe(i.field,t);l==="left"?o.push(i):l==="right"?r.push(i):n.push(i)}),t.left&&o.sort((i,l)=>{const c=t.left.indexOf(i.field),d=t.left.indexOf(l.field);return c-d}),t.right&&r.sort((i,l)=>{const c=t.right.indexOf(i.field),d=t.right.indexOf(l.field);return c-d}),{left:o,center:n,right:r}):{left:o,center:e,right:r}}function Go(e,t,o,n,r,i,l,c){const d={};if(!o)return d;let u=(c?je:0)+(i&&l?je:0)+(n&&r?je:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const v=Xe(x.field,o);v==="left"?(d[x.field]=u,u+=ot(x,t)):v==="right"&&g.push(x)});let m=0;for(let x=g.length-1;x>=0;x--)d[g[x].field]=m,m+=ot(g[x],t);return d}function Wo(e,t){let o=null,n=null;if(!t)return{lastLeft:o,firstRight:n};for(const r of e){if(r.isSpacer)continue;const i=Xe(r.field,t);i==="left"?o=r.field:i==="right"&&n===null&&(n=r.field)}return{lastLeft:o,firstRight:n}}function zn(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Sl(e,t,o=n=>n.id){const n=[],r=[],i=[];return t?(e.forEach(l=>{const c=zn(o(l),t);c==="top"?n.push(l):c==="bottom"?i.push(l):r.push(l)}),t.top&&n.sort((l,c)=>{const d=t.top.indexOf(o(l)),u=t.top.indexOf(o(c));return d-u}),t.bottom&&i.sort((l,c)=>{const d=t.bottom.indexOf(o(l)),u=t.bottom.indexOf(o(c));return d-u}),{top:n,center:r,bottom:i}):{top:n,center:e,bottom:i}}function kl(e,t,o){const n=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return o==="left"?{left:[...n,t],right:r}:o==="right"?{left:n,right:[...r,t]}:{left:n,right:r}}const Kn=new Set;function jn(e,t,o){process.env.NODE_ENV==="production"||Kn.has(e)||(Kn.add(e),console.warn(`[OpenGridX] ${t}.`,o))}function no(e,t,o,n){try{return e()}catch(r){return jn(o,n,r),t}}function Un(e,t,o){const n=e[t];if(!o?.valueGetter)return{value:n};try{return{value:o.valueGetter({row:e,field:t,value:n})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Le(e,t,o){const{value:n,error:r}=Un(e,t,o);return r!==void 0&&jn(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),n}function Ho(e,t,o,n){const r=n?.valueFormatter;if(r)return no(()=>r({value:o,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function nt(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 o=Number(t);return Number.isNaN(o)?null:o}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 El=/^(\d{4})-(\d{2})-(\d{2})$/;function ro(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 o=e.trim();if(o==="")return null;const n=El.exec(o);if(n){const r=Number(n[1]),i=Number(n[2])-1,l=Number(n[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else t=new Date(o)}else return null;return Number.isNaN(t.getTime())?null:t}function io(e){const t=ro(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Xn(e){const t=ro(e);if(!t)return"";const o=String(t.getFullYear()).padStart(4,"0"),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${r}`}let qn=null;function Yn(e){return qn??=new Intl.DateTimeFormat,qn.format(e)}function Ml(e,t){if(!e)return;const o=i=>typeof i=="object"?i.value:i,n=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(o(i),t))??e.find(i=>String(o(i))===String(t));return r===void 0?void 0:n(r)}function Bo(e,t){if(e==null)return"";switch(t?.type){case"date":{const o=ro(e);return o?Yn(o):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ml(t.valueOptions,e)??String(e);default:return String(e)}}const Vo=200;function zo(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:Vo}function Ko(e,t){if(e)return no(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Nl(e,t){const o=zo(e);return o==="auto"?t??Vo:o}function Pl(e,t){if(t.size===0||e.size===0)return e;let o=!1;const n=new Set;for(const r of e)t.get(r)?.isGroupRow?o=!0:n.add(r);return o?n:e}const Il=e=>e.id;function Tl(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 Fl(e,t,o){const n=new Map;e.forEach(f=>{if(!Object.prototype.hasOwnProperty.call(t,f.field)&&f.flex&&f.flex>0){n.set(f.field,{kind:"flex",flex:f.flex});return}const p=Tl(t[f.field]??f.width);p.type==="fixed"?n.set(f.field,{kind:"fixed",width:$o(p.value,f.minWidth,f.maxWidth)}):p.type==="percentage"?n.set(f.field,{kind:"percentage",percentage:p.value}):n.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,w)=>{const p=n.get(w.field);if(p.kind==="fixed")return f+p.width;if(p.kind==="percentage")return f+100;if(w.flex&&w.flex>0){const b=w.minWidth??150;return f+(b||(typeof w.width=="number"?w.width:150))}return f+(w.minWidth??150)},0),i=Math.max(o,r),l=e.reduce((f,w)=>{const p=n.get(w.field);return p.kind==="fixed"?f+p.width:f},0),c=new Map,d=Math.max(0,i-l);let u=0;e.forEach(f=>{const w=n.get(f.field);if(w.kind==="fixed")c.set(f.field,w.width);else if(w.kind==="percentage"){const p=w.percentage/100*d,b=$o(p>0?p:100,f.minWidth??50,f.maxWidth);c.set(f.field,b),u+=b}});const g=Math.max(0,d-u),m=new Map,x=e.flatMap(f=>{const w=n.get(f.field);return w.kind!=="flex"?[]:(m.set(f.field,w.flex),[{field:f.field,flex:w.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let v=0;const h=x.length*2;for(;v<h;){v++;const f=x.filter(E=>!E.frozen);if(f.length===0)break;const w=f.reduce((E,P)=>E+P.flex,0),p=x.reduce((E,P)=>P.frozen?E+P.computedWidth:E,0),b=Math.max(0,g-p);if(w<=0){f.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0});break}const y=b/w;let C=0;const N=[],T=[];if(f.forEach(E=>{const P=y*E.flex;P<E.minWidth?(C+=E.minWidth-P,N.push(E)):P>E.maxWidth?(C+=E.maxWidth-P,T.push(E)):E.computedWidth=P}),N.length===0&&T.length===0){f.forEach(E=>{E.frozen=!0});break}C>0?N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}):C<0?T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}):(N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}),T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}))}return x.forEach(f=>c.set(f.field,f.computedWidth)),{widths:c,flexByField:m}}function Ll(e){const{rowHeight:t,pagination:o,paginatedUnpinnedRows:n,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:c,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:m,visibleOrderedColumns:x,pinnedColumns:v,columnWidths:h,viewportWidth:f,checkboxSelection:w,hasDetailPanel:p,rowReordering:b,pinCheckboxColumn:y,pinExpandColumn:C,paginationMode:N,isLoading:T,pageSize:E,getRowId:P=Il}=e;return a.useMemo(()=>{const O=o?n:r,W=(j,z)=>{const k=P(j);if(!i.has(k))return t;const L=Ko(l,{row:j,id:k,rowIndex:z});return t+Nl(L,c?.get(k))},X=O.map((j,z)=>W(j,d+z)),S=X.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]),M=N==="infinite"&&T&&O.length>0?Math.min(E,20):0,I=(S[S.length-1]||0)+M*t,_=(j,z)=>j?j.reduce((k,L,Q)=>k+W(L,Q),0):z*t,F=_(g,d),A=_(m,u),{left:q,center:K,right:J}=_l(x,v),te=(w?je:0)+(p?je:0)+(b?je:0),ne=(b?je:0)+(p&&C?je:0)+(w&&y?je:0),{widths:Z,flexByField:de}=Fl([...q,...K,...J],h,f-te),ae=j=>Z.get(j.field)??100,oe=j=>({...j,width:ae(j),flex:de.get(j.field)??j.flex}),se=11,re=q.map((j,z)=>({...oe(j),zIndex:se+z})),B=11,D=J.map((j,z)=>({...oe(j),zIndex:B+(J.length-1-z)})),$=K.map(oe),R=$.map(j=>j.width),U=re.reduce((j,z)=>j+z.width,0),G=D.reduce((j,z)=>j+z.width,0),V=R.reduce((j,z)=>j+z,0),Y=U+V+G+te,H=R.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]);return{rowHeights:X,cumulativeHeights:S,unpinnedRowsHeight:I,pinnedTopHeight:F,pinnedBottomHeight:A,leftPinnedCols:re,rightPinnedCols:D,unpinnedColsWithWidth:$,unpinnedColWidths:R,unpinnedAccWidths:H,totalWidth:Y,leftWidth:U,rightWidth:G,unpinnedTotalWidth:V,systemColumnsWidth:te,pinnedSystemColumnsWidth:ne,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,unpinnedRowsLength:O.length}},[t,o,n,r,i,l,c,d,u,g,m,x,v,h,f,w,p,b,y,C,N,T,E,P])}function Ol(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Rn(e,t,o,n,r){if(t<0||t>=o.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:c}=e,d=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(n,Ol(e)),g=d+(t===0?0:o[t-1]),m=r!==void 0?Math.min(g+r,d+o[t]):d+o[t];g<l+d?e.scrollTop=Math.max(0,g-d):m>l+c-u&&(e.scrollTop=m-c+u)}function Dl(e,t,o){const{unpinnedAccWidths:n,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:c}=o;if(t<0||t>=n.length)return;const d=l+r,u=d+(t>0?n[t-1]:0),g=d+n[t],m=c+r,{scrollLeft:x,clientWidth:v}=e;u<x+m?e.scrollLeft=Math.max(0,u-m):g>x+v-i&&(e.scrollLeft=g-v+i)}function Jn(e,t){const{row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c,rowMeta:d}=e;if(!i.editable||d?.isGroupRow||o._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c})}catch{return!1}}const Al={},jo=e=>e==null||typeof e=="string"&&e.trim()==="",Qn=e=>{const t=[];for(const o of e){const n=nt(o);n!==null&&t.push(n)}return t},Zn=(e,t)=>{let o=null,n=null;for(const r of e){const i=nt(r);i!==null&&(o===null||t(i,o))&&(o=i,n=r)}return o===null?null:n instanceof Date?n:o},lo={sum:e=>Qn(e).reduce((t,o)=>t+o,0),avg:e=>{const t=Qn(e);return t.length?t.reduce((o,n)=>o+n,0)/t.length:null},count:e=>e.filter(t=>!jo(t)).length,min:e=>Zn(e,(t,o)=>t<o),max:e=>Zn(e,(t,o)=>t>o),unique:e=>new Set(e.filter(t=>!jo(t))).size};function Uo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function so(e,t,o,n){const r={};for(const[i,l]of Object.entries(t)){const c=o.get(i);if(!Uo(c,l))continue;const d=lo[l];if(!d){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=d(e.map(u=>Le(u,i,c)))}return r}function Xo(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const $l=new Set(["count","unique"]);function er(e){return e!==void 0&&$l.has(e)}function tr(e,t,o){return e?.type==="date"&&(t==="min"||t==="max")&&typeof o=="number"&&Number.isFinite(o)?new Date(o):o}function ao(e,t,o,n){if(e==null)return"—";if(er(t))return Xo(e,t);const r=tr(o,t,e);if(o?.valueFormatter)try{return String(o.valueFormatter({value:r,row:n??{},field:o.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Yn(r):Xo(r,t)}const qo=new Set(["isEmpty","isNotEmpty"]);function or(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Gl(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Lt=e=>(t,o)=>{const n=nt(t),r=nt(o);return n===null||r===null?!1:e(n,r)},Ot=e=>(t,o)=>{const n=io(t),r=io(o);return n===null||r===null?!1:e(n,r)},nr=Ot((e,t)=>e===t),rr=(e,t)=>{const o=io(e),n=io(t);return o===null||n===null?!0:o!==n},ir={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()!=="","=":Lt((e,t)=>e===t),">":Lt((e,t)=>e>t),">=":Lt((e,t)=>e>=t),"<":Lt((e,t)=>e<t),"<=":Lt((e,t)=>e<=t),"!=":(e,t)=>{if(or(t))return!0;const o=nt(e),n=nt(t);return o!==null&&n!==null?o!==n:Gl(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const o=Array.isArray(t)?t:[t],n=String(e).toLowerCase();return o.some(r=>r!=null&&String(r).toLowerCase()===n)},not:(e,t)=>e instanceof Date?rr(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:Ot((e,t)=>e>t),onOrAfter:Ot((e,t)=>e>=t),before:Ot((e,t)=>e<t),onOrBefore:Ot((e,t)=>e<=t)},Wl={is:nr,not:rr};function Hl(e,t){if(!Object.prototype.hasOwnProperty.call(ir,e))return;const o=e;if(t?.type==="date"){const n=Wl[o];if(n)return n}return ir[o]}function Bl(e){return"items"in e&&Array.isArray(e.items)}function Vl(e,t){const{field:o,operator:n,value:r}=e;if(!qo.has(n)&&or(r))return null;const i=t.columns?.byField.get(o),l=Hl(n,i);return l?c=>l(Le(c,o,i),r):(t.warned.has(n)||(t.warned.add(n),console.warn(`Unknown filter operator: ${n}`)),null)}function lr(e,t,o){const n=[];for(const r of e){const i=Bl(r)?lr(r.items,r.logicOperator,o):Vl(r,o);i&&n.push(i)}return n.length===0?null:n.length===1?n[0]:t==="or"?r=>n.some(i=>i(r)):r=>n.every(i=>i(r))}function Yo(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 o=Xn(t);o&&e.push(o);return}if(Array.isArray(t))for(const o of t)(o==null||typeof o!="object")&&Yo(e,o)}}function sr(e,t){const o=[];if(!t){for(const n of Object.values(e))Yo(o,n);return o}for(const n of t.quickFilterColumns){const r=Le(e,n.field,n),i=Ho(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Yo(o,r)}return o}const ar=new WeakMap;function zl(e,t){if(!t)return sr(e,t);let o=ar.get(t);o||(o=new WeakMap,ar.set(t,o));let n=o.get(e);return n||(n=sr(e,t),o.set(e,n)),n}function Kl(e,t){const o=(e??[]).map(n=>String(n??"").trim().toLowerCase()).filter(n=>n!=="");return o.length===0?null:n=>{const r=zl(n,t);return o.every(i=>r.some(l=>l.includes(i)))}}function co(e,t){if(!e)return null;const o={columns:t,warned:new Set},n="quickFilterValues"in e?e.quickFilterValues:void 0,r=Kl(n,t),i=lr(e.items??[],e.logicOperator??"and",o);return r&&i?l=>r(l)&&i(l):r??i}function Ro(e,t,o){const n=co(t,o);return n?e.filter(r=>n(r)):e}function jl(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 Ul=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Jo=0,dr=1,Xl=2,cr=3,ur=4;function ht(e,t){return{rank:e,num:t,str:""}}function Qo(e,t){if(e==null)return null;if(t==="number"){const o=nt(e);return o===null?null:ht(Jo,o)}if(t==="date"){const o=ro(e);return o?ht(dr,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(Jo,e);case"bigint":return ht(Jo,Number(e));case"boolean":return ht(Xl,e?1:0);case"string":return{rank:cr,num:0,str:e}}if(e instanceof Date){const o=e.getTime();return Number.isNaN(o)?null:ht(dr,o)}return{rank:ur,num:0,str:String(e)}}function fr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===cr||e.rank===ur?Ul.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function gr(e,t){return e===0?0:t==="asc"?e:-e}function ql(e,t,o,n){return gr(fr(Qo(e,n),Qo(t,n)),o)}function Yl(e,t,o){return t.length===0?e:Zo(e,t,(n,r)=>{const i=o?.byField.get(r.field);return{value:Le(n,r.field,i),type:i?.type}})}function Zo(e,t,o){if(t.length===0||e.length<2)return[...e];const n=t.map(i=>e.map(l=>{const{value:c,type:d}=o(l,i);return Qo(c,d)})),r=e.map((i,l)=>l);return r.sort((i,l)=>{for(let c=0;c<t.length;c++){const d=gr(fr(n[c][i],n[c][l]),t[c].sort);if(d!==0)return d}return i-l}),r.map(i=>e[i])}function Rl(e,t,o){if(!o)return e.filter(r=>r.field!==t);const n=e.findIndex(r=>r.field===t);return n===-1?[...e,{field:t,sort:o}]:e.map((r,i)=>i===n?{field:t,sort:o}:r)}function en(e,t={}){const o=new Map,n=[];for(const r of e)o.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&n.push(r);return{byField:o,quickFilterColumns:n}}const wt="__pivot_grand_total__",Jl="__pivot_row__:",pr=e=>`${Jl}${JSON.stringify(e.split(hr))}`,Ql="Grand Total",hr="\0",mt="",tn=`${mt}id`,wr=e=>e==="id"?tn:e,on={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},mr=e=>e.map(t=>String(t??"")).join(hr),xr=e=>e===void 0||e===""?null:e;function Zl(e,t){const o=e==null,n=t==null;return o||n?o===n?0:o?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 es(e,t){for(let o=0;o<e.length;o++){const n=Zl(e[o],t[o]);if(n!==0)return n}return 0}function br(e,t){if(!e||e.length===0)return null;const o=lo[t](e);return typeof o=="number"||o instanceof Date?o:null}const ts=e=>"logicOperator"in e&&"items"in e,os=e=>!!(e&&e.items&&e.items.length>0);function ns(e,t){const o=l=>!t.has(l)&&l.includes(mt),n=l=>ts(l)?l.items.length>0&&l.items.every(n):o(l.field),r=[],i=[];for(const l of e.items??[])(n(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function vr(e,t,o,n={}){const r=new Map(t.map(S=>[S.field,S])),i=S=>r.get(S)?.groupable!==!1,l=o.rowFields.filter(i),c=o.columnFields.filter(i),d=new Set,u=o.valueFields.filter(S=>{if(!Uo(r.get(S.field),S.aggFn))return!1;const M=`${S.field}${mt}${S.aggFn}`;return d.has(M)?!1:(d.add(M),!0)});if(l.length===0||u.length===0)return on;const g=c.length>0,m=Array.from(new Set(u.map(S=>S.field))),x=(S,M)=>Le(S,M,r.get(M)),v=new Map,h=new Map(g?[]:[["",{values:[]}]]);for(const S of e){const M=l.map(J=>x(S,J)),I=mr(M);let _=v.get(I);_||(_={labels:M.map(xr),sample:S,cells:new Map},v.set(I,_));const F=c.map(J=>x(S,J)),A=g?mr(F):"",q=h.get(A);q?q.sample||(q.sample=S):h.set(A,{values:F.map(xr),sample:S});let K=_.cells.get(A);K||(K=new Map,_.cells.set(A,K));for(const J of m){const te=x(S,J);if(jo(te))continue;let ne=K.get(J);ne||(ne=[],K.set(J,ne)),ne.push(te)}}const f=Array.from(h.keys()).sort((S,M)=>es(h.get(S).values,h.get(M).values)),w=(S,M)=>g?`${S}${mt}${M.field}${mt}${M.aggFn}`:`${M.field}${mt}${M.aggFn}`,p=new Map;let b=[];for(const[S,M]of v){const I={id:pr(S)};l.forEach((_,F)=>{I[wr(_)]=M.labels[F]}),I.id=pr(S);for(const _ of f){const F=M.cells.get(_);for(const A of u)I[w(_,A)]=br(F?.get(A.field),A.aggFn)}p.set(I.id,M),b.push({row:I,entry:M})}const y=S=>l.includes(S),C=S=>y(S)?r.get(S)?.type:"number",{outputFilterModel:N,sortModel:T}=n;if(os(N)){const S=[];for(const I of f)for(const _ of u)S.push({field:w(I,_),type:"number"});const M=co(N,en(S));M&&(b=b.filter(({row:I})=>M(I)))}const E=(S,M)=>M==="id"&&y("id")?S[tn]:S[M];T&&T.length>0&&(b=[...b].sort((S,M)=>{for(const I of T){const _=ql(E(S.row,I.field),E(M.row,I.field),I.sort,C(I.field));if(_!==0)return _}return 0}));const P=b.map(S=>S.row);if(b.length>0){const S={id:wt};l.forEach((M,I)=>{S[wr(M)]=I===0?Ql:""}),S.id=wt;for(const M of f)for(const I of m){const _=[];for(const{entry:F}of b){const A=F.cells.get(M)?.get(I);if(A)for(const q of A)_.push(q)}for(const F of u)F.field===I&&(S[w(M,F)]=br(_,F.aggFn))}P.push(S)}const O=b[0]?.entry.sample,W=S=>S===wt?O:S===void 0?void 0:p.get(S)?.sample,X=l.map(S=>is(S,r.get(S),W));for(const S of f){const M=h.get(S),I=g?c.map((_,F)=>{const A=r.get(_),q=rs(A,_,M.values[F],M.sample);return A?.headerName?`${A.headerName}: ${q}`:q}).join(" / "):"";for(const _ of u){const F=r.get(_.field),A=_.headerName??F?.headerName??_.field;X.push({field:w(S,_),headerName:I?`${I} — ${A} (${_.aggFn})`:`${A} (${_.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:q,row:K})=>ao(q,_.aggFn,F,K)})}}return{pivotRows:P,pivotColumns:X,colKeys:f,isValid:!0}}function rs(e,t,o,n){const r=n?Ho(n,t,o,e):void 0;return r!==void 0?r:o==null?"":String(o)}function is(e,t,o){const n={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(n.type=t.type),t.align!==void 0&&(n.align=t.align),t.headerAlign!==void 0&&(n.headerAlign=t.headerAlign),t.description!==void 0&&(n.description=t.description),t.minWidth!==void 0&&(n.minWidth=t.minWidth),t.maxWidth!==void 0&&(n.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(n.valueOptions=t.valueOptions)),e==="id"&&(n.valueGetter=({row:c})=>c[tn]);const r=c=>c?.id===wt,i=t?.valueFormatter;i&&(n.valueFormatter=({value:c,row:d})=>r(d)?String(c??""):i({value:c,row:o(d?.id)??d,field:e}));const l=t?.renderCell;return l&&(n.renderCell=c=>r(c.row)?c.formattedValue??String(c.value??""):l({...c,row:o(c.row.id)??c.row})),n}function qe(e,t){return e===wt||t?.get(e)?.isGroupRow===!0}const Dt="__reorder_col__",At="__expand_col__",Ye="__checkbox_col__",rt=e=>e===Dt||e===At||e===Ye,yr=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,ls=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),ss=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function as(e){const t=e.tagName;if(t==="INPUT")return!ls.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const o=e.getAttribute("role");return o!==null&&ss.has(o)}const Cr=e=>e!==null&&e.nodeType===1;function _r(e,t){const o=e.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const n=e.closest('[role="gridcell"], [role="columnheader"]');return!n||n.closest(".ogx__viewport")!==t?null:n}function ds(e,t){if(e===t)return"grid";if(!Cr(e)||!t.contains(e))return"foreign";const o=_r(e,t);return o?o.classList.contains("ogx__cell--editing")?"editor":o===e?"grid":as(e)?"foreign":o.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function cs(e,t,o,n){if(!Cr(e))return null;const r=_r(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")),c=Number.isInteger(l)?o[l]:void 0;return c?{id:n(c),field:i,rowIndex:l}:null}function Sr(e,t){if(!e)return null;for(const o of Array.from(e.children))if(o.dataset.field===t)return o;return null}function nn(e,t,o){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Sr(r,t.field);return i&&t.field===Ye?i.querySelector("input")??i:i}if(o<0)return null;const n=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${o}"]`);return Sr(n,t.field)}const us=e=>e.id,kr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function fs(e,t,o,n){if(!e||o.length===0)return{cell:null,rowIndex:-1};const r=(o.find(d=>!rt(d.field))??o[0]).field,i=o.some(d=>d.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 c=l!==void 0&&t[l]&&n(t[l])===e.id?l:t.findIndex(d=>n(d)===e.id);return c===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(c=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:n(t[c]),field:i,rowIndex:c},rowIndex:c}):{cell:i===e.field?e:{...e,field:i},rowIndex:c}}function gs(e){const{allRenderableRows:t,navigationColumns:o,checkboxSelection:n,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:c,setKeyboardMode:d,sortModel:u,handleSort:g,handleSortAdd:m,multiSort:x=!1,isCellEditable:v,pagination:h,pageSize:f,virtualization:w,viewportRef:p,pinnedTopRowCount:b=0,getRowId:y=us,rowMetaMap:C,onRowActivate:N,toggleRowExpansion:T,handleSelectAll:E,rowSelectionEnabled:P=!0,multipleRowSelectionEnabled:O=!0,pinCheckboxColumn:W=!0,pinExpandColumn:X=!0,rowHeight:S,getSpanOrigin:M}=e,[I,_]=a.useState(null),[F,A]=a.useState(!1),q=a.useMemo(()=>fs(I,t,o,y),[I,t,o,y]),K=q.cell,J=q.rowIndex,te=a.useRef(!1),ne=a.useRef(!1),Z=a.useRef(!1),de=a.useRef(null),ae=a.useCallback(G=>{ne.current=!0,G.focus({preventScroll:!0}),ne.current=!1},[]),oe=a.useCallback(()=>{const G=p.current;G&&!G.contains(G.ownerDocument.activeElement)&&ae(G)},[p,ae]),se=a.useMemo(()=>o.find(G=>!rt(G.field))??o[0],[o]),re=a.useCallback(()=>{if(n)return{id:null,field:Ye};if(!se)return null;const G=t[0];return G?{id:y(G),field:se.field,rowIndex:0}:{id:null,field:se.field}},[n,se,t,y]),B=a.useCallback((G,V)=>{const Y=p.current;if(!Y)return;const{cumulativeHeights:H,pinnedBottomHeight:j,columnMetrics:z}=w;if(G>=0&&Rn(Y,G-b,H,j,S),rt(V)){!(V===Dt||V===At&&X||V===Ye&&W)&&Y.scrollLeft>0&&(Y.scrollLeft=0);return}if(!z)return;const{clientWidth:k,scrollLeft:L}=Y,{leftPinnedWidth:Q,rightPinnedWidth:ee,unpinnedAccWidths:ce,unpinnedCols:ue,totalSpecialsWidth:he,pinnedSpecialsWidth:be}=z,Ce=ue.findIndex(ye=>ye.field===V);if(Ce===-1)return;const fe=he+Q+(Ce>0?ce[Ce-1]:0),me=he+Q+ce[Ce],ve=L+be+Q,Se=L+k-ee;let le=L;fe<ve?le=Math.max(0,fe-be-Q):me>Se&&(le=me-k+ee),le!==L&&(Y.scrollLeft=le)},[p,w,b,S,W,X]);a.useLayoutEffect(()=>{const G=p.current,V=!yr(de.current,K);if(de.current=K,!G||!K)return;const Y=G.ownerDocument,H=Y.activeElement;let j;if(H===G?j=!0:!H||H===Y.body?j=te.current:G.contains(H)?j=V:j=!1,!j)return;const z=nn(G,K,J);z?z.contains(H)||z.focus({preventScroll:!0}):H!==G&&ae(G)});const D=a.useCallback(()=>{Z.current=!0,d(!1)},[d]),$=a.useCallback(G=>{const V=G.currentTarget,Y=G.relatedTarget,H=!(Y instanceof Node&&V.contains(Y)),j=Z.current;if(Z.current=!1,te.current=!0,A(!0),ne.current)return;if(G.target===V){if(!H)return;if(j||d(!0),K){const L=nn(V,K,J);L?L.focus({preventScroll:!0}):B(J,K.field);return}const k=re();k&&(_(L=>L??k),B(k.rowIndex??-1,k.field));return}const z=cs(G.target,V,t,y);z&&!yr(z,K)&&_(z)},[K,J,re,B,d,t,y]),R=a.useCallback(G=>{const V=G.relatedTarget;V instanceof Node&&G.currentTarget.contains(V)||(te.current=!1,Z.current=!1,A(!1),d(!1))},[d]),U=a.useCallback(G=>{const V=G.currentTarget,Y=ds(G.target,V);if(Y==="foreign"||(d(!0),G.nativeEvent?.isComposing||G.keyCode===229))return;const{key:H}=G,j=H===" "||H==="Spacebar",z=!!c.editingCell,k=(ie,ge)=>{const we=o[ge];!we||ie<-1||ie>=t.length||(_(ie===-1?{id:null,field:we.field}:{id:y(t[ie]),field:we.field,rowIndex:ie}),B(ie,we.field))};if(!K){if(!kr.has(H))return;const ie=re();if(!ie)return;G.preventDefault(),_(ie),B(ie.rowIndex??-1,ie.field);return}const{id:L,field:Q}=K,ee=J,ce=o.findIndex(ie=>ie.field===Q),ue=o.filter(ie=>rt(ie.field)).length,he=ie=>qe(ie,C),be=(ie,ge,we)=>{const Me=o[we];return rt(Me.field)?!1:Jn({row:ie,field:Me.field,value:Le(ie,Me.field,Me),colDef:Me,rowIndex:ge,colIndex:we-ue,rowMeta:C?.get(y(ie))},v)},Ce=ie=>{let ge=ee,we=ce;const Me=(t.length+1)*o.length;for(let Pe=0;Pe<Me;Pe++){if(we+=ie,we>=o.length?(we=0,ge++):we<0&&(we=o.length-1,ge--),ge<0||ge>=t.length)return null;const De=t[ge];if(!M?.(y(De),o[we].field)&&be(De,ge,we))return{r:ge,c:we}}return null};if(z){if(H==="Enter")G.preventDefault(),c.stopCellEdit();else if(H==="Escape")G.preventDefault(),c.stopCellEdit({cancel:!0});else if(H==="Tab"&&L!==null){const ie=Ce(G.shiftKey?-1:1);ie&&(G.preventDefault(),c.stopCellEdit(),k(ie.r,ie.c))}return}if(H==="Tab"||H==="Escape"||Y==="control"&&(H==="Enter"||j))return;if((G.ctrlKey||G.metaKey)&&(H==="a"||H==="A")){if(!P||!O||!E)return;G.preventDefault(),E(!0);return}if(L===null){if(H==="Enter"||j){if(G.preventDefault(),Q===Ye){nn(V,K,-1)?.click();return}const ie=o[ce];if(!ie||rt(Q)||ie.sortable===!1)return;const ge=u.find(Me=>Me.field===Q),we=ge?ge.sort==="asc"?"desc":null:"asc";(x||G.shiftKey)&&m?m(Q,we):g(Q,we);return}}else if(H==="Enter"||j){G.preventDefault();const ie=t[ee];if(Q===Ye){i(L,!r.has(L));return}if(Q===At){G.shiftKey||l(L);return}if(j){G.shiftKey&&P&&!he(L)&&i(L,!r.has(L));return}if(Q===Dt)return;if(be(ie,ee,ce)){c.startCellEdit({id:L,field:Q,value:Le(ie,Q,o[ce])});return}if(T&&C?.get(L)?.hasChildren){T(L);return}N?.({row:ie,id:L,rowIndex:ee});return}if(G.altKey&&(H==="ArrowRight"||H==="ArrowLeft")&&T&&L!==null){G.preventDefault();const ie=C?.get(L);ie?.hasChildren&&!!ie.isExpanded!=(H==="ArrowRight")&&T(L);return}if(!kr.has(H))return;G.preventDefault();const fe=t.length-1,me=o.length-1,ve=G.ctrlKey||G.metaKey,Se=h?f:10,le=(ie,ge)=>{switch(H){case"ArrowRight":return ge+1>me?{r:ie+1,c:0}:{r:ie,c:ge+1};case"ArrowLeft":return ge-1<0?{r:ie-1,c:me}:{r:ie,c:ge-1};case"ArrowDown":return{r:ie+1,c:ge};case"ArrowUp":return{r:ie-1,c:ge};case"Home":return{r:ve?-1:ie,c:0};case"End":return{r:ve?fe:ie,c:me};case"PageUp":return{r:Math.max(-1,ie-Se),c:ge};default:return{r:Math.min(fe,ie+Se),c:ge}}},ye=({r:ie,c:ge})=>ie>=-1&&ie<=fe&&ge>=0&&ge<=me,Te=({r:ie,c:ge})=>ie>=0?M?.(y(t[ie]),o[ge].field)??null:null;let xe=le(ee,ce);if(H.startsWith("Arrow"))for(let ie=ye(xe)?Te(xe):null;ie&&ie.rowId===L&&ie.field===Q;ie=ye(xe)?Te(xe):null)xe=le(xe.r,xe.c);if(!ye(xe))return;const Ee=Te(xe);if(Ee){const ie=t.findIndex(we=>y(we)===Ee.rowId),ge=o.findIndex(we=>we.field===Ee.field);ie!==-1&&ge!==-1&&(xe={r:ie,c:ge})}xe.r===ee&&xe.c===ce||k(xe.r,xe.c)},[K,J,t,o,c,r,i,l,d,u,g,m,x,v,h,f,C,N,T,E,P,O,re,B,M,y]);return{focusedCell:K,setFocusedCell:_,viewportTabIndex:F?-1:0,ensureGridFocus:oe,handleFocus:$,handleBlur:R,handleKeyDown:U,handleMouseDownCapture:D}}const ps={rowFields:[],columnFields:[],valueFields:[]},Er=100;function hs(e){return!e||e.length===0||e.includes(Er)?Er:e[0]}function ws(e){const{initialState:t,sortModel:o,onSortModelChange:n,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:c,columnVisibilityModel:d,onColumnVisibilityModelChange:u,pinnedColumns:g,onPinnedColumnsChange:m,pivotModel:x,onPivotModelChange:v,paginationModel:h,onPaginationModelChange:f,pageSizeOptions:w,rowSelectionModel:p,onRowSelectionModelChange:b,density:y}=e,[C,N]=a.useState(()=>t?.sorting?.sortModel??[]),T=o!==void 0,E=T?o:C,P=a.useCallback(fe=>{T||N(fe),n?.(fe)},[T,n]),[O,W]=a.useState(()=>t?.filter?.filterModel??{items:[]}),X=r!=null,S=X?r:O,M=a.useCallback(fe=>{X||W(fe),i?.(fe)},[X,i]),I=l!==void 0,[_,F]=a.useState(()=>l??{}),A=JSON.stringify(I?l:_),q=a.useMemo(()=>JSON.parse(A),[A]),K=a.useCallback(fe=>{I||F(fe),c?.(fe)},[I,c]),J=d!==void 0,[te,ne]=a.useState(()=>t?.columns?.columnVisibilityModel??{}),Z=J?d:te,de=a.useCallback(fe=>{J||ne(fe),u?.(fe)},[J,u]),ae=g!==void 0,[oe,se]=a.useState(()=>t?.columns?.pinnedColumns??{}),re=ae?g:oe,B=a.useCallback(fe=>{ae||se(fe),m?.(fe)},[ae,m]),[D,$]=a.useState(()=>x??ps),R=x??D,U=a.useCallback(fe=>{$(fe),v?.(fe)},[v]),G=h!==void 0,[V,Y]=a.useState(()=>t?.pagination?.paginationModel??h??{page:0,pageSize:hs(w)}),H=G?h:V,j=a.useCallback(fe=>{G||Y(fe),f?.(fe)},[G,f]),z=p!==void 0,[k,L]=a.useState([]),Q=z?p:k,ee=a.useMemo(()=>new Set(Q),[Q]),ce=a.useRef(null);a.useLayoutEffect(()=>{ce.current=null});const ue=a.useCallback(()=>ce.current,[]),he=a.useCallback(fe=>{ce.current=fe,z||L(fe),b?.(fe)},[z,b]),[be]=a.useState(()=>t?.density?.density??"standard");return{sortModel:E,isSortControlled:T,setInternalSortModel:N,handleSortModelChange:P,filterModel:S,isFilterControlled:X,handleFilterModelChange:M,aggregationModel:q,handleAggregationModelChange:K,columnVisibilityModel:Z,handleColumnVisibilityModelChange:de,pinnedColumns:re,handlePinnedColumnsChange:B,currentPivotModel:R,handlePivotModelChange:U,effectivePaginationModel:H,handlePaginationModelChange:j,rowSelectionModel:Q,selectedRowIds:ee,isSelectionControlled:z,setInternalRowSelectionModel:L,handleRowSelectionModelChange:he,getPendingRowSelectionModel:ue,density:y??be}}const Mr=a.createContext(null),ms=52,xs=56,bs=32,vs=72;function uo(e){if(e===void 0)return;const t=/^\s*(\d+(?:\.\d+)?)\s*(px)?\s*$/.exec(e);if(!t)return;const o=Number(t[1]);return o>0?o:void 0}function ys(e){const{rowHeight:t,headerHeight:o,density:n}=e,r=a.useContext(Mr)?.grid;let i;return n==="compact"?i=uo(r?.rowHeightCompact)??bs:n==="comfortable"?i=uo(r?.rowHeightComfortable)??vs:i=t??uo(r?.rowHeightStandard)??ms,{rowHeight:i,headerHeight:o??uo(r?.headerHeight)??xs}}function fo(e){return e>=1?Math.floor(e):1}function rn(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/fo(t)))}function Cs(e){const{paginationMode:t,hasDataSource:o,dataSourceRowCount:n,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(o?n??r:r)??i}function Nr(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Pr(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function _s(e){const{effectiveRows:t,activeHierarchyHandlers:o,filterMode:n,filterModel:r,sortModel:i,sortingMode:l,pagination:c,paginationMode:d,effectivePaginationModel:u,pinnedRows:g,getRowId:m,columnLookup:x,hierarchyField:v}=e,h=a.useMemo(()=>o?o.getVisibleRows({labelField:v})||[]:n==="server"?t:Ro(t,r,x),[t,r,o,v,n,x]),f=a.useMemo(()=>o?n==="server"?t:Ro(t,r,x):h,[o,h,n,t,r,x]),{top:w,center:p,bottom:b}=a.useMemo(()=>o?{top:[],center:h,bottom:[]}:Sl(h,g,m),[h,g,o,m]),y=a.useMemo(()=>o||l==="server"?p:Yl(p,i,x),[p,i,o,l,x]),C=c&&d!=="server",N=fo(u.pageSize),T=C?Pr(u.page,rn(y.length,N)):u.page,E=a.useMemo(()=>{if(!C)return y;const O=T*N;return y.slice(O,O+N)},[y,C,T,N]),P=a.useMemo(()=>{const O=c?E:y;return[...w,...O,...b]},[w,E,y,b,c]);return{filteredRows:h,dataRows:f,pinnedTopRows:w,unpinnedRows:p,pinnedBottomRows:b,sortedUnpinnedRows:y,paginatedUnpinnedRows:E,currentPage:T,allRenderableRows:P}}function Ss(e){const{layout:t,scrollTop:o,scrollLeft:n,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:c,hasDetailPanel:d,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:m,overscanRows:x=5}=e;return a.useMemo(()=>{const{unpinnedAccWidths:v,unpinnedColsWithWidth:h,leftPinnedCols:f,rightPinnedCols:w,totalWidth:p,leftWidth:b,rightWidth:y,unpinnedTotalWidth:C,systemColumnsWidth:N,cumulativeHeights:T,pinnedTopHeight:E,pinnedBottomHeight:P,unpinnedRowsHeight:O,rowHeights:W,unpinnedRowsLength:X}=t,S=r||1e3,M=l?E+O+P+50:i||600,I=6,_=Math.max(0,n-b),F=n+S-b;let A=0,q=h.length-1,K=0,J=v.length-1;for(;K<=J;){const U=K+J>>>1;v[U]<_?K=U+1:J=U-1}A=Math.max(0,K-I);for(let U=A;U<v.length;U++){if((U===0?0:v[U-1])>F){q=Math.min(h.length-1,U+I);break}q=Math.min(h.length-1,U+I)}const te=A>0?v[A-1]:0,ne=C-v[q],Z=[...f,...te>0?[{field:"__spacer_left__",width:te,isSpacer:!0}]:[],...h.slice(A,q+1),...ne>0?[{field:"__spacer_right__",width:ne,isSpacer:!0}]:[],...w],ae=S>0&&p>S?16:0,oe=E+O+P+ae+2;let se=0,re=X-1,B=0,D=0,$=T.length-1;for(;D<=$;){const U=D+$>>>1;T[U]<o?D=U+1:$=U-1}se=Math.max(0,D-x),B=se>0?T[se-1]:0;for(let U=se;U<T.length;U++)if(T[U]>=o+M){re=Math.min(X-1,U+x);break}const R=(c?48:0)+(d&&m?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:se,lastRowIndex:re,firstColumnIndex:A,lastColumnIndex:q},offsetTop:B,offsetLeft:0,totalHeight:oe,pinnedTopHeight:E,pinnedBottomHeight:P,totalWidth:p,rowHeights:W,cumulativeHeights:T,virtualColumns:Z,columnMetrics:{leftPinnedWidth:b,rightPinnedWidth:y,unpinnedAccWidths:v,unpinnedCols:h,totalSpecialsWidth:N,pinnedSpecialsWidth:R}}},[t,o,n,r,i,l,c,d,u,g,m,x])}const ln="application/x-ogx-row",sn="application/x-ogx-column";function Ir(e,t,o){const n=e.dataTransfer;!n||typeof n.setData!="function"||(n.setData(t,o),n.setData("text/plain",o))}function go(e,t){const o=e.dataTransfer?.types;return o?Array.from(o).includes(t):!0}function Tr(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const o=()=>t();return e.addEventListener("dragend",o,{once:!0}),()=>e.removeEventListener("dragend",o)}function ks(e){const{columns:t,onColumnOrderChange:o,disableColumnReorder:n=!1}=e,[r,i]=a.useState(null),[l,c]=a.useState(null),d=a.useRef(()=>{}),u=a.useCallback(()=>{d.current(),d.current=()=>{},i(null),c(null)},[]);a.useEffect(()=>()=>d.current(),[]);const g=a.useCallback(v=>h=>{if(!n){if(!t.some(f=>f.field===v)){h.preventDefault();return}d.current(),d.current=Tr(h.currentTarget,u),i(v),h.dataTransfer&&(h.dataTransfer.effectAllowed="move",Ir(h,sn,v))}},[t,n,u]),m=a.useCallback(v=>h=>{if(!(n||r===null)){if(!go(h,sn)){u();return}h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="move"),c(v)}},[r,n,u]),x=a.useCallback(v=>h=>{if(h.preventDefault(),n||r===null||!go(h,sn)){u();return}const f=t.findIndex(p=>p.field===r),w=t.findIndex(p=>p.field===v);u(),!(f===-1||w===-1||f===w)&&o?.({column:t[f],oldIndex:f,targetIndex:w})},[t,r,n,o,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:n?void 0:g,onDragOver:n?void 0:m,onDragEnd:n?void 0:u,onDrop:n?void 0:x}}function an({isExpanded:e,onClick:t,variant:o="chevron",tabIndex:n}){return s.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:n,children:o==="plus-minus"?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.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"}})]}):s.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:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Es({renderFn:e}){return s.jsx(s.Fragment,{children:e()})}function Ms(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,n)=>Object.is(o,t[n])):Object.is(e,t)}class it extends a.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,o){return Ms(t.resetKey,o.resetKey)?null:o.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,o.componentStack)}render(){return this.state.hasError?s.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):s.jsx(Es,{renderFn:this.props.renderFn})}}function Ns(e,t,o){if(!t||!o)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const n=l=>o.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>n(l.row)?l.value:r(l):void 0,valueFormatter:l=>n(l.row)?ao(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Fr(e,t){if(!t)return e;const o=t.left??[],n=t.right??[],r=i=>{const l=Xe(i.field,t);return l==="left"?o.indexOf(i.field)-o.length:l==="right"?1+n.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const po=e=>e.formattedValue??e.value;function Lr(e,t,o){const n=e.renderCell;if(!n)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!o){const l=n(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=n(t)}catch(l){return{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Ps(e,t,o){const n=e.rowMeta;if(!n?.isGroupRow)return po(e);if(n.isGroupFooter)return null;const r=n.descendantCount;if(t&&n.hasChildren){const i=n.groupLabel??`${n.groupingField}: ${String(n.groupingValue)}`;return s.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return o?s.jsxs("div",{className:"ogx__group-cell-content",children:[n.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):po(e)}const Is=e=>e.id;function Ts(e){const{activeColumns:t,isHierarchyEnabled:o,isRowGrouping:n,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:c,onColumnOrderChange:d,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:m,checkboxSelection:x,hasDetailPanel:v,rowReordering:h,initialState:f,setColumns:w,pinnedColumns:p,getRowId:b=Is,aggregationModel:y,groupingRows:C}=e,N=a.useMemo(()=>t.map($=>$.field),[t]),[T,E]=a.useState(()=>f?.columns?.columnOrder??null),P=m?N.join("\0"):"",[O,W]=a.useState(null),X=O&&O.key===P?O.order:N,M=m?X:c??(T??N),I=a.useCallback($=>{if(m){W(R=>{const U=R&&R.key===P?R.order:N;return{key:P,order:typeof $=="function"?$(U):$}});return}E(R=>typeof $=="function"?$(R??N):$)},[m,P,N]),_=a.useCallback($=>m&&$.hideable===!1||l[$.field]!==!1,[m,l]),F=a.useMemo(()=>{if(!o)return;const $=new Map(M.map((V,Y)=>[V,Y])),R=V=>$.get(V.field)??t.indexOf(V),U=[...t].sort((V,Y)=>R(V)-R(Y));return(Fr(U.filter(V=>l[V.field]!==!1),p)[0]??t[0])?.field},[o,M,t,l,p]),A=a.useMemo(()=>{if(!o)return t;const $=n?C:void 0;return t.map(R=>{const U=Ns(R,y?.[R.field],$);return R.field===F?{...R,...U,renderCell:G=>{const V=G.rowMeta,Y=V?.treeDepth??0,H=!!V?.hasChildren,j=!!V?.isExpanded,z=Lr(R,G,!0),k=z.useDefault?Ps(G,n,r):z.content;return s.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:Y*24,width:"100%",height:"100%"},children:[s.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?s.jsx("div",{onClick:L=>{L.stopPropagation(),L.preventDefault(),i?.toggleExpansion(b(G.row))},onMouseDown:L=>{L.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:s.jsx(an,{isExpanded:j,tabIndex:-1,onClick:L=>{L.stopPropagation(),L.preventDefault(),i?.toggleExpansion(b(G.row))}})}):null}),s.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})]})}}:{...R,...U,renderCell:G=>{const V=G.rowMeta;if(!V?.isGroupRow)return R.renderCell?R.renderCell(G):po(G);const Y=Lr(R,G,!1);return Y.useDefault?R.field===V.groupingField&&!V.isGroupFooter||G.value==null?null:po(G):Y.content}}})},[t,o,n,r,i,F,b,y,C]),[q,K]=a.useState(()=>f?.columns?.columnWidths??{}),J=a.useCallback(($,R)=>{K(U=>({...U,[$]:R}))},[]);a.useEffect(()=>{w(t)},[t,w]);const te=a.useMemo(()=>{const $=new Map(M.map((R,U)=>[R,U]));return[...A].sort((R,U)=>{const G=$.get(R.field)??A.indexOf(R),V=$.get(U.field)??A.indexOf(U);return G-V})},[A,M]),ne=a.useMemo(()=>te.filter(_),[te,_]),Z=a.useCallback(($,R)=>{(m||!c)&&I($),R&&d?.(R),m||u?.($)},[m,c,I,d,u]),de=a.useCallback(($,R)=>{const U=te.map(V=>V.field),[G]=U.splice($,1);U.splice(R,0,G),Z(U,{column:te[$],oldIndex:$,targetIndex:R})},[te,Z]),ae=ks({columns:te,onColumnOrderChange:a.useCallback(({oldIndex:$,targetIndex:R})=>de($,R),[de]),disableColumnReorder:g}),oe=a.useCallback(($,R)=>{const U=te.findIndex(V=>V.field===$),G=te.findIndex(V=>V.field===R);U===-1||G===-1||U===G||de(U,G)},[te,de]),se=a.useCallback(()=>{Z(N)},[Z,N]),re=a.useMemo(()=>Fr(ne,p),[ne,p]),B=a.useMemo(()=>{const $=[];return h&&$.push({field:Dt,sortable:!1,editable:!1}),v&&$.push({field:At,sortable:!1,editable:!1}),x&&$.push({field:Ye,sortable:!1,editable:!1}),[...$,...re]},[re,x,v,h]),D=a.useMemo(()=>new Map(re.map(($,R)=>[$.field,R])),[re]);return{effectiveColumns:A,hierarchyField:F,orderedColumns:te,visibleOrderedColumns:ne,renderOrderedColumns:re,navigationColumns:B,columnIndexMap:D,columnWidths:q,effectiveColumnOrder:M,setInternalColumnOrder:I,columnReorderHandlers:ae,moveColumn:oe,resetColumnOrder:se,handleColumnResize:J}}const Fs=e=>e.id;function Ls(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=Fs}=e;return a.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:u}=t,g=l?r:i,m=o.length,x=o.map((y,C)=>({row:y,id:c(y),rowIndex:C,pinned:"top"})),v=n.map((y,C)=>({row:y,id:c(y),rowIndex:m+g.length+C,pinned:"bottom"})),h=Math.max(0,d),f=Math.min(g.length,u+1),w=g.slice(h,f).map((y,C)=>({row:y,id:c(y),rowIndex:m+h+C})),p=[...x,...w,...v],b=new Set;return p.filter(y=>b.has(y.id)?!1:(b.add(y.id),!0))},[t,o,n,r,i,l,c])}const Os=100;function Or(e){const{scrollTop:t,scrollHeight:o,clientHeight:n}=e;return o-t-n>=Os?null:{visibleTop:t,visibleBottom:t+n,viewportHeight:n}}function Ds(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function As(e){const{onRowsScrollEnd:t,overscanRowCount:o=3,rowCount:n=0,autoHeight:r=!1}=e,i=a.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=a.useRef({scrollTop:0,scrollLeft:0,time:0}),c=a.useRef(null),d=a.useRef(null),u=a.useRef(null),g=a.useRef(!0),m=a.useRef(t),[x,v]=a.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});a.useEffect(()=>{m.current=t},[t]),a.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),d.current!==null&&clearTimeout(d.current)},[]);const h=a.useCallback(p=>{const b=Or(p);if(!b){g.current=!0;return}if(!g.current)return;const y=m.current;y&&(g.current=!1,y(b))},[]),f=a.useCallback(p=>{const b=p.currentTarget,y=performance.now(),C=Math.abs(b.scrollTop-l.current.scrollTop)+Math.abs(b.scrollLeft-l.current.scrollLeft),N=y-l.current.time,T=N>0?C/N:0,E=b.scrollTop!==l.current.scrollTop;l.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,time:y},i.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,velocity:T},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:P,scrollLeft:O,velocity:W}=i.current;v({scrollTop:P,scrollLeft:O,velocityOverscan:Ds(W)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,v(P=>P.velocityOverscan===0?P:{...P,velocityOverscan:0})},200),E&&h(b)},[h]);a.useEffect(()=>{g.current=!0;const p=u.current;!p||r||n<=0||p.clientHeight===0||h(p)},[n,r,h]);const w=a.useCallback(p=>{if(u.current=p,!p)return;const{scrollTop:b,scrollLeft:y}=i.current;if(b===0&&y===0)return;p.scrollTop=b,p.scrollLeft=y;const C={scrollTop:p.scrollTop,scrollLeft:p.scrollLeft};(C.scrollTop!==b||C.scrollLeft!==y)&&(i.current={...i.current,...C},l.current={...l.current,...C},v(N=>({...N,...C})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,o),handleScroll:f,attachViewport:w}}function $s(e){const t=a.useRef(null);return a.useCallback(o=>{if(t.current?.disconnect(),t.current=null,!o||typeof ResizeObserver>"u")return;const n=new ResizeObserver(r=>{for(const i of r){const{width:l,height:c}=i.contentRect;e(l,c)}});n.observe(o),t.current=n},[e])}function Gs(e){const{setDimensions:t,viewportRef:o,...n}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:d}=As(n),u=$s(t),g=a.useCallback(m=>{o.current=m,u(m),d(m)},[o,u,d]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:g}}function Ws(){const[e,t]=a.useState(()=>new Map),o=a.useCallback((n,r)=>{t(i=>{if(i.get(n)===r)return i;const l=new Map(i);return l.set(n,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:o}}function Hs(e){const{hasDetailPanel:t,controlledExpandedRowIds:o,onDetailPanelExpandedRowIdsChange:n,rowMetaMap:r}=e,[i,l]=a.useState(new Set),c=o??i,d=a.useMemo(()=>Pl(c,r),[c,r]),u=a.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const v=new Set(c);v.has(x)?v.delete(x):v.add(x),o===void 0&&l(v),n?.(v)},[c,r,o,n]),{detailPanelHeights:g,reportDetailPanelHeight:m}=Ws();return{hasDetailPanel:t,expandedRowIds:d,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:m}}const Bs=new Set(["__group__"]),$t=e=>!Bs.has(e);function Dr(e){return Object.keys(e).every($t)?e:Object.fromEntries(Object.entries(e).filter(([o])=>$t(o)))}function Vs(e){const t={...e};return e.left&&(t.left=e.left.filter($t)),e.right&&(t.right=e.right.filter($t)),t}function zs(e){const{onStateChange:t,sortModel:o,filterModel:n,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:d,density:u}=e,g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t});const m=a.useRef(null);a.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:o},filter:{filterModel:n},pagination:{paginationModel:r},columns:{columnWidths:Dr(i),columnOrder:l.filter($t),columnVisibilityModel:Dr(c),pinnedColumns:Vs(d)},density:{density:u}},v=JSON.stringify(x);v!==m.current&&(m.current=v,g.current(x))},[o,n,r,i,l,c,d,u])}const Ks=200,js=178e5;function Us(e){const{paginationRequested:t,isRowGrouping:o,autoHeight:n,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:d=0,listViewWithoutColumn:u=!1}=e,g=a.useRef(!1),m=a.useRef(!1),x=a.useRef(!1),v=a.useRef(!1),h=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||!u||(h.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."))},[u]),a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!c||(x.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."))},[c]),a.useEffect(()=>{process.env.NODE_ENV==="production"||v.current||d<=js||(v.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(d)}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.`))},[d]),a.useEffect(()=>{process.env.NODE_ENV==="production"||g.current||t&&o&&(g.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,o]),a.useEffect(()=>{process.env.NODE_ENV==="production"||m.current||n||r>0&&l>Ks&&i>=l&&(m.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 container has no bounded height: it grows to fit its content. Give it a fixed height, or if it is a flex child add \`min-height: 0\`. See docs/features/virtualization.md.`))},[n,r,i,l])}function Xs(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Ar=!1;function qs(e){a.useEffect(()=>{if(process.env.NODE_ENV==="production"||Ar)return;const t=e.current;!t||!Xs(t)||(Ar=!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 ho(e,t,o,n){if(o&&n)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>o?r.add(i):r.delete(i)),Array.from(r)}function Ys(e,t,o){return o?e.has(t)?[]:[t]:ho(e,[t],!e.has(t),!1)}function $r(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function Rs(e){const{selectedRowIds:t,onSelectionModelChange:o,disableMultipleRowSelection:n,selectableRowIds:r}=e,i=a.useCallback(m=>{$r(t,m)||o(m)},[t,o]),l=a.useCallback((m,x)=>{i(ho(t,[m],x,n))},[i,t,n]),c=a.useCallback(m=>{i(Ys(t,m,n))},[i,t,n]),d=a.useCallback(m=>{i(ho(t,r,m,!1))},[i,t,r]),{allSelected:u,someSelected:g}=a.useMemo(()=>{let m=0;for(const v of r)t.has(v)&&m++;const x=r.length>0&&m===r.length;return{allSelected:x,someSelected:!x&&m>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:n?void 0:d,allSelected:u,someSelected:g}}function Js(e){const{dataRows:t,getRowId:o,isPivotActive:n,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:c,isHierarchyEnabled:d,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:m}=e,x=a.useMemo(()=>{const w=t.map(o);return n?w.filter(p=>p!==wt):w},[t,o,n]),v=Rs({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),h=a.useCallback(w=>{const{id:p}=w,b=d?u.get(p):void 0;if(b?.isGroupRow){b.hasChildren&&g?.toggleExpansion(p);return}m?.(w),!c&&!qe(p,u)&&v.clickRow(p)},[d,g,m,u,c,v]),f=a.useCallback((w,p)=>{qe(w,u)||v.toggleRow(w,p)},[u,v]);return{rowSelection:v,handleRowClick:h,handleSelectionChange:f}}const Gr=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Qs(e){const{selectedRowIds:t,rowsLookup:o,rowMetaMap:n,enabled:r,onSelectionModelChange:i}=e,l=a.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;const g=new Set;for(const m of t)o.has(m)||n.has(m)?g.add(m):u=!0;return u?g:t},[r,t,o,n]),c=a.useRef(i);a.useLayoutEffect(()=>{c.current=i});const d=a.useRef(null);return a.useEffect(()=>{if(l===t){d.current=null;return}const u=`${Gr(t)}|${Gr(l)}`;d.current!==u&&(d.current=u,c.current(Array.from(l)))},[l,t]),l}function dn(e,t,o,n){return n?Rl(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function Zs(e){const{sortModel:t,onSortModelChange:o}=e,n=a.useCallback((i,l)=>{o(dn(t,i,l,!1))},[t,o]),r=a.useCallback((i,l)=>{o(dn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function ea(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:o,pinnedColumns:n,onPinnedColumnsChange:r}=e,i=a.useRef({columnVisibilityModel:t,pinnedColumns:n});a.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:n}});const l=a.useCallback(d=>{const u={...i.current.columnVisibilityModel,[d]:!1};i.current={...i.current,columnVisibilityModel:u},o(u)},[o]),c=a.useCallback((d,u)=>{const g=kl(i.current.pinnedColumns,d,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function ta(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=t.current,r=()=>o.current;n.getSortModel=()=>r().sortModel,n.sortColumn=(d,u)=>{const{sortModel:g,multiSort:m,onSortModelChange:x}=r(),v=dn(g,d,u,m);o.current={...r(),sortModel:v},x(v)},n.getFilterModel=()=>r().filterModel,n.setFilterModel=d=>{o.current={...r(),filterModel:d},r().onFilterModelChange(d)};const i=d=>{o.current={...r(),paginationModel:d},r().onPaginationModelChange(d)};n.setPage=d=>i({...r().paginationModel,page:d}),n.setPageSize=d=>i({...r().paginationModel,pageSize:d,page:0});const l=()=>{const d=r().getPendingRowSelectionModel?.();return d?new Set(d):r().selectedRowIds},c=(d,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:m,isSyntheticRowId:x}=r(),v=x?d.filter(w=>!x(w)):d;if(v.length===0)return;const h=l(),f=ho(h,v,u,g);$r(h,f)||(o.current={...r(),selectedRowIds:new Set(f)},m(f))};n.getSelectedRows=()=>Array.from(l()),n.selectRow=(d,u=!0)=>c([d],u),n.selectRows=(d,u=!0)=>c(d,u),n.getVisibleRows=()=>r().getVisibleRows(),n.getAllFilteredRows=()=>r().getAllFilteredRows(),n.getVisibleColumns=()=>r().visibleColumns},[t])}const Wr="\0";function oa(e,t){const o=e.filter(n=>t[n.field]===!1).map(n=>n.field).join(Wr);return a.useMemo(()=>{const n={};if(o)for(const r of o.split(Wr))n[r]=!1;return en(e,n)},[e,o])}function na({paginationModel:e,currentPage:t,enabled:o,onPaginationModelChange:n}){const r=a.useRef({paginationModel:e,onPaginationModelChange:n});a.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:n}});const i=e.page,l=a.useRef(null);a.useEffect(()=>{if(!o)return;if(t===i){l.current=null;return}const c=`${i}>${t}`;if(l.current===c)return;l.current=c;const{paginationModel:d,onPaginationModelChange:u}=r.current;u({...d,page:t})},[o,t,i])}function ra(){const[e,t]=a.useState(!1),[o,n]=a.useState(!1),r=a.useRef(null),i=a.useRef(0),l=a.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),c=a.useCallback(()=>{i.current>0?t(!0):n(!0)},[]),d=a.useCallback(()=>t(!1),[]),u=a.useCallback(()=>n(!1),[]);return a.useEffect(()=>{if(!o)return;function g(x){r.current&&!r.current.contains(x.target)&&n(!1)}function m(x){x.key==="Escape"&&n(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",m)}},[o]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:d,standalonePanelOpen:o,closeStandalonePanel:u,standalonePanelRef:r,openColumnsPanel:c}}const Hr=a.createContext(null);function ia(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function la({render:e,toolbarProps:t}){return s.jsx(s.Fragment,{children:e(t)})}function sa({component:e,toolbarProps:t}){if(ia(e))return s.jsx(la,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return s.jsx(o,{...t})}const Br=48;function aa({columns:e,aggregationModel:t,aggregationResult:o,columnWidths:n,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:c,pinCheckboxColumn:d=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:m=!1}){const x=a.useMemo(()=>Go(e,n,g,i,d,l,u,c),[e,n,g,i,d,l,u,c]),{lastLeft:v,firstRight:h}=a.useMemo(()=>Wo(e,g),[e,g]),f=c?Br:0,w=f+(l&&u?Br:0),p=(b,y,C)=>s.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:C}:void 0,"aria-hidden":"true"},b);return s.jsxs("div",{className:`ogx__aggregation-footer${m?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":m||void 0,style:{minHeight:`${r}px`},children:[c&&p("__reorder_col__",!0,0),l&&p("__expand_col__",u,f),i&&p("__checkbox_col__",d,w),e.map(b=>{if(b.isSpacer){const X=typeof b.width=="number"?b.width:0;return s.jsx("div",{style:{width:X,minWidth:X,flexShrink:0},"aria-hidden":"true"},b.field)}const y=t[b.field],C=y&&Uo(b,y)?y:void 0,N=o[b.field],T=ot(b,n,120),E=Xe(b.field,g),P=E?x[b.field]:void 0,O=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&b.field===v&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&b.field===h&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),W={width:T,minWidth:T,maxWidth:T,textAlign:b.align||"left"};return E==="left"&&P!==void 0&&(W.left=P),E==="right"&&P!==void 0&&(W.right=P),s.jsx("div",{className:O,role:"gridcell",style:W,children:C?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ogx__aggregation-label",children:C}),s.jsx("span",{className:"ogx__aggregation-value",children:ao(N,C,b,o)})]}):null},b.field)})]})}function da({noRowsLabel:e,width:t,overlay:o}){return o?s.jsx("div",{className:"ogx__empty",style:{width:t},children:o}):s.jsxs("div",{className:"ogx__empty",style:{width:t},children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),s.jsx("span",{children:e})]})}function Vr({dataSource:e,paginationMode:t,sortingMode:o,filterMode:n}){return!!e&&(t==="server"||t==="infinite"||o==="server"||n==="server")}const zr=Number.MAX_SAFE_INTEGER,ca="An unexpected error occurred while loading the data.";function Kr(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:ca}function ua({error:e,onRetry:t}){if(!e)return null;const o=Kr(e);return s.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),s.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),s.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&s.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}const Gt=({indeterminate:e=!1,label:t,className:o="",inputRef:n,...r})=>{const i=a.useRef(null),l=a.useCallback(d=>{i.current=d,typeof n=="function"?n(d):n&&(n.current=d)},[n]);a.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const c=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return s.jsxs("label",{className:c,children:[s.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),s.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&s.jsx("span",{className:"ogx-checkbox__label",children:t})]})},fa=50;function cn(e,t,o,n){const r=Math.min(o??fa,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const ga=16;function pa(e){e.preventDefault(),e.stopPropagation()}function ha(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function wa(e){const{field:t,currentWidth:o,onResize:n,minWidth:r,maxWidth:i,edge:l="end"}=e,[c,d]=a.useState(!1),u=a.useRef(null);a.useEffect(()=>()=>{u.current=null},[]);const g=a.useCallback((p,b)=>{const y=b-p.startX,C=p.startWidth+(l==="start"?-y:y);return cn(C,p.startWidth,r,i)},[l,r,i]),m=a.useCallback(p=>{if(p.button===0){p.stopPropagation(),u.current={pointerId:p.pointerId,startX:p.clientX,startWidth:o,lastUpdate:0,moved:!1},d(!0);try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}}},[o]),x=a.useCallback(p=>{const b=u.current;if(!b||p.pointerId!==b.pointerId||(p.clientX!==b.startX&&(b.moved=!0),!b.moved))return;const y=Date.now();y-b.lastUpdate>=ga&&(b.lastUpdate=y,n(t,g(b,p.clientX)))},[t,n,g]),v=a.useCallback((p,b)=>{const y=u.current;!y||p.pointerId!==y.pointerId||(u.current=null,d(!1),(y.moved||p.clientX!==y.startX)&&(ha(),b&&n(t,g(y,p.clientX))))},[t,n,g]),h=a.useCallback(p=>{if(p.key!=="ArrowLeft"&&p.key!=="ArrowRight")return;p.preventDefault(),p.stopPropagation();const b=(p.shiftKey?50:10)*(p.key==="ArrowRight"?1:-1);n(t,cn(o+b,o,r,i))},[t,o,n,r,i]),f=a.useCallback(p=>{p.preventDefault(),p.stopPropagation()},[]),w=["ogx-column-resize-handle",l==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return s.jsx("div",{className:w,onPointerDown:m,onMouseDown:pa,onPointerMove:x,onPointerUp:p=>v(p,!0),onPointerCancel:p=>v(p,!1),onClick:p=>p.stopPropagation(),onDragStart:p=>{p.preventDefault(),p.stopPropagation()},onDoubleClick:f,onKeyDown:h,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(o),"aria-valuemin":Math.round(Math.min(r??50,o)),"aria-valuemax":i,tabIndex:-1,children:s.jsx("div",{className:"ogx-column-resize-handle__line"})})}function jr(e){if(!e)return 0;let t=0;const o=(n,r)=>{t=Math.max(t,r);for(const i of n.children)typeof i!="string"&&o(i,r+1)};return e.forEach(n=>o(n,1)),t}function Ur(e){const t=new Map;if(!e)return t;const o=(n,r)=>{const i=[...r,n];for(const l of n.children)typeof l=="string"?t.has(l)||t.set(l,i):o(l,i)};return e.forEach(n=>o(n,[])),t}function un(e,t,o){if(!e||e.length===0)return!0;const n=Ur(e),r=n.get(t),i=n.get(o);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function ma(e,t,o){const n=[];let r=0,i=null,l=null;for(const c of e){const d=c.isSpacer?null:t.get(c.field)?.[o]??null;(i===null||l!==d||i.pinned!==c.pinned)&&(i={key:`${d?d.groupId:"filler"}-${o}-${c.field}`,isGroup:d!==null,label:d?.headerName??"",headerClassName:d?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:c.pinned},l=d,n.push(i)),i.width+=c.width,i.flexGrow+=c.flex??0,c.isSpacer||(i.fields.push(c.field),r++)}return n}function xt(){return document.documentElement.clientWidth||window.innerWidth}function xa(){return document.documentElement.clientHeight||window.innerHeight}function bt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:s.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function vt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function ba(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function va(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),s.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function ya(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ca(){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function _a(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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"}),s.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Sa(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),s.jsx("polyline",{points:"11 8 4 12 11 16"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function ka(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),s.jsx("polyline",{points:"13 8 20 12 13 16"}),s.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Ea(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),s.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Xr=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Ma({colDef:e,sortModel:t,onSort:o,onHide:n,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:d}){const u=a.useRef(null),g=a.useCallback(W=>{W&&(d?.closest('[role="columnheader"]')??d)?.focus({preventScroll:!0}),c()},[d,c]),m=W=>{const X=Xr(u.current),S=X.indexOf(W.target);let M=-1;if(W.key==="ArrowDown")M=S+1>=X.length?0:S+1;else if(W.key==="ArrowUp")M=S<=0?X.length-1:S-1;else if(W.key==="Home")M=0;else if(W.key==="End")M=X.length-1;else if(W.key==="Tab"){W.preventDefault(),g(!0);return}else return;W.preventDefault(),X[M]?.focus()},[x,v]=a.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});a.useLayoutEffect(()=>{if(!d||!u.current)return;const W=d.getBoundingClientRect(),X=u.current.getBoundingClientRect(),S=xt(),M=xa(),I=8;let _=W.left;_+X.width+I>S&&(_=S-X.width-I),_<I&&(_=I);let F=W.bottom+4;F+X.height+I>M&&(F=W.top-X.height-4),v({position:"fixed",zIndex:1300,top:F,left:_,visibility:"visible"})},[d]);const h=x.visibility==="visible";a.useLayoutEffect(()=>{h&&Xr(u.current)[0]?.focus({preventScroll:!0})},[h]),a.useEffect(()=>{function W(S){u.current&&!u.current.contains(S.target)&&d&&!d.contains(S.target)&&c()}function X(S){S.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",W),document.addEventListener("keydown",X),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",X),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[d,c,g]);const f=W=>{o?.(e.field,W),g(!0)},w=!!n&&e.hideable!==!1,p=!!r&&e.pinnable!==!1,b=()=>{w&&n?.(e.field),g(!0)},y=W=>{p&&r?.(e.field,W),g(!0)},C=t?.find(W=>W.field===e.field)?.sort,N=C==null,T=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,P=!T&&!E,O=e.headerName||e.field;return tt.createPortal(s.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${O}`,onKeyDown:m,children:[o&&e.sortable!==!1&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(va,{})}),"Sort Ascending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ya,{})}),"Sort Descending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":N,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ca,{})}),"Unsort"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),s.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":T,"aria-label":"Pin to left",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Sa,{})}),"Pin to Left"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>y("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ka,{})}),"Pin to Right"]}),s.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:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ea,{})}),"Unpin"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),w&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${O} column`,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(_a,{})}),"Hide Column"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ba,{})}),"Manage columns"]})]}),d?.closest(".ogx-theme-provider")||document.body)}function Na(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:s.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 Pa(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:s.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function qr(e){const{columns:t,allColumns:o,columnGroupingModel:n,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:c,onSort:d,sortModel:u=[],onColumnResize:g,columnWidths:m={},pinnedColumns:x,hasDetailPanel:v=!1,pinCheckboxColumn:h=!0,pinExpandColumn:f=!0,rowReordering:w=!1,aggregationModel:p,draggedColumn:b,dragOverColumn:y,onDragStart:C,onDragOver:N,onDragEnd:T,onDrop:E,focusedCell:P,onHeaderClick:O,onSortAdd:W,multiSort:X=!1,onHideColumn:S,onPinColumn:M,onManageColumns:I,columnIndexMap:_}=e,F=a.useId(),[A,q]=a.useState(null),K=k=>L=>{L.stopPropagation(),q({colDef:k,anchorEl:L.currentTarget})},J=a.useCallback(()=>{q(null)},[]),te=k=>L=>{if(L.altKey&&(L.key==="ArrowLeft"||L.key==="ArrowRight")&&L.target===L.currentTarget){if(k.resizable===!1||!g)return;L.preventDefault(),L.stopPropagation();const ue=ot(k,m),he=(L.shiftKey?50:10)*(L.key==="ArrowRight"?1:-1);g(k.field,cn(ue+he,ue,k.minWidth,k.maxWidth));return}if(!(L.altKey&&L.key==="ArrowDown"||(L.ctrlKey||L.metaKey)&&L.key==="Enter")||k.disableColumnMenu||L.target!==L.currentTarget)return;L.preventDefault(),L.stopPropagation();const ce=L.currentTarget.querySelector(".ogx__menu-icon-btn")??L.currentTarget;q({colDef:k,anchorEl:ce})},ne=k=>P?.id===null&&P.field===k,Z=w?1:0,de=v?Z+1:Z,ae=r?de+1:de,oe=k=>L=>{if(k.sortable===!1)return;const Q=u.find(ce=>ce.field===k.field);let ee="asc";Q&&(Q.sort==="asc"?ee="desc":ee=null),(L.shiftKey||X)&&W?W(k.field,ee):d&&d(k.field,ee)},se=(k,L)=>{const Q=u.some(ce=>ce.field===k);W&&(L===null||Q||X||!d)?W(k,L):d?.(k,L)},re=k=>{const L=u.find(ee=>ee.field===k);if(!L)return null;const Q=u.length>1?u.indexOf(L)+1:null;return s.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${L.sort}`,"aria-hidden":"true",children:Q!==null&&s.jsx("span",{className:"ogx__sort-badge",children:Q})})},B=a.useMemo(()=>Go(t,m,x,r,h,v,f,w),[t,m,x,r,h,v,f,w]),D=a.useMemo(()=>Wo(t,x),[t,x]),$=jr(n),R=a.useMemo(()=>Ur(n),[n]),U=a.useMemo(()=>$===0?[]:(o??t).map(k=>({field:k.field,width:ot(k,m),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:Xe(k.field,x),isSpacer:k.isSpacer})),[$,o,t,m,x]),H=(w?48:0)+(v?48:0)+(r?48:0),j=(w||v||r)&&(!v||f)&&(!r||h),z=(w?1:0)+(v?1:0)+(r?1:0);return s.jsxs("div",{className:"ogx__header-wrap",children:[$>0&&Array.from({length:$},(k,L)=>{const Q=ma(U,R,L);return s.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":L+1,children:[H>0&&s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${j?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:H,minWidth:H,flexShrink:0,position:j?"sticky":void 0,left:j?0:void 0},"aria-hidden":"true"}),Q.map(ee=>{const ce=ee.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ee.pinned}`:"",ue={width:ee.width,minWidth:ee.width,flexShrink:0,flexGrow:ee.flexGrow};return ee.pinned==="left"?(ue.position="sticky",ue.left=B[ee.fields[0]]):ee.pinned==="right"&&(ue.position="sticky",ue.right=B[ee.fields[ee.fields.length-1]]),ee.isGroup?s.jsx("div",{role:"columnheader","aria-colspan":ee.fields.length,"aria-colindex":z+ee.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${ce}${ee.headerClassName?` ${ee.headerClassName}`:""}`,style:ue,title:ee.label,children:s.jsx("span",{className:"ogx-col-group-cell__label",children:ee.label})},ee.key):s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${ce}`,style:ue,"aria-hidden":"true"},ee.key)})]},`ogx-grp-${L}`)}),s.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":$+1,children:[w&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${ne("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":Z,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),v&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${ne("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":de,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:f?"sticky":void 0,left:f?w?48:0:void 0}}),r&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${ne("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:h?"sticky":void 0,left:h?(w?48:0)+(v&&f?48:0):void 0},children:c&&s.jsx(Gt,{id:F,name:F,checked:i,indeterminate:l,onChange:k=>c(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,L)=>{if(k.isSpacer)return s.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const Q=k.sortable!==!1,ee=u.findIndex(Pe=>Pe.field===k.field),ce=ee!==-1,ue=ce?u[ee].sort:null,he=_?.get(k.field)??L,be=Q?ee===0?ue==="asc"?"ascending":"descending":"none":void 0,Ce=ce&&u.length>1?`Sorted ${ue==="asc"?"ascending":"descending"}, sort priority ${ee+1} of ${u.length}`:void 0,fe=k.resizable!==!1,me=Xe(k.field,x),ve=me!==null,Se=b===k.field,le=y===k.field,ye=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,Q&&"ogx__header-cell--sortable",ce&&"ogx__header-cell--sorted",ve&&"ogx__header-cell--pinned",ve&&`ogx__header-cell--pinned-${me}`,me==="left"&&k.field===D.lastLeft&&"ogx__header-cell--pinned-left-last",me==="right"&&k.field===D.firstRight&&"ogx__header-cell--pinned-right-first",Se&&"ogx__header-cell--dragging",le&&"ogx__header-cell--drag-over",ne(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),xe={width:m[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:ve?"sticky":"relative",zIndex:k.zIndex,opacity:Se?.5:1};if(ve&&me){const Pe=B[k.field];me==="left"?xe.left=Pe:xe.right=Pe}const Ee=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:he}):k.headerName||k.field,ie=Pe=>{if(Pe.target.closest(".ogx-column-resize-handle")){Pe.stopPropagation();return}O?.(k.field),Q&&oe(k)(Pe)},ge=C&&!ve?C(k.field):void 0,we=N&&!ve?N(k.field):void 0,Me=E&&!ve?E(k.field):void 0;return s.jsxs("div",{className:ye,style:xe,title:k.description,onClick:ie,role:"columnheader",draggable:!!ge,onDragStart:ge,onDragOver:we,onDragEnd:T,onDrop:Me,onKeyDown:te(k),"aria-sort":be,"aria-description":Ce,"aria-colindex":z+he+1,"data-field":k.field,tabIndex:-1,children:[s.jsxs("div",{className:"ogx__header-cell-content",children:[Se&&s.jsx("div",{className:"ogx__header-drag-icon",children:s.jsx(Pa,{})}),s.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[s.jsx("span",{className:"ogx__header-cell-title",children:Ee}),p&&p[k.field]&&s.jsx("span",{className:"ogx__header-cell-aggregation",children:p[k.field]})]}),Q&&re(k.field),!k.disableColumnMenu&&s.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:K(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:s.jsx(Na,{})})]}),fe&&g&&s.jsx(wa,{field:k.field,currentWidth:ot(k,m),onResize:g,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:me==="right"?"start":"end"})]},k.field)}),A&&s.jsx(Ma,{colDef:A.colDef,sortModel:u,onSort:d||W?se:void 0,onHide:S,onPin:M,pinnedColumns:x,onManageColumns:I,onClose:J,anchorEl:A.anchorEl})]})]})}const lt=()=>{};function Yr(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:lt,selectRows:lt,getSelectedRows:()=>[],sortColumn:lt,getSortModel:()=>[],setFilterModel:lt,getFilterModel:()=>({items:[]}),setPage:lt,setPageSize:lt,scrollToIndexes:lt,copySelectedRows:()=>Promise.resolve()}}const Ia=e=>e.id;let Rr=!1;function Jr(e,t,o){const n=new Map,r=new Map,i=[],l=[];return e.forEach(c=>{const d=o?.get(c)??t(c);if(n.has(d)){l.push(d);return}n.set(d,c),r.set(c,d),i.push(d)}),l.length>0&&!Rr&&process.env.NODE_ENV!=="production"&&(Rr=!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:n,allRows:i,idByRow:r}}function Ta(e,t,o,n={}){const r=new Map,i=[];return o.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Jr(e,t),columns:{all:o,lookup:r,orderedFields:i,columnVisibilityModel:n},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Fa(e,t){switch(t.type){case"SET_ROWS":{const o=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),n=typeof t.payload=="function"?t.payload(o):t.payload;return{...e,rows:Jr(n,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const o=e.rows.idRowsLookup.get(t.id);if(o===void 0)return e;const n=new Map(e.rows.idRowsLookup);n.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(o),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:n,idByRow:r}}}case"SET_COLUMNS":{const o=new Map,n=[];return t.payload.forEach(r=>{o.set(r.field,r),n.push(r.field)}),{...e,columns:{all:t.payload,lookup:o,orderedFields:n,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 La(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,d=e.getRowId??Ia,u=a.useRef(d);a.useLayoutEffect(()=>{u.current=d});const[g]=a.useState(()=>Ta(t,d,o,i)),[m,x]=a.useReducer(Fa,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:n,headerHeight:r}}),[v,h]=a.useState({rows:t,syncRows:c});(v.rows!==t||v.syncRows!==c)&&(h({rows:t,syncRows:c}),c&&x({type:"SET_ROWS",payload:t,getRowId:d}));const f=a.useRef(m);a.useLayoutEffect(()=>{f.current=m});const w=a.useCallback((O,W)=>{x({type:"SET_ROWS",payload:O,getRowId:u.current})},[]),p=a.useCallback((O,W)=>{x({type:"REPLACE_ROW",id:O,row:W})},[]),b=a.useCallback(O=>{x({type:"SET_COLUMNS",payload:O})},[]),y=a.useCallback((O,W)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:O,viewportHeight:W}})},[]),C=a.useCallback(O=>{x({type:"SET_DATASOURCE_LOADING",payload:O})},[]),N=a.useCallback(O=>{x({type:"SET_DATASOURCE_ERROR",payload:O})},[]),T=a.useCallback(O=>{x({type:"SET_ROW_COUNT",payload:O})},[]),[E]=a.useState(()=>({...Yr(),getRow:O=>f.current.rows.idRowsLookup.get(O)||null,getAllRows:()=>f.current.rows.allRows.map(O=>f.current.rows.idRowsLookup.get(O)),getColumn:O=>f.current.columns.lookup.get(O)||null,getAllColumns:()=>f.current.columns.all})),P=a.useRef(E);return{state:m,dispatch:x,apiRef:P,setRows:w,replaceRow:p,setColumns:b,setDimensions:y,setDataSourceLoading:C,setDataSourceError:N,setRowCount:T}}function Oa(e){const{onRowOrderChange:t,rows:o,getRowId:n,rowReordering:r=!1}=e,[i,l]=a.useState(null),[c,d]=a.useState(null),u=a.useRef(()=>{}),g=a.useMemo(()=>{const w=new Map;return o.forEach((p,b)=>w.set(n?n(p):p.id,b)),w},[o,n]),m=a.useCallback(w=>g.has(w),[g]),x=a.useCallback(()=>{u.current(),u.current=()=>{},l(null),d(null)},[]);a.useEffect(()=>()=>u.current(),[]);const v=a.useCallback(w=>p=>{if(r){if(!g.has(w)){p.preventDefault();return}u.current(),u.current=Tr(p.currentTarget,x),l(w),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Ir(p,ln,String(w)))}},[r,g,x]),h=a.useCallback(w=>p=>{if(!(!r||i===null)){if(!go(p,ln)){x();return}g.has(w)&&(p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),c!==w&&d(w))}},[r,i,c,g,x]),f=a.useCallback(w=>p=>{if(p.preventDefault(),i===null||!go(p,ln)){x();return}const b=g.get(i),y=g.get(w);x(),t&&b!==void 0&&y!==void 0&&b!==y&&t({row:o[b],oldIndex:b,targetIndex:y})},[i,t,o,g,x]);return{draggedRowId:i,dragOverRowId:c,canReorderRow:m,onDragStart:r?v:void 0,onDragOver:r?h:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const Qr=new Map,Zr=e=>JSON.stringify(e),Da=e=>`auto-group-${e}`,ei=5,ti=e=>e.slice(0,ei).map(t=>JSON.stringify(t)).join(", ")+(e.length>ei?", …":""),Aa={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function $a(e,t,o){const n=new Map,r=[],i=[],l=new Set,c=new Map,d=new Map,u=[],g=new Array(e.length),m=new Array(e.length),x=[],v=new Map;e.forEach((f,w)=>{const p=t(f),b=o(f),y=Array.isArray(b)?b.map(C=>String(C)):[];if(g[w]=p,m[w]=y,c.set(p,f),y.length===0)x.push(p);else{const C=Zr(y),N=d.get(C);if(N===void 0)d.set(C,p);else{const T=v.get(C)??[N];T.push(p),v.set(C,T)}}n.set(p,{id:p,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const h=f=>{const w=Zr(f),p=d.get(w);if(p!==void 0)return p;const b=Da(w),y=f[f.length-1],C={id:b,parentId:null,depth:f.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};n.set(b,C),d.set(w,b),l.add(b);const N={id:b};if(i.push(N),c.set(b,N),f.length===1)r.push(b);else{const T=h(f.slice(0,-1));C.parentId=T,n.get(T)?.children?.push(b)}return b};return e.forEach((f,w)=>{const p=g[w],b=m[w];if(b.length<=1){r.push(p);return}const y=h(b.slice(0,-1)),C=n.get(p);C&&(C.parentId=y),n.get(y)?.children?.push(p)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${ti(x)}. They are shown as top-level rows.`),v.forEach((f,w)=>{u.push(`[OpenGridX] treeData: rows ${ti(f)} have the same path ${w}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:n,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:c,issues:u}}function Ga(e,t){const{treeNodes:o,rootIds:n,syntheticIds:r,rowLookup:i}=e,l=new Set,c=new Map,d=new Map,u=g=>{const m=o.get(g);if(!m)return!1;const x=[];let v=0;for(const p of m.children??[])u(p)&&(x.push(p),v+=(r.has(p)?0:1)+(d.get(p)??0));c.set(g,x),d.set(g,v);const h=i.get(g),w=!r.has(g)&&h!==void 0&&(t?t(h):!0)||x.length>0;return w&&l.add(g),w};return n.forEach(u),{visible:l,visibleChildren:c,descendantCounts:d}}function Wa(e){const{rows:t,getRowId:o,getTreeDataPath:n,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:c,onRowExpansionChange:d,columnLookup:u,filterMode:g="client",sortingMode:m="client"}=e,x=r&&!!n,v=a.useMemo(()=>!r||!n?Aa:$a(t,o,n),[t,n,r,o]),{treeNodes:h,rootIds:f,groupingRows:w,syntheticIds:p,rowLookup:b}=v,y=v.issues.join(`
|
|
1
|
+
(function(he,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],s):(he=typeof globalThis<"u"?globalThis:he||self,s(he.OpenGridX={},he.ReactJSXRuntime,he.React,he.ReactDOM))})(this,(function(he,s,a,tt){"use strict";function Go(e,t,o){return Math.max(t??0,Math.min(o??1/0,e))}function ot(e,t,o=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const n=t[e.field]??e.width,r=typeof n=="number"&&Number.isFinite(n)?n:o;return Go(r,e.minWidth,e.maxWidth)}const je=48;function Xe(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function _l(e,t){const o=[],n=[],r=[];return t?(e.forEach(i=>{const l=Xe(i.field,t);l==="left"?o.push(i):l==="right"?r.push(i):n.push(i)}),t.left&&o.sort((i,l)=>{const c=t.left.indexOf(i.field),d=t.left.indexOf(l.field);return c-d}),t.right&&r.sort((i,l)=>{const c=t.right.indexOf(i.field),d=t.right.indexOf(l.field);return c-d}),{left:o,center:n,right:r}):{left:o,center:e,right:r}}function Wo(e,t,o,n,r,i,l,c){const d={};if(!o)return d;let u=(c?je:0)+(i&&l?je:0)+(n&&r?je:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const v=Xe(x.field,o);v==="left"?(d[x.field]=u,u+=ot(x,t)):v==="right"&&g.push(x)});let m=0;for(let x=g.length-1;x>=0;x--)d[g[x].field]=m,m+=ot(g[x],t);return d}function Ho(e,t){let o=null,n=null;if(!t)return{lastLeft:o,firstRight:n};for(const r of e){if(r.isSpacer)continue;const i=Xe(r.field,t);i==="left"?o=r.field:i==="right"&&n===null&&(n=r.field)}return{lastLeft:o,firstRight:n}}function zn(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Sl(e,t,o=n=>n.id){const n=[],r=[],i=[];return t?(e.forEach(l=>{const c=zn(o(l),t);c==="top"?n.push(l):c==="bottom"?i.push(l):r.push(l)}),t.top&&n.sort((l,c)=>{const d=t.top.indexOf(o(l)),u=t.top.indexOf(o(c));return d-u}),t.bottom&&i.sort((l,c)=>{const d=t.bottom.indexOf(o(l)),u=t.bottom.indexOf(o(c));return d-u}),{top:n,center:r,bottom:i}):{top:n,center:e,bottom:i}}function kl(e,t,o){const n=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return o==="left"?{left:[...n,t],right:r}:o==="right"?{left:n,right:[...r,t]}:{left:n,right:r}}const Kn=new Set;function jn(e,t,o){process.env.NODE_ENV==="production"||Kn.has(e)||(Kn.add(e),console.warn(`[OpenGridX] ${t}.`,o))}function ro(e,t,o,n){try{return e()}catch(r){return jn(o,n,r),t}}function Un(e,t,o){const n=e[t];if(!o?.valueGetter)return{value:n};try{return{value:o.valueGetter({row:e,field:t,value:n})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Fe(e,t,o){const{value:n,error:r}=Un(e,t,o);return r!==void 0&&jn(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),n}function Bo(e,t,o,n){const r=n?.valueFormatter;if(r)return ro(()=>r({value:o,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function nt(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 o=Number(t);return Number.isNaN(o)?null:o}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 El=/^(\d{4})-(\d{2})-(\d{2})$/;function io(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 o=e.trim();if(o==="")return null;const n=El.exec(o);if(n){const r=Number(n[1]),i=Number(n[2])-1,l=Number(n[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else t=new Date(o)}else return null;return Number.isNaN(t.getTime())?null:t}function lo(e){const t=io(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Xn(e){const t=io(e);if(!t)return"";const o=String(t.getFullYear()).padStart(4,"0"),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${r}`}let qn=null;function Yn(e){return qn??=new Intl.DateTimeFormat,qn.format(e)}function Ml(e,t){if(!e)return;const o=i=>typeof i=="object"?i.value:i,n=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(o(i),t))??e.find(i=>String(o(i))===String(t));return r===void 0?void 0:n(r)}function Vo(e,t){if(e==null)return"";switch(t?.type){case"date":{const o=io(e);return o?Yn(o):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ml(t.valueOptions,e)??String(e);default:return String(e)}}const zo=200;function Ko(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:zo}function jo(e,t){if(e)return ro(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Nl(e,t){const o=Ko(e);return o==="auto"?t??zo:o}function Pl(e,t){if(t.size===0||e.size===0)return e;let o=!1;const n=new Set;for(const r of e)t.get(r)?.isGroupRow?o=!0:n.add(r);return o?n:e}const Il=e=>e.id;function Tl(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 Ll(e,t,o){const n=new Map;e.forEach(f=>{if(!Object.prototype.hasOwnProperty.call(t,f.field)&&f.flex&&f.flex>0){n.set(f.field,{kind:"flex",flex:f.flex});return}const p=Tl(t[f.field]??f.width);p.type==="fixed"?n.set(f.field,{kind:"fixed",width:Go(p.value,f.minWidth,f.maxWidth)}):p.type==="percentage"?n.set(f.field,{kind:"percentage",percentage:p.value}):n.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,w)=>{const p=n.get(w.field);if(p.kind==="fixed")return f+p.width;if(p.kind==="percentage")return f+100;if(w.flex&&w.flex>0){const b=w.minWidth??150;return f+(b||(typeof w.width=="number"?w.width:150))}return f+(w.minWidth??150)},0),i=Math.max(o,r),l=e.reduce((f,w)=>{const p=n.get(w.field);return p.kind==="fixed"?f+p.width:f},0),c=new Map,d=Math.max(0,i-l);let u=0;e.forEach(f=>{const w=n.get(f.field);if(w.kind==="fixed")c.set(f.field,w.width);else if(w.kind==="percentage"){const p=w.percentage/100*d,b=Go(p>0?p:100,f.minWidth??50,f.maxWidth);c.set(f.field,b),u+=b}});const g=Math.max(0,d-u),m=new Map,x=e.flatMap(f=>{const w=n.get(f.field);return w.kind!=="flex"?[]:(m.set(f.field,w.flex),[{field:f.field,flex:w.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let v=0;const h=x.length*2;for(;v<h;){v++;const f=x.filter(E=>!E.frozen);if(f.length===0)break;const w=f.reduce((E,P)=>E+P.flex,0),p=x.reduce((E,P)=>P.frozen?E+P.computedWidth:E,0),b=Math.max(0,g-p);if(w<=0){f.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0});break}const y=b/w;let C=0;const N=[],T=[];if(f.forEach(E=>{const P=y*E.flex;P<E.minWidth?(C+=E.minWidth-P,N.push(E)):P>E.maxWidth?(C+=E.maxWidth-P,T.push(E)):E.computedWidth=P}),N.length===0&&T.length===0){f.forEach(E=>{E.frozen=!0});break}C>0?N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}):C<0?T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}):(N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}),T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}))}return x.forEach(f=>c.set(f.field,f.computedWidth)),{widths:c,flexByField:m}}function Fl(e){const{rowHeight:t,pagination:o,paginatedUnpinnedRows:n,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:c,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:m,visibleOrderedColumns:x,pinnedColumns:v,columnWidths:h,viewportWidth:f,checkboxSelection:w,hasDetailPanel:p,rowReordering:b,pinCheckboxColumn:y,pinExpandColumn:C,paginationMode:N,isLoading:T,pageSize:E,getRowId:P=Il}=e;return a.useMemo(()=>{const O=o?n:r,W=(j,z)=>{const k=P(j);if(!i.has(k))return t;const F=jo(l,{row:j,id:k,rowIndex:z});return t+Nl(F,c?.get(k))},X=O.map((j,z)=>W(j,d+z)),S=X.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]),M=N==="infinite"&&T&&O.length>0?Math.min(E,20):0,I=(S[S.length-1]||0)+M*t,_=(j,z)=>j?j.reduce((k,F,Q)=>k+W(F,Q),0):z*t,L=_(g,d),A=_(m,u),{left:q,center:K,right:J}=_l(x,v),te=(w?je:0)+(p?je:0)+(b?je:0),oe=(b?je:0)+(p&&C?je:0)+(w&&y?je:0),{widths:Z,flexByField:de}=Ll([...q,...K,...J],h,f-te),ae=j=>Z.get(j.field)??100,ne=j=>({...j,width:ae(j),flex:de.get(j.field)??j.flex}),se=11,re=q.map((j,z)=>({...ne(j),zIndex:se+z})),B=11,D=J.map((j,z)=>({...ne(j),zIndex:B+(J.length-1-z)})),$=K.map(ne),R=$.map(j=>j.width),U=re.reduce((j,z)=>j+z.width,0),G=D.reduce((j,z)=>j+z.width,0),V=R.reduce((j,z)=>j+z,0),Y=U+V+G+te,H=R.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]);return{rowHeights:X,cumulativeHeights:S,unpinnedRowsHeight:I,pinnedTopHeight:L,pinnedBottomHeight:A,leftPinnedCols:re,rightPinnedCols:D,unpinnedColsWithWidth:$,unpinnedColWidths:R,unpinnedAccWidths:H,totalWidth:Y,leftWidth:U,rightWidth:G,unpinnedTotalWidth:V,systemColumnsWidth:te,pinnedSystemColumnsWidth:oe,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,unpinnedRowsLength:O.length}},[t,o,n,r,i,l,c,d,u,g,m,x,v,h,f,w,p,b,y,C,N,T,E,P])}function Ol(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Rn(e,t,o,n,r){if(t<0||t>=o.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:c}=e,d=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(n,Ol(e)),g=d+(t===0?0:o[t-1]),m=r!==void 0?Math.min(g+r,d+o[t]):d+o[t];g<l+d?e.scrollTop=Math.max(0,g-d):m>l+c-u&&(e.scrollTop=m-c+u)}function Dl(e,t,o){const{unpinnedAccWidths:n,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:c}=o;if(t<0||t>=n.length)return;const d=l+r,u=d+(t>0?n[t-1]:0),g=d+n[t],m=c+r,{scrollLeft:x,clientWidth:v}=e;u<x+m?e.scrollLeft=Math.max(0,u-m):g>x+v-i&&(e.scrollLeft=g-v+i)}function Jn(e,t){const{row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c,rowMeta:d}=e;if(!i.editable||d?.isGroupRow||o._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c})}catch{return!1}}const Al={},Uo=e=>e==null||typeof e=="string"&&e.trim()==="",Qn=e=>{const t=[];for(const o of e){const n=nt(o);n!==null&&t.push(n)}return t},Zn=(e,t)=>{let o=null,n=null;for(const r of e){const i=nt(r);i!==null&&(o===null||t(i,o))&&(o=i,n=r)}return o===null?null:n instanceof Date?n:o},so={sum:e=>Qn(e).reduce((t,o)=>t+o,0),avg:e=>{const t=Qn(e);return t.length?t.reduce((o,n)=>o+n,0)/t.length:null},count:e=>e.filter(t=>!Uo(t)).length,min:e=>Zn(e,(t,o)=>t<o),max:e=>Zn(e,(t,o)=>t>o),unique:e=>new Set(e.filter(t=>!Uo(t))).size};function Xo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function ao(e,t,o,n){const r={};for(const[i,l]of Object.entries(t)){const c=o.get(i);if(!Xo(c,l))continue;const d=so[l];if(!d){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=d(e.map(u=>Fe(u,i,c)))}return r}function qo(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const $l=new Set(["count","unique"]);function er(e){return e!==void 0&&$l.has(e)}function tr(e,t,o){return e?.type==="date"&&(t==="min"||t==="max")&&typeof o=="number"&&Number.isFinite(o)?new Date(o):o}function co(e,t,o,n){if(e==null)return"—";if(er(t))return qo(e,t);const r=tr(o,t,e);if(o?.valueFormatter)try{return String(o.valueFormatter({value:r,row:n??{},field:o.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Yn(r):qo(r,t)}const Yo=new Set(["isEmpty","isNotEmpty"]);function or(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Gl(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Ot=e=>(t,o)=>{const n=nt(t),r=nt(o);return n===null||r===null?!1:e(n,r)},Dt=e=>(t,o)=>{const n=lo(t),r=lo(o);return n===null||r===null?!1:e(n,r)},nr=Dt((e,t)=>e===t),rr=(e,t)=>{const o=lo(e),n=lo(t);return o===null||n===null?!0:o!==n},ir={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()!=="","=":Ot((e,t)=>e===t),">":Ot((e,t)=>e>t),">=":Ot((e,t)=>e>=t),"<":Ot((e,t)=>e<t),"<=":Ot((e,t)=>e<=t),"!=":(e,t)=>{if(or(t))return!0;const o=nt(e),n=nt(t);return o!==null&&n!==null?o!==n:Gl(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const o=Array.isArray(t)?t:[t],n=String(e).toLowerCase();return o.some(r=>r!=null&&String(r).toLowerCase()===n)},not:(e,t)=>e instanceof Date?rr(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:Dt((e,t)=>e>t),onOrAfter:Dt((e,t)=>e>=t),before:Dt((e,t)=>e<t),onOrBefore:Dt((e,t)=>e<=t)},Wl={is:nr,not:rr};function Hl(e,t){if(!Object.prototype.hasOwnProperty.call(ir,e))return;const o=e;if(t?.type==="date"){const n=Wl[o];if(n)return n}return ir[o]}function Bl(e){return"items"in e&&Array.isArray(e.items)}function Vl(e,t){const{field:o,operator:n,value:r}=e;if(!Yo.has(n)&&or(r))return null;const i=t.columns?.byField.get(o),l=Hl(n,i);return l?c=>l(Fe(c,o,i),r):(t.warned.has(n)||(t.warned.add(n),console.warn(`Unknown filter operator: ${n}`)),null)}function lr(e,t,o){const n=[];for(const r of e){const i=Bl(r)?lr(r.items,r.logicOperator,o):Vl(r,o);i&&n.push(i)}return n.length===0?null:n.length===1?n[0]:t==="or"?r=>n.some(i=>i(r)):r=>n.every(i=>i(r))}function Ro(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 o=Xn(t);o&&e.push(o);return}if(Array.isArray(t))for(const o of t)(o==null||typeof o!="object")&&Ro(e,o)}}function sr(e,t){const o=[];if(!t){for(const n of Object.values(e))Ro(o,n);return o}for(const n of t.quickFilterColumns){const r=Fe(e,n.field,n),i=Bo(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Ro(o,r)}return o}const ar=new WeakMap;function zl(e,t){if(!t)return sr(e,t);let o=ar.get(t);o||(o=new WeakMap,ar.set(t,o));let n=o.get(e);return n||(n=sr(e,t),o.set(e,n)),n}function Kl(e,t){const o=(e??[]).map(n=>String(n??"").trim().toLowerCase()).filter(n=>n!=="");return o.length===0?null:n=>{const r=zl(n,t);return o.every(i=>r.some(l=>l.includes(i)))}}function uo(e,t){if(!e)return null;const o={columns:t,warned:new Set},n="quickFilterValues"in e?e.quickFilterValues:void 0,r=Kl(n,t),i=lr(e.items??[],e.logicOperator??"and",o);return r&&i?l=>r(l)&&i(l):r??i}function Jo(e,t,o){const n=uo(t,o);return n?e.filter(r=>n(r)):e}function jl(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 Ul=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Qo=0,dr=1,Xl=2,cr=3,ur=4;function ht(e,t){return{rank:e,num:t,str:""}}function Zo(e,t){if(e==null)return null;if(t==="number"){const o=nt(e);return o===null?null:ht(Qo,o)}if(t==="date"){const o=io(e);return o?ht(dr,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(Qo,e);case"bigint":return ht(Qo,Number(e));case"boolean":return ht(Xl,e?1:0);case"string":return{rank:cr,num:0,str:e}}if(e instanceof Date){const o=e.getTime();return Number.isNaN(o)?null:ht(dr,o)}return{rank:ur,num:0,str:String(e)}}function fr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===cr||e.rank===ur?Ul.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function gr(e,t){return e===0?0:t==="asc"?e:-e}function ql(e,t,o,n){return gr(fr(Zo(e,n),Zo(t,n)),o)}function Yl(e,t,o){return t.length===0?e:en(e,t,(n,r)=>{const i=o?.byField.get(r.field);return{value:Fe(n,r.field,i),type:i?.type}})}function en(e,t,o){if(t.length===0||e.length<2)return[...e];const n=t.map(i=>e.map(l=>{const{value:c,type:d}=o(l,i);return Zo(c,d)})),r=e.map((i,l)=>l);return r.sort((i,l)=>{for(let c=0;c<t.length;c++){const d=gr(fr(n[c][i],n[c][l]),t[c].sort);if(d!==0)return d}return i-l}),r.map(i=>e[i])}function Rl(e,t,o){if(!o)return e.filter(r=>r.field!==t);const n=e.findIndex(r=>r.field===t);return n===-1?[...e,{field:t,sort:o}]:e.map((r,i)=>i===n?{field:t,sort:o}:r)}function tn(e,t={}){const o=new Map,n=[];for(const r of e)o.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&n.push(r);return{byField:o,quickFilterColumns:n}}const wt="__pivot_grand_total__",Jl="__pivot_row__:",pr=e=>`${Jl}${JSON.stringify(e.split(hr))}`,Ql="Grand Total",hr="\0",mt="",on=`${mt}id`,wr=e=>e==="id"?on:e,nn={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},mr=e=>e.map(t=>String(t??"")).join(hr),xr=e=>e===void 0||e===""?null:e;function Zl(e,t){const o=e==null,n=t==null;return o||n?o===n?0:o?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 es(e,t){for(let o=0;o<e.length;o++){const n=Zl(e[o],t[o]);if(n!==0)return n}return 0}function br(e,t){if(!e||e.length===0)return null;const o=so[t](e);return typeof o=="number"||o instanceof Date?o:null}const ts=e=>"logicOperator"in e&&"items"in e,os=e=>!!(e&&e.items&&e.items.length>0);function ns(e,t){const o=l=>!t.has(l)&&l.includes(mt),n=l=>ts(l)?l.items.length>0&&l.items.every(n):o(l.field),r=[],i=[];for(const l of e.items??[])(n(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function vr(e,t,o,n={}){const r=new Map(t.map(S=>[S.field,S])),i=S=>r.get(S)?.groupable!==!1,l=o.rowFields.filter(i),c=o.columnFields.filter(i),d=new Set,u=o.valueFields.filter(S=>{if(!Xo(r.get(S.field),S.aggFn))return!1;const M=`${S.field}${mt}${S.aggFn}`;return d.has(M)?!1:(d.add(M),!0)});if(l.length===0||u.length===0)return nn;const g=c.length>0,m=Array.from(new Set(u.map(S=>S.field))),x=(S,M)=>Fe(S,M,r.get(M)),v=new Map,h=new Map(g?[]:[["",{values:[]}]]);for(const S of e){const M=l.map(J=>x(S,J)),I=mr(M);let _=v.get(I);_||(_={labels:M.map(xr),sample:S,cells:new Map},v.set(I,_));const L=c.map(J=>x(S,J)),A=g?mr(L):"",q=h.get(A);q?q.sample||(q.sample=S):h.set(A,{values:L.map(xr),sample:S});let K=_.cells.get(A);K||(K=new Map,_.cells.set(A,K));for(const J of m){const te=x(S,J);if(Uo(te))continue;let oe=K.get(J);oe||(oe=[],K.set(J,oe)),oe.push(te)}}const f=Array.from(h.keys()).sort((S,M)=>es(h.get(S).values,h.get(M).values)),w=(S,M)=>g?`${S}${mt}${M.field}${mt}${M.aggFn}`:`${M.field}${mt}${M.aggFn}`,p=new Map;let b=[];for(const[S,M]of v){const I={id:pr(S)};l.forEach((_,L)=>{I[wr(_)]=M.labels[L]}),I.id=pr(S);for(const _ of f){const L=M.cells.get(_);for(const A of u)I[w(_,A)]=br(L?.get(A.field),A.aggFn)}p.set(I.id,M),b.push({row:I,entry:M})}const y=S=>l.includes(S),C=S=>y(S)?r.get(S)?.type:"number",{outputFilterModel:N,sortModel:T}=n;if(os(N)){const S=[];for(const I of f)for(const _ of u)S.push({field:w(I,_),type:"number"});const M=uo(N,tn(S));M&&(b=b.filter(({row:I})=>M(I)))}const E=(S,M)=>M==="id"&&y("id")?S[on]:S[M];T&&T.length>0&&(b=[...b].sort((S,M)=>{for(const I of T){const _=ql(E(S.row,I.field),E(M.row,I.field),I.sort,C(I.field));if(_!==0)return _}return 0}));const P=b.map(S=>S.row);if(b.length>0){const S={id:wt};l.forEach((M,I)=>{S[wr(M)]=I===0?Ql:""}),S.id=wt;for(const M of f)for(const I of m){const _=[];for(const{entry:L}of b){const A=L.cells.get(M)?.get(I);if(A)for(const q of A)_.push(q)}for(const L of u)L.field===I&&(S[w(M,L)]=br(_,L.aggFn))}P.push(S)}const O=b[0]?.entry.sample,W=S=>S===wt?O:S===void 0?void 0:p.get(S)?.sample,X=l.map(S=>is(S,r.get(S),W));for(const S of f){const M=h.get(S),I=g?c.map((_,L)=>{const A=r.get(_),q=rs(A,_,M.values[L],M.sample);return A?.headerName?`${A.headerName}: ${q}`:q}).join(" / "):"";for(const _ of u){const L=r.get(_.field),A=_.headerName??L?.headerName??_.field;X.push({field:w(S,_),headerName:I?`${I} — ${A} (${_.aggFn})`:`${A} (${_.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:q,row:K})=>co(q,_.aggFn,L,K)})}}return{pivotRows:P,pivotColumns:X,colKeys:f,isValid:!0}}function rs(e,t,o,n){const r=n?Bo(n,t,o,e):void 0;return r!==void 0?r:o==null?"":String(o)}function is(e,t,o){const n={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(n.type=t.type),t.align!==void 0&&(n.align=t.align),t.headerAlign!==void 0&&(n.headerAlign=t.headerAlign),t.description!==void 0&&(n.description=t.description),t.minWidth!==void 0&&(n.minWidth=t.minWidth),t.maxWidth!==void 0&&(n.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(n.valueOptions=t.valueOptions)),e==="id"&&(n.valueGetter=({row:c})=>c[on]);const r=c=>c?.id===wt,i=t?.valueFormatter;i&&(n.valueFormatter=({value:c,row:d})=>r(d)?String(c??""):i({value:c,row:o(d?.id)??d,field:e}));const l=t?.renderCell;return l&&(n.renderCell=c=>r(c.row)?c.formattedValue??String(c.value??""):l({...c,row:o(c.row.id)??c.row})),n}function qe(e,t){return e===wt||t?.get(e)?.isGroupRow===!0}const At="__reorder_col__",$t="__expand_col__",Ye="__checkbox_col__",rt=e=>e===At||e===$t||e===Ye,yr=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,ls=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),ss=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function as(e){const t=e.tagName;if(t==="INPUT")return!ls.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const o=e.getAttribute("role");return o!==null&&ss.has(o)}const Cr=e=>e!==null&&e.nodeType===1;function _r(e,t){const o=e.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const n=e.closest('[role="gridcell"], [role="columnheader"]');return!n||n.closest(".ogx__viewport")!==t?null:n}function ds(e,t){if(e===t)return"grid";if(!Cr(e)||!t.contains(e))return"foreign";const o=_r(e,t);return o?o.classList.contains("ogx__cell--editing")?"editor":o===e?"grid":as(e)?"foreign":o.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function cs(e,t,o,n){if(!Cr(e))return null;const r=_r(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")),c=Number.isInteger(l)?o[l]:void 0;return c?{id:n(c),field:i,rowIndex:l}:null}function Sr(e,t){if(!e)return null;for(const o of Array.from(e.children))if(o.dataset.field===t)return o;return null}function rn(e,t,o){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Sr(r,t.field);return i&&t.field===Ye?i.querySelector("input")??i:i}if(o<0)return null;const n=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${o}"]`);return Sr(n,t.field)}const us=e=>e.id,kr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function fs(e,t,o,n){if(!e||o.length===0)return{cell:null,rowIndex:-1};const r=(o.find(d=>!rt(d.field))??o[0]).field,i=o.some(d=>d.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 c=l!==void 0&&t[l]&&n(t[l])===e.id?l:t.findIndex(d=>n(d)===e.id);return c===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(c=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:n(t[c]),field:i,rowIndex:c},rowIndex:c}):{cell:i===e.field?e:{...e,field:i},rowIndex:c}}function gs(e){const{allRenderableRows:t,navigationColumns:o,checkboxSelection:n,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:c,setKeyboardMode:d,sortModel:u,handleSort:g,handleSortAdd:m,multiSort:x=!1,isCellEditable:v,pagination:h,pageSize:f,virtualization:w,viewportRef:p,pinnedTopRowCount:b=0,getRowId:y=us,rowMetaMap:C,onRowActivate:N,toggleRowExpansion:T,handleSelectAll:E,rowSelectionEnabled:P=!0,multipleRowSelectionEnabled:O=!0,pinCheckboxColumn:W=!0,pinExpandColumn:X=!0,rowHeight:S,getSpanOrigin:M}=e,[I,_]=a.useState(null),[L,A]=a.useState(!1),q=a.useMemo(()=>fs(I,t,o,y),[I,t,o,y]),K=q.cell,J=q.rowIndex,te=a.useRef(!1),oe=a.useRef(!1),Z=a.useRef(!1),de=a.useRef(null),ae=a.useCallback(G=>{oe.current=!0,G.focus({preventScroll:!0}),oe.current=!1},[]),ne=a.useCallback(()=>{const G=p.current;G&&!G.contains(G.ownerDocument.activeElement)&&ae(G)},[p,ae]),se=a.useMemo(()=>o.find(G=>!rt(G.field))??o[0],[o]),re=a.useCallback(()=>{if(n)return{id:null,field:Ye};if(!se)return null;const G=t[0];return G?{id:y(G),field:se.field,rowIndex:0}:{id:null,field:se.field}},[n,se,t,y]),B=a.useCallback((G,V)=>{const Y=p.current;if(!Y)return;const{cumulativeHeights:H,pinnedBottomHeight:j,columnMetrics:z}=w;if(G>=0&&Rn(Y,G-b,H,j,S),rt(V)){!(V===At||V===$t&&X||V===Ye&&W)&&Y.scrollLeft>0&&(Y.scrollLeft=0);return}if(!z)return;const{clientWidth:k,scrollLeft:F}=Y,{leftPinnedWidth:Q,rightPinnedWidth:ee,unpinnedAccWidths:ce,unpinnedCols:fe,totalSpecialsWidth:ge,pinnedSpecialsWidth:be}=z,Ce=fe.findIndex(ye=>ye.field===V);if(Ce===-1)return;const ue=ge+Q+(Ce>0?ce[Ce-1]:0),me=ge+Q+ce[Ce],ve=F+be+Q,Se=F+k-ee;let le=F;ue<ve?le=Math.max(0,ue-be-Q):me>Se&&(le=me-k+ee),le!==F&&(Y.scrollLeft=le)},[p,w,b,S,W,X]);a.useLayoutEffect(()=>{const G=p.current,V=!yr(de.current,K);if(de.current=K,!G||!K)return;const Y=G.ownerDocument,H=Y.activeElement;let j;if(H===G?j=!0:!H||H===Y.body?j=te.current:G.contains(H)?j=V:j=!1,!j)return;const z=rn(G,K,J);z?z.contains(H)||z.focus({preventScroll:!0}):H!==G&&ae(G)});const D=a.useCallback(()=>{Z.current=!0,d(!1)},[d]),$=a.useCallback(G=>{const V=G.currentTarget,Y=G.relatedTarget,H=!(Y instanceof Node&&V.contains(Y)),j=Z.current;if(Z.current=!1,te.current=!0,A(!0),oe.current)return;if(G.target===V){if(!H)return;if(j||d(!0),K){const F=rn(V,K,J);F?F.focus({preventScroll:!0}):B(J,K.field);return}const k=re();k&&(_(F=>F??k),B(k.rowIndex??-1,k.field));return}const z=cs(G.target,V,t,y);z&&!yr(z,K)&&_(z)},[K,J,re,B,d,t,y]),R=a.useCallback(G=>{const V=G.relatedTarget;V instanceof Node&&G.currentTarget.contains(V)||(te.current=!1,Z.current=!1,A(!1),d(!1))},[d]),U=a.useCallback(G=>{const V=G.currentTarget,Y=ds(G.target,V);if(Y==="foreign"||(d(!0),G.nativeEvent?.isComposing||G.keyCode===229))return;const{key:H}=G,j=H===" "||H==="Spacebar",z=!!c.editingCell,k=(ie,pe)=>{const we=o[pe];!we||ie<-1||ie>=t.length||(_(ie===-1?{id:null,field:we.field}:{id:y(t[ie]),field:we.field,rowIndex:ie}),B(ie,we.field))};if(!K){if(!kr.has(H))return;const ie=re();if(!ie)return;G.preventDefault(),_(ie),B(ie.rowIndex??-1,ie.field);return}const{id:F,field:Q}=K,ee=J,ce=o.findIndex(ie=>ie.field===Q),fe=o.filter(ie=>rt(ie.field)).length,ge=ie=>qe(ie,C),be=(ie,pe,we)=>{const Me=o[we];return rt(Me.field)?!1:Jn({row:ie,field:Me.field,value:Fe(ie,Me.field,Me),colDef:Me,rowIndex:pe,colIndex:we-fe,rowMeta:C?.get(y(ie))},v)},Ce=ie=>{let pe=ee,we=ce;const Me=(t.length+1)*o.length;for(let Pe=0;Pe<Me;Pe++){if(we+=ie,we>=o.length?(we=0,pe++):we<0&&(we=o.length-1,pe--),pe<0||pe>=t.length)return null;const De=t[pe];if(!M?.(y(De),o[we].field)&&be(De,pe,we))return{r:pe,c:we}}return null};if(z){if(H==="Enter")G.preventDefault(),c.stopCellEdit();else if(H==="Escape")G.preventDefault(),c.stopCellEdit({cancel:!0});else if(H==="Tab"&&F!==null){const ie=Ce(G.shiftKey?-1:1);ie&&(G.preventDefault(),c.stopCellEdit(),k(ie.r,ie.c))}return}if(H==="Tab"||H==="Escape"||Y==="control"&&(H==="Enter"||j))return;if((G.ctrlKey||G.metaKey)&&(H==="a"||H==="A")){if(!P||!O||!E)return;G.preventDefault(),E(!0);return}if(F===null){if(H==="Enter"||j){if(G.preventDefault(),Q===Ye){rn(V,K,-1)?.click();return}const ie=o[ce];if(!ie||rt(Q)||ie.sortable===!1)return;const pe=u.find(Me=>Me.field===Q),we=pe?pe.sort==="asc"?"desc":null:"asc";(x||G.shiftKey)&&m?m(Q,we):g(Q,we);return}}else if(H==="Enter"||j){G.preventDefault();const ie=t[ee];if(Q===Ye){i(F,!r.has(F));return}if(Q===$t){G.shiftKey||l(F);return}if(j){G.shiftKey&&P&&!ge(F)&&i(F,!r.has(F));return}if(Q===At)return;if(be(ie,ee,ce)){c.startCellEdit({id:F,field:Q,value:Fe(ie,Q,o[ce])});return}if(T&&C?.get(F)?.hasChildren){T(F);return}N?.({row:ie,id:F,rowIndex:ee});return}if(G.altKey&&(H==="ArrowRight"||H==="ArrowLeft")&&T&&F!==null){G.preventDefault();const ie=C?.get(F);ie?.hasChildren&&!!ie.isExpanded!=(H==="ArrowRight")&&T(F);return}if(!kr.has(H))return;G.preventDefault();const ue=t.length-1,me=o.length-1,ve=G.ctrlKey||G.metaKey,Se=h?f:10,le=(ie,pe)=>{switch(H){case"ArrowRight":return pe+1>me?{r:ie+1,c:0}:{r:ie,c:pe+1};case"ArrowLeft":return pe-1<0?{r:ie-1,c:me}:{r:ie,c:pe-1};case"ArrowDown":return{r:ie+1,c:pe};case"ArrowUp":return{r:ie-1,c:pe};case"Home":return{r:ve?-1:ie,c:0};case"End":return{r:ve?ue:ie,c:me};case"PageUp":return{r:Math.max(-1,ie-Se),c:pe};default:return{r:Math.min(ue,ie+Se),c:pe}}},ye=({r:ie,c:pe})=>ie>=-1&&ie<=ue&&pe>=0&&pe<=me,Le=({r:ie,c:pe})=>ie>=0?M?.(y(t[ie]),o[pe].field)??null:null;let xe=le(ee,ce);if(H.startsWith("Arrow"))for(let ie=ye(xe)?Le(xe):null;ie&&ie.rowId===F&&ie.field===Q;ie=ye(xe)?Le(xe):null)xe=le(xe.r,xe.c);if(!ye(xe))return;const ke=Le(xe);if(ke){const ie=t.findIndex(we=>y(we)===ke.rowId),pe=o.findIndex(we=>we.field===ke.field);ie!==-1&&pe!==-1&&(xe={r:ie,c:pe})}xe.r===ee&&xe.c===ce||k(xe.r,xe.c)},[K,J,t,o,c,r,i,l,d,u,g,m,x,v,h,f,C,N,T,E,P,O,re,B,M,y]);return{focusedCell:K,setFocusedCell:_,viewportTabIndex:L?-1:0,ensureGridFocus:ne,handleFocus:$,handleBlur:R,handleKeyDown:U,handleMouseDownCapture:D}}const ps={rowFields:[],columnFields:[],valueFields:[]},Er=100;function hs(e){return!e||e.length===0||e.includes(Er)?Er:e[0]}function ws(e){const{initialState:t,sortModel:o,onSortModelChange:n,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:c,columnVisibilityModel:d,onColumnVisibilityModelChange:u,pinnedColumns:g,onPinnedColumnsChange:m,pivotModel:x,onPivotModelChange:v,paginationModel:h,onPaginationModelChange:f,pageSizeOptions:w,rowSelectionModel:p,onRowSelectionModelChange:b,density:y}=e,[C,N]=a.useState(()=>t?.sorting?.sortModel??[]),T=o!==void 0,E=T?o:C,P=a.useCallback(ue=>{T||N(ue),n?.(ue)},[T,n]),[O,W]=a.useState(()=>t?.filter?.filterModel??{items:[]}),X=r!=null,S=X?r:O,M=a.useCallback(ue=>{X||W(ue),i?.(ue)},[X,i]),I=l!==void 0,[_,L]=a.useState(()=>l??{}),A=JSON.stringify(I?l:_),q=a.useMemo(()=>JSON.parse(A),[A]),K=a.useCallback(ue=>{I||L(ue),c?.(ue)},[I,c]),J=d!==void 0,[te,oe]=a.useState(()=>t?.columns?.columnVisibilityModel??{}),Z=J?d:te,de=a.useCallback(ue=>{J||oe(ue),u?.(ue)},[J,u]),ae=g!==void 0,[ne,se]=a.useState(()=>t?.columns?.pinnedColumns??{}),re=ae?g:ne,B=a.useCallback(ue=>{ae||se(ue),m?.(ue)},[ae,m]),[D,$]=a.useState(()=>x??ps),R=x??D,U=a.useCallback(ue=>{$(ue),v?.(ue)},[v]),G=h!==void 0,[V,Y]=a.useState(()=>t?.pagination?.paginationModel??h??{page:0,pageSize:hs(w)}),H=G?h:V,j=a.useCallback(ue=>{G||Y(ue),f?.(ue)},[G,f]),z=p!==void 0,[k,F]=a.useState([]),Q=z?p:k,ee=a.useMemo(()=>new Set(Q),[Q]),ce=a.useRef(null);a.useLayoutEffect(()=>{ce.current=null});const fe=a.useCallback(()=>ce.current,[]),ge=a.useCallback(ue=>{ce.current=ue,z||F(ue),b?.(ue)},[z,b]),[be]=a.useState(()=>t?.density?.density??"standard");return{sortModel:E,isSortControlled:T,setInternalSortModel:N,handleSortModelChange:P,filterModel:S,isFilterControlled:X,handleFilterModelChange:M,aggregationModel:q,handleAggregationModelChange:K,columnVisibilityModel:Z,handleColumnVisibilityModelChange:de,pinnedColumns:re,handlePinnedColumnsChange:B,currentPivotModel:R,handlePivotModelChange:U,effectivePaginationModel:H,handlePaginationModelChange:j,rowSelectionModel:Q,selectedRowIds:ee,isSelectionControlled:z,setInternalRowSelectionModel:F,handleRowSelectionModelChange:ge,getPendingRowSelectionModel:fe,density:y??be}}const Mr=a.createContext(null),ms=52,xs=56,bs=32,vs=72;function fo(e){if(e===void 0)return;const t=/^\s*(\d+(?:\.\d+)?)\s*(px)?\s*$/.exec(e);if(!t)return;const o=Number(t[1]);return o>0?o:void 0}function ys(e){const{rowHeight:t,headerHeight:o,density:n}=e,r=a.useContext(Mr)?.grid;let i;return n==="compact"?i=fo(r?.rowHeightCompact)??bs:n==="comfortable"?i=fo(r?.rowHeightComfortable)??vs:i=t??fo(r?.rowHeightStandard)??ms,{rowHeight:i,headerHeight:o??fo(r?.headerHeight)??xs}}function go(e){return e>=1?Math.floor(e):1}function ln(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/go(t)))}function Cs(e){const{paginationMode:t,hasDataSource:o,dataSourceRowCount:n,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(o?n??r:r)??i}function Nr(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Pr(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function _s(e){const{effectiveRows:t,activeHierarchyHandlers:o,filterMode:n,filterModel:r,sortModel:i,sortingMode:l,pagination:c,paginationMode:d,effectivePaginationModel:u,pinnedRows:g,getRowId:m,columnLookup:x,hierarchyField:v}=e,h=a.useMemo(()=>o?o.getVisibleRows({labelField:v})||[]:n==="server"?t:Jo(t,r,x),[t,r,o,v,n,x]),f=a.useMemo(()=>o?n==="server"?t:Jo(t,r,x):h,[o,h,n,t,r,x]),{top:w,center:p,bottom:b}=a.useMemo(()=>o?{top:[],center:h,bottom:[]}:Sl(h,g,m),[h,g,o,m]),y=a.useMemo(()=>o||l==="server"?p:Yl(p,i,x),[p,i,o,l,x]),C=c&&d!=="server",N=go(u.pageSize),T=C?Pr(u.page,ln(y.length,N)):u.page,E=a.useMemo(()=>{if(!C)return y;const O=T*N;return y.slice(O,O+N)},[y,C,T,N]),P=a.useMemo(()=>{const O=c?E:y;return[...w,...O,...b]},[w,E,y,b,c]);return{filteredRows:h,dataRows:f,pinnedTopRows:w,unpinnedRows:p,pinnedBottomRows:b,sortedUnpinnedRows:y,paginatedUnpinnedRows:E,currentPage:T,allRenderableRows:P}}function Ss(e){const{layout:t,scrollTop:o,scrollLeft:n,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:c,hasDetailPanel:d,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:m,overscanRows:x=5}=e;return a.useMemo(()=>{const{unpinnedAccWidths:v,unpinnedColsWithWidth:h,leftPinnedCols:f,rightPinnedCols:w,totalWidth:p,leftWidth:b,rightWidth:y,unpinnedTotalWidth:C,systemColumnsWidth:N,cumulativeHeights:T,pinnedTopHeight:E,pinnedBottomHeight:P,unpinnedRowsHeight:O,rowHeights:W,unpinnedRowsLength:X}=t,S=r||1e3,M=l?E+O+P+50:i||600,I=6,_=Math.max(0,n-b),L=n+S-b;let A=0,q=h.length-1,K=0,J=v.length-1;for(;K<=J;){const U=K+J>>>1;v[U]<_?K=U+1:J=U-1}A=Math.max(0,K-I);for(let U=A;U<v.length;U++){if((U===0?0:v[U-1])>L){q=Math.min(h.length-1,U+I);break}q=Math.min(h.length-1,U+I)}const te=A>0?v[A-1]:0,oe=C-v[q],Z=[...f,...te>0?[{field:"__spacer_left__",width:te,isSpacer:!0}]:[],...h.slice(A,q+1),...oe>0?[{field:"__spacer_right__",width:oe,isSpacer:!0}]:[],...w],ae=S>0&&p>S?16:0,ne=E+O+P+ae+2;let se=0,re=X-1,B=0,D=0,$=T.length-1;for(;D<=$;){const U=D+$>>>1;T[U]<o?D=U+1:$=U-1}se=Math.max(0,D-x),B=se>0?T[se-1]:0;for(let U=se;U<T.length;U++)if(T[U]>=o+M){re=Math.min(X-1,U+x);break}const R=(c?48:0)+(d&&m?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:se,lastRowIndex:re,firstColumnIndex:A,lastColumnIndex:q},offsetTop:B,offsetLeft:0,totalHeight:ne,pinnedTopHeight:E,pinnedBottomHeight:P,totalWidth:p,rowHeights:W,cumulativeHeights:T,virtualColumns:Z,columnMetrics:{leftPinnedWidth:b,rightPinnedWidth:y,unpinnedAccWidths:v,unpinnedCols:h,totalSpecialsWidth:N,pinnedSpecialsWidth:R}}},[t,o,n,r,i,l,c,d,u,g,m,x])}const sn="application/x-ogx-row",an="application/x-ogx-column";function Ir(e,t,o){const n=e.dataTransfer;!n||typeof n.setData!="function"||(n.setData(t,o),n.setData("text/plain",o))}function po(e,t){const o=e.dataTransfer?.types;return o?Array.from(o).includes(t):!0}function Tr(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const o=()=>t();return e.addEventListener("dragend",o,{once:!0}),()=>e.removeEventListener("dragend",o)}function ks(e){const{columns:t,onColumnOrderChange:o,disableColumnReorder:n=!1}=e,[r,i]=a.useState(null),[l,c]=a.useState(null),d=a.useRef(()=>{}),u=a.useCallback(()=>{d.current(),d.current=()=>{},i(null),c(null)},[]);a.useEffect(()=>()=>d.current(),[]);const g=a.useCallback(v=>h=>{if(!n){if(!t.some(f=>f.field===v)){h.preventDefault();return}d.current(),d.current=Tr(h.currentTarget,u),i(v),h.dataTransfer&&(h.dataTransfer.effectAllowed="move",Ir(h,an,v))}},[t,n,u]),m=a.useCallback(v=>h=>{if(!(n||r===null)){if(!po(h,an)){u();return}h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="move"),c(v)}},[r,n,u]),x=a.useCallback(v=>h=>{if(h.preventDefault(),n||r===null||!po(h,an)){u();return}const f=t.findIndex(p=>p.field===r),w=t.findIndex(p=>p.field===v);u(),!(f===-1||w===-1||f===w)&&o?.({column:t[f],oldIndex:f,targetIndex:w})},[t,r,n,o,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:n?void 0:g,onDragOver:n?void 0:m,onDragEnd:n?void 0:u,onDrop:n?void 0:x}}function dn({isExpanded:e,onClick:t,variant:o="chevron",tabIndex:n}){return s.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:n,children:o==="plus-minus"?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.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"}})]}):s.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:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Es({renderFn:e}){return s.jsx(s.Fragment,{children:e()})}function Ms(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,n)=>Object.is(o,t[n])):Object.is(e,t)}class it extends a.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,o){return Ms(t.resetKey,o.resetKey)?null:o.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,o.componentStack)}render(){return this.state.hasError?s.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):s.jsx(Es,{renderFn:this.props.renderFn})}}function Ns(e,t,o){if(!t||!o)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const n=l=>o.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>n(l.row)?l.value:r(l):void 0,valueFormatter:l=>n(l.row)?co(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Lr(e,t){if(!t)return e;const o=t.left??[],n=t.right??[],r=i=>{const l=Xe(i.field,t);return l==="left"?o.indexOf(i.field)-o.length:l==="right"?1+n.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const ho=e=>e.formattedValue??e.value;function Fr(e,t,o){const n=e.renderCell;if(!n)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!o){const l=n(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=n(t)}catch(l){return{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Ps(e,t,o){const n=e.rowMeta;if(!n?.isGroupRow)return ho(e);if(n.isGroupFooter)return null;const r=n.descendantCount;if(t&&n.hasChildren){const i=n.groupLabel??`${n.groupingField}: ${String(n.groupingValue)}`;return s.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return o?s.jsxs("div",{className:"ogx__group-cell-content",children:[n.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):ho(e)}const Is=e=>e.id;function Ts(e){const{activeColumns:t,isHierarchyEnabled:o,isRowGrouping:n,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:c,onColumnOrderChange:d,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:m,checkboxSelection:x,hasDetailPanel:v,rowReordering:h,initialState:f,setColumns:w,pinnedColumns:p,getRowId:b=Is,aggregationModel:y,groupingRows:C}=e,N=a.useMemo(()=>t.map($=>$.field),[t]),[T,E]=a.useState(()=>f?.columns?.columnOrder??null),P=m?N.join("\0"):"",[O,W]=a.useState(null),X=O&&O.key===P?O.order:N,M=m?X:c??(T??N),I=a.useCallback($=>{if(m){W(R=>{const U=R&&R.key===P?R.order:N;return{key:P,order:typeof $=="function"?$(U):$}});return}E(R=>typeof $=="function"?$(R??N):$)},[m,P,N]),_=a.useCallback($=>m&&$.hideable===!1||l[$.field]!==!1,[m,l]),L=a.useMemo(()=>{if(!o)return;const $=new Map(M.map((V,Y)=>[V,Y])),R=V=>$.get(V.field)??t.indexOf(V),U=[...t].sort((V,Y)=>R(V)-R(Y));return(Lr(U.filter(V=>l[V.field]!==!1),p)[0]??t[0])?.field},[o,M,t,l,p]),A=a.useMemo(()=>{if(!o)return t;const $=n?C:void 0;return t.map(R=>{const U=Ns(R,y?.[R.field],$);return R.field===L?{...R,...U,renderCell:G=>{const V=G.rowMeta,Y=V?.treeDepth??0,H=!!V?.hasChildren,j=!!V?.isExpanded,z=Fr(R,G,!0),k=z.useDefault?Ps(G,n,r):z.content;return s.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:Y*24,width:"100%",height:"100%"},children:[s.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?s.jsx("div",{onClick:F=>{F.stopPropagation(),F.preventDefault(),i?.toggleExpansion(b(G.row))},onMouseDown:F=>{F.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:s.jsx(dn,{isExpanded:j,tabIndex:-1,onClick:F=>{F.stopPropagation(),F.preventDefault(),i?.toggleExpansion(b(G.row))}})}):null}),s.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})]})}}:{...R,...U,renderCell:G=>{const V=G.rowMeta;if(!V?.isGroupRow)return R.renderCell?R.renderCell(G):ho(G);const Y=Fr(R,G,!1);return Y.useDefault?R.field===V.groupingField&&!V.isGroupFooter||G.value==null?null:ho(G):Y.content}}})},[t,o,n,r,i,L,b,y,C]),[q,K]=a.useState(()=>f?.columns?.columnWidths??{}),J=a.useCallback(($,R)=>{K(U=>({...U,[$]:R}))},[]);a.useEffect(()=>{w(t)},[t,w]);const te=a.useMemo(()=>{const $=new Map(M.map((R,U)=>[R,U]));return[...A].sort((R,U)=>{const G=$.get(R.field)??A.indexOf(R),V=$.get(U.field)??A.indexOf(U);return G-V})},[A,M]),oe=a.useMemo(()=>te.filter(_),[te,_]),Z=a.useCallback(($,R)=>{(m||!c)&&I($),R&&d?.(R),m||u?.($)},[m,c,I,d,u]),de=a.useCallback(($,R)=>{const U=te.map(V=>V.field),[G]=U.splice($,1);U.splice(R,0,G),Z(U,{column:te[$],oldIndex:$,targetIndex:R})},[te,Z]),ae=ks({columns:te,onColumnOrderChange:a.useCallback(({oldIndex:$,targetIndex:R})=>de($,R),[de]),disableColumnReorder:g}),ne=a.useCallback(($,R)=>{const U=te.findIndex(V=>V.field===$),G=te.findIndex(V=>V.field===R);U===-1||G===-1||U===G||de(U,G)},[te,de]),se=a.useCallback(()=>{Z(N)},[Z,N]),re=a.useMemo(()=>Lr(oe,p),[oe,p]),B=a.useMemo(()=>{const $=[];return h&&$.push({field:At,sortable:!1,editable:!1}),v&&$.push({field:$t,sortable:!1,editable:!1}),x&&$.push({field:Ye,sortable:!1,editable:!1}),[...$,...re]},[re,x,v,h]),D=a.useMemo(()=>new Map(re.map(($,R)=>[$.field,R])),[re]);return{effectiveColumns:A,hierarchyField:L,orderedColumns:te,visibleOrderedColumns:oe,renderOrderedColumns:re,navigationColumns:B,columnIndexMap:D,columnWidths:q,effectiveColumnOrder:M,setInternalColumnOrder:I,columnReorderHandlers:ae,moveColumn:ne,resetColumnOrder:se,handleColumnResize:J}}const Ls=e=>e.id;function Fs(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=Ls}=e;return a.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:u}=t,g=l?r:i,m=o.length,x=o.map((y,C)=>({row:y,id:c(y),rowIndex:C,pinned:"top"})),v=n.map((y,C)=>({row:y,id:c(y),rowIndex:m+g.length+C,pinned:"bottom"})),h=Math.max(0,d),f=Math.min(g.length,u+1),w=g.slice(h,f).map((y,C)=>({row:y,id:c(y),rowIndex:m+h+C})),p=[...x,...w,...v],b=new Set;return p.filter(y=>b.has(y.id)?!1:(b.add(y.id),!0))},[t,o,n,r,i,l,c])}const Os=100;function Or(e){const{scrollTop:t,scrollHeight:o,clientHeight:n}=e;return o-t-n>=Os?null:{visibleTop:t,visibleBottom:t+n,viewportHeight:n}}function Ds(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function As(e){const{onRowsScrollEnd:t,overscanRowCount:o=3,rowCount:n=0,autoHeight:r=!1}=e,i=a.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=a.useRef({scrollTop:0,scrollLeft:0,time:0}),c=a.useRef(null),d=a.useRef(null),u=a.useRef(null),g=a.useRef(!0),m=a.useRef(t),[x,v]=a.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});a.useEffect(()=>{m.current=t},[t]),a.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),d.current!==null&&clearTimeout(d.current)},[]);const h=a.useCallback(p=>{const b=Or(p);if(!b){g.current=!0;return}if(!g.current)return;const y=m.current;y&&(g.current=!1,y(b))},[]),f=a.useCallback(p=>{const b=p.currentTarget,y=performance.now(),C=Math.abs(b.scrollTop-l.current.scrollTop)+Math.abs(b.scrollLeft-l.current.scrollLeft),N=y-l.current.time,T=N>0?C/N:0,E=b.scrollTop!==l.current.scrollTop;l.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,time:y},i.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,velocity:T},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:P,scrollLeft:O,velocity:W}=i.current;v({scrollTop:P,scrollLeft:O,velocityOverscan:Ds(W)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,v(P=>P.velocityOverscan===0?P:{...P,velocityOverscan:0})},200),E&&h(b)},[h]);a.useEffect(()=>{g.current=!0;const p=u.current;!p||r||n<=0||p.clientHeight===0||h(p)},[n,r,h]);const w=a.useCallback(p=>{if(u.current=p,!p)return;const{scrollTop:b,scrollLeft:y}=i.current;if(b===0&&y===0)return;p.scrollTop=b,p.scrollLeft=y;const C={scrollTop:p.scrollTop,scrollLeft:p.scrollLeft};(C.scrollTop!==b||C.scrollLeft!==y)&&(i.current={...i.current,...C},l.current={...l.current,...C},v(N=>({...N,...C})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,o),handleScroll:f,attachViewport:w}}function $s(e){const t=a.useRef(null);return a.useCallback(o=>{if(t.current?.disconnect(),t.current=null,!o||typeof ResizeObserver>"u")return;const n=new ResizeObserver(r=>{for(const i of r){const{width:l,height:c}=i.contentRect;e(l,c)}});n.observe(o),t.current=n},[e])}function Gs(e){const{setDimensions:t,viewportRef:o,...n}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:d}=As(n),u=$s(t),g=a.useCallback(m=>{o.current=m,u(m),d(m)},[o,u,d]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:g}}function Ws(){const[e,t]=a.useState(()=>new Map),o=a.useCallback((n,r)=>{t(i=>{if(i.get(n)===r)return i;const l=new Map(i);return l.set(n,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:o}}function Hs(e){const{hasDetailPanel:t,controlledExpandedRowIds:o,onDetailPanelExpandedRowIdsChange:n,rowMetaMap:r}=e,[i,l]=a.useState(new Set),c=o??i,d=a.useMemo(()=>Pl(c,r),[c,r]),u=a.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const v=new Set(c);v.has(x)?v.delete(x):v.add(x),o===void 0&&l(v),n?.(v)},[c,r,o,n]),{detailPanelHeights:g,reportDetailPanelHeight:m}=Ws();return{hasDetailPanel:t,expandedRowIds:d,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:m}}const Bs=new Set(["__group__"]),Gt=e=>!Bs.has(e);function Dr(e){return Object.keys(e).every(Gt)?e:Object.fromEntries(Object.entries(e).filter(([o])=>Gt(o)))}function Vs(e){const t={...e};return e.left&&(t.left=e.left.filter(Gt)),e.right&&(t.right=e.right.filter(Gt)),t}function zs(e){const{onStateChange:t,sortModel:o,filterModel:n,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:d,density:u}=e,g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t});const m=a.useRef(null);a.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:o},filter:{filterModel:n},pagination:{paginationModel:r},columns:{columnWidths:Dr(i),columnOrder:l.filter(Gt),columnVisibilityModel:Dr(c),pinnedColumns:Vs(d)},density:{density:u}},v=JSON.stringify(x);v!==m.current&&(m.current=v,g.current(x))},[o,n,r,i,l,c,d,u])}const Ks=200,js=2e3,Us=178e5;function Xs(e){const{paginationRequested:t,isRowGrouping:o,autoHeight:n,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:d=0,listViewWithoutColumn:u=!1,listViewRowCount:g=0}=e,m=a.useRef(!1),x=a.useRef(!1),v=a.useRef(!1),h=a.useRef(!1),f=a.useRef(!1),w=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||g<=js||(w.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]),a.useEffect(()=>{process.env.NODE_ENV==="production"||f.current||!u||(f.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."))},[u]),a.useEffect(()=>{process.env.NODE_ENV==="production"||v.current||!c||(v.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."))},[c]),a.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||d<=Us||(h.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(d)}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.`))},[d]),a.useEffect(()=>{process.env.NODE_ENV==="production"||m.current||t&&o&&(m.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,o]),a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||n||r>0&&l>Ks&&i>=l&&r>=d&&(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.`))},[n,r,i,l,d])}function qs(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Ar=!1;function Ys(e){a.useEffect(()=>{if(process.env.NODE_ENV==="production"||Ar)return;const t=e.current;!t||!qs(t)||(Ar=!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 wo(e,t,o,n){if(o&&n)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>o?r.add(i):r.delete(i)),Array.from(r)}function Rs(e,t,o){return o?e.has(t)?[]:[t]:wo(e,[t],!e.has(t),!1)}function $r(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function Js(e){const{selectedRowIds:t,onSelectionModelChange:o,disableMultipleRowSelection:n,selectableRowIds:r}=e,i=a.useCallback(m=>{$r(t,m)||o(m)},[t,o]),l=a.useCallback((m,x)=>{i(wo(t,[m],x,n))},[i,t,n]),c=a.useCallback(m=>{i(Rs(t,m,n))},[i,t,n]),d=a.useCallback(m=>{i(wo(t,r,m,!1))},[i,t,r]),{allSelected:u,someSelected:g}=a.useMemo(()=>{let m=0;for(const v of r)t.has(v)&&m++;const x=r.length>0&&m===r.length;return{allSelected:x,someSelected:!x&&m>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:n?void 0:d,allSelected:u,someSelected:g}}function Qs(e){const{dataRows:t,getRowId:o,isPivotActive:n,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:c,isHierarchyEnabled:d,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:m}=e,x=a.useMemo(()=>{const w=t.map(o);return n?w.filter(p=>p!==wt):w},[t,o,n]),v=Js({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),h=a.useCallback(w=>{const{id:p}=w,b=d?u.get(p):void 0;if(b?.isGroupRow){b.hasChildren&&g?.toggleExpansion(p);return}m?.(w),!c&&!qe(p,u)&&v.clickRow(p)},[d,g,m,u,c,v]),f=a.useCallback((w,p)=>{qe(w,u)||v.toggleRow(w,p)},[u,v]);return{rowSelection:v,handleRowClick:h,handleSelectionChange:f}}const Gr=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Zs(e){const{selectedRowIds:t,rowsLookup:o,rowMetaMap:n,enabled:r,onSelectionModelChange:i}=e,l=a.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;const g=new Set;for(const m of t)o.has(m)||n.has(m)?g.add(m):u=!0;return u?g:t},[r,t,o,n]),c=a.useRef(i);a.useLayoutEffect(()=>{c.current=i});const d=a.useRef(null);return a.useEffect(()=>{if(l===t){d.current=null;return}const u=`${Gr(t)}|${Gr(l)}`;d.current!==u&&(d.current=u,c.current(Array.from(l)))},[l,t]),l}function cn(e,t,o,n){return n?Rl(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function ea(e){const{sortModel:t,onSortModelChange:o}=e,n=a.useCallback((i,l)=>{o(cn(t,i,l,!1))},[t,o]),r=a.useCallback((i,l)=>{o(cn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function ta(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:o,pinnedColumns:n,onPinnedColumnsChange:r}=e,i=a.useRef({columnVisibilityModel:t,pinnedColumns:n});a.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:n}});const l=a.useCallback(d=>{const u={...i.current.columnVisibilityModel,[d]:!1};i.current={...i.current,columnVisibilityModel:u},o(u)},[o]),c=a.useCallback((d,u)=>{const g=kl(i.current.pinnedColumns,d,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function oa(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=t.current,r=()=>o.current;n.getSortModel=()=>r().sortModel,n.sortColumn=(d,u)=>{const{sortModel:g,multiSort:m,onSortModelChange:x}=r(),v=cn(g,d,u,m);o.current={...r(),sortModel:v},x(v)},n.getFilterModel=()=>r().filterModel,n.setFilterModel=d=>{o.current={...r(),filterModel:d},r().onFilterModelChange(d)};const i=d=>{o.current={...r(),paginationModel:d},r().onPaginationModelChange(d)};n.setPage=d=>i({...r().paginationModel,page:d}),n.setPageSize=d=>i({...r().paginationModel,pageSize:d,page:0});const l=()=>{const d=r().getPendingRowSelectionModel?.();return d?new Set(d):r().selectedRowIds},c=(d,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:m,isSyntheticRowId:x}=r(),v=x?d.filter(w=>!x(w)):d;if(v.length===0)return;const h=l(),f=wo(h,v,u,g);$r(h,f)||(o.current={...r(),selectedRowIds:new Set(f)},m(f))};n.getSelectedRows=()=>Array.from(l()),n.selectRow=(d,u=!0)=>c([d],u),n.selectRows=(d,u=!0)=>c(d,u),n.getVisibleRows=()=>r().getVisibleRows(),n.getAllFilteredRows=()=>r().getAllFilteredRows(),n.getVisibleColumns=()=>r().visibleColumns},[t])}const Wr="\0";function na(e,t){const o=e.filter(n=>t[n.field]===!1).map(n=>n.field).join(Wr);return a.useMemo(()=>{const n={};if(o)for(const r of o.split(Wr))n[r]=!1;return tn(e,n)},[e,o])}function ra({paginationModel:e,currentPage:t,enabled:o,onPaginationModelChange:n}){const r=a.useRef({paginationModel:e,onPaginationModelChange:n});a.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:n}});const i=e.page,l=a.useRef(null);a.useEffect(()=>{if(!o)return;if(t===i){l.current=null;return}const c=`${i}>${t}`;if(l.current===c)return;l.current=c;const{paginationModel:d,onPaginationModelChange:u}=r.current;u({...d,page:t})},[o,t,i])}function ia(){const[e,t]=a.useState(!1),[o,n]=a.useState(!1),r=a.useRef(null),i=a.useRef(0),l=a.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),c=a.useCallback(()=>{i.current>0?t(!0):n(!0)},[]),d=a.useCallback(()=>t(!1),[]),u=a.useCallback(()=>n(!1),[]);return a.useEffect(()=>{if(!o)return;function g(x){r.current&&!r.current.contains(x.target)&&n(!1)}function m(x){x.key==="Escape"&&n(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",m)}},[o]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:d,standalonePanelOpen:o,closeStandalonePanel:u,standalonePanelRef:r,openColumnsPanel:c}}const Hr=a.createContext(null);function la(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function sa({render:e,toolbarProps:t}){return s.jsx(s.Fragment,{children:e(t)})}function aa({component:e,toolbarProps:t}){if(la(e))return s.jsx(sa,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return s.jsx(o,{...t})}const Br=48;function da({columns:e,aggregationModel:t,aggregationResult:o,columnWidths:n,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:c,pinCheckboxColumn:d=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:m=!1}){const x=a.useMemo(()=>Wo(e,n,g,i,d,l,u,c),[e,n,g,i,d,l,u,c]),{lastLeft:v,firstRight:h}=a.useMemo(()=>Ho(e,g),[e,g]),f=c?Br:0,w=f+(l&&u?Br:0),p=(b,y,C)=>s.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:C}:void 0,"aria-hidden":"true"},b);return s.jsxs("div",{className:`ogx__aggregation-footer${m?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":m||void 0,style:{minHeight:`${r}px`},children:[c&&p("__reorder_col__",!0,0),l&&p("__expand_col__",u,f),i&&p("__checkbox_col__",d,w),e.map(b=>{if(b.isSpacer){const X=typeof b.width=="number"?b.width:0;return s.jsx("div",{style:{width:X,minWidth:X,flexShrink:0},"aria-hidden":"true"},b.field)}const y=t[b.field],C=y&&Xo(b,y)?y:void 0,N=o[b.field],T=ot(b,n,120),E=Xe(b.field,g),P=E?x[b.field]:void 0,O=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&b.field===v&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&b.field===h&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),W={width:T,minWidth:T,maxWidth:T,textAlign:b.align||"left"};return E==="left"&&P!==void 0&&(W.left=P),E==="right"&&P!==void 0&&(W.right=P),s.jsx("div",{className:O,role:"gridcell",style:W,children:C?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ogx__aggregation-label",children:C}),s.jsx("span",{className:"ogx__aggregation-value",children:co(N,C,b,o)})]}):null},b.field)})]})}function ca({noRowsLabel:e,width:t,overlay:o}){return o?s.jsx("div",{className:"ogx__empty",style:{width:t},children:o}):s.jsxs("div",{className:"ogx__empty",style:{width:t},children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),s.jsx("span",{children:e})]})}function Vr({dataSource:e,paginationMode:t,sortingMode:o,filterMode:n}){return!!e&&(t==="server"||t==="infinite"||o==="server"||n==="server")}const zr=Number.MAX_SAFE_INTEGER,ua="An unexpected error occurred while loading the data.";function Kr(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:ua}function fa({error:e,onRetry:t}){if(!e)return null;const o=Kr(e);return s.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),s.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),s.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&s.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}const Wt=({indeterminate:e=!1,label:t,className:o="",inputRef:n,...r})=>{const i=a.useRef(null),l=a.useCallback(d=>{i.current=d,typeof n=="function"?n(d):n&&(n.current=d)},[n]);a.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const c=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return s.jsxs("label",{className:c,children:[s.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),s.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&s.jsx("span",{className:"ogx-checkbox__label",children:t})]})},ga=50;function un(e,t,o,n){const r=Math.min(o??ga,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const pa=16;function ha(e){e.preventDefault(),e.stopPropagation()}function wa(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function ma(e){const{field:t,currentWidth:o,onResize:n,minWidth:r,maxWidth:i,edge:l="end"}=e,[c,d]=a.useState(!1),u=a.useRef(null);a.useEffect(()=>()=>{u.current=null},[]);const g=a.useCallback((p,b)=>{const y=b-p.startX,C=p.startWidth+(l==="start"?-y:y);return un(C,p.startWidth,r,i)},[l,r,i]),m=a.useCallback(p=>{if(p.button===0){p.stopPropagation(),u.current={pointerId:p.pointerId,startX:p.clientX,startWidth:o,lastUpdate:0,moved:!1},d(!0);try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}}},[o]),x=a.useCallback(p=>{const b=u.current;if(!b||p.pointerId!==b.pointerId||(p.clientX!==b.startX&&(b.moved=!0),!b.moved))return;const y=Date.now();y-b.lastUpdate>=pa&&(b.lastUpdate=y,n(t,g(b,p.clientX)))},[t,n,g]),v=a.useCallback((p,b)=>{const y=u.current;!y||p.pointerId!==y.pointerId||(u.current=null,d(!1),(y.moved||p.clientX!==y.startX)&&(wa(),b&&n(t,g(y,p.clientX))))},[t,n,g]),h=a.useCallback(p=>{if(p.key!=="ArrowLeft"&&p.key!=="ArrowRight")return;p.preventDefault(),p.stopPropagation();const b=(p.shiftKey?50:10)*(p.key==="ArrowRight"?1:-1);n(t,un(o+b,o,r,i))},[t,o,n,r,i]),f=a.useCallback(p=>{p.preventDefault(),p.stopPropagation()},[]),w=["ogx-column-resize-handle",l==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return s.jsx("div",{className:w,onPointerDown:m,onMouseDown:ha,onPointerMove:x,onPointerUp:p=>v(p,!0),onPointerCancel:p=>v(p,!1),onClick:p=>p.stopPropagation(),onDragStart:p=>{p.preventDefault(),p.stopPropagation()},onDoubleClick:f,onKeyDown:h,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(o),"aria-valuemin":Math.round(Math.min(r??50,o)),"aria-valuemax":i,tabIndex:-1,children:s.jsx("div",{className:"ogx-column-resize-handle__line"})})}function jr(e){if(!e)return 0;let t=0;const o=(n,r)=>{t=Math.max(t,r);for(const i of n.children)typeof i!="string"&&o(i,r+1)};return e.forEach(n=>o(n,1)),t}function Ur(e){const t=new Map;if(!e)return t;const o=(n,r)=>{const i=[...r,n];for(const l of n.children)typeof l=="string"?t.has(l)||t.set(l,i):o(l,i)};return e.forEach(n=>o(n,[])),t}function fn(e,t,o){if(!e||e.length===0)return!0;const n=Ur(e),r=n.get(t),i=n.get(o);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function xa(e,t,o){const n=[];let r=0,i=null,l=null;for(const c of e){const d=c.isSpacer?null:t.get(c.field)?.[o]??null;(i===null||l!==d||i.pinned!==c.pinned)&&(i={key:`${d?d.groupId:"filler"}-${o}-${c.field}`,isGroup:d!==null,label:d?.headerName??"",headerClassName:d?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:c.pinned},l=d,n.push(i)),i.width+=c.width,i.flexGrow+=c.flex??0,c.isSpacer||(i.fields.push(c.field),r++)}return n}function xt(){return document.documentElement.clientWidth||window.innerWidth}function ba(){return document.documentElement.clientHeight||window.innerHeight}function bt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:s.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function vt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function va(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function ya(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),s.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ca(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function _a(){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Sa(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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"}),s.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function ka(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),s.jsx("polyline",{points:"11 8 4 12 11 16"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Ea(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),s.jsx("polyline",{points:"13 8 20 12 13 16"}),s.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Ma(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),s.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Xr=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Na({colDef:e,sortModel:t,onSort:o,onHide:n,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:d}){const u=a.useRef(null),g=a.useCallback(W=>{W&&(d?.closest('[role="columnheader"]')??d)?.focus({preventScroll:!0}),c()},[d,c]),m=W=>{const X=Xr(u.current),S=X.indexOf(W.target);let M=-1;if(W.key==="ArrowDown")M=S+1>=X.length?0:S+1;else if(W.key==="ArrowUp")M=S<=0?X.length-1:S-1;else if(W.key==="Home")M=0;else if(W.key==="End")M=X.length-1;else if(W.key==="Tab"){W.preventDefault(),g(!0);return}else return;W.preventDefault(),X[M]?.focus()},[x,v]=a.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});a.useLayoutEffect(()=>{if(!d||!u.current)return;const W=d.getBoundingClientRect(),X=u.current.getBoundingClientRect(),S=xt(),M=ba(),I=8;let _=W.left;_+X.width+I>S&&(_=S-X.width-I),_<I&&(_=I);let L=W.bottom+4;L+X.height+I>M&&(L=W.top-X.height-4),v({position:"fixed",zIndex:1300,top:L,left:_,visibility:"visible"})},[d]);const h=x.visibility==="visible";a.useLayoutEffect(()=>{h&&Xr(u.current)[0]?.focus({preventScroll:!0})},[h]),a.useEffect(()=>{function W(S){u.current&&!u.current.contains(S.target)&&d&&!d.contains(S.target)&&c()}function X(S){S.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",W),document.addEventListener("keydown",X),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",X),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[d,c,g]);const f=W=>{o?.(e.field,W),g(!0)},w=!!n&&e.hideable!==!1,p=!!r&&e.pinnable!==!1,b=()=>{w&&n?.(e.field),g(!0)},y=W=>{p&&r?.(e.field,W),g(!0)},C=t?.find(W=>W.field===e.field)?.sort,N=C==null,T=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,P=!T&&!E,O=e.headerName||e.field;return tt.createPortal(s.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${O}`,onKeyDown:m,children:[o&&e.sortable!==!1&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ya,{})}),"Sort Ascending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ca,{})}),"Sort Descending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":N,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(_a,{})}),"Unsort"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),s.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":T,"aria-label":"Pin to left",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ka,{})}),"Pin to Left"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>y("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ea,{})}),"Pin to Right"]}),s.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:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ma,{})}),"Unpin"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),w&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${O} column`,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Sa,{})}),"Hide Column"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(va,{})}),"Manage columns"]})]}),d?.closest(".ogx-theme-provider")||document.body)}function Pa(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:s.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 Ia(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:s.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function qr(e){const{columns:t,allColumns:o,columnGroupingModel:n,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:c,onSort:d,sortModel:u=[],onColumnResize:g,columnWidths:m={},pinnedColumns:x,hasDetailPanel:v=!1,pinCheckboxColumn:h=!0,pinExpandColumn:f=!0,rowReordering:w=!1,aggregationModel:p,draggedColumn:b,dragOverColumn:y,onDragStart:C,onDragOver:N,onDragEnd:T,onDrop:E,focusedCell:P,onHeaderClick:O,onSortAdd:W,multiSort:X=!1,onHideColumn:S,onPinColumn:M,onManageColumns:I,columnIndexMap:_}=e,L=a.useId(),[A,q]=a.useState(null),K=k=>F=>{F.stopPropagation(),q({colDef:k,anchorEl:F.currentTarget})},J=a.useCallback(()=>{q(null)},[]),te=k=>F=>{if(F.altKey&&(F.key==="ArrowLeft"||F.key==="ArrowRight")&&F.target===F.currentTarget){if(k.resizable===!1||!g)return;F.preventDefault(),F.stopPropagation();const fe=ot(k,m),ge=(F.shiftKey?50:10)*(F.key==="ArrowRight"?1:-1);g(k.field,un(fe+ge,fe,k.minWidth,k.maxWidth));return}if(!(F.altKey&&F.key==="ArrowDown"||(F.ctrlKey||F.metaKey)&&F.key==="Enter")||k.disableColumnMenu||F.target!==F.currentTarget)return;F.preventDefault(),F.stopPropagation();const ce=F.currentTarget.querySelector(".ogx__menu-icon-btn")??F.currentTarget;q({colDef:k,anchorEl:ce})},oe=k=>P?.id===null&&P.field===k,Z=w?1:0,de=v?Z+1:Z,ae=r?de+1:de,ne=k=>F=>{if(k.sortable===!1)return;const Q=u.find(ce=>ce.field===k.field);let ee="asc";Q&&(Q.sort==="asc"?ee="desc":ee=null),(F.shiftKey||X)&&W?W(k.field,ee):d&&d(k.field,ee)},se=(k,F)=>{const Q=u.some(ce=>ce.field===k);W&&(F===null||Q||X||!d)?W(k,F):d?.(k,F)},re=k=>{const F=u.find(ee=>ee.field===k);if(!F)return null;const Q=u.length>1?u.indexOf(F)+1:null;return s.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${F.sort}`,"aria-hidden":"true",children:Q!==null&&s.jsx("span",{className:"ogx__sort-badge",children:Q})})},B=a.useMemo(()=>Wo(t,m,x,r,h,v,f,w),[t,m,x,r,h,v,f,w]),D=a.useMemo(()=>Ho(t,x),[t,x]),$=jr(n),R=a.useMemo(()=>Ur(n),[n]),U=a.useMemo(()=>$===0?[]:(o??t).map(k=>({field:k.field,width:ot(k,m),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:Xe(k.field,x),isSpacer:k.isSpacer})),[$,o,t,m,x]),H=(w?48:0)+(v?48:0)+(r?48:0),j=(w||v||r)&&(!v||f)&&(!r||h),z=(w?1:0)+(v?1:0)+(r?1:0);return s.jsxs("div",{className:"ogx__header-wrap",children:[$>0&&Array.from({length:$},(k,F)=>{const Q=xa(U,R,F);return s.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":F+1,children:[H>0&&s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${j?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:H,minWidth:H,flexShrink:0,position:j?"sticky":void 0,left:j?0:void 0},"aria-hidden":"true"}),Q.map((ee,ce)=>{const fe=ee.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ee.pinned}`:"",ge={width:ee.width,minWidth:ee.width,flexShrink:0,flexGrow:ee.flexGrow};return ee.pinned==="left"?(ge.position="sticky",ge.left=B[ee.fields[0]]):ee.pinned==="right"&&(ge.position="sticky",ge.right=B[ee.fields[ee.fields.length-1]],Q[ce-1]?.pinned!=="right"&&(ge.marginLeft="auto")),ee.isGroup?s.jsx("div",{role:"columnheader","aria-colspan":ee.fields.length,"aria-colindex":z+ee.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${fe}${ee.headerClassName?` ${ee.headerClassName}`:""}`,style:ge,title:ee.label,children:s.jsx("span",{className:"ogx-col-group-cell__label",children:ee.label})},ee.key):s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${fe}`,style:ge,"aria-hidden":"true"},ee.key)})]},`ogx-grp-${F}`)}),s.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":$+1,children:[w&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${oe("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":Z,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),v&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${oe("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":de,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:f?"sticky":void 0,left:f?w?48:0:void 0}}),r&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${oe("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:h?"sticky":void 0,left:h?(w?48:0)+(v&&f?48:0):void 0},children:c&&s.jsx(Wt,{id:L,name:L,checked:i,indeterminate:l,onChange:k=>c(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,F)=>{if(k.isSpacer)return s.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const Q=k.sortable!==!1,ee=u.findIndex(Pe=>Pe.field===k.field),ce=ee!==-1,fe=ce?u[ee].sort:null,ge=_?.get(k.field)??F,be=Q?ee===0?fe==="asc"?"ascending":"descending":"none":void 0,Ce=ce&&u.length>1?`Sorted ${fe==="asc"?"ascending":"descending"}, sort priority ${ee+1} of ${u.length}`:void 0,ue=k.resizable!==!1,me=Xe(k.field,x),ve=me!==null,Se=b===k.field,le=y===k.field,ye=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,Q&&"ogx__header-cell--sortable",ce&&"ogx__header-cell--sorted",ve&&"ogx__header-cell--pinned",ve&&`ogx__header-cell--pinned-${me}`,me==="left"&&k.field===D.lastLeft&&"ogx__header-cell--pinned-left-last",me==="right"&&k.field===D.firstRight&&"ogx__header-cell--pinned-right-first",Se&&"ogx__header-cell--dragging",le&&"ogx__header-cell--drag-over",oe(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),xe={width:m[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:ve?"sticky":"relative",zIndex:k.zIndex,opacity:Se?.5:1};if(ve&&me){const Pe=B[k.field];me==="left"?xe.left=Pe:xe.right=Pe}const ke=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:ge}):k.headerName||k.field,ie=Pe=>{if(Pe.target.closest(".ogx-column-resize-handle")){Pe.stopPropagation();return}O?.(k.field),Q&&ne(k)(Pe)},pe=C&&!ve?C(k.field):void 0,we=N&&!ve?N(k.field):void 0,Me=E&&!ve?E(k.field):void 0;return s.jsxs("div",{className:ye,style:xe,title:k.description,onClick:ie,role:"columnheader",draggable:!!pe,onDragStart:pe,onDragOver:we,onDragEnd:T,onDrop:Me,onKeyDown:te(k),"aria-sort":be,"aria-description":Ce,"aria-colindex":z+ge+1,"data-field":k.field,tabIndex:-1,children:[s.jsxs("div",{className:"ogx__header-cell-content",children:[Se&&s.jsx("div",{className:"ogx__header-drag-icon",children:s.jsx(Ia,{})}),s.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[s.jsx("span",{className:"ogx__header-cell-title",children:ke}),p&&p[k.field]&&s.jsx("span",{className:"ogx__header-cell-aggregation",children:p[k.field]})]}),Q&&re(k.field),!k.disableColumnMenu&&s.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:K(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:s.jsx(Pa,{})})]}),ue&&g&&s.jsx(ma,{field:k.field,currentWidth:ot(k,m),onResize:g,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:me==="right"?"start":"end"})]},k.field)}),A&&s.jsx(Na,{colDef:A.colDef,sortModel:u,onSort:d||W?se:void 0,onHide:S,onPin:M,pinnedColumns:x,onManageColumns:I,onClose:J,anchorEl:A.anchorEl})]})]})}const lt=()=>{};function Yr(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:lt,selectRows:lt,getSelectedRows:()=>[],sortColumn:lt,getSortModel:()=>[],setFilterModel:lt,getFilterModel:()=>({items:[]}),setPage:lt,setPageSize:lt,scrollToIndexes:lt,copySelectedRows:()=>Promise.resolve()}}const Ta=e=>e.id;let Rr=!1;function Jr(e,t,o){const n=new Map,r=new Map,i=[],l=[];return e.forEach(c=>{const d=o?.get(c)??t(c);if(n.has(d)){l.push(d);return}n.set(d,c),r.set(c,d),i.push(d)}),l.length>0&&!Rr&&process.env.NODE_ENV!=="production"&&(Rr=!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:n,allRows:i,idByRow:r}}function La(e,t,o,n={}){const r=new Map,i=[];return o.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Jr(e,t),columns:{all:o,lookup:r,orderedFields:i,columnVisibilityModel:n},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Fa(e,t){switch(t.type){case"SET_ROWS":{const o=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),n=typeof t.payload=="function"?t.payload(o):t.payload;return{...e,rows:Jr(n,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const o=e.rows.idRowsLookup.get(t.id);if(o===void 0)return e;const n=new Map(e.rows.idRowsLookup);n.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(o),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:n,idByRow:r}}}case"SET_COLUMNS":{const o=new Map,n=[];return t.payload.forEach(r=>{o.set(r.field,r),n.push(r.field)}),{...e,columns:{all:t.payload,lookup:o,orderedFields:n,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 Oa(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,d=e.getRowId??Ta,u=a.useRef(d);a.useLayoutEffect(()=>{u.current=d});const[g]=a.useState(()=>La(t,d,o,i)),[m,x]=a.useReducer(Fa,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:n,headerHeight:r}}),[v,h]=a.useState({rows:t,syncRows:c});(v.rows!==t||v.syncRows!==c)&&(h({rows:t,syncRows:c}),c&&x({type:"SET_ROWS",payload:t,getRowId:d}));const f=a.useRef(m);a.useLayoutEffect(()=>{f.current=m});const w=a.useCallback((O,W)=>{x({type:"SET_ROWS",payload:O,getRowId:u.current})},[]),p=a.useCallback((O,W)=>{x({type:"REPLACE_ROW",id:O,row:W})},[]),b=a.useCallback(O=>{x({type:"SET_COLUMNS",payload:O})},[]),y=a.useCallback((O,W)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:O,viewportHeight:W}})},[]),C=a.useCallback(O=>{x({type:"SET_DATASOURCE_LOADING",payload:O})},[]),N=a.useCallback(O=>{x({type:"SET_DATASOURCE_ERROR",payload:O})},[]),T=a.useCallback(O=>{x({type:"SET_ROW_COUNT",payload:O})},[]),[E]=a.useState(()=>({...Yr(),getRow:O=>f.current.rows.idRowsLookup.get(O)||null,getAllRows:()=>f.current.rows.allRows.map(O=>f.current.rows.idRowsLookup.get(O)),getColumn:O=>f.current.columns.lookup.get(O)||null,getAllColumns:()=>f.current.columns.all})),P=a.useRef(E);return{state:m,dispatch:x,apiRef:P,setRows:w,replaceRow:p,setColumns:b,setDimensions:y,setDataSourceLoading:C,setDataSourceError:N,setRowCount:T}}function Da(e){const{onRowOrderChange:t,rows:o,getRowId:n,rowReordering:r=!1}=e,[i,l]=a.useState(null),[c,d]=a.useState(null),u=a.useRef(()=>{}),g=a.useMemo(()=>{const w=new Map;return o.forEach((p,b)=>w.set(n?n(p):p.id,b)),w},[o,n]),m=a.useCallback(w=>g.has(w),[g]),x=a.useCallback(()=>{u.current(),u.current=()=>{},l(null),d(null)},[]);a.useEffect(()=>()=>u.current(),[]);const v=a.useCallback(w=>p=>{if(r){if(!g.has(w)){p.preventDefault();return}u.current(),u.current=Tr(p.currentTarget,x),l(w),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Ir(p,sn,String(w)))}},[r,g,x]),h=a.useCallback(w=>p=>{if(!(!r||i===null)){if(!po(p,sn)){x();return}g.has(w)&&(p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),c!==w&&d(w))}},[r,i,c,g,x]),f=a.useCallback(w=>p=>{if(p.preventDefault(),i===null||!po(p,sn)){x();return}const b=g.get(i),y=g.get(w);x(),t&&b!==void 0&&y!==void 0&&b!==y&&t({row:o[b],oldIndex:b,targetIndex:y})},[i,t,o,g,x]);return{draggedRowId:i,dragOverRowId:c,canReorderRow:m,onDragStart:r?v:void 0,onDragOver:r?h:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const Qr=new Map,Zr=e=>JSON.stringify(e),Aa=e=>`auto-group-${e}`,ei=5,ti=e=>e.slice(0,ei).map(t=>JSON.stringify(t)).join(", ")+(e.length>ei?", …":""),$a={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Ga(e,t,o){const n=new Map,r=[],i=[],l=new Set,c=new Map,d=new Map,u=[],g=new Array(e.length),m=new Array(e.length),x=[],v=new Map;e.forEach((f,w)=>{const p=t(f),b=o(f),y=Array.isArray(b)?b.map(C=>String(C)):[];if(g[w]=p,m[w]=y,c.set(p,f),y.length===0)x.push(p);else{const C=Zr(y),N=d.get(C);if(N===void 0)d.set(C,p);else{const T=v.get(C)??[N];T.push(p),v.set(C,T)}}n.set(p,{id:p,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const h=f=>{const w=Zr(f),p=d.get(w);if(p!==void 0)return p;const b=Aa(w),y=f[f.length-1],C={id:b,parentId:null,depth:f.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};n.set(b,C),d.set(w,b),l.add(b);const N={id:b};if(i.push(N),c.set(b,N),f.length===1)r.push(b);else{const T=h(f.slice(0,-1));C.parentId=T,n.get(T)?.children?.push(b)}return b};return e.forEach((f,w)=>{const p=g[w],b=m[w];if(b.length<=1){r.push(p);return}const y=h(b.slice(0,-1)),C=n.get(p);C&&(C.parentId=y),n.get(y)?.children?.push(p)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${ti(x)}. They are shown as top-level rows.`),v.forEach((f,w)=>{u.push(`[OpenGridX] treeData: rows ${ti(f)} have the same path ${w}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:n,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:c,issues:u}}function Wa(e,t){const{treeNodes:o,rootIds:n,syntheticIds:r,rowLookup:i}=e,l=new Set,c=new Map,d=new Map,u=g=>{const m=o.get(g);if(!m)return!1;const x=[];let v=0;for(const p of m.children??[])u(p)&&(x.push(p),v+=(r.has(p)?0:1)+(d.get(p)??0));c.set(g,x),d.set(g,v);const h=i.get(g),w=!r.has(g)&&h!==void 0&&(t?t(h):!0)||x.length>0;return w&&l.add(g),w};return n.forEach(u),{visible:l,visibleChildren:c,descendantCounts:d}}function Ha(e){const{rows:t,getRowId:o,getTreeDataPath:n,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:c,onRowExpansionChange:d,columnLookup:u,filterMode:g="client",sortingMode:m="client"}=e,x=r&&!!n,v=a.useMemo(()=>!r||!n?$a:Ga(t,o,n),[t,n,r,o]),{treeNodes:h,rootIds:f,groupingRows:w,syntheticIds:p,rowLookup:b}=v,y=v.issues.join(`
|
|
2
2
|
`);a.useEffect(()=>{process.env.NODE_ENV==="production"||!y||y.split(`
|
|
3
|
-
`).forEach(J=>console.warn(J))},[y]);const C=r&&!n;a.useEffect(()=>{process.env.NODE_ENV==="production"||!C||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.")},[C]);const N=a.useMemo(()=>g==="server"?null:co(l,u),[g,l,u]),T=a.useMemo(()=>Ga(v,N),[v,N]),E=`${r}|${i}`,[P,O]=a.useState(()=>({configKey:E,overrides:new Map})),W=P.configKey===E?P.overrides:Qr,X=a.useCallback(J=>((J?.children?.length??0)>0||(J?.serverChildrenCount??0)>0)&&(i===-1||(J?.depth??0)<i),[i]),S=a.useMemo(()=>{const J=new Set;return x&&h.forEach((te,ne)=>{(W.get(ne)??X(te))&&J.add(ne)}),J},[x,h,W,X]),M=a.useCallback(J=>{const te=!S.has(J);if(O(ne=>{const Z=ne.configKey===E?ne.overrides:Qr,de=new Map(Z);return de.set(J,te),{configKey:E,overrides:de}}),te&&d){const ne=h.get(J);ne&&d(ne)}},[S,E,h,d]),I=m!=="server"&&!!(c&&c.length>0),_=a.useCallback(J=>{if(!x)return null;const te=J?.labelField,ne=J?.expandAll??!1,{visible:Z,visibleChildren:de}=T,ae=I&&c?c:[],oe=(D,$)=>{if(p.has(D))return{value:$.field===te?h.get(D)?.label:void 0};const R=b.get(D),U=u?.byField.get($.field);return{value:R?Le(R,$.field,U):void 0,type:U?.type}},se=[],re=new Set,B=D=>{const $=D.filter(U=>Z.has(U)),R=ae.length>0?Zo($,ae,oe):$;for(const U of R){if(re.has(U))continue;const G=b.get(U);if(!G)continue;re.add(U),se.push(G);const V=de.get(U);V&&V.length>0&&(ne||S.has(U))&&B(V)}};return B(f),se},[x,T,I,c,p,h,b,u,f,S]),F=a.useCallback(J=>S.has(J),[S]),A=a.useCallback(J=>h.get(J),[h]),q=a.useCallback(J=>{const te=[];let ne=J;for(;ne!==null;){const Z=h.get(ne);if(!Z)break;te.unshift(Z.groupingKey),ne=Z.parentId}return te},[h]),K=a.useMemo(()=>{const J=new Map,{visibleChildren:te,descendantCounts:ne}=T;return h.forEach((Z,de)=>{const ae=(Z.children?.length??0)===0&&(Z.serverChildrenCount??0)>0,oe=p.has(de),se={hasChildren:(te.get(de)?.length??0)>0||ae,treeDepth:Z.depth,descendantCount:ae?void 0:ne.get(de)??0,isGroupRow:oe,isExpanded:S.has(de)};oe&&(se.groupLabel=Z.label),J.set(de,se)}),J},[h,p,T,S]);return a.useMemo(()=>({treeNodes:h,groupingRows:w,toggleExpansion:M,isGroupExpanded:F,getVisibleRows:_,getNode:A,getNodePath:q,rowMetaMap:K}),[h,w,M,F,_,A,q,K])}const oi=e=>e===null?"footer":"inline";function ni(e,t){return no(()=>e(t),oi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Ha(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?no(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Ba=[],Va={},ri=new Map,He="";function za(e){if(typeof e=="string")return e;if(e===null)return`${He}null`;if(e===void 0)return`${He}undefined`;if(e instanceof Date)return`${He}date:${e.getTime()}`;if(typeof e=="object")try{return`${He}object:${JSON.stringify(e)}`}catch{return`${He}object:${String(e)}`}return`${He}${typeof e}:${String(e)}`}const Ka=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,ja=e=>`${e}${He}footer`,Ua=e=>e==="footer"?"f":e===null?"n":"i",Xa=e=>e==="f"?"footer":e==="n"?null:"inline";function qa(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Ba,aggregationModel:i=Va,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:d,getAggregationPosition:u=oi,columnLookup:g,filterMode:m="client",sortingMode:x="client"}=e,v=r.join(He),h=a.useMemo(()=>v===""?[]:v.split(He),[v]),f=JSON.stringify(Object.entries(i)),w=a.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),p=Object.keys(w).length>0,b=a.useMemo(()=>{const B=new Map;return(n??[]).forEach(D=>B.set(D.field,D)),B},[n]),y=h.length>0,C=a.useMemo(()=>h.filter(B=>b.get(B)?.groupable!==!1),[h,b]),T=`${C.join(He)}|${l}`,[E,P]=a.useState(()=>({configKey:T,overrides:new Map})),O=E.configKey===T?E.overrides:ri,W=a.useMemo(()=>{if(!y||m==="server")return null;const B=co(c,g);return B?new Set(t.filter(D=>B(D))):null},[y,t,m,c,g]),X=a.useMemo(()=>{const B=new Map,D=[],$=[],R=new Map,U=new Map,G=new Map;if(!y)return{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G};const V=(Y,H,j)=>{if(H>=C.length)return(W?Y.filter(ce=>W.has(ce)):Y).map(ce=>{const ue=o(ce);return G.set(ue,ce),B.set(ue,{id:ue,parentId:j,depth:H,groupingKey:"",isExpanded:!1}),ue});const z=C[H],k=b.get(z),L=new Map;for(const ee of Y){const ce=Le(ee,z,k),ue=za(ce);let he=L.get(ue);he||(he={value:ce,rows:[]},L.set(ue,he)),he.rows.push(ee)}const Q=[];return L.forEach((ee,ce)=>{const ue=W?ee.rows.filter(Se=>W.has(Se)):ee.rows;if(ue.length===0)return;const he=Ka(z,ce,j);Q.push(he),$.push(he);const be=p?so(ue,w,b,"useRowGrouping"):{},Ce={[z]:ee.value,...be,id:he},fe={[z]:ee.value,id:he},me=p?{...be,id:ja(he)}:null;R.set(he,{inline:Ce,bare:fe,footer:me}),U.set(he,Ce),me&&U.set(me.id,me);const ve={id:he,parentId:j,depth:H,groupingKey:String(ee.value),groupingField:z,groupingValue:ee.value,aggregatedValues:be,isExpanded:!1,children:[],label:Ha(k,z,ee.value),descendantCount:ue.length};B.set(he,ve),ve.children=V(ee.rows,H+1,he)}),Q};return D.push(...V(t,0,null)),{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G}},[y,t,W,C,p,w,o,b]),{treeNodes:S,rootIds:M,groupIds:I,groupRowVariants:_,groupingRows:F,rowLookup:A}=X,q=a.useCallback(B=>!!(B?.children&&B.children.length>0)&&(l===-1||(B?.depth??0)<l),[l]),K=a.useMemo(()=>{const B=new Set;return S.forEach((D,$)=>{!D.children||D.children.length===0||(O.get($)??q(D))&&B.add($)}),B},[S,O,q]),J=a.useCallback(B=>{P(D=>{const $=D.configKey===T?D.overrides:ri,R=$.get(B)??q(S.get(B)),U=new Map($);return U.set(B,!R),{configKey:T,overrides:U}})},[T,S,q]),te=a.useCallback(B=>K.has(B),[K]),ne=p?I.map(B=>{const D=S.get(B);return D?Ua(ni(u,{...D,isExpanded:K.has(B)})):"i"}).join(""):"",Z=a.useMemo(()=>{const B=new Map;return I.forEach((D,$)=>B.set(D,Xa(ne[$]))),B},[I,ne]),de=p?ni(u,null):"footer",ae=x!=="server"&&!!(d&&d.length>0),oe=a.useCallback(B=>{if(!y)return null;const D=B?.labelField,$=B?.expandAll??!1,R=ae&&d?d:[],U=(H,j)=>{const z=S.get(H);if(z&&_.has(H)){const Q=z.groupingField??"";return j.field===Q||j.field===D?{value:z.groupingValue,type:g?.byField.get(Q)?.type}:z.aggregatedValues&&Object.prototype.hasOwnProperty.call(z.aggregatedValues,j.field)?{value:z.aggregatedValues[j.field],type:g?.byField.get(j.field)?.type}:{value:void 0}}const k=A.get(H),L=g?.byField.get(j.field);return{value:k?Le(k,j.field,L):void 0,type:L?.type}},G=[],V=new Set,Y=H=>{const j=R.length>0?Zo(H,R,U):H;for(const z of j){if(V.has(z))continue;V.add(z);const k=_.get(z);if(!k){const ue=A.get(z);ue&&G.push(ue);continue}const L=S.get(z),Q=K.has(z),ee=Z.has(z)?Z.get(z)??null:"inline",ce=ee==="inline"||ee==="footer"&&!Q;G.push(ce?k.inline:k.bare),(Q||$)&&L?.children&&(Y(L.children),Q&&!$&&ee==="footer"&&k.footer&&G.push(k.footer))}};return Y(M),G},[y,ae,d,S,_,A,g,K,Z,M]),se=a.useCallback(B=>S.get(B),[S]),re=a.useMemo(()=>{const B=new Map;return S.forEach((D,$)=>{const R=_.get($);if(!R){B.set($,{hasChildren:!1,treeDepth:D.depth,isGroupRow:!1});return}const U={hasChildren:!0,treeDepth:D.depth,groupingField:D.groupingField,groupingValue:D.groupingValue,groupLabel:D.label,descendantCount:D.descendantCount,isGroupRow:!0,isExpanded:K.has($)};B.set($,U),R.footer&&Z.get($)==="footer"&&B.set(R.footer.id,{...U,hasChildren:!1,treeDepth:D.depth+1,isExpanded:void 0,isGroupFooter:!0})}),B},[S,_,K,Z]);return a.useMemo(()=>({treeNodes:S,groupingRows:F,toggleExpansion:J,isGroupExpanded:te,getVisibleRows:oe,getNode:se,rowMetaMap:re,aggregationPositions:Z,rootAggregationPosition:de}),[S,F,J,te,oe,se,re,Z,de])}const Ya=new Map;function Ra(e){const{rows:t,getRowId:o,getTreeDataPath:n,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:c,isRowGrouping:d,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}=e,p=Wa({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,columnLookup:h,filterMode:f,sortingMode:w}),b=qa({rows:t,getRowId:o,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}),y=i?p:d?b:null,C=a.useMemo(()=>i?p.rowMetaMap:d?b.rowMetaMap:Ya,[i,p.rowMetaMap,d,b.rowMetaMap]);return{treeDataHandlers:p,rowGroupingHandlers:b,activeHierarchyHandlers:y,rowMetaMap:C}}const yt=Promise.resolve();class ii extends Error{}function wo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Ja(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Qa(e){const[t,o]=a.useState(null),n=a.useRef(null),r=a.useRef(0),i=a.useRef(new Map),l=a.useRef(new Set),c=a.useRef(!1),d=a.useRef(e);a.useLayoutEffect(()=>{d.current=e}),a.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=a.useCallback(h=>{n.current=h,o(h)},[]),g=a.useCallback((h,f)=>{const w=i.current.get(h);if(w)return wo(w.value,f.value)?w.promise:w.promise.then(()=>{const F=n.current;if(!(r.current!==h||!F||wo(F.value,w.value)))return g(h,F)});const p=()=>r.current===h&&n.current!==null;if(wo(f.value,f.originalValue))return p()&&u(null),yt;const{rows:b,getRowId:y,columns:C,processRowUpdate:N}=d.current,T=b.find(F=>y(F)===f.id);if(!T)return p()&&u(null),yt;const E=F=>{const A=d.current.onProcessRowUpdateError;A?A(F):process.env.NODE_ENV!=="production"&&F instanceof ii&&console.error(F.message)},P=F=>{if(typeof F!="object"||F===null){E(new ii(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${F===null?"null":typeof F}. The edit was not saved and the editor stays open.`));return}d.current.onRowChange?.(F,f.id);const A=n.current;r.current!==h||!A||(wo(A.value,f.value)?u(null):u({...A,originalValue:f.value}))};let O,W;const X=new Promise((F,A)=>{O=F,W=A}),S={value:f.value,promise:X};i.current.set(h,S);const M=()=>{i.current.get(h)===S&&i.current.delete(h)};let I;try{const F=C?.find(q=>q.field===f.field),A=Za(T,f,F,l.current);I=N?N(A,T):A}catch(F){return M(),E(F),O(),X}const _=F=>{M();try{P(F),O()}catch(A){W(A)}};return Ja(I)?Promise.resolve(I).then(_,F=>{M(),E(F),O()}):_(I),X},[u]),m=a.useCallback(h=>{const f=n.current;if(f){if(f.id===h.id&&f.field===h.field)return;g(r.current,f)}r.current+=1,u({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[g,u]),x=a.useCallback(h=>{const f=n.current;return!f||!c.current||h?.id!==void 0&&h.id!==f.id||h?.field!==void 0&&h.field!==f.field?yt:h?.cancel?(u(null),yt):g(r.current,f)},[g,u]),v=a.useCallback(h=>{const f=n.current;!f||f.id!==h.id||f.field!==h.field||u({...f,value:h.value})},[u]);return a.useMemo(()=>({editingCell:t,startCellEdit:m,stopCellEdit:x,setEditCellValue:v}),[t,m,x,v])}function Za(e,t,o,n){return o?.valueSetter?o.valueSetter({value:t.value,row:e,field:t.field}):(o?.valueGetter&&process.env.NODE_ENV!=="production"&&!n.has(t.field)&&(n.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 ed=e=>e.id,td={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},li="\0",si="";function ai(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 od(e){return e.map(t=>t.field).join(li)}function nd(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:d,rowMetaMap:u,getRowId:g=ed}=e,m=a.useMemo(()=>r.some(p=>p.colSpan!==void 0&&p.colSpan!==null),[r]),x=a.useMemo(()=>r.some(p=>p.rowSpan!==void 0&&p.rowSpan!==null),[r]),v=m||x,h=v?[i,l,c].map(od).join(si):"",f=a.useMemo(()=>{if(!h)return{columns:[],leftCount:0,unpinnedCount:0};const p=new Map(r.map(N=>[N.field,N])),b=h.split(si).map(N=>N?N.split(li):[]),y=[];let C=0;for(const N of b){C+=N.length;for(const T of N){const E=p.get(T)??{field:T};y.push({colDef:E,field:T,sectionEnd:C,hasColSpan:E.colSpan!==void 0&&E.colSpan!==null,hasRowSpan:E.rowSpan!==void 0&&E.rowSpan!==null})}}return{columns:y,leftCount:b[0].length,unpinnedCount:b[1].length}},[h,r]),w=a.useMemo(()=>{if(!v||f.columns.length===0)return null;const p={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:f,expandedRowIds:d,rowMetaMap:u,getRowId:g,warned:new Set,out:p};return fn(t,0,!1,y),fn(o,t.length,!0,y),fn(n,t.length+o.length,!1,y),p},[v,f,t,o,n,d,u,g]);return a.useMemo(()=>{if(!w)return td;const{colspanMap:p,rowSpanningCaches:b,hiddenOriginFields:y,unpinnedRanges:C,centerRowSpanStart:N}=w,T=f.columns;return{hasColSpan:m,hasRowSpan:x,colspanMap:p,rowSpanningCaches:b,getSpanOrigin:(E,P)=>{const O=p.get(E)?.[P];if(O?.spannedByColSpan)return{rowId:E,field:T[O.leftVisibleCellIndex].field};const W=b.hiddenCellOriginMap[E]?.[P];return W===void 0?null:{rowId:W,field:y.get(E)?.[P]??P}},getUnpinnedColSpanRanges:E=>C.get(E),getCenterRowSpanStart:E=>N.get(E)??E}},[w,m,x,f])}function fn(e,t,o,n){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:d,out:u}=n,{columns:g,leftCount:m,unpinnedCount:x}=r,v=g.length,{colspanMap:h,rowSpanningCaches:f,hiddenOriginFields:w,unpinnedRanges:p,centerRowSpanStart:b}=u,y=new Int32Array(v),C=new Array(v),N=new Array(v),T=new Int32Array(v);let E=0;const P=[];g.forEach((X,S)=>{(X.hasColSpan||X.hasRowSpan)&&P.push(S)});const O=(X,S,M)=>{const I=g[M].field;if(Ct(f.hiddenCells,X,I,!0),Ct(f.hiddenCellOriginMap,X,I,C[M]),N[M]!==I&&Ct(w,X,I,N[M]),o){const _=b.get(S);(_===void 0||T[M]<_)&&b.set(S,T[M])}},W=(X,S,M)=>{const I=g[M],_=c(X),F=rd(X,_,I.colDef,t+S,M,l,d);let A=1;if(I.hasColSpan){const K=Math.min(di(I.colDef.colSpan,F,"colSpan",I.field,d),I.sectionEnd-M);for(;A<K&&y[M+A]<=S;)A++}let q=1;if(I.hasRowSpan){q=Math.min(di(I.colDef.rowSpan,F,"rowSpan",I.field,d),e.length-S);for(let K=1;K<q;K++)if(qe(c(e[S+K]),l)){q=K;break}if(q>1&&i&&i.size>0){for(let K=0;K<q-1;K++)if(i.has(c(e[S+K]))){q=K+1;break}}}if(A>1){Ct(h,_,I.field,{spannedByColSpan:!1,cellProps:{colSpan:A}});for(let K=1;K<A;K++){const J=g[M+K];Ct(h,_,J.field,{spannedByColSpan:!0,leftVisibleCellIndex:M,rightVisibleCellIndex:M+A-1})}if(M>=m&&M<m+x){let K=p.get(_);K||(K=[],p.set(_,K)),K.push(M-m,M+A-1-m)}}if(q>1){Ct(f.spannedCells,_,I.field,q);for(let K=M;K<M+A;K++)y[K]=S+q,C[K]=_,N[K]=I.field,T[K]=S;S+q>E&&(E=S+q)}return A};for(let X=0;X<e.length;X++){const S=e[X];if(!S||S._isSkeleton||qe(c(S),l))continue;if(E<=X){let I=0;for(const _ of P)_>=I&&(I=_+W(S,X,_));continue}let M=0;for(;M<v;)y[M]>X?(O(c(S),X,M),M++):g[M].hasColSpan||g[M].hasRowSpan?M+=W(S,X,M):M++}}function rd(e,t,o,n,r,i,l){const c=e[o.field];let d=c;if(o.valueGetter)try{d=o.valueGetter({row:e,field:o.field,value:c})}catch(u){ci(l,`valueGetter:${o.field}`,`valueGetter for column "${o.field}" threw while computing its span`,u),d=void 0}return{row:e,value:d,field:o.field,colDef:o,rowIndex:n,colIndex:r,rowMeta:i?.get(t)}}function di(e,t,o,n,r){if(typeof e=="number")return ai(e);if(typeof e!="function")return 1;try{return ai(e(t))}catch(i){return ci(r,`${o}:${n}`,`${o} for column "${n}" threw; the cell is rendered without a span`,i),1}}function ci(e,t,o,n){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${o}.`,n))}function Ct(e,t,o,n){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[o]=n;return}let r=e[t];r||(r={},e[t]=r),r[o]=n}function id(e){const{spanning:t,renderContext:o,offsetTop:n,cumulativeHeights:r}=e;return a.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:o,offsetTop:n};let i=Math.max(0,o.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=o.firstRowIndex?{renderContext:o,offsetTop:n}:{renderContext:{...o,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,o,n,r])}function ld(e){const{spanning:t,firstColumnIndex:o,lastColumnIndex:n,virtualColumns:r,layout:i,rows:l}=e;return a.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=o,d=n,u=!0;for(;u;){u=!1;for(const{row:p,id:b}of l){const y=t.getUnpinnedColSpanRanges(b??p.id);if(y)for(let C=0;C<y.length;C+=2){const N=y[C],T=y[C+1];T<c||N>d||(N<c&&(c=N,u=!0),T>d&&(d=T,u=!0))}}}if(c===o&&d===n)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:m,rightPinnedCols:x,unpinnedAccWidths:v,unpinnedTotalWidth:h}=i,f=c>0?v[c-1]:0,w=h-v[d];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...m.slice(c,d+1),...w>0?[{field:"__spacer_right__",width:w,isSpacer:!0}]:[],...x]},[t,o,n,r,i,l])}function sd(e,t){const{draggedColumn:o,onDragOver:n,onDrop:r,onDragEnd:i}=t,l=a.useMemo(()=>{if(!e||e.length===0)return null;const c=d=>o===null||un(e,o,d);return{onDragOver:n&&(d=>c(d)?n(d):()=>{}),onDrop:r&&(d=>c(d)?r(d):u=>{u.preventDefault(),i?.()})}},[e,o,n,r,i]);return l?{...t,...l}:t}const ad=300,ui=e=>e.id;function dd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function fi(e,t){const o=new Set,n=[];return e.forEach(r=>{const i=t(r);o.has(i)||(o.add(i),n.push({id:i,row:r}))}),n}function gi(e,t,o){const n=new Set(e.map(o)),r=t.filter(i=>!n.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function cd(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:d,rowGroupingActive:u=!1}=e,g=dd(i,u),m=!!t&&i==="server"&&u,x=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!m||(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."))},[m]);const v=t?.getRows,h=Vr({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),f=JSON.stringify([g,g!=="all"||l==="server"?o:null,g!=="all"||c==="server"?n:null,h?d??null:null,g==="all"?null:r.pageSize]),w=g==="all"?0:r.page,p=g==="all"?0:r.pageSize,b=a.useRef({params:e,kind:g});a.useLayoutEffect(()=>{b.current={params:e,kind:g}});const y=a.useRef(0),C=a.useRef(0),N=a.useRef(null),T=a.useRef({page:0,loadedEnd:0,inFlightEnd:null}),E=a.useRef(null),P=a.useRef(!1),O=a.useRef(0),W=a.useRef(!1),X=a.useRef(new Set),S=a.useCallback(()=>{const J=P.current||O.current>0;J!==W.current&&(W.current=J,b.current.params.setDataSourceLoading(J))},[]),M=a.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),I=a.useCallback(()=>{y.current++,T.current.inFlightEnd=null,P.current=!1},[]),_=a.useCallback(()=>{C.current++,X.current.clear(),O.current=0},[]),F=a.useCallback(async()=>{const{params:J,kind:te}=b.current,ne=J.dataSource;if(!ne)return!1;const Z=T.current,de=J.paginationModel.pageSize;let ae,oe;if(te==="infinite"){if(Z.inFlightEnd!==null)return!1;if(ae=Z.loadedEnd,oe=(Z.page+1)*de,oe<=ae)return P.current=!1,S(),!1;Z.inFlightEnd=oe}else te==="page"?(ae=J.paginationModel.page*de,oe=ae+de):(ae=0,oe=zr);const se=++y.current;P.current=!0,S(),J.setDataSourceError(null);let re;try{re=await ne.getRows({startRow:ae,endRow:oe,sortModel:J.sortModel,filterModel:J.filterModel,groupKeys:[],aggregationModel:J.aggregationModel})}catch(B){return se!==y.current||(Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S()),!1}if(se!==y.current)return!1;try{const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);if(te==="infinite"&&ae>0?B.setRows(R=>gi(R,$,D),!0):(B.setRows($.map(R=>R.row),!0),_()),re.aggregationResults&&B.onAggregationResults?.(re.aggregationResults),re.rowCount!==void 0&&B.setRowCount(re.rowCount),te==="infinite"&&(Z.inFlightEnd=null,Z.loadedEnd=ae+re.rows.length,re.rows.length>=oe-ae&&(Z.page+1)*de>oe))return!0}catch(B){return Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S(),!1}return P.current=!1,S(),!1},[S,_]),A=a.useCallback(async()=>{for(;await F(););},[F]);a.useLayoutEffect(()=>{if(!v){N.current&&(N.current=null,M(),I(),_(),b.current.params.setDataSourceError(null),S());return}const J=N.current,te=T.current;if(!J||J.key!==f||J.getRows!==v){N.current={key:f,getRows:v},I(),_();const ne=g==="infinite"&&J!==null&&w!==0;if(te.page=ne?0:w,te.loadedEnd=0,ne){const{params:Z}=b.current;Z.onPaginationModelChange?.({...Z.paginationModel,page:0})}}else g==="infinite"?(w<te.page&&(I(),te.loadedEnd=0),te.page=w):I();if(g==="infinite"){const ne=te.inFlightEnd!==null;if(ne||(te.page+1)*p<=te.loadedEnd){P.current=ne,S();return}}return P.current=!0,S(),E.current=setTimeout(()=>{E.current=null,A()},ad),M},[v,f,g,w,p,M,I,_,S,A]),a.useEffect(()=>()=>{I(),_()},[I,_]);const q=a.useCallback(()=>(M(),A()),[M,A]),K=a.useCallback(async(J,te,ne)=>{const{params:Z}=b.current,de=Z.dataSource;if(!de)return;const ae=JSON.stringify(te),oe=X.current;if(oe.has(ae))return;const se=C.current;oe.add(ae),O.current++,S();try{const re=await de.getRows({startRow:0,endRow:zr,sortModel:Z.sortModel,filterModel:Z.filterModel,groupKeys:te,aggregationModel:Z.aggregationModel});if(se!==C.current)return;if(re.rows.length>0){const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);B.setRows(R=>gi(R,$,D),!0)}}catch(re){if(se!==C.current)return;oe.delete(ae),console.error("Failed to fetch children:",re),ne?.(re)}finally{se===C.current&&(O.current--,S())}},[S]);return{fetchRows:q,fetchChildren:K}}function ud(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function fd({enabled:e,treeNodes:t,isGroupExpanded:o,getNodePath:n,toggleExpansion:r,fetchChildren:i}){const l=a.useRef({isGroupExpanded:o,toggleExpansion:r});a.useLayoutEffect(()=>{l.current={isGroupExpanded:o,toggleExpansion:r}}),a.useEffect(()=>{e&&t.forEach((c,d)=>{!ud(c)||!o(d)||i(d,n(d),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(d)&&g(d)})})},[e,t,o,n,i])}const pi={};function gd(e){const t=JSON.stringify(e),[o,n]=a.useState(null),r=a.useCallback(i=>n({modelKey:t,results:i}),[t]);return[o&&o.modelKey===t?o.results:null,r]}function hi(e){const{rows:t,columns:o,aggregationModel:n,isServerSide:r,dataSource:i,filterModel:l,sortModel:c,serverAggregationResults:d}=e,u=Object.keys(n).length>0,g=a.useMemo(()=>{const N=new Map;return(o??[]).forEach(T=>N.set(T.field,T)),N},[o]),m=a.useMemo(()=>r||!u?pi:so(t,n,g,"useAggregation"),[t,g,n,r,u]),x=JSON.stringify([n,l??null,c??[]]),v=r&&u&&!!i?.getAggregations&&!d,h=a.useRef({aggregationModel:n,filterModel:l,sortModel:c});a.useEffect(()=>{h.current={aggregationModel:n,filterModel:l,sortModel:c}});const[f,w]=a.useState(null);a.useEffect(()=>{const N=i?.getAggregations;if(!v||!N)return;let T=!1;const E=h.current;let P;try{P=Promise.resolve(N({sortModel:E.sortModel??[],filterModel:E.filterModel??{items:[]},groupKeys:[],aggregationModel:E.aggregationModel}))}catch(O){P=Promise.reject(O)}return P.then(O=>{T||w({key:x,result:O,error:null})},O=>{T||(console.error("[useAggregation] Server aggregation error:",O),w({key:x,result:null,error:O}))}),()=>{T=!0}},[v,i,x]);const p=f&&f.key===x?f:null,b=v&&p===null,y=v?p?.error??null:null;return{aggregationResult:a.useMemo(()=>r?d&&Object.keys(d).length>0?d:p?.result??pi:m,[r,m,d,p]),isLoading:b,error:y}}const pd={items:[]},hd=[];function wd(e){const{rows:t,columns:o,pivotMode:n,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:d}=e,u=n&&!c,g=a.useMemo(()=>new Set(o.map(p=>p.field)),[o]),m=a.useMemo(()=>en(o),[o]),x=a.useMemo(()=>ns(i,g),[i,g]),v=a.useMemo(()=>u?Ro(t,x.source,m):t,[u,t,x.source,m]),h=a.useMemo(()=>u?vr(v,o,r,{outputFilterModel:x.output,sortModel:l}):on,[u,v,o,r,x.output,l]),f=u&&h.isValid,w=a.useRef({dataSource:!1,hierarchy:!1});return a.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&c&&!w.current.dataSource&&(w.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`.")),f&&d&&!w.current.hierarchy&&(w.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.")))},[n,c,f,d]),{isActive:f,rows:f?h.pivotRows:t,columns:f?h.pivotColumns:o,pipelineFilterModel:f?pd:i,pipelineSortModel:f?hd:l}}const Wt=({variant:e="text",size:t="medium",color:o="default",disabled:n=!1,className:r="",type:i="button",children:l,...c})=>{const d=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${o}`,n&&"ogx-button--disabled",r].filter(Boolean).join(" ");return s.jsx("button",{type:i,className:d,disabled:n,...c,children:l})};function gn(e){const t=a.useId(),{page:o,pageSize:n,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:c=[10,25,50,100],showFirstButton:d=!0,showLastButton:u=!0,localeText:g}=e,m=fo(n),x=rn(r,m),v=Pr(o,x),h=c.includes(m)?c:[...c,m].sort((S,M)=>S-M),f=v*m,w=Math.min(f+m,r),p=r===0?0:`${f+1}–${w}`,b=g?.paginationRowsPerPage??"Rows per page:",y=g?.paginationOf?g.paginationOf(r===0?0:f+1,w,r):`${p} of ${r}`,C=g?.paginationPage?g.paginationPage(v+1,x):`Page ${v+1} of ${x}`,N=()=>{i(0)},T=()=>{i(Math.max(0,v-1))},E=()=>{i(Math.min(x-1,v+1))},P=()=>{i(x-1)},O=S=>{const M=parseInt(S.target.value,10);l(M)},W=v===0,X=v>=x-1;return s.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[s.jsxs("div",{className:"ogx-pagination__page-size",children:[s.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:b}),s.jsx("select",{id:t,className:"ogx-pagination__select",value:m,onChange:O,children:h.map(S=>s.jsx("option",{value:S,children:S},S))})]}),s.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),s.jsxs("div",{className:"ogx-pagination__actions",children:[d&&s.jsx(Wt,{variant:"text",size:"small",onClick:N,disabled:W,"aria-label":"Go to first page",title:"First page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),s.jsx(Wt,{variant:"text",size:"small",onClick:T,disabled:W,"aria-label":"Go to previous page",title:"Previous page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),s.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:C}),s.jsx(Wt,{variant:"text",size:"small",onClick:E,disabled:X,"aria-label":"Go to next page",title:"Next page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&s.jsx(Wt,{variant:"text",size:"small",onClick:P,disabled:X,"aria-label":"Go to last page",title:"Last page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function md({row:e,rowId:t,rowIndex:o,ariaRowIndex:n,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:c=!1,checkboxSelection:d=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:m,onSelectionChange:x,tabIndex:v=-1,onFocus:h,onToggleExpansion:f}){const w=t??e.id,p=r.field,b=Le(e,p,i),y=Ho(e,p,b,i)??Bo(b,i),C=l?.isGroupRow===!0||qe(w),N={row:e,value:b,formattedValue:y,field:p,colDef:i??r,rowIndex:o,colIndex:0,rowMeta:l},T=E=>{E.stopPropagation(),x?.(w,E.target.checked)};return s.jsxs("div",{className:`ogx-list-view__row${c?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:m?()=>m(e):void 0,role:"row","aria-rowindex":n??o+1,"aria-selected":c,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":o,tabIndex:v,onFocus:h?E=>{E.target===E.currentTarget&&h(o)}:void 0,children:[d&&s.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!C&&s.jsx("input",{type:"checkbox",checked:c,onChange:T,"aria-label":`Select row ${w}`,tabIndex:-1})}),l&&f&&s.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&s.jsx(an,{isExpanded:l.isExpanded===!0,onClick:()=>f(w),tabIndex:-1})}),s.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:s.jsx(it,{field:p,resetKey:e,renderFn:()=>{const E=r.renderCell(N);return E===void 0&&C?l?.groupLabel:E}})})]})}function xd(e,t){const o=a.useRef(!0),n=a.useRef(e);a.useEffect(()=>{n.current=e},[e]),a.useEffect(()=>{o.current=!0},[t]);const r=a.useCallback(i=>{const l=Or(i.currentTarget);if(!l){o.current=!0;return}if(!o.current)return;const c=n.current;c&&(o.current=!1,c(l))},[]);return e?r:void 0}const bd=e=>e.id;function vd({ariaLabel:e,allRenderableRows:t,dataRowCount:o,pinnedTopRowCount:n,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:c,currentPage:d,pageSizeOptions:u,selectedRowIds:g,listViewColumn:m,columnsByField:x,rowMetaMap:v,noRowsLabel:h,rowHeight:f,checkboxSelection:w,paginationMode:p,serverRowCount:b,paginationSlot:y,paginationSlotProps:C,localeText:N,onRowClick:T,onRowDoubleClick:E,onSelectionChange:P,onPaginationModelChange:O,onRowsScrollEnd:W,getRowId:X=bd,multiselectable:S=!1,loading:M=!1,loadingOverlay:I,noRowsOverlay:_,showPaginationControls:F=!0,selectable:A=!1,onToggleExpansion:q}){const K=y||gn,J=a.useRef(null),[te,ne]=a.useState(null),Z=te===null?-1:t.findIndex(Y=>X(Y)===te),de=Z===-1?0:Z,ae=Y=>{const H=t[Y];H&&(ne(X(H)),J.current?.querySelector(`:scope > [role="row"][data-rowindex="${Y}"]`)?.focus())},oe=Y=>{const H=Y.target;if(H.getAttribute("role")!=="row"||H.parentElement!==J.current)return;const j=Number(H.getAttribute("data-rowindex")),z=t[j];if(!z)return;const k=X(z),L=t.length-1,Q=v.get(k),ee=!!(Q?.hasChildren&&q);if(Y.altKey&&(Y.key==="ArrowRight"||Y.key==="ArrowLeft")){Y.preventDefault(),ee&&Y.key==="ArrowRight"!=(Q?.isExpanded===!0)&&q?.(k);return}switch(Y.key){case"ArrowDown":Y.preventDefault(),ae(Math.min(j+1,L));return;case"ArrowUp":Y.preventDefault(),ae(Math.max(j-1,0));return;case"Home":Y.preventDefault(),ae(0);return;case"End":Y.preventDefault(),ae(L);return;case"PageDown":Y.preventDefault(),ae(Math.min(j+10,L));return;case"PageUp":Y.preventDefault(),ae(Math.max(j-10,0));return;case"Enter":case" ":if(Y.preventDefault(),Y.key===" "&&Y.shiftKey){A&&!Q?.isGroupRow&&P(k,!g.has(k));return}ee?q?.(k):T({row:z,id:k,rowIndex:j});return}},se=p==="server",re=se?b||0:i,B=se?b||0:o,D=fo(c.pageSize),$=rn(re,D),R=l?d*D:0,U=t.length-n-r,G=Y=>{if(Y<n)return Y+1;const H=Y-n;return H<U?n+R+H+1:n+re+(H-U)+1},V=xd(W,t.length);return s.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":B,"aria-multiselectable":S,children:[s.jsx("div",{className:"ogx-list-view__toolbar",children:s.jsxs("span",{children:[B," ",B===1?"item":"items",l?` · page ${d+1} of ${$}`:"",g.size>0?` · ${g.size} selected`:""]})}),s.jsx("div",{className:"ogx-list-view__rows",onScroll:V,onKeyDown:oe,ref:J,children:t.length===0&&M?s.jsx("div",{className:"ogx-list-view__loading",children:I??s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&_?s.jsx("div",{className:"ogx-list-view__empty",children:_}):t.length===0?s.jsxs("div",{className:"ogx-list-view__empty",children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),h]}):t.map((Y,H)=>{const j=X(Y);return s.jsx(md,{row:Y,rowId:j,rowIndex:H,ariaRowIndex:G(H),listViewColumn:m,gridColumn:x.get(m.field),rowMeta:v.get(j),isSelected:g.has(j),checkboxSelection:w,rowHeight:f,onRowClick:z=>T({row:z,id:j,rowIndex:H}),onRowDoubleClick:E?z=>E({row:z,id:j,rowIndex:H}):void 0,onSelectionChange:P,tabIndex:H===de?0:-1,onToggleExpansion:q,onFocus:z=>ne(X(t[z]))},j)})}),l&&F&&s.jsx(K,{page:d,pageSize:c.pageSize,rowCount:re,pageSizeOptions:u,onPageChange:Y=>O({...c,page:Y}),onPageSizeChange:Y=>O({...c,pageSize:Y,page:0}),localeText:N,...C})]})}function yd({overlay:e}){return e?s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function Ht(e){return e.headerName||e.field}function Cd(e){return e.nativeEvent.isComposing||e.keyCode===229}function Bt(e,t,o=!0){return n=>{if(Cd(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function _d({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(String(e??"")),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"text",className:"ogx__edit-input","aria-label":Ht(t),value:i,onChange:d=>{l(d.target.value),o(d.target.value)},onBlur:n,onKeyDown:Bt(n,r)})}function Sd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(typeof e=="number"?e:""),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":Ht(t),value:i,onChange:d=>{const u=d.target.value===""?"":Number(d.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Bt(n,r)})}function kd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=()=>{o(!e),n()};return s.jsx("div",{className:"ogx__edit-boolean",children:s.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":Ht(t),checked:!!e,onChange:l,onBlur:n,onKeyDown:Bt(n,r,!1)})})}const pn=e=>typeof e=="object"?e.value:e,Ed=e=>typeof e=="object"?e.label:String(e);function Md(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Nd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(g=>String(pn(g)));let d=l.findIndex(g=>Md(pn(g),e));d===-1&&e!==null&&e!==void 0&&(d=c.indexOf(String(e)));const u=d===-1;return s.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Ht(t),value:u?"":c[d],onChange:g=>{const m=c.indexOf(g.target.value);o(m===-1?null:pn(l[m]))},onBlur:n,onKeyDown:Bt(n,r),children:[u&&s.jsx("option",{value:""}),l.map((g,m)=>s.jsx("option",{value:c[m],children:Ed(g)},m))]})}const wi=e=>String(e).padStart(2,"0"),mi=/^(\d{4}-\d{2}-\d{2})/;function hn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${wi(e.getMonth()+1)}-${wi(e.getDate())}`;if(typeof e=="string"){const t=mi.exec(e);return t?t[1]:e===""?"":hn(new Date(e))}return typeof e=="number"?hn(new Date(e)):""}function Pd(e,t){if(e==="")return null;const[o,n,r]=e.split("-").map(Number),i=l=>{const c=new Date(l.getTime());return c.setFullYear(o,n-1,r),c};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&mi.test(t)&&t.length>10?e+t.slice(10):e}function Id({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=a.useState(e),[l,c]=a.useState(()=>hn(e)),d=a.useRef(null);return a.useEffect(()=>{d.current?.focus()},[]),s.jsx("input",{ref:d,type:"date",className:"ogx__edit-input","aria-label":Ht(t),value:l,onChange:u=>{c(u.target.value),o(Pd(u.target.value,i))},onBlur:n,onKeyDown:Bt(n,r)})}function Td(e){const{colDef:t}=e;switch(t.type){case"number":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Sd,{...e})});case"boolean":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(kd,{...e})});case"singleSelect":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Nd,{...e})});case"date":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Id,{...e})});default:return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(_d,{...e})})}}function Fd(e){const{onCellClick:t,onCellEditStart:o,onCellValueChange:n,value:r,row:i,colDef:l,rowIndex:c,colIndex:d,ariaColIndex:u,isSelected:g,onClick:m,width:x,pinnedPosition:v,pinnedOffset:h,isPinnedEdge:f,isFocused:w,isFocusVisible:p,isEditable:b,isEditing:y,onEditStart:C,onEditStop:N,onValueChange:T,colSpanInfo:E,rowSpan:P,isHiddenByRowSpan:O,rowMeta:W,valueError:X}=e,S=a.useCallback(G=>{n?n(l.field,G):T?.(G)},[n,T,l.field]),M=W?.isGroupRow===!0,{formattedValue:I,error:_}=a.useMemo(()=>{if(l.valueFormatter&&!(M&&r==null))try{return{formattedValue:l.valueFormatter({value:r,row:i,field:l.field})}}catch(G){return{formattedValue:"",error:G??new Error("valueFormatter failed")}}return{formattedValue:Bo(r,l)}},[r,i,l,M]),F=a.useMemo(()=>{if(!l.cellClassName)return"";if(typeof l.cellClassName=="function")try{return l.cellClassName({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})||""}catch{return""}return l.cellClassName},[l,r,I,i,c,d,W]),A=X??_,q=l.field,K=a.useCallback(()=>{N?.(!1,q)},[N,q]),J=a.useCallback(()=>{N?.(!0,q)},[N,q]),te=a.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),ne=a.useRef(!1);if(a.useEffect(()=>{if(!(!y||!N))return ne.current=!0,()=>{ne.current=!1,queueMicrotask(()=>{ne.current||N(!1,q)})}},[y,N,q]),E?.spannedByColSpan)return null;const Z=E?.cellProps.colSpan??1,de=Z>1,ae=(de?E?.cellProps.width:void 0)??x??l.width??100,oe={width:"var(--width)","--width":typeof ae=="number"?`${ae}px`:ae,flexGrow:(de?E?.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(O)return s.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:oe,role:"presentation","data-field":l.field,"data-colindex":d});const se=G=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:d}),m?.(G))},re=()=>{y||!b||(o?o(l.field,r):C?.())},B=l.renderEditCell,D=v!=null,$=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&p&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${v}`,D&&f&&`ogx__cell--pinned-${v}-${v==="left"?"last":"first"}`,y&&"ogx__cell--editing",P&&P>1&&"ogx__cell--spanned",F].filter(Boolean).join(" "),R=P||1,U={...oe,position:D?"sticky":void 0,zIndex:l.zIndex??(D?3:void 0),padding:y?0:void 0};return R>1&&(U.height=`calc(var(--height) * ${R} - var(--border-width, 1px))`,U.zIndex=10,D&&(U.zIndex=40)),D&&h!==void 0&&(v==="left"?U.left=h:U.right=h),s.jsx("div",{className:$,style:U,onClick:se,onDoubleClick:re,role:"gridcell","aria-colindex":u??d+1,"aria-readonly":!b||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":d,...Z>1?{"aria-colspan":Z}:{},...R>1?{"aria-rowspan":R}:{},children:s.jsx("div",{className:"ogx__cell-content",children:y&&(n||T)&&N?B?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>B({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J})}):s.jsx(Td,{value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J}):A!==void 0?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>{throw A}}):l.renderCell?s.jsx(it,{field:l.field,resetKey:te,renderFn:()=>l.renderCell({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})}):l.type==="image"&&typeof r=="string"&&r!==""?s.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):I})})}const xi=a.memo(Fd),Ld=({className:e="",...t})=>s.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:s.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 Od(e){const{rowId:t,content:o,height:n,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,d=a.useRef(null),u=n==="auto";if(a.useLayoutEffect(()=>{const m=d.current;if(!m||!u||!r||!i)return;const x=()=>{m.getClientRects().length!==0&&i(t,m.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(x);return v.observe(m),()=>v.disconnect()},[u,r,i,t]),!r)return null;const g={height:u?"auto":`${n}px`,overflow:u?"visible":"auto"};return s.jsx("div",{ref:d,className:"ogx__detail-panel",style:g,role:"row",id:l,children:s.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:o})})}const wn=12;function Dd(e,t,o,n){let r=0,i=0,l=0;for(let c=t;c<e.length&&l<o;c++){const d=e[c];if(d.isSpacer)break;r+=ot(d,n),i+=d.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function mo(e){const{row:t,rowId:o,columns:n,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:c,onRowDoubleClick:d,onCellClick:u,onSelectionChange:g,columnWidths:m={},pinnedColumns:x,pinnedRows:v,hasDetailPanel:h=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:w,detailPanelContent:p,detailPanelHeight:b=Vo,onDetailPanelHeightChange:y,pinCheckboxColumn:C=!0,pinExpandColumn:N=!0,rowReordering:T=!1,onDragStart:E,onDragOver:P,onDragEnd:O,onDrop:W,isDragging:X,isDragOver:S,editingCell:M,onEditStart:I,onEditStop:_,onEditCellValueChange:F,isCellEditable:A,focusedCellField:q,isFocusVisible:K,colspanMap:J,rowSpanningCaches:te,rowHeight:ne=52,rowMeta:Z,columnIndexMap:de,ariaRowIndex:ae}=e,oe=o??t.id,se=a.useId(),re=a.useId(),B=a.useMemo(()=>Go(n,m,x,l,C,h,N,T),[n,m,x,l,C,h,N,T]),D=a.useMemo(()=>Wo(n,x),[n,x]),$=Z?.hasChildren===!0,R=Z?.isGroupRow===!0,U=h&&!R,G=!R&&!qe(oe),V=a.useCallback((le,ye)=>{I?.({id:oe,field:le,value:ye})},[oe,I]),Y=a.useCallback((le,ye)=>{F?.({id:oe,field:le,value:ye})},[F,oe]),H=a.useCallback((le,ye)=>{_?.({cancel:le,id:oe,field:ye})},[_,oe]);if(t._isSkeleton){const le=Math.max(n.length,5);return s.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ne,minHeight:ne},children:Array.from({length:le}).map((ye,Te)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-bar"})},Te))})}const j=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:oe,rowIndex:r})},z=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:oe,rowIndex:r})},k=le=>{le.stopPropagation(),g?.(oe,le.target.checked)},L=le=>{le.stopPropagation(),w?.(oe)},Q=T?1:0,ee=h?Q+1:Q,ce=l?ee+1:ee,ue=ce,he=de?.size??n.filter(le=>!le.isSpacer).length,be=Z!==void 0,Ce=Z?.hasChildren===!0,fe=zn(oe,v),me=fe==="top",ve=fe==="bottom",Se=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",me&&"ogx__row--pinned-top",ve&&"ogx__row--pinned-bottom",X&&"ogx__row--dragging",S&&"ogx__row--drag-over",$&&"ogx__row--group",Z?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Se,onClick:j,onDoubleClick:d?z:void 0,role:"row","aria-rowindex":ae??r+2,"aria-selected":i,"aria-level":be?(Z?.treeDepth??0)+1:void 0,"aria-expanded":Ce?Z?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:P?P(oe):void 0,onDrop:W?W(oe):void 0,style:{maxHeight:`${ne}px`,minHeight:`${ne}px`,"--height":`${ne}px`,"--border-width":"1px"},children:[T&&s.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${q==="__reorder_col__"?"ogx__cell--focused":""} ${q==="__reorder_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":E?"Drag to reorder row":void 0,"aria-colindex":Q,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:wn},draggable:!!E,onDragStart:E?E(oe):void 0,onDragEnd:O,onClick:le=>le.stopPropagation(),children:E&&s.jsx(Ld,{})}),h&&s.jsx("div",{className:`ogx__cell ogx__cell--expand ${N?"ogx__cell--pinned-left":""} ${q==="__expand_col__"?"ogx__cell--focused":""} ${q==="__expand_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":U?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":U?f:void 0,"aria-controls":U&&f?re:void 0,"aria-colindex":ee,"data-field":"__expand_col__",style:{position:N?"sticky":void 0,left:N?T?48:0:void 0,zIndex:N?wn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:U&&s.jsx(an,{isExpanded:f,onClick:L,variant:"plus-minus",tabIndex:-1})}),l&&s.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${C?"ogx__cell--pinned-left":""} ${q==="__checkbox_col__"?"ogx__cell--focused":""} ${q==="__checkbox_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ce,"data-field":"__checkbox_col__",style:{position:C?"sticky":void 0,left:C?(T?48:0)+(h&&N?48:0):void 0,zIndex:C?wn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:G&&s.jsx(Gt,{id:se,name:`ogx-select-row-${oe}`,checked:i,onChange:k,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${oe}`:`Select row ${oe}`,tabIndex:-1,onMouseDown:le=>le.preventDefault()})}),n.map((le,ye)=>{if(le.isSpacer)return s.jsx("div",{style:{width:le.width,minWidth:le.width,flexShrink:0},"aria-hidden":"true"},le.field);let Te,xe;R?Te=t[le.field]:{value:Te,error:xe}=Un(t,le.field,le);const Ee=de?.get(le.field)??ye,ie=m[le.field]??le.width,ge=Xe(le.field,x),we=!!I&&Jn({row:t,field:le.field,value:Te,colDef:le,rowIndex:r,colIndex:Ee,rowMeta:Z},A),Me=M?.id===oe&&M?.field===le.field,Pe=Me?M?.value:Te,De=J?.get(oe)?.[le.field],Qe=De&&!De.spannedByColSpan&&De.cellProps.colSpan>1?Dd(n,Ee,De.cellProps.colSpan,m):De,qt=Qe&&!Qe.spannedByColSpan?n[Ee+Qe.cellProps.colSpan-1]?.field??le.field:le.field,_o=ge==="right"?qt:le.field,$e=ge?B[_o]:void 0,So=ge==="left"&&qt===D.lastLeft||ge==="right"&&le.field===D.firstRight,Be=te?.spannedCells[oe]?.[le.field],ko=te?.hiddenCells[oe]?.[le.field]||!1;return s.jsx(xi,{value:Pe,row:t,colDef:le,rowIndex:r,colIndex:Ee,ariaColIndex:ue+Ee+1,isSelected:i,onCellClick:u,width:ie,pinnedPosition:ge,pinnedOffset:$e,isPinnedEdge:So,isFocused:q===le.field,isFocusVisible:K,isEditable:we,isEditing:Me,onCellEditStart:V,onEditStop:H,onCellValueChange:Y,colSpanInfo:Qe,rowSpan:Be,isHiddenByRowSpan:ko,rowMeta:Z,valueError:xe},le.field)})]}),U&&s.jsx(Od,{id:re,colSpan:ue+he,row:t,rowId:oe,rowIndex:r,content:p,height:b,isExpanded:f,onHeightChange:y})]})}function bi({getContent:e,params:t}){return s.jsx(it,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Ad=e=>e.id;function vi({rows:e,position:t,columns:o,selectedRowIds:n,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,expandedRowIds:v,getDetailPanelContent:h,getDetailPanelHeight:f,onDetailPanelToggle:w,onDetailPanelHeightChange:p,pinCheckboxColumn:b,pinExpandColumn:y,focusedCell:C,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMetaMap:P,getRowId:O=Ad,rowIndexOffset:W=0,ariaRowIndexBase:X,columnIndexMap:S,editingHandlers:M,isCellEditable:I,rowReordering:_=!1}){return e.length===0?null:s.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((F,A)=>{const q=O(F),K=W+A;return s.jsx(mo,{row:F,rowId:q,columns:o,rowIndex:K,ariaRowIndex:X!==void 0?X+A:void 0,columnIndexMap:S,isSelected:n.has(q),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,isDetailPanelExpanded:v.has(q),detailPanelContent:v.has(q)&&h?s.jsx(bi,{getContent:h,params:{row:F,id:q,rowIndex:K}}):null,detailPanelHeight:v.has(q)?zo(Ko(f,{row:F,id:q,rowIndex:K})):void 0,onDetailPanelHeightChange:p,onDetailPanelToggle:w,pinCheckboxColumn:b,pinExpandColumn:y,focusedCellField:C?.id===q?C.field:null,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMeta:P.get(q),editingCell:M?.editingCell,onEditStart:M?.startCellEdit,onEditStop:M?.stopCellEdit,onEditCellValueChange:M?.setEditCellValue,isCellEditable:I,rowReordering:_},q)})})}const $d=({columns:e,rowHeight:t,checkboxSelection:o=!1,hasDetailPanel:n=!1,rowReordering:r=!1})=>s.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[o&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,d=Math.min(c*.7,c-20);return s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:c,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&&s.jsx("div",{className:"ogx-skeleton-box",style:{width:d,height:16,borderRadius:4}})},i.field||l)})]});function Gd({virtualContainerHeight:e,offsetTop:t,effectiveLoading:o,visibleRows:n,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:c,hasDetailPanel:d,rowReordering:u,rowHeight:g,selectedRowIds:m,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,expandedRowIds:b,getDetailPanelContent:y,getDetailPanelHeight:C,onDetailPanelToggle:N,onDetailPanelHeightChange:T,pinCheckboxColumn:E,pinExpandColumn:P,rowReorderHandlers:O,editingHandlers:W,isCellEditable:X,focusedCell:S,colspanMap:M,rowSpanningCaches:I,paginationMode:_,dataSourceLoading:F,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:q,unpinnedRowsLength:K,lastRenderedRowIndex:J,rowMetaMap:te,loadingOverlay:ne,ariaRowIndexOffset:Z,columnIndexMap:de}){const ae=r.length>0?r:(()=>{const re=(l||1e3)-(c?48:0)-(d?48:0)-(u?48:0),B=150,D=Math.max(1,Math.ceil(re/B));return Array.from({length:D},($,R)=>({field:`placeholder_${R}`,headerName:"",width:B}))})(),oe=n.filter(re=>!re.pinned),se=_==="infinite"&&F&&A>0&&J>=K-1;return s.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:s.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[o&&n.length===0&&ne?s.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ne}):o&&n.length===0?Array.from({length:10}).map((re,B)=>s.jsx($d,{columns:ae,rowHeight:g,checkboxSelection:c,hasDetailPanel:d,rowReordering:u},`skeleton-${B}`)):oe.map(({row:re,id:B,rowIndex:D})=>s.jsx(mo,{row:re,rowId:B,columns:i,rowIndex:D,ariaRowIndex:Z!==void 0?D+Z:void 0,columnIndexMap:de,isSelected:m.has(B),checkboxSelection:c,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,hasDetailPanel:d,isDetailPanelExpanded:b.has(B),detailPanelContent:b.has(B)&&y?s.jsx(bi,{getContent:y,params:{row:re,id:B,rowIndex:D}}):null,detailPanelHeight:b.has(B)?zo(Ko(C,{row:re,id:B,rowIndex:D})):void 0,onDetailPanelHeightChange:T,onDetailPanelToggle:N,pinCheckboxColumn:E,pinExpandColumn:P,rowReordering:u,onDragStart:O.canReorderRow(B)?O.onDragStart:void 0,onDragOver:O.onDragOver,onDragEnd:O.onDragEnd,onDrop:O.onDrop,isDragging:O.draggedRowId===B,isDragOver:O.dragOverRowId===B,editingCell:W.editingCell,onEditStart:W.startCellEdit,onEditStop:W.stopCellEdit,onEditCellValueChange:W.setEditCellValue,isCellEditable:X,focusedCellField:S!=null&&S.id===B?S.field:null,colspanMap:M,rowSpanningCaches:I,rowHeight:g,rowMeta:te.get(B)},B)),se&&s.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:q}).map((re,B)=>s.jsx(mo,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:i,rowIndex:K+B,rowHeight:g},`__skeleton_${B}__`))})]})})}function Wd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hd(){return s.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[s.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function mn(e){const{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:d}=e,[u,g]=a.useState(""),m=a.useId(),[x,v]=a.useState(null),h=a.useRef(null),f=a.useMemo(()=>t.filter(P=>P.hideable!==!1),[t]),w=f.every(P=>o.has(P.field)),p=a.useMemo(()=>{const P=d?t:f;if(!u)return P;const O=u.toLowerCase();return P.filter(W=>(W.headerName||W.field).toLowerCase().includes(O))},[t,f,u,d]),b=P=>{P.target.checked?r():i()},y=P=>O=>{h.current=P,O.dataTransfer.effectAllowed="move",O.dataTransfer.setDragImage(O.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},C=P=>O=>{O.preventDefault(),O.dataTransfer.dropEffect="move",P!==h.current&&v(P)},N=()=>{v(null)},T=P=>O=>{O.preventDefault();const W=h.current;v(null),h.current=null,W&&W!==P&&l&&l(W,P)},E=()=>{v(null),h.current=null};return s.jsxs("div",{className:"ogx-column-visibility-panel",children:[s.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:s.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[s.jsx(Wd,{}),s.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:P=>g(P.target.value)})]})}),s.jsx("div",{className:"ogx-column-visibility-panel__list",children:p.map((P,O)=>{const W=`${m}-col-${O}`,X=o.has(P.field),S=P.hideable!==!1,M=x===P.field,I=!!l&&!u;return s.jsxs("div",{className:["ogx-column-visibility-panel__item",!S&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:I,onDragOver:I?C(P.field):void 0,onDragLeave:I?N:void 0,onDrop:I?T(P.field):void 0,onDragEnd:I?E:void 0,children:[I&&s.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(P.field),title:"Drag to reorder",children:s.jsx(Hd,{})}),s.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:S?"pointer":"not-allowed"},children:[s.jsx(Gt,{id:W,checked:X,onChange:_=>n(P.field,_.target.checked),disabled:!S}),s.jsx("label",{htmlFor:W,className:"ogx-column-visibility-panel__label",children:P.headerName||P.field})]})]},P.field)})}),s.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[s.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[s.jsx(Gt,{id:`${m}-all`,checked:w,onChange:b}),s.jsx("label",{htmlFor:`${m}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),s.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:"Reset"})]})]})}function Bd({isOpen:e,containerRef:t,panelRef:o,columns:n,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:d,onColumnOrderReset:u,columnGroupingModel:g}){const[m,x]=a.useState(null);if(a.useLayoutEffect(()=>{if(!e||!t.current)return;const h=t.current.getBoundingClientRect();x({top:h.top+8,right:xt()-h.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!m)return null;const v=i?void 0:(h,f)=>{un(g,h,f)&&d(h,f)};return tt.createPortal(s.jsxs("div",{ref:o,style:{position:"fixed",top:m.top,right:m.right,zIndex:9999,display:"inline-block"},children:[s.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:"×"}),s.jsx(mn,{columns:n,visibleColumns:new Set(n.filter(h=>r[h.field]!==!1).map(h=>h.field)),onVisibilityChange:(h,f)=>{c({...r,[h]:f})},onShowAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!0)}),c(h)},onHideAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!1)}),c(h)},onColumnReorder:v,onColumnOrderReset:i?void 0:u})]}),m.target)}const yi=[];function Vd(e){const{isPivotActive:t}=e,o=t?yi:e.rowGroupingModel,n=e.treeData&&!t,r=n&&e.hasTreeDataPath,i=o.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:o,isTreeDataRequested:n,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 zd(e){const{baseColumns:t,pinnedColumns:o,hasGroupingColumn:n,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=a.useMemo(()=>n?{...o,left:["__group__",...(o?.left??[]).filter(u=>u!=="__group__")]}:o,[n,o]);return{activeColumns:a.useMemo(()=>n?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:u})=>{const g=l(u);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,n,i,l,t]),effectivePinnedColumns:c}}function Kd(e){return e.id}function jd(e){const t=a.useCallback(r=>e.get(r)??r.id,[e]),o=a.useRef(t);a.useLayoutEffect(()=>{o.current=t});const n=a.useCallback(r=>o.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:n}}function Ud(e,t){a.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Xd(e){const{hierarchyHandlers:t,pinnedTopRows:o,sortedUnpinnedRows:n,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:c,dataRows:d}=e,u=t?.getVisibleRows({expandAll:!0,labelField:c});if(!u)return[...o,...n,...r];const g=d?new Set(d):null;return u.filter(m=>!i.get(l(m))?.isGroupRow&&(!g||g.has(m)))}function qd(e,t){if(e===t)return!0;const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;const n=e,r=t;return o.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(n[i],r[i]))}function Yd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>qd(o,t[n]))}function Rd(e){const[t,o]=a.useState(e),n=Yd(t,e);return n||o(e),n?t:e}function Jd(e){const{rows:t,getRowId:o,rowMetaMap:n,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:c}=e,d=Object.keys(i).length>0,u=new Map(r.map(v=>[v.field,v])),g=[],m=[],x=v=>{for(;m.length>0&&m[m.length-1].header.depth>=v;){const h=m.pop();d&&!c?.(h.id)&&g.push({type:"group-subtotal",depth:h.header.depth,groupField:h.header.groupField,groupValue:h.header.groupValue,groupLabel:h.header.groupLabel,aggregatedValues:so(h.leaves,i,u,"getGroupedExportRows")})}};for(const v of t){const h=o(v),f=n.get(h);if(!f?.isGroupFooter)if(f?.isGroupRow){const w=f.treeDepth??0;x(w);const p={type:"group-header",depth:w,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(p),m.push({id:h,header:p,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??m.length,row:v}),m.forEach(w=>w.leaves.push(v))}return x(0),d&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Qd(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=()=>o.current;t.current.getAggregationResult=()=>n().hasAggregation?n().aggregationResult:null,t.current.getAggregationModel=()=>n().hasAggregation?n().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:c,rowGroupingHandlers:d,rowMetaMap:u,columns:g,getRowId:m,hierarchyField:x}=n();return c?Jd({rows:d.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:m,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&d.rootAggregationPosition!==null?i:null,isSubtotalHidden:v=>d.aggregationPositions.get(v)===null}):null}},[t])}const Zd=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!rt(t.field)&&!Zd.has(t.field))}function Re(e){return!!e&&e.length>0}function Ci(e,t,o=n=>n.id){const n=new Set(t);return e.filter(r=>n.has(o(r)))}function Vt(e,t,o){return Re(t)?Ci(e,t,o):e}function zt(e,t){return!!e&&e.length>0&&!Re(t)}function _t(e,t,o,n,r){if(!n)return null;if(!t||!r||Object.keys(r).length===0)return n;const i=new Map(o.map(l=>[l.field,l]));return so(e,r,i,"export")}function Kt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function xo(e,t,o){if(!t.valueFormatter)return Bo(o,t);if(o==null)try{return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}function xn(e,t,o,n){return o==null?"":ao(o,t??"",e,n)}function St(e,t){return t?`${e}: ${t}`:e}function _i(e,t){const o={};return t.forEach(n=>{Object.prototype.hasOwnProperty.call(e,n.field)&&(o[n.field]=e[n.field])}),o}const ec=/^[=+\-@\t\r]/,tc=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function bo(e,t=!1){return t||!ec.test(e)||tc.test(e)?e:`'${e}`}function Je(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function _e(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const oc=/[\\/?*:[\]]/g,Si=31;function bn(e,t=new Set){let o=String(e??"").replace(oc,"-").trim().replace(/^'+|'+$/g,"").trim();o||(o="Sheet"),o=o.slice(0,Si).trim();const n=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=o;for(let i=2;n(r);i++){const l=` (${i})`;r=`${o.slice(0,Si-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const nc=new Set([Ye,At,Dt]),rc=/[\t\n\r"]/;function ki(e){return rc.test(e)?`"${e.replace(/"/g,'""')}"`:e}function ic(e){return st(e).filter(t=>!nc.has(t.field))}function lc(e,t){const o=t.map(r=>ki(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>ki(xo(r,i,Le(r,i.field,i)))).join(" "));return[o,...n].join(`
|
|
4
|
-
`)}function Ei(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,o=document.getSelection(),n=[];if(o)for(let l=0;l<o.rangeCount;l++)n.push(o.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}),o&&(o.removeAllRanges(),n.forEach(l=>o.addRange(l)))}return i}async function sc(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(o){if(Ei(e))return;throw o}if(!Ei(e))throw new Error("Clipboard API not available and fallback failed.")}function ac(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 dc(e){const t=a.useRef(e);a.useLayoutEffect(()=>{t.current=e});const o=a.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:c}=t.current,d=new Set(r());if(d.size===0)return;const u=l().filter(m=>d.has(c(m)));if(u.length===0)return;const g=lc(u,ic(i()));await sc(g)},[]),n=!!e.disableKeyboardShortcut;return a.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!ac(i))return;const l=document.activeElement,c=l?.tagName.toLowerCase(),d=l?.type;if(c==="input"&&d!=="checkbox"&&d!=="radio"||c==="textarea"||c==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const m=u();if(!m||!l||!m.contains(l))return}const g=window.getSelection();g&&!g.isCollapsed&&g.toString()!==""||o().catch(m=>{console.error("[OpenGridX] Failed to copy to clipboard:",m)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[o,n]),{copySelectedRows:o}}function cc(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=a.useCallback(()=>r.current,[r]),{copySelectedRows:c}=dc({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>o,getRows:()=>t.current.getAllFilteredRows(),getRowId:n,getRootElement:l,disableKeyboardShortcut:i});a.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function uc(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:n,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:c}=o.current,d=i.current;if(d&&(n!==void 0&&n>=0&&Rn(d,n,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;Dl(d,l.unpinnedColsWithWidth.findIndex(m=>m.field===g.field),l)}}},[t])}function fc(e){return a.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function gc(e){const{ensureGridFocus:t,setKeyboardMode:o,setFocusedCell:n,getRowId:r,onCellClick:i}=e,l=a.useCallback(d=>{t(),o(!1),n({id:r(d.row),field:d.field,rowIndex:d.rowIndex}),i?.(d)},[i,o,n,t,r]),c=a.useCallback(d=>{t(),n({id:null,field:d}),o(!1)},[t,n,o]);return{handleCellClick:l,handleHeaderClick:c}}function pc({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const d=e||gn;return s.jsx(d,{page:o,pageSize:n.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...n,page:u}),onPageSizeChange:u=>l({...n,pageSize:u,page:0}),localeText:Nr(c),...t})}function hc({loading:e,error:t,noRowsLabel:o,filteredRowCount:n,dataRowCount:r,filterModel:i}){return s.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${Kr(t)}`:"",!e&&!t&&(n===0?o:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:"")]})}function wc(e){const{headerRowCount:t,pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+o+i+n,topBase:t+1,centerOffset:t+l+1,bottomBase:t+o+i+1,bottomRowIndexOffset:o+r}}function mc(e){const{columnGroupingModel:t,pinnedTopCount:o,pinnedBottomCount:n,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:c,paginatedUnpinnedRowCount:d,sortedUnpinnedRowCount:u}=e,{page:g,pageSize:m}=l;return a.useMemo(()=>wc({headerRowCount:1+jr(t),pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r?d:u,totalCenterRowCount:r&&i==="server"?Math.max(c,d):u,pageOffset:r?g*m:0}),[t,o,n,r,d,u,i,c,g,m])}function xc(e){const{toolbar:t,toolbarSlotProps:o,apiRef:n,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,pivotMode:d,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:m,onPivotModelChange:x,filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,disableColumnReorder:p,columnGroupingModel:b,moveColumn:y,resetColumnOrder:C,forceColumnsOpen:N,onColumnsPanelClose:T}=e;return a.useMemo(()=>t?{apiRef:n,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,...d||u||g?{pivotModel:m,onPivotModelChange:x}:{},filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,onColumnReorder:p?void 0:(P,O)=>{un(b,P,O)&&y(P,O)},onColumnOrderReset:p?void 0:C,forceColumnsOpen:N,onColumnsPanelClose:T,...o}:null,[t,p,y,C,r,n,i,l,c,d,u,g,m,x,v,h,f,w,N,T,o,b])}function bc(e){const{rows:t,columns:o,getRowId:n,rowHeight:r,headerHeight:i,autoHeight:l=!1,density:c,checkboxSelection:d=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:g=!1,disableClipboardCopy:m=!1,rowSelectionModel:x,onRowSelectionModelChange:v,onRowClick:h,onRowDoubleClick:f,onCellClick:w,filterModel:p,onFilterModelChange:b,sortModel:y,onSortModelChange:C,pagination:N=!1,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P=[10,25,50,100],pinnedColumns:O,onPinnedColumnsChange:W,pinnedRows:X,getDetailPanelContent:S,getDetailPanelHeight:M,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,pinCheckboxColumn:F=!0,pinExpandColumn:A=!0,disableColumnReorder:q=!1,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,height:ne,rowReordering:Z=!1,onRowOrderChange:de,loading:ae=!1,treeData:oe=!1,getTreeDataPath:se,defaultGroupingExpansionDepth:re,groupingColDef:B,rowGroupingModel:D,aggregationModel:$,onAggregationModelChange:R,getAggregationPosition:U,isCellEditable:G,processRowUpdate:V,onProcessRowUpdateError:Y,dataSource:H,multiSort:j=!1,sortingMode:z="client",filterMode:k="client",paginationMode:L="client",rowCount:Q,slots:ee,slotProps:ce,pivotMode:ue=!1,pivotModel:he,onPivotModelChange:be,className:Ce="",style:fe,onRowsScrollEnd:me,ariaLabel:ve,initialState:Se,onStateChange:le,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,listView:xe=!1,listViewColumn:Ee,columnGroupingModel:ie,noRowsLabel:ge="No Data",localeText:we,apiRef:Me,overscanRowCount:Pe=3}=e,De=Rd(o),Qe=we?.noRowsLabel??ge,qt=D||yi,_o=ws({initialState:Se,sortModel:y,onSortModelChange:C,filterModel:p,onFilterModelChange:b,aggregationModel:$,onAggregationModelChange:R,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,pinnedColumns:O,onPinnedColumnsChange:W,pivotModel:he,onPivotModelChange:be,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P,rowSelectionModel:x,onRowSelectionModelChange:v,density:c}),{sortModel:$e,handleSortModelChange:So,filterModel:Be,handleFilterModelChange:ko,aggregationModel:Ge,handleAggregationModelChange:Lu,columnVisibilityModel:at,handleColumnVisibilityModelChange:Cn,pinnedColumns:_n,handlePinnedColumnsChange:Ou,currentPivotModel:Zi,handlePivotModelChange:Du,effectivePaginationModel:Ae,handlePaginationModelChange:Nt,selectedRowIds:Au,handleRowSelectionModelChange:Sn,density:el}=_o,Yt=wd({rows:t,columns:De,pivotMode:ue,pivotModel:Zi,filterModel:Be,sortModel:$e,hasDataSource:!!H,hierarchyRequested:oe||qt.length>0}),dt=Yt.isActive,{rowReordering:ct,hierarchyRowGroupingModel:$u,isTreeDataRequested:Gu,isTreeData:Eo,isRowGrouping:Pt,isHierarchyEnabled:Mo,hasGroupingColumn:Wu,pagination:Ve,listView:No}=Vd({rowGroupingModel:qt,treeData:oe,hasTreeDataPath:!!se,isPivotActive:dt,rowReordering:Z,hasGroupingColDef:!!B,pagination:N,paginationMode:L,listView:xe,hasListViewColumn:!!Ee}),{rowHeight:Ze,headerHeight:tl}=ys({rowHeight:r,headerHeight:i,density:el}),Hu=Yt.rows,Bu=Yt.columns,{activeColumns:ut,effectivePinnedColumns:Rt}=zd({baseColumns:Bu,pinnedColumns:_n,hasGroupingColumn:Wu,groupingColDef:B,isTreeData:Eo,getTreeDataPath:se}),kn=oa(ut,at),[Vu,zu]=gd(Ge),Jt=a.useRef(null),En=a.useRef(null),ol=!dt&&n||Kd,Mn=fc(Jt),Nn=La({rows:Hu,getRowId:ol,columns:ut,rowHeight:Ze,headerHeight:tl,columnVisibilityModel:at,initialState:e.initialState,syncRows:!H}),{state:ke,apiRef:Qt,setRows:Ku,replaceRow:ju,setColumns:Uu,setDimensions:Xu,setDataSourceLoading:qu,setDataSourceError:Yu,setRowCount:Ru}=Nn,{getRowIdOf:Ne,getRowIdOfInEvents:Ju}=jd(ke.rows.idByRow);Ud(Me,Qt);const Qu=ke.dataSource.loading,et=ae||Qu,Po=a.useMemo(()=>ke.rows.allRows.map(pt=>ke.rows.idRowsLookup.get(pt)),[ke.rows]),{treeDataHandlers:Io,rowGroupingHandlers:Pn,activeHierarchyHandlers:It,rowMetaMap:ze}=Ra({rows:Po,getRowId:Ne,getTreeDataPath:se,isTreeDataRequested:Gu,isTreeData:Eo,columns:ut,rowGroupingModel:$u,isRowGrouping:Pt,aggregationModel:Ge,defaultGroupingExpansionDepth:re,filterModel:Be,sortModel:$e,getAggregationPosition:U,columnLookup:kn,filterMode:k,sortingMode:z}),nl=Qa({rows:Po,getRowId:Ne,columns:ut,processRowUpdate:V,onProcessRowUpdateError:Y,onRowChange:(pt,Nf)=>{ju(Nf,pt)}}),Zt=Qs({selectedRowIds:Au,rowsLookup:ke.rows.idRowsLookup,rowMetaMap:ze,enabled:!H&&!dt&&L==="client"&&k==="client",onSelectionModelChange:Sn}),rl=cd({dataSource:H,sortModel:$e,filterModel:Be,paginationModel:Ae,paginationMode:L,sortingMode:z,filterMode:k,aggregationModel:Ge,rowGroupingActive:Pt,getRowId:ol,setRows:Ku,setRowCount:Ru,setDataSourceLoading:qu,setDataSourceError:Yu,onAggregationResults:zu,onPaginationModelChange:Nt});fd({enabled:Eo&&!!H,treeNodes:Io.treeNodes,isGroupExpanded:Io.isGroupExpanded,getNodePath:Io.getNodePath,toggleExpansion:Io.toggleExpansion,fetchChildren:rl.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:In,handleDetailPanelToggle:il,detailPanelHeights:Zu,reportDetailPanelHeight:ef}=Hs({hasDetailPanel:!!S,controlledExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,rowMetaMap:ze}),{effectiveColumns:ll,hierarchyField:Tn,orderedColumns:sl,visibleOrderedColumns:al,renderOrderedColumns:tf,navigationColumns:dl,columnIndexMap:cl,columnWidths:eo,effectiveColumnOrder:of,columnReorderHandlers:nf,moveColumn:ul,resetColumnOrder:fl,handleColumnResize:rf}=Ts({activeColumns:ut,isHierarchyEnabled:Mo,isRowGrouping:Pt,isTreeData:Eo,activeHierarchyHandlers:It,columnVisibilityModel:at,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,disableColumnReorder:q,pivotMode:dt,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,initialState:Se,setColumns:Uu,pinnedColumns:Rt,getRowId:Ju,aggregationModel:Ge,groupingRows:Pt?Pn.groupingRows:void 0});zs({onStateChange:le,sortModel:$e,filterModel:Be,effectivePaginationModel:Ae,columnWidths:eo,effectiveColumnOrder:of,columnVisibilityModel:at,pinnedColumns:_n,density:el});const To=_s({effectiveRows:Po,activeHierarchyHandlers:It,filterMode:k,filterModel:Yt.pipelineFilterModel,sortModel:Yt.pipelineSortModel,sortingMode:z,pagination:Ve,paginationMode:L,effectivePaginationModel:Ae,pinnedRows:X,getRowId:Ne,columnLookup:kn,hierarchyField:Tn}),{filteredRows:gl,dataRows:Tt,pinnedTopRows:We,pinnedBottomRows:Ke,sortedUnpinnedRows:Ue,paginatedUnpinnedRows:Fo,allRenderableRows:Fn}=To,Ln=Ve?Fo:Ue;na({paginationModel:Ae,currentPage:To.currentPage,enabled:Ve&&!et&&Ue.length>0,onPaginationModelChange:Nt});const Lo=Cs({paginationMode:L,hasDataSource:!!H,dataSourceRowCount:ke.pagination.rowCount,rowCountProp:Q,clientRowCount:Ue.length}),{rowSelection:On,handleRowClick:Dn,handleSelectionChange:An}=Js({dataRows:Tt,getRowId:Ne,isPivotActive:dt,selectedRowIds:Zt,onSelectionModelChange:Sn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:Mo,rowMetaMap:ze,activeHierarchyHandlers:It,onRowClick:h});ta({apiRef:Nn.apiRef,sortModel:$e,multiSort:j,onSortModelChange:So,filterModel:Be,onFilterModelChange:ko,paginationModel:Ae,onPaginationModelChange:Nt,selectedRowIds:Zt,getPendingRowSelectionModel:_o.getPendingRowSelectionModel,onRowSelectionModelChange:Sn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>qe(pt,ze),getVisibleRows:()=>[...We,...Ln,...Ke],getAllFilteredRows:()=>Xd({hierarchyHandlers:It,pinnedTopRows:We,sortedUnpinnedRows:Ue,pinnedBottomRows:Ke,rowMetaMap:ze,getRowId:Ne,hierarchyField:Tn,dataRows:Tt}),visibleColumns:tf});const lf=Oa({rows:Po,getRowId:Ne,onRowOrderChange:de,rowReordering:ct}),{aggregationResult:$n,isLoading:sf}=hi({rows:Tt,columns:ut,aggregationModel:dt?Al:Ge,isServerSide:Vr({dataSource:H,paginationMode:L,sortingMode:z,filterMode:k}),dataSource:H,filterModel:Be,sortModel:$e,serverAggregationResults:Vu}),Gn=Object.keys(Ge).length>0&&!dt;Qd({apiRef:Qt,hasAggregation:Gn,aggregationResult:$n,aggregationModel:Ge,isRowGrouping:Pt,rowGroupingHandlers:Pn,rowMetaMap:ze,columns:ut,getRowId:Ne,hierarchyField:Tn});const Ie=Ll({rowHeight:Ze,pagination:Ve,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,expandedRowIds:In,getDetailPanelHeight:M,detailPanelHeights:Zu,pinnedTopRowsLength:We.length,pinnedBottomRowsLength:Ke.length,pinnedTopRows:We,pinnedBottomRows:Ke,visibleOrderedColumns:al,pinnedColumns:Rt,columnWidths:eo,viewportWidth:ke.dimensions.viewportWidth||1e3,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:F,pinExpandColumn:A,paginationMode:L,isLoading:ke.dataSource.loading,pageSize:Ae.pageSize,getRowId:Ne}),to=nd({pinnedTopRows:We,centerRows:Ln,pinnedBottomRows:Ke,columns:al,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?In:void 0,rowMetaMap:ze,getRowId:Ne}),pl=a.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);cc({apiRef:Qt,columns:pl,getRowId:Ne,containerRef:Jt,disableKeyboardShortcut:m}),uc({apiRef:Qt,viewportRef:En,layout:Ie,rowHeight:Ze});const{scrollTop:af,scrollLeft:df,overscanRows:cf,handleScroll:uf,setViewportElement:ff}=Gs({onRowsScrollEnd:me,overscanRowCount:Pe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:Xu,viewportRef:En}),Fe=Ss({layout:Ie,scrollTop:af,scrollLeft:df,viewportWidth:ke.dimensions.viewportWidth,viewportHeight:ke.dimensions.viewportHeight,autoHeight:l,rowReordering:ct,hasDetailPanel:ft,checkboxSelection:d,pinCheckboxColumn:F,pinExpandColumn:A,overscanRows:cf}),{handleSort:hl,handleSortAdd:wl}=Zs({sortModel:$e,onSortModelChange:So}),Oo=d||!u,{focusedCell:ml,setFocusedCell:gf,viewportTabIndex:pf,ensureGridFocus:hf,handleFocus:wf,handleBlur:mf,handleKeyDown:xf,handleMouseDownCapture:bf}=gs({allRenderableRows:Fn,navigationColumns:dl,checkboxSelection:d,selectedRowIds:Zt,handleSelectionChange:An,handleDetailPanelToggle:il,editingHandlers:nl,setKeyboardMode:Mn,sortModel:$e,handleSort:hl,handleSortAdd:wl,multiSort:j,isCellEditable:G,pagination:Ve,pageSize:Ae.pageSize,virtualization:Fe,viewportRef:En,pinnedTopRowCount:We.length,getRowId:Ne,rowMetaMap:ze,getSpanOrigin:to.getSpanOrigin,onRowActivate:Dn,toggleRowExpansion:It?.toggleExpansion,handleSelectAll:On.selectAll,rowSelectionEnabled:Oo,multipleRowSelectionEnabled:!g,pinCheckboxColumn:F,pinExpandColumn:A,rowHeight:Ze}),{handleCellClick:vf,handleHeaderClick:yf}=gc({ensureGridFocus:hf,setKeyboardMode:Mn,setFocusedCell:gf,getRowId:Ne,onCellClick:w}),{handleHideColumn:Cf,handlePinColumn:_f}=ea({columnVisibilityModel:at,onColumnVisibilityModelChange:Cn,pinnedColumns:_n,onPinnedColumnsChange:Ou}),oo=mc({columnGroupingModel:ie,pinnedTopCount:We.length,pinnedBottomCount:Ke.length,pagination:Ve,paginationMode:L,paginationModel:Ae,paginationRowCount:Lo,paginatedUnpinnedRowCount:Fo.length,sortedUnpinnedRowCount:Ue.length}),Wn=id({spanning:to,renderContext:Fe.renderContext,offsetTop:Fe.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Hn=Ls({renderContext:Wn.renderContext,pinnedTopRows:We,pinnedBottomRows:Ke,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,pagination:Ve,getRowId:Ne}),Do=ld({spanning:to,firstColumnIndex:Fe.renderContext.firstColumnIndex,lastColumnIndex:Fe.renderContext.lastColumnIndex,virtualColumns:Fe.virtualColumns,layout:Ie,rows:Hn});Us({paginationRequested:N,isRowGrouping:Pt,autoHeight:l,viewportHeight:ke.dimensions.viewportHeight,renderedRowCount:Hn.length,totalRowCount:We.length+Ln.length+Ke.length,pinnedRowsIgnored:Mo&&!!(X?.top?.length||X?.bottom?.length),scrollHeight:Fe.totalHeight,listViewWithoutColumn:xe&&!Ee});const{allSelected:Sf,someSelected:kf}=On,Ft=sd(ie,nf),Ef=a.useMemo(()=>ll.some(pt=>!!pt.rowSpan),[ll]),gt=ra();qs(Jt);const xl=ee?.noRowsOverlay,bl=ee?.loadingOverlay,Bn=bl?s.jsx(bl,{...ce?.loadingOverlay}):void 0,vl=xl?s.jsx(xl,{...ce?.noRowsOverlay}):void 0,Ao=ee?.footer,Mf=et&&Fn.length>0&&L!=="infinite",yl=ee?.toolbar,Cl=xc({toolbar:ee?.toolbar,toolbarSlotProps:ce?.toolbar,apiRef:Qt,orderedColumns:sl,baseColumns:De,aggregationModel:Ge,onAggregationModelChange:Lu,pivotMode:ue,pivotModelProp:he,onPivotModelChangeProp:be,pivotModel:Zi,onPivotModelChange:Du,filterModel:Be,onFilterModelChange:ko,columnVisibilityModel:at,onColumnVisibilityModelChange:Cn,disableColumnReorder:q,columnGroupingModel:ie,moveColumn:ul,resetColumnOrder:fl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),Vn={rowReordering:ct,columnIndexMap:cl,editingHandlers:nl,isCellEditable:G,selectedRowIds:Zt,checkboxSelection:d,onRowClick:Dn,onRowDoubleClick:f,onCellClick:vf,onSelectionChange:An,columnWidths:eo,pinnedColumns:Rt,hasDetailPanel:ft,expandedRowIds:In,getDetailPanelContent:S,getDetailPanelHeight:M,onDetailPanelToggle:il,onDetailPanelHeightChange:ef,pinCheckboxColumn:F,pinExpandColumn:A,focusedCell:ml,colspanMap:to.colspanMap,rowSpanningCaches:to.rowSpanningCaches,rowHeight:Ze,rowMetaMap:ze};return s.jsxs("div",{ref:Jt,className:["ogx",Ce,l&&"ogx--auto-height",Ef&&"ogx--row-spanning",No&&"ogx--list-view"].filter(Boolean).join(" "),style:{...fe,height:ne??fe?.height,"--ogx-row-height":`${Ze}px`,"--ogx-header-height":`${tl}px`},"aria-busy":et,children:[yl&&Cl&&s.jsx(Hr.Provider,{value:gt.toolbarHost,children:s.jsx(sa,{component:yl,toolbarProps:Cl})}),s.jsx(Bd,{isOpen:gt.standalonePanelOpen,containerRef:Jt,panelRef:gt.standalonePanelRef,columns:sl,columnVisibilityModel:at,disableColumnReorder:q,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:Cn,onColumnMove:ul,onColumnOrderReset:fl,columnGroupingModel:ie}),No&&Ee&&s.jsx(vd,{ariaLabel:ve,allRenderableRows:Fn,dataRowCount:Tt.length,pinnedTopRowCount:We.length,pinnedBottomRowCount:Ke.length,unpinnedRowCount:Ue.length,pagination:Ve,effectivePaginationModel:Ae,currentPage:To.currentPage,pageSizeOptions:P,selectedRowIds:Zt,listViewColumn:Ee,columnsByField:kn.byField,rowMetaMap:ze,noRowsLabel:Qe,rowHeight:Ze,checkboxSelection:d,paginationMode:L,serverRowCount:Lo,paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,localeText:Nr(we),onRowClick:Dn,onRowDoubleClick:f,onSelectionChange:An,onPaginationModelChange:Nt,onRowsScrollEnd:me,getRowId:Ne,multiselectable:Oo&&!g,selectable:Oo,onToggleExpansion:It?.toggleExpansion,loading:et,loadingOverlay:Bn,noRowsOverlay:vl,showPaginationControls:!Ao}),!No&&s.jsx("div",{ref:ff,className:"ogx__viewport",onScroll:uf,role:"grid","aria-label":ve||"Data grid","aria-rowcount":oo.rowCount,"aria-colcount":dl.length,"aria-multiselectable":Oo&&!g,"aria-busy":et,tabIndex:pf,onKeyDownCapture:()=>{Mn(!0)},onMouseDownCapture:bf,onKeyDown:xf,onFocus:wf,onBlur:mf,children:s.jsxs("div",{className:"ogx__content",style:{width:Fe.totalWidth},role:"presentation",children:[s.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[s.jsx(qr,{columns:Do,allColumns:pl,columnGroupingModel:ie,checkboxSelection:d,allSelected:Sf,someSelected:kf,onSelectAll:On.selectAll,sortModel:$e,onSort:hl,onSortAdd:wl,multiSort:j,onColumnResize:rf,columnWidths:eo,pinnedColumns:Rt,focusedCell:ml,columnIndexMap:cl,onHeaderClick:yf,onDragStart:Ft.onDragStart,onDragOver:Ft.onDragOver,onDragEnd:Ft.onDragEnd,onDrop:Ft.onDrop,draggedColumn:Ft.draggedColumn,dragOverColumn:Ft.dragOverColumn,rowReordering:ct,hasDetailPanel:ft,pinCheckboxColumn:F,pinExpandColumn:A,aggregationModel:Ge,onHideColumn:Cf,onManageColumns:gt.openColumnsPanel,onPinColumn:_f}),s.jsx(vi,{...Vn,rows:We,position:"top",ariaRowIndexBase:oo.topBase,columns:Do,pinnedRows:X,getRowId:Ne})]}),!et&&!ke.dataSource.error&&gl.length===0&&s.jsx(da,{noRowsLabel:Qe,width:Fe.totalWidth,overlay:vl}),s.jsx(Gd,{...Vn,virtualContainerHeight:Fe.totalHeight-Fe.pinnedTopHeight-Fe.pinnedBottomHeight,offsetTop:Wn.offsetTop,effectiveLoading:et,visibleRows:Hn,baseColumns:De,virtualColumns:Do,viewportWidth:ke.dimensions.viewportWidth,rowReorderHandlers:lf,paginationMode:L,dataSourceLoading:ke.dataSource.loading,sortedUnpinnedRowCount:Ue.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:Wn.renderContext.lastRowIndex,ariaRowIndexOffset:oo.centerOffset,loadingOverlay:Bn}),s.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[s.jsx(vi,{...Vn,rows:Ke,position:"bottom",rowIndexOffset:oo.bottomRowIndexOffset,ariaRowIndexBase:oo.bottomBase,columns:Do,pinnedRows:X,getRowId:Ne}),Gn&&Pn.rootAggregationPosition!==null&&s.jsx(aa,{columns:Fe.virtualColumns,aggregationModel:Ge,aggregationResult:$n,columnWidths:eo,rowHeight:Ze,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:F,pinExpandColumn:A,pinnedColumns:Rt,loading:sf})]})]})}),Ao&&s.jsx(Ao,{apiRef:Nn.apiRef,aggregationModel:Ge,aggregationResult:Gn?$n:null,rowCount:Mo&&L!=="server"?Tt.length:Lo,pagination:Ve,paginationModel:Ae,pageSizeOptions:P,onPaginationModelChange:Nt,...ce?.footer}),!No&&!Ao&&Ve&&s.jsx(pc,{paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,page:To.currentPage,paginationModel:Ae,rowCount:Lo,pageSizeOptions:P,onPaginationModelChange:Nt,localeText:we}),s.jsx(hc,{loading:et,error:ke.dataSource.error,noRowsLabel:Qe,filteredRowCount:gl.length,dataRowCount:Tt.length,filterModel:Be}),Mf&&s.jsx(yd,{overlay:Bn}),s.jsx(ua,{error:ke.dataSource.error,onRetry:H?rl.fetchRows:void 0})]})}function vc({rows:e=5,columns:t=5}){return s.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((o,n)=>s.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-content"})},i))},n))})}const yc=300;function kt(e){return"field"in e&&!("items"in e)}function Mi(e,t){return e.find(o=>kt(o)&&o.field===t)}function Ni(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((o,n)=>Ni(o,t[n])):!1}function Cc(e,t){return e===t?!0:kt(e)&&kt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Ni(e.value,t.value):!kt(e)&&!kt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&vn(e.items,t.items):!1}function vn(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>Cc(o,t[n]))}function _c(e){return(e.valueOptions??[]).map((t,o)=>t!==null&&typeof t=="object"?{key:String(o),value:t.value,label:t.label}:{key:String(o),value:t,label:String(t)})}function Pi(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Ii(e,t){return e==null?"":t.type==="date"||e instanceof Date?Xn(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(o=>String(o)).join(", "):String(e)}function Ti(e,t){return t==="isAnyOf"?e.split(",").map(o=>o.trim()).filter(o=>o!==""):e}function Sc(e,t){if(!qo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const kc=({col:e,item:t,resetToken:o,onChange:n})=>{const r=a.useId(),i=jl(e.type),l=i[0],c=t?.operator??l,d=i.includes(c)?i:[c,...i],u=!!t,g=e.headerName||e.field,[m,x]=a.useState(null),[v,h]=a.useState(o);v!==o&&(h(o),x(null));const f=a.useRef(n),w=a.useRef(t),p=a.useRef(e);a.useLayoutEffect(()=>{f.current=n,w.current=t,p.current=e});const b=a.useCallback((M,I)=>({id:w.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:M,value:I}),[e.field]),y=a.useCallback(M=>{const I=w.current;if(I?M===Ii(I.value,p.current):M.trim()==="")return;const F=I?.operator??l;f.current(b(F,Ti(M,F)))},[l,b]),C=a.useRef(null),N=a.useRef(y);a.useLayoutEffect(()=>{C.current=m,N.current=y}),a.useEffect(()=>()=>{const M=C.current;C.current=null,M!==null&&N.current(M)},[]),a.useEffect(()=>{if(m===null)return;const M=setTimeout(()=>{C.current=null,y(m),x(null)},yc);return()=>clearTimeout(M)},[m,y]);const T=M=>{const I=m!==null?Ti(m,M):t?.value;x(null),n(b(M,Sc(I,M)))},E=()=>{x(null),n(null)},P=!qo.has(c),O=_c(e),W=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,X=`Filter value for ${g}`;let S=null;if(P&&e.type==="boolean")S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:M=>{M.target.value===""?n(null):n(b(c,M.target.value))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]});else if(P&&e.type==="singleSelect"&&O.length>0&&c==="isAnyOf"){const M=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];S=s.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(O.length,4),value:O.filter(I=>M.some(_=>Pi(I,_))).map(I=>I.key),onChange:I=>{const _=new Set(Array.from(I.target.selectedOptions,F=>F.value));n(b("isAnyOf",O.filter(F=>_.has(F.key)).map(F=>F.value)))},"aria-label":X,children:O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))})}else if(P&&e.type==="singleSelect"&&O.length>0&&(c==="is"||c==="not")){const M=O.find(I=>Pi(I,t?.value));S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:M?.key??"",onChange:I=>{const _=O.find(F=>F.key===I.target.value);n(b(c,_?_.value:""))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))]})}else P&&(S=s.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:W,type:e.type==="date"?"date":"text",value:m??Ii(t?.value,e),onChange:M=>x(M.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":X}));return s.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[s.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),s.jsxs("div",{className:"ogx-filter__controls",children:[s.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:c,onChange:M=>T(M.target.value),"aria-label":`Filter operator for ${g}`,children:d.map(M=>s.jsx("option",{value:M,children:M},M))}),S,u&&s.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},Fi=({filterModel:e,columns:t,onFilterModelChange:o})=>{const n=a.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=a.useState(null),[c,d]=a.useState(n),[u,g]=a.useState(0);if(c!==n){d(n);const w=!vn(c,n),p=i!==null&&vn(i,n);w&&!p&&g(b=>b+1)}const m=a.useCallback((w,p)=>{const b=n.findIndex(C=>kt(C)&&C.field===w);let y;if(b===-1){if(!p)return;y=[...n,p]}else p?y=n.map((C,N)=>N===b?p:C):y=n.filter((C,N)=>N!==b);l(y),o({...e,items:y})},[n,e,o]),x=a.useCallback(w=>{o({...e,logicOperator:w})},[e,o]),v=t.filter(w=>w.filterable!==!1),h=v.filter(w=>Mi(n,w.field)).length,f=n.length-h;return s.jsxs(s.Fragment,{children:[n.length>1&&s.jsxs("div",{className:"ogx-filter__logic-bar",children:[s.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),s.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)"}),s.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)"})]}),f>0&&s.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:f===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${f} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),v.length===0?s.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):v.map(w=>s.jsx(kc,{col:w,item:Mi(n,w.field),resetToken:u,onChange:p=>m(w.field,p)},w.field))]})},Li=["sum","avg","count","min","max"];function Oi(){return s.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:[s.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),s.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Ec({anchorRef:e,columns:t,model:o,onChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),[d,u]=a.useState(null);a.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const _=e.current.getBoundingClientRect();return{top:_.bottom+6,right:xt()-_.right}},[e]);a.useEffect(()=>{c(g());const _=()=>c(g());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[g]),a.useEffect(()=>{function _(A){i.current&&!i.current.contains(A.target)&&e.current&&!e.current.contains(A.target)&&r()}function F(A){A.key==="Escape"&&r()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",F)}},[e,r]);const m=new Set(o.rowFields),x=new Set(o.columnFields),v=new Set(o.valueFields.map(_=>_.field)),h=_=>m.has(_)||x.has(_)||v.has(_),f=_=>t.find(F=>F.field===_),w=_=>f(_)?.headerName??_,p=_=>{const F=f(_)?.availableAggregationFunctions;return F?Li.filter(A=>F.includes(A)):Li},b=_=>_.aggregable!==!1&&(_.type==="number"||_.aggregable===!0)&&p(_.field).length>0,y=_=>_.groupable!==!1;function C(_){m.has(_)||n({...o,rowFields:[...o.rowFields,_]})}function N(_){x.has(_)||n({...o,columnFields:[...o.columnFields,_]})}function T(_){v.has(_)||n({...o,valueFields:[...o.valueFields,{field:_,aggFn:p(_)[0]??"sum"}]})}function E(_){n({...o,rowFields:o.rowFields.filter((F,A)=>A!==_)})}function P(_){n({...o,columnFields:o.columnFields.filter((F,A)=>A!==_)})}function O(_){n({...o,valueFields:o.valueFields.filter((F,A)=>A!==_)})}function W(_,F){n({...o,valueFields:o.valueFields.map((A,q)=>q===_?{...A,aggFn:F}:A)})}function X(){n({rowFields:[],columnFields:[],valueFields:[]})}const S=o.rowFields.length+o.columnFields.length+o.valueFields.length,M=t.filter(_=>!h(_.field)&&(y(_)||b(_))),I=s.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[s.jsxs("div",{className:"ogx-pivot-panel__header",children:[s.jsxs("span",{className:"ogx-pivot-panel__title",children:[s.jsx(Oi,{}),"Pivot Mode"]}),S>0&&s.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:X,title:"Reset pivot",children:"Reset"})]}),s.jsxs("div",{className:"ogx-pivot-panel__body",children:[s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:o.rowFields.map((_,F)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(F),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Row Fields`,children:"×"})]},`${F}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:o.columnFields.map((_,F)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(F),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Column Fields`,children:"×"})]},`${F}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),s.jsx("div",{className:`ogx-pivot-chips${o.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:o.valueFields.map((_,F)=>{const A=p(_.field),q=A.includes(_.aggFn)?A:[_.aggFn,...A];return s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[w(_.field),s.jsx("select",{className:"ogx-pivot-chip__fn-select",value:_.aggFn,onChange:K=>W(F,K.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${w(_.field)}`,children:q.map(K=>s.jsx("option",{value:K,children:K.toUpperCase()},K))}),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>O(F),title:`Remove ${w(_.field)}`,"aria-label":`Remove ${w(_.field)} (${_.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${F}:${_.field}:${_.aggFn}`)})})]}),s.jsx("hr",{className:"ogx-pivot-panel__divider"}),s.jsxs("div",{children:[s.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),s.jsxs("div",{className:"ogx-pivot-fields",children:[M.map(_=>{const F=b(_),A=y(_),q=_.headerName??_.field;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[s.jsx("span",{className:`ogx-pivot-field-btn${F?" ogx-pivot-field-btn--numeric":""}`,children:q}),s.jsxs("div",{className:"ogx-pivot-field-actions",children:[A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(_.field),title:"Add to Row Fields","aria-label":`Add ${q} to Row Fields`,children:"Row"}),A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>N(_.field),title:"Add to Column Fields","aria-label":`Add ${q} to Column Fields`,children:"Col"}),F&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>T(_.field),title:"Add to Value Fields","aria-label":`Add ${q} to Value Fields`,children:"Val"})]})]},_.field)}),M.length===0&&s.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return d?tt.createPortal(I,d):null}function Mc(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Nc(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Di(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Pc({value:e="",onChange:t,placeholder:o="Search...",debounceMs:n=250}){const[r,i]=a.useState(()=>e.length>0),[l,c]=a.useState(e),d=a.useRef(null),u=a.useRef(null),g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t},[t]);const m=a.useRef(e),x=a.useRef(e);a.useEffect(()=>{e!==x.current&&(x.current=e,Di(e)!==Di(m.current)&&(c(e),m.current=e,i(e.length>0)))},[e]),a.useEffect(()=>{const b=setTimeout(()=>{l!==m.current&&(m.current=l,g.current(l))},n);return()=>clearTimeout(b)},[l,n]);const v=a.useRef(l);a.useLayoutEffect(()=>{v.current=l}),a.useEffect(()=>()=>{const b=v.current;b!==m.current&&(m.current=b,g.current(b))},[]);const h=a.useCallback(()=>{i(!0),requestAnimationFrame(()=>d.current?.focus())},[]),f=a.useCallback(b=>{b.stopPropagation(),c(""),m.current="",g.current(""),d.current?.focus()},[]),w=a.useCallback(()=>{i(!0)},[]),p=a.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return a.useEffect(()=>{const b=y=>{u.current&&!u.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),s.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:h,children:[s.jsx("div",{className:"ogx-global-search__icon-wrapper",children:s.jsx(Mc,{})}),s.jsx("input",{ref:d,className:"ogx-global-search__input",value:l,onChange:b=>c(b.target.value),onFocus:w,onBlur:p,placeholder:o,"aria-label":"Global Search",autoComplete:"off"}),l&&s.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:s.jsx(Nc,{})})]})}const vo=8;function jt({title:e,children:t,placement:o="top",enterDelay:n=200,leaveDelay:r=0}){const[i,l]=a.useState(!1),[c,d]=a.useState({top:0,left:0}),[u,g]=a.useState(null),m=a.useRef(null),x=a.useRef(null),v=a.useId(),h=a.useCallback(()=>{if(!x.current)return;const N=x.current.getBoundingClientRect(),T=N.left+N.width/2,E=N.top+N.height/2;switch(o){case"bottom":d({top:N.bottom+vo,left:T});break;case"left":d({top:E,left:N.left-vo});break;case"right":d({top:E,left:N.right+vo});break;default:d({top:N.top-vo,left:T})}},[o]),f=a.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null},[]);a.useLayoutEffect(()=>{if(!i)return;h();const N=T=>{T.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),document.addEventListener("keydown",N),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),document.removeEventListener("keydown",N)}},[i,h,f]),a.useEffect(()=>f,[f]);const w=()=>{f(),m.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},n)},p=()=>{f(),m.current=setTimeout(()=>{l(!1)},r)},b=a.useCallback(N=>{x.current=N?N.firstElementChild??N:null},[]),y=i&&!!e&&u!==null;let C=t;if(y&&a.isValidElement(t)){const N=t,T=N.props["aria-describedby"];C=a.cloneElement(N,{"aria-describedby":T?`${T} ${v}`:v})}return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:b,style:{display:"inline-block",lineHeight:0},onMouseEnter:w,onMouseLeave:p,onFocus:w,onBlur:p,children:C}),y&&u&&tt.createPortal(s.jsx("div",{id:v,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${o}`,style:{top:c.top,left:c.left,position:"fixed",zIndex:99999},children:e}),u)]})}const Ic=Object.keys(lo);function Tc(e){return Object.prototype.hasOwnProperty.call(lo,e)}function Ai(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Tc))):Ic}function $i(){return s.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:s.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Fc(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Gi(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Lc({anchorRef:e,aggregationModel:t,aggregableColumns:o,onFunctionChange:n,onClearAll:r,onClose:i,activeCount:l}){const c=a.useRef(null),[d,u]=a.useState({top:0,right:0}),[g,m]=a.useState(null);a.useLayoutEffect(()=>{m(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const h=e.current.getBoundingClientRect();return{top:h.bottom+6,right:xt()-h.right}},[e]);a.useEffect(()=>{u(x());const h=()=>u(x());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[x]),a.useEffect(()=>{function h(f){c.current&&!c.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[e,i]),a.useEffect(()=>{function h(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i]);const v=s.jsxs("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:d.top,right:d.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx($i,{}),"Summaries"]}),l>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),s.jsx("div",{className:"ogx-toolbar__panel-body",children:o.length===0?s.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",s.jsx("br",{}),"Set ",s.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):o.map(h=>{const f=t[h.field]||"none";return s.jsxs("div",{className:"ogx-toolbar__agg-row",children:[s.jsx("span",{className:"ogx-toolbar__agg-label",title:h.field,children:h.headerName||h.field}),s.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Ai(h)].map(w=>s.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===w?" ogx-toolbar__pill--active":""}`,onClick:()=>n(h.field,w),"aria-pressed":f===w,children:w},w))})]},h.field)})})]});return g?tt.createPortal(v,g):null}function Oc({anchorRef:e,columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:d,showNonHideableColumns:u}){const g=a.useRef(null),[m,x]=a.useState({top:0,right:0}),[v,h]=a.useState(null);a.useLayoutEffect(()=>{h(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:xt()-p.right}},[e]);a.useEffect(()=>{x(f());const p=()=>x(f());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[f]),a.useEffect(()=>{function p(b){g.current&&!g.current.contains(b.target)&&e.current&&!e.current.contains(b.target)&&d()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,d]),a.useEffect(()=>{function p(b){b.key==="Escape"&&d()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[d]);const w=s.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:m.top,right:m.right,width:280,padding:0},children:s.jsx(mn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return v?tt.createPortal(w,v):null}function Dc({anchorRef:e,columns:t,filterModel:o,onFilterModelChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),d=a.useRef(r);a.useLayoutEffect(()=>{d.current=r},[r]);const[u,g]=a.useState(null);a.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const m=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const f=e.current.getBoundingClientRect();return{top:f.bottom+6,right:xt()-f.right}},[e]);a.useEffect(()=>{c(m());const f=()=>c(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),a.useEffect(()=>{function f(w){w.key==="Escape"&&d.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=o.items?.length??0,v=()=>{n({...o,items:[],logicOperator:"and"})},h=s.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:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx(Gi,{}),"Filters",x>0&&s.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:v,title:"Clear all filters",children:"Clear all"}),s.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>d.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),s.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:s.jsx(Fi,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?tt.createPortal(h,u):null}const Ac={rowFields:[],columnFields:[],valueFields:[]};function $c({columns:e=[],baseColumns:t,aggregationModel:o={},onAggregationModelChange:n,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:c,columnVisibilityModel:d={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:m,forceColumnsOpen:x,onColumnsPanelClose:v,children:h,rightContent:f,style:w,renderColumnsButton:p,renderFilterButton:b,renderAggregationButton:y,renderExportButton:C,renderQuickFilter:N,className:T,showNonHideableColumns:E}){const[P,O]=a.useState(null),W=P==="summaries",X=P==="pivot",S=P==="columns",M=P==="filters",I=k=>{P==="columns"&&k!=="columns"&&v?.(),O(k)},_=k=>I(P===k?null:k),F=k=>{P===k&&I(null)};a.useEffect(()=>{x&&O("columns")},[x]);const A=a.useContext(Hr),q=x!==void 0&&!!u;a.useEffect(()=>{if(!(!A||!q))return A.registerColumnsPanel()},[A,q]);const K=a.useRef(null),J=a.useRef(null),te=a.useRef(null),ne=a.useRef(null),Z=a.useRef(null),de=a.useRef(null),ae=a.useRef(null),oe=r??Ac,se=oe.rowFields.length>0||oe.columnFields.length>0||oe.valueFields.length>0,re=t?new Set(t.map(k=>k.field)):null,B=e.filter(k=>k.aggregable!==!1&&(k.type==="number"||k.aggregable===!0)&&Ai(k).length>0&&(!re||re.has(k.field))),D=Object.keys(o).filter(k=>o[k]&&o[k]!=="none").length,$=a.useCallback((k,L)=>{if(!n)return;const Q={...o};L==="none"?delete Q[k]:Q[k]=L,n(Q)},[o,n]),R=a.useCallback(()=>{n?.({})},[n]),U=a.useCallback(k=>{if(!c)return;const L=k.trim().split(/\s+/).filter(Boolean),Q={...l||{},quickFilterValues:L,items:l?.items||[]};c(Q)},[l,c]),G=(l?.quickFilterValues??[]).join(" "),V=l?.items?.length||0,Y=new Set(e.filter(k=>d[k.field]!==!1).map(k=>k.field)),H=a.useCallback((k,L)=>{if(!u)return;const Q={...d,[k]:L};u(Q)},[d,u]),j=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(L=>{L.hideable!==!1&&(k[L.field]=!0)}),u(k)},[e,d,u]),z=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(L=>{L.hideable!==!1&&(k[L.field]=!1)}),u(k)},[e,d,u]);return s.jsxs("div",{className:["ogx-toolbar",T].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:w,children:[h&&s.jsx("div",{className:"ogx-toolbar__left",children:h}),s.jsx("div",{className:"ogx-toolbar__spacer"}),s.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&s.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:G,onChange:U}):s.jsx(Pc,{value:G,onChange:U,placeholder:"Search..."})}),u&&s.jsxs("div",{ref:Z,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[p?p({onClick:()=>_("columns"),isOpen:S,activeCount:e.length-Y.size}):s.jsx(jt,{title:"Columns",children:s.jsx("button",{type:"button",ref:te,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>_("columns"),children:s.jsx(Fc,{})})}),S&&s.jsx(Oc,{anchorRef:p?Z:te,columns:e,visibleColumns:Y,onVisibilityChange:H,onShowAll:j,onHideAll:z,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>F("columns"),showNonHideableColumns:E})]}),c&&s.jsxs("div",{ref:de,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>_("filters"),isOpen:M,activeCount:V}):s.jsx(jt,{title:"Filters",children:s.jsxs("button",{type:"button",ref:ne,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":M,onClick:()=>_("filters"),children:[s.jsx(Gi,{}),V>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),M&&s.jsx(Dc,{anchorRef:b?de:ne,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>F("filters")})]}),i&&s.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[s.jsx(jt,{title:"Pivot",children:s.jsxs("button",{type:"button",ref:J,className:`ogx-toolbar__icon-btn${X?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":X,onClick:()=>_("pivot"),children:[s.jsx(Oi,{}),se&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),X&&s.jsx(Ec,{anchorRef:J,columns:t??e,model:oe,onChange:k=>{i?.(k)},onClose:()=>F("pivot")})]}),n&&s.jsxs("div",{ref:ae,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>_("summaries"),isOpen:W,activeCount:D}):s.jsx(jt,{title:"Summaries",children:s.jsxs("button",{type:"button",ref:K,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":W,onClick:()=>_("summaries"),children:[s.jsx($i,{}),D>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),W&&s.jsx(Lc,{anchorRef:y?ae:K,aggregationModel:o,aggregableColumns:B,onFunctionChange:$,onClearAll:R,onClose:()=>F("summaries"),activeCount:D})]}),C&&C(),f]})]})}function Gc(){const[e]=a.useState(Yr);return a.useRef(e)}const Wc=({fullWidth:e=!1,error:t=!1,startAdornment:o,endAdornment:n,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 s.jsxs("div",{className:l,children:[o&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),s.jsx("input",{className:"ogx-input",...i}),n&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:n})]})};function Et(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const o=e.groupField??"",n=t.find(r=>r.field===o)?.groupingValueFormatter;return n?n({field:o,value:e.groupValue}):`${o}: ${String(e.groupValue??"")}`}const Hc=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 Bc(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 Vc(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Hc.has(r)){t+=n;continue}const i=Bc(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const zc=[79,70,229],Kc=[255,255,255];function Wi(e,t){const o=e.trim().replace(/^#/,""),n=/^[a-f\d]{3}$/i.test(o)?o.split("").map(i=>i+i).join(""):o,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Hi(e,t){return xo(e,t,Kt(e,t))}function Bi(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function jc(e,t){const o=e.reduce((r,i)=>r+Bi(i),0),n={};return e.forEach((r,i)=>{n[i]={cellWidth:Bi(r)/o*t}}),n}const Uc=new Set(["isEmpty","isNotEmpty"]);function Xc(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(Uc.has(e.operator))return`${n} ${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`${n} ${e.operator} "${i}"`}function Vi(e,t,o,n){const r=e.map(l=>"items"in l?Vi(l.items,l.logicOperator,o,!0):Xc(l,o)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return n&&r.length>1?`(${i})`:i}function qc(e,t){const o=[],n=Vi(e.items??[],e.logicOperator??"and",t,!1);n&&o.push(n);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&o.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),o.join(" • ")}const Yc=1.15*.3528;async function Rc(e,t,o={}){let n,r;try{const[D,$]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);n=D.default,r=$.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:i="export",title:l,logoUrl:c,orientation:d="landscape",selectedRows:u,getRowId:g,aggregationResult:m,aggregationModel:x,filterModel:v,alternateRowColor:h=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:w="#ffffff",fontSize:p=9,groupedRows:b,font:y}=o,C=new n({orientation:d,unit:"mm",format:"a4"}),N=C.internal.pageSize.getWidth(),T=C.internal.pageSize.getHeight(),E=14,P=N-E*2;let O="helvetica";y&&(C.addFileToVFS(`${y.name}-normal.ttf`,y.data),C.addFont(`${y.name}-normal.ttf`,y.name,"normal"),y.boldData&&C.addFileToVFS(`${y.name}-bold.ttf`,y.boldData),C.addFont(y.boldData?`${y.name}-bold.ttf`:`${y.name}-normal.ttf`,y.name,"bold"),O=y.name);let W=!1;const X=D=>{if(y)return D;const $=Vc(D);return $.lossy&&(W=!0),$.text},S=(D,$,R,U,G)=>{const V=C.splitTextToSize(X(D),U);return C.text(V.length===1?V[0]:V,$,R),Math.max(0,V.length-1)*G*Yc},M=st(t),I=zt(b,u),_=Vt(e,u,g);let F=E;if(l){let D=E,$=E+8;if(c)try{C.addImage(c,"PNG",D,E,10,10),D+=14}catch{}const R=N-E-D;C.setFontSize(16),C.setFont(O,"bold"),C.setTextColor(30,41,59),$+=S(l,D,$,R,16),$+=6,C.setFontSize(8),C.setFont(O,"normal"),C.setTextColor(100,116,139);const U=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),G=I?b.filter(V=>V.type==="leaf").length:_.length;if(C.text(X(`Exported: ${U} • ${G} row${G!==1?"s":""}`),D,$),$+=5,v){const V=qc(v,t);V&&($+=S(`Filters: ${V}`,D,$,R,8),$+=5)}C.setDrawColor(226,232,240),C.setLineWidth(.3),C.line(E,$+2,N-E,$+2),F=$+6}const A=[M.map(D=>X(D.headerName??D.field))],q=x||{},K=D=>M.map($=>xn($,q[$.field],D[$.field],D));let J,te;if(I)J=[],b.forEach(D=>{const $=" ".repeat(D.depth*2);if(D.type==="group-header"){const R=`${$}${Et(D,t)}`;J.push(M.map((U,G)=>G===0?R:""))}else if(D.type==="leaf"&&D.row){const R=D.row;J.push(M.map((U,G)=>(G===0?$:"")+Hi(R,U)))}else if(D.type==="group-subtotal"&&D.aggregatedValues){const R=K(D.aggregatedValues);J.push(R.map((U,G)=>G===0?`${$}${St("Subtotal",U)}`:U))}else D.type==="grand-total"&&D.aggregatedValues&&(te=[K(D.aggregatedValues).map((U,G)=>G===0?St("Grand Total",U):U)])});else{J=_.map($=>M.map(R=>Hi($,R)));const D=x?_t(_,Re(u),t,m,x):null;if(D&&x){const $=M.some(U=>x[U.field]);te=[K(D).map((U,G)=>G===0&&$?St("TOTAL",U):U)]}}J=J.map(D=>D.map(X)),te&&(te=te.map(D=>D.map(X))),W&&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 ne=jc(M,P),[Z,de,ae]=Wi(f,zc),[oe,se,re]=Wi(w,Kc);r(C,{head:A,body:J,...te?{foot:te}:{},startY:F,styles:{fontSize:p,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[Z,de,ae],textColor:[oe,se,re],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...te?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:ne,showFoot:te?"lastPage":"never",showHead:"everyPage",margin:{top:E,left:E,right:E,bottom:E+6}});const B=C.getNumberOfPages();for(let D=1;D<=B;D++)C.setPage(D),C.setFontSize(8),C.setTextColor(150,150,150),C.text(`Page ${D} of ${B}`,N-E,T-8,{align:"right"});C.save(`${i}.pdf`)}function Ut(e,t){const o=Kt(e,t);return{text:xo(e,t,o),raw:o}}function Mt(e,t,o){return e.map(n=>xn(n,o[n.field],t[n.field],t))}const Jc="\uFEFF";function Qc(e,t,o={}){const{fileName:n="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:c,escapeFormulas:d=!0,bom:u=!0}=o,g=st(t),m=o.aggregationModel||{},x=(f,w=!1)=>yo(d?bo(f,w):f,i),v=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
|
|
5
|
-
`;let h="";if(
|
|
6
|
-
`}else if(f.type==="leaf"&&f.row){const p=f.row,b=g.map((y,C)=>{const N=
|
|
7
|
-
`}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.aggregatedValues,b=f.type==="grand-total"?"Grand Total":`${w}Subtotal`,y=Mt(g,p,m),C=g.map((N,T)=>T===0?
|
|
8
|
-
`}});else{const f=
|
|
3
|
+
`).forEach(J=>console.warn(J))},[y]);const C=r&&!n;a.useEffect(()=>{process.env.NODE_ENV==="production"||!C||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.")},[C]);const N=a.useMemo(()=>g==="server"?null:uo(l,u),[g,l,u]),T=a.useMemo(()=>Wa(v,N),[v,N]),E=`${r}|${i}`,[P,O]=a.useState(()=>({configKey:E,overrides:new Map})),W=P.configKey===E?P.overrides:Qr,X=a.useCallback(J=>((J?.children?.length??0)>0||(J?.serverChildrenCount??0)>0)&&(i===-1||(J?.depth??0)<i),[i]),S=a.useMemo(()=>{const J=new Set;return x&&h.forEach((te,oe)=>{(W.get(oe)??X(te))&&J.add(oe)}),J},[x,h,W,X]),M=a.useCallback(J=>{const te=!S.has(J);if(O(oe=>{const Z=oe.configKey===E?oe.overrides:Qr,de=new Map(Z);return de.set(J,te),{configKey:E,overrides:de}}),te&&d){const oe=h.get(J);oe&&d(oe)}},[S,E,h,d]),I=m!=="server"&&!!(c&&c.length>0),_=a.useCallback(J=>{if(!x)return null;const te=J?.labelField,oe=J?.expandAll??!1,{visible:Z,visibleChildren:de}=T,ae=I&&c?c:[],ne=(D,$)=>{if(p.has(D))return{value:$.field===te?h.get(D)?.label:void 0};const R=b.get(D),U=u?.byField.get($.field);return{value:R?Fe(R,$.field,U):void 0,type:U?.type}},se=[],re=new Set,B=D=>{const $=D.filter(U=>Z.has(U)),R=ae.length>0?en($,ae,ne):$;for(const U of R){if(re.has(U))continue;const G=b.get(U);if(!G)continue;re.add(U),se.push(G);const V=de.get(U);V&&V.length>0&&(oe||S.has(U))&&B(V)}};return B(f),se},[x,T,I,c,p,h,b,u,f,S]),L=a.useCallback(J=>S.has(J),[S]),A=a.useCallback(J=>h.get(J),[h]),q=a.useCallback(J=>{const te=[];let oe=J;for(;oe!==null;){const Z=h.get(oe);if(!Z)break;te.unshift(Z.groupingKey),oe=Z.parentId}return te},[h]),K=a.useMemo(()=>{const J=new Map,{visibleChildren:te,descendantCounts:oe}=T;return h.forEach((Z,de)=>{const ae=(Z.children?.length??0)===0&&(Z.serverChildrenCount??0)>0,ne=p.has(de),se={hasChildren:(te.get(de)?.length??0)>0||ae,treeDepth:Z.depth,descendantCount:ae?void 0:oe.get(de)??0,isGroupRow:ne,isExpanded:S.has(de)};ne&&(se.groupLabel=Z.label),J.set(de,se)}),J},[h,p,T,S]);return a.useMemo(()=>({treeNodes:h,groupingRows:w,toggleExpansion:M,isGroupExpanded:L,getVisibleRows:_,getNode:A,getNodePath:q,rowMetaMap:K}),[h,w,M,L,_,A,q,K])}const oi=e=>e===null?"footer":"inline";function ni(e,t){return ro(()=>e(t),oi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Ba(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?ro(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Va=[],za={},ri=new Map,He="";function Ka(e){if(typeof e=="string")return e;if(e===null)return`${He}null`;if(e===void 0)return`${He}undefined`;if(e instanceof Date)return`${He}date:${e.getTime()}`;if(typeof e=="object")try{return`${He}object:${JSON.stringify(e)}`}catch{return`${He}object:${String(e)}`}return`${He}${typeof e}:${String(e)}`}const ja=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,Ua=e=>`${e}${He}footer`,Xa=e=>e==="footer"?"f":e===null?"n":"i",qa=e=>e==="f"?"footer":e==="n"?null:"inline";function Ya(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Va,aggregationModel:i=za,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:d,getAggregationPosition:u=oi,columnLookup:g,filterMode:m="client",sortingMode:x="client"}=e,v=r.join(He),h=a.useMemo(()=>v===""?[]:v.split(He),[v]),f=JSON.stringify(Object.entries(i)),w=a.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),p=Object.keys(w).length>0,b=a.useMemo(()=>{const B=new Map;return(n??[]).forEach(D=>B.set(D.field,D)),B},[n]),y=h.length>0,C=a.useMemo(()=>h.filter(B=>b.get(B)?.groupable!==!1),[h,b]),T=`${C.join(He)}|${l}`,[E,P]=a.useState(()=>({configKey:T,overrides:new Map})),O=E.configKey===T?E.overrides:ri,W=a.useMemo(()=>{if(!y||m==="server")return null;const B=uo(c,g);return B?new Set(t.filter(D=>B(D))):null},[y,t,m,c,g]),X=a.useMemo(()=>{const B=new Map,D=[],$=[],R=new Map,U=new Map,G=new Map;if(!y)return{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G};const V=(Y,H,j)=>{if(H>=C.length)return(W?Y.filter(ce=>W.has(ce)):Y).map(ce=>{const fe=o(ce);return G.set(fe,ce),B.set(fe,{id:fe,parentId:j,depth:H,groupingKey:"",isExpanded:!1}),fe});const z=C[H],k=b.get(z),F=new Map;for(const ee of Y){const ce=Fe(ee,z,k),fe=Ka(ce);let ge=F.get(fe);ge||(ge={value:ce,rows:[]},F.set(fe,ge)),ge.rows.push(ee)}const Q=[];return F.forEach((ee,ce)=>{const fe=W?ee.rows.filter(Se=>W.has(Se)):ee.rows;if(fe.length===0)return;const ge=ja(z,ce,j);Q.push(ge),$.push(ge);const be=p?ao(fe,w,b,"useRowGrouping"):{},Ce={[z]:ee.value,...be,id:ge},ue={[z]:ee.value,id:ge},me=p?{...be,id:Ua(ge)}:null;R.set(ge,{inline:Ce,bare:ue,footer:me}),U.set(ge,Ce),me&&U.set(me.id,me);const ve={id:ge,parentId:j,depth:H,groupingKey:String(ee.value),groupingField:z,groupingValue:ee.value,aggregatedValues:be,isExpanded:!1,children:[],label:Ba(k,z,ee.value),descendantCount:fe.length};B.set(ge,ve),ve.children=V(ee.rows,H+1,ge)}),Q};return D.push(...V(t,0,null)),{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G}},[y,t,W,C,p,w,o,b]),{treeNodes:S,rootIds:M,groupIds:I,groupRowVariants:_,groupingRows:L,rowLookup:A}=X,q=a.useCallback(B=>!!(B?.children&&B.children.length>0)&&(l===-1||(B?.depth??0)<l),[l]),K=a.useMemo(()=>{const B=new Set;return S.forEach((D,$)=>{!D.children||D.children.length===0||(O.get($)??q(D))&&B.add($)}),B},[S,O,q]),J=a.useCallback(B=>{P(D=>{const $=D.configKey===T?D.overrides:ri,R=$.get(B)??q(S.get(B)),U=new Map($);return U.set(B,!R),{configKey:T,overrides:U}})},[T,S,q]),te=a.useCallback(B=>K.has(B),[K]),oe=p?I.map(B=>{const D=S.get(B);return D?Xa(ni(u,{...D,isExpanded:K.has(B)})):"i"}).join(""):"",Z=a.useMemo(()=>{const B=new Map;return I.forEach((D,$)=>B.set(D,qa(oe[$]))),B},[I,oe]),de=p?ni(u,null):"footer",ae=x!=="server"&&!!(d&&d.length>0),ne=a.useCallback(B=>{if(!y)return null;const D=B?.labelField,$=B?.expandAll??!1,R=ae&&d?d:[],U=(H,j)=>{const z=S.get(H);if(z&&_.has(H)){const Q=z.groupingField??"";return j.field===Q||j.field===D?{value:z.groupingValue,type:g?.byField.get(Q)?.type}:z.aggregatedValues&&Object.prototype.hasOwnProperty.call(z.aggregatedValues,j.field)?{value:z.aggregatedValues[j.field],type:g?.byField.get(j.field)?.type}:{value:void 0}}const k=A.get(H),F=g?.byField.get(j.field);return{value:k?Fe(k,j.field,F):void 0,type:F?.type}},G=[],V=new Set,Y=H=>{const j=R.length>0?en(H,R,U):H;for(const z of j){if(V.has(z))continue;V.add(z);const k=_.get(z);if(!k){const fe=A.get(z);fe&&G.push(fe);continue}const F=S.get(z),Q=K.has(z),ee=Z.has(z)?Z.get(z)??null:"inline",ce=ee==="inline"||ee==="footer"&&!Q;G.push(ce?k.inline:k.bare),(Q||$)&&F?.children&&(Y(F.children),Q&&!$&&ee==="footer"&&k.footer&&G.push(k.footer))}};return Y(M),G},[y,ae,d,S,_,A,g,K,Z,M]),se=a.useCallback(B=>S.get(B),[S]),re=a.useMemo(()=>{const B=new Map;return S.forEach((D,$)=>{const R=_.get($);if(!R){B.set($,{hasChildren:!1,treeDepth:D.depth,isGroupRow:!1});return}const U={hasChildren:!0,treeDepth:D.depth,groupingField:D.groupingField,groupingValue:D.groupingValue,groupLabel:D.label,descendantCount:D.descendantCount,isGroupRow:!0,isExpanded:K.has($)};B.set($,U),R.footer&&Z.get($)==="footer"&&B.set(R.footer.id,{...U,hasChildren:!1,treeDepth:D.depth+1,isExpanded:void 0,isGroupFooter:!0})}),B},[S,_,K,Z]);return a.useMemo(()=>({treeNodes:S,groupingRows:L,toggleExpansion:J,isGroupExpanded:te,getVisibleRows:ne,getNode:se,rowMetaMap:re,aggregationPositions:Z,rootAggregationPosition:de}),[S,L,J,te,ne,se,re,Z,de])}const Ra=new Map;function Ja(e){const{rows:t,getRowId:o,getTreeDataPath:n,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:c,isRowGrouping:d,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}=e,p=Ha({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,columnLookup:h,filterMode:f,sortingMode:w}),b=Ya({rows:t,getRowId:o,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}),y=i?p:d?b:null,C=a.useMemo(()=>i?p.rowMetaMap:d?b.rowMetaMap:Ra,[i,p.rowMetaMap,d,b.rowMetaMap]);return{treeDataHandlers:p,rowGroupingHandlers:b,activeHierarchyHandlers:y,rowMetaMap:C}}const yt=Promise.resolve();class ii extends Error{}function mo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Qa(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Za(e){const[t,o]=a.useState(null),n=a.useRef(null),r=a.useRef(0),i=a.useRef(new Map),l=a.useRef(new Set),c=a.useRef(!1),d=a.useRef(e);a.useLayoutEffect(()=>{d.current=e}),a.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=a.useCallback(h=>{n.current=h,o(h)},[]),g=a.useCallback((h,f)=>{const w=i.current.get(h);if(w)return mo(w.value,f.value)?w.promise:w.promise.then(()=>{const L=n.current;if(!(r.current!==h||!L||mo(L.value,w.value)))return g(h,L)});const p=()=>r.current===h&&n.current!==null;if(mo(f.value,f.originalValue))return p()&&u(null),yt;const{rows:b,getRowId:y,columns:C,processRowUpdate:N}=d.current,T=b.find(L=>y(L)===f.id);if(!T)return p()&&u(null),yt;const E=L=>{const A=d.current.onProcessRowUpdateError;A?A(L):process.env.NODE_ENV!=="production"&&L instanceof ii&&console.error(L.message)},P=L=>{if(typeof L!="object"||L===null){E(new ii(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${L===null?"null":typeof L}. The edit was not saved and the editor stays open.`));return}d.current.onRowChange?.(L,f.id);const A=n.current;r.current!==h||!A||(mo(A.value,f.value)?u(null):u({...A,originalValue:f.value}))};let O,W;const X=new Promise((L,A)=>{O=L,W=A}),S={value:f.value,promise:X};i.current.set(h,S);const M=()=>{i.current.get(h)===S&&i.current.delete(h)};let I;try{const L=C?.find(q=>q.field===f.field),A=ed(T,f,L,l.current);I=N?N(A,T):A}catch(L){return M(),E(L),O(),X}const _=L=>{M();try{P(L),O()}catch(A){W(A)}};return Qa(I)?Promise.resolve(I).then(_,L=>{M(),E(L),O()}):_(I),X},[u]),m=a.useCallback(h=>{const f=n.current;if(f){if(f.id===h.id&&f.field===h.field)return;g(r.current,f)}r.current+=1,u({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[g,u]),x=a.useCallback(h=>{const f=n.current;return!f||!c.current||h?.id!==void 0&&h.id!==f.id||h?.field!==void 0&&h.field!==f.field?yt:h?.cancel?(u(null),yt):g(r.current,f)},[g,u]),v=a.useCallback(h=>{const f=n.current;!f||f.id!==h.id||f.field!==h.field||u({...f,value:h.value})},[u]);return a.useMemo(()=>({editingCell:t,startCellEdit:m,stopCellEdit:x,setEditCellValue:v}),[t,m,x,v])}function ed(e,t,o,n){return o?.valueSetter?o.valueSetter({value:t.value,row:e,field:t.field}):(o?.valueGetter&&process.env.NODE_ENV!=="production"&&!n.has(t.field)&&(n.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 td=e=>e.id,od={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},li="\0",si="";function ai(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 nd(e){return e.map(t=>t.field).join(li)}function rd(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:d,rowMetaMap:u,getRowId:g=td}=e,m=a.useMemo(()=>r.some(p=>p.colSpan!==void 0&&p.colSpan!==null),[r]),x=a.useMemo(()=>r.some(p=>p.rowSpan!==void 0&&p.rowSpan!==null),[r]),v=m||x,h=v?[i,l,c].map(nd).join(si):"",f=a.useMemo(()=>{if(!h)return{columns:[],leftCount:0,unpinnedCount:0};const p=new Map(r.map(N=>[N.field,N])),b=h.split(si).map(N=>N?N.split(li):[]),y=[];let C=0;for(const N of b){C+=N.length;for(const T of N){const E=p.get(T)??{field:T};y.push({colDef:E,field:T,sectionEnd:C,hasColSpan:E.colSpan!==void 0&&E.colSpan!==null,hasRowSpan:E.rowSpan!==void 0&&E.rowSpan!==null})}}return{columns:y,leftCount:b[0].length,unpinnedCount:b[1].length}},[h,r]),w=a.useMemo(()=>{if(!v||f.columns.length===0)return null;const p={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:f,expandedRowIds:d,rowMetaMap:u,getRowId:g,warned:new Set,out:p};return gn(t,0,!1,y),gn(o,t.length,!0,y),gn(n,t.length+o.length,!1,y),p},[v,f,t,o,n,d,u,g]);return a.useMemo(()=>{if(!w)return od;const{colspanMap:p,rowSpanningCaches:b,hiddenOriginFields:y,unpinnedRanges:C,centerRowSpanStart:N}=w,T=f.columns;return{hasColSpan:m,hasRowSpan:x,colspanMap:p,rowSpanningCaches:b,getSpanOrigin:(E,P)=>{const O=p.get(E)?.[P];if(O?.spannedByColSpan)return{rowId:E,field:T[O.leftVisibleCellIndex].field};const W=b.hiddenCellOriginMap[E]?.[P];return W===void 0?null:{rowId:W,field:y.get(E)?.[P]??P}},getUnpinnedColSpanRanges:E=>C.get(E),getCenterRowSpanStart:E=>N.get(E)??E}},[w,m,x,f])}function gn(e,t,o,n){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:d,out:u}=n,{columns:g,leftCount:m,unpinnedCount:x}=r,v=g.length,{colspanMap:h,rowSpanningCaches:f,hiddenOriginFields:w,unpinnedRanges:p,centerRowSpanStart:b}=u,y=new Int32Array(v),C=new Array(v),N=new Array(v),T=new Int32Array(v);let E=0;const P=[];g.forEach((X,S)=>{(X.hasColSpan||X.hasRowSpan)&&P.push(S)});const O=(X,S,M)=>{const I=g[M].field;if(Ct(f.hiddenCells,X,I,!0),Ct(f.hiddenCellOriginMap,X,I,C[M]),N[M]!==I&&Ct(w,X,I,N[M]),o){const _=b.get(S);(_===void 0||T[M]<_)&&b.set(S,T[M])}},W=(X,S,M)=>{const I=g[M],_=c(X),L=id(X,_,I.colDef,t+S,M,l,d);let A=1;if(I.hasColSpan){const K=Math.min(di(I.colDef.colSpan,L,"colSpan",I.field,d),I.sectionEnd-M);for(;A<K&&y[M+A]<=S;)A++}let q=1;if(I.hasRowSpan){q=Math.min(di(I.colDef.rowSpan,L,"rowSpan",I.field,d),e.length-S);for(let K=1;K<q;K++)if(qe(c(e[S+K]),l)){q=K;break}if(q>1&&i&&i.size>0){for(let K=0;K<q-1;K++)if(i.has(c(e[S+K]))){q=K+1;break}}}if(A>1){Ct(h,_,I.field,{spannedByColSpan:!1,cellProps:{colSpan:A}});for(let K=1;K<A;K++){const J=g[M+K];Ct(h,_,J.field,{spannedByColSpan:!0,leftVisibleCellIndex:M,rightVisibleCellIndex:M+A-1})}if(M>=m&&M<m+x){let K=p.get(_);K||(K=[],p.set(_,K)),K.push(M-m,M+A-1-m)}}if(q>1){Ct(f.spannedCells,_,I.field,q);for(let K=M;K<M+A;K++)y[K]=S+q,C[K]=_,N[K]=I.field,T[K]=S;S+q>E&&(E=S+q)}return A};for(let X=0;X<e.length;X++){const S=e[X];if(!S||S._isSkeleton||qe(c(S),l))continue;if(E<=X){let I=0;for(const _ of P)_>=I&&(I=_+W(S,X,_));continue}let M=0;for(;M<v;)y[M]>X?(O(c(S),X,M),M++):g[M].hasColSpan||g[M].hasRowSpan?M+=W(S,X,M):M++}}function id(e,t,o,n,r,i,l){const c=e[o.field];let d=c;if(o.valueGetter)try{d=o.valueGetter({row:e,field:o.field,value:c})}catch(u){ci(l,`valueGetter:${o.field}`,`valueGetter for column "${o.field}" threw while computing its span`,u),d=void 0}return{row:e,value:d,field:o.field,colDef:o,rowIndex:n,colIndex:r,rowMeta:i?.get(t)}}function di(e,t,o,n,r){if(typeof e=="number")return ai(e);if(typeof e!="function")return 1;try{return ai(e(t))}catch(i){return ci(r,`${o}:${n}`,`${o} for column "${n}" threw; the cell is rendered without a span`,i),1}}function ci(e,t,o,n){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${o}.`,n))}function Ct(e,t,o,n){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[o]=n;return}let r=e[t];r||(r={},e[t]=r),r[o]=n}function ld(e){const{spanning:t,renderContext:o,offsetTop:n,cumulativeHeights:r}=e;return a.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:o,offsetTop:n};let i=Math.max(0,o.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=o.firstRowIndex?{renderContext:o,offsetTop:n}:{renderContext:{...o,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,o,n,r])}function sd(e){const{spanning:t,firstColumnIndex:o,lastColumnIndex:n,virtualColumns:r,layout:i,rows:l}=e;return a.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=o,d=n,u=!0;for(;u;){u=!1;for(const{row:p,id:b}of l){const y=t.getUnpinnedColSpanRanges(b??p.id);if(y)for(let C=0;C<y.length;C+=2){const N=y[C],T=y[C+1];T<c||N>d||(N<c&&(c=N,u=!0),T>d&&(d=T,u=!0))}}}if(c===o&&d===n)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:m,rightPinnedCols:x,unpinnedAccWidths:v,unpinnedTotalWidth:h}=i,f=c>0?v[c-1]:0,w=h-v[d];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...m.slice(c,d+1),...w>0?[{field:"__spacer_right__",width:w,isSpacer:!0}]:[],...x]},[t,o,n,r,i,l])}function ad(e,t){const{draggedColumn:o,onDragOver:n,onDrop:r,onDragEnd:i}=t,l=a.useMemo(()=>{if(!e||e.length===0)return null;const c=d=>o===null||fn(e,o,d);return{onDragOver:n&&(d=>c(d)?n(d):()=>{}),onDrop:r&&(d=>c(d)?r(d):u=>{u.preventDefault(),i?.()})}},[e,o,n,r,i]);return l?{...t,...l}:t}const dd=300,ui=e=>e.id;function cd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function fi(e,t){const o=new Set,n=[];return e.forEach(r=>{const i=t(r);o.has(i)||(o.add(i),n.push({id:i,row:r}))}),n}function gi(e,t,o){const n=new Set(e.map(o)),r=t.filter(i=>!n.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function ud(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:d,rowGroupingActive:u=!1}=e,g=cd(i,u),m=!!t&&i==="server"&&u,x=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!m||(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."))},[m]);const v=t?.getRows,h=Vr({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),f=JSON.stringify([g,g!=="all"||l==="server"?o:null,g!=="all"||c==="server"?n:null,h?d??null:null,g==="all"?null:r.pageSize]),w=g==="all"?0:r.page,p=g==="all"?0:r.pageSize,b=a.useRef({params:e,kind:g});a.useLayoutEffect(()=>{b.current={params:e,kind:g}});const y=a.useRef(0),C=a.useRef(0),N=a.useRef(null),T=a.useRef({page:0,loadedEnd:0,inFlightEnd:null}),E=a.useRef(null),P=a.useRef(!1),O=a.useRef(0),W=a.useRef(!1),X=a.useRef(new Set),S=a.useCallback(()=>{const J=P.current||O.current>0;J!==W.current&&(W.current=J,b.current.params.setDataSourceLoading(J))},[]),M=a.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),I=a.useCallback(()=>{y.current++,T.current.inFlightEnd=null,P.current=!1},[]),_=a.useCallback(()=>{C.current++,X.current.clear(),O.current=0},[]),L=a.useCallback(async()=>{const{params:J,kind:te}=b.current,oe=J.dataSource;if(!oe)return!1;const Z=T.current,de=J.paginationModel.pageSize;let ae,ne;if(te==="infinite"){if(Z.inFlightEnd!==null)return!1;if(ae=Z.loadedEnd,ne=(Z.page+1)*de,ne<=ae)return P.current=!1,S(),!1;Z.inFlightEnd=ne}else te==="page"?(ae=J.paginationModel.page*de,ne=ae+de):(ae=0,ne=zr);const se=++y.current;P.current=!0,S(),J.setDataSourceError(null);let re;try{re=await oe.getRows({startRow:ae,endRow:ne,sortModel:J.sortModel,filterModel:J.filterModel,groupKeys:[],aggregationModel:J.aggregationModel})}catch(B){return se!==y.current||(Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S()),!1}if(se!==y.current)return!1;try{const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);if(te==="infinite"&&ae>0?B.setRows(R=>gi(R,$,D),!0):(B.setRows($.map(R=>R.row),!0),_()),re.aggregationResults&&B.onAggregationResults?.(re.aggregationResults),re.rowCount!==void 0&&B.setRowCount(re.rowCount),te==="infinite"&&(Z.inFlightEnd=null,Z.loadedEnd=ae+re.rows.length,re.rows.length>=ne-ae&&(Z.page+1)*de>ne))return!0}catch(B){return Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S(),!1}return P.current=!1,S(),!1},[S,_]),A=a.useCallback(async()=>{for(;await L(););},[L]);a.useLayoutEffect(()=>{if(!v){N.current&&(N.current=null,M(),I(),_(),b.current.params.setDataSourceError(null),S());return}const J=N.current,te=T.current;if(!J||J.key!==f||J.getRows!==v){N.current={key:f,getRows:v},I(),_();const oe=g==="infinite"&&J!==null&&w!==0;if(te.page=oe?0:w,te.loadedEnd=0,oe){const{params:Z}=b.current;Z.onPaginationModelChange?.({...Z.paginationModel,page:0})}}else g==="infinite"?(w<te.page&&(I(),te.loadedEnd=0),te.page=w):I();if(g==="infinite"){const oe=te.inFlightEnd!==null;if(oe||(te.page+1)*p<=te.loadedEnd){P.current=oe,S();return}}return P.current=!0,S(),E.current=setTimeout(()=>{E.current=null,A()},dd),M},[v,f,g,w,p,M,I,_,S,A]),a.useEffect(()=>()=>{I(),_()},[I,_]);const q=a.useCallback(()=>(M(),A()),[M,A]),K=a.useCallback(async(J,te,oe)=>{const{params:Z}=b.current,de=Z.dataSource;if(!de)return;const ae=JSON.stringify(te),ne=X.current;if(ne.has(ae))return;const se=C.current;ne.add(ae),O.current++,S();try{const re=await de.getRows({startRow:0,endRow:zr,sortModel:Z.sortModel,filterModel:Z.filterModel,groupKeys:te,aggregationModel:Z.aggregationModel});if(se!==C.current)return;if(re.rows.length>0){const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);B.setRows(R=>gi(R,$,D),!0)}}catch(re){if(se!==C.current)return;ne.delete(ae),console.error("Failed to fetch children:",re),oe?.(re)}finally{se===C.current&&(O.current--,S())}},[S]);return{fetchRows:q,fetchChildren:K}}function fd(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function gd({enabled:e,treeNodes:t,isGroupExpanded:o,getNodePath:n,toggleExpansion:r,fetchChildren:i}){const l=a.useRef({isGroupExpanded:o,toggleExpansion:r});a.useLayoutEffect(()=>{l.current={isGroupExpanded:o,toggleExpansion:r}}),a.useEffect(()=>{e&&t.forEach((c,d)=>{!fd(c)||!o(d)||i(d,n(d),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(d)&&g(d)})})},[e,t,o,n,i])}const pi={};function pd(e){const t=JSON.stringify(e),[o,n]=a.useState(null),r=a.useCallback(i=>n({modelKey:t,results:i}),[t]);return[o&&o.modelKey===t?o.results:null,r]}function hi(e){const{rows:t,columns:o,aggregationModel:n,isServerSide:r,dataSource:i,filterModel:l,sortModel:c,serverAggregationResults:d}=e,u=Object.keys(n).length>0,g=a.useMemo(()=>{const N=new Map;return(o??[]).forEach(T=>N.set(T.field,T)),N},[o]),m=a.useMemo(()=>r||!u?pi:ao(t,n,g,"useAggregation"),[t,g,n,r,u]),x=JSON.stringify([n,l??null,c??[]]),v=r&&u&&!!i?.getAggregations&&!d,h=a.useRef({aggregationModel:n,filterModel:l,sortModel:c});a.useEffect(()=>{h.current={aggregationModel:n,filterModel:l,sortModel:c}});const[f,w]=a.useState(null);a.useEffect(()=>{const N=i?.getAggregations;if(!v||!N)return;let T=!1;const E=h.current;let P;try{P=Promise.resolve(N({sortModel:E.sortModel??[],filterModel:E.filterModel??{items:[]},groupKeys:[],aggregationModel:E.aggregationModel}))}catch(O){P=Promise.reject(O)}return P.then(O=>{T||w({key:x,result:O,error:null})},O=>{T||(console.error("[useAggregation] Server aggregation error:",O),w({key:x,result:null,error:O}))}),()=>{T=!0}},[v,i,x]);const p=f&&f.key===x?f:null,b=v&&p===null,y=v?p?.error??null:null;return{aggregationResult:a.useMemo(()=>r?d&&Object.keys(d).length>0?d:p?.result??pi:m,[r,m,d,p]),isLoading:b,error:y}}const hd={items:[]},wd=[];function md(e){const{rows:t,columns:o,pivotMode:n,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:d}=e,u=n&&!c,g=a.useMemo(()=>new Set(o.map(p=>p.field)),[o]),m=a.useMemo(()=>tn(o),[o]),x=a.useMemo(()=>ns(i,g),[i,g]),v=a.useMemo(()=>u?Jo(t,x.source,m):t,[u,t,x.source,m]),h=a.useMemo(()=>u?vr(v,o,r,{outputFilterModel:x.output,sortModel:l}):nn,[u,v,o,r,x.output,l]),f=u&&h.isValid,w=a.useRef({dataSource:!1,hierarchy:!1});return a.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&c&&!w.current.dataSource&&(w.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`.")),f&&d&&!w.current.hierarchy&&(w.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.")))},[n,c,f,d]),{isActive:f,rows:f?h.pivotRows:t,columns:f?h.pivotColumns:o,pipelineFilterModel:f?hd:i,pipelineSortModel:f?wd:l}}const Ht=({variant:e="text",size:t="medium",color:o="default",disabled:n=!1,className:r="",type:i="button",children:l,...c})=>{const d=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${o}`,n&&"ogx-button--disabled",r].filter(Boolean).join(" ");return s.jsx("button",{type:i,className:d,disabled:n,...c,children:l})};function pn(e){const t=a.useId(),{page:o,pageSize:n,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:c=[10,25,50,100],showFirstButton:d=!0,showLastButton:u=!0,localeText:g}=e,m=go(n),x=ln(r,m),v=Pr(o,x),h=c.includes(m)?c:[...c,m].sort((S,M)=>S-M),f=v*m,w=Math.min(f+m,r),p=r===0?0:`${f+1}–${w}`,b=g?.paginationRowsPerPage??"Rows per page:",y=g?.paginationOf?g.paginationOf(r===0?0:f+1,w,r):`${p} of ${r}`,C=g?.paginationPage?g.paginationPage(v+1,x):`Page ${v+1} of ${x}`,N=()=>{i(0)},T=()=>{i(Math.max(0,v-1))},E=()=>{i(Math.min(x-1,v+1))},P=()=>{i(x-1)},O=S=>{const M=parseInt(S.target.value,10);l(M)},W=v===0,X=v>=x-1;return s.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[s.jsxs("div",{className:"ogx-pagination__page-size",children:[s.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:b}),s.jsx("select",{id:t,className:"ogx-pagination__select",value:m,onChange:O,children:h.map(S=>s.jsx("option",{value:S,children:S},S))})]}),s.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),s.jsxs("div",{className:"ogx-pagination__actions",children:[d&&s.jsx(Ht,{variant:"text",size:"small",onClick:N,disabled:W,"aria-label":"Go to first page",title:"First page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),s.jsx(Ht,{variant:"text",size:"small",onClick:T,disabled:W,"aria-label":"Go to previous page",title:"Previous page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),s.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:C}),s.jsx(Ht,{variant:"text",size:"small",onClick:E,disabled:X,"aria-label":"Go to next page",title:"Next page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&s.jsx(Ht,{variant:"text",size:"small",onClick:P,disabled:X,"aria-label":"Go to last page",title:"Last page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function xd({row:e,rowId:t,rowIndex:o,ariaRowIndex:n,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:c=!1,checkboxSelection:d=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:m,onSelectionChange:x,tabIndex:v=-1,onFocus:h,onToggleExpansion:f}){const w=t??e.id,p=r.field,b=Fe(e,p,i),y=Bo(e,p,b,i)??Vo(b,i),C=l?.isGroupRow===!0||qe(w),N={row:e,value:b,formattedValue:y,field:p,colDef:i??r,rowIndex:o,colIndex:0,rowMeta:l},T=E=>{E.stopPropagation(),x?.(w,E.target.checked)};return s.jsxs("div",{className:`ogx-list-view__row${c?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:m?()=>m(e):void 0,role:"row","aria-rowindex":n??o+1,"aria-selected":c,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":o,tabIndex:v,onFocus:h?E=>{E.target===E.currentTarget&&h(o)}:void 0,children:[d&&s.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!C&&s.jsx("input",{type:"checkbox",checked:c,onChange:T,"aria-label":`Select row ${w}`,tabIndex:-1})}),l&&f&&s.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&s.jsx(dn,{isExpanded:l.isExpanded===!0,onClick:()=>f(w),tabIndex:-1})}),s.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:s.jsx(it,{field:p,resetKey:e,renderFn:()=>{const E=r.renderCell(N);return E===void 0&&C?l?.groupLabel:E}})})]})}function bd(e,t){const o=a.useRef(!0),n=a.useRef(e);a.useEffect(()=>{n.current=e},[e]),a.useEffect(()=>{o.current=!0},[t]);const r=a.useCallback(i=>{const l=Or(i.currentTarget);if(!l){o.current=!0;return}if(!o.current)return;const c=n.current;c&&(o.current=!1,c(l))},[]);return e?r:void 0}const vd=e=>e.id;function yd({ariaLabel:e,allRenderableRows:t,dataRowCount:o,pinnedTopRowCount:n,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:c,currentPage:d,pageSizeOptions:u,selectedRowIds:g,listViewColumn:m,columnsByField:x,rowMetaMap:v,noRowsLabel:h,rowHeight:f,checkboxSelection:w,paginationMode:p,serverRowCount:b,paginationSlot:y,paginationSlotProps:C,localeText:N,onRowClick:T,onRowDoubleClick:E,onSelectionChange:P,onPaginationModelChange:O,onRowsScrollEnd:W,getRowId:X=vd,multiselectable:S=!1,loading:M=!1,loadingOverlay:I,noRowsOverlay:_,showPaginationControls:L=!0,selectable:A=!1,onToggleExpansion:q}){const K=y||pn,J=a.useRef(null),[te,oe]=a.useState(null),Z=te===null?-1:t.findIndex(Y=>X(Y)===te),de=Z===-1?0:Z,ae=Y=>{const H=t[Y];H&&(oe(X(H)),J.current?.querySelector(`:scope > [role="row"][data-rowindex="${Y}"]`)?.focus())},ne=Y=>{const H=Y.target;if(H.getAttribute("role")!=="row"||H.parentElement!==J.current)return;const j=Number(H.getAttribute("data-rowindex")),z=t[j];if(!z)return;const k=X(z),F=t.length-1,Q=v.get(k),ee=!!(Q?.hasChildren&&q);if(Y.altKey&&(Y.key==="ArrowRight"||Y.key==="ArrowLeft")){Y.preventDefault(),ee&&Y.key==="ArrowRight"!=(Q?.isExpanded===!0)&&q?.(k);return}switch(Y.key){case"ArrowDown":Y.preventDefault(),ae(Math.min(j+1,F));return;case"ArrowUp":Y.preventDefault(),ae(Math.max(j-1,0));return;case"Home":Y.preventDefault(),ae(0);return;case"End":Y.preventDefault(),ae(F);return;case"PageDown":Y.preventDefault(),ae(Math.min(j+10,F));return;case"PageUp":Y.preventDefault(),ae(Math.max(j-10,0));return;case"Enter":case" ":if(Y.preventDefault(),Y.key===" "&&Y.shiftKey){A&&!Q?.isGroupRow&&P(k,!g.has(k));return}ee?q?.(k):T({row:z,id:k,rowIndex:j});return}},se=p==="server",re=se?b||0:i,B=se?b||0:o,D=go(c.pageSize),$=ln(re,D),R=l?d*D:0,U=t.length-n-r,G=Y=>{if(Y<n)return Y+1;const H=Y-n;return H<U?n+R+H+1:n+re+(H-U)+1},V=bd(W,t.length);return s.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":B,"aria-multiselectable":S,children:[s.jsx("div",{className:"ogx-list-view__toolbar",children:s.jsxs("span",{children:[B," ",B===1?"item":"items",l?` · page ${d+1} of ${$}`:"",g.size>0?` · ${g.size} selected`:""]})}),s.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:V,onKeyDown:ne,ref:J,children:t.length===0&&M?s.jsx("div",{className:"ogx-list-view__loading",children:I??s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&_?s.jsx("div",{className:"ogx-list-view__empty",children:_}):t.length===0?s.jsxs("div",{className:"ogx-list-view__empty",children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),h]}):t.map((Y,H)=>{const j=X(Y);return s.jsx(xd,{row:Y,rowId:j,rowIndex:H,ariaRowIndex:G(H),listViewColumn:m,gridColumn:x.get(m.field),rowMeta:v.get(j),isSelected:g.has(j),checkboxSelection:w,rowHeight:f,onRowClick:z=>T({row:z,id:j,rowIndex:H}),onRowDoubleClick:E?z=>E({row:z,id:j,rowIndex:H}):void 0,onSelectionChange:P,tabIndex:H===de?0:-1,onToggleExpansion:q,onFocus:z=>oe(X(t[z]))},j)})}),l&&L&&s.jsx(K,{page:d,pageSize:c.pageSize,rowCount:re,pageSizeOptions:u,onPageChange:Y=>O({...c,page:Y}),onPageSizeChange:Y=>O({...c,pageSize:Y,page:0}),localeText:N,...C})]})}function Cd({overlay:e}){return e?s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function Bt(e){return e.headerName||e.field}function _d(e){return e.nativeEvent.isComposing||e.keyCode===229}function Vt(e,t,o=!0){return n=>{if(_d(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function Sd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(String(e??"")),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"text",className:"ogx__edit-input","aria-label":Bt(t),value:i,onChange:d=>{l(d.target.value),o(d.target.value)},onBlur:n,onKeyDown:Vt(n,r)})}function kd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(typeof e=="number"?e:""),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":Bt(t),value:i,onChange:d=>{const u=d.target.value===""?"":Number(d.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Vt(n,r)})}function Ed({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=()=>{o(!e),n()};return s.jsx("div",{className:"ogx__edit-boolean",children:s.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":Bt(t),checked:!!e,onChange:l,onBlur:n,onKeyDown:Vt(n,r,!1)})})}const hn=e=>typeof e=="object"?e.value:e,Md=e=>typeof e=="object"?e.label:String(e);function Nd(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Pd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(g=>String(hn(g)));let d=l.findIndex(g=>Nd(hn(g),e));d===-1&&e!==null&&e!==void 0&&(d=c.indexOf(String(e)));const u=d===-1;return s.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Bt(t),value:u?"":c[d],onChange:g=>{const m=c.indexOf(g.target.value);o(m===-1?null:hn(l[m]))},onBlur:n,onKeyDown:Vt(n,r),children:[u&&s.jsx("option",{value:""}),l.map((g,m)=>s.jsx("option",{value:c[m],children:Md(g)},m))]})}const wi=e=>String(e).padStart(2,"0"),mi=/^(\d{4}-\d{2}-\d{2})/;function wn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${wi(e.getMonth()+1)}-${wi(e.getDate())}`;if(typeof e=="string"){const t=mi.exec(e);return t?t[1]:e===""?"":wn(new Date(e))}return typeof e=="number"?wn(new Date(e)):""}function Id(e,t){if(e==="")return null;const[o,n,r]=e.split("-").map(Number),i=l=>{const c=new Date(l.getTime());return c.setFullYear(o,n-1,r),c};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&mi.test(t)&&t.length>10?e+t.slice(10):e}function Td({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=a.useState(e),[l,c]=a.useState(()=>wn(e)),d=a.useRef(null);return a.useEffect(()=>{d.current?.focus()},[]),s.jsx("input",{ref:d,type:"date",className:"ogx__edit-input","aria-label":Bt(t),value:l,onChange:u=>{c(u.target.value),o(Id(u.target.value,i))},onBlur:n,onKeyDown:Vt(n,r)})}function Ld(e){const{colDef:t}=e;switch(t.type){case"number":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(kd,{...e})});case"boolean":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Ed,{...e})});case"singleSelect":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Pd,{...e})});case"date":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Td,{...e})});default:return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Sd,{...e})})}}function Fd(e){const{onCellClick:t,onCellEditStart:o,onCellValueChange:n,value:r,row:i,colDef:l,rowIndex:c,colIndex:d,ariaColIndex:u,isSelected:g,onClick:m,width:x,pinnedPosition:v,pinnedOffset:h,isPinnedEdge:f,isFocused:w,isFocusVisible:p,isEditable:b,isEditing:y,onEditStart:C,onEditStop:N,onValueChange:T,colSpanInfo:E,rowSpan:P,isHiddenByRowSpan:O,rowMeta:W,valueError:X}=e,S=a.useCallback(G=>{n?n(l.field,G):T?.(G)},[n,T,l.field]),M=W?.isGroupRow===!0,{formattedValue:I,error:_}=a.useMemo(()=>{if(l.valueFormatter&&!(M&&r==null))try{return{formattedValue:l.valueFormatter({value:r,row:i,field:l.field})}}catch(G){return{formattedValue:"",error:G??new Error("valueFormatter failed")}}return{formattedValue:Vo(r,l)}},[r,i,l,M]),L=a.useMemo(()=>{if(!l.cellClassName)return"";if(typeof l.cellClassName=="function")try{return l.cellClassName({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})||""}catch{return""}return l.cellClassName},[l,r,I,i,c,d,W]),A=X??_,q=l.field,K=a.useCallback(()=>{N?.(!1,q)},[N,q]),J=a.useCallback(()=>{N?.(!0,q)},[N,q]),te=a.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),oe=a.useRef(!1);if(a.useEffect(()=>{if(!(!y||!N))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.current||N(!1,q)})}},[y,N,q]),E?.spannedByColSpan)return null;const Z=E?.cellProps.colSpan??1,de=Z>1,ae=(de?E?.cellProps.width:void 0)??x??l.width??100,ne={width:"var(--width)","--width":typeof ae=="number"?`${ae}px`:ae,flexGrow:(de?E?.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(O)return s.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:ne,role:"presentation","data-field":l.field,"data-colindex":d});const se=G=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:d}),m?.(G))},re=()=>{y||!b||(o?o(l.field,r):C?.())},B=l.renderEditCell,D=v!=null,$=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&p&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${v}`,D&&f&&`ogx__cell--pinned-${v}-${v==="left"?"last":"first"}`,y&&"ogx__cell--editing",P&&P>1&&"ogx__cell--spanned",L].filter(Boolean).join(" "),R=P||1,U={...ne,position:D?"sticky":void 0,zIndex:l.zIndex??(D?3:void 0),padding:y?0:void 0};return R>1&&(U.height=`calc(var(--height) * ${R} - var(--border-width, 1px))`,U.zIndex=10,D&&(U.zIndex=40)),D&&h!==void 0&&(v==="left"?U.left=h:U.right=h),s.jsx("div",{className:$,style:U,onClick:se,onDoubleClick:re,role:"gridcell","aria-colindex":u??d+1,"aria-readonly":!b||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":d,...Z>1?{"aria-colspan":Z}:{},...R>1?{"aria-rowspan":R}:{},children:s.jsx("div",{className:"ogx__cell-content",children:y&&(n||T)&&N?B?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>B({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J})}):s.jsx(Ld,{value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J}):A!==void 0?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>{throw A}}):l.renderCell?s.jsx(it,{field:l.field,resetKey:te,renderFn:()=>l.renderCell({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})}):l.type==="image"&&typeof r=="string"&&r!==""?s.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):I})})}const xi=a.memo(Fd),Od=({className:e="",...t})=>s.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:s.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 Dd(e){const{rowId:t,content:o,height:n,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,d=a.useRef(null),u=n==="auto";if(a.useLayoutEffect(()=>{const m=d.current;if(!m||!u||!r||!i)return;const x=()=>{m.getClientRects().length!==0&&i(t,m.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(x);return v.observe(m),()=>v.disconnect()},[u,r,i,t]),!r)return null;const g={height:u?"auto":`${n}px`,overflow:u?"visible":"auto"};return s.jsx("div",{ref:d,className:"ogx__detail-panel",style:g,role:"row",id:l,children:s.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:o})})}const mn=12;function Ad(e,t,o,n){let r=0,i=0,l=0;for(let c=t;c<e.length&&l<o;c++){const d=e[c];if(d.isSpacer)break;r+=ot(d,n),i+=d.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function xo(e){const{row:t,rowId:o,columns:n,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:c,onRowDoubleClick:d,onCellClick:u,onSelectionChange:g,columnWidths:m={},pinnedColumns:x,pinnedRows:v,hasDetailPanel:h=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:w,detailPanelContent:p,detailPanelHeight:b=zo,onDetailPanelHeightChange:y,pinCheckboxColumn:C=!0,pinExpandColumn:N=!0,rowReordering:T=!1,onDragStart:E,onDragOver:P,onDragEnd:O,onDrop:W,isDragging:X,isDragOver:S,editingCell:M,onEditStart:I,onEditStop:_,onEditCellValueChange:L,isCellEditable:A,focusedCellField:q,isFocusVisible:K,colspanMap:J,rowSpanningCaches:te,rowHeight:oe=52,rowMeta:Z,columnIndexMap:de,ariaRowIndex:ae}=e,ne=o??t.id,se=a.useId(),re=a.useId(),B=a.useMemo(()=>Wo(n,m,x,l,C,h,N,T),[n,m,x,l,C,h,N,T]),D=a.useMemo(()=>Ho(n,x),[n,x]),$=Z?.hasChildren===!0,R=Z?.isGroupRow===!0,U=h&&!R,G=!R&&!qe(ne),V=a.useCallback((le,ye)=>{I?.({id:ne,field:le,value:ye})},[ne,I]),Y=a.useCallback((le,ye)=>{L?.({id:ne,field:le,value:ye})},[L,ne]),H=a.useCallback((le,ye)=>{_?.({cancel:le,id:ne,field:ye})},[_,ne]);if(t._isSkeleton){const le=Math.max(n.length,5);return s.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:oe,minHeight:oe},children:Array.from({length:le}).map((ye,Le)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-bar"})},Le))})}const j=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:ne,rowIndex:r})},z=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:ne,rowIndex:r})},k=le=>{le.stopPropagation(),g?.(ne,le.target.checked)},F=le=>{le.stopPropagation(),w?.(ne)},Q=T?1:0,ee=h?Q+1:Q,ce=l?ee+1:ee,fe=ce,ge=de?.size??n.filter(le=>!le.isSpacer).length,be=Z!==void 0,Ce=Z?.hasChildren===!0,ue=zn(ne,v),me=ue==="top",ve=ue==="bottom",Se=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",me&&"ogx__row--pinned-top",ve&&"ogx__row--pinned-bottom",X&&"ogx__row--dragging",S&&"ogx__row--drag-over",$&&"ogx__row--group",Z?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Se,onClick:j,onDoubleClick:d?z:void 0,role:"row","aria-rowindex":ae??r+2,"aria-selected":i,"aria-level":be?(Z?.treeDepth??0)+1:void 0,"aria-expanded":Ce?Z?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:P?P(ne):void 0,onDrop:W?W(ne):void 0,style:{maxHeight:`${oe}px`,minHeight:`${oe}px`,"--height":`${oe}px`,"--border-width":"1px"},children:[T&&s.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${q==="__reorder_col__"?"ogx__cell--focused":""} ${q==="__reorder_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":E?"Drag to reorder row":void 0,"aria-colindex":Q,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:mn},draggable:!!E,onDragStart:E?E(ne):void 0,onDragEnd:O,onClick:le=>le.stopPropagation(),children:E&&s.jsx(Od,{})}),h&&s.jsx("div",{className:`ogx__cell ogx__cell--expand ${N?"ogx__cell--pinned-left":""} ${q==="__expand_col__"?"ogx__cell--focused":""} ${q==="__expand_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":U?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":U?f:void 0,"aria-controls":U&&f?re:void 0,"aria-colindex":ee,"data-field":"__expand_col__",style:{position:N?"sticky":void 0,left:N?T?48:0:void 0,zIndex:N?mn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:U&&s.jsx(dn,{isExpanded:f,onClick:F,variant:"plus-minus",tabIndex:-1})}),l&&s.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${C?"ogx__cell--pinned-left":""} ${q==="__checkbox_col__"?"ogx__cell--focused":""} ${q==="__checkbox_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ce,"data-field":"__checkbox_col__",style:{position:C?"sticky":void 0,left:C?(T?48:0)+(h&&N?48:0):void 0,zIndex:C?mn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:G&&s.jsx(Wt,{id:se,name:`ogx-select-row-${ne}`,checked:i,onChange:k,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${ne}`:`Select row ${ne}`,tabIndex:-1,onMouseDown:le=>le.preventDefault()})}),n.map((le,ye)=>{if(le.isSpacer)return s.jsx("div",{style:{width:le.width,minWidth:le.width,flexShrink:0},"aria-hidden":"true"},le.field);let Le,xe;R?Le=t[le.field]:{value:Le,error:xe}=Un(t,le.field,le);const ke=de?.get(le.field)??ye,ie=m[le.field]??le.width,pe=Xe(le.field,x),we=!!I&&Jn({row:t,field:le.field,value:Le,colDef:le,rowIndex:r,colIndex:ke,rowMeta:Z},A),Me=M?.id===ne&&M?.field===le.field,Pe=Me?M?.value:Le,De=J?.get(ne)?.[le.field],Qe=De&&!De.spannedByColSpan&&De.cellProps.colSpan>1?Ad(n,ke,De.cellProps.colSpan,m):De,Yt=Qe&&!Qe.spannedByColSpan?n[ke+Qe.cellProps.colSpan-1]?.field??le.field:le.field,So=pe==="right"?Yt:le.field,$e=pe?B[So]:void 0,ko=pe==="left"&&Yt===D.lastLeft||pe==="right"&&le.field===D.firstRight,Be=te?.spannedCells[ne]?.[le.field],Eo=te?.hiddenCells[ne]?.[le.field]||!1;return s.jsx(xi,{value:Pe,row:t,colDef:le,rowIndex:r,colIndex:ke,ariaColIndex:fe+ke+1,isSelected:i,onCellClick:u,width:ie,pinnedPosition:pe,pinnedOffset:$e,isPinnedEdge:ko,isFocused:q===le.field,isFocusVisible:K,isEditable:we,isEditing:Me,onCellEditStart:V,onEditStop:H,onCellValueChange:Y,colSpanInfo:Qe,rowSpan:Be,isHiddenByRowSpan:Eo,rowMeta:Z,valueError:xe},le.field)})]}),U&&s.jsx(Dd,{id:re,colSpan:fe+ge,row:t,rowId:ne,rowIndex:r,content:p,height:b,isExpanded:f,onHeightChange:y})]})}function bi({getContent:e,params:t}){return s.jsx(it,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const $d=e=>e.id;function vi({rows:e,position:t,columns:o,selectedRowIds:n,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,expandedRowIds:v,getDetailPanelContent:h,getDetailPanelHeight:f,onDetailPanelToggle:w,onDetailPanelHeightChange:p,pinCheckboxColumn:b,pinExpandColumn:y,focusedCell:C,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMetaMap:P,getRowId:O=$d,rowIndexOffset:W=0,ariaRowIndexBase:X,columnIndexMap:S,editingHandlers:M,isCellEditable:I,rowReordering:_=!1}){return e.length===0?null:s.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((L,A)=>{const q=O(L),K=W+A;return s.jsx(xo,{row:L,rowId:q,columns:o,rowIndex:K,ariaRowIndex:X!==void 0?X+A:void 0,columnIndexMap:S,isSelected:n.has(q),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,isDetailPanelExpanded:v.has(q),detailPanelContent:v.has(q)&&h?s.jsx(bi,{getContent:h,params:{row:L,id:q,rowIndex:K}}):null,detailPanelHeight:v.has(q)?Ko(jo(f,{row:L,id:q,rowIndex:K})):void 0,onDetailPanelHeightChange:p,onDetailPanelToggle:w,pinCheckboxColumn:b,pinExpandColumn:y,focusedCellField:C?.id===q?C.field:null,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMeta:P.get(q),editingCell:M?.editingCell,onEditStart:M?.startCellEdit,onEditStop:M?.stopCellEdit,onEditCellValueChange:M?.setEditCellValue,isCellEditable:I,rowReordering:_},q)})})}const Gd=({columns:e,rowHeight:t,checkboxSelection:o=!1,hasDetailPanel:n=!1,rowReordering:r=!1})=>s.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[o&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,d=Math.min(c*.7,c-20);return s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:c,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&&s.jsx("div",{className:"ogx-skeleton-box",style:{width:d,height:16,borderRadius:4}})},i.field||l)})]});function Wd({virtualContainerHeight:e,offsetTop:t,effectiveLoading:o,visibleRows:n,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:c,hasDetailPanel:d,rowReordering:u,rowHeight:g,selectedRowIds:m,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,expandedRowIds:b,getDetailPanelContent:y,getDetailPanelHeight:C,onDetailPanelToggle:N,onDetailPanelHeightChange:T,pinCheckboxColumn:E,pinExpandColumn:P,rowReorderHandlers:O,editingHandlers:W,isCellEditable:X,focusedCell:S,colspanMap:M,rowSpanningCaches:I,paginationMode:_,dataSourceLoading:L,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:q,unpinnedRowsLength:K,lastRenderedRowIndex:J,rowMetaMap:te,loadingOverlay:oe,ariaRowIndexOffset:Z,columnIndexMap:de}){const ae=r.length>0?r:(()=>{const re=(l||1e3)-(c?48:0)-(d?48:0)-(u?48:0),B=150,D=Math.max(1,Math.ceil(re/B));return Array.from({length:D},($,R)=>({field:`placeholder_${R}`,headerName:"",width:B}))})(),ne=n.filter(re=>!re.pinned),se=_==="infinite"&&L&&A>0&&J>=K-1;return s.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:s.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[o&&n.length===0&&oe?s.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:oe}):o&&n.length===0?Array.from({length:10}).map((re,B)=>s.jsx(Gd,{columns:ae,rowHeight:g,checkboxSelection:c,hasDetailPanel:d,rowReordering:u},`skeleton-${B}`)):ne.map(({row:re,id:B,rowIndex:D})=>s.jsx(xo,{row:re,rowId:B,columns:i,rowIndex:D,ariaRowIndex:Z!==void 0?D+Z:void 0,columnIndexMap:de,isSelected:m.has(B),checkboxSelection:c,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,hasDetailPanel:d,isDetailPanelExpanded:b.has(B),detailPanelContent:b.has(B)&&y?s.jsx(bi,{getContent:y,params:{row:re,id:B,rowIndex:D}}):null,detailPanelHeight:b.has(B)?Ko(jo(C,{row:re,id:B,rowIndex:D})):void 0,onDetailPanelHeightChange:T,onDetailPanelToggle:N,pinCheckboxColumn:E,pinExpandColumn:P,rowReordering:u,onDragStart:O.canReorderRow(B)?O.onDragStart:void 0,onDragOver:O.onDragOver,onDragEnd:O.onDragEnd,onDrop:O.onDrop,isDragging:O.draggedRowId===B,isDragOver:O.dragOverRowId===B,editingCell:W.editingCell,onEditStart:W.startCellEdit,onEditStop:W.stopCellEdit,onEditCellValueChange:W.setEditCellValue,isCellEditable:X,focusedCellField:S!=null&&S.id===B?S.field:null,colspanMap:M,rowSpanningCaches:I,rowHeight:g,rowMeta:te.get(B)},B)),se&&s.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:q}).map((re,B)=>s.jsx(xo,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:i,rowIndex:K+B,rowHeight:g},`__skeleton_${B}__`))})]})})}function Hd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Bd(){return s.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[s.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function xn(e){const{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:d}=e,[u,g]=a.useState(""),m=a.useId(),[x,v]=a.useState(null),h=a.useRef(null),f=a.useMemo(()=>t.filter(P=>P.hideable!==!1),[t]),w=f.every(P=>o.has(P.field)),p=a.useMemo(()=>{const P=d?t:f;if(!u)return P;const O=u.toLowerCase();return P.filter(W=>(W.headerName||W.field).toLowerCase().includes(O))},[t,f,u,d]),b=P=>{P.target.checked?r():i()},y=P=>O=>{h.current=P,O.dataTransfer.effectAllowed="move",O.dataTransfer.setDragImage(O.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},C=P=>O=>{O.preventDefault(),O.dataTransfer.dropEffect="move",P!==h.current&&v(P)},N=()=>{v(null)},T=P=>O=>{O.preventDefault();const W=h.current;v(null),h.current=null,W&&W!==P&&l&&l(W,P)},E=()=>{v(null),h.current=null};return s.jsxs("div",{className:"ogx-column-visibility-panel",children:[s.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:s.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[s.jsx(Hd,{}),s.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:P=>g(P.target.value)})]})}),s.jsx("div",{className:"ogx-column-visibility-panel__list",children:p.map((P,O)=>{const W=`${m}-col-${O}`,X=o.has(P.field),S=P.hideable!==!1,M=x===P.field,I=!!l&&!u;return s.jsxs("div",{className:["ogx-column-visibility-panel__item",!S&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:I,onDragOver:I?C(P.field):void 0,onDragLeave:I?N:void 0,onDrop:I?T(P.field):void 0,onDragEnd:I?E:void 0,children:[I&&s.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(P.field),title:"Drag to reorder",children:s.jsx(Bd,{})}),s.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:S?"pointer":"not-allowed"},children:[s.jsx(Wt,{id:W,checked:X,onChange:_=>n(P.field,_.target.checked),disabled:!S}),s.jsx("label",{htmlFor:W,className:"ogx-column-visibility-panel__label",children:P.headerName||P.field})]})]},P.field)})}),s.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[s.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[s.jsx(Wt,{id:`${m}-all`,checked:w,onChange:b}),s.jsx("label",{htmlFor:`${m}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),s.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:"Reset"})]})]})}function Vd({isOpen:e,containerRef:t,panelRef:o,columns:n,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:d,onColumnOrderReset:u,columnGroupingModel:g}){const[m,x]=a.useState(null);if(a.useLayoutEffect(()=>{if(!e||!t.current)return;const h=t.current.getBoundingClientRect();x({top:h.top+8,right:xt()-h.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!m)return null;const v=i?void 0:(h,f)=>{fn(g,h,f)&&d(h,f)};return tt.createPortal(s.jsxs("div",{ref:o,style:{position:"fixed",top:m.top,right:m.right,zIndex:9999,display:"inline-block"},children:[s.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:"×"}),s.jsx(xn,{columns:n,visibleColumns:new Set(n.filter(h=>r[h.field]!==!1).map(h=>h.field)),onVisibilityChange:(h,f)=>{c({...r,[h]:f})},onShowAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!0)}),c(h)},onHideAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!1)}),c(h)},onColumnReorder:v,onColumnOrderReset:i?void 0:u})]}),m.target)}const yi=[];function zd(e){const{isPivotActive:t}=e,o=t?yi:e.rowGroupingModel,n=e.treeData&&!t,r=n&&e.hasTreeDataPath,i=o.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:o,isTreeDataRequested:n,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 Kd(e){const{baseColumns:t,pinnedColumns:o,hasGroupingColumn:n,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=a.useMemo(()=>n?{...o,left:["__group__",...(o?.left??[]).filter(u=>u!=="__group__")]}:o,[n,o]);return{activeColumns:a.useMemo(()=>n?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:u})=>{const g=l(u);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,n,i,l,t]),effectivePinnedColumns:c}}function jd(e){return e.id}function Ud(e){const t=a.useCallback(r=>e.get(r)??r.id,[e]),o=a.useRef(t);a.useLayoutEffect(()=>{o.current=t});const n=a.useCallback(r=>o.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:n}}function Xd(e,t){a.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function qd(e){const{hierarchyHandlers:t,pinnedTopRows:o,sortedUnpinnedRows:n,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:c,dataRows:d}=e,u=t?.getVisibleRows({expandAll:!0,labelField:c});if(!u)return[...o,...n,...r];const g=d?new Set(d):null;return u.filter(m=>!i.get(l(m))?.isGroupRow&&(!g||g.has(m)))}function Yd(e,t){if(e===t)return!0;const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;const n=e,r=t;return o.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(n[i],r[i]))}function Rd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>Yd(o,t[n]))}function Jd(e){const[t,o]=a.useState(e),n=Rd(t,e);return n||o(e),n?t:e}function Qd(e){const{rows:t,getRowId:o,rowMetaMap:n,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:c}=e,d=Object.keys(i).length>0,u=new Map(r.map(v=>[v.field,v])),g=[],m=[],x=v=>{for(;m.length>0&&m[m.length-1].header.depth>=v;){const h=m.pop();d&&!c?.(h.id)&&g.push({type:"group-subtotal",depth:h.header.depth,groupField:h.header.groupField,groupValue:h.header.groupValue,groupLabel:h.header.groupLabel,aggregatedValues:ao(h.leaves,i,u,"getGroupedExportRows")})}};for(const v of t){const h=o(v),f=n.get(h);if(!f?.isGroupFooter)if(f?.isGroupRow){const w=f.treeDepth??0;x(w);const p={type:"group-header",depth:w,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(p),m.push({id:h,header:p,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??m.length,row:v}),m.forEach(w=>w.leaves.push(v))}return x(0),d&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Zd(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=()=>o.current;t.current.getAggregationResult=()=>n().hasAggregation?n().aggregationResult:null,t.current.getAggregationModel=()=>n().hasAggregation?n().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:c,rowGroupingHandlers:d,rowMetaMap:u,columns:g,getRowId:m,hierarchyField:x}=n();return c?Qd({rows:d.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:m,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&d.rootAggregationPosition!==null?i:null,isSubtotalHidden:v=>d.aggregationPositions.get(v)===null}):null}},[t])}const ec=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!rt(t.field)&&!ec.has(t.field))}function Re(e){return!!e&&e.length>0}function Ci(e,t,o=n=>n.id){const n=new Set(t);return e.filter(r=>n.has(o(r)))}function zt(e,t,o){return Re(t)?Ci(e,t,o):e}function Kt(e,t){return!!e&&e.length>0&&!Re(t)}function _t(e,t,o,n,r){if(!n)return null;if(!t||!r||Object.keys(r).length===0)return n;const i=new Map(o.map(l=>[l.field,l]));return ao(e,r,i,"export")}function jt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function bo(e,t,o){if(!t.valueFormatter)return Vo(o,t);if(o==null)try{return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}function bn(e,t,o,n){return o==null?"":co(o,t??"",e,n)}function St(e,t){return t?`${e}: ${t}`:e}function _i(e,t){const o={};return t.forEach(n=>{Object.prototype.hasOwnProperty.call(e,n.field)&&(o[n.field]=e[n.field])}),o}const tc=/^[=+\-@\t\r]/,oc=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function vo(e,t=!1){return t||!tc.test(e)||oc.test(e)?e:`'${e}`}function Je(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function _e(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const nc=/[\\/?*:[\]]/g,Si=31;function vn(e,t=new Set){let o=String(e??"").replace(nc,"-").trim().replace(/^'+|'+$/g,"").trim();o||(o="Sheet"),o=o.slice(0,Si).trim();const n=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=o;for(let i=2;n(r);i++){const l=` (${i})`;r=`${o.slice(0,Si-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const rc=new Set([Ye,$t,At]),ic=/[\t\n\r"]/;function ki(e){return ic.test(e)?`"${e.replace(/"/g,'""')}"`:e}function lc(e){return st(e).filter(t=>!rc.has(t.field))}function sc(e,t){const o=t.map(r=>ki(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>ki(bo(r,i,Fe(r,i.field,i)))).join(" "));return[o,...n].join(`
|
|
4
|
+
`)}function Ei(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,o=document.getSelection(),n=[];if(o)for(let l=0;l<o.rangeCount;l++)n.push(o.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}),o&&(o.removeAllRanges(),n.forEach(l=>o.addRange(l)))}return i}async function ac(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(o){if(Ei(e))return;throw o}if(!Ei(e))throw new Error("Clipboard API not available and fallback failed.")}function dc(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 cc(e){const t=a.useRef(e);a.useLayoutEffect(()=>{t.current=e});const o=a.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:c}=t.current,d=new Set(r());if(d.size===0)return;const u=l().filter(m=>d.has(c(m)));if(u.length===0)return;const g=sc(u,lc(i()));await ac(g)},[]),n=!!e.disableKeyboardShortcut;return a.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!dc(i))return;const l=document.activeElement,c=l?.tagName.toLowerCase(),d=l?.type;if(c==="input"&&d!=="checkbox"&&d!=="radio"||c==="textarea"||c==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const m=u();if(!m||!l||!m.contains(l))return}const g=window.getSelection();g&&!g.isCollapsed&&g.toString()!==""||o().catch(m=>{console.error("[OpenGridX] Failed to copy to clipboard:",m)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[o,n]),{copySelectedRows:o}}function uc(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=a.useCallback(()=>r.current,[r]),{copySelectedRows:c}=cc({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>o,getRows:()=>t.current.getAllFilteredRows(),getRowId:n,getRootElement:l,disableKeyboardShortcut:i});a.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function fc(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:n,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:c}=o.current,d=i.current;if(d&&(n!==void 0&&n>=0&&Rn(d,n,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;Dl(d,l.unpinnedColsWithWidth.findIndex(m=>m.field===g.field),l)}}},[t])}function gc(e){return a.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function pc(e){const{ensureGridFocus:t,setKeyboardMode:o,setFocusedCell:n,getRowId:r,onCellClick:i}=e,l=a.useCallback(d=>{t(),o(!1),n({id:r(d.row),field:d.field,rowIndex:d.rowIndex}),i?.(d)},[i,o,n,t,r]),c=a.useCallback(d=>{t(),n({id:null,field:d}),o(!1)},[t,n,o]);return{handleCellClick:l,handleHeaderClick:c}}function hc({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const d=e||pn;return s.jsx(d,{page:o,pageSize:n.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...n,page:u}),onPageSizeChange:u=>l({...n,pageSize:u,page:0}),localeText:Nr(c),...t})}function wc({loading:e,error:t,noRowsLabel:o,filteredRowCount:n,dataRowCount:r,filterModel:i}){return s.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${Kr(t)}`:"",!e&&!t&&(n===0?o:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:"")]})}function mc(e){const{headerRowCount:t,pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+o+i+n,topBase:t+1,centerOffset:t+l+1,bottomBase:t+o+i+1,bottomRowIndexOffset:o+r}}function xc(e){const{columnGroupingModel:t,pinnedTopCount:o,pinnedBottomCount:n,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:c,paginatedUnpinnedRowCount:d,sortedUnpinnedRowCount:u}=e,{page:g,pageSize:m}=l;return a.useMemo(()=>mc({headerRowCount:1+jr(t),pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r?d:u,totalCenterRowCount:r&&i==="server"?Math.max(c,d):u,pageOffset:r?g*m:0}),[t,o,n,r,d,u,i,c,g,m])}function bc(e){const{toolbar:t,toolbarSlotProps:o,apiRef:n,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,pivotMode:d,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:m,onPivotModelChange:x,filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,disableColumnReorder:p,columnGroupingModel:b,moveColumn:y,resetColumnOrder:C,forceColumnsOpen:N,onColumnsPanelClose:T}=e;return a.useMemo(()=>t?{apiRef:n,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,...d||u||g?{pivotModel:m,onPivotModelChange:x}:{},filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,onColumnReorder:p?void 0:(P,O)=>{fn(b,P,O)&&y(P,O)},onColumnOrderReset:p?void 0:C,forceColumnsOpen:N,onColumnsPanelClose:T,...o}:null,[t,p,y,C,r,n,i,l,c,d,u,g,m,x,v,h,f,w,N,T,o,b])}function vc(e){const{rows:t,columns:o,getRowId:n,rowHeight:r,headerHeight:i,autoHeight:l=!1,density:c,checkboxSelection:d=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:g=!1,disableClipboardCopy:m=!1,rowSelectionModel:x,onRowSelectionModelChange:v,onRowClick:h,onRowDoubleClick:f,onCellClick:w,filterModel:p,onFilterModelChange:b,sortModel:y,onSortModelChange:C,pagination:N=!1,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P=[10,25,50,100],pinnedColumns:O,onPinnedColumnsChange:W,pinnedRows:X,getDetailPanelContent:S,getDetailPanelHeight:M,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,pinCheckboxColumn:L=!0,pinExpandColumn:A=!0,disableColumnReorder:q=!1,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,height:oe,rowReordering:Z=!1,onRowOrderChange:de,loading:ae=!1,treeData:ne=!1,getTreeDataPath:se,defaultGroupingExpansionDepth:re,groupingColDef:B,rowGroupingModel:D,aggregationModel:$,onAggregationModelChange:R,getAggregationPosition:U,isCellEditable:G,processRowUpdate:V,onProcessRowUpdateError:Y,dataSource:H,multiSort:j=!1,sortingMode:z="client",filterMode:k="client",paginationMode:F="client",rowCount:Q,slots:ee,slotProps:ce,pivotMode:fe=!1,pivotModel:ge,onPivotModelChange:be,className:Ce="",style:ue,onRowsScrollEnd:me,ariaLabel:ve,initialState:Se,onStateChange:le,columnVisibilityModel:ye,onColumnVisibilityModelChange:Le,listView:xe=!1,listViewColumn:ke,columnGroupingModel:ie,noRowsLabel:pe="No Data",localeText:we,apiRef:Me,overscanRowCount:Pe=3}=e,De=Jd(o),Qe=we?.noRowsLabel??pe,Yt=D||yi,So=ws({initialState:Se,sortModel:y,onSortModelChange:C,filterModel:p,onFilterModelChange:b,aggregationModel:$,onAggregationModelChange:R,columnVisibilityModel:ye,onColumnVisibilityModelChange:Le,pinnedColumns:O,onPinnedColumnsChange:W,pivotModel:ge,onPivotModelChange:be,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P,rowSelectionModel:x,onRowSelectionModelChange:v,density:c}),{sortModel:$e,handleSortModelChange:ko,filterModel:Be,handleFilterModelChange:Eo,aggregationModel:Ge,handleAggregationModelChange:Ou,columnVisibilityModel:at,handleColumnVisibilityModelChange:_n,pinnedColumns:Sn,handlePinnedColumnsChange:Du,currentPivotModel:Zi,handlePivotModelChange:Au,effectivePaginationModel:Ae,handlePaginationModelChange:Nt,selectedRowIds:$u,handleRowSelectionModelChange:kn,density:el}=So,Rt=md({rows:t,columns:De,pivotMode:fe,pivotModel:Zi,filterModel:Be,sortModel:$e,hasDataSource:!!H,hierarchyRequested:ne||Yt.length>0}),dt=Rt.isActive,{rowReordering:ct,hierarchyRowGroupingModel:Gu,isTreeDataRequested:Wu,isTreeData:Mo,isRowGrouping:Pt,isHierarchyEnabled:No,hasGroupingColumn:Hu,pagination:Ve,listView:Jt}=zd({rowGroupingModel:Yt,treeData:ne,hasTreeDataPath:!!se,isPivotActive:dt,rowReordering:Z,hasGroupingColDef:!!B,pagination:N,paginationMode:F,listView:xe,hasListViewColumn:!!ke}),{rowHeight:Ze,headerHeight:tl}=ys({rowHeight:r,headerHeight:i,density:el}),Bu=Rt.rows,Vu=Rt.columns,{activeColumns:ut,effectivePinnedColumns:It}=Kd({baseColumns:Vu,pinnedColumns:Sn,hasGroupingColumn:Hu,groupingColDef:B,isTreeData:Mo,getTreeDataPath:se}),En=na(ut,at),[zu,Ku]=pd(Ge),Qt=a.useRef(null),Mn=a.useRef(null),ol=!dt&&n||jd,Nn=gc(Qt),Pn=Oa({rows:Bu,getRowId:ol,columns:ut,rowHeight:Ze,headerHeight:tl,columnVisibilityModel:at,initialState:e.initialState,syncRows:!H}),{state:Ee,apiRef:Zt,setRows:ju,replaceRow:Uu,setColumns:Xu,setDimensions:qu,setDataSourceLoading:Yu,setDataSourceError:Ru,setRowCount:Ju}=Pn,{getRowIdOf:Ne,getRowIdOfInEvents:Qu}=Ud(Ee.rows.idByRow);Xd(Me,Zt);const Zu=Ee.dataSource.loading,et=ae||Zu,Po=a.useMemo(()=>Ee.rows.allRows.map(pt=>Ee.rows.idRowsLookup.get(pt)),[Ee.rows]),{treeDataHandlers:Io,rowGroupingHandlers:In,activeHierarchyHandlers:Tt,rowMetaMap:ze}=Ja({rows:Po,getRowId:Ne,getTreeDataPath:se,isTreeDataRequested:Wu,isTreeData:Mo,columns:ut,rowGroupingModel:Gu,isRowGrouping:Pt,aggregationModel:Ge,defaultGroupingExpansionDepth:re,filterModel:Be,sortModel:$e,getAggregationPosition:U,columnLookup:En,filterMode:k,sortingMode:z}),nl=Za({rows:Po,getRowId:Ne,columns:ut,processRowUpdate:V,onProcessRowUpdateError:Y,onRowChange:(pt,Pf)=>{Uu(Pf,pt)}}),eo=Zs({selectedRowIds:$u,rowsLookup:Ee.rows.idRowsLookup,rowMetaMap:ze,enabled:!H&&!dt&&F==="client"&&k==="client",onSelectionModelChange:kn}),rl=ud({dataSource:H,sortModel:$e,filterModel:Be,paginationModel:Ae,paginationMode:F,sortingMode:z,filterMode:k,aggregationModel:Ge,rowGroupingActive:Pt,getRowId:ol,setRows:ju,setRowCount:Ju,setDataSourceLoading:Yu,setDataSourceError:Ru,onAggregationResults:Ku,onPaginationModelChange:Nt});gd({enabled:Mo&&!!H,treeNodes:Io.treeNodes,isGroupExpanded:Io.isGroupExpanded,getNodePath:Io.getNodePath,toggleExpansion:Io.toggleExpansion,fetchChildren:rl.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:Tn,handleDetailPanelToggle:il,detailPanelHeights:ef,reportDetailPanelHeight:tf}=Hs({hasDetailPanel:!!S,controlledExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,rowMetaMap:ze}),{effectiveColumns:ll,hierarchyField:Ln,orderedColumns:sl,visibleOrderedColumns:al,renderOrderedColumns:of,navigationColumns:dl,columnIndexMap:cl,columnWidths:to,effectiveColumnOrder:nf,columnReorderHandlers:rf,moveColumn:ul,resetColumnOrder:fl,handleColumnResize:lf}=Ts({activeColumns:ut,isHierarchyEnabled:No,isRowGrouping:Pt,isTreeData:Mo,activeHierarchyHandlers:Tt,columnVisibilityModel:at,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,disableColumnReorder:q,pivotMode:dt,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,initialState:Se,setColumns:Xu,pinnedColumns:It,getRowId:Qu,aggregationModel:Ge,groupingRows:Pt?In.groupingRows:void 0});zs({onStateChange:le,sortModel:$e,filterModel:Be,effectivePaginationModel:Ae,columnWidths:to,effectiveColumnOrder:nf,columnVisibilityModel:at,pinnedColumns:Sn,density:el});const To=_s({effectiveRows:Po,activeHierarchyHandlers:Tt,filterMode:k,filterModel:Rt.pipelineFilterModel,sortModel:Rt.pipelineSortModel,sortingMode:z,pagination:Ve,paginationMode:F,effectivePaginationModel:Ae,pinnedRows:X,getRowId:Ne,columnLookup:En,hierarchyField:Ln}),{filteredRows:gl,dataRows:Lt,pinnedTopRows:We,pinnedBottomRows:Ke,sortedUnpinnedRows:Ue,paginatedUnpinnedRows:Lo,allRenderableRows:Fo}=To,Fn=Ve?Lo:Ue;ra({paginationModel:Ae,currentPage:To.currentPage,enabled:Ve&&!et&&Ue.length>0,onPaginationModelChange:Nt});const Oo=Cs({paginationMode:F,hasDataSource:!!H,dataSourceRowCount:Ee.pagination.rowCount,rowCountProp:Q,clientRowCount:Ue.length}),{rowSelection:On,handleRowClick:Dn,handleSelectionChange:An}=Qs({dataRows:Lt,getRowId:Ne,isPivotActive:dt,selectedRowIds:eo,onSelectionModelChange:kn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:No,rowMetaMap:ze,activeHierarchyHandlers:Tt,onRowClick:h});oa({apiRef:Pn.apiRef,sortModel:$e,multiSort:j,onSortModelChange:ko,filterModel:Be,onFilterModelChange:Eo,paginationModel:Ae,onPaginationModelChange:Nt,selectedRowIds:eo,getPendingRowSelectionModel:So.getPendingRowSelectionModel,onRowSelectionModelChange:kn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>qe(pt,ze),getVisibleRows:()=>[...We,...Fn,...Ke],getAllFilteredRows:()=>qd({hierarchyHandlers:Tt,pinnedTopRows:We,sortedUnpinnedRows:Ue,pinnedBottomRows:Ke,rowMetaMap:ze,getRowId:Ne,hierarchyField:Ln,dataRows:Lt}),visibleColumns:of});const sf=Da({rows:Po,getRowId:Ne,onRowOrderChange:de,rowReordering:ct}),{aggregationResult:$n,isLoading:af}=hi({rows:Lt,columns:ut,aggregationModel:dt?Al:Ge,isServerSide:Vr({dataSource:H,paginationMode:F,sortingMode:z,filterMode:k}),dataSource:H,filterModel:Be,sortModel:$e,serverAggregationResults:zu}),Gn=Object.keys(Ge).length>0&&!dt;Zd({apiRef:Zt,hasAggregation:Gn,aggregationResult:$n,aggregationModel:Ge,isRowGrouping:Pt,rowGroupingHandlers:In,rowMetaMap:ze,columns:ut,getRowId:Ne,hierarchyField:Ln});const Ie=Fl({rowHeight:Ze,pagination:Ve,paginatedUnpinnedRows:Lo,sortedUnpinnedRows:Ue,expandedRowIds:Tn,getDetailPanelHeight:M,detailPanelHeights:ef,pinnedTopRowsLength:We.length,pinnedBottomRowsLength:Ke.length,pinnedTopRows:We,pinnedBottomRows:Ke,visibleOrderedColumns:al,pinnedColumns:It,columnWidths:to,viewportWidth:Ee.dimensions.viewportWidth||1e3,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,paginationMode:F,isLoading:Ee.dataSource.loading,pageSize:Ae.pageSize,getRowId:Ne}),oo=rd({pinnedTopRows:We,centerRows:Fn,pinnedBottomRows:Ke,columns:al,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?Tn:void 0,rowMetaMap:ze,getRowId:Ne}),pl=a.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);uc({apiRef:Zt,columns:pl,getRowId:Ne,containerRef:Qt,disableKeyboardShortcut:m}),fc({apiRef:Zt,viewportRef:Mn,layout:Ie,rowHeight:Ze});const{scrollTop:df,scrollLeft:cf,overscanRows:uf,handleScroll:ff,setViewportElement:gf}=Gs({onRowsScrollEnd:me,overscanRowCount:Pe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:qu,viewportRef:Mn}),Te=Ss({layout:Ie,scrollTop:df,scrollLeft:cf,viewportWidth:Ee.dimensions.viewportWidth,viewportHeight:Ee.dimensions.viewportHeight,autoHeight:l,rowReordering:ct,hasDetailPanel:ft,checkboxSelection:d,pinCheckboxColumn:L,pinExpandColumn:A,overscanRows:uf}),{handleSort:hl,handleSortAdd:wl}=ea({sortModel:$e,onSortModelChange:ko}),Do=d||!u,{focusedCell:ml,setFocusedCell:pf,viewportTabIndex:hf,ensureGridFocus:wf,handleFocus:mf,handleBlur:xf,handleKeyDown:bf,handleMouseDownCapture:vf}=gs({allRenderableRows:Fo,navigationColumns:dl,checkboxSelection:d,selectedRowIds:eo,handleSelectionChange:An,handleDetailPanelToggle:il,editingHandlers:nl,setKeyboardMode:Nn,sortModel:$e,handleSort:hl,handleSortAdd:wl,multiSort:j,isCellEditable:G,pagination:Ve,pageSize:Ae.pageSize,virtualization:Te,viewportRef:Mn,pinnedTopRowCount:We.length,getRowId:Ne,rowMetaMap:ze,getSpanOrigin:oo.getSpanOrigin,onRowActivate:Dn,toggleRowExpansion:Tt?.toggleExpansion,handleSelectAll:On.selectAll,rowSelectionEnabled:Do,multipleRowSelectionEnabled:!g,pinCheckboxColumn:L,pinExpandColumn:A,rowHeight:Ze}),{handleCellClick:yf,handleHeaderClick:Cf}=pc({ensureGridFocus:wf,setKeyboardMode:Nn,setFocusedCell:pf,getRowId:Ne,onCellClick:w}),{handleHideColumn:_f,handlePinColumn:Sf}=ta({columnVisibilityModel:at,onColumnVisibilityModelChange:_n,pinnedColumns:Sn,onPinnedColumnsChange:Du}),no=xc({columnGroupingModel:ie,pinnedTopCount:We.length,pinnedBottomCount:Ke.length,pagination:Ve,paginationMode:F,paginationModel:Ae,paginationRowCount:Oo,paginatedUnpinnedRowCount:Lo.length,sortedUnpinnedRowCount:Ue.length}),Wn=ld({spanning:oo,renderContext:Te.renderContext,offsetTop:Te.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Hn=Fs({renderContext:Wn.renderContext,pinnedTopRows:We,pinnedBottomRows:Ke,paginatedUnpinnedRows:Lo,sortedUnpinnedRows:Ue,pagination:Ve,getRowId:Ne}),Ao=sd({spanning:oo,firstColumnIndex:Te.renderContext.firstColumnIndex,lastColumnIndex:Te.renderContext.lastColumnIndex,virtualColumns:Te.virtualColumns,layout:Ie,rows:Hn});Xs({paginationRequested:N,isRowGrouping:Pt,autoHeight:l,viewportHeight:Ee.dimensions.viewportHeight,renderedRowCount:Hn.length,totalRowCount:We.length+Fn.length+Ke.length,pinnedRowsIgnored:No&&!!(X?.top?.length||X?.bottom?.length),scrollHeight:Te.totalHeight,listViewWithoutColumn:xe&&!ke,listViewRowCount:Jt&&ke?Fo.length:0});const{allSelected:kf,someSelected:Ef}=On,Ft=ad(ie,rf),Mf=a.useMemo(()=>ll.some(pt=>!!pt.rowSpan),[ll]),gt=ia();Ys(Qt);const xl=ee?.noRowsOverlay,bl=ee?.loadingOverlay,Bn=bl?s.jsx(bl,{...ce?.loadingOverlay}):void 0,vl=xl?s.jsx(xl,{...ce?.noRowsOverlay}):void 0,$o=ee?.footer,Nf=et&&Fo.length>0&&F!=="infinite",yl=ee?.toolbar,Cl=bc({toolbar:ee?.toolbar,toolbarSlotProps:ce?.toolbar,apiRef:Zt,orderedColumns:sl,baseColumns:De,aggregationModel:Ge,onAggregationModelChange:Ou,pivotMode:fe,pivotModelProp:ge,onPivotModelChangeProp:be,pivotModel:Zi,onPivotModelChange:Au,filterModel:Be,onFilterModelChange:Eo,columnVisibilityModel:at,onColumnVisibilityModelChange:_n,disableColumnReorder:q,columnGroupingModel:ie,moveColumn:ul,resetColumnOrder:fl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),Vn={rowReordering:ct,columnIndexMap:cl,editingHandlers:nl,isCellEditable:G,selectedRowIds:eo,checkboxSelection:d,onRowClick:Dn,onRowDoubleClick:f,onCellClick:yf,onSelectionChange:An,columnWidths:to,pinnedColumns:It,hasDetailPanel:ft,expandedRowIds:Tn,getDetailPanelContent:S,getDetailPanelHeight:M,onDetailPanelToggle:il,onDetailPanelHeightChange:tf,pinCheckboxColumn:L,pinExpandColumn:A,focusedCell:ml,colspanMap:oo.colspanMap,rowSpanningCaches:oo.rowSpanningCaches,rowHeight:Ze,rowMetaMap:ze};return s.jsxs("div",{ref:Qt,className:["ogx",Ce,l&&"ogx--auto-height",!l&&oe===void 0&&ue?.height===void 0&&"ogx--fill",Mf&&"ogx--row-spanning",Jt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...ue,height:oe??ue?.height,"--ogx-row-height":`${Ze}px`,"--ogx-header-height":`${tl}px`},"aria-busy":et,children:[yl&&Cl&&s.jsx(Hr.Provider,{value:gt.toolbarHost,children:s.jsx(aa,{component:yl,toolbarProps:Cl})}),s.jsx(Vd,{isOpen:gt.standalonePanelOpen,containerRef:Qt,panelRef:gt.standalonePanelRef,columns:sl,columnVisibilityModel:at,disableColumnReorder:q,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:_n,onColumnMove:ul,onColumnOrderReset:fl,columnGroupingModel:ie}),Jt&&ke&&s.jsx(yd,{ariaLabel:ve,allRenderableRows:Fo,dataRowCount:Lt.length,pinnedTopRowCount:We.length,pinnedBottomRowCount:Ke.length,unpinnedRowCount:Ue.length,pagination:Ve,effectivePaginationModel:Ae,currentPage:To.currentPage,pageSizeOptions:P,selectedRowIds:eo,listViewColumn:ke,columnsByField:En.byField,rowMetaMap:ze,noRowsLabel:Qe,rowHeight:Ze,checkboxSelection:d,paginationMode:F,serverRowCount:Oo,paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,localeText:Nr(we),onRowClick:Dn,onRowDoubleClick:f,onSelectionChange:An,onPaginationModelChange:Nt,onRowsScrollEnd:me,getRowId:Ne,multiselectable:Do&&!g,selectable:Do,onToggleExpansion:Tt?.toggleExpansion,loading:et,loadingOverlay:Bn,noRowsOverlay:vl,showPaginationControls:!$o}),!Jt&&s.jsx("div",{ref:gf,className:"ogx__viewport",onScroll:ff,role:"grid","aria-label":ve||"Data grid","aria-rowcount":no.rowCount,"aria-colcount":dl.length,"aria-multiselectable":Do&&!g,"aria-busy":et,tabIndex:hf,onKeyDownCapture:()=>{Nn(!0)},onMouseDownCapture:vf,onKeyDown:bf,onFocus:mf,onBlur:xf,children:s.jsxs("div",{className:"ogx__content",style:{width:It?.right?.length?`max(100%, ${Te.totalWidth}px)`:Te.totalWidth},role:"presentation",children:[s.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[s.jsx(qr,{columns:Ao,allColumns:pl,columnGroupingModel:ie,checkboxSelection:d,allSelected:kf,someSelected:Ef,onSelectAll:On.selectAll,sortModel:$e,onSort:hl,onSortAdd:wl,multiSort:j,onColumnResize:lf,columnWidths:to,pinnedColumns:It,focusedCell:ml,columnIndexMap:cl,onHeaderClick:Cf,onDragStart:Ft.onDragStart,onDragOver:Ft.onDragOver,onDragEnd:Ft.onDragEnd,onDrop:Ft.onDrop,draggedColumn:Ft.draggedColumn,dragOverColumn:Ft.dragOverColumn,rowReordering:ct,hasDetailPanel:ft,pinCheckboxColumn:L,pinExpandColumn:A,aggregationModel:Ge,onHideColumn:_f,onManageColumns:gt.openColumnsPanel,onPinColumn:Sf}),s.jsx(vi,{...Vn,rows:We,position:"top",ariaRowIndexBase:no.topBase,columns:Ao,pinnedRows:X,getRowId:Ne})]}),!et&&!Ee.dataSource.error&&gl.length===0&&s.jsx(ca,{noRowsLabel:Qe,width:Te.totalWidth,overlay:vl}),s.jsx(Wd,{...Vn,virtualContainerHeight:Te.totalHeight-Te.pinnedTopHeight-Te.pinnedBottomHeight,offsetTop:Wn.offsetTop,effectiveLoading:et,visibleRows:Hn,baseColumns:De,virtualColumns:Ao,viewportWidth:Ee.dimensions.viewportWidth,rowReorderHandlers:sf,paginationMode:F,dataSourceLoading:Ee.dataSource.loading,sortedUnpinnedRowCount:Ue.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:Wn.renderContext.lastRowIndex,ariaRowIndexOffset:no.centerOffset,loadingOverlay:Bn}),s.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[s.jsx(vi,{...Vn,rows:Ke,position:"bottom",rowIndexOffset:no.bottomRowIndexOffset,ariaRowIndexBase:no.bottomBase,columns:Ao,pinnedRows:X,getRowId:Ne}),Gn&&In.rootAggregationPosition!==null&&s.jsx(da,{columns:Te.virtualColumns,aggregationModel:Ge,aggregationResult:$n,columnWidths:to,rowHeight:Ze,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,pinnedColumns:It,loading:af})]})]})}),$o&&s.jsx($o,{apiRef:Pn.apiRef,aggregationModel:Ge,aggregationResult:Gn?$n:null,rowCount:No&&F!=="server"?Lt.length:Oo,pagination:Ve,paginationModel:Ae,pageSizeOptions:P,onPaginationModelChange:Nt,...ce?.footer}),!Jt&&!$o&&Ve&&s.jsx(hc,{paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,page:To.currentPage,paginationModel:Ae,rowCount:Oo,pageSizeOptions:P,onPaginationModelChange:Nt,localeText:we}),s.jsx(wc,{loading:et,error:Ee.dataSource.error,noRowsLabel:Qe,filteredRowCount:gl.length,dataRowCount:Lt.length,filterModel:Be}),Nf&&s.jsx(Cd,{overlay:Bn}),s.jsx(fa,{error:Ee.dataSource.error,onRetry:H?rl.fetchRows:void 0})]})}function yc({rows:e=5,columns:t=5}){return s.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((o,n)=>s.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-content"})},i))},n))})}const Cc=300;function kt(e){return"field"in e&&!("items"in e)}function Mi(e,t){return e.find(o=>kt(o)&&o.field===t)}function Ni(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((o,n)=>Ni(o,t[n])):!1}function _c(e,t){return e===t?!0:kt(e)&&kt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Ni(e.value,t.value):!kt(e)&&!kt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&yn(e.items,t.items):!1}function yn(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>_c(o,t[n]))}function Sc(e){return(e.valueOptions??[]).map((t,o)=>t!==null&&typeof t=="object"?{key:String(o),value:t.value,label:t.label}:{key:String(o),value:t,label:String(t)})}function Pi(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Ii(e,t){return e==null?"":t.type==="date"||e instanceof Date?Xn(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(o=>String(o)).join(", "):String(e)}function Ti(e,t){return t==="isAnyOf"?e.split(",").map(o=>o.trim()).filter(o=>o!==""):e}function kc(e,t){if(!Yo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Ec=({col:e,item:t,resetToken:o,onChange:n})=>{const r=a.useId(),i=jl(e.type),l=i[0],c=t?.operator??l,d=i.includes(c)?i:[c,...i],u=!!t,g=e.headerName||e.field,[m,x]=a.useState(null),[v,h]=a.useState(o);v!==o&&(h(o),x(null));const f=a.useRef(n),w=a.useRef(t),p=a.useRef(e);a.useLayoutEffect(()=>{f.current=n,w.current=t,p.current=e});const b=a.useCallback((M,I)=>({id:w.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:M,value:I}),[e.field]),y=a.useCallback(M=>{const I=w.current;if(I?M===Ii(I.value,p.current):M.trim()==="")return;const L=I?.operator??l;f.current(b(L,Ti(M,L)))},[l,b]),C=a.useRef(null),N=a.useRef(y);a.useLayoutEffect(()=>{C.current=m,N.current=y}),a.useEffect(()=>()=>{const M=C.current;C.current=null,M!==null&&N.current(M)},[]),a.useEffect(()=>{if(m===null)return;const M=setTimeout(()=>{C.current=null,y(m),x(null)},Cc);return()=>clearTimeout(M)},[m,y]);const T=M=>{const I=m!==null?Ti(m,M):t?.value;x(null),n(b(M,kc(I,M)))},E=()=>{x(null),n(null)},P=!Yo.has(c),O=Sc(e),W=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,X=`Filter value for ${g}`;let S=null;if(P&&e.type==="boolean")S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:M=>{M.target.value===""?n(null):n(b(c,M.target.value))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]});else if(P&&e.type==="singleSelect"&&O.length>0&&c==="isAnyOf"){const M=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];S=s.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(O.length,4),value:O.filter(I=>M.some(_=>Pi(I,_))).map(I=>I.key),onChange:I=>{const _=new Set(Array.from(I.target.selectedOptions,L=>L.value));n(b("isAnyOf",O.filter(L=>_.has(L.key)).map(L=>L.value)))},"aria-label":X,children:O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))})}else if(P&&e.type==="singleSelect"&&O.length>0&&(c==="is"||c==="not")){const M=O.find(I=>Pi(I,t?.value));S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:M?.key??"",onChange:I=>{const _=O.find(L=>L.key===I.target.value);n(b(c,_?_.value:""))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))]})}else P&&(S=s.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:W,type:e.type==="date"?"date":"text",value:m??Ii(t?.value,e),onChange:M=>x(M.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":X}));return s.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[s.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),s.jsxs("div",{className:"ogx-filter__controls",children:[s.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:c,onChange:M=>T(M.target.value),"aria-label":`Filter operator for ${g}`,children:d.map(M=>s.jsx("option",{value:M,children:M},M))}),S,u&&s.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},Li=({filterModel:e,columns:t,onFilterModelChange:o})=>{const n=a.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=a.useState(null),[c,d]=a.useState(n),[u,g]=a.useState(0);if(c!==n){d(n);const w=!yn(c,n),p=i!==null&&yn(i,n);w&&!p&&g(b=>b+1)}const m=a.useCallback((w,p)=>{const b=n.findIndex(C=>kt(C)&&C.field===w);let y;if(b===-1){if(!p)return;y=[...n,p]}else p?y=n.map((C,N)=>N===b?p:C):y=n.filter((C,N)=>N!==b);l(y),o({...e,items:y})},[n,e,o]),x=a.useCallback(w=>{o({...e,logicOperator:w})},[e,o]),v=t.filter(w=>w.filterable!==!1),h=v.filter(w=>Mi(n,w.field)).length,f=n.length-h;return s.jsxs(s.Fragment,{children:[n.length>1&&s.jsxs("div",{className:"ogx-filter__logic-bar",children:[s.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),s.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)"}),s.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)"})]}),f>0&&s.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:f===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${f} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),v.length===0?s.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):v.map(w=>s.jsx(Ec,{col:w,item:Mi(n,w.field),resetToken:u,onChange:p=>m(w.field,p)},w.field))]})},Fi=["sum","avg","count","min","max"];function Oi(){return s.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:[s.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),s.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Mc({anchorRef:e,columns:t,model:o,onChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),[d,u]=a.useState(null);a.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const _=e.current.getBoundingClientRect();return{top:_.bottom+6,right:xt()-_.right}},[e]);a.useEffect(()=>{c(g());const _=()=>c(g());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[g]),a.useEffect(()=>{function _(A){i.current&&!i.current.contains(A.target)&&e.current&&!e.current.contains(A.target)&&r()}function L(A){A.key==="Escape"&&r()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",L)}},[e,r]);const m=new Set(o.rowFields),x=new Set(o.columnFields),v=new Set(o.valueFields.map(_=>_.field)),h=_=>m.has(_)||x.has(_)||v.has(_),f=_=>t.find(L=>L.field===_),w=_=>f(_)?.headerName??_,p=_=>{const L=f(_)?.availableAggregationFunctions;return L?Fi.filter(A=>L.includes(A)):Fi},b=_=>_.aggregable!==!1&&(_.type==="number"||_.aggregable===!0)&&p(_.field).length>0,y=_=>_.groupable!==!1;function C(_){m.has(_)||n({...o,rowFields:[...o.rowFields,_]})}function N(_){x.has(_)||n({...o,columnFields:[...o.columnFields,_]})}function T(_){v.has(_)||n({...o,valueFields:[...o.valueFields,{field:_,aggFn:p(_)[0]??"sum"}]})}function E(_){n({...o,rowFields:o.rowFields.filter((L,A)=>A!==_)})}function P(_){n({...o,columnFields:o.columnFields.filter((L,A)=>A!==_)})}function O(_){n({...o,valueFields:o.valueFields.filter((L,A)=>A!==_)})}function W(_,L){n({...o,valueFields:o.valueFields.map((A,q)=>q===_?{...A,aggFn:L}:A)})}function X(){n({rowFields:[],columnFields:[],valueFields:[]})}const S=o.rowFields.length+o.columnFields.length+o.valueFields.length,M=t.filter(_=>!h(_.field)&&(y(_)||b(_))),I=s.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[s.jsxs("div",{className:"ogx-pivot-panel__header",children:[s.jsxs("span",{className:"ogx-pivot-panel__title",children:[s.jsx(Oi,{}),"Pivot Mode"]}),S>0&&s.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:X,title:"Reset pivot",children:"Reset"})]}),s.jsxs("div",{className:"ogx-pivot-panel__body",children:[s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:o.rowFields.map((_,L)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(L),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Row Fields`,children:"×"})]},`${L}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:o.columnFields.map((_,L)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(L),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Column Fields`,children:"×"})]},`${L}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),s.jsx("div",{className:`ogx-pivot-chips${o.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:o.valueFields.map((_,L)=>{const A=p(_.field),q=A.includes(_.aggFn)?A:[_.aggFn,...A];return s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[w(_.field),s.jsx("select",{className:"ogx-pivot-chip__fn-select",value:_.aggFn,onChange:K=>W(L,K.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${w(_.field)}`,children:q.map(K=>s.jsx("option",{value:K,children:K.toUpperCase()},K))}),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>O(L),title:`Remove ${w(_.field)}`,"aria-label":`Remove ${w(_.field)} (${_.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${L}:${_.field}:${_.aggFn}`)})})]}),s.jsx("hr",{className:"ogx-pivot-panel__divider"}),s.jsxs("div",{children:[s.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),s.jsxs("div",{className:"ogx-pivot-fields",children:[M.map(_=>{const L=b(_),A=y(_),q=_.headerName??_.field;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[s.jsx("span",{className:`ogx-pivot-field-btn${L?" ogx-pivot-field-btn--numeric":""}`,children:q}),s.jsxs("div",{className:"ogx-pivot-field-actions",children:[A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(_.field),title:"Add to Row Fields","aria-label":`Add ${q} to Row Fields`,children:"Row"}),A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>N(_.field),title:"Add to Column Fields","aria-label":`Add ${q} to Column Fields`,children:"Col"}),L&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>T(_.field),title:"Add to Value Fields","aria-label":`Add ${q} to Value Fields`,children:"Val"})]})]},_.field)}),M.length===0&&s.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return d?tt.createPortal(I,d):null}function Nc(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Pc(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Di(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Ic({value:e="",onChange:t,placeholder:o="Search...",debounceMs:n=250}){const[r,i]=a.useState(()=>e.length>0),[l,c]=a.useState(e),d=a.useRef(null),u=a.useRef(null),g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t},[t]);const m=a.useRef(e),x=a.useRef(e);a.useEffect(()=>{e!==x.current&&(x.current=e,Di(e)!==Di(m.current)&&(c(e),m.current=e,i(e.length>0)))},[e]),a.useEffect(()=>{const b=setTimeout(()=>{l!==m.current&&(m.current=l,g.current(l))},n);return()=>clearTimeout(b)},[l,n]);const v=a.useRef(l);a.useLayoutEffect(()=>{v.current=l}),a.useEffect(()=>()=>{const b=v.current;b!==m.current&&(m.current=b,g.current(b))},[]);const h=a.useCallback(()=>{i(!0),requestAnimationFrame(()=>d.current?.focus())},[]),f=a.useCallback(b=>{b.stopPropagation(),c(""),m.current="",g.current(""),d.current?.focus()},[]),w=a.useCallback(()=>{i(!0)},[]),p=a.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return a.useEffect(()=>{const b=y=>{u.current&&!u.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),s.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:h,children:[s.jsx("div",{className:"ogx-global-search__icon-wrapper",children:s.jsx(Nc,{})}),s.jsx("input",{ref:d,className:"ogx-global-search__input",value:l,onChange:b=>c(b.target.value),onFocus:w,onBlur:p,placeholder:o,"aria-label":"Global Search",autoComplete:"off"}),l&&s.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:s.jsx(Pc,{})})]})}const yo=8;function Ut({title:e,children:t,placement:o="top",enterDelay:n=200,leaveDelay:r=0}){const[i,l]=a.useState(!1),[c,d]=a.useState({top:0,left:0}),[u,g]=a.useState(null),m=a.useRef(null),x=a.useRef(null),v=a.useId(),h=a.useCallback(()=>{if(!x.current)return;const N=x.current.getBoundingClientRect(),T=N.left+N.width/2,E=N.top+N.height/2;switch(o){case"bottom":d({top:N.bottom+yo,left:T});break;case"left":d({top:E,left:N.left-yo});break;case"right":d({top:E,left:N.right+yo});break;default:d({top:N.top-yo,left:T})}},[o]),f=a.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null},[]);a.useLayoutEffect(()=>{if(!i)return;h();const N=T=>{T.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),document.addEventListener("keydown",N),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),document.removeEventListener("keydown",N)}},[i,h,f]),a.useEffect(()=>f,[f]);const w=()=>{f(),m.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},n)},p=()=>{f(),m.current=setTimeout(()=>{l(!1)},r)},b=a.useCallback(N=>{x.current=N?N.firstElementChild??N:null},[]),y=i&&!!e&&u!==null;let C=t;if(y&&a.isValidElement(t)){const N=t,T=N.props["aria-describedby"];C=a.cloneElement(N,{"aria-describedby":T?`${T} ${v}`:v})}return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:b,style:{display:"inline-block",lineHeight:0},onMouseEnter:w,onMouseLeave:p,onFocus:w,onBlur:p,children:C}),y&&u&&tt.createPortal(s.jsx("div",{id:v,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${o}`,style:{top:c.top,left:c.left,position:"fixed",zIndex:99999},children:e}),u)]})}const Tc=Object.keys(so);function Lc(e){return Object.prototype.hasOwnProperty.call(so,e)}function Ai(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Lc))):Tc}function $i(){return s.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:s.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Fc(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Gi(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Oc({anchorRef:e,aggregationModel:t,aggregableColumns:o,onFunctionChange:n,onClearAll:r,onClose:i,activeCount:l}){const c=a.useRef(null),[d,u]=a.useState({top:0,right:0}),[g,m]=a.useState(null);a.useLayoutEffect(()=>{m(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const h=e.current.getBoundingClientRect();return{top:h.bottom+6,right:xt()-h.right}},[e]);a.useEffect(()=>{u(x());const h=()=>u(x());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[x]),a.useEffect(()=>{function h(f){c.current&&!c.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[e,i]),a.useEffect(()=>{function h(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i]);const v=s.jsxs("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:d.top,right:d.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx($i,{}),"Summaries"]}),l>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),s.jsx("div",{className:"ogx-toolbar__panel-body",children:o.length===0?s.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",s.jsx("br",{}),"Set ",s.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):o.map(h=>{const f=t[h.field]||"none";return s.jsxs("div",{className:"ogx-toolbar__agg-row",children:[s.jsx("span",{className:"ogx-toolbar__agg-label",title:h.field,children:h.headerName||h.field}),s.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Ai(h)].map(w=>s.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===w?" ogx-toolbar__pill--active":""}`,onClick:()=>n(h.field,w),"aria-pressed":f===w,children:w},w))})]},h.field)})})]});return g?tt.createPortal(v,g):null}function Dc({anchorRef:e,columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:d,showNonHideableColumns:u}){const g=a.useRef(null),[m,x]=a.useState({top:0,right:0}),[v,h]=a.useState(null);a.useLayoutEffect(()=>{h(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:xt()-p.right}},[e]);a.useEffect(()=>{x(f());const p=()=>x(f());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[f]),a.useEffect(()=>{function p(b){g.current&&!g.current.contains(b.target)&&e.current&&!e.current.contains(b.target)&&d()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,d]),a.useEffect(()=>{function p(b){b.key==="Escape"&&d()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[d]);const w=s.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:m.top,right:m.right,width:280,padding:0},children:s.jsx(xn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return v?tt.createPortal(w,v):null}function Ac({anchorRef:e,columns:t,filterModel:o,onFilterModelChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),d=a.useRef(r);a.useLayoutEffect(()=>{d.current=r},[r]);const[u,g]=a.useState(null);a.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const m=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const f=e.current.getBoundingClientRect();return{top:f.bottom+6,right:xt()-f.right}},[e]);a.useEffect(()=>{c(m());const f=()=>c(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),a.useEffect(()=>{function f(w){w.key==="Escape"&&d.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=o.items?.length??0,v=()=>{n({...o,items:[],logicOperator:"and"})},h=s.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:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx(Gi,{}),"Filters",x>0&&s.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:v,title:"Clear all filters",children:"Clear all"}),s.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>d.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),s.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:s.jsx(Li,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?tt.createPortal(h,u):null}const $c={rowFields:[],columnFields:[],valueFields:[]};function Gc({columns:e=[],baseColumns:t,aggregationModel:o={},onAggregationModelChange:n,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:c,columnVisibilityModel:d={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:m,forceColumnsOpen:x,onColumnsPanelClose:v,children:h,rightContent:f,style:w,renderColumnsButton:p,renderFilterButton:b,renderAggregationButton:y,renderExportButton:C,renderQuickFilter:N,className:T,showNonHideableColumns:E}){const[P,O]=a.useState(null),W=P==="summaries",X=P==="pivot",S=P==="columns",M=P==="filters",I=k=>{P==="columns"&&k!=="columns"&&v?.(),O(k)},_=k=>I(P===k?null:k),L=k=>{P===k&&I(null)};a.useEffect(()=>{x&&O("columns")},[x]);const A=a.useContext(Hr),q=x!==void 0&&!!u;a.useEffect(()=>{if(!(!A||!q))return A.registerColumnsPanel()},[A,q]);const K=a.useRef(null),J=a.useRef(null),te=a.useRef(null),oe=a.useRef(null),Z=a.useRef(null),de=a.useRef(null),ae=a.useRef(null),ne=r??$c,se=ne.rowFields.length>0||ne.columnFields.length>0||ne.valueFields.length>0,re=t?new Set(t.map(k=>k.field)):null,B=e.filter(k=>k.aggregable!==!1&&(k.type==="number"||k.aggregable===!0)&&Ai(k).length>0&&(!re||re.has(k.field))),D=Object.keys(o).filter(k=>o[k]&&o[k]!=="none").length,$=a.useCallback((k,F)=>{if(!n)return;const Q={...o};F==="none"?delete Q[k]:Q[k]=F,n(Q)},[o,n]),R=a.useCallback(()=>{n?.({})},[n]),U=a.useCallback(k=>{if(!c)return;const F=k.trim().split(/\s+/).filter(Boolean),Q={...l||{},quickFilterValues:F,items:l?.items||[]};c(Q)},[l,c]),G=(l?.quickFilterValues??[]).join(" "),V=l?.items?.length||0,Y=new Set(e.filter(k=>d[k.field]!==!1).map(k=>k.field)),H=a.useCallback((k,F)=>{if(!u)return;const Q={...d,[k]:F};u(Q)},[d,u]),j=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(F=>{F.hideable!==!1&&(k[F.field]=!0)}),u(k)},[e,d,u]),z=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(F=>{F.hideable!==!1&&(k[F.field]=!1)}),u(k)},[e,d,u]);return s.jsxs("div",{className:["ogx-toolbar",T].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:w,children:[h&&s.jsx("div",{className:"ogx-toolbar__left",children:h}),s.jsx("div",{className:"ogx-toolbar__spacer"}),s.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&s.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:G,onChange:U}):s.jsx(Ic,{value:G,onChange:U,placeholder:"Search..."})}),u&&s.jsxs("div",{ref:Z,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[p?p({onClick:()=>_("columns"),isOpen:S,activeCount:e.length-Y.size}):s.jsx(Ut,{title:"Columns",children:s.jsx("button",{type:"button",ref:te,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>_("columns"),children:s.jsx(Fc,{})})}),S&&s.jsx(Dc,{anchorRef:p?Z:te,columns:e,visibleColumns:Y,onVisibilityChange:H,onShowAll:j,onHideAll:z,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>L("columns"),showNonHideableColumns:E})]}),c&&s.jsxs("div",{ref:de,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>_("filters"),isOpen:M,activeCount:V}):s.jsx(Ut,{title:"Filters",children:s.jsxs("button",{type:"button",ref:oe,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":M,onClick:()=>_("filters"),children:[s.jsx(Gi,{}),V>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),M&&s.jsx(Ac,{anchorRef:b?de:oe,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>L("filters")})]}),i&&s.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[s.jsx(Ut,{title:"Pivot",children:s.jsxs("button",{type:"button",ref:J,className:`ogx-toolbar__icon-btn${X?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":X,onClick:()=>_("pivot"),children:[s.jsx(Oi,{}),se&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),X&&s.jsx(Mc,{anchorRef:J,columns:t??e,model:ne,onChange:k=>{i?.(k)},onClose:()=>L("pivot")})]}),n&&s.jsxs("div",{ref:ae,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>_("summaries"),isOpen:W,activeCount:D}):s.jsx(Ut,{title:"Summaries",children:s.jsxs("button",{type:"button",ref:K,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":W,onClick:()=>_("summaries"),children:[s.jsx($i,{}),D>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),W&&s.jsx(Oc,{anchorRef:y?ae:K,aggregationModel:o,aggregableColumns:B,onFunctionChange:$,onClearAll:R,onClose:()=>L("summaries"),activeCount:D})]}),C&&C(),f]})]})}function Wc(){const[e]=a.useState(Yr);return a.useRef(e)}const Hc=({fullWidth:e=!1,error:t=!1,startAdornment:o,endAdornment:n,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 s.jsxs("div",{className:l,children:[o&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),s.jsx("input",{className:"ogx-input",...i}),n&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:n})]})};function Et(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const o=e.groupField??"",n=t.find(r=>r.field===o)?.groupingValueFormatter;return n?n({field:o,value:e.groupValue}):`${o}: ${String(e.groupValue??"")}`}const Bc=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 Vc(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 zc(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Bc.has(r)){t+=n;continue}const i=Vc(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const Kc=[79,70,229],jc=[255,255,255];function Wi(e,t){const o=e.trim().replace(/^#/,""),n=/^[a-f\d]{3}$/i.test(o)?o.split("").map(i=>i+i).join(""):o,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Hi(e,t){return bo(e,t,jt(e,t))}function Bi(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function Uc(e,t){const o=e.reduce((r,i)=>r+Bi(i),0),n={};return e.forEach((r,i)=>{n[i]={cellWidth:Bi(r)/o*t}}),n}const Xc=new Set(["isEmpty","isNotEmpty"]);function qc(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(Xc.has(e.operator))return`${n} ${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`${n} ${e.operator} "${i}"`}function Vi(e,t,o,n){const r=e.map(l=>"items"in l?Vi(l.items,l.logicOperator,o,!0):qc(l,o)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return n&&r.length>1?`(${i})`:i}function Yc(e,t){const o=[],n=Vi(e.items??[],e.logicOperator??"and",t,!1);n&&o.push(n);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&o.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),o.join(" • ")}const Rc=1.15*.3528;async function Jc(e,t,o={}){let n,r;try{const[D,$]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);n=D.default,r=$.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:i="export",title:l,logoUrl:c,orientation:d="landscape",selectedRows:u,getRowId:g,aggregationResult:m,aggregationModel:x,filterModel:v,alternateRowColor:h=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:w="#ffffff",fontSize:p=9,groupedRows:b,font:y}=o,C=new n({orientation:d,unit:"mm",format:"a4"}),N=C.internal.pageSize.getWidth(),T=C.internal.pageSize.getHeight(),E=14,P=N-E*2;let O="helvetica";y&&(C.addFileToVFS(`${y.name}-normal.ttf`,y.data),C.addFont(`${y.name}-normal.ttf`,y.name,"normal"),y.boldData&&C.addFileToVFS(`${y.name}-bold.ttf`,y.boldData),C.addFont(y.boldData?`${y.name}-bold.ttf`:`${y.name}-normal.ttf`,y.name,"bold"),O=y.name);let W=!1;const X=D=>{if(y)return D;const $=zc(D);return $.lossy&&(W=!0),$.text},S=(D,$,R,U,G)=>{const V=C.splitTextToSize(X(D),U);return C.text(V.length===1?V[0]:V,$,R),Math.max(0,V.length-1)*G*Rc},M=st(t),I=Kt(b,u),_=zt(e,u,g);let L=E;if(l){let D=E,$=E+8;if(c)try{C.addImage(c,"PNG",D,E,10,10),D+=14}catch{}const R=N-E-D;C.setFontSize(16),C.setFont(O,"bold"),C.setTextColor(30,41,59),$+=S(l,D,$,R,16),$+=6,C.setFontSize(8),C.setFont(O,"normal"),C.setTextColor(100,116,139);const U=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),G=I?b.filter(V=>V.type==="leaf").length:_.length;if(C.text(X(`Exported: ${U} • ${G} row${G!==1?"s":""}`),D,$),$+=5,v){const V=Yc(v,t);V&&($+=S(`Filters: ${V}`,D,$,R,8),$+=5)}C.setDrawColor(226,232,240),C.setLineWidth(.3),C.line(E,$+2,N-E,$+2),L=$+6}const A=[M.map(D=>X(D.headerName??D.field))],q=x||{},K=D=>M.map($=>bn($,q[$.field],D[$.field],D));let J,te;if(I)J=[],b.forEach(D=>{const $=" ".repeat(D.depth*2);if(D.type==="group-header"){const R=`${$}${Et(D,t)}`;J.push(M.map((U,G)=>G===0?R:""))}else if(D.type==="leaf"&&D.row){const R=D.row;J.push(M.map((U,G)=>(G===0?$:"")+Hi(R,U)))}else if(D.type==="group-subtotal"&&D.aggregatedValues){const R=K(D.aggregatedValues);J.push(R.map((U,G)=>G===0?`${$}${St("Subtotal",U)}`:U))}else D.type==="grand-total"&&D.aggregatedValues&&(te=[K(D.aggregatedValues).map((U,G)=>G===0?St("Grand Total",U):U)])});else{J=_.map($=>M.map(R=>Hi($,R)));const D=x?_t(_,Re(u),t,m,x):null;if(D&&x){const $=M.some(U=>x[U.field]);te=[K(D).map((U,G)=>G===0&&$?St("TOTAL",U):U)]}}J=J.map(D=>D.map(X)),te&&(te=te.map(D=>D.map(X))),W&&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 oe=Uc(M,P),[Z,de,ae]=Wi(f,Kc),[ne,se,re]=Wi(w,jc);r(C,{head:A,body:J,...te?{foot:te}:{},startY:L,styles:{fontSize:p,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[Z,de,ae],textColor:[ne,se,re],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...te?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:oe,showFoot:te?"lastPage":"never",showHead:"everyPage",margin:{top:E,left:E,right:E,bottom:E+6}});const B=C.getNumberOfPages();for(let D=1;D<=B;D++)C.setPage(D),C.setFontSize(8),C.setTextColor(150,150,150),C.text(`Page ${D} of ${B}`,N-E,T-8,{align:"right"});C.save(`${i}.pdf`)}function Xt(e,t){const o=jt(e,t);return{text:bo(e,t,o),raw:o}}function Mt(e,t,o){return e.map(n=>bn(n,o[n.field],t[n.field],t))}const Qc="\uFEFF";function Zc(e,t,o={}){const{fileName:n="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:c,escapeFormulas:d=!0,bom:u=!0}=o,g=st(t),m=o.aggregationModel||{},x=(f,w=!1)=>Co(d?vo(f,w):f,i),v=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
|
|
5
|
+
`;let h="";if(Kt(c,l))r&&(h+=v()),c.forEach(f=>{const w=" ".repeat(f.depth);if(f.type==="group-header"){const p=Et(f,t),b=Co(w+(d?vo(p):p),i);h+=g.map((y,C)=>C===0?b:"").join(i)+`
|
|
6
|
+
`}else if(f.type==="leaf"&&f.row){const p=f.row,b=g.map((y,C)=>{const N=Xt(p,y),T=d?vo(N.text,Je(N.raw)):N.text;return Co((C===0?w:"")+T,i)});h+=b.join(i)+`
|
|
7
|
+
`}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.aggregatedValues,b=f.type==="grand-total"?"Grand Total":`${w}Subtotal`,y=Mt(g,p,m),C=g.map((N,T)=>T===0?Co(St(b,y[0]),i):x(y[T],Je(p[N.field])));h+=C.join(i)+`
|
|
8
|
+
`}});else{const f=zt(e,l,o.getRowId);if(f.length===0){console.warn("No rows to export");return}r&&(h+=v()),f.forEach(p=>{const b=g.map(y=>{const C=Xt(p,y);return x(C.text,Je(C.raw))});h+=b.join(i)+`
|
|
9
9
|
`});const w=_t(f,Re(l),t,o.aggregationResult,o.aggregationModel);if(w){const p=g.map(y=>x(m[y.field]?m[y.field].toUpperCase():""));h+=p.join(i)+`
|
|
10
10
|
`;const b=Mt(g,w,m);h+=g.map((y,C)=>x(b[C],Je(w[y.field]))).join(i)+`
|
|
11
|
-
`}}
|
|
12
|
-
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const
|
|
11
|
+
`}}Cn((u?Qc:"")+h,n,"text/csv;charset=utf-8;")}function Co(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
|
|
12
|
+
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const _o="ogx-xls-text";function eu(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Je(t)}function tu(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 ou(e,t,o={}){const{fileName:n="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:c,escapeFormulas:d=!0}=o,u=st(t),g=o.aggregationModel||{},m=(w,p=!1)=>_e(d?vo(w,p):w),x=w=>`<td class="${_o}">${w}</td>`;let h=`<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>${_e(vn(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${_o}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(h+="<thead><tr>",u.forEach(w=>{h+=`<th class="${_o}">${m(w.headerName||w.field)}</th>`}),h+="</tr></thead>"),h+="<tbody>";const f=(w,p,b="")=>{const y=b+m(w.text,Je(w.raw));return eu(p,w.raw)?x(y):`<td>${y}</td>`};if(Kt(c,l))c.forEach(w=>{const p=" ".repeat(w.depth*2);if(w.type==="group-header")h+='<tr style="font-weight:bold;background:#e8eaf6;">',h+=`<td colspan="${u.length}" class="${_o}">${_e(p)}${m(Et(w,t))}</td>`,h+="</tr>";else if(w.type==="leaf"&&w.row){const b=w.row;h+="<tr>",u.forEach((y,C)=>{h+=f(Xt(b,y),y,C===0?_e(p):"")}),h+="</tr>"}else if((w.type==="group-subtotal"||w.type==="grand-total")&&w.aggregatedValues){const b=w.aggregatedValues,y=w.type==="grand-total"?"Grand Total":`${p}Subtotal`,C=Mt(u,b,g);h+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((N,T)=>{if(T===0){h+=x(_e(St(y,C[0])));return}h+=C[T]?`<td style="text-align:right;">${m(C[T],Je(b[N.field]))}</td>`:"<td></td>"}),h+="</tr>"}});else{const w=zt(e,l,o.getRowId);if(w.length===0){console.warn("No rows to export");return}w.forEach(b=>{h+="<tr>",u.forEach(y=>{h+=f(Xt(b,y),y)}),h+="</tr>"});const p=_t(w,Re(l),t,o.aggregationResult,o.aggregationModel);if(p){h+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(y=>{h+=g[y.field]?`<td style="text-align:right;font-weight:bold;">${_e(g[y.field].toUpperCase())}</td>`:"<td></td>"}),h+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const b=Mt(u,p,g);u.forEach((y,C)=>{h+=b[C]?`<td style="text-align:right;">${m(b[C],Je(p[y.field]))}</td>`:"<td></td>"}),h+="</tr>"}}h+="</tbody></table></body></html>",Cn(h,tu(n),"application/vnd.ms-excel")}function nu(e,t,o={}){const{fileName:n="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=o,c=st(t),d=g=>{const m={};return c.forEach(x=>{m[x.field]=jt(g,x)}),m};let u;if(Kt(l,i)){const g=[],m=[];let x;l.forEach(v=>{if(v.type==="group-header"){const h={group:Et(v,t),field:v.groupField??"",value:v.groupValue,rows:[],children:[]};for(;g.length>v.depth;)g.pop();g.length===0?m.push(h):(g[g.length-1].children??=[]).push(h),g.push(h)}else v.type==="leaf"&&v.row?g.length>0&&g[g.length-1].rows.push(d(v.row)):v.type==="group-subtotal"&&v.aggregatedValues&&g.length>0?(g[g.length-1].subtotals=_i(v.aggregatedValues,c),g.pop()):v.type==="grand-total"&&v.aggregatedValues&&(x=_i(v.aggregatedValues,c))}),u=x?{groups:m,grandTotal:x}:{groups:m}}else{const g=zt(e,i,o.getRowId);if(g.length===0){console.warn("No rows to export");return}const m=g.map(d),x=_t(g,Re(i),t,o.aggregationResult,o.aggregationModel);if(x){const v=o.aggregationModel||{},h={};c.forEach(w=>{v[w.field]&&(h[w.field]=v[w.field].toUpperCase())});const f={};c.forEach(w=>{x[w.field]!==void 0&&x[w.field]!==null&&(f[w.field]=x[w.field])}),u={data:m,aggregation:{labels:h,values:f}}}else u=m}Cn(r?JSON.stringify(u,null,2):JSON.stringify(u),n,"application/json;charset=utf-8;")}const ru=/^(?:https?:|data:image\/|blob:)/i,iu=/^[a-z][a-z\d+.-]*:/i;function lu(e){const t=e.trim();return t?ru.test(t)?t:iu.test(t)?null:t:null}async function su(e,t,o){const n=window.open("","_blank");if(!n){console.error("Failed to open print window. Please check your popup blocker settings.");return}n.document.write(`
|
|
13
13
|
<!DOCTYPE html>
|
|
14
14
|
<html>
|
|
15
15
|
<head>
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
tr.group-subtotal{background:#f0f4ff;font-style:italic;}
|
|
41
41
|
tr.grand-total{background:#f5f5f5;font-weight:bold;}
|
|
42
42
|
@media print{body{margin:0;}@page{margin:1cm;}}
|
|
43
|
-
</style></head><body>`;r&&(x+=`<h1>${_e(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${_e(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const v=(f,w,p="",b=!1)=>{const{text:y}=Ut(f,w),C=w.type==="image"?iu(y):null;if(C!==null){const N=`<img src="${_e(C)}" alt="${_e(w.headerName||w.field)}" style="max-height:40px;border-radius:4px;">`;return b?`<td><div style="display:flex;justify-content:center;">${N}</div></td>`:`<td>${N}</td>`}return`<td>${p}${_e(y)}</td>`};if(zt(u,i))u.forEach(f=>{const w=" ".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${w}${_e(Et(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const p=f.row;x+="<tr>",g.forEach((b,y)=>{x+=v(p,b,y===0?w:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.type==="grand-total",b=Mt(g,f.aggregatedValues,m);x+=`<tr class="${p?"grand-total":"group-subtotal"}">`,g.forEach((y,C)=>{if(C===0){x+=`<td>${p?"":w}${_e(St(p?"Grand Total":"Subtotal",b[0]))}</td>`;return}x+=b[C]?`<td style="text-align:right;">${_e(b[C])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=Vt(e,i,l);if(f.length===0){n.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(p=>{x+="<tr>",g.forEach(b=>{x+=v(p,b,"",!0)}),x+="</tr>"});const w=_t(f,Re(i),t,c,d);w&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(p=>{x+=m[p.field]?`<td style="text-align:right;font-weight:bold;">${_e(m[p.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Mt(g,w,m).forEach(p=>{x+=p?`<td style="text-align:right;">${_e(p)}</td>`:"<td></td>"}),x+="</tr></tfoot>")}x+="</tbody></table></body></html>",n.document.open(),n.document.write(x),n.document.close(),n.document.title=r||"Print Preview",n.focus();let h=!1;n.onload=()=>{h||(h=!0,n.print(),setTimeout(()=>{n.close()},100))},setTimeout(()=>{!h&&n&&!n.closed&&(h=!0,n.print(),setTimeout(()=>{n.closed||n.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),n&&!n.closed){const i=r instanceof Error?r.message:String(r);n.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${_e(i)}</p></div>`}}}function yn(e,t,o){const n=new Blob([e],{type:o}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function su(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 Xt(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 au=/^(\d{4})-(\d{2})-(\d{2})$/,du=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,cu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function uu(e){if(e instanceof Date)return Xt(e);if(typeof e=="number")return Number.isFinite(e)?Xt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=au.exec(t);if(o){const[n,r,i]=[Number(o[1]),Number(o[2]),Number(o[3])],l=new Date(Date.UTC(n,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(du.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:Xt(n)}}function fu(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 o=Number(t);return Number.isSafeInteger(o)?o:void 0}if(typeof t=="string"&&cu.test(t.trim())){const o=Number(t.trim());return Number.isFinite(o)?o:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const o=t.trim().toLowerCase();if(o==="true")return!0;if(o==="false")return!1}return}return uu(t)}function zi(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 Xt(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function gu(e,t){const o=Kt(e,t),n=su(t,o);if(n!=="string"){const r=fu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:zi(o)}return t.valueFormatter?xo(e,t,o):zi(o)}const Ki="#,##0",pu="#,##0.##";function hu(e){return Number.isInteger(e)?Ki:pu}function ji(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ui(e,t,o){if(!(t?.numFmt||typeof o!="number"||e.type!=="number"))return hu(o)}function wu(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function mu(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 Xi(e,t){const o=Kt(e,t);return typeof o=="string"&&o?o:null}async function xu(e){const t=await Promise.allSettled(e.map(async n=>{let r;if(n.startsWith("data:")){const l=n.slice(n.indexOf(",")+1),c=atob(l);r=new Uint8Array(c.length);for(let d=0;d<c.length;d++)r[d]=c.charCodeAt(d)}else{const l=await fetch(n,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=mu(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:n,buffer:r.slice().buffer,ext:i}})),o=new Map;return t.forEach((n,r)=>{n.status==="fulfilled"?o.set(n.value.url,{buffer:n.value.buffer,extension:n.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,n.reason)}),o}async function bu(e,t,o={}){const{fileName:n="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:c="#334155",headerFontSize:d=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:m=null,selectedRows:x,getRowId:v,groupedRows:h,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:w="#f0f4ff"}=o,p=(await import("exceljs")).default,b=new p.Workbook;b.creator="OpenGridX",b.created=new Date;const y=t,C=st(y),N=e,T=Re(x)?Ci(N,x,v):[],E=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],P=new Set,O=new Map,W=(_,F)=>{const A=F[_.field],q=m?.[_.field];if(A==null)return{value:null};const K=tr(_,q,A);return typeof K=="number"?Number.isFinite(K)?er(q)?{value:K,numFmt:Ki}:{value:K,numFmt:Ui(_,i[_.field],K)}:{value:null}:K instanceof Date?{value:Xt(K)}:{value:xn(_,q,A,F)}};for(const _ of E){if("type"in _&&_.type==="summary"){if(!g||!m)continue;const V=b.addWorksheet(bn(_.name??"Summary",P));V.addRow(["Summary / Aggregation Totals"]),V.getRow(1).font={bold:!0,size:d+2,color:{argb:Oe(c)}},V.addRow([]),V.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.border=qi()}),C.forEach(H=>{const j=m[H.field];if(j==null||g[H.field]==null)return;const{value:z,numFmt:k}=W(H,g),Q=V.addRow([H.headerName??H.field,j.toUpperCase(),z]).getCell(3),ee=k??ji(H,i[H.field]);ee&&(Q.numFmt=ee),Q.alignment={horizontal:"right"},Q.font={bold:!0,size:u}}),V.getColumn(1).width=20,V.getColumn(2).width=12,V.getColumn(3).width=18;continue}const F=_,{name:A="Data",rows:q="all",includeHeaders:K=!0,includeSummary:J=!1,autoFilter:te=!0,frozenHeader:ne=!0,alternateRowColor:Z="#f8fafc"}=F,de=q==="all"&&!!(h&&h.length>0),ae=q==="selected"?T:de?h.flatMap(V=>V.type==="leaf"&&V.row?[V.row]:[]):N,oe=C.filter(V=>i[V.field]?.embedImage);if(oe.length>0){const V=[],Y=new Set;if(ae.forEach(H=>{oe.forEach(j=>{const z=Xi(H,j);z&&!O.has(z)&&!Y.has(z)&&(V.push(z),Y.add(z))})}),V.length>0){const H=await xu(V);for(const[j,{buffer:z,extension:k}]of H){const L=b.addImage({buffer:z,extension:k});O.set(j,L)}}}const se=b.addWorksheet(bn(A,P));se.columns=C.map(V=>({key:V.field,width:wu(V,i[V.field]?.width),style:{numFmt:ji(V,i[V.field])}}));const re=(V,Y)=>{C.forEach((H,j)=>Y(V.getCell(j+1),H,j+1))};if(K){const V=C.map(H=>H.headerName??H.field),Y=se.addRow(V);Y.height=20,re(Y,(H,j)=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.alignment={horizontal:i[j.field]?.alignment??(j.type==="number"?"right":"left"),vertical:"middle"},H.border=qi()}),te&&(se.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),ne?se.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:se.views=[{showGridLines:!1}]}let B=K?1:0;const D=(V,Y,H)=>{const j=C.map(L=>i[L.field]?.embedImage?"":gu(V,L)),z=se.addRow(j);z.font={size:u},H>0&&(z.outlineLevel=H);const k=!!Z&&Y%2===1;if(re(z,(L,Q,ee)=>{const ce=Ui(Q,i[Q.field],j[ee-1]);ce&&(L.numFmt=ce),k&&Z&&(L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(Z)}}),L.alignment={horizontal:i[Q.field]?.alignment??(Q.type==="number"?"right":"left"),vertical:"middle"},L.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),oe.length>0){const L=oe.reduce((ce,ue)=>Math.max(ce,i[ue.field]?.imageHeight??40),0),Q=Math.ceil(L/1.333),ee=Q*1.333;z.height=Q,oe.forEach(ce=>{const ue=C.indexOf(ce),he=Xi(V,ce),be=he?O.get(he):void 0;if(be===void 0){z.getCell(ue+1).value=he??"";return}const Ce=i[ce.field],fe=Ce?.imageWidth??40,me=Ce?.imageHeight??40,Se=(se.getColumn(ue+1).width??8)*7+5,le=Math.max(0,Se-fe)/2,ye=Math.max(0,ee-me)/2;se.addImage(be,{tl:{col:ue,row:B,nativeColOff:Math.floor(le*9525),nativeRowOff:Math.floor(ye*9525)},ext:{width:fe,height:me},editAs:"oneCell"})})}else z.height=16;B++},$=V=>Et(V,y),R=(V,Y,H,j,z)=>{const k=C.map((Q,ee)=>ee===0&&Y[Q.field]==null?{value:V}:W(Q,Y)),L=se.addRow(k.map(Q=>Q.value));L.height=18,j>0&&(L.outlineLevel=j),L.font={bold:z,italic:!z,size:u,color:{argb:Oe(c)}},re(L,(Q,ee,ce)=>{const ue=k[ce-1].numFmt;ue&&(Q.numFmt=ue),Q.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(H)}},Q.alignment={horizontal:ce===1?"left":ee.type==="number"?"right":"left",vertical:"middle"},Q.border=Yi()}),B++};let U=!1;if(de){let V=0;h.forEach(Y=>{if(Y.type==="group-header"){const H=se.addRow([$(Y)]);H.height=18,Y.depth>0&&(H.outlineLevel=Y.depth),H.font={bold:!0,size:u,color:{argb:Oe(c)}};for(let j=1;j<=C.length;j++)H.getCell(j).fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(f)}};H.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:Y.depth},B++,V=0}else Y.type==="leaf"&&Y.row?D(Y.row,V++,Y.depth):Y.type==="group-subtotal"&&Y.aggregatedValues?R("Subtotal",Y.aggregatedValues,w,Y.depth,!1):Y.type==="grand-total"&&Y.aggregatedValues&&(R("Grand Total",Y.aggregatedValues,l,0,!0),U=!0)}),se.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else ae.forEach((V,Y)=>D(V,Y,0));const G=_t(ae,q==="selected",y,g,m);if(J&&!U&&G&&m){const V=C.map(z=>{const k=m[z.field];return k?k.toUpperCase():""}),Y=se.addRow(V);Y.height=16,Y.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},re(Y,z=>{z.alignment={horizontal:"right",vertical:"middle"},z.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=C.map(z=>m[z.field]==null?{value:null}:W(z,G)),j=se.addRow(H.map(z=>z.value));j.height=18,j.font={bold:!0,size:u,color:{argb:Oe(c)}},re(j,(z,k,L)=>{const Q=H[L-1].numFmt;Q&&(z.numFmt=Q),z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},z.alignment={horizontal:"right",vertical:"middle"},z.border=Yi()})}}const X=await b.xlsx.writeBuffer(),S=new Blob([X],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),M=URL.createObjectURL(S),I=document.createElement("a");I.href=M,I.download=n.endsWith(".xlsx")?n:`${n}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(M)}function Oe(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(o=>o+o).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function qi(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Yi(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function vu(e,t,o,n){return a.useMemo(()=>n?vr(e,t,o):on,[e,t,o,n])}const Ri={"--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-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)"},Ji={"--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",...Ri},yu={...Ji,"--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",...Ri,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Cu=[50,100,200,300,400,500,600,700,800,900];function _u(e){const t={};function o(n,r){r!==void 0&&(t[n]=r)}if(e.colors){const n=e.colors;if(o("--ogx-color-primary",n.primary),o("--ogx-color-primary-dark",n.primaryDark),o("--ogx-color-primary-light",n.primaryLight),o("--ogx-color-primary-focus",n.primaryFocus),o("--ogx-color-secondary",n.secondary),o("--ogx-color-secondary-dark",n.secondaryDark),o("--ogx-color-secondary-light",n.secondaryLight),o("--ogx-color-success",n.success),o("--ogx-color-warning",n.warning),o("--ogx-color-error",n.error),o("--ogx-color-info",n.info),o("--ogx-color-white",n.white),o("--ogx-color-black",n.black),n.gray)for(const r of Cu)o(`--ogx-color-gray-${r}`,n.gray[r])}if(e.typography){const n=e.typography;o("--ogx-font-family",n.fontFamily),o("--ogx-font-family-mono",n.fontFamilyMono),o("--ogx-font-size-xs",n.fontSizeXs),o("--ogx-font-size-sm",n.fontSizeSm),o("--ogx-font-size-md",n.fontSizeMd),o("--ogx-font-size-lg",n.fontSizeLg),o("--ogx-font-size-xl",n.fontSizeXl)}if(e.spacing){const n=e.spacing;o("--ogx-spacing-xs",n.xs),o("--ogx-spacing-sm",n.sm),o("--ogx-spacing-md",n.md),o("--ogx-spacing-lg",n.lg),o("--ogx-spacing-xl",n.xl),o("--ogx-spacing-xxl",n.xxl)}if(e.borders){const n=e.borders;o("--ogx-border-width-thin",n.widthThin),o("--ogx-border-width-medium",n.widthMedium),o("--ogx-border-width-thick",n.widthThick),o("--ogx-border-radius-sm",n.radiusSm),o("--ogx-border-radius-md",n.radiusMd),o("--ogx-border-radius-lg",n.radiusLg),o("--ogx-border-radius-xl",n.radiusXl),o("--ogx-border-color",n.color),o("--ogx-border-color-hover",n.colorHover)}if(e.shadows){const n=e.shadows;o("--ogx-shadow-sm",n.sm),o("--ogx-shadow-md",n.md),o("--ogx-shadow-lg",n.lg),o("--ogx-shadow-xl",n.xl)}if(e.grid){const n=e.grid;o("--ogx-grid-row-height-compact",n.rowHeightCompact),o("--ogx-grid-row-height-standard",n.rowHeightStandard),o("--ogx-row-height",n.rowHeightStandard),o("--ogx-grid-row-height-comfortable",n.rowHeightComfortable),o("--ogx-grid-header-height",n.headerHeight),o("--ogx-header-height",n.headerHeight),o("--ogx-grid-cell-padding-x",n.cellPaddingX),o("--ogx-grid-cell-padding-y",n.cellPaddingY),o("--ogx-grid-cell-font-size",n.cellFontSize),o("--ogx-grid-header-font-size",n.headerFontSize),o("--ogx-grid-background",n.background),o("--ogx-grid-border-color",n.borderColor),o("--ogx-grid-header-background",n.headerBackground),o("--ogx-grid-header-text",n.headerText),o("--ogx-grid-header-hover-background",n.headerHoverBackground),o("--ogx-grid-header-sorted-background",n.headerSortedBackground),o("--ogx-grid-row-text",n.rowText),o("--ogx-grid-row-hover-background",n.rowHoverBackground),o("--ogx-grid-row-alternate-background",n.rowAlternateBackground),o("--ogx-grid-row-selected-background",n.rowSelectedBackground),o("--ogx-grid-row-selected-hover-background",n.rowSelectedHoverBackground),o("--ogx-grid-cell-focus-border",n.cellFocusBorder),o("--ogx-grid-pinned-left-shadow",n.pinnedLeftShadow),o("--ogx-grid-pinned-right-shadow",n.pinnedRightShadow),o("--ogx-checkbox-bg",n.checkboxBg),o("--ogx-checkbox-border",n.checkboxBorder)}if(e.transitions){const n=e.transitions;o("--ogx-transition-duration-fast",n.durationFast),o("--ogx-transition-duration-normal",n.durationNormal),o("--ogx-transition-duration-slow",n.durationSlow),o("--ogx-transition-easing",n.easing)}if(e.toolbar){const n=e.toolbar;o("--ogx-toolbar-background",n.background),o("--ogx-toolbar-text",n.text),o("--ogx-toolbar-border",n.border),o("--ogx-toolbar-btn-bg",n.buttonBackground),o("--ogx-toolbar-btn-hover",n.buttonHoverBackground),o("--ogx-toolbar-btn-text",n.buttonText),o("--ogx-toolbar-btn-primary-bg",n.buttonPrimaryBackground),o("--ogx-toolbar-btn-primary-hover",n.buttonPrimaryHoverBackground),o("--ogx-toolbar-btn-primary-text",n.buttonPrimaryText),o("--ogx-toolbar-btn-danger-bg",n.buttonDangerBackground),o("--ogx-toolbar-btn-danger-hover",n.buttonDangerHoverBackground),o("--ogx-toolbar-btn-danger-text",n.buttonDangerText),o("--ogx-toolbar-input-bg",n.inputBackground),o("--ogx-toolbar-input-text",n.inputText),o("--ogx-toolbar-input-border",n.inputBorder),o("--ogx-toolbar-input-focus-border",n.inputFocusBorder),o("--ogx-toolbar-input-focus-shadow",n.inputFocusShadow),o("--ogx-toolbar-chip-bg",n.chipBackground),o("--ogx-toolbar-chip-text",n.chipText),o("--ogx-toolbar-chip-active-bg",n.chipActiveBackground),o("--ogx-toolbar-chip-active-text",n.chipActiveText)}if(e.overlays){const n=e.overlays;o("--ogx-overlay-background",n.background),o("--ogx-overlay-text",n.text),o("--ogx-overlay-border",n.border),o("--ogx-overlay-shadow",n.shadow),o("--ogx-overlay-item-hover-bg",n.itemHoverBackground),o("--ogx-overlay-item-hover-text",n.itemHoverText),o("--ogx-overlay-item-selected-bg",n.itemSelectedBackground),o("--ogx-overlay-item-selected-text",n.itemSelectedText),o("--ogx-overlay-item-danger-bg",n.itemDangerBackground),o("--ogx-overlay-item-danger-text",n.itemDangerText)}if(e.scrollbar){const n=e.scrollbar;o("--ogx-scrollbar-thumb",n.thumbColor),o("--ogx-scrollbar-track",n.trackColor),o("--ogx-scrollbar-size",n.size)}if(e.skeleton){const n=e.skeleton;o("--ogx-skeleton-base",n.baseColor),o("--ogx-skeleton-highlight",n.highlightColor)}return t}function Su({theme:e,children:t,className:o,style:n}){const r=a.useMemo(()=>({...e.mode==="dark"?yu:Ji,..._u(e)}),[e]);return s.jsx(Mr.Provider,{value:e,children:s.jsx("div",{className:`ogx-theme-provider ${o||""}`.trim(),style:{...n,...r},children:t})})}const ku={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",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"}},Eu={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"}},Mu={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"}},Nu={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"}},Pu={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 Iu(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Qi(e,t){try{const o=t.getItem(e);return o?JSON.parse(o):void 0}catch{return}}function Tu(e,t,o,n){try{const r=o?Object.fromEntries(Object.entries(t).filter(([i])=>o.includes(i))):t;n.setItem(e,JSON.stringify(r))}catch{}}function Fu(e){const t=typeof e=="string"?{key:e}:e,{key:o,debounceMs:n=300,include:r,storage:i}=t,[l]=a.useState(Iu),c=i??l,d=a.useRef(r),u=a.useRef(c);a.useLayoutEffect(()=>{d.current=r,u.current=c});const[g,m]=a.useState(()=>({key:o,state:c?Qi(o,c):void 0}));let x=g.state;g.key!==o&&(x=c?Qi(o,c):void 0,m({key:o,state:x}));const v=a.useRef(null),h=a.useRef(null),f=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null);const b=h.current;h.current=null;const y=u.current;b&&y&&Tu(b.key,b.state,d.current,y)},[]),w=a.useCallback(b=>{h.current&&h.current.key!==o&&f(),h.current={key:o,state:b},v.current&&clearTimeout(v.current),v.current=setTimeout(f,n)},[o,f,n]);a.useEffect(()=>f,[f]);const p=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),h.current=null;const b=u.current;if(b)try{b.removeItem(o)}catch{}},[o]);return a.useMemo(()=>({initialState:x,onStateChange:w,clearState:p}),[x,w,p])}pe.Button=Wt,pe.Cell=xi,pe.Checkbox=Gt,pe.ColumnVisibilityPanel=mn,pe.DataGrid=bc,pe.DataGridThemeProvider=Su,pe.FilterPanel=Fi,pe.GridToolbar=$c,pe.GridTooltip=jt,pe.Header=qr,pe.Input=Wc,pe.Pagination=gn,pe.Row=mo,pe.Skeleton=vc,pe.amberTheme=Nu,pe.compactTheme=Pu,pe.darkTheme=ku,pe.emeraldTheme=Mu,pe.exportToCsv=Qc,pe.exportToExcel=tu,pe.exportToExcelAdvanced=bu,pe.exportToJson=ou,pe.exportToPdf=Rc,pe.formatAggregationValue=Xo,pe.printGrid=lu,pe.roseTheme=Eu,pe.useAggregation=hi,pe.useGridApiRef=Gc,pe.useGridStateStorage=Fu,pe.usePivot=vu,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})}));
|
|
43
|
+
</style></head><body>`;r&&(x+=`<h1>${_e(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${_e(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const v=(f,w,p="",b=!1)=>{const{text:y}=Xt(f,w),C=w.type==="image"?lu(y):null;if(C!==null){const N=`<img src="${_e(C)}" alt="${_e(w.headerName||w.field)}" style="max-height:40px;border-radius:4px;">`;return b?`<td><div style="display:flex;justify-content:center;">${N}</div></td>`:`<td>${N}</td>`}return`<td>${p}${_e(y)}</td>`};if(Kt(u,i))u.forEach(f=>{const w=" ".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${w}${_e(Et(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const p=f.row;x+="<tr>",g.forEach((b,y)=>{x+=v(p,b,y===0?w:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.type==="grand-total",b=Mt(g,f.aggregatedValues,m);x+=`<tr class="${p?"grand-total":"group-subtotal"}">`,g.forEach((y,C)=>{if(C===0){x+=`<td>${p?"":w}${_e(St(p?"Grand Total":"Subtotal",b[0]))}</td>`;return}x+=b[C]?`<td style="text-align:right;">${_e(b[C])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=zt(e,i,l);if(f.length===0){n.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(p=>{x+="<tr>",g.forEach(b=>{x+=v(p,b,"",!0)}),x+="</tr>"});const w=_t(f,Re(i),t,c,d);w&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(p=>{x+=m[p.field]?`<td style="text-align:right;font-weight:bold;">${_e(m[p.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Mt(g,w,m).forEach(p=>{x+=p?`<td style="text-align:right;">${_e(p)}</td>`:"<td></td>"}),x+="</tr></tfoot>")}x+="</tbody></table></body></html>",n.document.open(),n.document.write(x),n.document.close(),n.document.title=r||"Print Preview",n.focus();let h=!1;n.onload=()=>{h||(h=!0,n.print(),setTimeout(()=>{n.close()},100))},setTimeout(()=>{!h&&n&&!n.closed&&(h=!0,n.print(),setTimeout(()=>{n.closed||n.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),n&&!n.closed){const i=r instanceof Error?r.message:String(r);n.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${_e(i)}</p></div>`}}}function Cn(e,t,o){const n=new Blob([e],{type:o}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function au(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 qt(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 du=/^(\d{4})-(\d{2})-(\d{2})$/,cu=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,uu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function fu(e){if(e instanceof Date)return qt(e);if(typeof e=="number")return Number.isFinite(e)?qt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=du.exec(t);if(o){const[n,r,i]=[Number(o[1]),Number(o[2]),Number(o[3])],l=new Date(Date.UTC(n,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(cu.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:qt(n)}}function gu(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 o=Number(t);return Number.isSafeInteger(o)?o:void 0}if(typeof t=="string"&&uu.test(t.trim())){const o=Number(t.trim());return Number.isFinite(o)?o:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const o=t.trim().toLowerCase();if(o==="true")return!0;if(o==="false")return!1}return}return fu(t)}function zi(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 qt(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function pu(e,t){const o=jt(e,t),n=au(t,o);if(n!=="string"){const r=gu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:zi(o)}return t.valueFormatter?bo(e,t,o):zi(o)}const Ki="#,##0",hu="#,##0.##";function wu(e){return Number.isInteger(e)?Ki:hu}function ji(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ui(e,t,o){if(!(t?.numFmt||typeof o!="number"||e.type!=="number"))return wu(o)}function mu(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function xu(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 Xi(e,t){const o=jt(e,t);return typeof o=="string"&&o?o:null}async function bu(e){const t=await Promise.allSettled(e.map(async n=>{let r;if(n.startsWith("data:")){const l=n.slice(n.indexOf(",")+1),c=atob(l);r=new Uint8Array(c.length);for(let d=0;d<c.length;d++)r[d]=c.charCodeAt(d)}else{const l=await fetch(n,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=xu(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:n,buffer:r.slice().buffer,ext:i}})),o=new Map;return t.forEach((n,r)=>{n.status==="fulfilled"?o.set(n.value.url,{buffer:n.value.buffer,extension:n.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,n.reason)}),o}async function vu(e,t,o={}){const{fileName:n="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:c="#334155",headerFontSize:d=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:m=null,selectedRows:x,getRowId:v,groupedRows:h,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:w="#f0f4ff"}=o,p=(await import("exceljs")).default,b=new p.Workbook;b.creator="OpenGridX",b.created=new Date;const y=t,C=st(y),N=e,T=Re(x)?Ci(N,x,v):[],E=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],P=new Set,O=new Map,W=(_,L)=>{const A=L[_.field],q=m?.[_.field];if(A==null)return{value:null};const K=tr(_,q,A);return typeof K=="number"?Number.isFinite(K)?er(q)?{value:K,numFmt:Ki}:{value:K,numFmt:Ui(_,i[_.field],K)}:{value:null}:K instanceof Date?{value:qt(K)}:{value:bn(_,q,A,L)}};for(const _ of E){if("type"in _&&_.type==="summary"){if(!g||!m)continue;const V=b.addWorksheet(vn(_.name??"Summary",P));V.addRow(["Summary / Aggregation Totals"]),V.getRow(1).font={bold:!0,size:d+2,color:{argb:Oe(c)}},V.addRow([]),V.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.border=qi()}),C.forEach(H=>{const j=m[H.field];if(j==null||g[H.field]==null)return;const{value:z,numFmt:k}=W(H,g),Q=V.addRow([H.headerName??H.field,j.toUpperCase(),z]).getCell(3),ee=k??ji(H,i[H.field]);ee&&(Q.numFmt=ee),Q.alignment={horizontal:"right"},Q.font={bold:!0,size:u}}),V.getColumn(1).width=20,V.getColumn(2).width=12,V.getColumn(3).width=18;continue}const L=_,{name:A="Data",rows:q="all",includeHeaders:K=!0,includeSummary:J=!1,autoFilter:te=!0,frozenHeader:oe=!0,alternateRowColor:Z="#f8fafc"}=L,de=q==="all"&&!!(h&&h.length>0),ae=q==="selected"?T:de?h.flatMap(V=>V.type==="leaf"&&V.row?[V.row]:[]):N,ne=C.filter(V=>i[V.field]?.embedImage);if(ne.length>0){const V=[],Y=new Set;if(ae.forEach(H=>{ne.forEach(j=>{const z=Xi(H,j);z&&!O.has(z)&&!Y.has(z)&&(V.push(z),Y.add(z))})}),V.length>0){const H=await bu(V);for(const[j,{buffer:z,extension:k}]of H){const F=b.addImage({buffer:z,extension:k});O.set(j,F)}}}const se=b.addWorksheet(vn(A,P));se.columns=C.map(V=>({key:V.field,width:mu(V,i[V.field]?.width),style:{numFmt:ji(V,i[V.field])}}));const re=(V,Y)=>{C.forEach((H,j)=>Y(V.getCell(j+1),H,j+1))};if(K){const V=C.map(H=>H.headerName??H.field),Y=se.addRow(V);Y.height=20,re(Y,(H,j)=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.alignment={horizontal:i[j.field]?.alignment??(j.type==="number"?"right":"left"),vertical:"middle"},H.border=qi()}),te&&(se.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),oe?se.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:se.views=[{showGridLines:!1}]}let B=K?1:0;const D=(V,Y,H)=>{const j=C.map(F=>i[F.field]?.embedImage?"":pu(V,F)),z=se.addRow(j);z.font={size:u},H>0&&(z.outlineLevel=H);const k=!!Z&&Y%2===1;if(re(z,(F,Q,ee)=>{const ce=Ui(Q,i[Q.field],j[ee-1]);ce&&(F.numFmt=ce),k&&Z&&(F.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(Z)}}),F.alignment={horizontal:i[Q.field]?.alignment??(Q.type==="number"?"right":"left"),vertical:"middle"},F.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ne.length>0){const F=ne.reduce((ce,fe)=>Math.max(ce,i[fe.field]?.imageHeight??40),0),Q=Math.ceil(F/1.333),ee=Q*1.333;z.height=Q,ne.forEach(ce=>{const fe=C.indexOf(ce),ge=Xi(V,ce),be=ge?O.get(ge):void 0;if(be===void 0){z.getCell(fe+1).value=ge??"";return}const Ce=i[ce.field],ue=Ce?.imageWidth??40,me=Ce?.imageHeight??40,Se=(se.getColumn(fe+1).width??8)*7+5,le=Math.max(0,Se-ue)/2,ye=Math.max(0,ee-me)/2;se.addImage(be,{tl:{col:fe,row:B,nativeColOff:Math.floor(le*9525),nativeRowOff:Math.floor(ye*9525)},ext:{width:ue,height:me},editAs:"oneCell"})})}else z.height=16;B++},$=V=>Et(V,y),R=(V,Y,H,j,z)=>{const k=C.map((Q,ee)=>ee===0&&Y[Q.field]==null?{value:V}:W(Q,Y)),F=se.addRow(k.map(Q=>Q.value));F.height=18,j>0&&(F.outlineLevel=j),F.font={bold:z,italic:!z,size:u,color:{argb:Oe(c)}},re(F,(Q,ee,ce)=>{const fe=k[ce-1].numFmt;fe&&(Q.numFmt=fe),Q.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(H)}},Q.alignment={horizontal:ce===1?"left":ee.type==="number"?"right":"left",vertical:"middle"},Q.border=Yi()}),B++};let U=!1;if(de){let V=0;h.forEach(Y=>{if(Y.type==="group-header"){const H=se.addRow([$(Y)]);H.height=18,Y.depth>0&&(H.outlineLevel=Y.depth),H.font={bold:!0,size:u,color:{argb:Oe(c)}};for(let j=1;j<=C.length;j++)H.getCell(j).fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(f)}};H.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:Y.depth},B++,V=0}else Y.type==="leaf"&&Y.row?D(Y.row,V++,Y.depth):Y.type==="group-subtotal"&&Y.aggregatedValues?R("Subtotal",Y.aggregatedValues,w,Y.depth,!1):Y.type==="grand-total"&&Y.aggregatedValues&&(R("Grand Total",Y.aggregatedValues,l,0,!0),U=!0)}),se.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else ae.forEach((V,Y)=>D(V,Y,0));const G=_t(ae,q==="selected",y,g,m);if(J&&!U&&G&&m){const V=C.map(z=>{const k=m[z.field];return k?k.toUpperCase():""}),Y=se.addRow(V);Y.height=16,Y.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},re(Y,z=>{z.alignment={horizontal:"right",vertical:"middle"},z.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=C.map(z=>m[z.field]==null?{value:null}:W(z,G)),j=se.addRow(H.map(z=>z.value));j.height=18,j.font={bold:!0,size:u,color:{argb:Oe(c)}},re(j,(z,k,F)=>{const Q=H[F-1].numFmt;Q&&(z.numFmt=Q),z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},z.alignment={horizontal:"right",vertical:"middle"},z.border=Yi()})}}const X=await b.xlsx.writeBuffer(),S=new Blob([X],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),M=URL.createObjectURL(S),I=document.createElement("a");I.href=M,I.download=n.endsWith(".xlsx")?n:`${n}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(M)}function Oe(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(o=>o+o).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function qi(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Yi(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function yu(e,t,o,n){return a.useMemo(()=>n?vr(e,t,o):nn,[e,t,o,n])}const Ri={"--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-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)"},Ji={"--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",...Ri},Cu={...Ji,"--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",...Ri,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},_u=[50,100,200,300,400,500,600,700,800,900];function Su(e){const t={};function o(n,r){r!==void 0&&(t[n]=r)}if(e.colors){const n=e.colors;if(o("--ogx-color-primary",n.primary),o("--ogx-color-primary-dark",n.primaryDark),o("--ogx-color-primary-light",n.primaryLight),o("--ogx-color-primary-focus",n.primaryFocus),o("--ogx-color-secondary",n.secondary),o("--ogx-color-secondary-dark",n.secondaryDark),o("--ogx-color-secondary-light",n.secondaryLight),o("--ogx-color-success",n.success),o("--ogx-color-warning",n.warning),o("--ogx-color-error",n.error),o("--ogx-color-info",n.info),o("--ogx-color-white",n.white),o("--ogx-color-black",n.black),n.gray)for(const r of _u)o(`--ogx-color-gray-${r}`,n.gray[r])}if(e.typography){const n=e.typography;o("--ogx-font-family",n.fontFamily),o("--ogx-font-family-mono",n.fontFamilyMono),o("--ogx-font-size-xs",n.fontSizeXs),o("--ogx-font-size-sm",n.fontSizeSm),o("--ogx-font-size-md",n.fontSizeMd),o("--ogx-font-size-lg",n.fontSizeLg),o("--ogx-font-size-xl",n.fontSizeXl)}if(e.spacing){const n=e.spacing;o("--ogx-spacing-xs",n.xs),o("--ogx-spacing-sm",n.sm),o("--ogx-spacing-md",n.md),o("--ogx-spacing-lg",n.lg),o("--ogx-spacing-xl",n.xl),o("--ogx-spacing-xxl",n.xxl)}if(e.borders){const n=e.borders;o("--ogx-border-width-thin",n.widthThin),o("--ogx-border-width-medium",n.widthMedium),o("--ogx-border-width-thick",n.widthThick),o("--ogx-border-radius-sm",n.radiusSm),o("--ogx-border-radius-md",n.radiusMd),o("--ogx-border-radius-lg",n.radiusLg),o("--ogx-border-radius-xl",n.radiusXl),o("--ogx-border-color",n.color),o("--ogx-border-color-hover",n.colorHover)}if(e.shadows){const n=e.shadows;o("--ogx-shadow-sm",n.sm),o("--ogx-shadow-md",n.md),o("--ogx-shadow-lg",n.lg),o("--ogx-shadow-xl",n.xl)}if(e.grid){const n=e.grid;o("--ogx-grid-row-height-compact",n.rowHeightCompact),o("--ogx-grid-row-height-standard",n.rowHeightStandard),o("--ogx-row-height",n.rowHeightStandard),o("--ogx-grid-row-height-comfortable",n.rowHeightComfortable),o("--ogx-grid-header-height",n.headerHeight),o("--ogx-header-height",n.headerHeight),o("--ogx-grid-cell-padding-x",n.cellPaddingX),o("--ogx-grid-cell-padding-y",n.cellPaddingY),o("--ogx-grid-cell-font-size",n.cellFontSize),o("--ogx-grid-header-font-size",n.headerFontSize),o("--ogx-grid-background",n.background),o("--ogx-grid-border-color",n.borderColor),o("--ogx-grid-header-background",n.headerBackground),o("--ogx-grid-header-text",n.headerText),o("--ogx-grid-header-hover-background",n.headerHoverBackground),o("--ogx-grid-header-sorted-background",n.headerSortedBackground),o("--ogx-grid-row-text",n.rowText),o("--ogx-grid-row-hover-background",n.rowHoverBackground),o("--ogx-grid-row-alternate-background",n.rowAlternateBackground),o("--ogx-grid-row-selected-background",n.rowSelectedBackground),o("--ogx-grid-row-selected-hover-background",n.rowSelectedHoverBackground),o("--ogx-grid-cell-focus-border",n.cellFocusBorder),o("--ogx-grid-pinned-left-shadow",n.pinnedLeftShadow),o("--ogx-grid-pinned-right-shadow",n.pinnedRightShadow),o("--ogx-checkbox-bg",n.checkboxBg),o("--ogx-checkbox-border",n.checkboxBorder)}if(e.transitions){const n=e.transitions;o("--ogx-transition-duration-fast",n.durationFast),o("--ogx-transition-duration-normal",n.durationNormal),o("--ogx-transition-duration-slow",n.durationSlow),o("--ogx-transition-easing",n.easing)}if(e.toolbar){const n=e.toolbar;o("--ogx-toolbar-background",n.background),o("--ogx-toolbar-text",n.text),o("--ogx-toolbar-border",n.border),o("--ogx-toolbar-btn-bg",n.buttonBackground),o("--ogx-toolbar-btn-hover",n.buttonHoverBackground),o("--ogx-toolbar-btn-text",n.buttonText),o("--ogx-toolbar-btn-primary-bg",n.buttonPrimaryBackground),o("--ogx-toolbar-btn-primary-hover",n.buttonPrimaryHoverBackground),o("--ogx-toolbar-btn-primary-text",n.buttonPrimaryText),o("--ogx-toolbar-btn-danger-bg",n.buttonDangerBackground),o("--ogx-toolbar-btn-danger-hover",n.buttonDangerHoverBackground),o("--ogx-toolbar-btn-danger-text",n.buttonDangerText),o("--ogx-toolbar-input-bg",n.inputBackground),o("--ogx-toolbar-input-text",n.inputText),o("--ogx-toolbar-input-border",n.inputBorder),o("--ogx-toolbar-input-focus-border",n.inputFocusBorder),o("--ogx-toolbar-input-focus-shadow",n.inputFocusShadow),o("--ogx-toolbar-chip-bg",n.chipBackground),o("--ogx-toolbar-chip-text",n.chipText),o("--ogx-toolbar-chip-active-bg",n.chipActiveBackground),o("--ogx-toolbar-chip-active-text",n.chipActiveText)}if(e.overlays){const n=e.overlays;o("--ogx-overlay-background",n.background),o("--ogx-overlay-text",n.text),o("--ogx-overlay-border",n.border),o("--ogx-overlay-shadow",n.shadow),o("--ogx-overlay-item-hover-bg",n.itemHoverBackground),o("--ogx-overlay-item-hover-text",n.itemHoverText),o("--ogx-overlay-item-selected-bg",n.itemSelectedBackground),o("--ogx-overlay-item-selected-text",n.itemSelectedText),o("--ogx-overlay-item-danger-bg",n.itemDangerBackground),o("--ogx-overlay-item-danger-text",n.itemDangerText)}if(e.scrollbar){const n=e.scrollbar;o("--ogx-scrollbar-thumb",n.thumbColor),o("--ogx-scrollbar-track",n.trackColor),o("--ogx-scrollbar-size",n.size)}if(e.skeleton){const n=e.skeleton;o("--ogx-skeleton-base",n.baseColor),o("--ogx-skeleton-highlight",n.highlightColor)}return t}function ku({theme:e,children:t,className:o,style:n}){const r=a.useMemo(()=>({...e.mode==="dark"?Cu:Ji,...Su(e)}),[e]);return s.jsx(Mr.Provider,{value:e,children:s.jsx("div",{className:`ogx-theme-provider ${o||""}`.trim(),style:{...n,...r},children:t})})}const Eu={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",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"}},Mu={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"}},Nu={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"}},Pu={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"}},Iu={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 Tu(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Qi(e,t){try{const o=t.getItem(e);return o?JSON.parse(o):void 0}catch{return}}function Lu(e,t,o,n){try{const r=o?Object.fromEntries(Object.entries(t).filter(([i])=>o.includes(i))):t;n.setItem(e,JSON.stringify(r))}catch{}}function Fu(e){const t=typeof e=="string"?{key:e}:e,{key:o,debounceMs:n=300,include:r,storage:i}=t,[l]=a.useState(Tu),c=i??l,d=a.useRef(r),u=a.useRef(c);a.useLayoutEffect(()=>{d.current=r,u.current=c});const[g,m]=a.useState(()=>({key:o,state:c?Qi(o,c):void 0}));let x=g.state;g.key!==o&&(x=c?Qi(o,c):void 0,m({key:o,state:x}));const v=a.useRef(null),h=a.useRef(null),f=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null);const b=h.current;h.current=null;const y=u.current;b&&y&&Lu(b.key,b.state,d.current,y)},[]),w=a.useCallback(b=>{h.current&&h.current.key!==o&&f(),h.current={key:o,state:b},v.current&&clearTimeout(v.current),v.current=setTimeout(f,n)},[o,f,n]);a.useEffect(()=>f,[f]);const p=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),h.current=null;const b=u.current;if(b)try{b.removeItem(o)}catch{}},[o]);return a.useMemo(()=>({initialState:x,onStateChange:w,clearState:p}),[x,w,p])}he.Button=Ht,he.Cell=xi,he.Checkbox=Wt,he.ColumnVisibilityPanel=xn,he.DataGrid=vc,he.DataGridThemeProvider=ku,he.FilterPanel=Li,he.GridToolbar=Gc,he.GridTooltip=Ut,he.Header=qr,he.Input=Hc,he.Pagination=pn,he.Row=xo,he.Skeleton=yc,he.amberTheme=Pu,he.compactTheme=Iu,he.darkTheme=Eu,he.emeraldTheme=Nu,he.exportToCsv=Zc,he.exportToExcel=ou,he.exportToExcelAdvanced=vu,he.exportToJson=nu,he.exportToPdf=Jc,he.formatAggregationValue=qo,he.printGrid=su,he.roseTheme=Mu,he.useAggregation=hi,he.useGridApiRef=Wc,he.useGridStateStorage=Fu,he.usePivot=yu,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})}));
|
|
44
44
|
//# sourceMappingURL=opengridx.umd.js.map
|