@opencorestack/opengridx 3.1.0 → 3.2.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.
@@ -1,15 +1,15 @@
1
- (function(he,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],a):(he=typeof globalThis<"u"?globalThis:he||self,a(he.OpenGridX={},he.ReactJSXRuntime,he.React,he.ReactDOM))})(this,(function(he,a,s,ot){"use strict";function Wo(e,t,o){return Math.max(t??0,Math.min(o??1/0,e))}function nt(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 Wo(r,e.minWidth,e.maxWidth)}const Ke=48;function qe(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function Ml(e,t){const o=[],n=[],r=[];return t?(e.forEach(i=>{const l=qe(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 Ho(e,t,o,n,r,i,l,c){const d={};if(!o)return d;let u=(c?Ke:0)+(i&&l?Ke:0)+(n&&r?Ke:0);const g=[];e.forEach(w=>{if(w.isSpacer)return;const v=qe(w.field,o);v==="left"?(d[w.field]=u,u+=nt(w,t)):v==="right"&&g.push(w)});let m=0;for(let w=g.length-1;w>=0;w--)d[g[w].field]=m,m+=nt(g[w],t);return d}function Bo(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=qe(r.field,t);i==="left"?o=r.field:i==="right"&&n===null&&(n=r.field)}return{lastLeft:o,firstRight:n}}function Un(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Nl(e,t,o=n=>n.id){const n=[],r=[],i=[];return t?(e.forEach(l=>{const c=Un(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 Pl(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 qn=new Set;function ro(e,t,o){process.env.NODE_ENV==="production"||qn.has(e)||(qn.add(e),console.warn(`[OpenGridX] ${t}.`,o))}function io(e,t,o,n){try{return e()}catch(r){return ro(o,n,r),t}}function Xn(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}=Xn(e,t,o);return r!==void 0&&ro(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),n}function zo(e,t,o,n){const r=n?.valueFormatter;if(r)return io(()=>r({value:o,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function rt(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 Il=/^(\d{4})-(\d{2})-(\d{2})$/;function lo(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=Il.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 so(e){const t=lo(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Yn(e){const t=lo(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 Rn=null;function Jn(e){return Rn??=new Intl.DateTimeFormat,Rn.format(e)}function Tl(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=lo(e);return o?Jn(o):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Tl(t.valueOptions,e)??String(e);default:return String(e)}}const Ko=200;function jo(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:Ko}function Uo(e,t){if(e)return io(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Ll(e,t){const o=jo(e);return o==="auto"?t??Ko:o}function Fl(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 Ol=e=>e.id;function Al(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 Dl(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 b=Al(t[f.field]??f.width);b.type==="fixed"?n.set(f.field,{kind:"fixed",width:Wo(b.value,f.minWidth,f.maxWidth)}):b.type==="percentage"?n.set(f.field,{kind:"percentage",percentage:b.value}):n.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,x)=>{const b=n.get(x.field);if(b.kind==="fixed")return f+b.width;if(b.kind==="percentage")return f+100;if(x.flex&&x.flex>0){const h=x.minWidth??150;return f+(h||(typeof x.width=="number"?x.width:150))}return f+(x.minWidth??150)},0),i=Math.max(o,r),l=e.reduce((f,x)=>{const b=n.get(x.field);return b.kind==="fixed"?f+b.width:f},0),c=new Map,d=Math.max(0,i-l);let u=0;e.forEach(f=>{const x=n.get(f.field);if(x.kind==="fixed")c.set(f.field,x.width);else if(x.kind==="percentage"){const b=x.percentage/100*d,h=Wo(b>0?b:100,f.minWidth??50,f.maxWidth);c.set(f.field,h),u+=h}});const g=Math.max(0,d-u),m=new Map,w=e.flatMap(f=>{const x=n.get(f.field);return x.kind!=="flex"?[]:(m.set(f.field,x.flex),[{field:f.field,flex:x.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let v=0;const p=w.length*2;for(;v<p;){v++;const f=w.filter(E=>!E.frozen);if(f.length===0)break;const x=f.reduce((E,I)=>E+I.flex,0),b=w.reduce((E,I)=>I.frozen?E+I.computedWidth:E,0),h=Math.max(0,g-b);if(x<=0){f.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0});break}const y=h/x;let C=0;const N=[],T=[];if(f.forEach(E=>{const I=y*E.flex;I<E.minWidth?(C+=E.minWidth-I,N.push(E)):I>E.maxWidth?(C+=E.maxWidth-I,T.push(E)):E.computedWidth=I}),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 w.forEach(f=>c.set(f.field,f.computedWidth)),{widths:c,flexByField:m}}function $l(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:w,pinnedColumns:v,columnWidths:p,viewportWidth:f,checkboxSelection:x,hasDetailPanel:b,rowReordering:h,pinCheckboxColumn:y,pinExpandColumn:C,paginationMode:N,isLoading:T,pageSize:E,getRowId:I=Ol}=e;return s.useMemo(()=>{const F=o?n:r,G=(K,B)=>{const Q=I(K);if(!i.has(Q))return t;const k=Uo(l,{row:K,id:Q,rowIndex:B});return t+Ll(k,c?.get(Q))},j=F.map((K,B)=>G(K,d+B)),S=j.reduce((K,B,Q)=>(K.push((K[Q-1]||0)+B),K),[]),M=N==="infinite"&&T&&F.length>0?Math.min(E,20):0,P=(S[S.length-1]||0)+M*t,_=(K,B)=>K?K.reduce((Q,k,q)=>Q+G(k,q),0):B*t,L=_(g,d),A=_(m,u),{left:X,center:z,right:J}=Ml(w,v),ee=(x?Ke:0)+(b?Ke:0)+(h?Ke:0),ne=(h?Ke:0)+(b&&C?Ke:0)+(x&&y?Ke:0),{widths:Z,flexByField:ce}=Dl([...X,...z,...J],p,f-ee),ae=K=>Z.get(K.field)??100,oe=K=>({...K,width:ae(K),flex:ce.get(K.field)??K.flex}),de=11,ie=X.map((K,B)=>({...oe(K),zIndex:de+B})),V=11,O=J.map((K,B)=>({...oe(K),zIndex:V+(J.length-1-B)})),$=z.map(oe),Y=$.map(K=>K.width),U=ie.reduce((K,B)=>K+B.width,0),D=O.reduce((K,B)=>K+B.width,0),W=Y.reduce((K,B)=>K+B,0),R=U+W+D+ee,H=Y.reduce((K,B,Q)=>(K.push((K[Q-1]||0)+B),K),[]);return{rowHeights:j,cumulativeHeights:S,unpinnedRowsHeight:P,pinnedTopHeight:L,pinnedBottomHeight:A,leftPinnedCols:ie,rightPinnedCols:O,unpinnedColsWithWidth:$,unpinnedColWidths:Y,unpinnedAccWidths:H,totalWidth:R,leftWidth:U,rightWidth:D,unpinnedTotalWidth:W,systemColumnsWidth:ee,pinnedSystemColumnsWidth:ne,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,unpinnedRowsLength:F.length}},[t,o,n,r,i,l,c,d,u,g,m,w,v,p,f,x,b,h,y,C,N,T,E,I])}function Gl(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Qn(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,Gl(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 Wl(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:w,clientWidth:v}=e;u<w+m?e.scrollLeft=Math.max(0,u-m):g>w+v-i&&(e.scrollLeft=g-v+i)}function Zn(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 Hl={},qo=e=>e==null||typeof e=="string"&&e.trim()==="",er=e=>{const t=[];for(const o of e){const n=rt(o);n!==null&&t.push(n)}return t},tr=(e,t)=>{let o=null,n=null;for(const r of e){const i=rt(r);i!==null&&(o===null||t(i,o))&&(o=i,n=r)}return o===null?null:n instanceof Date?n:o},ao={sum:e=>er(e).reduce((t,o)=>t+o,0),avg:e=>{const t=er(e);return t.length?t.reduce((o,n)=>o+n,0)/t.length:null},count:e=>e.filter(t=>!qo(t)).length,min:e=>tr(e,(t,o)=>t<o),max:e=>tr(e,(t,o)=>t>o),unique:e=>new Set(e.filter(t=>!qo(t))).size};function Xo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function co(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=ao[l];if(!d){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=d(e.map(u=>Fe(u,i,c)))}return r}function Yo(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const Bl=new Set(["count","unique"]);function or(e){return e!==void 0&&Bl.has(e)}function nr(e,t,o){return e?.type==="date"&&(t==="min"||t==="max")&&typeof o=="number"&&Number.isFinite(o)?new Date(o):o}function uo(e,t,o,n){if(e==null)return"—";if(or(t))return Yo(e,t);const r=nr(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())?"":Jn(r):Yo(r,t)}const Ro=new Set(["isEmpty","isNotEmpty"]);function rr(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function zl(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Dt=e=>(t,o)=>{const n=rt(t),r=rt(o);return n===null||r===null?!1:e(n,r)},$t=e=>(t,o)=>{const n=so(t),r=so(o);return n===null||r===null?!1:e(n,r)},ir=$t((e,t)=>e===t),lr=(e,t)=>{const o=so(e),n=so(t);return o===null||n===null?!0:o!==n},sr={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()!=="","=":Dt((e,t)=>e===t),">":Dt((e,t)=>e>t),">=":Dt((e,t)=>e>=t),"<":Dt((e,t)=>e<t),"<=":Dt((e,t)=>e<=t),"!=":(e,t)=>{if(rr(t))return!0;const o=rt(e),n=rt(t);return o!==null&&n!==null?o!==n:zl(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?lr(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?ir(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:$t((e,t)=>e>t),onOrAfter:$t((e,t)=>e>=t),before:$t((e,t)=>e<t),onOrBefore:$t((e,t)=>e<=t)},Vl={is:ir,not:lr};function Kl(e,t){if(!Object.prototype.hasOwnProperty.call(sr,e))return;const o=e;if(t?.type==="date"){const n=Vl[o];if(n)return n}return sr[o]}function jl(e){return"items"in e&&Array.isArray(e.items)}function Ul(e,t){const{field:o,operator:n,value:r}=e;if(!Ro.has(n)&&rr(r))return null;const i=t.columns?.byField.get(o),l=Kl(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 ar(e,t,o){const n=[];for(const r of e){const i=jl(r)?ar(r.items,r.logicOperator,o):Ul(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 Jo(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=Yn(t);o&&e.push(o);return}if(Array.isArray(t))for(const o of t)(o==null||typeof o!="object")&&Jo(e,o)}}function dr(e,t){const o=[];if(!t){for(const n of Object.values(e))Jo(o,n);return o}for(const n of t.quickFilterColumns){const r=Fe(e,n.field,n),i=zo(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Jo(o,r)}return o}const cr=new WeakMap;function ql(e,t){if(!t)return dr(e,t);let o=cr.get(t);o||(o=new WeakMap,cr.set(t,o));let n=o.get(e);return n||(n=dr(e,t),o.set(e,n)),n}function Xl(e,t){const o=(e??[]).map(n=>String(n??"").trim().toLowerCase()).filter(n=>n!=="");return o.length===0?null:n=>{const r=ql(n,t);return o.every(i=>r.some(l=>l.includes(i)))}}function fo(e,t){if(!e)return null;const o={columns:t,warned:new Set},n="quickFilterValues"in e?e.quickFilterValues:void 0,r=Xl(n,t),i=ar(e.items??[],e.logicOperator??"and",o);return r&&i?l=>r(l)&&i(l):r??i}function Qo(e,t,o){const n=fo(t,o);return n?e.filter(r=>n(r)):e}function Yl(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 Rl=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Zo=0,ur=1,Jl=2,fr=3,gr=4;function ht(e,t){return{rank:e,num:t,str:""}}function en(e,t){if(e==null)return null;if(t==="number"){const o=rt(e);return o===null?null:ht(Zo,o)}if(t==="date"){const o=lo(e);return o?ht(ur,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(Zo,e);case"bigint":return ht(Zo,Number(e));case"boolean":return ht(Jl,e?1:0);case"string":return{rank:fr,num:0,str:e}}if(e instanceof Date){const o=e.getTime();return Number.isNaN(o)?null:ht(ur,o)}return{rank:gr,num:0,str:String(e)}}function pr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===fr||e.rank===gr?Rl.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function tn(e,t){return e===0?0:t==="asc"?e:-e}function Ql(e,t,o,n){return tn(pr(en(e,n),en(t,n)),o)}function hr(e,t,o){let n;try{n=e(t.value,o.value,t,o)}catch(r){return ro(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof n!="number"||Number.isNaN(n)?(ro(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(n)}; the values are treated as equal`,void 0),0):n}const Zl=e=>e.id;function es(e,t,o,n=Zl){return t.length===0?e:on(e,t,(r,i)=>{const l=o?.byField.get(i.field),c=Fe(r,i.field,l);return{value:c,type:l?.type,comparator:l?.sortComparator,params:l?.sortComparator?{id:n(r),field:i.field,row:r,value:c}:void 0}})}function on(e,t,o){if(t.length===0||e.length<2)return[...e];const n=t.map(l=>e.map(c=>o(c,l))),r=n.map(l=>l.map(({value:c,type:d})=>en(c,d))),i=e.map((l,c)=>c);return i.sort((l,c)=>{for(let d=0;d<t.length;d++){const u=n[d][l],g=n[d][c],m=u.comparator&&u.comparator===g.comparator&&u.params&&g.params?hr(u.comparator,u.params,g.params):pr(r[d][l],r[d][c]),w=tn(m,t[d].sort);if(w!==0)return w}return l-c}),i.map(l=>e[l])}function ts(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 nn(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 mt="__pivot_grand_total__",os="__pivot_row__:",mr=e=>`${os}${JSON.stringify(e.split(wr))}`,ns="Grand Total",wr="\0",wt="",rn=`${wt}id`,xr=e=>e==="id"?rn:e,ln={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},br=e=>e.map(t=>String(t??"")).join(wr),vr=e=>e===void 0||e===""?null:e;function rs(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 is(e,t){for(let o=0;o<e.length;o++){const n=rs(e[o],t[o]);if(n!==0)return n}return 0}function yr(e,t){if(!e||e.length===0)return null;const o=ao[t](e);return typeof o=="number"||o instanceof Date?o:null}const ls=e=>"logicOperator"in e&&"items"in e,ss=e=>!!(e&&e.items&&e.items.length>0);function as(e,t){const o=l=>!t.has(l)&&l.includes(wt),n=l=>ls(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 Cr(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}${wt}${S.aggFn}`;return d.has(M)?!1:(d.add(M),!0)});if(l.length===0||u.length===0)return ln;const g=c.length>0,m=Array.from(new Set(u.map(S=>S.field))),w=(S,M)=>Fe(S,M,r.get(M)),v=new Map,p=new Map(g?[]:[["",{values:[]}]]);for(const S of e){const M=l.map(J=>w(S,J)),P=br(M);let _=v.get(P);_||(_={labels:M.map(vr),sample:S,cells:new Map},v.set(P,_));const L=c.map(J=>w(S,J)),A=g?br(L):"",X=p.get(A);X?X.sample||(X.sample=S):p.set(A,{values:L.map(vr),sample:S});let z=_.cells.get(A);z||(z=new Map,_.cells.set(A,z));for(const J of m){const ee=w(S,J);if(qo(ee))continue;let ne=z.get(J);ne||(ne=[],z.set(J,ne)),ne.push(ee)}}const f=Array.from(p.keys()).sort((S,M)=>is(p.get(S).values,p.get(M).values)),x=(S,M)=>g?`${S}${wt}${M.field}${wt}${M.aggFn}`:`${M.field}${wt}${M.aggFn}`,b=new Map;let h=[];for(const[S,M]of v){const P={id:mr(S)};l.forEach((_,L)=>{P[xr(_)]=M.labels[L]}),P.id=mr(S);for(const _ of f){const L=M.cells.get(_);for(const A of u)P[x(_,A)]=yr(L?.get(A.field),A.aggFn)}b.set(P.id,M),h.push({row:P,entry:M})}const y=S=>l.includes(S),C=S=>y(S)?r.get(S)?.type:"number",{outputFilterModel:N,sortModel:T}=n;if(ss(N)){const S=[];for(const P of f)for(const _ of u)S.push({field:x(P,_),type:"number"});const M=fo(N,nn(S));M&&(h=h.filter(({row:P})=>M(P)))}const E=(S,M)=>M==="id"&&y("id")?S[rn]:S[M];T&&T.length>0&&(h=[...h].sort((S,M)=>{for(const P of T){const _=E(S.row,P.field),L=E(M.row,P.field),A=y(P.field)?r.get(P.field)?.sortComparator:void 0,X=A?tn(hr(A,{id:S.row.id,field:P.field,row:S.row,value:_},{id:M.row.id,field:P.field,row:M.row,value:L}),P.sort):Ql(_,L,P.sort,C(P.field));if(X!==0)return X}return 0}));const I=h.map(S=>S.row);if(h.length>0){const S={id:mt};l.forEach((M,P)=>{S[xr(M)]=P===0?ns:""}),S.id=mt;for(const M of f)for(const P of m){const _=[];for(const{entry:L}of h){const A=L.cells.get(M)?.get(P);if(A)for(const X of A)_.push(X)}for(const L of u)L.field===P&&(S[x(M,L)]=yr(_,L.aggFn))}I.push(S)}const F=h[0]?.entry.sample,G=S=>S===mt?F:S===void 0?void 0:b.get(S)?.sample,j=l.map(S=>cs(S,r.get(S),G));for(const S of f){const M=p.get(S),P=g?c.map((_,L)=>{const A=r.get(_),X=ds(A,_,M.values[L],M.sample);return A?.headerName?`${A.headerName}: ${X}`:X}).join(" / "):"";for(const _ of u){const L=r.get(_.field),A=_.headerName??L?.headerName??_.field;j.push({field:x(S,_),headerName:P?`${P} — ${A} (${_.aggFn})`:`${A} (${_.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:X,row:z})=>uo(X,_.aggFn,L,z)})}}return{pivotRows:I,pivotColumns:j,colKeys:f,isValid:!0}}function ds(e,t,o,n){const r=n?zo(n,t,o,e):void 0;return r!==void 0?r:o==null?"":String(o)}function cs(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[rn]);const r=c=>c?.id===mt,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 Xe(e,t){return e===mt||t?.get(e)?.isGroupRow===!0}const Gt="__reorder_col__",Wt="__expand_col__",Ye="__checkbox_col__",it=e=>e===Gt||e===Wt||e===Ye,_r=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,us=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),fs=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function gs(e){const t=e.tagName;if(t==="INPUT")return!us.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&&fs.has(o)}const Sr=e=>e!==null&&e.nodeType===1;function kr(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 ps(e,t){if(e===t)return"grid";if(!Sr(e)||!t.contains(e))return"foreign";const o=kr(e,t);return o?o.classList.contains("ogx__cell--editing")?"editor":o===e?"grid":gs(e)?"foreign":o.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function hs(e,t,o,n){if(!Sr(e))return null;const r=kr(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 Er(e,t){if(!e)return null;for(const o of Array.from(e.children))if(o.dataset.field===t)return o;return null}function sn(e,t,o){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Er(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 Er(n,t.field)}const ms=e=>e.id,Mr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function ws(e,t,o,n){if(!e||o.length===0)return{cell:null,rowIndex:-1};const r=(o.find(d=>!it(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 xs(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:w=!1,isCellEditable:v,pagination:p,pageSize:f,virtualization:x,viewportRef:b,pinnedTopRowCount:h=0,getRowId:y=ms,rowMetaMap:C,onRowActivate:N,toggleRowExpansion:T,handleSelectAll:E,rowSelectionEnabled:I=!0,multipleRowSelectionEnabled:F=!0,pinCheckboxColumn:G=!0,pinExpandColumn:j=!0,rowHeight:S,getSpanOrigin:M}=e,[P,_]=s.useState(null),[L,A]=s.useState(!1),X=s.useMemo(()=>ws(P,t,o,y),[P,t,o,y]),z=X.cell,J=X.rowIndex,ee=s.useRef(!1),ne=s.useRef(!1),Z=s.useRef(!1),ce=s.useRef(null),ae=s.useCallback(D=>{ne.current=!0,D.focus({preventScroll:!0}),ne.current=!1},[]),oe=s.useCallback(()=>{const D=b.current;D&&!D.contains(D.ownerDocument.activeElement)&&ae(D)},[b,ae]),de=s.useMemo(()=>o.find(D=>!it(D.field))??o[0],[o]),ie=s.useCallback(()=>{if(n)return{id:null,field:Ye};if(!de)return null;const D=t[0];return D?{id:y(D),field:de.field,rowIndex:0}:{id:null,field:de.field}},[n,de,t,y]),V=s.useCallback((D,W)=>{const R=b.current;if(!R)return;const{cumulativeHeights:H,pinnedBottomHeight:K,columnMetrics:B}=x;if(D>=0&&Qn(R,D-h,H,K,S),it(W)){!(W===Gt||W===Wt&&j||W===Ye&&G)&&R.scrollLeft>0&&(R.scrollLeft=0);return}if(!B)return;const{clientWidth:Q,scrollLeft:k}=R,{leftPinnedWidth:q,rightPinnedWidth:re,unpinnedAccWidths:te,unpinnedCols:ue,totalSpecialsWidth:ge,pinnedSpecialsWidth:me}=B,Se=ue.findIndex(ye=>ye.field===W);if(Se===-1)return;const fe=ge+q+(Se>0?te[Se-1]:0),xe=ge+q+te[Se],be=k+me+q,ve=k+Q-re;let se=k;fe<be?se=Math.max(0,fe-me-q):xe>ve&&(se=xe-Q+re),se!==k&&(R.scrollLeft=se)},[b,x,h,S,G,j]);s.useLayoutEffect(()=>{const D=b.current,W=!_r(ce.current,z);if(ce.current=z,!D||!z)return;const R=D.ownerDocument,H=R.activeElement;let K;if(H===D?K=!0:!H||H===R.body?K=ee.current:D.contains(H)?K=W:K=!1,!K)return;const B=sn(D,z,J);B?B.contains(H)||B.focus({preventScroll:!0}):H!==D&&ae(D)});const O=s.useCallback(()=>{Z.current=!0,d(!1)},[d]),$=s.useCallback(D=>{const W=D.currentTarget,R=D.relatedTarget,H=!(R instanceof Node&&W.contains(R)),K=Z.current;if(Z.current=!1,ee.current=!0,A(!0),ne.current)return;if(D.target===W){if(!H)return;if(K||d(!0),z){const k=sn(W,z,J);k?k.focus({preventScroll:!0}):V(J,z.field);return}const Q=ie();Q&&(_(k=>k??Q),V(Q.rowIndex??-1,Q.field));return}const B=hs(D.target,W,t,y);B&&!_r(B,z)&&_(B)},[z,J,ie,V,d,t,y]),Y=s.useCallback(D=>{const W=D.relatedTarget;W instanceof Node&&D.currentTarget.contains(W)||(ee.current=!1,Z.current=!1,A(!1),d(!1))},[d]),U=s.useCallback(D=>{const W=D.currentTarget,R=ps(D.target,W);if(R==="foreign"||(d(!0),D.nativeEvent?.isComposing||D.keyCode===229))return;const{key:H}=D,K=H===" "||H==="Spacebar",B=!!c.editingCell,Q=(le,pe)=>{const we=o[pe];!we||le<-1||le>=t.length||(_(le===-1?{id:null,field:we.field}:{id:y(t[le]),field:we.field,rowIndex:le}),V(le,we.field))};if(!z){if(!Mr.has(H))return;const le=ie();if(!le)return;D.preventDefault(),_(le),V(le.rowIndex??-1,le.field);return}const{id:k,field:q}=z,re=J,te=o.findIndex(le=>le.field===q),ue=o.filter(le=>it(le.field)).length,ge=le=>Xe(le,C),me=(le,pe,we)=>{const Ne=o[we];return it(Ne.field)?!1:Zn({row:le,field:Ne.field,value:Fe(le,Ne.field,Ne),colDef:Ne,rowIndex:pe,colIndex:we-ue,rowMeta:C?.get(y(le))},v)},Se=le=>{let pe=re,we=te;const Ne=(t.length+1)*o.length;for(let Qe=0;Qe<Ne;Qe++){if(we+=le,we>=o.length?(we=0,pe++):we<0&&(we=o.length-1,pe--),pe<0||pe>=t.length)return null;const _e=t[pe];if(!M?.(y(_e),o[we].field)&&me(_e,pe,we))return{r:pe,c:we}}return null};if(B){if(H==="Enter")D.preventDefault(),c.stopCellEdit();else if(H==="Escape")D.preventDefault(),c.stopCellEdit({cancel:!0});else if(H==="Tab"&&k!==null){const le=Se(D.shiftKey?-1:1);le&&(D.preventDefault(),c.stopCellEdit(),Q(le.r,le.c))}return}if(H==="Tab"||H==="Escape"||R==="control"&&(H==="Enter"||K))return;if((D.ctrlKey||D.metaKey)&&(H==="a"||H==="A")){if(!I||!F||!E)return;D.preventDefault(),E(!0);return}if(k===null){if(H==="Enter"||K){if(D.preventDefault(),q===Ye){sn(W,z,-1)?.click();return}const le=o[te];if(!le||it(q)||le.sortable===!1)return;const pe=u.find(Ne=>Ne.field===q),we=pe?pe.sort==="asc"?"desc":null:"asc";(w||D.shiftKey)&&m?m(q,we):g(q,we);return}}else if(H==="Enter"||K){D.preventDefault();const le=t[re];if(q===Ye){i(k,!r.has(k));return}if(q===Wt){D.shiftKey||l(k);return}if(K){D.shiftKey&&I&&!ge(k)&&i(k,!r.has(k));return}if(q===Gt)return;if(me(le,re,te)){c.startCellEdit({id:k,field:q,value:Fe(le,q,o[te])});return}if(T&&C?.get(k)?.hasChildren){T(k);return}N?.({row:le,id:k,rowIndex:re});return}if(D.altKey&&(H==="ArrowRight"||H==="ArrowLeft")&&T&&k!==null){D.preventDefault();const le=C?.get(k);le?.hasChildren&&!!le.isExpanded!=(H==="ArrowRight")&&T(k);return}if(!Mr.has(H))return;D.preventDefault();const fe=t.length-1,xe=o.length-1,be=D.ctrlKey||D.metaKey,ve=p?f:10,se=(le,pe)=>{switch(H){case"ArrowRight":return pe+1>xe?{r:le+1,c:0}:{r:le,c:pe+1};case"ArrowLeft":return pe-1<0?{r:le-1,c:xe}:{r:le,c:pe-1};case"ArrowDown":return{r:le+1,c:pe};case"ArrowUp":return{r:le-1,c:pe};case"Home":return{r:be?-1:le,c:0};case"End":return{r:be?fe:le,c:xe};case"PageUp":return{r:Math.max(-1,le-ve),c:pe};default:return{r:Math.min(fe,le+ve),c:pe}}},ye=({r:le,c:pe})=>le>=-1&&le<=fe&&pe>=0&&pe<=xe,Te=({r:le,c:pe})=>le>=0?M?.(y(t[le]),o[pe].field)??null:null;let Ce=se(re,te);if(H.startsWith("Arrow"))for(let le=ye(Ce)?Te(Ce):null;le&&le.rowId===k&&le.field===q;le=ye(Ce)?Te(Ce):null)Ce=se(Ce.r,Ce.c);if(!ye(Ce))return;const ke=Te(Ce);if(ke){const le=t.findIndex(we=>y(we)===ke.rowId),pe=o.findIndex(we=>we.field===ke.field);le!==-1&&pe!==-1&&(Ce={r:le,c:pe})}Ce.r===re&&Ce.c===te||Q(Ce.r,Ce.c)},[z,J,t,o,c,r,i,l,d,u,g,m,w,v,p,f,C,N,T,E,I,F,ie,V,M,y]);return{focusedCell:z,setFocusedCell:_,viewportTabIndex:L?-1:0,ensureGridFocus:oe,handleFocus:$,handleBlur:Y,handleKeyDown:U,handleMouseDownCapture:O}}const bs={rowFields:[],columnFields:[],valueFields:[]},Nr=100;function vs(e){return!e||e.length===0||e.includes(Nr)?Nr:e[0]}function ys(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:w,onPivotModelChange:v,paginationModel:p,onPaginationModelChange:f,pageSizeOptions:x,rowSelectionModel:b,onRowSelectionModelChange:h,density:y}=e,[C,N]=s.useState(()=>t?.sorting?.sortModel??[]),T=o!==void 0,E=T?o:C,I=s.useCallback(fe=>{T||N(fe),n?.(fe)},[T,n]),[F,G]=s.useState(()=>t?.filter?.filterModel??{items:[]}),j=r!=null,S=j?r:F,M=s.useCallback(fe=>{j||G(fe),i?.(fe)},[j,i]),P=l!==void 0,[_,L]=s.useState(()=>l??{}),A=JSON.stringify(P?l:_),X=s.useMemo(()=>JSON.parse(A),[A]),z=s.useCallback(fe=>{P||L(fe),c?.(fe)},[P,c]),J=d!==void 0,[ee,ne]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),Z=J?d:ee,ce=s.useCallback(fe=>{J||ne(fe),u?.(fe)},[J,u]),ae=g!==void 0,[oe,de]=s.useState(()=>t?.columns?.pinnedColumns??{}),ie=ae?g:oe,V=s.useCallback(fe=>{ae||de(fe),m?.(fe)},[ae,m]),[O,$]=s.useState(()=>w??bs),Y=w??O,U=s.useCallback(fe=>{$(fe),v?.(fe)},[v]),D=p!==void 0,[W,R]=s.useState(()=>t?.pagination?.paginationModel??p??{page:0,pageSize:vs(x)}),H=D?p:W,K=s.useCallback(fe=>{D||R(fe),f?.(fe)},[D,f]),B=b!==void 0,[Q,k]=s.useState([]),q=B?b:Q,re=s.useMemo(()=>new Set(q),[q]),te=s.useRef(null);s.useLayoutEffect(()=>{te.current=null});const ue=s.useCallback(()=>te.current,[]),ge=s.useCallback(fe=>{te.current=fe,B||k(fe),h?.(fe)},[B,h]),[me]=s.useState(()=>t?.density?.density??"standard");return{sortModel:E,isSortControlled:T,setInternalSortModel:N,handleSortModelChange:I,filterModel:S,isFilterControlled:j,handleFilterModelChange:M,aggregationModel:X,handleAggregationModelChange:z,columnVisibilityModel:Z,handleColumnVisibilityModelChange:ce,pinnedColumns:ie,handlePinnedColumnsChange:V,currentPivotModel:Y,handlePivotModelChange:U,effectivePaginationModel:H,handlePaginationModelChange:K,rowSelectionModel:q,selectedRowIds:re,isSelectionControlled:B,setInternalRowSelectionModel:k,handleRowSelectionModelChange:ge,getPendingRowSelectionModel:ue,density:y??me}}const Pr=s.createContext(null),Cs=52,_s=56,Ss=32,ks=72;function go(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 Es(e){const{rowHeight:t,headerHeight:o,density:n}=e,r=s.useContext(Pr)?.grid;let i;return n==="compact"?i=go(r?.rowHeightCompact)??Ss:n==="comfortable"?i=go(r?.rowHeightComfortable)??ks:i=t??go(r?.rowHeightStandard)??Cs,{rowHeight:i,headerHeight:o??go(r?.headerHeight)??_s}}function po(e){return e>=1?Math.floor(e):1}function an(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/po(t)))}function Ms(e){const{paginationMode:t,hasDataSource:o,dataSourceRowCount:n,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(o?n??r:r)??i}function Ir(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Tr(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Ns(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:w,hierarchyField:v}=e,p=s.useMemo(()=>o?o.getVisibleRows({labelField:v})||[]:n==="server"?t:Qo(t,r,w),[t,r,o,v,n,w]),f=s.useMemo(()=>o?n==="server"?t:Qo(t,r,w):p,[o,p,n,t,r,w]),{top:x,center:b,bottom:h}=s.useMemo(()=>o?{top:[],center:p,bottom:[]}:Nl(p,g,m),[p,g,o,m]),y=s.useMemo(()=>o||l==="server"?b:es(b,i,w,m),[b,i,o,l,w,m]),C=c&&d!=="server",N=po(u.pageSize),T=C?Tr(u.page,an(y.length,N)):u.page,E=s.useMemo(()=>{if(!C)return y;const F=T*N;return y.slice(F,F+N)},[y,C,T,N]),I=s.useMemo(()=>{const F=c?E:y;return[...x,...F,...h]},[x,E,y,h,c]);return{filteredRows:p,dataRows:f,pinnedTopRows:x,unpinnedRows:b,pinnedBottomRows:h,sortedUnpinnedRows:y,paginatedUnpinnedRows:E,currentPage:T,allRenderableRows:I}}function Ps(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:w=5}=e;return s.useMemo(()=>{const{unpinnedAccWidths:v,unpinnedColsWithWidth:p,leftPinnedCols:f,rightPinnedCols:x,totalWidth:b,leftWidth:h,rightWidth:y,unpinnedTotalWidth:C,systemColumnsWidth:N,cumulativeHeights:T,pinnedTopHeight:E,pinnedBottomHeight:I,unpinnedRowsHeight:F,rowHeights:G,unpinnedRowsLength:j}=t,S=r||1e3,M=l?E+F+I+50:i||600,P=6,_=Math.max(0,n-h),L=n+S-h;let A=0,X=p.length-1,z=0,J=v.length-1;for(;z<=J;){const U=z+J>>>1;v[U]<_?z=U+1:J=U-1}A=Math.max(0,z-P);for(let U=A;U<v.length;U++){if((U===0?0:v[U-1])>L){X=Math.min(p.length-1,U+P);break}X=Math.min(p.length-1,U+P)}const ee=A>0?v[A-1]:0,ne=C-v[X],Z=[...f,...ee>0?[{field:"__spacer_left__",width:ee,isSpacer:!0}]:[],...p.slice(A,X+1),...ne>0?[{field:"__spacer_right__",width:ne,isSpacer:!0}]:[],...x],ae=S>0&&b>S?16:0,oe=E+F+I+ae+2;let de=0,ie=j-1,V=0,O=0,$=T.length-1;for(;O<=$;){const U=O+$>>>1;T[U]<o?O=U+1:$=U-1}de=Math.max(0,O-w),V=de>0?T[de-1]:0;for(let U=de;U<T.length;U++)if(T[U]>=o+M){ie=Math.min(j-1,U+w);break}const Y=(c?48:0)+(d&&m?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:de,lastRowIndex:ie,firstColumnIndex:A,lastColumnIndex:X},offsetTop:V,offsetLeft:0,totalHeight:oe,pinnedTopHeight:E,pinnedBottomHeight:I,totalWidth:b,rowHeights:G,cumulativeHeights:T,virtualColumns:Z,columnMetrics:{leftPinnedWidth:h,rightPinnedWidth:y,unpinnedAccWidths:v,unpinnedCols:p,totalSpecialsWidth:N,pinnedSpecialsWidth:Y}}},[t,o,n,r,i,l,c,d,u,g,m,w])}const dn="application/x-ogx-row",cn="application/x-ogx-column";function Lr(e,t,o){const n=e.dataTransfer;!n||typeof n.setData!="function"||(n.setData(t,o),n.setData("text/plain",o))}function ho(e,t){const o=e.dataTransfer?.types;return o?Array.from(o).includes(t):!0}function Fr(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const o=()=>t();return e.addEventListener("dragend",o,{once:!0}),()=>e.removeEventListener("dragend",o)}function Is(e){const{columns:t,onColumnOrderChange:o,disableColumnReorder:n=!1}=e,[r,i]=s.useState(null),[l,c]=s.useState(null),d=s.useRef(()=>{}),u=s.useCallback(()=>{d.current(),d.current=()=>{},i(null),c(null)},[]);s.useEffect(()=>()=>d.current(),[]);const g=s.useCallback(v=>p=>{if(!n){if(!t.some(f=>f.field===v)){p.preventDefault();return}d.current(),d.current=Fr(p.currentTarget,u),i(v),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Lr(p,cn,v))}},[t,n,u]),m=s.useCallback(v=>p=>{if(!(n||r===null)){if(!ho(p,cn)){u();return}p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),c(v)}},[r,n,u]),w=s.useCallback(v=>p=>{if(p.preventDefault(),n||r===null||!ho(p,cn)){u();return}const f=t.findIndex(b=>b.field===r),x=t.findIndex(b=>b.field===v);u(),!(f===-1||x===-1||f===x)&&o?.({column:t[f],oldIndex:f,targetIndex:x})},[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:w}}function un({isExpanded:e,onClick:t,variant:o="chevron",tabIndex:n}){return a.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",type:"button",tabIndex:n,children:o==="plus-minus"?a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:a.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Ts({renderFn:e}){return a.jsx(a.Fragment,{children:e()})}function Ls(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 lt extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,o){return Ls(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?a.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):a.jsx(Ts,{renderFn:this.props.renderFn})}}function Fs(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)?uo(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Or(e,t){if(!t)return e;const o=t.left??[],n=t.right??[],r=i=>{const l=qe(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 mo=e=>e.formattedValue??e.value;function Ar(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:a.jsx(lt,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:a.jsx(lt,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Os(e,t,o){const n=e.rowMeta;if(!n?.isGroupRow)return mo(e);if(n.isGroupFooter)return null;const r=n.descendantCount;if(t&&n.hasChildren){const i=n.groupLabel??`${n.groupingField}: ${String(n.groupingValue)}`;return a.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return o?a.jsxs("div",{className:"ogx__group-cell-content",children:[n.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):mo(e)}const As=e=>e.id;function Ds(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:w,hasDetailPanel:v,rowReordering:p,initialState:f,setColumns:x,pinnedColumns:b,getRowId:h=As,aggregationModel:y,groupingRows:C}=e,N=s.useMemo(()=>t.map($=>$.field),[t]),[T,E]=s.useState(()=>f?.columns?.columnOrder??null),I=m?N.join("\0"):"",[F,G]=s.useState(null),j=F&&F.key===I?F.order:N,M=m?j:c??(T??N),P=s.useCallback($=>{if(m){G(Y=>{const U=Y&&Y.key===I?Y.order:N;return{key:I,order:typeof $=="function"?$(U):$}});return}E(Y=>typeof $=="function"?$(Y??N):$)},[m,I,N]),_=s.useCallback($=>m&&$.hideable===!1||l[$.field]!==!1,[m,l]),L=s.useMemo(()=>{if(!o)return;const $=new Map(M.map((W,R)=>[W,R])),Y=W=>$.get(W.field)??t.indexOf(W),U=[...t].sort((W,R)=>Y(W)-Y(R));return(Or(U.filter(W=>l[W.field]!==!1),b)[0]??t[0])?.field},[o,M,t,l,b]),A=s.useMemo(()=>{if(!o)return t;const $=n?C:void 0;return t.map(Y=>{const U=Fs(Y,y?.[Y.field],$);return Y.field===L?{...Y,...U,renderCell:D=>{const W=D.rowMeta,R=W?.treeDepth??0,H=!!W?.hasChildren,K=!!W?.isExpanded,B=Ar(Y,D,!0),Q=B.useDefault?Os(D,n,r):B.content;return a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:R*24,width:"100%",height:"100%"},children:[a.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?a.jsx("div",{onClick:k=>{k.stopPropagation(),k.preventDefault(),i?.toggleExpansion(h(D.row))},onMouseDown:k=>{k.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:a.jsx(un,{isExpanded:K,tabIndex:-1,onClick:k=>{k.stopPropagation(),k.preventDefault(),i?.toggleExpansion(h(D.row))}})}):null}),a.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q})]})}}:{...Y,...U,renderCell:D=>{const W=D.rowMeta;if(!W?.isGroupRow)return Y.renderCell?Y.renderCell(D):mo(D);const R=Ar(Y,D,!1);return R.useDefault?Y.field===W.groupingField&&!W.isGroupFooter||D.value==null?null:mo(D):R.content}}})},[t,o,n,r,i,L,h,y,C]),[X,z]=s.useState(()=>f?.columns?.columnWidths??{}),J=s.useCallback(($,Y)=>{z(U=>({...U,[$]:Y}))},[]);s.useEffect(()=>{x(t)},[t,x]);const ee=s.useMemo(()=>{const $=new Map(M.map((Y,U)=>[Y,U]));return[...A].sort((Y,U)=>{const D=$.get(Y.field)??A.indexOf(Y),W=$.get(U.field)??A.indexOf(U);return D-W})},[A,M]),ne=s.useMemo(()=>ee.filter(_),[ee,_]),Z=s.useCallback(($,Y)=>{(m||!c)&&P($),Y&&d?.(Y),m||u?.($)},[m,c,P,d,u]),ce=s.useCallback(($,Y)=>{const U=ee.map(W=>W.field),[D]=U.splice($,1);U.splice(Y,0,D),Z(U,{column:ee[$],oldIndex:$,targetIndex:Y})},[ee,Z]),ae=Is({columns:ee,onColumnOrderChange:s.useCallback(({oldIndex:$,targetIndex:Y})=>ce($,Y),[ce]),disableColumnReorder:g}),oe=s.useCallback(($,Y)=>{const U=ee.findIndex(W=>W.field===$),D=ee.findIndex(W=>W.field===Y);U===-1||D===-1||U===D||ce(U,D)},[ee,ce]),de=s.useCallback(()=>{Z(N)},[Z,N]),ie=s.useMemo(()=>Or(ne,b),[ne,b]),V=s.useMemo(()=>{const $=[];return p&&$.push({field:Gt,sortable:!1,editable:!1}),v&&$.push({field:Wt,sortable:!1,editable:!1}),w&&$.push({field:Ye,sortable:!1,editable:!1}),[...$,...ie]},[ie,w,v,p]),O=s.useMemo(()=>new Map(ie.map(($,Y)=>[$.field,Y])),[ie]);return{effectiveColumns:A,hierarchyField:L,orderedColumns:ee,visibleOrderedColumns:ne,renderOrderedColumns:ie,navigationColumns:V,columnIndexMap:O,columnWidths:X,effectiveColumnOrder:M,setInternalColumnOrder:P,columnReorderHandlers:ae,moveColumn:oe,resetColumnOrder:de,handleColumnResize:J}}const $s=e=>e.id;function Gs(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=$s}=e;return s.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:u}=t,g=l?r:i,m=o.length,w=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"})),p=Math.max(0,d),f=Math.min(g.length,u+1),x=g.slice(p,f).map((y,C)=>({row:y,id:c(y),rowIndex:m+p+C})),b=[...w,...x,...v],h=new Set;return b.filter(y=>h.has(y.id)?!1:(h.add(y.id),!0))},[t,o,n,r,i,l,c])}const Ws=100;function Dr(e){const{scrollTop:t,scrollHeight:o,clientHeight:n}=e;return o-t-n>=Ws?null:{visibleTop:t,visibleBottom:t+n,viewportHeight:n}}function Hs(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Bs(e){const{onRowsScrollEnd:t,overscanRowCount:o=3,rowCount:n=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),c=s.useRef(null),d=s.useRef(null),u=s.useRef(null),g=s.useRef(!0),m=s.useRef(t),[w,v]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{m.current=t},[t]),s.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),d.current!==null&&clearTimeout(d.current)},[]);const p=s.useCallback(b=>{const h=Dr(b);if(!h){g.current=!0;return}if(!g.current)return;const y=m.current;y&&(g.current=!1,y(h))},[]),f=s.useCallback(b=>{const h=b.currentTarget,y=performance.now(),C=Math.abs(h.scrollTop-l.current.scrollTop)+Math.abs(h.scrollLeft-l.current.scrollLeft),N=y-l.current.time,T=N>0?C/N:0,E=h.scrollTop!==l.current.scrollTop;l.current={scrollTop:h.scrollTop,scrollLeft:h.scrollLeft,time:y},i.current={scrollTop:h.scrollTop,scrollLeft:h.scrollLeft,velocity:T},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:I,scrollLeft:F,velocity:G}=i.current;v({scrollTop:I,scrollLeft:F,velocityOverscan:Hs(G)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,v(I=>I.velocityOverscan===0?I:{...I,velocityOverscan:0})},200),E&&p(h)},[p]);s.useEffect(()=>{g.current=!0;const b=u.current;!b||r||n<=0||b.clientHeight===0||p(b)},[n,r,p]);const x=s.useCallback(b=>{if(u.current=b,!b)return;const{scrollTop:h,scrollLeft:y}=i.current;if(h===0&&y===0)return;b.scrollTop=h,b.scrollLeft=y;const C={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft};(C.scrollTop!==h||C.scrollLeft!==y)&&(i.current={...i.current,...C},l.current={...l.current,...C},v(N=>({...N,...C})))},[]);return{scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,overscanRows:Math.max(w.velocityOverscan,o),handleScroll:f,attachViewport:x}}function zs(e){const t=s.useRef(null);return s.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 Vs(e){const{setDimensions:t,viewportRef:o,...n}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:d}=Bs(n),u=zs(t),g=s.useCallback(m=>{o.current=m,u(m),d(m)},[o,u,d]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:g}}function Ks(){const[e,t]=s.useState(()=>new Map),o=s.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 js(e){const{hasDetailPanel:t,controlledExpandedRowIds:o,onDetailPanelExpandedRowIdsChange:n,rowMetaMap:r}=e,[i,l]=s.useState(new Set),c=o??i,d=s.useMemo(()=>Fl(c,r),[c,r]),u=s.useCallback(w=>{if(r.get(w)?.isGroupRow)return;const v=new Set(c);v.has(w)?v.delete(w):v.add(w),o===void 0&&l(v),n?.(v)},[c,r,o,n]),{detailPanelHeights:g,reportDetailPanelHeight:m}=Ks();return{hasDetailPanel:t,expandedRowIds:d,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:m}}const Us=new Set(["__group__"]),Ht=e=>!Us.has(e);function $r(e){return Object.keys(e).every(Ht)?e:Object.fromEntries(Object.entries(e).filter(([o])=>Ht(o)))}function qs(e){const t={...e};return e.left&&(t.left=e.left.filter(Ht)),e.right&&(t.right=e.right.filter(Ht)),t}function Xs(e){const{onStateChange:t,sortModel:o,filterModel:n,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:d,density:u}=e,g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t});const m=s.useRef(null);s.useEffect(()=>{if(!g.current)return;const w={sorting:{sortModel:o},filter:{filterModel:n},pagination:{paginationModel:r},columns:{columnWidths:$r(i),columnOrder:l.filter(Ht),columnVisibilityModel:$r(c),pinnedColumns:qs(d)},density:{density:u}},v=JSON.stringify(w);v!==m.current&&(m.current=v,g.current(w))},[o,n,r,i,l,c,d,u])}const Ys=200,Rs=2e3,Js=178e5;function Qs(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=s.useRef(!1),w=s.useRef(!1),v=s.useRef(!1),p=s.useRef(!1),f=s.useRef(!1),x=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||g<=Rs||(x.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${g} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[g]),s.useEffect(()=>{process.env.NODE_ENV==="production"||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]),s.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]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||d<=Js||(p.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]),s.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]),s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||n||r>0&&l>Ys&&i>=l&&r>=d&&(w.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 Zs(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Gr=!1;function ea(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||Gr)return;const t=e.current;!t||!Zs(t)||(Gr=!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 ta(e,t,o){return o?e.has(t)?[]:[t]:wo(e,[t],!e.has(t),!1)}function Wr(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function oa(e){const{selectedRowIds:t,onSelectionModelChange:o,disableMultipleRowSelection:n,selectableRowIds:r}=e,i=s.useCallback(m=>{Wr(t,m)||o(m)},[t,o]),l=s.useCallback((m,w)=>{i(wo(t,[m],w,n))},[i,t,n]),c=s.useCallback(m=>{i(ta(t,m,n))},[i,t,n]),d=s.useCallback(m=>{i(wo(t,r,m,!1))},[i,t,r]),{allSelected:u,someSelected:g}=s.useMemo(()=>{let m=0;for(const v of r)t.has(v)&&m++;const w=r.length>0&&m===r.length;return{allSelected:w,someSelected:!w&&m>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:n?void 0:d,allSelected:u,someSelected:g}}function na(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,w=s.useMemo(()=>{const x=t.map(o);return n?x.filter(b=>b!==mt):x},[t,o,n]),v=oa({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:w}),p=s.useCallback(x=>{const{id:b}=x,h=d?u.get(b):void 0;if(h?.isGroupRow){h.hasChildren&&g?.toggleExpansion(b);return}m?.(x),!c&&!Xe(b,u)&&v.clickRow(b)},[d,g,m,u,c,v]),f=s.useCallback((x,b)=>{Xe(x,u)||v.toggleRow(x,b)},[u,v]);return{rowSelection:v,handleRowClick:p,handleSelectionChange:f}}const Hr=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function ra(e){const{selectedRowIds:t,rowsLookup:o,rowMetaMap:n,enabled:r,onSelectionModelChange:i}=e,l=s.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=s.useRef(i);s.useLayoutEffect(()=>{c.current=i});const d=s.useRef(null);return s.useEffect(()=>{if(l===t){d.current=null;return}const u=`${Hr(t)}|${Hr(l)}`;d.current!==u&&(d.current=u,c.current(Array.from(l)))},[l,t]),l}function fn(e,t,o,n){return n?ts(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function ia(e){const{sortModel:t,onSortModelChange:o}=e,n=s.useCallback((i,l)=>{o(fn(t,i,l,!1))},[t,o]),r=s.useCallback((i,l)=>{o(fn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function la(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:o,pinnedColumns:n,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:n});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:n}});const l=s.useCallback(d=>{const u={...i.current.columnVisibilityModel,[d]:!1};i.current={...i.current,columnVisibilityModel:u},o(u)},[o]),c=s.useCallback((d,u)=>{const g=Pl(i.current.pinnedColumns,d,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function sa(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.useLayoutEffect(()=>{const n=t.current,r=()=>o.current;n.getSortModel=()=>r().sortModel,n.sortColumn=(d,u)=>{const{sortModel:g,multiSort:m,onSortModelChange:w}=r(),v=fn(g,d,u,m);o.current={...r(),sortModel:v},w(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:w}=r(),v=w?d.filter(x=>!w(x)):d;if(v.length===0)return;const p=l(),f=wo(p,v,u,g);Wr(p,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 Br="\0";function aa(e,t){const o=e.filter(n=>t[n.field]===!1).map(n=>n.field).join(Br);return s.useMemo(()=>{const n={};if(o)for(const r of o.split(Br))n[r]=!1;return nn(e,n)},[e,o])}function da({paginationModel:e,currentPage:t,enabled:o,onPaginationModelChange:n}){const r=s.useRef({paginationModel:e,onPaginationModelChange:n});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:n}});const i=e.page,l=s.useRef(null);s.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 ca(){const[e,t]=s.useState(!1),[o,n]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),l=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),c=s.useCallback(()=>{i.current>0?t(!0):n(!0)},[]),d=s.useCallback(()=>t(!1),[]),u=s.useCallback(()=>n(!1),[]);return s.useEffect(()=>{if(!o)return;function g(w){r.current&&!r.current.contains(w.target)&&n(!1)}function m(w){w.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 zr=s.createContext(null);function ua(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function fa({render:e,toolbarProps:t}){return a.jsx(a.Fragment,{children:e(t)})}function ga({component:e,toolbarProps:t}){if(ua(e))return a.jsx(fa,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return a.jsx(o,{...t})}const Vr=48;function pa({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 w=s.useMemo(()=>Ho(e,n,g,i,d,l,u,c),[e,n,g,i,d,l,u,c]),{lastLeft:v,firstRight:p}=s.useMemo(()=>Bo(e,g),[e,g]),f=c?Vr:0,x=f+(l&&u?Vr:0),b=(h,y,C)=>a.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:C}:void 0,"aria-hidden":"true"},h);return a.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&&b("__reorder_col__",!0,0),l&&b("__expand_col__",u,f),i&&b("__checkbox_col__",d,x),e.map(h=>{if(h.isSpacer){const j=typeof h.width=="number"?h.width:0;return a.jsx("div",{style:{width:j,minWidth:j,flexShrink:0},"aria-hidden":"true"},h.field)}const y=t[h.field],C=y&&Xo(h,y)?y:void 0,N=o[h.field],T=nt(h,n,120),E=qe(h.field,g),I=E?w[h.field]:void 0,F=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&h.field===v&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&h.field===p&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),G={width:T,minWidth:T,maxWidth:T,textAlign:h.align||"left"};return E==="left"&&I!==void 0&&(G.left=I),E==="right"&&I!==void 0&&(G.right=I),a.jsx("div",{className:F,role:"gridcell",style:G,children:C?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"ogx__aggregation-label",children:C}),a.jsx("span",{className:"ogx__aggregation-value",children:uo(N,C,h,o)})]}):null},h.field)})]})}function ha({noRowsLabel:e,width:t,overlay:o}){return o?a.jsx("div",{className:"ogx__empty",style:{width:t},children:o}):a.jsxs("div",{className:"ogx__empty",style:{width:t},children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),a.jsx("span",{children:e})]})}function Kr({dataSource:e,paginationMode:t,sortingMode:o,filterMode:n}){return!!e&&(t==="server"||t==="infinite"||o==="server"||n==="server")}const jr=Number.MAX_SAFE_INTEGER,ma="An unexpected error occurred while loading the data.";function Ur(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:ma}function wa({error:e,onRetry:t}){if(!e)return null;const o=Ur(e);return a.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[a.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),a.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&a.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}const Bt=({indeterminate:e=!1,label:t,className:o="",inputRef:n,...r})=>{const i=s.useRef(null),l=s.useCallback(d=>{i.current=d,typeof n=="function"?n(d):n&&(n.current=d)},[n]);s.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const c=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return a.jsxs("label",{className:c,children:[a.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),a.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&a.jsx("span",{className:"ogx-checkbox__label",children:t})]})},qr=50;function gn(e,t,o,n){const r=Math.min(o??qr,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const xa=16;function ba(e){e.preventDefault(),e.stopPropagation()}function va(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function ya(e){const{field:t,currentWidth:o,onResize:n,onAutosize:r,minWidth:i,maxWidth:l,edge:c="end"}=e,[d,u]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>()=>{g.current=null},[]);const m=s.useCallback((h,y)=>{const C=y-h.startX,N=h.startWidth+(c==="start"?-C:C);return gn(N,h.startWidth,i,l)},[c,i,l]),w=s.useCallback(h=>{if(h.button===0){h.stopPropagation(),g.current={pointerId:h.pointerId,startX:h.clientX,startWidth:o,lastUpdate:0,moved:!1},u(!0);try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}}},[o]),v=s.useCallback(h=>{const y=g.current;if(!y||h.pointerId!==y.pointerId||(h.clientX!==y.startX&&(y.moved=!0),!y.moved))return;const C=Date.now();C-y.lastUpdate>=xa&&(y.lastUpdate=C,n(t,m(y,h.clientX)))},[t,n,m]),p=s.useCallback((h,y)=>{const C=g.current;!C||h.pointerId!==C.pointerId||(g.current=null,u(!1),(C.moved||h.clientX!==C.startX)&&(va(),y&&n(t,m(C,h.clientX))))},[t,n,m]),f=s.useCallback(h=>{if(h.key==="Enter"&&r){h.preventDefault(),h.stopPropagation(),r(t);return}if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;h.preventDefault(),h.stopPropagation();const y=(h.shiftKey?50:10)*(h.key==="ArrowRight"?1:-1);n(t,gn(o+y,o,i,l))},[t,o,n,r,i,l]),x=s.useCallback(h=>{h.preventDefault(),h.stopPropagation(),r?.(t)},[t,r]),b=["ogx-column-resize-handle",c==="start"&&"ogx-column-resize-handle--start",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return a.jsx("div",{className:b,onPointerDown:w,onMouseDown:ba,onPointerMove:v,onPointerUp:h=>p(h,!0),onPointerCancel:h=>p(h,!1),onClick:h=>h.stopPropagation(),onDragStart:h=>{h.preventDefault(),h.stopPropagation()},onDoubleClick:x,onKeyDown:f,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(o),"aria-valuemin":Math.round(Math.min(i??50,o)),"aria-valuemax":l,tabIndex:-1,children:a.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Xr(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 Yr(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 pn(e,t,o){if(!e||e.length===0)return!0;const n=Yr(e),r=n.get(t),i=n.get(o);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function Ca(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 _a(){return document.documentElement.clientHeight||window.innerHeight}function bt(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:a.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function vt(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:a.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Sa(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function ka(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ea(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ma(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Na(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Pa(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),a.jsx("polyline",{points:"11 8 4 12 11 16"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Ia(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),a.jsx("polyline",{points:"13 8 20 12 13 16"}),a.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Ta(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),a.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Rr=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function La({colDef:e,sortModel:t,onSort:o,onHide:n,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:d}){const u=s.useRef(null),g=s.useCallback(G=>{G&&(d?.closest('[role="columnheader"]')??d)?.focus({preventScroll:!0}),c()},[d,c]),m=G=>{const j=Rr(u.current),S=j.indexOf(G.target);let M=-1;if(G.key==="ArrowDown")M=S+1>=j.length?0:S+1;else if(G.key==="ArrowUp")M=S<=0?j.length-1:S-1;else if(G.key==="Home")M=0;else if(G.key==="End")M=j.length-1;else if(G.key==="Tab"){G.preventDefault(),g(!0);return}else return;G.preventDefault(),j[M]?.focus()},[w,v]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!d||!u.current)return;const G=d.getBoundingClientRect(),j=u.current.getBoundingClientRect(),S=xt(),M=_a(),P=8;let _=G.left;_+j.width+P>S&&(_=S-j.width-P),_<P&&(_=P);let L=G.bottom+4;L+j.height+P>M&&(L=G.top-j.height-4),v({position:"fixed",zIndex:1300,top:L,left:_,visibility:"visible"})},[d]);const p=w.visibility==="visible";s.useLayoutEffect(()=>{p&&Rr(u.current)[0]?.focus({preventScroll:!0})},[p]),s.useEffect(()=>{function G(S){u.current&&!u.current.contains(S.target)&&d&&!d.contains(S.target)&&c()}function j(S){S.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",j),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",j),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[d,c,g]);const f=G=>{o?.(e.field,G),g(!0)},x=!!n&&e.hideable!==!1,b=!!r&&e.pinnable!==!1,h=()=>{x&&n?.(e.field),g(!0)},y=G=>{b&&r?.(e.field,G),g(!0)},C=t?.find(G=>G.field===e.field)?.sort,N=C==null,T=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,I=!T&&!E,F=e.headerName||e.field;return ot.createPortal(a.jsxs("div",{ref:u,className:"ogx-column-menu",style:w,role:"menu","aria-label":`Column options for ${F}`,onKeyDown:m,children:[o&&e.sortable!==!1&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(ka,{})}),"Sort Ascending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ea,{})}),"Sort Descending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":N,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ma,{})}),"Unsort"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),a.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":T,"aria-label":"Pin to left",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Pa,{})}),"Pin to Left"]}),a.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:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ia,{})}),"Pin to Right"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>y(null),role:"menuitemradio","aria-checked":I,"aria-label":"Unpin column",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ta,{})}),"Unpin"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${F} column`,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Na,{})}),"Hide Column"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Sa,{})}),"Manage columns"]})]}),d?.closest(".ogx-theme-provider")||document.body)}function Fa(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:a.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Oa(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:a.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Jr(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,onColumnAutosize:m,columnWidths:w={},pinnedColumns:v,hasDetailPanel:p=!1,pinCheckboxColumn:f=!0,pinExpandColumn:x=!0,rowReordering:b=!1,aggregationModel:h,draggedColumn:y,dragOverColumn:C,onDragStart:N,onDragOver:T,onDragEnd:E,onDrop:I,focusedCell:F,onHeaderClick:G,onSortAdd:j,multiSort:S=!1,onHideColumn:M,onPinColumn:P,onManageColumns:_,columnIndexMap:L}=e,A=s.useId(),[X,z]=s.useState(null),J=k=>q=>{q.stopPropagation(),z({colDef:k,anchorEl:q.currentTarget})},ee=s.useCallback(()=>{z(null)},[]),ne=k=>q=>{if(q.altKey&&(q.key==="ArrowLeft"||q.key==="ArrowRight")&&q.target===q.currentTarget){if(k.resizable===!1||!g)return;q.preventDefault(),q.stopPropagation();const ge=nt(k,w),me=(q.shiftKey?50:10)*(q.key==="ArrowRight"?1:-1);g(k.field,gn(ge+me,ge,k.minWidth,k.maxWidth));return}if(!(q.altKey&&q.key==="ArrowDown"||(q.ctrlKey||q.metaKey)&&q.key==="Enter")||k.disableColumnMenu||q.target!==q.currentTarget)return;q.preventDefault(),q.stopPropagation();const ue=q.currentTarget.querySelector(".ogx__menu-icon-btn")??q.currentTarget;z({colDef:k,anchorEl:ue})},Z=k=>F?.id===null&&F.field===k,ce=b?1:0,ae=p?ce+1:ce,oe=r?ae+1:ae,de=k=>q=>{if(k.sortable===!1)return;const re=u.find(ue=>ue.field===k.field);let te="asc";re&&(re.sort==="asc"?te="desc":te=null),(q.shiftKey||S)&&j?j(k.field,te):d&&d(k.field,te)},ie=(k,q)=>{const re=u.some(ue=>ue.field===k);j&&(q===null||re||S||!d)?j(k,q):d?.(k,q)},V=k=>{const q=u.find(te=>te.field===k);if(!q)return null;const re=u.length>1?u.indexOf(q)+1:null;return a.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${q.sort}`,"aria-hidden":"true",children:re!==null&&a.jsx("span",{className:"ogx__sort-badge",children:re})})},O=s.useMemo(()=>Ho(t,w,v,r,f,p,x,b),[t,w,v,r,f,p,x,b]),$=s.useMemo(()=>Bo(t,v),[t,v]),Y=Xr(n),U=s.useMemo(()=>Yr(n),[n]),D=s.useMemo(()=>Y===0?[]:(o??t).map(k=>({field:k.field,width:nt(k,w),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:qe(k.field,v),isSpacer:k.isSpacer})),[Y,o,t,w,v]),K=(b?48:0)+(p?48:0)+(r?48:0),B=(b||p||r)&&(!p||x)&&(!r||f),Q=(b?1:0)+(p?1:0)+(r?1:0);return a.jsxs("div",{className:"ogx__header-wrap",children:[Y>0&&Array.from({length:Y},(k,q)=>{const re=Ca(D,U,q);return a.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":q+1,children:[K>0&&a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${B?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:K,minWidth:K,flexShrink:0,position:B?"sticky":void 0,left:B?0:void 0},"aria-hidden":"true"}),re.map((te,ue)=>{const ge=te.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${te.pinned}`:"",me={width:te.width,minWidth:te.width,flexShrink:0,flexGrow:te.flexGrow};return te.pinned==="left"?(me.position="sticky",me.left=O[te.fields[0]]):te.pinned==="right"&&(me.position="sticky",me.right=O[te.fields[te.fields.length-1]],re[ue-1]?.pinned!=="right"&&(me.marginLeft="auto")),te.isGroup?a.jsx("div",{role:"columnheader","aria-colspan":te.fields.length,"aria-colindex":Q+te.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${ge}${te.headerClassName?` ${te.headerClassName}`:""}`,style:me,title:te.label,children:a.jsx("span",{className:"ogx-col-group-cell__label",children:te.label})},te.key):a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${ge}`,style:me,"aria-hidden":"true"},te.key)})]},`ogx-grp-${q}`)}),a.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":Y+1,children:[b&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${Z("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":ce,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),p&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${x?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${Z("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":ae,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:x?"sticky":void 0,left:x?b?48:0:void 0}}),r&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${Z("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":oe,"data-field":"__checkbox_col__",style:{position:f?"sticky":void 0,left:f?(b?48:0)+(p&&x?48:0):void 0},children:c&&a.jsx(Bt,{id:A,name:A,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,q)=>{if(k.isSpacer)return a.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const re=k.sortable!==!1,te=u.findIndex(_e=>_e.field===k.field),ue=te!==-1,ge=ue?u[te].sort:null,me=L?.get(k.field)??q,Se=re?te===0?ge==="asc"?"ascending":"descending":"none":void 0,fe=ue&&u.length>1?`Sorted ${ge==="asc"?"ascending":"descending"}, sort priority ${te+1} of ${u.length}`:void 0,xe=k.resizable!==!1,be=qe(k.field,v),ve=be!==null,se=y===k.field,ye=C===k.field,Te=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,re&&"ogx__header-cell--sortable",ue&&"ogx__header-cell--sorted",ve&&"ogx__header-cell--pinned",ve&&`ogx__header-cell--pinned-${be}`,be==="left"&&k.field===$.lastLeft&&"ogx__header-cell--pinned-left-last",be==="right"&&k.field===$.firstRight&&"ogx__header-cell--pinned-right-first",se&&"ogx__header-cell--dragging",ye&&"ogx__header-cell--drag-over",Z(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),ke={width:w[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&&be){const _e=O[k.field];be==="left"?ke.left=_e:ke.right=_e}const le=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:me}):k.headerName||k.field,pe=_e=>{if(_e.target.closest(".ogx-column-resize-handle")){_e.stopPropagation();return}G?.(k.field),re&&de(k)(_e)},we=N&&!ve?N(k.field):void 0,Ne=T&&!ve?T(k.field):void 0,Qe=I&&!ve?I(k.field):void 0;return a.jsxs("div",{className:Te,style:ke,title:k.description,onClick:pe,role:"columnheader",draggable:!!we,onDragStart:we,onDragOver:Ne,onDragEnd:E,onDrop:Qe,onKeyDown:ne(k),"aria-sort":Se,"aria-description":fe,"aria-colindex":Q+me+1,"data-field":k.field,tabIndex:-1,children:[a.jsxs("div",{className:"ogx__header-cell-content",children:[se&&a.jsx("div",{className:"ogx__header-drag-icon",children:a.jsx(Oa,{})}),a.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[a.jsx("span",{className:"ogx__header-cell-title",children:le}),h&&h[k.field]&&a.jsx("span",{className:"ogx__header-cell-aggregation",children:h[k.field]})]}),re&&V(k.field),!k.disableColumnMenu&&a.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:J(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:a.jsx(Fa,{})})]}),xe&&g&&a.jsx(ya,{field:k.field,currentWidth:nt(k,w),onResize:g,onAutosize:m,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:be==="right"?"start":"end"})]},k.field)}),X&&a.jsx(La,{colDef:X.colDef,sortModel:u,onSort:d||j?ie:void 0,onHide:M,onPin:P,pinnedColumns:v,onManageColumns:_,onClose:ee,anchorEl:X.anchorEl})]})]})}const je=()=>{};function Qr(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:je,selectRows:je,getSelectedRows:()=>[],sortColumn:je,getSortModel:()=>[],setFilterModel:je,getFilterModel:()=>({items:[]}),setPage:je,setPageSize:je,scrollToIndexes:je,autosizeColumn:je,autosizeColumns:je,copySelectedRows:()=>Promise.resolve()}}const Aa=e=>e.id;let Zr=!1;function ei(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&&!Zr&&process.env.NODE_ENV!=="production"&&(Zr=!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 Da(e,t,o,n={}){const r=new Map,i=[];return o.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:ei(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 $a(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:ei(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 Ga(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,d=e.getRowId??Aa,u=s.useRef(d);s.useLayoutEffect(()=>{u.current=d});const[g]=s.useState(()=>Da(t,d,o,i)),[m,w]=s.useReducer($a,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:n,headerHeight:r}}),[v,p]=s.useState({rows:t,syncRows:c});(v.rows!==t||v.syncRows!==c)&&(p({rows:t,syncRows:c}),c&&w({type:"SET_ROWS",payload:t,getRowId:d}));const f=s.useRef(m);s.useLayoutEffect(()=>{f.current=m});const x=s.useCallback((F,G)=>{w({type:"SET_ROWS",payload:F,getRowId:u.current})},[]),b=s.useCallback((F,G)=>{w({type:"REPLACE_ROW",id:F,row:G})},[]),h=s.useCallback(F=>{w({type:"SET_COLUMNS",payload:F})},[]),y=s.useCallback((F,G)=>{w({type:"SET_DIMENSIONS",payload:{viewportWidth:F,viewportHeight:G}})},[]),C=s.useCallback(F=>{w({type:"SET_DATASOURCE_LOADING",payload:F})},[]),N=s.useCallback(F=>{w({type:"SET_DATASOURCE_ERROR",payload:F})},[]),T=s.useCallback(F=>{w({type:"SET_ROW_COUNT",payload:F})},[]),[E]=s.useState(()=>({...Qr(),getRow:F=>f.current.rows.idRowsLookup.get(F)||null,getAllRows:()=>f.current.rows.allRows.map(F=>f.current.rows.idRowsLookup.get(F)),getColumn:F=>f.current.columns.lookup.get(F)||null,getAllColumns:()=>f.current.columns.all})),I=s.useRef(E);return{state:m,dispatch:w,apiRef:I,setRows:x,replaceRow:b,setColumns:h,setDimensions:y,setDataSourceLoading:C,setDataSourceError:N,setRowCount:T}}function Wa(e){const{onRowOrderChange:t,rows:o,getRowId:n,rowReordering:r=!1}=e,[i,l]=s.useState(null),[c,d]=s.useState(null),u=s.useRef(()=>{}),g=s.useMemo(()=>{const x=new Map;return o.forEach((b,h)=>x.set(n?n(b):b.id,h)),x},[o,n]),m=s.useCallback(x=>g.has(x),[g]),w=s.useCallback(()=>{u.current(),u.current=()=>{},l(null),d(null)},[]);s.useEffect(()=>()=>u.current(),[]);const v=s.useCallback(x=>b=>{if(r){if(!g.has(x)){b.preventDefault();return}u.current(),u.current=Fr(b.currentTarget,w),l(x),b.dataTransfer&&(b.dataTransfer.effectAllowed="move",Lr(b,dn,String(x)))}},[r,g,w]),p=s.useCallback(x=>b=>{if(!(!r||i===null)){if(!ho(b,dn)){w();return}g.has(x)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),c!==x&&d(x))}},[r,i,c,g,w]),f=s.useCallback(x=>b=>{if(b.preventDefault(),i===null||!ho(b,dn)){w();return}const h=g.get(i),y=g.get(x);w(),t&&h!==void 0&&y!==void 0&&h!==y&&t({row:o[h],oldIndex:h,targetIndex:y})},[i,t,o,g,w]);return{draggedRowId:i,dragOverRowId:c,canReorderRow:m,onDragStart:r?v:void 0,onDragOver:r?p:void 0,onDragEnd:r?w:void 0,onDrop:r?f:void 0}}const ti=new Map,oi=e=>JSON.stringify(e),Ha=e=>`auto-group-${e}`,ni=5,ri=e=>e.slice(0,ni).map(t=>JSON.stringify(t)).join(", ")+(e.length>ni?", …":""),Ba={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function za(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),w=[],v=new Map;e.forEach((f,x)=>{const b=t(f),h=o(f),y=Array.isArray(h)?h.map(C=>String(C)):[];if(g[x]=b,m[x]=y,c.set(b,f),y.length===0)w.push(b);else{const C=oi(y),N=d.get(C);if(N===void 0)d.set(C,b);else{const T=v.get(C)??[N];T.push(b),v.set(C,T)}}n.set(b,{id:b,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const p=f=>{const x=oi(f),b=d.get(x);if(b!==void 0)return b;const h=Ha(x),y=f[f.length-1],C={id:h,parentId:null,depth:f.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};n.set(h,C),d.set(x,h),l.add(h);const N={id:h};if(i.push(N),c.set(h,N),f.length===1)r.push(h);else{const T=p(f.slice(0,-1));C.parentId=T,n.get(T)?.children?.push(h)}return h};return e.forEach((f,x)=>{const b=g[x],h=m[x];if(h.length<=1){r.push(b);return}const y=p(h.slice(0,-1)),C=n.get(b);C&&(C.parentId=y),n.get(y)?.children?.push(b)}),w.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${ri(w)}. They are shown as top-level rows.`),v.forEach((f,x)=>{u.push(`[OpenGridX] treeData: rows ${ri(f)} have the same path ${x}. 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 Va(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 w=[];let v=0;for(const b of m.children??[])u(b)&&(w.push(b),v+=(r.has(b)?0:1)+(d.get(b)??0));c.set(g,w),d.set(g,v);const p=i.get(g),x=!r.has(g)&&p!==void 0&&(t?t(p):!0)||w.length>0;return x&&l.add(g),x};return n.forEach(u),{visible:l,visibleChildren:c,descendantCounts:d}}function Ka(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,w=r&&!!n,v=s.useMemo(()=>!r||!n?Ba:za(t,o,n),[t,n,r,o]),{treeNodes:p,rootIds:f,groupingRows:x,syntheticIds:b,rowLookup:h}=v,y=v.issues.join(`
1
+ (function(me,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],a):(me=typeof globalThis<"u"?globalThis:me||self,a(me.OpenGridX={},me.ReactJSXRuntime,me.React,me.ReactDOM))})(this,(function(me,a,s,ot){"use strict";function Ho(e,t,o){return Math.max(t??0,Math.min(o??1/0,e))}function nt(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 Ho(r,e.minWidth,e.maxWidth)}const Ke=48;function qe(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function Il(e,t){const o=[],n=[],r=[];return t?(e.forEach(i=>{const l=qe(i.field,t);l==="left"?o.push(i):l==="right"?r.push(i):n.push(i)}),t.left&&o.sort((i,l)=>{const d=t.left.indexOf(i.field),c=t.left.indexOf(l.field);return d-c}),t.right&&r.sort((i,l)=>{const d=t.right.indexOf(i.field),c=t.right.indexOf(l.field);return d-c}),{left:o,center:n,right:r}):{left:o,center:e,right:r}}function Bo(e,t,o,n,r,i,l,d){const c={};if(!o)return c;let u=(d?Ke:0)+(i&&l?Ke:0)+(n&&r?Ke:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const v=qe(x.field,o);v==="left"?(c[x.field]=u,u+=nt(x,t)):v==="right"&&g.push(x)});let w=0;for(let x=g.length-1;x>=0;x--)c[g[x].field]=w,w+=nt(g[x],t);return c}function zo(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=qe(r.field,t);i==="left"?o=r.field:i==="right"&&n===null&&(n=r.field)}return{lastLeft:o,firstRight:n}}function qn(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Tl(e,t,o=n=>n.id){const n=[],r=[],i=[];return t?(e.forEach(l=>{const d=qn(o(l),t);d==="top"?n.push(l):d==="bottom"?i.push(l):r.push(l)}),t.top&&n.sort((l,d)=>{const c=t.top.indexOf(o(l)),u=t.top.indexOf(o(d));return c-u}),t.bottom&&i.sort((l,d)=>{const c=t.bottom.indexOf(o(l)),u=t.bottom.indexOf(o(d));return c-u}),{top:n,center:r,bottom:i}):{top:n,center:e,bottom:i}}function Ll(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 Xn=new Set;function io(e,t,o){process.env.NODE_ENV==="production"||Xn.has(e)||(Xn.add(e),console.warn(`[OpenGridX] ${t}.`,o))}function lo(e,t,o,n){try{return e()}catch(r){return io(o,n,r),t}}function Rn(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}=Rn(e,t,o);return r!==void 0&&io(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),n}function Vo(e,t,o,n){const r=n?.valueFormatter;if(r)return lo(()=>r({value:o,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function rt(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 Fl=/^(\d{4})-(\d{2})-(\d{2})$/;function so(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=Fl.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 ao(e){const t=so(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Yn(e){const t=so(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 Jn=null;function Qn(e){return Jn??=new Intl.DateTimeFormat,Jn.format(e)}function Ol(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 Ko(e,t){if(e==null)return"";switch(t?.type){case"date":{const o=so(e);return o?Qn(o):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ol(t.valueOptions,e)??String(e);default:return String(e)}}const Uo=200;function jo(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:Uo}function qo(e,t){if(e)return lo(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Al(e,t){const o=jo(e);return o==="auto"?t??Uo:o}function Dl(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 $l=e=>e.id;function Gl(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 Wl(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 b=Gl(t[f.field]??f.width);b.type==="fixed"?n.set(f.field,{kind:"fixed",width:Ho(b.value,f.minWidth,f.maxWidth)}):b.type==="percentage"?n.set(f.field,{kind:"percentage",percentage:b.value}):n.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,m)=>{const b=n.get(m.field);if(b.kind==="fixed")return f+b.width;if(b.kind==="percentage")return f+100;if(m.flex&&m.flex>0){const h=m.minWidth??150;return f+(h||(typeof m.width=="number"?m.width:150))}return f+(m.minWidth??150)},0),i=Math.max(o,r),l=e.reduce((f,m)=>{const b=n.get(m.field);return b.kind==="fixed"?f+b.width:f},0),d=new Map,c=Math.max(0,i-l);let u=0;e.forEach(f=>{const m=n.get(f.field);if(m.kind==="fixed")d.set(f.field,m.width);else if(m.kind==="percentage"){const b=m.percentage/100*c,h=Ho(b>0?b:100,f.minWidth??50,f.maxWidth);d.set(f.field,h),u+=h}});const g=Math.max(0,c-u),w=new Map,x=e.flatMap(f=>{const m=n.get(f.field);return m.kind!=="flex"?[]:(w.set(f.field,m.flex),[{field:f.field,flex:m.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let v=0;const p=x.length*2;for(;v<p;){v++;const f=x.filter(E=>!E.frozen);if(f.length===0)break;const m=f.reduce((E,I)=>E+I.flex,0),b=x.reduce((E,I)=>I.frozen?E+I.computedWidth:E,0),h=Math.max(0,g-b);if(m<=0){f.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0});break}const y=h/m;let S=0;const N=[],T=[];if(f.forEach(E=>{const I=y*E.flex;I<E.minWidth?(S+=E.minWidth-I,N.push(E)):I>E.maxWidth?(S+=E.maxWidth-I,T.push(E)):E.computedWidth=I}),N.length===0&&T.length===0){f.forEach(E=>{E.frozen=!0});break}S>0?N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}):S<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=>d.set(f.field,f.computedWidth)),{widths:d,flexByField:w}}function Hl(e){const{rowHeight:t,pagination:o,paginatedUnpinnedRows:n,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:d,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:w,visibleOrderedColumns:x,pinnedColumns:v,columnWidths:p,viewportWidth:f,checkboxSelection:m,hasDetailPanel:b,rowReordering:h,pinCheckboxColumn:y,pinExpandColumn:S,paginationMode:N,isLoading:T,pageSize:E,getRowId:I=$l}=e;return s.useMemo(()=>{const F=o?n:r,G=(B,A)=>{const R=I(B);if(!i.has(R))return t;const k=qo(l,{row:B,id:R,rowIndex:A});return t+Al(k,d?.get(R))},H=F.map((B,A)=>G(B,c+A)),_=H.reduce((B,A,R)=>(B.push((B[R-1]||0)+A),B),[]),M=N==="infinite"&&T&&F.length>0?Math.min(E,20):0,P=(_[_.length-1]||0)+M*t,C=(B,A)=>B?B.reduce((R,k,K)=>R+G(k,K),0):A*t,L=C(g,c),O=C(w,u),{left:j,center:W,right:Z}=Il(x,v),oe=(m?Ke:0)+(b?Ke:0)+(h?Ke:0),ie=(h?Ke:0)+(b&&S?Ke:0)+(m&&y?Ke:0),{widths:te,flexByField:ue}=Wl([...j,...W,...Z],p,f-oe),de=B=>te.get(B.field)??100,re=B=>({...B,width:de(B),flex:ue.get(B.field)??B.flex}),ce=11,le=j.map((B,A)=>({...re(B),zIndex:ce+A})),D=11,ee=Z.map((B,A)=>({...re(B),zIndex:D+(Z.length-1-A)})),J=W.map(re),Y=J.map(B=>B.width),Q=le.reduce((B,A)=>B+A.width,0),z=ee.reduce((B,A)=>B+A.width,0),q=Y.reduce((B,A)=>B+A,0),X=Q+q+z+oe,$=Y.reduce((B,A,R)=>(B.push((B[R-1]||0)+A),B),[]);return{rowHeights:H,cumulativeHeights:_,unpinnedRowsHeight:P,pinnedTopHeight:L,pinnedBottomHeight:O,leftPinnedCols:le,rightPinnedCols:ee,unpinnedColsWithWidth:J,unpinnedColWidths:Y,unpinnedAccWidths:$,totalWidth:X,leftWidth:Q,rightWidth:z,unpinnedTotalWidth:q,systemColumnsWidth:oe,pinnedSystemColumnsWidth:ie,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,unpinnedRowsLength:F.length}},[t,o,n,r,i,l,d,c,u,g,w,x,v,p,f,m,b,h,y,S,N,T,E,I])}function Bl(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Zn(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:d}=e,c=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(n,Bl(e)),g=c+(t===0?0:o[t-1]),w=r!==void 0?Math.min(g+r,c+o[t]):c+o[t];g<l+c?e.scrollTop=Math.max(0,g-c):w>l+d-u&&(e.scrollTop=w-d+u)}function zl(e,t,o){const{unpinnedAccWidths:n,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:d}=o;if(t<0||t>=n.length)return;const c=l+r,u=c+(t>0?n[t-1]:0),g=c+n[t],w=d+r,{scrollLeft:x,clientWidth:v}=e;u<x+w?e.scrollLeft=Math.max(0,u-w):g>x+v-i&&(e.scrollLeft=g-v+i)}function er(e,t){const{row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:d,rowMeta:c}=e;if(!i.editable||c?.isGroupRow||o._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:d})}catch{return!1}}const Vl={},Xo=e=>e==null||typeof e=="string"&&e.trim()==="",tr=e=>{const t=[];for(const o of e){const n=rt(o);n!==null&&t.push(n)}return t},or=(e,t)=>{let o=null,n=null;for(const r of e){const i=rt(r);i!==null&&(o===null||t(i,o))&&(o=i,n=r)}return o===null?null:n instanceof Date?n:o},co={sum:e=>tr(e).reduce((t,o)=>t+o,0),avg:e=>{const t=tr(e);return t.length?t.reduce((o,n)=>o+n,0)/t.length:null},count:e=>e.filter(t=>!Xo(t)).length,min:e=>or(e,(t,o)=>t<o),max:e=>or(e,(t,o)=>t>o),unique:e=>new Set(e.filter(t=>!Xo(t))).size};function Ro(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function uo(e,t,o,n){const r={};for(const[i,l]of Object.entries(t)){const d=o.get(i);if(!Ro(d,l))continue;const c=co[l];if(!c){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=c(e.map(u=>Fe(u,i,d)))}return r}function Yo(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const Kl=new Set(["count","unique"]);function nr(e){return e!==void 0&&Kl.has(e)}function rr(e,t,o){return e?.type==="date"&&(t==="min"||t==="max")&&typeof o=="number"&&Number.isFinite(o)?new Date(o):o}function fo(e,t,o,n){if(e==null)return"—";if(nr(t))return Yo(e,t);const r=rr(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())?"":Qn(r):Yo(r,t)}const Jo=new Set(["isEmpty","isNotEmpty"]);function ir(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Ul(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const $t=e=>(t,o)=>{const n=rt(t),r=rt(o);return n===null||r===null?!1:e(n,r)},Gt=e=>(t,o)=>{const n=ao(t),r=ao(o);return n===null||r===null?!1:e(n,r)},lr=Gt((e,t)=>e===t),sr=(e,t)=>{const o=ao(e),n=ao(t);return o===null||n===null?!0:o!==n},ar={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()!=="","=":$t((e,t)=>e===t),">":$t((e,t)=>e>t),">=":$t((e,t)=>e>=t),"<":$t((e,t)=>e<t),"<=":$t((e,t)=>e<=t),"!=":(e,t)=>{if(ir(t))return!0;const o=rt(e),n=rt(t);return o!==null&&n!==null?o!==n:Ul(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?sr(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?lr(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:Gt((e,t)=>e>t),onOrAfter:Gt((e,t)=>e>=t),before:Gt((e,t)=>e<t),onOrBefore:Gt((e,t)=>e<=t)},jl={is:lr,not:sr};function ql(e,t){if(!Object.prototype.hasOwnProperty.call(ar,e))return;const o=e;if(t?.type==="date"){const n=jl[o];if(n)return n}return ar[o]}function Xl(e){return"items"in e&&Array.isArray(e.items)}function Rl(e,t){const{field:o,operator:n,value:r}=e;if(!Jo.has(n)&&ir(r))return null;const i=t.columns?.byField.get(o),l=ql(n,i);return l?d=>l(Fe(d,o,i),r):(t.warned.has(n)||(t.warned.add(n),console.warn(`Unknown filter operator: ${n}`)),null)}function cr(e,t,o){const n=[];for(const r of e){const i=Xl(r)?cr(r.items,r.logicOperator,o):Rl(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 Qo(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=Yn(t);o&&e.push(o);return}if(Array.isArray(t))for(const o of t)(o==null||typeof o!="object")&&Qo(e,o)}}function dr(e,t){const o=[];if(!t){for(const n of Object.values(e))Qo(o,n);return o}for(const n of t.quickFilterColumns){const r=Fe(e,n.field,n),i=Vo(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Qo(o,r)}return o}const ur=new WeakMap;function Yl(e,t){if(!t)return dr(e,t);let o=ur.get(t);o||(o=new WeakMap,ur.set(t,o));let n=o.get(e);return n||(n=dr(e,t),o.set(e,n)),n}function Jl(e,t){const o=(e??[]).map(n=>String(n??"").trim().toLowerCase()).filter(n=>n!=="");return o.length===0?null:n=>{const r=Yl(n,t);return o.every(i=>r.some(l=>l.includes(i)))}}function go(e,t){if(!e)return null;const o={columns:t,warned:new Set},n="quickFilterValues"in e?e.quickFilterValues:void 0,r=Jl(n,t),i=cr(e.items??[],e.logicOperator??"and",o);return r&&i?l=>r(l)&&i(l):r??i}function Zo(e,t,o){const n=go(t,o);return n?e.filter(r=>n(r)):e}function Ql(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 Zl=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),en=0,fr=1,es=2,gr=3,pr=4;function ht(e,t){return{rank:e,num:t,str:""}}function tn(e,t){if(e==null)return null;if(t==="number"){const o=rt(e);return o===null?null:ht(en,o)}if(t==="date"){const o=so(e);return o?ht(fr,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(en,e);case"bigint":return ht(en,Number(e));case"boolean":return ht(es,e?1:0);case"string":return{rank:gr,num:0,str:e}}if(e instanceof Date){const o=e.getTime();return Number.isNaN(o)?null:ht(fr,o)}return{rank:pr,num:0,str:String(e)}}function hr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===gr||e.rank===pr?Zl.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function on(e,t){return e===0?0:t==="asc"?e:-e}function ts(e,t,o,n){return on(hr(tn(e,n),tn(t,n)),o)}function wr(e,t,o){let n;try{n=e(t.value,o.value,t,o)}catch(r){return io(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof n!="number"||Number.isNaN(n)?(io(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(n)}; the values are treated as equal`,void 0),0):n}const os=e=>e.id;function ns(e,t,o,n=os){return t.length===0?e:nn(e,t,(r,i)=>{const l=o?.byField.get(i.field),d=Fe(r,i.field,l);return{value:d,type:l?.type,comparator:l?.sortComparator,params:l?.sortComparator?{id:n(r),field:i.field,row:r,value:d}:void 0}})}function nn(e,t,o){if(t.length===0||e.length<2)return[...e];const n=t.map(l=>e.map(d=>o(d,l))),r=n.map(l=>l.map(({value:d,type:c})=>tn(d,c))),i=e.map((l,d)=>d);return i.sort((l,d)=>{for(let c=0;c<t.length;c++){const u=n[c][l],g=n[c][d],w=u.comparator&&u.comparator===g.comparator&&u.params&&g.params?wr(u.comparator,u.params,g.params):hr(r[c][l],r[c][d]),x=on(w,t[c].sort);if(x!==0)return x}return l-d}),i.map(l=>e[l])}function rs(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 rn(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__",is="__pivot_row__:",mr=e=>`${is}${JSON.stringify(e.split(xr))}`,ls="Grand Total",xr="\0",mt="",ln=`${mt}id`,br=e=>e==="id"?ln:e,sn={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},vr=e=>e.map(t=>String(t??"")).join(xr),yr=e=>e===void 0||e===""?null:e;function ss(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 as(e,t){for(let o=0;o<e.length;o++){const n=ss(e[o],t[o]);if(n!==0)return n}return 0}function Cr(e,t){if(!e||e.length===0)return null;const o=co[t](e);return typeof o=="number"||o instanceof Date?o:null}const cs=e=>"logicOperator"in e&&"items"in e,ds=e=>!!(e&&e.items&&e.items.length>0);function us(e,t){const o=l=>!t.has(l)&&l.includes(mt),n=l=>cs(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 _r(e,t,o,n={}){const r=new Map(t.map(_=>[_.field,_])),i=_=>r.get(_)?.groupable!==!1,l=o.rowFields.filter(i),d=o.columnFields.filter(i),c=new Set,u=o.valueFields.filter(_=>{if(!Ro(r.get(_.field),_.aggFn))return!1;const M=`${_.field}${mt}${_.aggFn}`;return c.has(M)?!1:(c.add(M),!0)});if(l.length===0||u.length===0)return sn;const g=d.length>0,w=Array.from(new Set(u.map(_=>_.field))),x=(_,M)=>Fe(_,M,r.get(M)),v=new Map,p=new Map(g?[]:[["",{values:[]}]]);for(const _ of e){const M=l.map(Z=>x(_,Z)),P=vr(M);let C=v.get(P);C||(C={labels:M.map(yr),sample:_,cells:new Map},v.set(P,C));const L=d.map(Z=>x(_,Z)),O=g?vr(L):"",j=p.get(O);j?j.sample||(j.sample=_):p.set(O,{values:L.map(yr),sample:_});let W=C.cells.get(O);W||(W=new Map,C.cells.set(O,W));for(const Z of w){const oe=x(_,Z);if(Xo(oe))continue;let ie=W.get(Z);ie||(ie=[],W.set(Z,ie)),ie.push(oe)}}const f=Array.from(p.keys()).sort((_,M)=>as(p.get(_).values,p.get(M).values)),m=(_,M)=>g?`${_}${mt}${M.field}${mt}${M.aggFn}`:`${M.field}${mt}${M.aggFn}`,b=new Map;let h=[];for(const[_,M]of v){const P={id:mr(_)};l.forEach((C,L)=>{P[br(C)]=M.labels[L]}),P.id=mr(_);for(const C of f){const L=M.cells.get(C);for(const O of u)P[m(C,O)]=Cr(L?.get(O.field),O.aggFn)}b.set(P.id,M),h.push({row:P,entry:M})}const y=_=>l.includes(_),S=_=>y(_)?r.get(_)?.type:"number",{outputFilterModel:N,sortModel:T}=n;if(ds(N)){const _=[];for(const P of f)for(const C of u)_.push({field:m(P,C),type:"number"});const M=go(N,rn(_));M&&(h=h.filter(({row:P})=>M(P)))}const E=(_,M)=>M==="id"&&y("id")?_[ln]:_[M];T&&T.length>0&&(h=[...h].sort((_,M)=>{for(const P of T){const C=E(_.row,P.field),L=E(M.row,P.field),O=y(P.field)?r.get(P.field)?.sortComparator:void 0,j=O?on(wr(O,{id:_.row.id,field:P.field,row:_.row,value:C},{id:M.row.id,field:P.field,row:M.row,value:L}),P.sort):ts(C,L,P.sort,S(P.field));if(j!==0)return j}return 0}));const I=h.map(_=>_.row);if(h.length>0){const _={id:wt};l.forEach((M,P)=>{_[br(M)]=P===0?ls:""}),_.id=wt;for(const M of f)for(const P of w){const C=[];for(const{entry:L}of h){const O=L.cells.get(M)?.get(P);if(O)for(const j of O)C.push(j)}for(const L of u)L.field===P&&(_[m(M,L)]=Cr(C,L.aggFn))}I.push(_)}const F=h[0]?.entry.sample,G=_=>_===wt?F:_===void 0?void 0:b.get(_)?.sample,H=l.map(_=>gs(_,r.get(_),G));for(const _ of f){const M=p.get(_),P=g?d.map((C,L)=>{const O=r.get(C),j=fs(O,C,M.values[L],M.sample);return O?.headerName?`${O.headerName}: ${j}`:j}).join(" / "):"";for(const C of u){const L=r.get(C.field),O=C.headerName??L?.headerName??C.field;H.push({field:m(_,C),headerName:P?`${P} — ${O} (${C.aggFn})`:`${O} (${C.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:j,row:W})=>fo(j,C.aggFn,L,W)})}}return{pivotRows:I,pivotColumns:H,colKeys:f,isValid:!0}}function fs(e,t,o,n){const r=n?Vo(n,t,o,e):void 0;return r!==void 0?r:o==null?"":String(o)}function gs(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:d})=>d[ln]);const r=d=>d?.id===wt,i=t?.valueFormatter;i&&(n.valueFormatter=({value:d,row:c})=>r(c)?String(d??""):i({value:d,row:o(c?.id)??c,field:e}));const l=t?.renderCell;return l&&(n.renderCell=d=>r(d.row)?d.formattedValue??String(d.value??""):l({...d,row:o(d.row.id)??d.row})),n}function Xe(e,t){return e===wt||t?.get(e)?.isGroupRow===!0}const Wt="__reorder_col__",Ht="__expand_col__",Re="__checkbox_col__",it=e=>e===Wt||e===Ht||e===Re,Sr=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,ps=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),hs=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function ws(e){const t=e.tagName;if(t==="INPUT")return!ps.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&&hs.has(o)}const kr=e=>e!==null&&e.nodeType===1;function Er(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 ms(e,t){if(e===t)return"grid";if(!kr(e)||!t.contains(e))return"foreign";const o=Er(e,t);return o?o.classList.contains("ogx__cell--editing")?"editor":o===e?"grid":ws(e)?"foreign":o.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function xs(e,t,o,n){if(!kr(e))return null;const r=Er(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader")return r.parentElement?.classList.contains("ogx__header")?{id:null,field:i}:null;const l=Number(r.parentElement?.getAttribute("data-rowindex")),d=Number.isInteger(l)?o[l]:void 0;return d?{id:n(d),field:i,rowIndex:l}:null}function Mr(e,t){if(!e)return null;for(const o of Array.from(e.children))if(o.dataset.field===t)return o;return null}function an(e,t,o){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Mr(r,t.field);return i&&t.field===Re?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 Mr(n,t.field)}const bs=e=>e.id,Nr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function vs(e,t,o,n){if(!e||o.length===0)return{cell:null,rowIndex:-1};const r=(o.find(c=>!it(c.field))??o[0]).field,i=o.some(c=>c.field===e.field)?e.field:r;if(e.id===null)return{cell:i===e.field?e:{id:null,field:i},rowIndex:-1};const l=e.rowIndex;let d=l!==void 0&&t[l]&&n(t[l])===e.id?l:t.findIndex(c=>n(c)===e.id);return d===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(d=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:n(t[d]),field:i,rowIndex:d},rowIndex:d}):{cell:i===e.field?e:{...e,field:i},rowIndex:d}}function ys(e){const{allRenderableRows:t,navigationColumns:o,checkboxSelection:n,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:d,setKeyboardMode:c,sortModel:u,handleSort:g,handleSortAdd:w,multiSort:x=!1,isCellEditable:v,pagination:p,pageSize:f,virtualization:m,viewportRef:b,pinnedTopRowCount:h=0,getRowId:y=bs,rowMetaMap:S,onRowActivate:N,toggleRowExpansion:T,handleSelectAll:E,rowSelectionEnabled:I=!0,multipleRowSelectionEnabled:F=!0,pinCheckboxColumn:G=!0,pinExpandColumn:H=!0,rowHeight:_,getSpanOrigin:M}=e,[P,C]=s.useState(null),[L,O]=s.useState(!1),j=s.useMemo(()=>vs(P,t,o,y),[P,t,o,y]),W=j.cell,Z=j.rowIndex,oe=s.useRef(!1),ie=s.useRef(!1),te=s.useRef(!1),ue=s.useRef(null),de=s.useCallback(z=>{ie.current=!0,z.focus({preventScroll:!0}),ie.current=!1},[]),re=s.useCallback(()=>{const z=b.current;z&&!z.contains(z.ownerDocument.activeElement)&&de(z)},[b,de]),ce=s.useMemo(()=>o.find(z=>!it(z.field))??o[0],[o]),le=s.useCallback(()=>{if(n)return{id:null,field:Re};if(!ce)return null;const z=t[0];return z?{id:y(z),field:ce.field,rowIndex:0}:{id:null,field:ce.field}},[n,ce,t,y]),D=s.useCallback((z,q)=>{const X=b.current;if(!X)return;const{cumulativeHeights:$,pinnedBottomHeight:B,columnMetrics:A}=m;if(z>=0&&Zn(X,z-h,$,B,_),it(q)){!(q===Wt||q===Ht&&H||q===Re&&G)&&X.scrollLeft>0&&(X.scrollLeft=0);return}if(!A)return;const{clientWidth:R,scrollLeft:k}=X,{leftPinnedWidth:K,rightPinnedWidth:U,unpinnedAccWidths:V,unpinnedCols:ne,totalSpecialsWidth:fe,pinnedSpecialsWidth:pe}=A,he=ne.findIndex(Ce=>Ce.field===q);if(he===-1)return;const ge=fe+K+(he>0?V[he-1]:0),be=fe+K+V[he],ve=k+pe+K,ye=k+R-U;let ae=k;ge<ve?ae=Math.max(0,ge-pe-K):be>ye&&(ae=be-R+U),ae!==k&&(X.scrollLeft=ae)},[b,m,h,_,G,H]);s.useLayoutEffect(()=>{const z=b.current,q=!Sr(ue.current,W);if(ue.current=W,!z||!W)return;const X=z.ownerDocument,$=X.activeElement;let B;if($===z?B=!0:!$||$===X.body?B=oe.current:z.contains($)?B=q:B=!1,!B)return;const A=an(z,W,Z);A?A.contains($)||A.focus({preventScroll:!0}):$!==z&&de(z)});const ee=s.useCallback(()=>{te.current=!0,c(!1)},[c]),J=s.useCallback(z=>{const q=z.currentTarget,X=z.relatedTarget,$=!(X instanceof Node&&q.contains(X)),B=te.current;if(te.current=!1,oe.current=!0,O(!0),ie.current)return;if(z.target===q){if(!$)return;if(B||c(!0),W){const k=an(q,W,Z);k?k.focus({preventScroll:!0}):D(Z,W.field);return}const R=le();R&&(C(k=>k??R),D(R.rowIndex??-1,R.field));return}const A=xs(z.target,q,t,y);A&&!Sr(A,W)&&C(A)},[W,Z,le,D,c,t,y]),Y=s.useCallback(z=>{const q=z.relatedTarget;q instanceof Node&&z.currentTarget.contains(q)||(oe.current=!1,te.current=!1,O(!1),c(!1))},[c]),Q=s.useCallback(z=>{const q=z.currentTarget,X=ms(z.target,q);if(X==="foreign"||(c(!0),z.nativeEvent?.isComposing||z.keyCode===229))return;const{key:$}=z,B=$===" "||$==="Spacebar",A=!!d.editingCell,R=(se,we)=>{const xe=o[we];!xe||se<-1||se>=t.length||(C(se===-1?{id:null,field:xe.field}:{id:y(t[se]),field:xe.field,rowIndex:se}),D(se,xe.field))};if(!W){if(!Nr.has($))return;const se=le();if(!se)return;z.preventDefault(),C(se),D(se.rowIndex??-1,se.field);return}const{id:k,field:K}=W,U=Z,V=o.findIndex(se=>se.field===K),ne=o.filter(se=>it(se.field)).length,fe=se=>Xe(se,S),pe=(se,we,xe)=>{const Ne=o[xe];return it(Ne.field)?!1:er({row:se,field:Ne.field,value:Fe(se,Ne.field,Ne),colDef:Ne,rowIndex:we,colIndex:xe-ne,rowMeta:S?.get(y(se))},v)},he=se=>{let we=U,xe=V;const Ne=(t.length+1)*o.length;for(let Qe=0;Qe<Ne;Qe++){if(xe+=se,xe>=o.length?(xe=0,we++):xe<0&&(xe=o.length-1,we--),we<0||we>=t.length)return null;const Se=t[we];if(!M?.(y(Se),o[xe].field)&&pe(Se,we,xe))return{r:we,c:xe}}return null};if(A){if($==="Enter")z.preventDefault(),d.stopCellEdit();else if($==="Escape")z.preventDefault(),d.stopCellEdit({cancel:!0});else if($==="Tab"&&k!==null){const se=he(z.shiftKey?-1:1);se&&(z.preventDefault(),d.stopCellEdit(),R(se.r,se.c))}return}if($==="Tab"||$==="Escape"||X==="control"&&($==="Enter"||B))return;if((z.ctrlKey||z.metaKey)&&($==="a"||$==="A")){if(!I||!F||!E)return;z.preventDefault(),E(!0);return}if(k===null){if($==="Enter"||B){if(z.preventDefault(),K===Re){an(q,W,-1)?.click();return}const se=o[V];if(!se||it(K)||se.sortable===!1)return;const we=u.find(Ne=>Ne.field===K),xe=we?we.sort==="asc"?"desc":null:"asc";(x||z.shiftKey)&&w?w(K,xe):g(K,xe);return}}else if($==="Enter"||B){z.preventDefault();const se=t[U];if(K===Re){i(k,!r.has(k));return}if(K===Ht){z.shiftKey||l(k);return}if(B){z.shiftKey&&I&&!fe(k)&&i(k,!r.has(k));return}if(K===Wt)return;if(pe(se,U,V)){d.startCellEdit({id:k,field:K,value:Fe(se,K,o[V])});return}if(T&&S?.get(k)?.hasChildren){T(k);return}N?.({row:se,id:k,rowIndex:U});return}if(z.altKey&&($==="ArrowRight"||$==="ArrowLeft")&&T&&k!==null){z.preventDefault();const se=S?.get(k);se?.hasChildren&&!!se.isExpanded!=($==="ArrowRight")&&T(k);return}if(!Nr.has($))return;z.preventDefault();const ge=t.length-1,be=o.length-1,ve=z.ctrlKey||z.metaKey,ye=p?f:10,ae=(se,we)=>{switch($){case"ArrowRight":return we+1>be?{r:se+1,c:0}:{r:se,c:we+1};case"ArrowLeft":return we-1<0?{r:se-1,c:be}:{r:se,c:we-1};case"ArrowDown":return{r:se+1,c:we};case"ArrowUp":return{r:se-1,c:we};case"Home":return{r:ve?-1:se,c:0};case"End":return{r:ve?ge:se,c:be};case"PageUp":return{r:Math.max(-1,se-ye),c:we};default:return{r:Math.min(ge,se+ye),c:we}}},Ce=({r:se,c:we})=>se>=-1&&se<=ge&&we>=0&&we<=be,Te=({r:se,c:we})=>se>=0?M?.(y(t[se]),o[we].field)??null:null;let _e=ae(U,V);if($.startsWith("Arrow"))for(let se=Ce(_e)?Te(_e):null;se&&se.rowId===k&&se.field===K;se=Ce(_e)?Te(_e):null)_e=ae(_e.r,_e.c);if(!Ce(_e))return;const ke=Te(_e);if(ke){const se=t.findIndex(xe=>y(xe)===ke.rowId),we=o.findIndex(xe=>xe.field===ke.field);se!==-1&&we!==-1&&(_e={r:se,c:we})}_e.r===U&&_e.c===V||R(_e.r,_e.c)},[W,Z,t,o,d,r,i,l,c,u,g,w,x,v,p,f,S,N,T,E,I,F,le,D,M,y]);return{focusedCell:W,setFocusedCell:C,viewportTabIndex:L?-1:0,ensureGridFocus:re,handleFocus:J,handleBlur:Y,handleKeyDown:Q,handleMouseDownCapture:ee}}const Cs={rowFields:[],columnFields:[],valueFields:[]},Pr=100;function _s(e){return!e||e.length===0||e.includes(Pr)?Pr:e[0]}function Ss(e){const{initialState:t,sortModel:o,onSortModelChange:n,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:d,columnVisibilityModel:c,onColumnVisibilityModelChange:u,pinnedColumns:g,onPinnedColumnsChange:w,pivotModel:x,onPivotModelChange:v,paginationModel:p,onPaginationModelChange:f,pageSizeOptions:m,rowSelectionModel:b,onRowSelectionModelChange:h,density:y}=e,[S,N]=s.useState(()=>t?.sorting?.sortModel??[]),T=o!==void 0,E=T?o:S,I=s.useCallback(ge=>{T||N(ge),n?.(ge)},[T,n]),[F,G]=s.useState(()=>t?.filter?.filterModel??{items:[]}),H=r!=null,_=H?r:F,M=s.useCallback(ge=>{H||G(ge),i?.(ge)},[H,i]),P=l!==void 0,[C,L]=s.useState(()=>l??{}),O=JSON.stringify(P?l:C),j=s.useMemo(()=>JSON.parse(O),[O]),W=s.useCallback(ge=>{P||L(ge),d?.(ge)},[P,d]),Z=c!==void 0,[oe,ie]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),te=Z?c:oe,ue=s.useCallback(ge=>{Z||ie(ge),u?.(ge)},[Z,u]),de=g!==void 0,[re,ce]=s.useState(()=>t?.columns?.pinnedColumns??{}),le=de?g:re,D=s.useCallback(ge=>{de||ce(ge),w?.(ge)},[de,w]),[ee,J]=s.useState(()=>x??Cs),Y=x??ee,Q=s.useCallback(ge=>{J(ge),v?.(ge)},[v]),z=p!==void 0,[q,X]=s.useState(()=>t?.pagination?.paginationModel??p??{page:0,pageSize:_s(m)}),$=z?p:q,B=s.useCallback(ge=>{z||X(ge),f?.(ge)},[z,f]),A=b!==void 0,[R,k]=s.useState([]),K=A?b:R,U=s.useMemo(()=>new Set(K),[K]),V=s.useRef(null);s.useLayoutEffect(()=>{V.current=null});const ne=s.useCallback(()=>V.current,[]),fe=s.useCallback(ge=>{V.current=ge,A||k(ge),h?.(ge)},[A,h]),[pe]=s.useState(()=>t?.density?.density??"standard");return{sortModel:E,isSortControlled:T,setInternalSortModel:N,handleSortModelChange:I,filterModel:_,isFilterControlled:H,handleFilterModelChange:M,aggregationModel:j,handleAggregationModelChange:W,columnVisibilityModel:te,handleColumnVisibilityModelChange:ue,pinnedColumns:le,handlePinnedColumnsChange:D,currentPivotModel:Y,handlePivotModelChange:Q,effectivePaginationModel:$,handlePaginationModelChange:B,rowSelectionModel:K,selectedRowIds:U,isSelectionControlled:A,setInternalRowSelectionModel:k,handleRowSelectionModelChange:fe,getPendingRowSelectionModel:ne,density:y??pe}}const Ir=s.createContext(null),ks=52,Es=56,Ms=32,Ns=72;function po(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 Ps(e){const{rowHeight:t,headerHeight:o,density:n}=e,r=s.useContext(Ir)?.grid;let i;return n==="compact"?i=po(r?.rowHeightCompact)??Ms:n==="comfortable"?i=po(r?.rowHeightComfortable)??Ns:i=t??po(r?.rowHeightStandard)??ks,{rowHeight:i,headerHeight:o??po(r?.headerHeight)??Es}}function ho(e){return e>=1?Math.floor(e):1}function cn(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/ho(t)))}function Is(e){const{paginationMode:t,hasDataSource:o,dataSourceRowCount:n,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(o?n??r:r)??i}function Tr(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Lr(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Ts(e){const{effectiveRows:t,activeHierarchyHandlers:o,filterMode:n,filterModel:r,sortModel:i,sortingMode:l,pagination:d,paginationMode:c,effectivePaginationModel:u,pinnedRows:g,getRowId:w,columnLookup:x,hierarchyField:v}=e,p=s.useMemo(()=>o?o.getVisibleRows({labelField:v})||[]:n==="server"?t:Zo(t,r,x),[t,r,o,v,n,x]),f=s.useMemo(()=>o?n==="server"?t:Zo(t,r,x):p,[o,p,n,t,r,x]),{top:m,center:b,bottom:h}=s.useMemo(()=>o?{top:[],center:p,bottom:[]}:Tl(p,g,w),[p,g,o,w]),y=s.useMemo(()=>o||l==="server"?b:ns(b,i,x,w),[b,i,o,l,x,w]),S=d&&c!=="server",N=ho(u.pageSize),T=S?Lr(u.page,cn(y.length,N)):u.page,E=s.useMemo(()=>{if(!S)return y;const F=T*N;return y.slice(F,F+N)},[y,S,T,N]),I=s.useMemo(()=>{const F=d?E:y;return[...m,...F,...h]},[m,E,y,h,d]);return{filteredRows:p,dataRows:f,pinnedTopRows:m,unpinnedRows:b,pinnedBottomRows:h,sortedUnpinnedRows:y,paginatedUnpinnedRows:E,currentPage:T,allRenderableRows:I}}function Ls(e){const{layout:t,scrollTop:o,scrollLeft:n,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:d,hasDetailPanel:c,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:w,overscanRows:x=5}=e;return s.useMemo(()=>{const{unpinnedAccWidths:v,unpinnedColsWithWidth:p,leftPinnedCols:f,rightPinnedCols:m,totalWidth:b,leftWidth:h,rightWidth:y,unpinnedTotalWidth:S,systemColumnsWidth:N,cumulativeHeights:T,pinnedTopHeight:E,pinnedBottomHeight:I,unpinnedRowsHeight:F,rowHeights:G,unpinnedRowsLength:H}=t,_=r||1e3,M=l?E+F+I+50:i||600,P=6,C=Math.max(0,n-h),L=n+_-h;let O=0,j=p.length-1,W=0,Z=v.length-1;for(;W<=Z;){const Q=W+Z>>>1;v[Q]<C?W=Q+1:Z=Q-1}O=Math.max(0,W-P);for(let Q=O;Q<v.length;Q++){if((Q===0?0:v[Q-1])>L){j=Math.min(p.length-1,Q+P);break}j=Math.min(p.length-1,Q+P)}const oe=O>0?v[O-1]:0,ie=S-v[j],te=[...f,...oe>0?[{field:"__spacer_left__",width:oe,isSpacer:!0}]:[],...p.slice(O,j+1),...ie>0?[{field:"__spacer_right__",width:ie,isSpacer:!0}]:[],...m],de=_>0&&b>_?16:0,re=E+F+I+de+2;let ce=0,le=H-1,D=0,ee=0,J=T.length-1;for(;ee<=J;){const Q=ee+J>>>1;T[Q]<o?ee=Q+1:J=Q-1}ce=Math.max(0,ee-x),D=ce>0?T[ce-1]:0;for(let Q=ce;Q<T.length;Q++)if(T[Q]>=o+M){le=Math.min(H-1,Q+x);break}const Y=(d?48:0)+(c&&w?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:ce,lastRowIndex:le,firstColumnIndex:O,lastColumnIndex:j},offsetTop:D,offsetLeft:0,totalHeight:re,pinnedTopHeight:E,pinnedBottomHeight:I,totalWidth:b,rowHeights:G,cumulativeHeights:T,virtualColumns:te,columnMetrics:{leftPinnedWidth:h,rightPinnedWidth:y,unpinnedAccWidths:v,unpinnedCols:p,totalSpecialsWidth:N,pinnedSpecialsWidth:Y}}},[t,o,n,r,i,l,d,c,u,g,w,x])}const dn="application/x-ogx-row",un="application/x-ogx-column";function Fr(e,t,o){const n=e.dataTransfer;!n||typeof n.setData!="function"||(n.setData(t,o),n.setData("text/plain",o))}function wo(e,t){const o=e.dataTransfer?.types;return o?Array.from(o).includes(t):!0}function Or(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const o=()=>t();return e.addEventListener("dragend",o,{once:!0}),()=>e.removeEventListener("dragend",o)}function Fs(e){const{columns:t,onColumnOrderChange:o,disableColumnReorder:n=!1}=e,[r,i]=s.useState(null),[l,d]=s.useState(null),c=s.useRef(()=>{}),u=s.useCallback(()=>{c.current(),c.current=()=>{},i(null),d(null)},[]);s.useEffect(()=>()=>c.current(),[]);const g=s.useCallback(v=>p=>{if(!n){if(!t.some(f=>f.field===v)){p.preventDefault();return}c.current(),c.current=Or(p.currentTarget,u),i(v),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Fr(p,un,v))}},[t,n,u]),w=s.useCallback(v=>p=>{if(!(n||r===null)){if(!wo(p,un)){u();return}p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),d(v)}},[r,n,u]),x=s.useCallback(v=>p=>{if(p.preventDefault(),n||r===null||!wo(p,un)){u();return}const f=t.findIndex(b=>b.field===r),m=t.findIndex(b=>b.field===v);u(),!(f===-1||m===-1||f===m)&&o?.({column:t[f],oldIndex:f,targetIndex:m})},[t,r,n,o,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:n?void 0:g,onDragOver:n?void 0:w,onDragEnd:n?void 0:u,onDrop:n?void 0:x}}function fn({isExpanded:e,onClick:t,variant:o="chevron",tabIndex:n}){return a.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",type:"button",tabIndex:n,children:o==="plus-minus"?a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:a.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Os({renderFn:e}){return a.jsx(a.Fragment,{children:e()})}function As(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 lt extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,o){return As(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?a.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):a.jsx(Os,{renderFn:this.props.renderFn})}}function Ds(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)?fo(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Ar(e,t){if(!t)return e;const o=t.left??[],n=t.right??[],r=i=>{const l=qe(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 mo=e=>e.formattedValue??e.value;function Dr(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:a.jsx(lt,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:a.jsx(lt,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function $s(e,t,o){const n=e.rowMeta;if(!n?.isGroupRow)return mo(e);if(n.isGroupFooter)return null;const r=n.descendantCount;if(t&&n.hasChildren){const i=n.groupLabel??`${n.groupingField}: ${String(n.groupingValue)}`;return a.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return o?a.jsxs("div",{className:"ogx__group-cell-content",children:[n.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):mo(e)}const Gs=e=>e.id;function Ws(e){const{activeColumns:t,isHierarchyEnabled:o,isRowGrouping:n,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:d,onColumnOrderChange:c,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:w,checkboxSelection:x,hasDetailPanel:v,rowReordering:p,initialState:f,setColumns:m,pinnedColumns:b,getRowId:h=Gs,aggregationModel:y,groupingRows:S}=e,N=s.useMemo(()=>t.map(J=>J.field),[t]),[T,E]=s.useState(()=>f?.columns?.columnOrder??null),I=w?N.join("\0"):"",[F,G]=s.useState(null),H=F&&F.key===I?F.order:N,M=w?H:d??(T??N),P=s.useCallback(J=>{if(w){G(Y=>{const Q=Y&&Y.key===I?Y.order:N;return{key:I,order:typeof J=="function"?J(Q):J}});return}E(Y=>typeof J=="function"?J(Y??N):J)},[w,I,N]),C=s.useCallback(J=>w&&J.hideable===!1||l[J.field]!==!1,[w,l]),L=s.useMemo(()=>{if(!o)return;const J=new Map(M.map((q,X)=>[q,X])),Y=q=>J.get(q.field)??t.indexOf(q),Q=[...t].sort((q,X)=>Y(q)-Y(X));return(Ar(Q.filter(q=>l[q.field]!==!1),b)[0]??t[0])?.field},[o,M,t,l,b]),O=s.useMemo(()=>{if(!o)return t;const J=n?S:void 0;return t.map(Y=>{const Q=Ds(Y,y?.[Y.field],J);return Y.field===L?{...Y,...Q,renderCell:z=>{const q=z.rowMeta,X=q?.treeDepth??0,$=!!q?.hasChildren,B=!!q?.isExpanded,A=Dr(Y,z,!0),R=A.useDefault?$s(z,n,r):A.content;return a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:X*24,width:"100%",height:"100%"},children:[a.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:$?"pointer":"default",flexShrink:0},children:$?a.jsx("div",{onClick:k=>{k.stopPropagation(),k.preventDefault(),i?.toggleExpansion(h(z.row))},onMouseDown:k=>{k.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:a.jsx(fn,{isExpanded:B,tabIndex:-1,onClick:k=>{k.stopPropagation(),k.preventDefault(),i?.toggleExpansion(h(z.row))}})}):null}),a.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R})]})}}:{...Y,...Q,renderCell:z=>{const q=z.rowMeta;if(!q?.isGroupRow)return Y.renderCell?Y.renderCell(z):mo(z);const X=Dr(Y,z,!1);return X.useDefault?Y.field===q.groupingField&&!q.isGroupFooter||z.value==null?null:mo(z):X.content}}})},[t,o,n,r,i,L,h,y,S]),[j,W]=s.useState(()=>f?.columns?.columnWidths??{}),Z=s.useCallback((J,Y)=>{W(Q=>({...Q,[J]:Y}))},[]);s.useEffect(()=>{m(t)},[t,m]);const oe=s.useMemo(()=>{const J=new Map(M.map((Y,Q)=>[Y,Q]));return[...O].sort((Y,Q)=>{const z=J.get(Y.field)??O.indexOf(Y),q=J.get(Q.field)??O.indexOf(Q);return z-q})},[O,M]),ie=s.useMemo(()=>oe.filter(C),[oe,C]),te=s.useCallback((J,Y)=>{(w||!d)&&P(J),Y&&c?.(Y),w||u?.(J)},[w,d,P,c,u]),ue=s.useCallback((J,Y)=>{const Q=oe.map(q=>q.field),[z]=Q.splice(J,1);Q.splice(Y,0,z),te(Q,{column:oe[J],oldIndex:J,targetIndex:Y})},[oe,te]),de=Fs({columns:oe,onColumnOrderChange:s.useCallback(({oldIndex:J,targetIndex:Y})=>ue(J,Y),[ue]),disableColumnReorder:g}),re=s.useCallback((J,Y)=>{const Q=oe.findIndex(q=>q.field===J),z=oe.findIndex(q=>q.field===Y);Q===-1||z===-1||Q===z||ue(Q,z)},[oe,ue]),ce=s.useCallback(()=>{te(N)},[te,N]),le=s.useMemo(()=>Ar(ie,b),[ie,b]),D=s.useMemo(()=>{const J=[];return p&&J.push({field:Wt,sortable:!1,editable:!1}),v&&J.push({field:Ht,sortable:!1,editable:!1}),x&&J.push({field:Re,sortable:!1,editable:!1}),[...J,...le]},[le,x,v,p]),ee=s.useMemo(()=>new Map(le.map((J,Y)=>[J.field,Y])),[le]);return{effectiveColumns:O,hierarchyField:L,orderedColumns:oe,visibleOrderedColumns:ie,renderOrderedColumns:le,navigationColumns:D,columnIndexMap:ee,columnWidths:j,effectiveColumnOrder:M,setInternalColumnOrder:P,columnReorderHandlers:de,moveColumn:re,resetColumnOrder:ce,handleColumnResize:Z}}const Hs=e=>e.id;function Bs(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:d=Hs}=e;return s.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:u}=t,g=l?r:i,w=o.length,x=o.map((y,S)=>({row:y,id:d(y),rowIndex:S,pinned:"top"})),v=n.map((y,S)=>({row:y,id:d(y),rowIndex:w+g.length+S,pinned:"bottom"})),p=Math.max(0,c),f=Math.min(g.length,u+1),m=g.slice(p,f).map((y,S)=>({row:y,id:d(y),rowIndex:w+p+S})),b=[...x,...m,...v],h=new Set;return b.filter(y=>h.has(y.id)?!1:(h.add(y.id),!0))},[t,o,n,r,i,l,d])}const zs=100;function $r(e){const{scrollTop:t,scrollHeight:o,clientHeight:n}=e;return o-t-n>=zs?null:{visibleTop:t,visibleBottom:t+n,viewportHeight:n}}function Vs(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Ks(e){const{onRowsScrollEnd:t,overscanRowCount:o=3,rowCount:n=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),d=s.useRef(null),c=s.useRef(null),u=s.useRef(null),g=s.useRef(!0),w=s.useRef(t),[x,v]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{w.current=t},[t]),s.useEffect(()=>()=>{d.current!==null&&cancelAnimationFrame(d.current),c.current!==null&&clearTimeout(c.current)},[]);const p=s.useCallback(b=>{const h=$r(b);if(!h){g.current=!0;return}if(!g.current)return;const y=w.current;y&&(g.current=!1,y(h))},[]),f=s.useCallback(b=>{const h=b.currentTarget,y=performance.now(),S=Math.abs(h.scrollTop-l.current.scrollTop)+Math.abs(h.scrollLeft-l.current.scrollLeft),N=y-l.current.time,T=N>0?S/N:0,E=h.scrollTop!==l.current.scrollTop;l.current={scrollTop:h.scrollTop,scrollLeft:h.scrollLeft,time:y},i.current={scrollTop:h.scrollTop,scrollLeft:h.scrollLeft,velocity:T},d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;const{scrollTop:I,scrollLeft:F,velocity:G}=i.current;v({scrollTop:I,scrollLeft:F,velocityOverscan:Vs(G)})}),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,v(I=>I.velocityOverscan===0?I:{...I,velocityOverscan:0})},200),E&&p(h)},[p]);s.useEffect(()=>{g.current=!0;const b=u.current;!b||r||n<=0||b.clientHeight===0||p(b)},[n,r,p]);const m=s.useCallback(b=>{if(u.current=b,!b)return;const{scrollTop:h,scrollLeft:y}=i.current;if(h===0&&y===0)return;b.scrollTop=h,b.scrollLeft=y;const S={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft};(S.scrollTop!==h||S.scrollLeft!==y)&&(i.current={...i.current,...S},l.current={...l.current,...S},v(N=>({...N,...S})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,o),handleScroll:f,attachViewport:m}}function Us(e){const t=s.useRef(null);return s.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:d}=i.contentRect;e(l,d)}});n.observe(o),t.current=n},[e])}function js(e){const{setDimensions:t,viewportRef:o,...n}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,attachViewport:c}=Ks(n),u=Us(t),g=s.useCallback(w=>{o.current=w,u(w),c(w)},[o,u,c]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:d,setViewportElement:g}}function qs(){const[e,t]=s.useState(()=>new Map),o=s.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 Xs(e){const{hasDetailPanel:t,controlledExpandedRowIds:o,onDetailPanelExpandedRowIdsChange:n,rowMetaMap:r}=e,[i,l]=s.useState(new Set),d=o??i,c=s.useMemo(()=>Dl(d,r),[d,r]),u=s.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const v=new Set(d);v.has(x)?v.delete(x):v.add(x),o===void 0&&l(v),n?.(v)},[d,r,o,n]),{detailPanelHeights:g,reportDetailPanelHeight:w}=qs();return{hasDetailPanel:t,expandedRowIds:c,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:w}}const Rs=new Set(["__group__"]),Bt=e=>!Rs.has(e);function Gr(e){return Object.keys(e).every(Bt)?e:Object.fromEntries(Object.entries(e).filter(([o])=>Bt(o)))}function Ys(e){const t={...e};return e.left&&(t.left=e.left.filter(Bt)),e.right&&(t.right=e.right.filter(Bt)),t}function Js(e){const{onStateChange:t,sortModel:o,filterModel:n,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:d,pinnedColumns:c,density:u}=e,g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t});const w=s.useRef(null);s.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:o},filter:{filterModel:n},pagination:{paginationModel:r},columns:{columnWidths:Gr(i),columnOrder:l.filter(Bt),columnVisibilityModel:Gr(d),pinnedColumns:Ys(c)},density:{density:u}},v=JSON.stringify(x);v!==w.current&&(w.current=v,g.current(x))},[o,n,r,i,l,d,c,u])}const Qs=200,Zs=2e3,ea=178e5;function ta(e){const{paginationRequested:t,isRowGrouping:o,autoHeight:n,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:d=!1,scrollHeight:c=0,listViewWithoutColumn:u=!1,listViewRowCount:g=0}=e,w=s.useRef(!1),x=s.useRef(!1),v=s.useRef(!1),p=s.useRef(!1),f=s.useRef(!1),m=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||m.current||g<=Zs||(m.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${g} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[g]),s.useEffect(()=>{process.env.NODE_ENV==="production"||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]),s.useEffect(()=>{process.env.NODE_ENV==="production"||v.current||!d||(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."))},[d]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||c<=ea||(p.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(c)}px tall. Browsers cap element heights (about 17.9M px in Firefox, 33.5M px in Chrome and Safari), so the last rows may not be reachable by scrolling. Use pagination, server-side or infinite loading, or a smaller rowHeight. See docs/features/virtualization.md.`))},[c]),s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||t&&o&&(w.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,o]),s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||n||r>0&&l>Qs&&i>=l&&r>=c&&(x.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off: the grid fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[n,r,i,l,c])}function oa(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Wr=!1;function na(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||Wr)return;const t=e.current;!t||!oa(t)||(Wr=!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 xo(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 ra(e,t,o){return o?e.has(t)?[]:[t]:xo(e,[t],!e.has(t),!1)}function Hr(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function ia(e){const{selectedRowIds:t,onSelectionModelChange:o,disableMultipleRowSelection:n,selectableRowIds:r}=e,i=s.useCallback(w=>{Hr(t,w)||o(w)},[t,o]),l=s.useCallback((w,x)=>{i(xo(t,[w],x,n))},[i,t,n]),d=s.useCallback(w=>{i(ra(t,w,n))},[i,t,n]),c=s.useCallback(w=>{i(xo(t,r,w,!1))},[i,t,r]),{allSelected:u,someSelected:g}=s.useMemo(()=>{let w=0;for(const v of r)t.has(v)&&w++;const x=r.length>0&&w===r.length;return{allSelected:x,someSelected:!x&&w>0}},[r,t]);return{toggleRow:l,clickRow:d,selectAll:n?void 0:c,allSelected:u,someSelected:g}}function la(e){const{dataRows:t,getRowId:o,isPivotActive:n,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:d,isHierarchyEnabled:c,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:w}=e,x=s.useMemo(()=>{const m=t.map(o);return n?m.filter(b=>b!==wt):m},[t,o,n]),v=ia({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),p=s.useCallback(m=>{const{id:b}=m,h=c?u.get(b):void 0;if(h?.isGroupRow){h.hasChildren&&g?.toggleExpansion(b);return}w?.(m),!d&&!Xe(b,u)&&v.clickRow(b)},[c,g,w,u,d,v]),f=s.useCallback((m,b)=>{Xe(m,u)||v.toggleRow(m,b)},[u,v]);return{rowSelection:v,handleRowClick:p,handleSelectionChange:f}}const Br=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function sa(e){const{selectedRowIds:t,rowsLookup:o,rowMetaMap:n,enabled:r,onSelectionModelChange:i}=e,l=s.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;const g=new Set;for(const w of t)o.has(w)||n.has(w)?g.add(w):u=!0;return u?g:t},[r,t,o,n]),d=s.useRef(i);s.useLayoutEffect(()=>{d.current=i});const c=s.useRef(null);return s.useEffect(()=>{if(l===t){c.current=null;return}const u=`${Br(t)}|${Br(l)}`;c.current!==u&&(c.current=u,d.current(Array.from(l)))},[l,t]),l}function gn(e,t,o,n){return n?rs(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function aa(e){const{sortModel:t,onSortModelChange:o}=e,n=s.useCallback((i,l)=>{o(gn(t,i,l,!1))},[t,o]),r=s.useCallback((i,l)=>{o(gn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function ca(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:o,pinnedColumns:n,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:n});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:n}});const l=s.useCallback(c=>{const u={...i.current.columnVisibilityModel,[c]:!1};i.current={...i.current,columnVisibilityModel:u},o(u)},[o]),d=s.useCallback((c,u)=>{const g=Ll(i.current.pinnedColumns,c,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:d}}function da(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.useLayoutEffect(()=>{const n=t.current,r=()=>o.current;n.getSortModel=()=>r().sortModel,n.sortColumn=(c,u)=>{const{sortModel:g,multiSort:w,onSortModelChange:x}=r(),v=gn(g,c,u,w);o.current={...r(),sortModel:v},x(v)},n.getFilterModel=()=>r().filterModel,n.setFilterModel=c=>{o.current={...r(),filterModel:c},r().onFilterModelChange(c)};const i=c=>{o.current={...r(),paginationModel:c},r().onPaginationModelChange(c)};n.setPage=c=>i({...r().paginationModel,page:c}),n.setPageSize=c=>i({...r().paginationModel,pageSize:c,page:0});const l=()=>{const c=r().getPendingRowSelectionModel?.();return c?new Set(c):r().selectedRowIds},d=(c,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:w,isSyntheticRowId:x}=r(),v=x?c.filter(m=>!x(m)):c;if(v.length===0)return;const p=l(),f=xo(p,v,u,g);Hr(p,f)||(o.current={...r(),selectedRowIds:new Set(f)},w(f))};n.getSelectedRows=()=>Array.from(l()),n.selectRow=(c,u=!0)=>d([c],u),n.selectRows=(c,u=!0)=>d(c,u),n.getVisibleRows=()=>r().getVisibleRows(),n.getAllFilteredRows=()=>r().getAllFilteredRows(),n.getVisibleColumns=()=>r().visibleColumns},[t])}const zr="\0";function ua(e,t){const o=e.filter(n=>t[n.field]===!1).map(n=>n.field).join(zr);return s.useMemo(()=>{const n={};if(o)for(const r of o.split(zr))n[r]=!1;return rn(e,n)},[e,o])}function fa({paginationModel:e,currentPage:t,enabled:o,onPaginationModelChange:n}){const r=s.useRef({paginationModel:e,onPaginationModelChange:n});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:n}});const i=e.page,l=s.useRef(null);s.useEffect(()=>{if(!o)return;if(t===i){l.current=null;return}const d=`${i}>${t}`;if(l.current===d)return;l.current=d;const{paginationModel:c,onPaginationModelChange:u}=r.current;u({...c,page:t})},[o,t,i])}function ga(){const[e,t]=s.useState(!1),[o,n]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),l=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),d=s.useCallback(()=>{i.current>0?t(!0):n(!0)},[]),c=s.useCallback(()=>t(!1),[]),u=s.useCallback(()=>n(!1),[]);return s.useEffect(()=>{if(!o)return;function g(x){r.current&&!r.current.contains(x.target)&&n(!1)}function w(x){x.key==="Escape"&&n(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",w)}},[o]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:c,standalonePanelOpen:o,closeStandalonePanel:u,standalonePanelRef:r,openColumnsPanel:d}}const Vr=s.createContext(null);function pa(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function ha({render:e,toolbarProps:t}){return a.jsx(a.Fragment,{children:e(t)})}function wa({component:e,toolbarProps:t}){if(pa(e))return a.jsx(ha,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return a.jsx(o,{...t})}const Kr=48;function ma({columns:e,aggregationModel:t,aggregationResult:o,columnWidths:n,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:d,pinCheckboxColumn:c=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:w=!1}){const x=s.useMemo(()=>Bo(e,n,g,i,c,l,u,d),[e,n,g,i,c,l,u,d]),{lastLeft:v,firstRight:p}=s.useMemo(()=>zo(e,g),[e,g]),f=d?Kr:0,m=f+(l&&u?Kr:0),b=(h,y,S)=>a.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:S}:void 0,"aria-hidden":"true"},h);return a.jsxs("div",{className:`ogx__aggregation-footer${w?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":w||void 0,style:{minHeight:`${r}px`},children:[d&&b("__reorder_col__",!0,0),l&&b("__expand_col__",u,f),i&&b("__checkbox_col__",c,m),e.map(h=>{if(h.isSpacer){const H=typeof h.width=="number"?h.width:0;return a.jsx("div",{style:{width:H,minWidth:H,flexShrink:0},"aria-hidden":"true"},h.field)}const y=t[h.field],S=y&&Ro(h,y)?y:void 0,N=o[h.field],T=nt(h,n,120),E=qe(h.field,g),I=E?x[h.field]:void 0,F=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&h.field===v&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&h.field===p&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),G={width:T,minWidth:T,maxWidth:T,textAlign:h.align||"left"};return E==="left"&&I!==void 0&&(G.left=I),E==="right"&&I!==void 0&&(G.right=I),a.jsx("div",{className:F,role:"gridcell",style:G,children:S?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"ogx__aggregation-label",children:S}),a.jsx("span",{className:"ogx__aggregation-value",children:fo(N,S,h,o)})]}):null},h.field)})]})}function xa({noRowsLabel:e,width:t,overlay:o}){return o?a.jsx("div",{className:"ogx__empty",style:{width:t},children:o}):a.jsxs("div",{className:"ogx__empty",style:{width:t},children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),a.jsx("span",{children:e})]})}function Ur({dataSource:e,paginationMode:t,sortingMode:o,filterMode:n}){return!!e&&(t==="server"||t==="infinite"||o==="server"||n==="server")}const jr=Number.MAX_SAFE_INTEGER,ba="An unexpected error occurred while loading the data.";function qr(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:ba}function va({error:e,onRetry:t}){if(!e)return null;const o=qr(e);return a.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[a.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),a.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&a.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}const zt=({indeterminate:e=!1,label:t,className:o="",inputRef:n,...r})=>{const i=s.useRef(null),l=s.useCallback(c=>{i.current=c,typeof n=="function"?n(c):n&&(n.current=c)},[n]);s.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const d=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return a.jsxs("label",{className:d,children:[a.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),a.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&a.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&a.jsx("span",{className:"ogx-checkbox__label",children:t})]})},Xr=50;function pn(e,t,o,n){const r=Math.min(o??Xr,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const ya=16;function Ca(e){e.preventDefault(),e.stopPropagation()}function _a(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function Sa(e){const{field:t,currentWidth:o,onResize:n,onAutosize:r,minWidth:i,maxWidth:l,edge:d="end"}=e,[c,u]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>()=>{g.current=null},[]);const w=s.useCallback((h,y)=>{const S=y-h.startX,N=h.startWidth+(d==="start"?-S:S);return pn(N,h.startWidth,i,l)},[d,i,l]),x=s.useCallback(h=>{if(h.button===0){h.stopPropagation(),g.current={pointerId:h.pointerId,startX:h.clientX,startWidth:o,lastUpdate:0,moved:!1},u(!0);try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}}},[o]),v=s.useCallback(h=>{const y=g.current;if(!y||h.pointerId!==y.pointerId||(h.clientX!==y.startX&&(y.moved=!0),!y.moved))return;const S=Date.now();S-y.lastUpdate>=ya&&(y.lastUpdate=S,n(t,w(y,h.clientX)))},[t,n,w]),p=s.useCallback((h,y)=>{const S=g.current;!S||h.pointerId!==S.pointerId||(g.current=null,u(!1),(S.moved||h.clientX!==S.startX)&&(_a(),y&&n(t,w(S,h.clientX))))},[t,n,w]),f=s.useCallback(h=>{if(h.key==="Enter"&&r){h.preventDefault(),h.stopPropagation(),r(t);return}if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;h.preventDefault(),h.stopPropagation();const y=(h.shiftKey?50:10)*(h.key==="ArrowRight"?1:-1);n(t,pn(o+y,o,i,l))},[t,o,n,r,i,l]),m=s.useCallback(h=>{h.preventDefault(),h.stopPropagation(),r?.(t)},[t,r]),b=["ogx-column-resize-handle",d==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return a.jsx("div",{className:b,onPointerDown:x,onMouseDown:Ca,onPointerMove:v,onPointerUp:h=>p(h,!0),onPointerCancel:h=>p(h,!1),onClick:h=>h.stopPropagation(),onDragStart:h=>{h.preventDefault(),h.stopPropagation()},onDoubleClick:m,onKeyDown:f,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(o),"aria-valuemin":Math.round(Math.min(i??50,o)),"aria-valuemax":l,tabIndex:-1,children:a.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Rr(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 Yr(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 hn(e,t,o){if(!e||e.length===0)return!0;const n=Yr(e),r=n.get(t),i=n.get(o);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function ka(e,t,o){const n=[];let r=0,i=null,l=null;for(const d of e){const c=d.isSpacer?null:t.get(d.field)?.[o]??null;(i===null||l!==c||i.pinned!==d.pinned)&&(i={key:`${c?c.groupId:"filler"}-${o}-${d.field}`,isGroup:c!==null,label:c?.headerName??"",headerClassName:c?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:d.pinned},l=c,n.push(i)),i.width+=d.width,i.flexGrow+=d.flex??0,d.isSpacer||(i.fields.push(d.field),r++)}return n}function xt(){return document.documentElement.clientWidth||window.innerWidth}function Ea(){return document.documentElement.clientHeight||window.innerHeight}function bt(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:a.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function vt(){return a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:a.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Ma(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Na(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),a.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Pa(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ia(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Ta(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function La(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),a.jsx("polyline",{points:"11 8 4 12 11 16"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Fa(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),a.jsx("polyline",{points:"13 8 20 12 13 16"}),a.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Oa(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),a.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),a.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Jr=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Aa({colDef:e,sortModel:t,onSort:o,onHide:n,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:d,anchorEl:c}){const u=s.useRef(null),g=s.useCallback(G=>{G&&(c?.closest('[role="columnheader"]')??c)?.focus({preventScroll:!0}),d()},[c,d]),w=G=>{const H=Jr(u.current),_=H.indexOf(G.target);let M=-1;if(G.key==="ArrowDown")M=_+1>=H.length?0:_+1;else if(G.key==="ArrowUp")M=_<=0?H.length-1:_-1;else if(G.key==="Home")M=0;else if(G.key==="End")M=H.length-1;else if(G.key==="Tab"){G.preventDefault(),g(!0);return}else return;G.preventDefault(),H[M]?.focus()},[x,v]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!u.current)return;const G=c.getBoundingClientRect(),H=u.current.getBoundingClientRect(),_=xt(),M=Ea(),P=8;let C=G.left;C+H.width+P>_&&(C=_-H.width-P),C<P&&(C=P);let L=G.bottom+4;L+H.height+P>M&&(L=G.top-H.height-4),v({position:"fixed",zIndex:1300,top:L,left:C,visibility:"visible"})},[c]);const p=x.visibility==="visible";s.useLayoutEffect(()=>{p&&Jr(u.current)[0]?.focus({preventScroll:!0})},[p]),s.useEffect(()=>{function G(_){u.current&&!u.current.contains(_.target)&&c&&!c.contains(_.target)&&d()}function H(_){_.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",H),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",H),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[c,d,g]);const f=G=>{o?.(e.field,G),g(!0)},m=!!n&&e.hideable!==!1,b=!!r&&e.pinnable!==!1,h=()=>{m&&n?.(e.field),g(!0)},y=G=>{b&&r?.(e.field,G),g(!0)},S=t?.find(G=>G.field===e.field)?.sort,N=S==null,T=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,I=!T&&!E,F=e.headerName||e.field;return ot.createPortal(a.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${F}`,onKeyDown:w,children:[o&&e.sortable!==!1&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:`ogx-menu-item${S==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":S==="asc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S==="asc"?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Na,{})}),"Sort Ascending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${S==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":S==="desc",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S==="desc"?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Pa,{})}),"Sort Descending"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":N,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ia,{})}),"Unsort"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),a.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":T,"aria-label":"Pin to left",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(La,{})}),"Pin to Left"]}),a.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:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Fa,{})}),"Pin to Right"]}),a.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>y(null),role:"menuitemradio","aria-checked":I,"aria-label":"Unpin column",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?a.jsx(bt,{}):a.jsx(vt,{})}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Oa,{})}),"Unpin"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),m&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${F} column`,children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ta,{})}),"Hide Column"]}),a.jsx("div",{className:"ogx-menu-divider"})]}),a.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[a.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),a.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:a.jsx(Ma,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}function Da(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:a.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function $a(){return a.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:a.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Qr(e){const{columns:t,allColumns:o,columnGroupingModel:n,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:d,onSort:c,sortModel:u=[],onColumnResize:g,onColumnAutosize:w,columnWidths:x={},pinnedColumns:v,hasDetailPanel:p=!1,pinCheckboxColumn:f=!0,pinExpandColumn:m=!0,rowReordering:b=!1,aggregationModel:h,draggedColumn:y,dragOverColumn:S,onDragStart:N,onDragOver:T,onDragEnd:E,onDrop:I,focusedCell:F,onHeaderClick:G,onSortAdd:H,multiSort:_=!1,onHideColumn:M,onPinColumn:P,onManageColumns:C,columnIndexMap:L}=e,O=s.useId(),[j,W]=s.useState(null),Z=k=>K=>{K.stopPropagation(),W({colDef:k,anchorEl:K.currentTarget})},oe=s.useCallback(()=>{W(null)},[]),ie=k=>K=>{if(K.altKey&&(K.key==="ArrowLeft"||K.key==="ArrowRight")&&K.target===K.currentTarget){if(k.resizable===!1||!g)return;K.preventDefault(),K.stopPropagation();const fe=nt(k,x),pe=(K.shiftKey?50:10)*(K.key==="ArrowRight"?1:-1);g(k.field,pn(fe+pe,fe,k.minWidth,k.maxWidth));return}if(!(K.altKey&&K.key==="ArrowDown"||(K.ctrlKey||K.metaKey)&&K.key==="Enter")||k.disableColumnMenu||K.target!==K.currentTarget)return;K.preventDefault(),K.stopPropagation();const ne=K.currentTarget.querySelector(".ogx__menu-icon-btn")??K.currentTarget;W({colDef:k,anchorEl:ne})},te=k=>F?.id===null&&F.field===k,ue=b?1:0,de=p?ue+1:ue,re=r?de+1:de,ce=k=>K=>{if(k.sortable===!1)return;const U=u.find(ne=>ne.field===k.field);let V="asc";U&&(U.sort==="asc"?V="desc":V=null),(K.shiftKey||_)&&H?H(k.field,V):c&&c(k.field,V)},le=(k,K)=>{const U=u.some(ne=>ne.field===k);H&&(K===null||U||_||!c)?H(k,K):c?.(k,K)},D=k=>{const K=u.find(V=>V.field===k);if(!K)return null;const U=u.length>1?u.indexOf(K)+1:null;return a.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${K.sort}`,"aria-hidden":"true",children:U!==null&&a.jsx("span",{className:"ogx__sort-badge",children:U})})},ee=s.useMemo(()=>Bo(t,x,v,r,f,p,m,b),[t,x,v,r,f,p,m,b]),J=s.useMemo(()=>zo(t,v),[t,v]),Y=Rr(n),Q=s.useMemo(()=>Yr(n),[n]),z=s.useMemo(()=>Y===0?[]:(o??t).map(k=>({field:k.field,width:nt(k,x),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:qe(k.field,v),isSpacer:k.isSpacer})),[Y,o,t,x,v]),B=(b?48:0)+(p?48:0)+(r?48:0),A=(b||p||r)&&(!p||m)&&(!r||f),R=(b?1:0)+(p?1:0)+(r?1:0);return a.jsxs("div",{className:"ogx__header-wrap",children:[Y>0&&Array.from({length:Y},(k,K)=>{const U=ka(z,Q,K);return a.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":K+1,children:[B>0&&a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${A?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:B,minWidth:B,flexShrink:0,position:A?"sticky":void 0,left:A?0:void 0},"aria-hidden":"true"}),U.map((V,ne)=>{const fe=V.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${V.pinned}`:"",pe={width:V.width,minWidth:V.width,flexShrink:0,flexGrow:V.flexGrow};return V.pinned==="left"?(pe.position="sticky",pe.left=ee[V.fields[0]]):V.pinned==="right"&&(pe.position="sticky",pe.right=ee[V.fields[V.fields.length-1]],U[ne-1]?.pinned!=="right"&&(pe.marginLeft="auto")),V.isGroup?a.jsx("div",{role:"columnheader","aria-colspan":V.fields.length,"aria-colindex":R+V.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${fe}${V.headerClassName?` ${V.headerClassName}`:""}`,style:pe,title:V.label,children:a.jsx("span",{className:"ogx-col-group-cell__label",children:V.label})},V.key):a.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${fe}`,style:pe,"aria-hidden":"true"},V.key)})]},`ogx-grp-${K}`)}),a.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":Y+1,children:[b&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${te("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":ue,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),p&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__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:m?"sticky":void 0,left:m?b?48:0:void 0}}),r&&a.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":re,"data-field":"__checkbox_col__",style:{position:f?"sticky":void 0,left:f?(b?48:0)+(p&&m?48:0):void 0},children:d&&a.jsx(zt,{id:O,name:O,checked:i,indeterminate:l,onChange:k=>d(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,K)=>{if(k.isSpacer)return a.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const U=k.sortable!==!1,V=u.findIndex(Se=>Se.field===k.field),ne=V!==-1,fe=ne?u[V].sort:null,pe=L?.get(k.field)??K,he=U?V===0?fe==="asc"?"ascending":"descending":"none":void 0,ge=ne&&u.length>1?`Sorted ${fe==="asc"?"ascending":"descending"}, sort priority ${V+1} of ${u.length}`:void 0,be=k.resizable!==!1,ve=qe(k.field,v),ye=ve!==null,ae=y===k.field,Ce=S===k.field,Te=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,U&&"ogx__header-cell--sortable",ne&&"ogx__header-cell--sorted",ye&&"ogx__header-cell--pinned",ye&&`ogx__header-cell--pinned-${ve}`,ve==="left"&&k.field===J.lastLeft&&"ogx__header-cell--pinned-left-last",ve==="right"&&k.field===J.firstRight&&"ogx__header-cell--pinned-right-first",ae&&"ogx__header-cell--dragging",Ce&&"ogx__header-cell--drag-over",te(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),ke={width:x[k.field]??k.width??100,minWidth:k.minWidth,maxWidth:k.maxWidth,flexGrow:k.flex??0,flexShrink:0,flexBasis:(k.flex,"auto"),boxSizing:"border-box",position:ye?"sticky":"relative",zIndex:k.zIndex,opacity:ae?.5:1};if(ye&&ve){const Se=ee[k.field];ve==="left"?ke.left=Se:ke.right=Se}const se=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:pe}):k.headerName||k.field,we=Se=>{if(Se.target.closest(".ogx-column-resize-handle")){Se.stopPropagation();return}G?.(k.field),U&&ce(k)(Se)},xe=N&&!ye?N(k.field):void 0,Ne=T&&!ye?T(k.field):void 0,Qe=I&&!ye?I(k.field):void 0;return a.jsxs("div",{className:Te,style:ke,title:k.description,onClick:we,role:"columnheader",draggable:!!xe,onDragStart:xe,onDragOver:Ne,onDragEnd:E,onDrop:Qe,onKeyDown:ie(k),"aria-sort":he,"aria-description":ge,"aria-colindex":R+pe+1,"data-field":k.field,tabIndex:-1,children:[a.jsxs("div",{className:"ogx__header-cell-content",children:[ae&&a.jsx("div",{className:"ogx__header-drag-icon",children:a.jsx($a,{})}),a.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[a.jsx("span",{className:"ogx__header-cell-title",children:se}),h&&h[k.field]&&a.jsx("span",{className:"ogx__header-cell-aggregation",children:h[k.field]})]}),U&&D(k.field),!k.disableColumnMenu&&a.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:Z(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:a.jsx(Da,{})})]}),be&&g&&a.jsx(Sa,{field:k.field,currentWidth:nt(k,x),onResize:g,onAutosize:w,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:ve==="right"?"start":"end"})]},k.field)}),j&&a.jsx(Aa,{colDef:j.colDef,sortModel:u,onSort:c||H?le:void 0,onHide:M,onPin:P,pinnedColumns:v,onManageColumns:C,onClose:oe,anchorEl:j.anchorEl})]})]})}const Ue=()=>{};function Zr(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:Ue,selectRows:Ue,getSelectedRows:()=>[],sortColumn:Ue,getSortModel:()=>[],setFilterModel:Ue,getFilterModel:()=>({items:[]}),setPage:Ue,setPageSize:Ue,scrollToIndexes:Ue,autosizeColumn:Ue,autosizeColumns:Ue,copySelectedRows:()=>Promise.resolve()}}const Ga=e=>e.id;let ei=!1;function ti(e,t,o){const n=new Map,r=new Map,i=[],l=[];return e.forEach(d=>{const c=o?.get(d)??t(d);if(n.has(c)){l.push(c);return}n.set(c,d),r.set(d,c),i.push(c)}),l.length>0&&!ei&&process.env.NODE_ENV!=="production"&&(ei=!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 Wa(e,t,o,n={}){const r=new Map,i=[];return o.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:ti(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 Ha(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:ti(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 Ba(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:d=!1}=e,c=e.getRowId??Ga,u=s.useRef(c);s.useLayoutEffect(()=>{u.current=c});const[g]=s.useState(()=>Wa(t,c,o,i)),[w,x]=s.useReducer(Ha,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:n,headerHeight:r}}),[v,p]=s.useState({rows:t,syncRows:d});(v.rows!==t||v.syncRows!==d)&&(p({rows:t,syncRows:d}),d&&x({type:"SET_ROWS",payload:t,getRowId:c}));const f=s.useRef(w);s.useLayoutEffect(()=>{f.current=w});const m=s.useCallback((F,G)=>{x({type:"SET_ROWS",payload:F,getRowId:u.current})},[]),b=s.useCallback((F,G)=>{x({type:"REPLACE_ROW",id:F,row:G})},[]),h=s.useCallback(F=>{x({type:"SET_COLUMNS",payload:F})},[]),y=s.useCallback((F,G)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:F,viewportHeight:G}})},[]),S=s.useCallback(F=>{x({type:"SET_DATASOURCE_LOADING",payload:F})},[]),N=s.useCallback(F=>{x({type:"SET_DATASOURCE_ERROR",payload:F})},[]),T=s.useCallback(F=>{x({type:"SET_ROW_COUNT",payload:F})},[]),[E]=s.useState(()=>({...Zr(),getRow:F=>f.current.rows.idRowsLookup.get(F)||null,getAllRows:()=>f.current.rows.allRows.map(F=>f.current.rows.idRowsLookup.get(F)),getColumn:F=>f.current.columns.lookup.get(F)||null,getAllColumns:()=>f.current.columns.all})),I=s.useRef(E);return{state:w,dispatch:x,apiRef:I,setRows:m,replaceRow:b,setColumns:h,setDimensions:y,setDataSourceLoading:S,setDataSourceError:N,setRowCount:T}}function za(e){const{onRowOrderChange:t,rows:o,getRowId:n,rowReordering:r=!1}=e,[i,l]=s.useState(null),[d,c]=s.useState(null),u=s.useRef(()=>{}),g=s.useMemo(()=>{const m=new Map;return o.forEach((b,h)=>m.set(n?n(b):b.id,h)),m},[o,n]),w=s.useCallback(m=>g.has(m),[g]),x=s.useCallback(()=>{u.current(),u.current=()=>{},l(null),c(null)},[]);s.useEffect(()=>()=>u.current(),[]);const v=s.useCallback(m=>b=>{if(r){if(!g.has(m)){b.preventDefault();return}u.current(),u.current=Or(b.currentTarget,x),l(m),b.dataTransfer&&(b.dataTransfer.effectAllowed="move",Fr(b,dn,String(m)))}},[r,g,x]),p=s.useCallback(m=>b=>{if(!(!r||i===null)){if(!wo(b,dn)){x();return}g.has(m)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),d!==m&&c(m))}},[r,i,d,g,x]),f=s.useCallback(m=>b=>{if(b.preventDefault(),i===null||!wo(b,dn)){x();return}const h=g.get(i),y=g.get(m);x(),t&&h!==void 0&&y!==void 0&&h!==y&&t({row:o[h],oldIndex:h,targetIndex:y})},[i,t,o,g,x]);return{draggedRowId:i,dragOverRowId:d,canReorderRow:w,onDragStart:r?v:void 0,onDragOver:r?p:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const oi=new Map,ni=e=>JSON.stringify(e),Va=e=>`auto-group-${e}`,ri=5,ii=e=>e.slice(0,ri).map(t=>JSON.stringify(t)).join(", ")+(e.length>ri?", …":""),Ka={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Ua(e,t,o){const n=new Map,r=[],i=[],l=new Set,d=new Map,c=new Map,u=[],g=new Array(e.length),w=new Array(e.length),x=[],v=new Map;e.forEach((f,m)=>{const b=t(f),h=o(f),y=Array.isArray(h)?h.map(S=>String(S)):[];if(g[m]=b,w[m]=y,d.set(b,f),y.length===0)x.push(b);else{const S=ni(y),N=c.get(S);if(N===void 0)c.set(S,b);else{const T=v.get(S)??[N];T.push(b),v.set(S,T)}}n.set(b,{id:b,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const p=f=>{const m=ni(f),b=c.get(m);if(b!==void 0)return b;const h=Va(m),y=f[f.length-1],S={id:h,parentId:null,depth:f.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};n.set(h,S),c.set(m,h),l.add(h);const N={id:h};if(i.push(N),d.set(h,N),f.length===1)r.push(h);else{const T=p(f.slice(0,-1));S.parentId=T,n.get(T)?.children?.push(h)}return h};return e.forEach((f,m)=>{const b=g[m],h=w[m];if(h.length<=1){r.push(b);return}const y=p(h.slice(0,-1)),S=n.get(b);S&&(S.parentId=y),n.get(y)?.children?.push(b)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${ii(x)}. They are shown as top-level rows.`),v.forEach((f,m)=>{u.push(`[OpenGridX] treeData: rows ${ii(f)} have the same path ${m}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:n,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:d,issues:u}}function ja(e,t){const{treeNodes:o,rootIds:n,syntheticIds:r,rowLookup:i}=e,l=new Set,d=new Map,c=new Map,u=g=>{const w=o.get(g);if(!w)return!1;const x=[];let v=0;for(const b of w.children??[])u(b)&&(x.push(b),v+=(r.has(b)?0:1)+(c.get(b)??0));d.set(g,x),c.set(g,v);const p=i.get(g),m=!r.has(g)&&p!==void 0&&(t?t(p):!0)||x.length>0;return m&&l.add(g),m};return n.forEach(u),{visible:l,visibleChildren:d,descendantCounts:c}}function qa(e){const{rows:t,getRowId:o,getTreeDataPath:n,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:d,onRowExpansionChange:c,columnLookup:u,filterMode:g="client",sortingMode:w="client"}=e,x=r&&!!n,v=s.useMemo(()=>!r||!n?Ka:Ua(t,o,n),[t,n,r,o]),{treeNodes:p,rootIds:f,groupingRows:m,syntheticIds:b,rowLookup:h}=v,y=v.issues.join(`
2
2
  `);s.useEffect(()=>{process.env.NODE_ENV==="production"||!y||y.split(`
3
- `).forEach(J=>console.warn(J))},[y]);const C=r&&!n;s.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=s.useMemo(()=>g==="server"?null:fo(l,u),[g,l,u]),T=s.useMemo(()=>Va(v,N),[v,N]),E=`${r}|${i}`,[I,F]=s.useState(()=>({configKey:E,overrides:new Map})),G=I.configKey===E?I.overrides:ti,j=s.useCallback(J=>((J?.children?.length??0)>0||(J?.serverChildrenCount??0)>0)&&(i===-1||(J?.depth??0)<i),[i]),S=s.useMemo(()=>{const J=new Set;return w&&p.forEach((ee,ne)=>{(G.get(ne)??j(ee))&&J.add(ne)}),J},[w,p,G,j]),M=s.useCallback(J=>{const ee=!S.has(J);if(F(ne=>{const Z=ne.configKey===E?ne.overrides:ti,ce=new Map(Z);return ce.set(J,ee),{configKey:E,overrides:ce}}),ee&&d){const ne=p.get(J);ne&&d(ne)}},[S,E,p,d]),P=m!=="server"&&!!(c&&c.length>0),_=s.useCallback(J=>{if(!w)return null;const ee=J?.labelField,ne=J?.expandAll??!1,{visible:Z,visibleChildren:ce}=T,ae=P&&c?c:[],oe=(O,$)=>{if(b.has(O))return{value:$.field===ee?p.get(O)?.label:void 0};const Y=h.get(O),U=u?.byField.get($.field),D=Y?Fe(Y,$.field,U):void 0,W=U?.sortComparator;return{value:D,type:U?.type,comparator:W,params:W&&Y?{id:O,field:$.field,row:Y,value:D}:void 0}},de=[],ie=new Set,V=O=>{const $=O.filter(U=>Z.has(U)),Y=ae.length>0?on($,ae,oe):$;for(const U of Y){if(ie.has(U))continue;const D=h.get(U);if(!D)continue;ie.add(U),de.push(D);const W=ce.get(U);W&&W.length>0&&(ne||S.has(U))&&V(W)}};return V(f),de},[w,T,P,c,b,p,h,u,f,S]),L=s.useCallback(J=>S.has(J),[S]),A=s.useCallback(J=>p.get(J),[p]),X=s.useCallback(J=>{const ee=[];let ne=J;for(;ne!==null;){const Z=p.get(ne);if(!Z)break;ee.unshift(Z.groupingKey),ne=Z.parentId}return ee},[p]),z=s.useMemo(()=>{const J=new Map,{visibleChildren:ee,descendantCounts:ne}=T;return p.forEach((Z,ce)=>{const ae=(Z.children?.length??0)===0&&(Z.serverChildrenCount??0)>0,oe=b.has(ce),de={hasChildren:(ee.get(ce)?.length??0)>0||ae,treeDepth:Z.depth,descendantCount:ae?void 0:ne.get(ce)??0,isGroupRow:oe,isExpanded:S.has(ce)};oe&&(de.groupLabel=Z.label),J.set(ce,de)}),J},[p,b,T,S]);return s.useMemo(()=>({treeNodes:p,groupingRows:x,toggleExpansion:M,isGroupExpanded:L,getVisibleRows:_,getNode:A,getNodePath:X,rowMetaMap:z}),[p,x,M,L,_,A,X,z])}const ii=e=>e===null?"footer":"inline";function li(e,t){return io(()=>e(t),ii(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function ja(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?io(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Ua=[],qa={},si=new Map,We="";function Xa(e){if(typeof e=="string")return e;if(e===null)return`${We}null`;if(e===void 0)return`${We}undefined`;if(e instanceof Date)return`${We}date:${e.getTime()}`;if(typeof e=="object")try{return`${We}object:${JSON.stringify(e)}`}catch{return`${We}object:${String(e)}`}return`${We}${typeof e}:${String(e)}`}const Ya=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,Ra=e=>`${e}${We}footer`,Ja=e=>e==="footer"?"f":e===null?"n":"i",Qa=e=>e==="f"?"footer":e==="n"?null:"inline";function Za(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Ua,aggregationModel:i=qa,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:d,getAggregationPosition:u=ii,columnLookup:g,filterMode:m="client",sortingMode:w="client"}=e,v=r.join(We),p=s.useMemo(()=>v===""?[]:v.split(We),[v]),f=JSON.stringify(Object.entries(i)),x=s.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),b=Object.keys(x).length>0,h=s.useMemo(()=>{const V=new Map;return(n??[]).forEach(O=>V.set(O.field,O)),V},[n]),y=p.length>0,C=s.useMemo(()=>p.filter(V=>h.get(V)?.groupable!==!1),[p,h]),T=`${C.join(We)}|${l}`,[E,I]=s.useState(()=>({configKey:T,overrides:new Map})),F=E.configKey===T?E.overrides:si,G=s.useMemo(()=>{if(!y||m==="server")return null;const V=fo(c,g);return V?new Set(t.filter(O=>V(O))):null},[y,t,m,c,g]),j=s.useMemo(()=>{const V=new Map,O=[],$=[],Y=new Map,U=new Map,D=new Map;if(!y)return{treeNodes:V,rootIds:O,groupIds:$,groupRowVariants:Y,groupingRows:U,rowLookup:D};const W=(R,H,K)=>{if(H>=C.length)return(G?R.filter(te=>G.has(te)):R).map(te=>{const ue=o(te);return D.set(ue,te),V.set(ue,{id:ue,parentId:K,depth:H,groupingKey:"",isExpanded:!1}),ue});const B=C[H],Q=h.get(B),k=new Map;for(const re of R){const te=Fe(re,B,Q),ue=Xa(te);let ge=k.get(ue);ge||(ge={value:te,rows:[]},k.set(ue,ge)),ge.rows.push(re)}const q=[];return k.forEach((re,te)=>{const ue=G?re.rows.filter(ve=>G.has(ve)):re.rows;if(ue.length===0)return;const ge=Ya(B,te,K);q.push(ge),$.push(ge);const me=b?co(ue,x,h,"useRowGrouping"):{},Se={[B]:re.value,...me,id:ge},fe={[B]:re.value,id:ge},xe=b?{...me,id:Ra(ge)}:null;Y.set(ge,{inline:Se,bare:fe,footer:xe}),U.set(ge,Se),xe&&U.set(xe.id,xe);const be={id:ge,parentId:K,depth:H,groupingKey:String(re.value),groupingField:B,groupingValue:re.value,aggregatedValues:me,isExpanded:!1,children:[],label:ja(Q,B,re.value),descendantCount:ue.length};V.set(ge,be),be.children=W(re.rows,H+1,ge)}),q};return O.push(...W(t,0,null)),{treeNodes:V,rootIds:O,groupIds:$,groupRowVariants:Y,groupingRows:U,rowLookup:D}},[y,t,G,C,b,x,o,h]),{treeNodes:S,rootIds:M,groupIds:P,groupRowVariants:_,groupingRows:L,rowLookup:A}=j,X=s.useCallback(V=>!!(V?.children&&V.children.length>0)&&(l===-1||(V?.depth??0)<l),[l]),z=s.useMemo(()=>{const V=new Set;return S.forEach((O,$)=>{!O.children||O.children.length===0||(F.get($)??X(O))&&V.add($)}),V},[S,F,X]),J=s.useCallback(V=>{I(O=>{const $=O.configKey===T?O.overrides:si,Y=$.get(V)??X(S.get(V)),U=new Map($);return U.set(V,!Y),{configKey:T,overrides:U}})},[T,S,X]),ee=s.useCallback(V=>z.has(V),[z]),ne=b?P.map(V=>{const O=S.get(V);return O?Ja(li(u,{...O,isExpanded:z.has(V)})):"i"}).join(""):"",Z=s.useMemo(()=>{const V=new Map;return P.forEach((O,$)=>V.set(O,Qa(ne[$]))),V},[P,ne]),ce=b?li(u,null):"footer",ae=w!=="server"&&!!(d&&d.length>0),oe=s.useCallback(V=>{if(!y)return null;const O=V?.labelField,$=V?.expandAll??!1,Y=ae&&d?d:[],U=(H,K)=>{const B=S.get(H),Q=_.get(H);if(B&&Q){const ue=B.groupingField??"";if(K.field===ue||K.field===O){const ge=g?.byField.get(ue),me=ge?.sortComparator;return{value:B.groupingValue,type:ge?.type,comparator:me,params:me?{id:H,field:ue,row:Q.inline,value:B.groupingValue}:void 0}}return B.aggregatedValues&&Object.prototype.hasOwnProperty.call(B.aggregatedValues,K.field)?{value:B.aggregatedValues[K.field],type:g?.byField.get(K.field)?.type}:{value:void 0}}const k=A.get(H),q=g?.byField.get(K.field),re=k?Fe(k,K.field,q):void 0,te=q?.sortComparator;return{value:re,type:q?.type,comparator:te,params:te&&k?{id:H,field:K.field,row:k,value:re}:void 0}},D=[],W=new Set,R=H=>{const K=Y.length>0?on(H,Y,U):H;for(const B of K){if(W.has(B))continue;W.add(B);const Q=_.get(B);if(!Q){const ue=A.get(B);ue&&D.push(ue);continue}const k=S.get(B),q=z.has(B),re=Z.has(B)?Z.get(B)??null:"inline",te=re==="inline"||re==="footer"&&!q;D.push(te?Q.inline:Q.bare),(q||$)&&k?.children&&(R(k.children),q&&!$&&re==="footer"&&Q.footer&&D.push(Q.footer))}};return R(M),D},[y,ae,d,S,_,A,g,z,Z,M]),de=s.useCallback(V=>S.get(V),[S]),ie=s.useMemo(()=>{const V=new Map;return S.forEach((O,$)=>{const Y=_.get($);if(!Y){V.set($,{hasChildren:!1,treeDepth:O.depth,isGroupRow:!1});return}const U={hasChildren:!0,treeDepth:O.depth,groupingField:O.groupingField,groupingValue:O.groupingValue,groupLabel:O.label,descendantCount:O.descendantCount,isGroupRow:!0,isExpanded:z.has($)};V.set($,U),Y.footer&&Z.get($)==="footer"&&V.set(Y.footer.id,{...U,hasChildren:!1,treeDepth:O.depth+1,isExpanded:void 0,isGroupFooter:!0})}),V},[S,_,z,Z]);return s.useMemo(()=>({treeNodes:S,groupingRows:L,toggleExpansion:J,isGroupExpanded:ee,getVisibleRows:oe,getNode:de,rowMetaMap:ie,aggregationPositions:Z,rootAggregationPosition:ce}),[S,L,J,ee,oe,de,ie,Z,ce])}const ed=new Map;function td(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:w,getAggregationPosition:v,columnLookup:p,filterMode:f,sortingMode:x}=e,b=Ka({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:w,columnLookup:p,filterMode:f,sortingMode:x}),h=Za({rows:t,getRowId:o,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:w,getAggregationPosition:v,columnLookup:p,filterMode:f,sortingMode:x}),y=i?b:d?h:null,C=s.useMemo(()=>i?b.rowMetaMap:d?h.rowMetaMap:ed,[i,b.rowMetaMap,d,h.rowMetaMap]);return{treeDataHandlers:b,rowGroupingHandlers:h,activeHierarchyHandlers:y,rowMetaMap:C}}const yt=Promise.resolve();class ai extends Error{}function xo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function od(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function nd(e){const[t,o]=s.useState(null),n=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),c=s.useRef(!1),d=s.useRef(e);s.useLayoutEffect(()=>{d.current=e}),s.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=s.useCallback(p=>{n.current=p,o(p)},[]),g=s.useCallback((p,f)=>{const x=i.current.get(p);if(x)return xo(x.value,f.value)?x.promise:x.promise.then(()=>{const L=n.current;if(!(r.current!==p||!L||xo(L.value,x.value)))return g(p,L)});const b=()=>r.current===p&&n.current!==null;if(xo(f.value,f.originalValue))return b()&&u(null),yt;const{rows:h,getRowId:y,columns:C,processRowUpdate:N}=d.current,T=h.find(L=>y(L)===f.id);if(!T)return b()&&u(null),yt;const E=L=>{const A=d.current.onProcessRowUpdateError;A?A(L):process.env.NODE_ENV!=="production"&&L instanceof ai&&console.error(L.message)},I=L=>{if(typeof L!="object"||L===null){E(new ai(`[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!==p||!A||(xo(A.value,f.value)?u(null):u({...A,originalValue:f.value}))};let F,G;const j=new Promise((L,A)=>{F=L,G=A}),S={value:f.value,promise:j};i.current.set(p,S);const M=()=>{i.current.get(p)===S&&i.current.delete(p)};let P;try{const L=C?.find(X=>X.field===f.field),A=rd(T,f,L,l.current);P=N?N(A,T):A}catch(L){return M(),E(L),F(),j}const _=L=>{M();try{I(L),F()}catch(A){G(A)}};return od(P)?Promise.resolve(P).then(_,L=>{M(),E(L),F()}):_(P),j},[u]),m=s.useCallback(p=>{const f=n.current;if(f){if(f.id===p.id&&f.field===p.field)return;g(r.current,f)}r.current+=1,u({id:p.id,field:p.field,value:p.value,originalValue:p.value})},[g,u]),w=s.useCallback(p=>{const f=n.current;return!f||!c.current||p?.id!==void 0&&p.id!==f.id||p?.field!==void 0&&p.field!==f.field?yt:p?.cancel?(u(null),yt):g(r.current,f)},[g,u]),v=s.useCallback(p=>{const f=n.current;!f||f.id!==p.id||f.field!==p.field||u({...f,value:p.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:m,stopCellEdit:w,setEditCellValue:v}),[t,m,w,v])}function rd(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 id=e=>e.id,ld={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},di="\0",ci="";function ui(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 sd(e){return e.map(t=>t.field).join(di)}function ad(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:d,rowMetaMap:u,getRowId:g=id}=e,m=s.useMemo(()=>r.some(b=>b.colSpan!==void 0&&b.colSpan!==null),[r]),w=s.useMemo(()=>r.some(b=>b.rowSpan!==void 0&&b.rowSpan!==null),[r]),v=m||w,p=v?[i,l,c].map(sd).join(ci):"",f=s.useMemo(()=>{if(!p)return{columns:[],leftCount:0,unpinnedCount:0};const b=new Map(r.map(N=>[N.field,N])),h=p.split(ci).map(N=>N?N.split(di):[]),y=[];let C=0;for(const N of h){C+=N.length;for(const T of N){const E=b.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:h[0].length,unpinnedCount:h[1].length}},[p,r]),x=s.useMemo(()=>{if(!v||f.columns.length===0)return null;const b={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:b};return hn(t,0,!1,y),hn(o,t.length,!0,y),hn(n,t.length+o.length,!1,y),b},[v,f,t,o,n,d,u,g]);return s.useMemo(()=>{if(!x)return ld;const{colspanMap:b,rowSpanningCaches:h,hiddenOriginFields:y,unpinnedRanges:C,centerRowSpanStart:N}=x,T=f.columns;return{hasColSpan:m,hasRowSpan:w,colspanMap:b,rowSpanningCaches:h,getSpanOrigin:(E,I)=>{const F=b.get(E)?.[I];if(F?.spannedByColSpan)return{rowId:E,field:T[F.leftVisibleCellIndex].field};const G=h.hiddenCellOriginMap[E]?.[I];return G===void 0?null:{rowId:G,field:y.get(E)?.[I]??I}},getUnpinnedColSpanRanges:E=>C.get(E),getCenterRowSpanStart:E=>N.get(E)??E}},[x,m,w,f])}function hn(e,t,o,n){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:d,out:u}=n,{columns:g,leftCount:m,unpinnedCount:w}=r,v=g.length,{colspanMap:p,rowSpanningCaches:f,hiddenOriginFields:x,unpinnedRanges:b,centerRowSpanStart:h}=u,y=new Int32Array(v),C=new Array(v),N=new Array(v),T=new Int32Array(v);let E=0;const I=[];g.forEach((j,S)=>{(j.hasColSpan||j.hasRowSpan)&&I.push(S)});const F=(j,S,M)=>{const P=g[M].field;if(Ct(f.hiddenCells,j,P,!0),Ct(f.hiddenCellOriginMap,j,P,C[M]),N[M]!==P&&Ct(x,j,P,N[M]),o){const _=h.get(S);(_===void 0||T[M]<_)&&h.set(S,T[M])}},G=(j,S,M)=>{const P=g[M],_=c(j),L=dd(j,_,P.colDef,t+S,M,l,d);let A=1;if(P.hasColSpan){const z=Math.min(fi(P.colDef.colSpan,L,"colSpan",P.field,d),P.sectionEnd-M);for(;A<z&&y[M+A]<=S;)A++}let X=1;if(P.hasRowSpan){X=Math.min(fi(P.colDef.rowSpan,L,"rowSpan",P.field,d),e.length-S);for(let z=1;z<X;z++)if(Xe(c(e[S+z]),l)){X=z;break}if(X>1&&i&&i.size>0){for(let z=0;z<X-1;z++)if(i.has(c(e[S+z]))){X=z+1;break}}}if(A>1){Ct(p,_,P.field,{spannedByColSpan:!1,cellProps:{colSpan:A}});for(let z=1;z<A;z++){const J=g[M+z];Ct(p,_,J.field,{spannedByColSpan:!0,leftVisibleCellIndex:M,rightVisibleCellIndex:M+A-1})}if(M>=m&&M<m+w){let z=b.get(_);z||(z=[],b.set(_,z)),z.push(M-m,M+A-1-m)}}if(X>1){Ct(f.spannedCells,_,P.field,X);for(let z=M;z<M+A;z++)y[z]=S+X,C[z]=_,N[z]=P.field,T[z]=S;S+X>E&&(E=S+X)}return A};for(let j=0;j<e.length;j++){const S=e[j];if(!S||S._isSkeleton||Xe(c(S),l))continue;if(E<=j){let P=0;for(const _ of I)_>=P&&(P=_+G(S,j,_));continue}let M=0;for(;M<v;)y[M]>j?(F(c(S),j,M),M++):g[M].hasColSpan||g[M].hasRowSpan?M+=G(S,j,M):M++}}function dd(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){gi(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 fi(e,t,o,n,r){if(typeof e=="number")return ui(e);if(typeof e!="function")return 1;try{return ui(e(t))}catch(i){return gi(r,`${o}:${n}`,`${o} for column "${n}" threw; the cell is rendered without a span`,i),1}}function gi(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 cd(e){const{spanning:t,renderContext:o,offsetTop:n,cumulativeHeights:r}=e;return s.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 ud(e){const{spanning:t,firstColumnIndex:o,lastColumnIndex:n,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=o,d=n,u=!0;for(;u;){u=!1;for(const{row:b,id:h}of l){const y=t.getUnpinnedColSpanRanges(h??b.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:w,unpinnedAccWidths:v,unpinnedTotalWidth:p}=i,f=c>0?v[c-1]:0,x=p-v[d];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...m.slice(c,d+1),...x>0?[{field:"__spacer_right__",width:x,isSpacer:!0}]:[],...w]},[t,o,n,r,i,l])}function fd(e,t){const{draggedColumn:o,onDragOver:n,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const c=d=>o===null||pn(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 gd=300,pi=e=>e.id;function pd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function hi(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 mi(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 hd(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:d,rowGroupingActive:u=!1}=e,g=pd(i,u),m=!!t&&i==="server"&&u,w=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||!m||(w.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,p=Kr({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),f=JSON.stringify([g,g!=="all"||l==="server"?o:null,g!=="all"||c==="server"?n:null,p?d??null:null,g==="all"?null:r.pageSize]),x=g==="all"?0:r.page,b=g==="all"?0:r.pageSize,h=s.useRef({params:e,kind:g});s.useLayoutEffect(()=>{h.current={params:e,kind:g}});const y=s.useRef(0),C=s.useRef(0),N=s.useRef(null),T=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),E=s.useRef(null),I=s.useRef(!1),F=s.useRef(0),G=s.useRef(!1),j=s.useRef(new Set),S=s.useCallback(()=>{const J=I.current||F.current>0;J!==G.current&&(G.current=J,h.current.params.setDataSourceLoading(J))},[]),M=s.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),P=s.useCallback(()=>{y.current++,T.current.inFlightEnd=null,I.current=!1},[]),_=s.useCallback(()=>{C.current++,j.current.clear(),F.current=0},[]),L=s.useCallback(async()=>{const{params:J,kind:ee}=h.current,ne=J.dataSource;if(!ne)return!1;const Z=T.current,ce=J.paginationModel.pageSize;let ae,oe;if(ee==="infinite"){if(Z.inFlightEnd!==null)return!1;if(ae=Z.loadedEnd,oe=(Z.page+1)*ce,oe<=ae)return I.current=!1,S(),!1;Z.inFlightEnd=oe}else ee==="page"?(ae=J.paginationModel.page*ce,oe=ae+ce):(ae=0,oe=jr);const de=++y.current;I.current=!0,S(),J.setDataSourceError(null);let ie;try{ie=await ne.getRows({startRow:ae,endRow:oe,sortModel:J.sortModel,filterModel:J.filterModel,groupKeys:[],aggregationModel:J.aggregationModel})}catch(V){return de!==y.current||(Z.inFlightEnd=null,I.current=!1,h.current.params.setDataSourceError(V),console.error("Data Source Error:",V),S()),!1}if(de!==y.current)return!1;try{const{params:V}=h.current,O=V.getRowId??pi,$=hi(ie.rows,O);if(ee==="infinite"&&ae>0?V.setRows(Y=>mi(Y,$,O),!0):(V.setRows($.map(Y=>Y.row),!0),_()),ie.aggregationResults&&V.onAggregationResults?.(ie.aggregationResults),ie.rowCount!==void 0&&V.setRowCount(ie.rowCount),ee==="infinite"&&(Z.inFlightEnd=null,Z.loadedEnd=ae+ie.rows.length,ie.rows.length>=oe-ae&&(Z.page+1)*ce>oe))return!0}catch(V){return Z.inFlightEnd=null,I.current=!1,h.current.params.setDataSourceError(V),console.error("Data Source Error:",V),S(),!1}return I.current=!1,S(),!1},[S,_]),A=s.useCallback(async()=>{for(;await L(););},[L]);s.useLayoutEffect(()=>{if(!v){N.current&&(N.current=null,M(),P(),_(),h.current.params.setDataSourceError(null),S());return}const J=N.current,ee=T.current;if(!J||J.key!==f||J.getRows!==v){N.current={key:f,getRows:v},P(),_();const ne=g==="infinite"&&J!==null&&x!==0;if(ee.page=ne?0:x,ee.loadedEnd=0,ne){const{params:Z}=h.current;Z.onPaginationModelChange?.({...Z.paginationModel,page:0})}}else g==="infinite"?(x<ee.page&&(P(),ee.loadedEnd=0),ee.page=x):P();if(g==="infinite"){const ne=ee.inFlightEnd!==null;if(ne||(ee.page+1)*b<=ee.loadedEnd){I.current=ne,S();return}}return I.current=!0,S(),E.current=setTimeout(()=>{E.current=null,A()},gd),M},[v,f,g,x,b,M,P,_,S,A]),s.useEffect(()=>()=>{P(),_()},[P,_]);const X=s.useCallback(()=>(M(),A()),[M,A]),z=s.useCallback(async(J,ee,ne)=>{const{params:Z}=h.current,ce=Z.dataSource;if(!ce)return;const ae=JSON.stringify(ee),oe=j.current;if(oe.has(ae))return;const de=C.current;oe.add(ae),F.current++,S();try{const ie=await ce.getRows({startRow:0,endRow:jr,sortModel:Z.sortModel,filterModel:Z.filterModel,groupKeys:ee,aggregationModel:Z.aggregationModel});if(de!==C.current)return;if(ie.rows.length>0){const{params:V}=h.current,O=V.getRowId??pi,$=hi(ie.rows,O);V.setRows(Y=>mi(Y,$,O),!0)}}catch(ie){if(de!==C.current)return;oe.delete(ae),console.error("Failed to fetch children:",ie),ne?.(ie)}finally{de===C.current&&(F.current--,S())}},[S]);return{fetchRows:X,fetchChildren:z}}function md(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function wd({enabled:e,treeNodes:t,isGroupExpanded:o,getNodePath:n,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:o,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:o,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((c,d)=>{!md(c)||!o(d)||i(d,n(d),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(d)&&g(d)})})},[e,t,o,n,i])}const wi={};function xd(e){const t=JSON.stringify(e),[o,n]=s.useState(null),r=s.useCallback(i=>n({modelKey:t,results:i}),[t]);return[o&&o.modelKey===t?o.results:null,r]}function xi(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=s.useMemo(()=>{const N=new Map;return(o??[]).forEach(T=>N.set(T.field,T)),N},[o]),m=s.useMemo(()=>r||!u?wi:co(t,n,g,"useAggregation"),[t,g,n,r,u]),w=JSON.stringify([n,l??null,c??[]]),v=r&&u&&!!i?.getAggregations&&!d,p=s.useRef({aggregationModel:n,filterModel:l,sortModel:c});s.useEffect(()=>{p.current={aggregationModel:n,filterModel:l,sortModel:c}});const[f,x]=s.useState(null);s.useEffect(()=>{const N=i?.getAggregations;if(!v||!N)return;let T=!1;const E=p.current;let I;try{I=Promise.resolve(N({sortModel:E.sortModel??[],filterModel:E.filterModel??{items:[]},groupKeys:[],aggregationModel:E.aggregationModel}))}catch(F){I=Promise.reject(F)}return I.then(F=>{T||x({key:w,result:F,error:null})},F=>{T||(console.error("[useAggregation] Server aggregation error:",F),x({key:w,result:null,error:F}))}),()=>{T=!0}},[v,i,w]);const b=f&&f.key===w?f:null,h=v&&b===null,y=v?b?.error??null:null;return{aggregationResult:s.useMemo(()=>r?d&&Object.keys(d).length>0?d:b?.result??wi:m,[r,m,d,b]),isLoading:h,error:y}}const bd={items:[]},vd=[];function yd(e){const{rows:t,columns:o,pivotMode:n,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:d}=e,u=n&&!c,g=s.useMemo(()=>new Set(o.map(b=>b.field)),[o]),m=s.useMemo(()=>nn(o),[o]),w=s.useMemo(()=>as(i,g),[i,g]),v=s.useMemo(()=>u?Qo(t,w.source,m):t,[u,t,w.source,m]),p=s.useMemo(()=>u?Cr(v,o,r,{outputFilterModel:w.output,sortModel:l}):ln,[u,v,o,r,w.output,l]),f=u&&p.isValid,x=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&c&&!x.current.dataSource&&(x.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&&!x.current.hierarchy&&(x.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?p.pivotRows:t,columns:f?p.pivotColumns:o,pipelineFilterModel:f?bd:i,pipelineSortModel:f?vd:l}}const zt=({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 a.jsx("button",{type:i,className:d,disabled:n,...c,children:l})};function mn(e){const t=s.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=po(n),w=an(r,m),v=Tr(o,w),p=c.includes(m)?c:[...c,m].sort((S,M)=>S-M),f=v*m,x=Math.min(f+m,r),b=r===0?0:`${f+1}–${x}`,h=g?.paginationRowsPerPage??"Rows per page:",y=g?.paginationOf?g.paginationOf(r===0?0:f+1,x,r):`${b} of ${r}`,C=g?.paginationPage?g.paginationPage(v+1,w):`Page ${v+1} of ${w}`,N=()=>{i(0)},T=()=>{i(Math.max(0,v-1))},E=()=>{i(Math.min(w-1,v+1))},I=()=>{i(w-1)},F=S=>{const M=parseInt(S.target.value,10);l(M)},G=v===0,j=v>=w-1;return a.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[a.jsxs("div",{className:"ogx-pagination__page-size",children:[a.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:h}),a.jsx("select",{id:t,className:"ogx-pagination__select",value:m,onChange:F,children:p.map(S=>a.jsx("option",{value:S,children:S},S))})]}),a.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),a.jsxs("div",{className:"ogx-pagination__actions",children:[d&&a.jsx(zt,{variant:"text",size:"small",onClick:N,disabled:G,"aria-label":"Go to first page",title:"First page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),a.jsx(zt,{variant:"text",size:"small",onClick:T,disabled:G,"aria-label":"Go to previous page",title:"Previous page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),a.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:C}),a.jsx(zt,{variant:"text",size:"small",onClick:E,disabled:j,"aria-label":"Go to next page",title:"Next page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&a.jsx(zt,{variant:"text",size:"small",onClick:I,disabled:j,"aria-label":"Go to last page",title:"Last page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Cd({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:w,tabIndex:v=-1,onFocus:p,onToggleExpansion:f}){const x=t??e.id,b=r.field,h=Fe(e,b,i),y=zo(e,b,h,i)??Vo(h,i),C=l?.isGroupRow===!0||Xe(x),N={row:e,value:h,formattedValue:y,field:b,colDef:i??r,rowIndex:o,colIndex:0,rowMeta:l},T=E=>{E.stopPropagation(),w?.(x,E.target.checked)};return a.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:p?E=>{E.target===E.currentTarget&&p(o)}:void 0,children:[d&&a.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!C&&a.jsx("input",{type:"checkbox",checked:c,onChange:T,"aria-label":`Select row ${x}`,tabIndex:-1})}),l&&f&&a.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&a.jsx(un,{isExpanded:l.isExpanded===!0,onClick:()=>f(x),tabIndex:-1})}),a.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:a.jsx(lt,{field:b,resetKey:e,renderFn:()=>{const E=r.renderCell(N);return E===void 0&&C?l?.groupLabel:E}})})]})}function _d(e,t){const o=s.useRef(!0),n=s.useRef(e);s.useEffect(()=>{n.current=e},[e]),s.useEffect(()=>{o.current=!0},[t]);const r=s.useCallback(i=>{const l=Dr(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 Sd=e=>e.id;function kd({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:w,rowMetaMap:v,noRowsLabel:p,rowHeight:f,checkboxSelection:x,paginationMode:b,serverRowCount:h,paginationSlot:y,paginationSlotProps:C,localeText:N,onRowClick:T,onRowDoubleClick:E,onSelectionChange:I,onPaginationModelChange:F,onRowsScrollEnd:G,getRowId:j=Sd,multiselectable:S=!1,loading:M=!1,loadingOverlay:P,noRowsOverlay:_,showPaginationControls:L=!0,selectable:A=!1,onToggleExpansion:X}){const z=y||mn,J=s.useRef(null),[ee,ne]=s.useState(null),Z=ee===null?-1:t.findIndex(R=>j(R)===ee),ce=Z===-1?0:Z,ae=R=>{const H=t[R];H&&(ne(j(H)),J.current?.querySelector(`:scope > [role="row"][data-rowindex="${R}"]`)?.focus())},oe=R=>{const H=R.target;if(H.getAttribute("role")!=="row"||H.parentElement!==J.current)return;const K=Number(H.getAttribute("data-rowindex")),B=t[K];if(!B)return;const Q=j(B),k=t.length-1,q=v.get(Q),re=!!(q?.hasChildren&&X);if(R.altKey&&(R.key==="ArrowRight"||R.key==="ArrowLeft")){R.preventDefault(),re&&R.key==="ArrowRight"!=(q?.isExpanded===!0)&&X?.(Q);return}switch(R.key){case"ArrowDown":R.preventDefault(),ae(Math.min(K+1,k));return;case"ArrowUp":R.preventDefault(),ae(Math.max(K-1,0));return;case"Home":R.preventDefault(),ae(0);return;case"End":R.preventDefault(),ae(k);return;case"PageDown":R.preventDefault(),ae(Math.min(K+10,k));return;case"PageUp":R.preventDefault(),ae(Math.max(K-10,0));return;case"Enter":case" ":if(R.preventDefault(),R.key===" "&&R.shiftKey){A&&!q?.isGroupRow&&I(Q,!g.has(Q));return}re?X?.(Q):T({row:B,id:Q,rowIndex:K});return}},de=b==="server",ie=de?h||0:i,V=de?h||0:o,O=po(c.pageSize),$=an(ie,O),Y=l?d*O:0,U=t.length-n-r,D=R=>{if(R<n)return R+1;const H=R-n;return H<U?n+Y+H+1:n+ie+(H-U)+1},W=_d(G,t.length);return a.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":V,"aria-multiselectable":S,children:[a.jsx("div",{className:"ogx-list-view__toolbar",children:a.jsxs("span",{children:[V," ",V===1?"item":"items",l?` · page ${d+1} of ${$}`:"",g.size>0?` · ${g.size} selected`:""]})}),a.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:W,onKeyDown:oe,ref:J,children:t.length===0&&M?a.jsx("div",{className:"ogx-list-view__loading",children:P??a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&_?a.jsx("div",{className:"ogx-list-view__empty",children:_}):t.length===0?a.jsxs("div",{className:"ogx-list-view__empty",children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),p]}):t.map((R,H)=>{const K=j(R);return a.jsx(Cd,{row:R,rowId:K,rowIndex:H,ariaRowIndex:D(H),listViewColumn:m,gridColumn:w.get(m.field),rowMeta:v.get(K),isSelected:g.has(K),checkboxSelection:x,rowHeight:f,onRowClick:B=>T({row:B,id:K,rowIndex:H}),onRowDoubleClick:E?B=>E({row:B,id:K,rowIndex:H}):void 0,onSelectionChange:I,tabIndex:H===ce?0:-1,onToggleExpansion:X,onFocus:B=>ne(j(t[B]))},K)})}),l&&L&&a.jsx(z,{page:d,pageSize:c.pageSize,rowCount:ie,pageSizeOptions:u,onPageChange:R=>F({...c,page:R}),onPageSizeChange:R=>F({...c,pageSize:R,page:0}),localeText:N,...C})]})}function Ed({overlay:e}){return e?a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function Vt(e){return e.headerName||e.field}function Md(e){return e.nativeEvent.isComposing||e.keyCode===229}function Kt(e,t,o=!0){return n=>{if(Md(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function Nd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=s.useState(String(e??"")),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),a.jsx("input",{ref:c,type:"text",className:"ogx__edit-input","aria-label":Vt(t),value:i,onChange:d=>{l(d.target.value),o(d.target.value)},onBlur:n,onKeyDown:Kt(n,r)})}function Pd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),a.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":Vt(t),value:i,onChange:d=>{const u=d.target.value===""?"":Number(d.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Kt(n,r)})}function Id({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{o(!e),n()};return a.jsx("div",{className:"ogx__edit-boolean",children:a.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":Vt(t),checked:!!e,onChange:l,onBlur:n,onKeyDown:Kt(n,r,!1)})})}const wn=e=>typeof e=="object"?e.value:e,Td=e=>typeof e=="object"?e.label:String(e);function Ld(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Fd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(g=>String(wn(g)));let d=l.findIndex(g=>Ld(wn(g),e));d===-1&&e!==null&&e!==void 0&&(d=c.indexOf(String(e)));const u=d===-1;return a.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Vt(t),value:u?"":c[d],onChange:g=>{const m=c.indexOf(g.target.value);o(m===-1?null:wn(l[m]))},onBlur:n,onKeyDown:Kt(n,r),children:[u&&a.jsx("option",{value:""}),l.map((g,m)=>a.jsx("option",{value:c[m],children:Td(g)},m))]})}const bi=e=>String(e).padStart(2,"0"),vi=/^(\d{4}-\d{2}-\d{2})/;function xn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${bi(e.getMonth()+1)}-${bi(e.getDate())}`;if(typeof e=="string"){const t=vi.exec(e);return t?t[1]:e===""?"":xn(new Date(e))}return typeof e=="number"?xn(new Date(e)):""}function Od(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"&&vi.test(t)&&t.length>10?e+t.slice(10):e}function Ad({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=s.useState(e),[l,c]=s.useState(()=>xn(e)),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus()},[]),a.jsx("input",{ref:d,type:"date",className:"ogx__edit-input","aria-label":Vt(t),value:l,onChange:u=>{c(u.target.value),o(Od(u.target.value,i))},onBlur:n,onKeyDown:Kt(n,r)})}function Dd(e){const{colDef:t}=e;switch(t.type){case"number":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Pd,{...e})});case"boolean":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Id,{...e})});case"singleSelect":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Fd,{...e})});case"date":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Ad,{...e})});default:return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Nd,{...e})})}}function $d(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:w,pinnedPosition:v,pinnedOffset:p,isPinnedEdge:f,isFocused:x,isFocusVisible:b,isEditable:h,isEditing:y,onEditStart:C,onEditStop:N,onValueChange:T,colSpanInfo:E,rowSpan:I,isHiddenByRowSpan:F,rowMeta:G,valueError:j}=e,S=s.useCallback(D=>{n?n(l.field,D):T?.(D)},[n,T,l.field]),M=G?.isGroupRow===!0,{formattedValue:P,error:_}=s.useMemo(()=>{if(l.valueFormatter&&!(M&&r==null))try{return{formattedValue:l.valueFormatter({value:r,row:i,field:l.field})}}catch(D){return{formattedValue:"",error:D??new Error("valueFormatter failed")}}return{formattedValue:Vo(r,l)}},[r,i,l,M]),L=s.useMemo(()=>{if(!l.cellClassName)return"";if(typeof l.cellClassName=="function")try{return l.cellClassName({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:G})||""}catch{return""}return l.cellClassName},[l,r,P,i,c,d,G]),A=j??_,X=l.field,z=s.useCallback(()=>{N?.(!1,X)},[N,X]),J=s.useCallback(()=>{N?.(!0,X)},[N,X]),ee=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),ne=s.useRef(!1);if(s.useEffect(()=>{if(!(!y||!N))return ne.current=!0,()=>{ne.current=!1,queueMicrotask(()=>{ne.current||N(!1,X)})}},[y,N,X]),E?.spannedByColSpan)return null;const Z=E?.cellProps.colSpan??1,ce=Z>1,ae=(ce?E?.cellProps.width:void 0)??w??l.width??100,oe={width:"var(--width)","--width":typeof ae=="number"?`${ae}px`:ae,flexGrow:(ce?E?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:ce?void 0:l.minWidth,maxWidth:ce?void 0:l.maxWidth};if(F)return a.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:oe,role:"presentation","data-field":l.field,"data-colindex":d});const de=D=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:d}),m?.(D))},ie=()=>{y||!h||(o?o(l.field,r):C?.())},V=l.renderEditCell,O=v!=null,$=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",x&&"ogx__cell--focused",x&&b&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,O&&"ogx__cell--pinned",O&&`ogx__cell--pinned-${v}`,O&&f&&`ogx__cell--pinned-${v}-${v==="left"?"last":"first"}`,y&&"ogx__cell--editing",I&&I>1&&"ogx__cell--spanned",L].filter(Boolean).join(" "),Y=I||1,U={...oe,position:O?"sticky":void 0,zIndex:l.zIndex??(O?3:void 0),padding:y?0:void 0};return Y>1&&(U.height=`calc(var(--height) * ${Y} - var(--border-width, 1px))`,U.zIndex=10,O&&(U.zIndex=40)),O&&p!==void 0&&(v==="left"?U.left=p:U.right=p),a.jsx("div",{className:$,style:U,onClick:de,onDoubleClick:ie,role:"gridcell","aria-colindex":u??d+1,"aria-readonly":!h||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":d,...Z>1?{"aria-colspan":Z}:{},...Y>1?{"aria-rowspan":Y}:{},children:a.jsx("div",{className:"ogx__cell-content",children:y&&(n||T)&&N?V?a.jsx(lt,{field:l.field,resetKey:i,renderFn:()=>V({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:G,onValueChange:S,onCommit:z,onCancel:J})}):a.jsx(Dd,{value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:G,onValueChange:S,onCommit:z,onCancel:J}):A!==void 0?a.jsx(lt,{field:l.field,resetKey:i,renderFn:()=>{throw A}}):l.renderCell?a.jsx(lt,{field:l.field,resetKey:ee,renderFn:()=>l.renderCell({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:G})}):l.type==="image"&&typeof r=="string"&&r!==""?a.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):P})})}const yi=s.memo($d),Gd=({className:e="",...t})=>a.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:a.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function Wd(e){const{rowId:t,content:o,height:n,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,d=s.useRef(null),u=n==="auto";if(s.useLayoutEffect(()=>{const m=d.current;if(!m||!u||!r||!i)return;const w=()=>{m.getClientRects().length!==0&&i(t,m.offsetHeight)};if(w(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(w);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 a.jsx("div",{ref:d,className:"ogx__detail-panel",style:g,role:"row",id:l,children:a.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:o})})}const bn=12;function Hd(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+=nt(d,n),i+=d.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function bo(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:w,pinnedRows:v,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:x,detailPanelContent:b,detailPanelHeight:h=Ko,onDetailPanelHeightChange:y,pinCheckboxColumn:C=!0,pinExpandColumn:N=!0,rowReordering:T=!1,onDragStart:E,onDragOver:I,onDragEnd:F,onDrop:G,isDragging:j,isDragOver:S,editingCell:M,onEditStart:P,onEditStop:_,onEditCellValueChange:L,isCellEditable:A,focusedCellField:X,isFocusVisible:z,colspanMap:J,rowSpanningCaches:ee,rowHeight:ne=52,rowMeta:Z,columnIndexMap:ce,ariaRowIndex:ae}=e,oe=o??t.id,de=s.useId(),ie=s.useId(),V=s.useMemo(()=>Ho(n,m,w,l,C,p,N,T),[n,m,w,l,C,p,N,T]),O=s.useMemo(()=>Bo(n,w),[n,w]),$=Z?.hasChildren===!0,Y=Z?.isGroupRow===!0,U=p&&!Y,D=!Y&&!Xe(oe),W=s.useCallback((se,ye)=>{P?.({id:oe,field:se,value:ye})},[oe,P]),R=s.useCallback((se,ye)=>{L?.({id:oe,field:se,value:ye})},[L,oe]),H=s.useCallback((se,ye)=>{_?.({cancel:se,id:oe,field:ye})},[_,oe]);if(t._isSkeleton){const se=Math.max(n.length,5);return a.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ne,minHeight:ne},children:Array.from({length:se}).map((ye,Te)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-bar"})},Te))})}const K=se=>{se.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:oe,rowIndex:r})},B=se=>{se.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:oe,rowIndex:r})},Q=se=>{se.stopPropagation(),g?.(oe,se.target.checked)},k=se=>{se.stopPropagation(),x?.(oe)},q=T?1:0,re=p?q+1:q,te=l?re+1:re,ue=te,ge=ce?.size??n.filter(se=>!se.isSpacer).length,me=Z!==void 0,Se=Z?.hasChildren===!0,fe=Un(oe,v),xe=fe==="top",be=fe==="bottom",ve=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",xe&&"ogx__row--pinned-top",be&&"ogx__row--pinned-bottom",j&&"ogx__row--dragging",S&&"ogx__row--drag-over",$&&"ogx__row--group",Z?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ve,onClick:K,onDoubleClick:d?B:void 0,role:"row","aria-rowindex":ae??r+2,"aria-selected":i,"aria-level":me?(Z?.treeDepth??0)+1:void 0,"aria-expanded":Se?Z?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:I?I(oe):void 0,onDrop:G?G(oe):void 0,style:{maxHeight:`${ne}px`,minHeight:`${ne}px`,"--height":`${ne}px`,"--border-width":"1px"},children:[T&&a.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${X==="__reorder_col__"?"ogx__cell--focused":""} ${X==="__reorder_col__"&&z?"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:bn},draggable:!!E,onDragStart:E?E(oe):void 0,onDragEnd:F,onClick:se=>se.stopPropagation(),children:E&&a.jsx(Gd,{})}),p&&a.jsx("div",{className:`ogx__cell ogx__cell--expand ${N?"ogx__cell--pinned-left":""} ${X==="__expand_col__"?"ogx__cell--focused":""} ${X==="__expand_col__"&&z?"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?ie:void 0,"aria-colindex":re,"data-field":"__expand_col__",style:{position:N?"sticky":void 0,left:N?T?48:0:void 0,zIndex:N?bn:void 0},tabIndex:-1,onClick:se=>{se.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:U&&a.jsx(un,{isExpanded:f,onClick:k,variant:"plus-minus",tabIndex:-1})}),l&&a.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${C?"ogx__cell--pinned-left":""} ${X==="__checkbox_col__"?"ogx__cell--focused":""} ${X==="__checkbox_col__"&&z?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":te,"data-field":"__checkbox_col__",style:{position:C?"sticky":void 0,left:C?(T?48:0)+(p&&N?48:0):void 0,zIndex:C?bn:void 0},tabIndex:-1,onClick:se=>{se.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:D&&a.jsx(Bt,{id:de,name:`ogx-select-row-${oe}`,checked:i,onChange:Q,onClick:se=>se.stopPropagation(),"aria-label":i?`Deselect row ${oe}`:`Select row ${oe}`,tabIndex:-1,onMouseDown:se=>se.preventDefault()})}),n.map((se,ye)=>{if(se.isSpacer)return a.jsx("div",{style:{width:se.width,minWidth:se.width,flexShrink:0},"aria-hidden":"true"},se.field);let Te,Ce;Y?Te=t[se.field]:{value:Te,error:Ce}=Xn(t,se.field,se);const ke=ce?.get(se.field)??ye,le=m[se.field]??se.width,pe=qe(se.field,w),we=!!P&&Zn({row:t,field:se.field,value:Te,colDef:se,rowIndex:r,colIndex:ke,rowMeta:Z},A),Ne=M?.id===oe&&M?.field===se.field,Qe=Ne?M?.value:Te,_e=J?.get(oe)?.[se.field],Ze=_e&&!_e.spannedByColSpan&&_e.cellProps.colSpan>1?Hd(n,ke,_e.cellProps.colSpan,m):_e,Jt=Ze&&!Ze.spannedByColSpan?n[ke+Ze.cellProps.colSpan-1]?.field??se.field:se.field,ko=pe==="right"?Jt:se.field,De=pe?V[ko]:void 0,Eo=pe==="left"&&Jt===O.lastLeft||pe==="right"&&se.field===O.firstRight,He=ee?.spannedCells[oe]?.[se.field],Mo=ee?.hiddenCells[oe]?.[se.field]||!1;return a.jsx(yi,{value:Qe,row:t,colDef:se,rowIndex:r,colIndex:ke,ariaColIndex:ue+ke+1,isSelected:i,onCellClick:u,width:le,pinnedPosition:pe,pinnedOffset:De,isPinnedEdge:Eo,isFocused:X===se.field,isFocusVisible:z,isEditable:we,isEditing:Ne,onCellEditStart:W,onEditStop:H,onCellValueChange:R,colSpanInfo:Ze,rowSpan:He,isHiddenByRowSpan:Mo,rowMeta:Z,valueError:Ce},se.field)})]}),U&&a.jsx(Wd,{id:ie,colSpan:ue+ge,row:t,rowId:oe,rowIndex:r,content:b,height:h,isExpanded:f,onHeightChange:y})]})}function Ci({getContent:e,params:t}){return a.jsx(lt,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Bd=e=>e.id;function _i({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:w,expandedRowIds:v,getDetailPanelContent:p,getDetailPanelHeight:f,onDetailPanelToggle:x,onDetailPanelHeightChange:b,pinCheckboxColumn:h,pinExpandColumn:y,focusedCell:C,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMetaMap:I,getRowId:F=Bd,rowIndexOffset:G=0,ariaRowIndexBase:j,columnIndexMap:S,editingHandlers:M,isCellEditable:P,rowReordering:_=!1}){return e.length===0?null:a.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((L,A)=>{const X=F(L),z=G+A;return a.jsx(bo,{row:L,rowId:X,columns:o,rowIndex:z,ariaRowIndex:j!==void 0?j+A:void 0,columnIndexMap:S,isSelected:n.has(X),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:w,isDetailPanelExpanded:v.has(X),detailPanelContent:v.has(X)&&p?a.jsx(Ci,{getContent:p,params:{row:L,id:X,rowIndex:z}}):null,detailPanelHeight:v.has(X)?jo(Uo(f,{row:L,id:X,rowIndex:z})):void 0,onDetailPanelHeightChange:b,onDetailPanelToggle:x,pinCheckboxColumn:h,pinExpandColumn:y,focusedCellField:C?.id===X?C.field:null,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMeta:I.get(X),editingCell:M?.editingCell,onEditStart:M?.startCellEdit,onEditStop:M?.stopCellEdit,onEditCellValueChange:M?.setEditCellValue,isCellEditable:P,rowReordering:_},X)})})}const zd=({columns:e,rowHeight:t,checkboxSelection:o=!1,hasDetailPanel:n=!1,rowReordering:r=!1})=>a.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[o&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,d=Math.min(c*.7,c-20);return a.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&&a.jsx("div",{className:"ogx-skeleton-box",style:{width:d,height:16,borderRadius:4}})},i.field||l)})]});function Vd({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:w,onRowDoubleClick:v,onCellClick:p,onSelectionChange:f,columnWidths:x,pinnedColumns:b,expandedRowIds:h,getDetailPanelContent:y,getDetailPanelHeight:C,onDetailPanelToggle:N,onDetailPanelHeightChange:T,pinCheckboxColumn:E,pinExpandColumn:I,rowReorderHandlers:F,editingHandlers:G,isCellEditable:j,focusedCell:S,colspanMap:M,rowSpanningCaches:P,paginationMode:_,dataSourceLoading:L,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:X,unpinnedRowsLength:z,lastRenderedRowIndex:J,rowMetaMap:ee,loadingOverlay:ne,ariaRowIndexOffset:Z,columnIndexMap:ce}){const ae=r.length>0?r:(()=>{const ie=(l||1e3)-(c?48:0)-(d?48:0)-(u?48:0),V=150,O=Math.max(1,Math.ceil(ie/V));return Array.from({length:O},($,Y)=>({field:`placeholder_${Y}`,headerName:"",width:V}))})(),oe=n.filter(ie=>!ie.pinned),de=_==="infinite"&&L&&A>0&&J>=z-1;return a.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:a.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[o&&n.length===0&&ne?a.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ne}):o&&n.length===0?Array.from({length:10}).map((ie,V)=>a.jsx(zd,{columns:ae,rowHeight:g,checkboxSelection:c,hasDetailPanel:d,rowReordering:u},`skeleton-${V}`)):oe.map(({row:ie,id:V,rowIndex:O})=>a.jsx(bo,{row:ie,rowId:V,columns:i,rowIndex:O,ariaRowIndex:Z!==void 0?O+Z:void 0,columnIndexMap:ce,isSelected:m.has(V),checkboxSelection:c,onRowClick:w,onRowDoubleClick:v,onCellClick:p,onSelectionChange:f,columnWidths:x,pinnedColumns:b,hasDetailPanel:d,isDetailPanelExpanded:h.has(V),detailPanelContent:h.has(V)&&y?a.jsx(Ci,{getContent:y,params:{row:ie,id:V,rowIndex:O}}):null,detailPanelHeight:h.has(V)?jo(Uo(C,{row:ie,id:V,rowIndex:O})):void 0,onDetailPanelHeightChange:T,onDetailPanelToggle:N,pinCheckboxColumn:E,pinExpandColumn:I,rowReordering:u,onDragStart:F.canReorderRow(V)?F.onDragStart:void 0,onDragOver:F.onDragOver,onDragEnd:F.onDragEnd,onDrop:F.onDrop,isDragging:F.draggedRowId===V,isDragOver:F.dragOverRowId===V,editingCell:G.editingCell,onEditStart:G.startCellEdit,onEditStop:G.stopCellEdit,onEditCellValueChange:G.setEditCellValue,isCellEditable:j,focusedCellField:S!=null&&S.id===V?S.field:null,colspanMap:M,rowSpanningCaches:P,rowHeight:g,rowMeta:ee.get(V)},V)),de&&a.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:X}).map((ie,V)=>a.jsx(bo,{row:{id:`__skeleton_${V}__`,_isSkeleton:!0},columns:i,rowIndex:z+V,rowHeight:g},`__skeleton_${V}__`))})]})})}function Kd(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function jd(){return a.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[a.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function vn(e){const{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:d}=e,[u,g]=s.useState(""),m=s.useId(),[w,v]=s.useState(null),p=s.useRef(null),f=s.useMemo(()=>t.filter(I=>I.hideable!==!1),[t]),x=f.every(I=>o.has(I.field)),b=s.useMemo(()=>{const I=d?t:f;if(!u)return I;const F=u.toLowerCase();return I.filter(G=>(G.headerName||G.field).toLowerCase().includes(F))},[t,f,u,d]),h=I=>{I.target.checked?r():i()},y=I=>F=>{p.current=I,F.dataTransfer.effectAllowed="move",F.dataTransfer.setDragImage(F.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},C=I=>F=>{F.preventDefault(),F.dataTransfer.dropEffect="move",I!==p.current&&v(I)},N=()=>{v(null)},T=I=>F=>{F.preventDefault();const G=p.current;v(null),p.current=null,G&&G!==I&&l&&l(G,I)},E=()=>{v(null),p.current=null};return a.jsxs("div",{className:"ogx-column-visibility-panel",children:[a.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:a.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[a.jsx(Kd,{}),a.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:I=>g(I.target.value)})]})}),a.jsx("div",{className:"ogx-column-visibility-panel__list",children:b.map((I,F)=>{const G=`${m}-col-${F}`,j=o.has(I.field),S=I.hideable!==!1,M=w===I.field,P=!!l&&!u;return a.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:P,onDragOver:P?C(I.field):void 0,onDragLeave:P?N:void 0,onDrop:P?T(I.field):void 0,onDragEnd:P?E:void 0,children:[P&&a.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(I.field),title:"Drag to reorder",children:a.jsx(jd,{})}),a.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:[a.jsx(Bt,{id:G,checked:j,onChange:_=>n(I.field,_.target.checked),disabled:!S}),a.jsx("label",{htmlFor:G,className:"ogx-column-visibility-panel__label",children:I.headerName||I.field})]})]},I.field)})}),a.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[a.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[a.jsx(Bt,{id:`${m}-all`,checked:x,onChange:h}),a.jsx("label",{htmlFor:`${m}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),a.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:"Reset"})]})]})}function Ud({isOpen:e,containerRef:t,panelRef:o,columns:n,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:d,onColumnOrderReset:u,columnGroupingModel:g}){const[m,w]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const p=t.current.getBoundingClientRect();w({top:p.top+8,right:xt()-p.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!m)return null;const v=i?void 0:(p,f)=>{pn(g,p,f)&&d(p,f)};return ot.createPortal(a.jsxs("div",{ref:o,style:{position:"fixed",top:m.top,right:m.right,zIndex:9999,display:"inline-block"},children:[a.jsx("button",{type:"button",onClick:l,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),a.jsx(vn,{columns:n,visibleColumns:new Set(n.filter(p=>r[p.field]!==!1).map(p=>p.field)),onVisibilityChange:(p,f)=>{c({...r,[p]:f})},onShowAll:()=>{const p={...r};n.forEach(f=>{f.hideable!==!1&&(p[f.field]=!0)}),c(p)},onHideAll:()=>{const p={...r};n.forEach(f=>{f.hideable!==!1&&(p[f.field]=!1)}),c(p)},onColumnReorder:v,onColumnOrderReset:i?void 0:u})]}),m.target)}const Si=[];function qd(e){const{isPivotActive:t}=e,o=t?Si: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 Xd(e){const{baseColumns:t,pinnedColumns:o,hasGroupingColumn:n,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=s.useMemo(()=>n?{...o,left:["__group__",...(o?.left??[]).filter(u=>u!=="__group__")]}:o,[n,o]);return{activeColumns:s.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 Yd(e){return e.id}function Rd(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),o=s.useRef(t);s.useLayoutEffect(()=>{o.current=t});const n=s.useCallback(r=>o.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:n}}function Jd(e,t){s.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 Zd(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 ec(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>Zd(o,t[n]))}function tc(e){const[t,o]=s.useState(e),n=ec(t,e);return n||o(e),n?t:e}function oc(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=[],w=v=>{for(;m.length>0&&m[m.length-1].header.depth>=v;){const p=m.pop();d&&!c?.(p.id)&&g.push({type:"group-subtotal",depth:p.header.depth,groupField:p.header.groupField,groupValue:p.header.groupValue,groupLabel:p.header.groupLabel,aggregatedValues:co(p.leaves,i,u,"getGroupedExportRows")})}};for(const v of t){const p=o(v),f=n.get(p);if(!f?.isGroupFooter)if(f?.isGroupRow){const x=f.treeDepth??0;w(x);const b={type:"group-header",depth:x,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(b),m.push({id:p,header:b,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??m.length,row:v}),m.forEach(x=>x.leaves.push(v))}return w(0),d&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function nc(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.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:w}=n();return c?oc({rows:d.getVisibleRows({expandAll:!0,labelField:w})??[],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 rc=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!it(t.field)&&!rc.has(t.field))}function Re(e){return!!e&&e.length>0}function ki(e,t,o=n=>n.id){const n=new Set(t);return e.filter(r=>n.has(o(r)))}function jt(e,t,o){return Re(t)?ki(e,t,o):e}function Ut(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 co(e,r,i,"export")}function qt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function vo(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 yn(e,t,o,n){return o==null?"":uo(o,t??"",e,n)}function St(e,t){return t?`${e}: ${t}`:e}function Ei(e,t){const o={};return t.forEach(n=>{Object.prototype.hasOwnProperty.call(e,n.field)&&(o[n.field]=e[n.field])}),o}const ic=/^[=+\-@\t\r]/,lc=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function yo(e,t=!1){return t||!ic.test(e)||lc.test(e)?e:`'${e}`}function Je(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Ee(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const sc=/[\\/?*:[\]]/g,Mi=31;function Cn(e,t=new Set){let o=String(e??"").replace(sc,"-").trim().replace(/^'+|'+$/g,"").trim();o||(o="Sheet"),o=o.slice(0,Mi).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,Mi-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const ac=new Set([Ye,Wt,Gt]),dc=/[\t\n\r"]/;function Ni(e){return dc.test(e)?`"${e.replace(/"/g,'""')}"`:e}function cc(e){return st(e).filter(t=>!ac.has(t.field))}function uc(e,t){const o=t.map(r=>Ni(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>Ni(vo(r,i,Fe(r,i.field,i)))).join(" "));return[o,...n].join(`
4
- `)}function Pi(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 fc(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(Pi(e))return;throw o}if(!Pi(e))throw new Error("Clipboard API not available and fallback failed.")}function gc(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 pc(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const o=s.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=uc(u,cc(i()));await fc(g)},[]),n=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!gc(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 hc(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=s.useCallback(()=>r.current,[r]),{copySelectedRows:c}=pc({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>o,getRows:()=>t.current.getAllFilteredRows(),getRowId:n,getRootElement:l,disableKeyboardShortcut:i});s.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function mc(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.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&&Qn(d,n,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;Wl(d,l.unpinnedColsWithWidth.findIndex(m=>m.field===g.field),l)}}},[t])}const wc=".ogx";function Ii(e,t){const o=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const n=t.getBoundingClientRect().width;t.style.cssText=o;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,c)=>l+(parseFloat(c)||0),0);return n+i}function xc(e,t){const o=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/"/g,'\\"'),n=l=>l.closest(wc)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${o}"]`).forEach(l=>{if(!n(l))return;const c=l.querySelector(".ogx__header-cell-content");c&&i(Ii(l,c))}),e.querySelectorAll(`[role="gridcell"][data-field="${o}"]`).forEach(l=>{if(!n(l)||l.hasAttribute("aria-colspan"))return;const c=l.querySelector(":scope > .ogx__cell-content");c&&i(Ii(l,c))}),r===null?null:Math.ceil(r)}function bc(e,t,o){return Math.max(t??qr,Math.min(o??1/0,e))}function vc(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e});const n=s.useCallback(i=>{const{containerRef:l,columns:c,onColumnResize:d}=o.current,u=l.current;if(!u)return;const g=[];for(const m of i??c.map(w=>w.field)){const w=c.find(p=>p.field===m);if(!w||w.resizable===!1)continue;const v=xc(u,m);v!==null&&g.push([m,bc(v,w.minWidth,w.maxWidth)])}for(const[m,w]of g)d(m,w)},[]),r=s.useCallback(i=>n([i]),[n]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=n},[t,r,n]),r}function yc(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function Cc(e){const{ensureGridFocus:t,setKeyboardMode:o,setFocusedCell:n,getRowId:r,onCellClick:i}=e,l=s.useCallback(d=>{t(),o(!1),n({id:r(d.row),field:d.field,rowIndex:d.rowIndex}),i?.(d)},[i,o,n,t,r]),c=s.useCallback(d=>{t(),n({id:null,field:d}),o(!1)},[t,n,o]);return{handleCellClick:l,handleHeaderClick:c}}function _c({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const d=e||mn;return a.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:Ir(c),...t})}function Sc({loading:e,error:t,noRowsLabel:o,filteredRowCount:n,dataRowCount:r,filterModel:i}){return a.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${Ur(t)}`:"",!e&&!t&&(n===0?o:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:"")]})}function kc(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 Ec(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 s.useMemo(()=>kc({headerRowCount:1+Xr(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 Mc(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:w,filterModel:v,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:x,disableColumnReorder:b,columnGroupingModel:h,moveColumn:y,resetColumnOrder:C,forceColumnsOpen:N,onColumnsPanelClose:T}=e;return s.useMemo(()=>t?{apiRef:n,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,...d||u||g?{pivotModel:m,onPivotModelChange:w}:{},filterModel:v,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:x,onColumnReorder:b?void 0:(I,F)=>{pn(h,I,F)&&y(I,F)},onColumnOrderReset:b?void 0:C,forceColumnsOpen:N,onColumnsPanelClose:T,...o}:null,[t,b,y,C,r,n,i,l,c,d,u,g,m,w,v,p,f,x,N,T,o,h])}function Nc(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:w,onRowSelectionModelChange:v,onRowClick:p,onRowDoubleClick:f,onCellClick:x,filterModel:b,onFilterModelChange:h,sortModel:y,onSortModelChange:C,pagination:N=!1,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:I=[10,25,50,100],pinnedColumns:F,onPinnedColumnsChange:G,pinnedRows:j,getDetailPanelContent:S,getDetailPanelHeight:M,detailPanelExpandedRowIds:P,onDetailPanelExpandedRowIdsChange:_,pinCheckboxColumn:L=!0,pinExpandColumn:A=!0,disableColumnReorder:X=!1,columnOrder:z,onColumnOrderChange:J,onColumnOrderModelChange:ee,height:ne,rowReordering:Z=!1,onRowOrderChange:ce,loading:ae=!1,treeData:oe=!1,getTreeDataPath:de,defaultGroupingExpansionDepth:ie,groupingColDef:V,rowGroupingModel:O,aggregationModel:$,onAggregationModelChange:Y,getAggregationPosition:U,isCellEditable:D,processRowUpdate:W,onProcessRowUpdateError:R,dataSource:H,multiSort:K=!1,sortingMode:B="client",filterMode:Q="client",paginationMode:k="client",rowCount:q,slots:re,slotProps:te,pivotMode:ue=!1,pivotModel:ge,onPivotModelChange:me,className:Se="",style:fe,onRowsScrollEnd:xe,ariaLabel:be,initialState:ve,onStateChange:se,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,listView:Ce=!1,listViewColumn:ke,columnGroupingModel:le,noRowsLabel:pe="No Data",localeText:we,apiRef:Ne,overscanRowCount:Qe=3}=e,_e=tc(o),Ze=we?.noRowsLabel??pe,Jt=O||Si,ko=ys({initialState:ve,sortModel:y,onSortModelChange:C,filterModel:b,onFilterModelChange:h,aggregationModel:$,onAggregationModelChange:Y,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,pinnedColumns:F,onPinnedColumnsChange:G,pivotModel:ge,onPivotModelChange:me,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:I,rowSelectionModel:w,onRowSelectionModelChange:v,density:c}),{sortModel:De,handleSortModelChange:Eo,filterModel:He,handleFilterModelChange:Mo,aggregationModel:$e,handleAggregationModelChange:zu,columnVisibilityModel:at,handleColumnVisibilityModelChange:kn,pinnedColumns:En,handlePinnedColumnsChange:Vu,currentPivotModel:nl,handlePivotModelChange:Ku,effectivePaginationModel:Ae,handlePaginationModelChange:Nt,selectedRowIds:ju,handleRowSelectionModelChange:Mn,density:rl}=ko,Qt=yd({rows:t,columns:_e,pivotMode:ue,pivotModel:nl,filterModel:He,sortModel:De,hasDataSource:!!H,hierarchyRequested:oe||Jt.length>0}),dt=Qt.isActive,{rowReordering:ct,hierarchyRowGroupingModel:Uu,isTreeDataRequested:qu,isTreeData:No,isRowGrouping:Pt,isHierarchyEnabled:Po,hasGroupingColumn:Xu,pagination:Be,listView:Zt}=qd({rowGroupingModel:Jt,treeData:oe,hasTreeDataPath:!!de,isPivotActive:dt,rowReordering:Z,hasGroupingColDef:!!V,pagination:N,paginationMode:k,listView:Ce,hasListViewColumn:!!ke}),{rowHeight:et,headerHeight:il}=Es({rowHeight:r,headerHeight:i,density:rl}),Yu=Qt.rows,Ru=Qt.columns,{activeColumns:ut,effectivePinnedColumns:It}=Xd({baseColumns:Ru,pinnedColumns:En,hasGroupingColumn:Xu,groupingColDef:V,isTreeData:No,getTreeDataPath:de}),Nn=aa(ut,at),[Ju,Qu]=xd($e),Tt=s.useRef(null),Pn=s.useRef(null),ll=!dt&&n||Yd,In=yc(Tt),Tn=Ga({rows:Yu,getRowId:ll,columns:ut,rowHeight:et,headerHeight:il,columnVisibilityModel:at,initialState:e.initialState,syncRows:!H}),{state:Me,apiRef:Lt,setRows:Zu,replaceRow:ef,setColumns:tf,setDimensions:of,setDataSourceLoading:nf,setDataSourceError:rf,setRowCount:lf}=Tn,{getRowIdOf:Pe,getRowIdOfInEvents:sf}=Rd(Me.rows.idByRow);Jd(Ne,Lt);const af=Me.dataSource.loading,tt=ae||af,Io=s.useMemo(()=>Me.rows.allRows.map(pt=>Me.rows.idRowsLookup.get(pt)),[Me.rows]),{treeDataHandlers:To,rowGroupingHandlers:Ln,activeHierarchyHandlers:Ft,rowMetaMap:ze}=td({rows:Io,getRowId:Pe,getTreeDataPath:de,isTreeDataRequested:qu,isTreeData:No,columns:ut,rowGroupingModel:Uu,isRowGrouping:Pt,aggregationModel:$e,defaultGroupingExpansionDepth:ie,filterModel:He,sortModel:De,getAggregationPosition:U,columnLookup:Nn,filterMode:Q,sortingMode:B}),sl=nd({rows:Io,getRowId:Pe,columns:ut,processRowUpdate:W,onProcessRowUpdateError:R,onRowChange:(pt,$f)=>{ef($f,pt)}}),eo=ra({selectedRowIds:ju,rowsLookup:Me.rows.idRowsLookup,rowMetaMap:ze,enabled:!H&&!dt&&k==="client"&&Q==="client",onSelectionModelChange:Mn}),al=hd({dataSource:H,sortModel:De,filterModel:He,paginationModel:Ae,paginationMode:k,sortingMode:B,filterMode:Q,aggregationModel:$e,rowGroupingActive:Pt,getRowId:ll,setRows:Zu,setRowCount:lf,setDataSourceLoading:nf,setDataSourceError:rf,onAggregationResults:Qu,onPaginationModelChange:Nt});wd({enabled:No&&!!H,treeNodes:To.treeNodes,isGroupExpanded:To.isGroupExpanded,getNodePath:To.getNodePath,toggleExpansion:To.toggleExpansion,fetchChildren:al.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:Fn,handleDetailPanelToggle:dl,detailPanelHeights:df,reportDetailPanelHeight:cf}=js({hasDetailPanel:!!S,controlledExpandedRowIds:P,onDetailPanelExpandedRowIdsChange:_,rowMetaMap:ze}),{effectiveColumns:cl,hierarchyField:On,orderedColumns:An,visibleOrderedColumns:ul,renderOrderedColumns:uf,navigationColumns:fl,columnIndexMap:gl,columnWidths:to,effectiveColumnOrder:ff,columnReorderHandlers:gf,moveColumn:pl,resetColumnOrder:hl,handleColumnResize:ml}=Ds({activeColumns:ut,isHierarchyEnabled:Po,isRowGrouping:Pt,isTreeData:No,activeHierarchyHandlers:Ft,columnVisibilityModel:at,columnOrder:z,onColumnOrderChange:J,onColumnOrderModelChange:ee,disableColumnReorder:X,pivotMode:dt,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,initialState:ve,setColumns:tf,pinnedColumns:It,getRowId:sf,aggregationModel:$e,groupingRows:Pt?Ln.groupingRows:void 0});Xs({onStateChange:se,sortModel:De,filterModel:He,effectivePaginationModel:Ae,columnWidths:to,effectiveColumnOrder:ff,columnVisibilityModel:at,pinnedColumns:En,density:rl});const Lo=Ns({effectiveRows:Io,activeHierarchyHandlers:Ft,filterMode:Q,filterModel:Qt.pipelineFilterModel,sortModel:Qt.pipelineSortModel,sortingMode:B,pagination:Be,paginationMode:k,effectivePaginationModel:Ae,pinnedRows:j,getRowId:Pe,columnLookup:Nn,hierarchyField:On}),{filteredRows:wl,dataRows:Ot,pinnedTopRows:Ge,pinnedBottomRows:Ve,sortedUnpinnedRows:Ue,paginatedUnpinnedRows:Fo,allRenderableRows:Oo}=Lo,Dn=Be?Fo:Ue;da({paginationModel:Ae,currentPage:Lo.currentPage,enabled:Be&&!tt&&Ue.length>0,onPaginationModelChange:Nt});const Ao=Ms({paginationMode:k,hasDataSource:!!H,dataSourceRowCount:Me.pagination.rowCount,rowCountProp:q,clientRowCount:Ue.length}),{rowSelection:$n,handleRowClick:Gn,handleSelectionChange:Wn}=na({dataRows:Ot,getRowId:Pe,isPivotActive:dt,selectedRowIds:eo,onSelectionModelChange:Mn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:Po,rowMetaMap:ze,activeHierarchyHandlers:Ft,onRowClick:p});sa({apiRef:Tn.apiRef,sortModel:De,multiSort:K,onSortModelChange:Eo,filterModel:He,onFilterModelChange:Mo,paginationModel:Ae,onPaginationModelChange:Nt,selectedRowIds:eo,getPendingRowSelectionModel:ko.getPendingRowSelectionModel,onRowSelectionModelChange:Mn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>Xe(pt,ze),getVisibleRows:()=>[...Ge,...Dn,...Ve],getAllFilteredRows:()=>Qd({hierarchyHandlers:Ft,pinnedTopRows:Ge,sortedUnpinnedRows:Ue,pinnedBottomRows:Ve,rowMetaMap:ze,getRowId:Pe,hierarchyField:On,dataRows:Ot}),visibleColumns:uf});const pf=Wa({rows:Io,getRowId:Pe,onRowOrderChange:ce,rowReordering:ct}),{aggregationResult:Hn,isLoading:hf}=xi({rows:Ot,columns:ut,aggregationModel:dt?Hl:$e,isServerSide:Kr({dataSource:H,paginationMode:k,sortingMode:B,filterMode:Q}),dataSource:H,filterModel:He,sortModel:De,serverAggregationResults:Ju}),Bn=Object.keys($e).length>0&&!dt;nc({apiRef:Lt,hasAggregation:Bn,aggregationResult:Hn,aggregationModel:$e,isRowGrouping:Pt,rowGroupingHandlers:Ln,rowMetaMap:ze,columns:ut,getRowId:Pe,hierarchyField:On});const Ie=$l({rowHeight:et,pagination:Be,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,expandedRowIds:Fn,getDetailPanelHeight:M,detailPanelHeights:df,pinnedTopRowsLength:Ge.length,pinnedBottomRowsLength:Ve.length,pinnedTopRows:Ge,pinnedBottomRows:Ve,visibleOrderedColumns:ul,pinnedColumns:It,columnWidths:to,viewportWidth:Me.dimensions.viewportWidth||1e3,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,paginationMode:k,isLoading:Me.dataSource.loading,pageSize:Ae.pageSize,getRowId:Pe}),oo=ad({pinnedTopRows:Ge,centerRows:Dn,pinnedBottomRows:Ve,columns:ul,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?Fn:void 0,rowMetaMap:ze,getRowId:Pe}),xl=s.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);hc({apiRef:Lt,columns:xl,getRowId:Pe,containerRef:Tt,disableKeyboardShortcut:m}),mc({apiRef:Lt,viewportRef:Pn,layout:Ie,rowHeight:et});const mf=vc({apiRef:Lt,containerRef:Tt,columns:An,onColumnResize:ml}),{scrollTop:wf,scrollLeft:xf,overscanRows:bf,handleScroll:vf,setViewportElement:yf}=Vs({onRowsScrollEnd:xe,overscanRowCount:Qe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:of,viewportRef:Pn}),Le=Ps({layout:Ie,scrollTop:wf,scrollLeft:xf,viewportWidth:Me.dimensions.viewportWidth,viewportHeight:Me.dimensions.viewportHeight,autoHeight:l,rowReordering:ct,hasDetailPanel:ft,checkboxSelection:d,pinCheckboxColumn:L,pinExpandColumn:A,overscanRows:bf}),{handleSort:bl,handleSortAdd:vl}=ia({sortModel:De,onSortModelChange:Eo}),Do=d||!u,{focusedCell:yl,setFocusedCell:Cf,viewportTabIndex:_f,ensureGridFocus:Sf,handleFocus:kf,handleBlur:Ef,handleKeyDown:Mf,handleMouseDownCapture:Nf}=xs({allRenderableRows:Oo,navigationColumns:fl,checkboxSelection:d,selectedRowIds:eo,handleSelectionChange:Wn,handleDetailPanelToggle:dl,editingHandlers:sl,setKeyboardMode:In,sortModel:De,handleSort:bl,handleSortAdd:vl,multiSort:K,isCellEditable:D,pagination:Be,pageSize:Ae.pageSize,virtualization:Le,viewportRef:Pn,pinnedTopRowCount:Ge.length,getRowId:Pe,rowMetaMap:ze,getSpanOrigin:oo.getSpanOrigin,onRowActivate:Gn,toggleRowExpansion:Ft?.toggleExpansion,handleSelectAll:$n.selectAll,rowSelectionEnabled:Do,multipleRowSelectionEnabled:!g,pinCheckboxColumn:L,pinExpandColumn:A,rowHeight:et}),{handleCellClick:Pf,handleHeaderClick:If}=Cc({ensureGridFocus:Sf,setKeyboardMode:In,setFocusedCell:Cf,getRowId:Pe,onCellClick:x}),{handleHideColumn:Tf,handlePinColumn:Lf}=la({columnVisibilityModel:at,onColumnVisibilityModelChange:kn,pinnedColumns:En,onPinnedColumnsChange:Vu}),no=Ec({columnGroupingModel:le,pinnedTopCount:Ge.length,pinnedBottomCount:Ve.length,pagination:Be,paginationMode:k,paginationModel:Ae,paginationRowCount:Ao,paginatedUnpinnedRowCount:Fo.length,sortedUnpinnedRowCount:Ue.length}),zn=cd({spanning:oo,renderContext:Le.renderContext,offsetTop:Le.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Vn=Gs({renderContext:zn.renderContext,pinnedTopRows:Ge,pinnedBottomRows:Ve,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,pagination:Be,getRowId:Pe}),$o=ud({spanning:oo,firstColumnIndex:Le.renderContext.firstColumnIndex,lastColumnIndex:Le.renderContext.lastColumnIndex,virtualColumns:Le.virtualColumns,layout:Ie,rows:Vn});Qs({paginationRequested:N,isRowGrouping:Pt,autoHeight:l,viewportHeight:Me.dimensions.viewportHeight,renderedRowCount:Vn.length,totalRowCount:Ge.length+Dn.length+Ve.length,pinnedRowsIgnored:Po&&!!(j?.top?.length||j?.bottom?.length),scrollHeight:Le.totalHeight,listViewWithoutColumn:Ce&&!ke,listViewRowCount:Zt&&ke?Oo.length:0});const{allSelected:Ff,someSelected:Of}=$n,At=fd(le,gf),Af=s.useMemo(()=>cl.some(pt=>!!pt.rowSpan),[cl]),gt=ca();ea(Tt);const Cl=re?.noRowsOverlay,_l=re?.loadingOverlay,Kn=_l?a.jsx(_l,{...te?.loadingOverlay}):void 0,Sl=Cl?a.jsx(Cl,{...te?.noRowsOverlay}):void 0,Go=re?.footer,Df=tt&&Oo.length>0&&k!=="infinite",kl=re?.toolbar,El=Mc({toolbar:re?.toolbar,toolbarSlotProps:te?.toolbar,apiRef:Lt,orderedColumns:An,baseColumns:_e,aggregationModel:$e,onAggregationModelChange:zu,pivotMode:ue,pivotModelProp:ge,onPivotModelChangeProp:me,pivotModel:nl,onPivotModelChange:Ku,filterModel:He,onFilterModelChange:Mo,columnVisibilityModel:at,onColumnVisibilityModelChange:kn,disableColumnReorder:X,columnGroupingModel:le,moveColumn:pl,resetColumnOrder:hl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),jn={rowReordering:ct,columnIndexMap:gl,editingHandlers:sl,isCellEditable:D,selectedRowIds:eo,checkboxSelection:d,onRowClick:Gn,onRowDoubleClick:f,onCellClick:Pf,onSelectionChange:Wn,columnWidths:to,pinnedColumns:It,hasDetailPanel:ft,expandedRowIds:Fn,getDetailPanelContent:S,getDetailPanelHeight:M,onDetailPanelToggle:dl,onDetailPanelHeightChange:cf,pinCheckboxColumn:L,pinExpandColumn:A,focusedCell:yl,colspanMap:oo.colspanMap,rowSpanningCaches:oo.rowSpanningCaches,rowHeight:et,rowMetaMap:ze};return a.jsxs("div",{ref:Tt,className:["ogx",Se,l&&"ogx--auto-height",!l&&ne===void 0&&fe?.height===void 0&&"ogx--fill",Af&&"ogx--row-spanning",Zt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...fe,height:ne??fe?.height,"--ogx-row-height":`${et}px`,"--ogx-header-height":`${il}px`},"aria-busy":tt,children:[kl&&El&&a.jsx(zr.Provider,{value:gt.toolbarHost,children:a.jsx(ga,{component:kl,toolbarProps:El})}),a.jsx(Ud,{isOpen:gt.standalonePanelOpen,containerRef:Tt,panelRef:gt.standalonePanelRef,columns:An,columnVisibilityModel:at,disableColumnReorder:X,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:kn,onColumnMove:pl,onColumnOrderReset:hl,columnGroupingModel:le}),Zt&&ke&&a.jsx(kd,{ariaLabel:be,allRenderableRows:Oo,dataRowCount:Ot.length,pinnedTopRowCount:Ge.length,pinnedBottomRowCount:Ve.length,unpinnedRowCount:Ue.length,pagination:Be,effectivePaginationModel:Ae,currentPage:Lo.currentPage,pageSizeOptions:I,selectedRowIds:eo,listViewColumn:ke,columnsByField:Nn.byField,rowMetaMap:ze,noRowsLabel:Ze,rowHeight:et,checkboxSelection:d,paginationMode:k,serverRowCount:Ao,paginationSlot:re?.pagination,paginationSlotProps:te?.pagination,localeText:Ir(we),onRowClick:Gn,onRowDoubleClick:f,onSelectionChange:Wn,onPaginationModelChange:Nt,onRowsScrollEnd:xe,getRowId:Pe,multiselectable:Do&&!g,selectable:Do,onToggleExpansion:Ft?.toggleExpansion,loading:tt,loadingOverlay:Kn,noRowsOverlay:Sl,showPaginationControls:!Go}),!Zt&&a.jsx("div",{ref:yf,className:"ogx__viewport",onScroll:vf,role:"grid","aria-label":be||"Data grid","aria-rowcount":no.rowCount,"aria-colcount":fl.length,"aria-multiselectable":Do&&!g,"aria-busy":tt,tabIndex:_f,onKeyDownCapture:()=>{In(!0)},onMouseDownCapture:Nf,onKeyDown:Mf,onFocus:kf,onBlur:Ef,children:a.jsxs("div",{className:"ogx__content",style:{width:It?.right?.length?`max(100%, ${Le.totalWidth}px)`:Le.totalWidth},role:"presentation",children:[a.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[a.jsx(Jr,{columns:$o,allColumns:xl,columnGroupingModel:le,checkboxSelection:d,allSelected:Ff,someSelected:Of,onSelectAll:$n.selectAll,sortModel:De,onSort:bl,onSortAdd:vl,multiSort:K,onColumnResize:ml,onColumnAutosize:mf,columnWidths:to,pinnedColumns:It,focusedCell:yl,columnIndexMap:gl,onHeaderClick:If,onDragStart:At.onDragStart,onDragOver:At.onDragOver,onDragEnd:At.onDragEnd,onDrop:At.onDrop,draggedColumn:At.draggedColumn,dragOverColumn:At.dragOverColumn,rowReordering:ct,hasDetailPanel:ft,pinCheckboxColumn:L,pinExpandColumn:A,aggregationModel:$e,onHideColumn:Tf,onManageColumns:gt.openColumnsPanel,onPinColumn:Lf}),a.jsx(_i,{...jn,rows:Ge,position:"top",ariaRowIndexBase:no.topBase,columns:$o,pinnedRows:j,getRowId:Pe})]}),!tt&&!Me.dataSource.error&&wl.length===0&&a.jsx(ha,{noRowsLabel:Ze,width:Le.totalWidth,overlay:Sl}),a.jsx(Vd,{...jn,virtualContainerHeight:Le.totalHeight-Le.pinnedTopHeight-Le.pinnedBottomHeight,offsetTop:zn.offsetTop,effectiveLoading:tt,visibleRows:Vn,baseColumns:_e,virtualColumns:$o,viewportWidth:Me.dimensions.viewportWidth,rowReorderHandlers:pf,paginationMode:k,dataSourceLoading:Me.dataSource.loading,sortedUnpinnedRowCount:Ue.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:zn.renderContext.lastRowIndex,ariaRowIndexOffset:no.centerOffset,loadingOverlay:Kn}),a.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[a.jsx(_i,{...jn,rows:Ve,position:"bottom",rowIndexOffset:no.bottomRowIndexOffset,ariaRowIndexBase:no.bottomBase,columns:$o,pinnedRows:j,getRowId:Pe}),Bn&&Ln.rootAggregationPosition!==null&&a.jsx(pa,{columns:Le.virtualColumns,aggregationModel:$e,aggregationResult:Hn,columnWidths:to,rowHeight:et,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,pinnedColumns:It,loading:hf})]})]})}),Go&&a.jsx(Go,{apiRef:Tn.apiRef,aggregationModel:$e,aggregationResult:Bn?Hn:null,rowCount:Po&&k!=="server"?Ot.length:Ao,pagination:Be,paginationModel:Ae,pageSizeOptions:I,onPaginationModelChange:Nt,...te?.footer}),!Zt&&!Go&&Be&&a.jsx(_c,{paginationSlot:re?.pagination,paginationSlotProps:te?.pagination,page:Lo.currentPage,paginationModel:Ae,rowCount:Ao,pageSizeOptions:I,onPaginationModelChange:Nt,localeText:we}),a.jsx(Sc,{loading:tt,error:Me.dataSource.error,noRowsLabel:Ze,filteredRowCount:wl.length,dataRowCount:Ot.length,filterModel:He}),Df&&a.jsx(Ed,{overlay:Kn}),a.jsx(wa,{error:Me.dataSource.error,onRetry:H?al.fetchRows:void 0})]})}function Pc({rows:e=5,columns:t=5}){return a.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((o,n)=>a.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-content"})},i))},n))})}const Ic=300;function kt(e){return"field"in e&&!("items"in e)}function Ti(e,t){return e.find(o=>kt(o)&&o.field===t)}function Li(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)=>Li(o,t[n])):!1}function Tc(e,t){return e===t?!0:kt(e)&&kt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Li(e.value,t.value):!kt(e)&&!kt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&_n(e.items,t.items):!1}function _n(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>Tc(o,t[n]))}function Lc(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 Fi(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Oi(e,t){return e==null?"":t.type==="date"||e instanceof Date?Yn(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(o=>String(o)).join(", "):String(e)}function Ai(e,t){return t==="isAnyOf"?e.split(",").map(o=>o.trim()).filter(o=>o!==""):e}function Fc(e,t){if(!Ro.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Oc=({col:e,item:t,resetToken:o,onChange:n})=>{const r=s.useId(),i=Yl(e.type),l=i[0],c=t?.operator??l,d=i.includes(c)?i:[c,...i],u=!!t,g=e.headerName||e.field,[m,w]=s.useState(null),[v,p]=s.useState(o);v!==o&&(p(o),w(null));const f=s.useRef(n),x=s.useRef(t),b=s.useRef(e);s.useLayoutEffect(()=>{f.current=n,x.current=t,b.current=e});const h=s.useCallback((M,P)=>({id:x.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:M,value:P}),[e.field]),y=s.useCallback(M=>{const P=x.current;if(P?M===Oi(P.value,b.current):M.trim()==="")return;const L=P?.operator??l;f.current(h(L,Ai(M,L)))},[l,h]),C=s.useRef(null),N=s.useRef(y);s.useLayoutEffect(()=>{C.current=m,N.current=y}),s.useEffect(()=>()=>{const M=C.current;C.current=null,M!==null&&N.current(M)},[]),s.useEffect(()=>{if(m===null)return;const M=setTimeout(()=>{C.current=null,y(m),w(null)},Ic);return()=>clearTimeout(M)},[m,y]);const T=M=>{const P=m!==null?Ai(m,M):t?.value;w(null),n(h(M,Fc(P,M)))},E=()=>{w(null),n(null)},I=!Ro.has(c),F=Lc(e),G=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,j=`Filter value for ${g}`;let S=null;if(I&&e.type==="boolean")S=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:M=>{M.target.value===""?n(null):n(h(c,M.target.value))},"aria-label":j,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"true",children:"true"}),a.jsx("option",{value:"false",children:"false"})]});else if(I&&e.type==="singleSelect"&&F.length>0&&c==="isAnyOf"){const M=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];S=a.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(F.length,4),value:F.filter(P=>M.some(_=>Fi(P,_))).map(P=>P.key),onChange:P=>{const _=new Set(Array.from(P.target.selectedOptions,L=>L.value));n(h("isAnyOf",F.filter(L=>_.has(L.key)).map(L=>L.value)))},"aria-label":j,children:F.map(P=>a.jsx("option",{value:P.key,children:P.label},P.key))})}else if(I&&e.type==="singleSelect"&&F.length>0&&(c==="is"||c==="not")){const M=F.find(P=>Fi(P,t?.value));S=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-select`,value:M?.key??"",onChange:P=>{const _=F.find(L=>L.key===P.target.value);n(h(c,_?_.value:""))},"aria-label":j,children:[a.jsx("option",{value:"",children:"Any"}),F.map(P=>a.jsx("option",{value:P.key,children:P.label},P.key))]})}else I&&(S=a.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:G,type:e.type==="date"?"date":"text",value:m??Oi(t?.value,e),onChange:M=>w(M.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":j}));return a.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[a.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),a.jsxs("div",{className:"ogx-filter__controls",children:[a.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:c,onChange:M=>T(M.target.value),"aria-label":`Filter operator for ${g}`,children:d.map(M=>a.jsx("option",{value:M,children:M},M))}),S,u&&a.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},Di=({filterModel:e,columns:t,onFilterModelChange:o})=>{const n=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[c,d]=s.useState(n),[u,g]=s.useState(0);if(c!==n){d(n);const x=!_n(c,n),b=i!==null&&_n(i,n);x&&!b&&g(h=>h+1)}const m=s.useCallback((x,b)=>{const h=n.findIndex(C=>kt(C)&&C.field===x);let y;if(h===-1){if(!b)return;y=[...n,b]}else b?y=n.map((C,N)=>N===h?b:C):y=n.filter((C,N)=>N!==h);l(y),o({...e,items:y})},[n,e,o]),w=s.useCallback(x=>{o({...e,logicOperator:x})},[e,o]),v=t.filter(x=>x.filterable!==!1),p=v.filter(x=>Ti(n,x.field)).length,f=n.length-p;return a.jsxs(a.Fragment,{children:[n.length>1&&a.jsxs("div",{className:"ogx-filter__logic-bar",children:[a.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>w("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>w("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),f>0&&a.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?a.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):v.map(x=>a.jsx(Oc,{col:x,item:Ti(n,x.field),resetToken:u,onChange:b=>m(x.field,b)},x.field))]})},$i=["sum","avg","count","min","max"];function Gi(){return a.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),a.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Ac({anchorRef:e,columns:t,model:o,onChange:n,onClose:r}){const i=s.useRef(null),[l,c]=s.useState({top:0,right:0}),[d,u]=s.useState(null);s.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const _=e.current.getBoundingClientRect();return{top:_.bottom+6,right:xt()-_.right}},[e]);s.useEffect(()=>{c(g());const _=()=>c(g());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[g]),s.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),w=new Set(o.columnFields),v=new Set(o.valueFields.map(_=>_.field)),p=_=>m.has(_)||w.has(_)||v.has(_),f=_=>t.find(L=>L.field===_),x=_=>f(_)?.headerName??_,b=_=>{const L=f(_)?.availableAggregationFunctions;return L?$i.filter(A=>L.includes(A)):$i},h=_=>_.aggregable!==!1&&(_.type==="number"||_.aggregable===!0)&&b(_.field).length>0,y=_=>_.groupable!==!1;function C(_){m.has(_)||n({...o,rowFields:[...o.rowFields,_]})}function N(_){w.has(_)||n({...o,columnFields:[...o.columnFields,_]})}function T(_){v.has(_)||n({...o,valueFields:[...o.valueFields,{field:_,aggFn:b(_)[0]??"sum"}]})}function E(_){n({...o,rowFields:o.rowFields.filter((L,A)=>A!==_)})}function I(_){n({...o,columnFields:o.columnFields.filter((L,A)=>A!==_)})}function F(_){n({...o,valueFields:o.valueFields.filter((L,A)=>A!==_)})}function G(_,L){n({...o,valueFields:o.valueFields.map((A,X)=>X===_?{...A,aggFn:L}:A)})}function j(){n({rowFields:[],columnFields:[],valueFields:[]})}const S=o.rowFields.length+o.columnFields.length+o.valueFields.length,M=t.filter(_=>!p(_.field)&&(y(_)||h(_))),P=a.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[a.jsxs("div",{className:"ogx-pivot-panel__header",children:[a.jsxs("span",{className:"ogx-pivot-panel__title",children:[a.jsx(Gi,{}),"Pivot Mode"]}),S>0&&a.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:j,title:"Reset pivot",children:"Reset"})]}),a.jsxs("div",{className:"ogx-pivot-panel__body",children:[a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${o.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:o.rowFields.map((_,L)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[x(_),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(L),title:`Remove ${x(_)}`,"aria-label":`Remove ${x(_)} from Row Fields`,children:"×"})]},`${L}:${_}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${o.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:o.columnFields.map((_,L)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[x(_),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>I(L),title:`Remove ${x(_)}`,"aria-label":`Remove ${x(_)} from Column Fields`,children:"×"})]},`${L}:${_}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),a.jsx("div",{className:`ogx-pivot-chips${o.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:o.valueFields.map((_,L)=>{const A=b(_.field),X=A.includes(_.aggFn)?A:[_.aggFn,...A];return a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[x(_.field),a.jsx("select",{className:"ogx-pivot-chip__fn-select",value:_.aggFn,onChange:z=>G(L,z.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${x(_.field)}`,children:X.map(z=>a.jsx("option",{value:z,children:z.toUpperCase()},z))}),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>F(L),title:`Remove ${x(_.field)}`,"aria-label":`Remove ${x(_.field)} (${_.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${L}:${_.field}:${_.aggFn}`)})})]}),a.jsx("hr",{className:"ogx-pivot-panel__divider"}),a.jsxs("div",{children:[a.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),a.jsxs("div",{className:"ogx-pivot-fields",children:[M.map(_=>{const L=h(_),A=y(_),X=_.headerName??_.field;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[a.jsx("span",{className:`ogx-pivot-field-btn${L?" ogx-pivot-field-btn--numeric":""}`,children:X}),a.jsxs("div",{className:"ogx-pivot-field-actions",children:[A&&a.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 ${X} to Row Fields`,children:"Row"}),A&&a.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 ${X} to Column Fields`,children:"Col"}),L&&a.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 ${X} to Value Fields`,children:"Val"})]})]},_.field)}),M.length===0&&a.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return d?ot.createPortal(P,d):null}function Dc(){return a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function $c(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Wi(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Gc({value:e="",onChange:t,placeholder:o="Search...",debounceMs:n=250}){const[r,i]=s.useState(()=>e.length>0),[l,c]=s.useState(e),d=s.useRef(null),u=s.useRef(null),g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t},[t]);const m=s.useRef(e),w=s.useRef(e);s.useEffect(()=>{e!==w.current&&(w.current=e,Wi(e)!==Wi(m.current)&&(c(e),m.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const h=setTimeout(()=>{l!==m.current&&(m.current=l,g.current(l))},n);return()=>clearTimeout(h)},[l,n]);const v=s.useRef(l);s.useLayoutEffect(()=>{v.current=l}),s.useEffect(()=>()=>{const h=v.current;h!==m.current&&(m.current=h,g.current(h))},[]);const p=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>d.current?.focus())},[]),f=s.useCallback(h=>{h.stopPropagation(),c(""),m.current="",g.current(""),d.current?.focus()},[]),x=s.useCallback(()=>{i(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const h=y=>{u.current&&!u.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),a.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:p,children:[a.jsx("div",{className:"ogx-global-search__icon-wrapper",children:a.jsx(Dc,{})}),a.jsx("input",{ref:d,className:"ogx-global-search__input",value:l,onChange:h=>c(h.target.value),onFocus:x,onBlur:b,placeholder:o,"aria-label":"Global Search",autoComplete:"off"}),l&&a.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:a.jsx($c,{})})]})}const Co=8;function Xt({title:e,children:t,placement:o="top",enterDelay:n=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[c,d]=s.useState({top:0,left:0}),[u,g]=s.useState(null),m=s.useRef(null),w=s.useRef(null),v=s.useId(),p=s.useCallback(()=>{if(!w.current)return;const N=w.current.getBoundingClientRect(),T=N.left+N.width/2,E=N.top+N.height/2;switch(o){case"bottom":d({top:N.bottom+Co,left:T});break;case"left":d({top:E,left:N.left-Co});break;case"right":d({top:E,left:N.right+Co});break;default:d({top:N.top-Co,left:T})}},[o]),f=s.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;p();const N=T=>{T.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),document.addEventListener("keydown",N),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),document.removeEventListener("keydown",N)}},[i,p,f]),s.useEffect(()=>f,[f]);const x=()=>{f(),m.current=setTimeout(()=>{g(w.current?.closest(".ogx-theme-provider")??document.body),l(!0)},n)},b=()=>{f(),m.current=setTimeout(()=>{l(!1)},r)},h=s.useCallback(N=>{w.current=N?N.firstElementChild??N:null},[]),y=i&&!!e&&u!==null;let C=t;if(y&&s.isValidElement(t)){const N=t,T=N.props["aria-describedby"];C=s.cloneElement(N,{"aria-describedby":T?`${T} ${v}`:v})}return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:h,style:{display:"inline-block",lineHeight:0},onMouseEnter:x,onMouseLeave:b,onFocus:x,onBlur:b,children:C}),y&&u&&ot.createPortal(a.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 Wc=Object.keys(ao);function Hc(e){return Object.prototype.hasOwnProperty.call(ao,e)}function Hi(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Hc))):Wc}function Bi(){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Bc(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function zi(){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function zc({anchorRef:e,aggregationModel:t,aggregableColumns:o,onFunctionChange:n,onClearAll:r,onClose:i,activeCount:l}){const c=s.useRef(null),[d,u]=s.useState({top:0,right:0}),[g,m]=s.useState(null);s.useLayoutEffect(()=>{m(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const w=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:xt()-p.right}},[e]);s.useEffect(()=>{u(w());const p=()=>u(w());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[w]),s.useEffect(()=>{function p(f){c.current&&!c.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,i]),s.useEffect(()=>{function p(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]);const v=a.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:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(Bi,{}),"Summaries"]}),l>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),a.jsx("div",{className:"ogx-toolbar__panel-body",children:o.length===0?a.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",a.jsx("br",{}),"Set ",a.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):o.map(p=>{const f=t[p.field]||"none";return a.jsxs("div",{className:"ogx-toolbar__agg-row",children:[a.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),a.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Hi(p)].map(x=>a.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===x?" ogx-toolbar__pill--active":""}`,onClick:()=>n(p.field,x),"aria-pressed":f===x,children:x},x))})]},p.field)})})]});return g?ot.createPortal(v,g):null}function Vc({anchorRef:e,columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:d,showNonHideableColumns:u}){const g=s.useRef(null),[m,w]=s.useState({top:0,right:0}),[v,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const b=e.current.getBoundingClientRect();return{top:b.bottom+6,right:xt()-b.right}},[e]);s.useEffect(()=>{w(f());const b=()=>w(f());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[f]),s.useEffect(()=>{function b(h){g.current&&!g.current.contains(h.target)&&e.current&&!e.current.contains(h.target)&&d()}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e,d]),s.useEffect(()=>{function b(h){h.key==="Escape"&&d()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[d]);const x=a.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:a.jsx(vn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return v?ot.createPortal(x,v):null}function Kc({anchorRef:e,columns:t,filterModel:o,onFilterModelChange:n,onClose:r}){const i=s.useRef(null),[l,c]=s.useState({top:0,right:0}),d=s.useRef(r);s.useLayoutEffect(()=>{d.current=r},[r]);const[u,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const m=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const f=e.current.getBoundingClientRect();return{top:f.bottom+6,right:xt()-f.right}},[e]);s.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]),s.useEffect(()=>{function f(x){x.key==="Escape"&&d.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const w=o.items?.length??0,v=()=>{n({...o,items:[],logicOperator:"and"})},p=a.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(zi,{}),"Filters",w>0&&a.jsx("span",{className:"ogx-toolbar__panel-count",children:w})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[w>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:v,title:"Clear all filters",children:"Clear all"}),a.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>d.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),a.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:a.jsx(Di,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?ot.createPortal(p,u):null}const jc={rowFields:[],columnFields:[],valueFields:[]};function Uc({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:w,onColumnsPanelClose:v,children:p,rightContent:f,style:x,renderColumnsButton:b,renderFilterButton:h,renderAggregationButton:y,renderExportButton:C,renderQuickFilter:N,className:T,showNonHideableColumns:E}){const[I,F]=s.useState(null),G=I==="summaries",j=I==="pivot",S=I==="columns",M=I==="filters",P=Q=>{I==="columns"&&Q!=="columns"&&v?.(),F(Q)},_=Q=>P(I===Q?null:Q),L=Q=>{I===Q&&P(null)};s.useEffect(()=>{w&&F("columns")},[w]);const A=s.useContext(zr),X=w!==void 0&&!!u;s.useEffect(()=>{if(!(!A||!X))return A.registerColumnsPanel()},[A,X]);const z=s.useRef(null),J=s.useRef(null),ee=s.useRef(null),ne=s.useRef(null),Z=s.useRef(null),ce=s.useRef(null),ae=s.useRef(null),oe=r??jc,de=oe.rowFields.length>0||oe.columnFields.length>0||oe.valueFields.length>0,ie=t?new Set(t.map(Q=>Q.field)):null,V=e.filter(Q=>Q.aggregable!==!1&&(Q.type==="number"||Q.aggregable===!0)&&Hi(Q).length>0&&(!ie||ie.has(Q.field))),O=Object.keys(o).filter(Q=>o[Q]&&o[Q]!=="none").length,$=s.useCallback((Q,k)=>{if(!n)return;const q={...o};k==="none"?delete q[Q]:q[Q]=k,n(q)},[o,n]),Y=s.useCallback(()=>{n?.({})},[n]),U=s.useCallback(Q=>{if(!c)return;const k=Q.trim().split(/\s+/).filter(Boolean),q={...l||{},quickFilterValues:k,items:l?.items||[]};c(q)},[l,c]),D=(l?.quickFilterValues??[]).join(" "),W=l?.items?.length||0,R=new Set(e.filter(Q=>d[Q.field]!==!1).map(Q=>Q.field)),H=s.useCallback((Q,k)=>{if(!u)return;const q={...d,[Q]:k};u(q)},[d,u]),K=s.useCallback(()=>{if(!u)return;const Q={...d};e.forEach(k=>{k.hideable!==!1&&(Q[k.field]=!0)}),u(Q)},[e,d,u]),B=s.useCallback(()=>{if(!u)return;const Q={...d};e.forEach(k=>{k.hideable!==!1&&(Q[k.field]=!1)}),u(Q)},[e,d,u]);return a.jsxs("div",{className:["ogx-toolbar",T].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:x,children:[p&&a.jsx("div",{className:"ogx-toolbar__left",children:p}),a.jsx("div",{className:"ogx-toolbar__spacer"}),a.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&a.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:D,onChange:U}):a.jsx(Gc,{value:D,onChange:U,placeholder:"Search..."})}),u&&a.jsxs("div",{ref:Z,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>_("columns"),isOpen:S,activeCount:e.length-R.size}):a.jsx(Xt,{title:"Columns",children:a.jsx("button",{type:"button",ref:ee,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>_("columns"),children:a.jsx(Bc,{})})}),S&&a.jsx(Vc,{anchorRef:b?Z:ee,columns:e,visibleColumns:R,onVisibilityChange:H,onShowAll:K,onHideAll:B,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>L("columns"),showNonHideableColumns:E})]}),c&&a.jsxs("div",{ref:ce,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[h?h({onClick:()=>_("filters"),isOpen:M,activeCount:W}):a.jsx(Xt,{title:"Filters",children:a.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:[a.jsx(zi,{}),W>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),M&&a.jsx(Kc,{anchorRef:h?ce:ne,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>L("filters")})]}),i&&a.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[a.jsx(Xt,{title:"Pivot",children:a.jsxs("button",{type:"button",ref:J,className:`ogx-toolbar__icon-btn${j?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":j,onClick:()=>_("pivot"),children:[a.jsx(Gi,{}),de&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),j&&a.jsx(Ac,{anchorRef:J,columns:t??e,model:oe,onChange:Q=>{i?.(Q)},onClose:()=>L("pivot")})]}),n&&a.jsxs("div",{ref:ae,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>_("summaries"),isOpen:G,activeCount:O}):a.jsx(Xt,{title:"Summaries",children:a.jsxs("button",{type:"button",ref:z,className:`ogx-toolbar__icon-btn${G?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":G,onClick:()=>_("summaries"),children:[a.jsx(Bi,{}),O>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${O} active summaries`})]})}),G&&a.jsx(zc,{anchorRef:y?ae:z,aggregationModel:o,aggregableColumns:V,onFunctionChange:$,onClearAll:Y,onClose:()=>L("summaries"),activeCount:O})]}),C&&C(),f]})]})}function qc(){const[e]=s.useState(Qr);return s.useRef(e)}const Xc=({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 a.jsxs("div",{className:l,children:[o&&a.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),a.jsx("input",{className:"ogx-input",...i}),n&&a.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 Yc=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 Rc(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 Jc(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Yc.has(r)){t+=n;continue}const i=Rc(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const Qc=[79,70,229],Zc=[255,255,255];function Vi(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 Ki(e,t){return vo(e,t,qt(e,t))}function ji(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function eu(e,t){const o=e.reduce((r,i)=>r+ji(i),0),n={};return e.forEach((r,i)=>{n[i]={cellWidth:ji(r)/o*t}}),n}const tu=new Set(["isEmpty","isNotEmpty"]);function ou(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(tu.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 Ui(e,t,o,n){const r=e.map(l=>"items"in l?Ui(l.items,l.logicOperator,o,!0):ou(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 nu(e,t){const o=[],n=Ui(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 ru=1.15*.3528;async function iu(e,t,o={}){let n,r;try{const[O,$]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);n=O.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:w,filterModel:v,alternateRowColor:p=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:x="#ffffff",fontSize:b=9,groupedRows:h,font:y}=o,C=new n({orientation:d,unit:"mm",format:"a4"}),N=C.internal.pageSize.getWidth(),T=C.internal.pageSize.getHeight(),E=14,I=N-E*2;let F="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"),F=y.name);let G=!1;const j=O=>{if(y)return O;const $=Jc(O);return $.lossy&&(G=!0),$.text},S=(O,$,Y,U,D)=>{const W=C.splitTextToSize(j(O),U);return C.text(W.length===1?W[0]:W,$,Y),Math.max(0,W.length-1)*D*ru},M=st(t),P=Ut(h,u),_=jt(e,u,g);let L=E;if(l){let O=E,$=E+8;if(c)try{C.addImage(c,"PNG",O,E,10,10),O+=14}catch{}const Y=N-E-O;C.setFontSize(16),C.setFont(F,"bold"),C.setTextColor(30,41,59),$+=S(l,O,$,Y,16),$+=6,C.setFontSize(8),C.setFont(F,"normal"),C.setTextColor(100,116,139);const U=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),D=P?h.filter(W=>W.type==="leaf").length:_.length;if(C.text(j(`Exported: ${U} • ${D} row${D!==1?"s":""}`),O,$),$+=5,v){const W=nu(v,t);W&&($+=S(`Filters: ${W}`,O,$,Y,8),$+=5)}C.setDrawColor(226,232,240),C.setLineWidth(.3),C.line(E,$+2,N-E,$+2),L=$+6}const A=[M.map(O=>j(O.headerName??O.field))],X=w||{},z=O=>M.map($=>yn($,X[$.field],O[$.field],O));let J,ee;if(P)J=[],h.forEach(O=>{const $=" ".repeat(O.depth*2);if(O.type==="group-header"){const Y=`${$}${Et(O,t)}`;J.push(M.map((U,D)=>D===0?Y:""))}else if(O.type==="leaf"&&O.row){const Y=O.row;J.push(M.map((U,D)=>(D===0?$:"")+Ki(Y,U)))}else if(O.type==="group-subtotal"&&O.aggregatedValues){const Y=z(O.aggregatedValues);J.push(Y.map((U,D)=>D===0?`${$}${St("Subtotal",U)}`:U))}else O.type==="grand-total"&&O.aggregatedValues&&(ee=[z(O.aggregatedValues).map((U,D)=>D===0?St("Grand Total",U):U)])});else{J=_.map($=>M.map(Y=>Ki($,Y)));const O=w?_t(_,Re(u),t,m,w):null;if(O&&w){const $=M.some(U=>w[U.field]);ee=[z(O).map((U,D)=>D===0&&$?St("TOTAL",U):U)]}}J=J.map(O=>O.map(j)),ee&&(ee=ee.map(O=>O.map(j))),G&&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=eu(M,I),[Z,ce,ae]=Vi(f,Qc),[oe,de,ie]=Vi(x,Zc);r(C,{head:A,body:J,...ee?{foot:ee}:{},startY:L,styles:{fontSize:b,cellPadding:3,font:F,overflow:"linebreak"},headStyles:{fillColor:[Z,ce,ae],textColor:[oe,de,ie],fontStyle:"bold"},...p?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...ee?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:ne,showFoot:ee?"lastPage":"never",showHead:"everyPage",margin:{top:E,left:E,right:E,bottom:E+6}});const V=C.getNumberOfPages();for(let O=1;O<=V;O++)C.setPage(O),C.setFontSize(8),C.setTextColor(150,150,150),C.text(`Page ${O} of ${V}`,N-E,T-8,{align:"right"});C.save(`${i}.pdf`)}function Yt(e,t){const o=qt(e,t);return{text:vo(e,t,o),raw:o}}function Mt(e,t,o){return e.map(n=>yn(n,o[n.field],t[n.field],t))}const lu="\uFEFF";function su(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||{},w=(f,x=!1)=>_o(d?yo(f,x):f,i),v=()=>g.map(f=>w(f.headerName||f.field)).join(i)+`
5
- `;let p="";if(Ut(c,l))r&&(p+=v()),c.forEach(f=>{const x=" ".repeat(f.depth);if(f.type==="group-header"){const b=Et(f,t),h=_o(x+(d?yo(b):b),i);p+=g.map((y,C)=>C===0?h:"").join(i)+`
6
- `}else if(f.type==="leaf"&&f.row){const b=f.row,h=g.map((y,C)=>{const N=Yt(b,y),T=d?yo(N.text,Je(N.raw)):N.text;return _o((C===0?x:"")+T,i)});p+=h.join(i)+`
7
- `}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.aggregatedValues,h=f.type==="grand-total"?"Grand Total":`${x}Subtotal`,y=Mt(g,b,m),C=g.map((N,T)=>T===0?_o(St(h,y[0]),i):w(y[T],Je(b[N.field])));p+=C.join(i)+`
8
- `}});else{const f=jt(e,l,o.getRowId);if(f.length===0){console.warn("No rows to export");return}r&&(p+=v()),f.forEach(b=>{const h=g.map(y=>{const C=Yt(b,y);return w(C.text,Je(C.raw))});p+=h.join(i)+`
9
- `});const x=_t(f,Re(l),t,o.aggregationResult,o.aggregationModel);if(x){const b=g.map(y=>w(m[y.field]?m[y.field].toUpperCase():""));p+=b.join(i)+`
10
- `;const h=Mt(g,x,m);p+=g.map((y,C)=>w(h[C],Je(x[y.field]))).join(i)+`
11
- `}}Sn((u?lu:"")+p,n,"text/csv;charset=utf-8;")}function _o(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
12
- `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const So="ogx-xls-text";function au(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Je(t)}function du(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 cu(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=(x,b=!1)=>Ee(d?yo(x,b):x),w=x=>`<td class="${So}">${x}</td>`;let p=`<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>${Ee(Cn(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${So}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(p+="<thead><tr>",u.forEach(x=>{p+=`<th class="${So}">${m(x.headerName||x.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>";const f=(x,b,h="")=>{const y=h+m(x.text,Je(x.raw));return au(b,x.raw)?w(y):`<td>${y}</td>`};if(Ut(c,l))c.forEach(x=>{const b=" ".repeat(x.depth*2);if(x.type==="group-header")p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${u.length}" class="${So}">${Ee(b)}${m(Et(x,t))}</td>`,p+="</tr>";else if(x.type==="leaf"&&x.row){const h=x.row;p+="<tr>",u.forEach((y,C)=>{p+=f(Yt(h,y),y,C===0?Ee(b):"")}),p+="</tr>"}else if((x.type==="group-subtotal"||x.type==="grand-total")&&x.aggregatedValues){const h=x.aggregatedValues,y=x.type==="grand-total"?"Grand Total":`${b}Subtotal`,C=Mt(u,h,g);p+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((N,T)=>{if(T===0){p+=w(Ee(St(y,C[0])));return}p+=C[T]?`<td style="text-align:right;">${m(C[T],Je(h[N.field]))}</td>`:"<td></td>"}),p+="</tr>"}});else{const x=jt(e,l,o.getRowId);if(x.length===0){console.warn("No rows to export");return}x.forEach(h=>{p+="<tr>",u.forEach(y=>{p+=f(Yt(h,y),y)}),p+="</tr>"});const b=_t(x,Re(l),t,o.aggregationResult,o.aggregationModel);if(b){p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(y=>{p+=g[y.field]?`<td style="text-align:right;font-weight:bold;">${Ee(g[y.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const h=Mt(u,b,g);u.forEach((y,C)=>{p+=h[C]?`<td style="text-align:right;">${m(h[C],Je(b[y.field]))}</td>`:"<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",Sn(p,du(n),"application/vnd.ms-excel")}function uu(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(w=>{m[w.field]=qt(g,w)}),m};let u;if(Ut(l,i)){const g=[],m=[];let w;l.forEach(v=>{if(v.type==="group-header"){const p={group:Et(v,t),field:v.groupField??"",value:v.groupValue,rows:[],children:[]};for(;g.length>v.depth;)g.pop();g.length===0?m.push(p):(g[g.length-1].children??=[]).push(p),g.push(p)}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=Ei(v.aggregatedValues,c),g.pop()):v.type==="grand-total"&&v.aggregatedValues&&(w=Ei(v.aggregatedValues,c))}),u=w?{groups:m,grandTotal:w}:{groups:m}}else{const g=jt(e,i,o.getRowId);if(g.length===0){console.warn("No rows to export");return}const m=g.map(d),w=_t(g,Re(i),t,o.aggregationResult,o.aggregationModel);if(w){const v=o.aggregationModel||{},p={};c.forEach(x=>{v[x.field]&&(p[x.field]=v[x.field].toUpperCase())});const f={};c.forEach(x=>{w[x.field]!==void 0&&w[x.field]!==null&&(f[x.field]=w[x.field])}),u={data:m,aggregation:{labels:p,values:f}}}else u=m}Sn(r?JSON.stringify(u,null,2):JSON.stringify(u),n,"application/json;charset=utf-8;")}const fu=/^(?:https?:|data:image\/|blob:)/i,gu=/^[a-z][a-z\d+.-]*:/i;function pu(e){const t=e.trim();return t?fu.test(t)?t:gu.test(t)?null:t:null}async function hu(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(`
3
+ `).forEach(Z=>console.warn(Z))},[y]);const S=r&&!n;s.useEffect(()=>{process.env.NODE_ENV==="production"||!S||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.")},[S]);const N=s.useMemo(()=>g==="server"?null:go(l,u),[g,l,u]),T=s.useMemo(()=>ja(v,N),[v,N]),E=`${r}|${i}`,[I,F]=s.useState(()=>({configKey:E,overrides:new Map})),G=I.configKey===E?I.overrides:oi,H=s.useCallback(Z=>((Z?.children?.length??0)>0||(Z?.serverChildrenCount??0)>0)&&(i===-1||(Z?.depth??0)<i),[i]),_=s.useMemo(()=>{const Z=new Set;return x&&p.forEach((oe,ie)=>{(G.get(ie)??H(oe))&&Z.add(ie)}),Z},[x,p,G,H]),M=s.useCallback(Z=>{const oe=!_.has(Z);if(F(ie=>{const te=ie.configKey===E?ie.overrides:oi,ue=new Map(te);return ue.set(Z,oe),{configKey:E,overrides:ue}}),oe&&c){const ie=p.get(Z);ie&&c(ie)}},[_,E,p,c]),P=w!=="server"&&!!(d&&d.length>0),C=s.useCallback(Z=>{if(!x)return null;const oe=Z?.labelField,ie=Z?.expandAll??!1,{visible:te,visibleChildren:ue}=T,de=P&&d?d:[],re=(ee,J)=>{if(b.has(ee))return{value:J.field===oe?p.get(ee)?.label:void 0};const Y=h.get(ee),Q=u?.byField.get(J.field),z=Y?Fe(Y,J.field,Q):void 0,q=Q?.sortComparator;return{value:z,type:Q?.type,comparator:q,params:q&&Y?{id:ee,field:J.field,row:Y,value:z}:void 0}},ce=[],le=new Set,D=ee=>{const J=ee.filter(Q=>te.has(Q)),Y=de.length>0?nn(J,de,re):J;for(const Q of Y){if(le.has(Q))continue;const z=h.get(Q);if(!z)continue;le.add(Q),ce.push(z);const q=ue.get(Q);q&&q.length>0&&(ie||_.has(Q))&&D(q)}};return D(f),ce},[x,T,P,d,b,p,h,u,f,_]),L=s.useCallback(Z=>_.has(Z),[_]),O=s.useCallback(Z=>p.get(Z),[p]),j=s.useCallback(Z=>{const oe=[];let ie=Z;for(;ie!==null;){const te=p.get(ie);if(!te)break;oe.unshift(te.groupingKey),ie=te.parentId}return oe},[p]),W=s.useMemo(()=>{const Z=new Map,{visibleChildren:oe,descendantCounts:ie}=T;return p.forEach((te,ue)=>{const de=(te.children?.length??0)===0&&(te.serverChildrenCount??0)>0,re=b.has(ue),ce={hasChildren:(oe.get(ue)?.length??0)>0||de,treeDepth:te.depth,descendantCount:de?void 0:ie.get(ue)??0,isGroupRow:re,isExpanded:_.has(ue)};re&&(ce.groupLabel=te.label),Z.set(ue,ce)}),Z},[p,b,T,_]);return s.useMemo(()=>({treeNodes:p,groupingRows:m,toggleExpansion:M,isGroupExpanded:L,getVisibleRows:C,getNode:O,getNodePath:j,rowMetaMap:W}),[p,m,M,L,C,O,j,W])}const li=e=>e===null?"footer":"inline";function si(e,t){return lo(()=>e(t),li(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Xa(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?lo(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Ra=[],Ya={},ai=new Map,We="";function Ja(e){if(typeof e=="string")return e;if(e===null)return`${We}null`;if(e===void 0)return`${We}undefined`;if(e instanceof Date)return`${We}date:${e.getTime()}`;if(typeof e=="object")try{return`${We}object:${JSON.stringify(e)}`}catch{return`${We}object:${String(e)}`}return`${We}${typeof e}:${String(e)}`}const Qa=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,Za=e=>`${e}${We}footer`,ec=e=>e==="footer"?"f":e===null?"n":"i",tc=e=>e==="f"?"footer":e==="n"?null:"inline";function oc(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Ra,aggregationModel:i=Ya,defaultGroupingExpansionDepth:l=0,filterModel:d,sortModel:c,getAggregationPosition:u=li,columnLookup:g,filterMode:w="client",sortingMode:x="client"}=e,v=r.join(We),p=s.useMemo(()=>v===""?[]:v.split(We),[v]),f=JSON.stringify(Object.entries(i)),m=s.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),b=Object.keys(m).length>0,h=s.useMemo(()=>{const D=new Map;return(n??[]).forEach(ee=>D.set(ee.field,ee)),D},[n]),y=p.length>0,S=s.useMemo(()=>p.filter(D=>h.get(D)?.groupable!==!1),[p,h]),T=`${S.join(We)}|${l}`,[E,I]=s.useState(()=>({configKey:T,overrides:new Map})),F=E.configKey===T?E.overrides:ai,G=s.useMemo(()=>{if(!y||w==="server")return null;const D=go(d,g);return D?new Set(t.filter(ee=>D(ee))):null},[y,t,w,d,g]),H=s.useMemo(()=>{const D=new Map,ee=[],J=[],Y=new Map,Q=new Map,z=new Map;if(!y)return{treeNodes:D,rootIds:ee,groupIds:J,groupRowVariants:Y,groupingRows:Q,rowLookup:z};const q=(X,$,B)=>{if($>=S.length)return(G?X.filter(V=>G.has(V)):X).map(V=>{const ne=o(V);return z.set(ne,V),D.set(ne,{id:ne,parentId:B,depth:$,groupingKey:"",isExpanded:!1}),ne});const A=S[$],R=h.get(A),k=new Map;for(const U of X){const V=Fe(U,A,R),ne=Ja(V);let fe=k.get(ne);fe||(fe={value:V,rows:[]},k.set(ne,fe)),fe.rows.push(U)}const K=[];return k.forEach((U,V)=>{const ne=G?U.rows.filter(ye=>G.has(ye)):U.rows;if(ne.length===0)return;const fe=Qa(A,V,B);K.push(fe),J.push(fe);const pe=b?uo(ne,m,h,"useRowGrouping"):{},he={[A]:U.value,...pe,id:fe},ge={[A]:U.value,id:fe},be=b?{...pe,id:Za(fe)}:null;Y.set(fe,{inline:he,bare:ge,footer:be}),Q.set(fe,he),be&&Q.set(be.id,be);const ve={id:fe,parentId:B,depth:$,groupingKey:String(U.value),groupingField:A,groupingValue:U.value,aggregatedValues:pe,isExpanded:!1,children:[],label:Xa(R,A,U.value),descendantCount:ne.length};D.set(fe,ve),ve.children=q(U.rows,$+1,fe)}),K};return ee.push(...q(t,0,null)),{treeNodes:D,rootIds:ee,groupIds:J,groupRowVariants:Y,groupingRows:Q,rowLookup:z}},[y,t,G,S,b,m,o,h]),{treeNodes:_,rootIds:M,groupIds:P,groupRowVariants:C,groupingRows:L,rowLookup:O}=H,j=s.useCallback(D=>!!(D?.children&&D.children.length>0)&&(l===-1||(D?.depth??0)<l),[l]),W=s.useMemo(()=>{const D=new Set;return _.forEach((ee,J)=>{!ee.children||ee.children.length===0||(F.get(J)??j(ee))&&D.add(J)}),D},[_,F,j]),Z=s.useCallback(D=>{I(ee=>{const J=ee.configKey===T?ee.overrides:ai,Y=J.get(D)??j(_.get(D)),Q=new Map(J);return Q.set(D,!Y),{configKey:T,overrides:Q}})},[T,_,j]),oe=s.useCallback(D=>W.has(D),[W]),ie=b?P.map(D=>{const ee=_.get(D);return ee?ec(si(u,{...ee,isExpanded:W.has(D)})):"i"}).join(""):"",te=s.useMemo(()=>{const D=new Map;return P.forEach((ee,J)=>D.set(ee,tc(ie[J]))),D},[P,ie]),ue=b?si(u,null):"footer",de=x!=="server"&&!!(c&&c.length>0),re=s.useCallback(D=>{if(!y)return null;const ee=D?.labelField,J=D?.expandAll??!1,Y=de&&c?c:[],Q=($,B)=>{const A=_.get($),R=C.get($);if(A&&R){const ne=A.groupingField??"";if(B.field===ne||B.field===ee){const fe=g?.byField.get(ne),pe=fe?.sortComparator;return{value:A.groupingValue,type:fe?.type,comparator:pe,params:pe?{id:$,field:ne,row:R.inline,value:A.groupingValue}:void 0}}return A.aggregatedValues&&Object.prototype.hasOwnProperty.call(A.aggregatedValues,B.field)?{value:A.aggregatedValues[B.field],type:g?.byField.get(B.field)?.type}:{value:void 0}}const k=O.get($),K=g?.byField.get(B.field),U=k?Fe(k,B.field,K):void 0,V=K?.sortComparator;return{value:U,type:K?.type,comparator:V,params:V&&k?{id:$,field:B.field,row:k,value:U}:void 0}},z=[],q=new Set,X=$=>{const B=Y.length>0?nn($,Y,Q):$;for(const A of B){if(q.has(A))continue;q.add(A);const R=C.get(A);if(!R){const ne=O.get(A);ne&&z.push(ne);continue}const k=_.get(A),K=W.has(A),U=te.has(A)?te.get(A)??null:"inline",V=U==="inline"||U==="footer"&&!K;z.push(V?R.inline:R.bare),(K||J)&&k?.children&&(X(k.children),K&&!J&&U==="footer"&&R.footer&&z.push(R.footer))}};return X(M),z},[y,de,c,_,C,O,g,W,te,M]),ce=s.useCallback(D=>_.get(D),[_]),le=s.useMemo(()=>{const D=new Map;return _.forEach((ee,J)=>{const Y=C.get(J);if(!Y){D.set(J,{hasChildren:!1,treeDepth:ee.depth,isGroupRow:!1});return}const Q={hasChildren:!0,treeDepth:ee.depth,groupingField:ee.groupingField,groupingValue:ee.groupingValue,groupLabel:ee.label,descendantCount:ee.descendantCount,isGroupRow:!0,isExpanded:W.has(J)};D.set(J,Q),Y.footer&&te.get(J)==="footer"&&D.set(Y.footer.id,{...Q,hasChildren:!1,treeDepth:ee.depth+1,isExpanded:void 0,isGroupFooter:!0})}),D},[_,C,W,te]);return s.useMemo(()=>({treeNodes:_,groupingRows:L,toggleExpansion:Z,isGroupExpanded:oe,getVisibleRows:re,getNode:ce,rowMetaMap:le,aggregationPositions:te,rootAggregationPosition:ue}),[_,L,Z,oe,re,ce,le,te,ue])}const nc=new Map;function rc(e){const{rows:t,getRowId:o,getTreeDataPath:n,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:d,isRowGrouping:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:w,sortModel:x,getAggregationPosition:v,columnLookup:p,filterMode:f,sortingMode:m}=e,b=qa({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:w,sortModel:x,columnLookup:p,filterMode:f,sortingMode:m}),h=oc({rows:t,getRowId:o,columns:l,rowGroupingModel:d,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:w,sortModel:x,getAggregationPosition:v,columnLookup:p,filterMode:f,sortingMode:m}),y=i?b:c?h:null,S=s.useMemo(()=>i?b.rowMetaMap:c?h.rowMetaMap:nc,[i,b.rowMetaMap,c,h.rowMetaMap]);return{treeDataHandlers:b,rowGroupingHandlers:h,activeHierarchyHandlers:y,rowMetaMap:S}}const yt=Promise.resolve();class ci extends Error{}function bo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function ic(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function lc(e){const[t,o]=s.useState(null),n=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),d=s.useRef(!1),c=s.useRef(e);s.useLayoutEffect(()=>{c.current=e}),s.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const u=s.useCallback(p=>{n.current=p,o(p)},[]),g=s.useCallback((p,f)=>{const m=i.current.get(p);if(m)return bo(m.value,f.value)?m.promise:m.promise.then(()=>{const L=n.current;if(!(r.current!==p||!L||bo(L.value,m.value)))return g(p,L)});const b=()=>r.current===p&&n.current!==null;if(bo(f.value,f.originalValue))return b()&&u(null),yt;const{rows:h,getRowId:y,columns:S,processRowUpdate:N}=c.current,T=h.find(L=>y(L)===f.id);if(!T)return b()&&u(null),yt;const E=L=>{const O=c.current.onProcessRowUpdateError;O?O(L):process.env.NODE_ENV!=="production"&&L instanceof ci&&console.error(L.message)},I=L=>{if(typeof L!="object"||L===null){E(new ci(`[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}c.current.onRowChange?.(L,f.id);const O=n.current;r.current!==p||!O||(bo(O.value,f.value)?u(null):u({...O,originalValue:f.value}))};let F,G;const H=new Promise((L,O)=>{F=L,G=O}),_={value:f.value,promise:H};i.current.set(p,_);const M=()=>{i.current.get(p)===_&&i.current.delete(p)};let P;try{const L=S?.find(j=>j.field===f.field),O=sc(T,f,L,l.current);P=N?N(O,T):O}catch(L){return M(),E(L),F(),H}const C=L=>{M();try{I(L),F()}catch(O){G(O)}};return ic(P)?Promise.resolve(P).then(C,L=>{M(),E(L),F()}):C(P),H},[u]),w=s.useCallback(p=>{const f=n.current;if(f){if(f.id===p.id&&f.field===p.field)return;g(r.current,f)}r.current+=1,u({id:p.id,field:p.field,value:p.value,originalValue:p.value})},[g,u]),x=s.useCallback(p=>{const f=n.current;return!f||!d.current||p?.id!==void 0&&p.id!==f.id||p?.field!==void 0&&p.field!==f.field?yt:p?.cancel?(u(null),yt):g(r.current,f)},[g,u]),v=s.useCallback(p=>{const f=n.current;!f||f.id!==p.id||f.field!==p.field||u({...f,value:p.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:w,stopCellEdit:x,setEditCellValue:v}),[t,w,x,v])}function sc(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 ac=e=>e.id,cc={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},di="\0",ui="";function fi(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 dc(e){return e.map(t=>t.field).join(di)}function uc(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:d,expandedRowIds:c,rowMetaMap:u,getRowId:g=ac}=e,w=s.useMemo(()=>r.some(b=>b.colSpan!==void 0&&b.colSpan!==null),[r]),x=s.useMemo(()=>r.some(b=>b.rowSpan!==void 0&&b.rowSpan!==null),[r]),v=w||x,p=v?[i,l,d].map(dc).join(ui):"",f=s.useMemo(()=>{if(!p)return{columns:[],leftCount:0,unpinnedCount:0};const b=new Map(r.map(N=>[N.field,N])),h=p.split(ui).map(N=>N?N.split(di):[]),y=[];let S=0;for(const N of h){S+=N.length;for(const T of N){const E=b.get(T)??{field:T};y.push({colDef:E,field:T,sectionEnd:S,hasColSpan:E.colSpan!==void 0&&E.colSpan!==null,hasRowSpan:E.rowSpan!==void 0&&E.rowSpan!==null})}}return{columns:y,leftCount:h[0].length,unpinnedCount:h[1].length}},[p,r]),m=s.useMemo(()=>{if(!v||f.columns.length===0)return null;const b={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:f,expandedRowIds:c,rowMetaMap:u,getRowId:g,warned:new Set,out:b};return wn(t,0,!1,y),wn(o,t.length,!0,y),wn(n,t.length+o.length,!1,y),b},[v,f,t,o,n,c,u,g]);return s.useMemo(()=>{if(!m)return cc;const{colspanMap:b,rowSpanningCaches:h,hiddenOriginFields:y,unpinnedRanges:S,centerRowSpanStart:N}=m,T=f.columns;return{hasColSpan:w,hasRowSpan:x,colspanMap:b,rowSpanningCaches:h,getSpanOrigin:(E,I)=>{const F=b.get(E)?.[I];if(F?.spannedByColSpan)return{rowId:E,field:T[F.leftVisibleCellIndex].field};const G=h.hiddenCellOriginMap[E]?.[I];return G===void 0?null:{rowId:G,field:y.get(E)?.[I]??I}},getUnpinnedColSpanRanges:E=>S.get(E),getCenterRowSpanStart:E=>N.get(E)??E}},[m,w,x,f])}function wn(e,t,o,n){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:d,warned:c,out:u}=n,{columns:g,leftCount:w,unpinnedCount:x}=r,v=g.length,{colspanMap:p,rowSpanningCaches:f,hiddenOriginFields:m,unpinnedRanges:b,centerRowSpanStart:h}=u,y=new Int32Array(v),S=new Array(v),N=new Array(v),T=new Int32Array(v);let E=0;const I=[];g.forEach((H,_)=>{(H.hasColSpan||H.hasRowSpan)&&I.push(_)});const F=(H,_,M)=>{const P=g[M].field;if(Ct(f.hiddenCells,H,P,!0),Ct(f.hiddenCellOriginMap,H,P,S[M]),N[M]!==P&&Ct(m,H,P,N[M]),o){const C=h.get(_);(C===void 0||T[M]<C)&&h.set(_,T[M])}},G=(H,_,M)=>{const P=g[M],C=d(H),L=fc(H,C,P.colDef,t+_,M,l,c);let O=1;if(P.hasColSpan){const W=Math.min(gi(P.colDef.colSpan,L,"colSpan",P.field,c),P.sectionEnd-M);for(;O<W&&y[M+O]<=_;)O++}let j=1;if(P.hasRowSpan){j=Math.min(gi(P.colDef.rowSpan,L,"rowSpan",P.field,c),e.length-_);for(let W=1;W<j;W++)if(Xe(d(e[_+W]),l)){j=W;break}if(j>1&&i&&i.size>0){for(let W=0;W<j-1;W++)if(i.has(d(e[_+W]))){j=W+1;break}}}if(O>1){Ct(p,C,P.field,{spannedByColSpan:!1,cellProps:{colSpan:O}});for(let W=1;W<O;W++){const Z=g[M+W];Ct(p,C,Z.field,{spannedByColSpan:!0,leftVisibleCellIndex:M,rightVisibleCellIndex:M+O-1})}if(M>=w&&M<w+x){let W=b.get(C);W||(W=[],b.set(C,W)),W.push(M-w,M+O-1-w)}}if(j>1){Ct(f.spannedCells,C,P.field,j);for(let W=M;W<M+O;W++)y[W]=_+j,S[W]=C,N[W]=P.field,T[W]=_;_+j>E&&(E=_+j)}return O};for(let H=0;H<e.length;H++){const _=e[H];if(!_||_._isSkeleton||Xe(d(_),l))continue;if(E<=H){let P=0;for(const C of I)C>=P&&(P=C+G(_,H,C));continue}let M=0;for(;M<v;)y[M]>H?(F(d(_),H,M),M++):g[M].hasColSpan||g[M].hasRowSpan?M+=G(_,H,M):M++}}function fc(e,t,o,n,r,i,l){const d=e[o.field];let c=d;if(o.valueGetter)try{c=o.valueGetter({row:e,field:o.field,value:d})}catch(u){pi(l,`valueGetter:${o.field}`,`valueGetter for column "${o.field}" threw while computing its span`,u),c=void 0}return{row:e,value:c,field:o.field,colDef:o,rowIndex:n,colIndex:r,rowMeta:i?.get(t)}}function gi(e,t,o,n,r){if(typeof e=="number")return fi(e);if(typeof e!="function")return 1;try{return fi(e(t))}catch(i){return pi(r,`${o}:${n}`,`${o} for column "${n}" threw; the cell is rendered without a span`,i),1}}function pi(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 gc(e){const{spanning:t,renderContext:o,offsetTop:n,cumulativeHeights:r}=e;return s.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 pc(e){const{spanning:t,firstColumnIndex:o,lastColumnIndex:n,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let d=o,c=n,u=!0;for(;u;){u=!1;for(const{row:b,id:h}of l){const y=t.getUnpinnedColSpanRanges(h??b.id);if(y)for(let S=0;S<y.length;S+=2){const N=y[S],T=y[S+1];T<d||N>c||(N<d&&(d=N,u=!0),T>c&&(c=T,u=!0))}}}if(d===o&&c===n)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:w,rightPinnedCols:x,unpinnedAccWidths:v,unpinnedTotalWidth:p}=i,f=d>0?v[d-1]:0,m=p-v[c];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...w.slice(d,c+1),...m>0?[{field:"__spacer_right__",width:m,isSpacer:!0}]:[],...x]},[t,o,n,r,i,l])}function hc(e,t){const{draggedColumn:o,onDragOver:n,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const d=c=>o===null||hn(e,o,c);return{onDragOver:n&&(c=>d(c)?n(c):()=>{}),onDrop:r&&(c=>d(c)?r(c):u=>{u.preventDefault(),i?.()})}},[e,o,n,r,i]);return l?{...t,...l}:t}const wc=300,hi=e=>e.id;function mc(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function wi(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 mi(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 xc(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:d,aggregationModel:c,rowGroupingActive:u=!1}=e,g=mc(i,u),w=!!t&&i==="server"&&u,x=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!w||(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."))},[w]);const v=t?.getRows,p=Ur({dataSource:t,paginationMode:i,sortingMode:l,filterMode:d}),f=JSON.stringify([g,g!=="all"||l==="server"?o:null,g!=="all"||d==="server"?n:null,p?c??null:null,g==="all"?null:r.pageSize]),m=g==="all"?0:r.page,b=g==="all"?0:r.pageSize,h=s.useRef({params:e,kind:g});s.useLayoutEffect(()=>{h.current={params:e,kind:g}});const y=s.useRef(0),S=s.useRef(0),N=s.useRef(null),T=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),E=s.useRef(null),I=s.useRef(!1),F=s.useRef(0),G=s.useRef(!1),H=s.useRef(new Set),_=s.useCallback(()=>{const Z=I.current||F.current>0;Z!==G.current&&(G.current=Z,h.current.params.setDataSourceLoading(Z))},[]),M=s.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),P=s.useCallback(()=>{y.current++,T.current.inFlightEnd=null,I.current=!1},[]),C=s.useCallback(()=>{S.current++,H.current.clear(),F.current=0},[]),L=s.useCallback(async()=>{const{params:Z,kind:oe}=h.current,ie=Z.dataSource;if(!ie)return!1;const te=T.current,ue=Z.paginationModel.pageSize;let de,re;if(oe==="infinite"){if(te.inFlightEnd!==null)return!1;if(de=te.loadedEnd,re=(te.page+1)*ue,re<=de)return I.current=!1,_(),!1;te.inFlightEnd=re}else oe==="page"?(de=Z.paginationModel.page*ue,re=de+ue):(de=0,re=jr);const ce=++y.current;I.current=!0,_(),Z.setDataSourceError(null);let le;try{le=await ie.getRows({startRow:de,endRow:re,sortModel:Z.sortModel,filterModel:Z.filterModel,groupKeys:[],aggregationModel:Z.aggregationModel})}catch(D){return ce!==y.current||(te.inFlightEnd=null,I.current=!1,h.current.params.setDataSourceError(D),console.error("Data Source Error:",D),_()),!1}if(ce!==y.current)return!1;try{const{params:D}=h.current,ee=D.getRowId??hi,J=wi(le.rows,ee);if(oe==="infinite"&&de>0?D.setRows(Y=>mi(Y,J,ee),!0):(D.setRows(J.map(Y=>Y.row),!0),C()),le.aggregationResults&&D.onAggregationResults?.(le.aggregationResults),le.rowCount!==void 0&&D.setRowCount(le.rowCount),oe==="infinite"&&(te.inFlightEnd=null,te.loadedEnd=de+le.rows.length,le.rows.length>=re-de&&(te.page+1)*ue>re))return!0}catch(D){return te.inFlightEnd=null,I.current=!1,h.current.params.setDataSourceError(D),console.error("Data Source Error:",D),_(),!1}return I.current=!1,_(),!1},[_,C]),O=s.useCallback(async()=>{for(;await L(););},[L]);s.useLayoutEffect(()=>{if(!v){N.current&&(N.current=null,M(),P(),C(),h.current.params.setDataSourceError(null),_());return}const Z=N.current,oe=T.current;if(!Z||Z.key!==f||Z.getRows!==v){N.current={key:f,getRows:v},P(),C();const ie=g==="infinite"&&Z!==null&&m!==0;if(oe.page=ie?0:m,oe.loadedEnd=0,ie){const{params:te}=h.current;te.onPaginationModelChange?.({...te.paginationModel,page:0})}}else g==="infinite"?(m<oe.page&&(P(),oe.loadedEnd=0),oe.page=m):P();if(g==="infinite"){const ie=oe.inFlightEnd!==null;if(ie||(oe.page+1)*b<=oe.loadedEnd){I.current=ie,_();return}}return I.current=!0,_(),E.current=setTimeout(()=>{E.current=null,O()},wc),M},[v,f,g,m,b,M,P,C,_,O]),s.useEffect(()=>()=>{P(),C()},[P,C]);const j=s.useCallback(()=>(M(),O()),[M,O]),W=s.useCallback(async(Z,oe,ie)=>{const{params:te}=h.current,ue=te.dataSource;if(!ue)return;const de=JSON.stringify(oe),re=H.current;if(re.has(de))return;const ce=S.current;re.add(de),F.current++,_();try{const le=await ue.getRows({startRow:0,endRow:jr,sortModel:te.sortModel,filterModel:te.filterModel,groupKeys:oe,aggregationModel:te.aggregationModel});if(ce!==S.current)return;if(le.rows.length>0){const{params:D}=h.current,ee=D.getRowId??hi,J=wi(le.rows,ee);D.setRows(Y=>mi(Y,J,ee),!0)}}catch(le){if(ce!==S.current)return;re.delete(de),console.error("Failed to fetch children:",le),ie?.(le)}finally{ce===S.current&&(F.current--,_())}},[_]);return{fetchRows:j,fetchChildren:W}}function bc(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function vc({enabled:e,treeNodes:t,isGroupExpanded:o,getNodePath:n,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:o,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:o,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((d,c)=>{!bc(d)||!o(c)||i(c,n(c),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(c)&&g(c)})})},[e,t,o,n,i])}const xi={};function yc(e){const t=JSON.stringify(e),[o,n]=s.useState(null),r=s.useCallback(i=>n({modelKey:t,results:i}),[t]);return[o&&o.modelKey===t?o.results:null,r]}function bi(e){const{rows:t,columns:o,aggregationModel:n,isServerSide:r,dataSource:i,filterModel:l,sortModel:d,serverAggregationResults:c}=e,u=Object.keys(n).length>0,g=s.useMemo(()=>{const N=new Map;return(o??[]).forEach(T=>N.set(T.field,T)),N},[o]),w=s.useMemo(()=>r||!u?xi:uo(t,n,g,"useAggregation"),[t,g,n,r,u]),x=JSON.stringify([n,l??null,d??[]]),v=r&&u&&!!i?.getAggregations&&!c,p=s.useRef({aggregationModel:n,filterModel:l,sortModel:d});s.useEffect(()=>{p.current={aggregationModel:n,filterModel:l,sortModel:d}});const[f,m]=s.useState(null);s.useEffect(()=>{const N=i?.getAggregations;if(!v||!N)return;let T=!1;const E=p.current;let I;try{I=Promise.resolve(N({sortModel:E.sortModel??[],filterModel:E.filterModel??{items:[]},groupKeys:[],aggregationModel:E.aggregationModel}))}catch(F){I=Promise.reject(F)}return I.then(F=>{T||m({key:x,result:F,error:null})},F=>{T||(console.error("[useAggregation] Server aggregation error:",F),m({key:x,result:null,error:F}))}),()=>{T=!0}},[v,i,x]);const b=f&&f.key===x?f:null,h=v&&b===null,y=v?b?.error??null:null;return{aggregationResult:s.useMemo(()=>r?c&&Object.keys(c).length>0?c:b?.result??xi:w,[r,w,c,b]),isLoading:h,error:y}}const Cc={items:[]},_c=[];function Sc(e){const{rows:t,columns:o,pivotMode:n,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:d,hierarchyRequested:c}=e,u=n&&!d,g=s.useMemo(()=>new Set(o.map(b=>b.field)),[o]),w=s.useMemo(()=>rn(o),[o]),x=s.useMemo(()=>us(i,g),[i,g]),v=s.useMemo(()=>u?Zo(t,x.source,w):t,[u,t,x.source,w]),p=s.useMemo(()=>u?_r(v,o,r,{outputFilterModel:x.output,sortModel:l}):sn,[u,v,o,r,x.output,l]),f=u&&p.isValid,m=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&d&&!m.current.dataSource&&(m.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),f&&c&&!m.current.hierarchy&&(m.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[n,d,f,c]),{isActive:f,rows:f?p.pivotRows:t,columns:f?p.pivotColumns:o,pipelineFilterModel:f?Cc:i,pipelineSortModel:f?_c:l}}const Vt=({variant:e="text",size:t="medium",color:o="default",disabled:n=!1,className:r="",type:i="button",children:l,...d})=>{const c=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${o}`,n&&"ogx-button--disabled",r].filter(Boolean).join(" ");return a.jsx("button",{type:i,className:c,disabled:n,...d,children:l})};function mn(e){const t=s.useId(),{page:o,pageSize:n,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:d=[10,25,50,100],showFirstButton:c=!0,showLastButton:u=!0,localeText:g}=e,w=ho(n),x=cn(r,w),v=Lr(o,x),p=d.includes(w)?d:[...d,w].sort((_,M)=>_-M),f=v*w,m=Math.min(f+w,r),b=r===0?0:`${f+1}–${m}`,h=g?.paginationRowsPerPage??"Rows per page:",y=g?.paginationOf?g.paginationOf(r===0?0:f+1,m,r):`${b} of ${r}`,S=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))},I=()=>{i(x-1)},F=_=>{const M=parseInt(_.target.value,10);l(M)},G=v===0,H=v>=x-1;return a.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[a.jsxs("div",{className:"ogx-pagination__page-size",children:[a.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:h}),a.jsx("select",{id:t,className:"ogx-pagination__select",value:w,onChange:F,children:p.map(_=>a.jsx("option",{value:_,children:_},_))})]}),a.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),a.jsxs("div",{className:"ogx-pagination__actions",children:[c&&a.jsx(Vt,{variant:"text",size:"small",onClick:N,disabled:G,"aria-label":"Go to first page",title:"First page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),a.jsx(Vt,{variant:"text",size:"small",onClick:T,disabled:G,"aria-label":"Go to previous page",title:"Previous page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),a.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:S}),a.jsx(Vt,{variant:"text",size:"small",onClick:E,disabled:H,"aria-label":"Go to next page",title:"Next page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&a.jsx(Vt,{variant:"text",size:"small",onClick:I,disabled:H,"aria-label":"Go to last page",title:"Last page",children:a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function kc({row:e,rowId:t,rowIndex:o,ariaRowIndex:n,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:d=!1,checkboxSelection:c=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:w,onSelectionChange:x,tabIndex:v=-1,onFocus:p,onToggleExpansion:f}){const m=t??e.id,b=r.field,h=Fe(e,b,i),y=Vo(e,b,h,i)??Ko(h,i),S=l?.isGroupRow===!0||Xe(m),N={row:e,value:h,formattedValue:y,field:b,colDef:i??r,rowIndex:o,colIndex:0,rowMeta:l},T=E=>{E.stopPropagation(),x?.(m,E.target.checked)};return a.jsxs("div",{className:`ogx-list-view__row${d?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:w?()=>w(e):void 0,role:"row","aria-rowindex":n??o+1,"aria-selected":d,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":o,tabIndex:v,onFocus:p?E=>{E.target===E.currentTarget&&p(o)}:void 0,children:[c&&a.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!S&&a.jsx("input",{type:"checkbox",checked:d,onChange:T,"aria-label":`Select row ${m}`,tabIndex:-1})}),l&&f&&a.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&a.jsx(fn,{isExpanded:l.isExpanded===!0,onClick:()=>f(m),tabIndex:-1})}),a.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:a.jsx(lt,{field:b,resetKey:e,renderFn:()=>{const E=r.renderCell(N);return E===void 0&&S?l?.groupLabel:E}})})]})}function Ec(e,t){const o=s.useRef(!0),n=s.useRef(e);s.useEffect(()=>{n.current=e},[e]),s.useEffect(()=>{o.current=!0},[t]);const r=s.useCallback(i=>{const l=$r(i.currentTarget);if(!l){o.current=!0;return}if(!o.current)return;const d=n.current;d&&(o.current=!1,d(l))},[]);return e?r:void 0}const Mc=e=>e.id;function Nc({ariaLabel:e,allRenderableRows:t,dataRowCount:o,pinnedTopRowCount:n,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:d,currentPage:c,pageSizeOptions:u,selectedRowIds:g,listViewColumn:w,columnsByField:x,rowMetaMap:v,noRowsLabel:p,rowHeight:f,checkboxSelection:m,paginationMode:b,serverRowCount:h,paginationSlot:y,paginationSlotProps:S,localeText:N,onRowClick:T,onRowDoubleClick:E,onSelectionChange:I,onPaginationModelChange:F,onRowsScrollEnd:G,getRowId:H=Mc,multiselectable:_=!1,loading:M=!1,loadingOverlay:P,noRowsOverlay:C,showPaginationControls:L=!0,selectable:O=!1,onToggleExpansion:j}){const W=y||mn,Z=s.useRef(null),[oe,ie]=s.useState(null),te=oe===null?-1:t.findIndex(X=>H(X)===oe),ue=te===-1?0:te,de=X=>{const $=t[X];$&&(ie(H($)),Z.current?.querySelector(`:scope > [role="row"][data-rowindex="${X}"]`)?.focus())},re=X=>{const $=X.target;if($.getAttribute("role")!=="row"||$.parentElement!==Z.current)return;const B=Number($.getAttribute("data-rowindex")),A=t[B];if(!A)return;const R=H(A),k=t.length-1,K=v.get(R),U=!!(K?.hasChildren&&j);if(X.altKey&&(X.key==="ArrowRight"||X.key==="ArrowLeft")){X.preventDefault(),U&&X.key==="ArrowRight"!=(K?.isExpanded===!0)&&j?.(R);return}switch(X.key){case"ArrowDown":X.preventDefault(),de(Math.min(B+1,k));return;case"ArrowUp":X.preventDefault(),de(Math.max(B-1,0));return;case"Home":X.preventDefault(),de(0);return;case"End":X.preventDefault(),de(k);return;case"PageDown":X.preventDefault(),de(Math.min(B+10,k));return;case"PageUp":X.preventDefault(),de(Math.max(B-10,0));return;case"Enter":case" ":if(X.preventDefault(),X.key===" "&&X.shiftKey){O&&!K?.isGroupRow&&I(R,!g.has(R));return}U?j?.(R):T({row:A,id:R,rowIndex:B});return}},ce=b==="server",le=ce?h||0:i,D=ce?h||0:o,ee=ho(d.pageSize),J=cn(le,ee),Y=l?c*ee:0,Q=t.length-n-r,z=X=>{if(X<n)return X+1;const $=X-n;return $<Q?n+Y+$+1:n+le+($-Q)+1},q=Ec(G,t.length);return a.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":D,"aria-multiselectable":_,children:[a.jsx("div",{className:"ogx-list-view__toolbar",children:a.jsxs("span",{children:[D," ",D===1?"item":"items",l?` · page ${c+1} of ${J}`:"",g.size>0?` · ${g.size} selected`:""]})}),a.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:q,onKeyDown:re,ref:Z,children:t.length===0&&M?a.jsx("div",{className:"ogx-list-view__loading",children:P??a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&C?a.jsx("div",{className:"ogx-list-view__empty",children:C}):t.length===0?a.jsxs("div",{className:"ogx-list-view__empty",children:[a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),a.jsx("path",{d:"M3 9h18M9 21V9"})]}),p]}):t.map((X,$)=>{const B=H(X);return a.jsx(kc,{row:X,rowId:B,rowIndex:$,ariaRowIndex:z($),listViewColumn:w,gridColumn:x.get(w.field),rowMeta:v.get(B),isSelected:g.has(B),checkboxSelection:m,rowHeight:f,onRowClick:A=>T({row:A,id:B,rowIndex:$}),onRowDoubleClick:E?A=>E({row:A,id:B,rowIndex:$}):void 0,onSelectionChange:I,tabIndex:$===ue?0:-1,onToggleExpansion:j,onFocus:A=>ie(H(t[A]))},B)})}),l&&L&&a.jsx(W,{page:c,pageSize:d.pageSize,rowCount:le,pageSizeOptions:u,onPageChange:X=>F({...d,page:X}),onPageSizeChange:X=>F({...d,pageSize:X,page:0}),localeText:N,...S})]})}function Pc({overlay:e}){return e?a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):a.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:a.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function Kt(e){return e.headerName||e.field}function Ic(e){return e.nativeEvent.isComposing||e.keyCode===229}function Ut(e,t,o=!0){return n=>{if(Ic(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function Tc({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=s.useState(String(e??"")),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),a.jsx("input",{ref:d,type:"text",className:"ogx__edit-input","aria-label":Kt(t),value:i,onChange:c=>{l(c.target.value),o(c.target.value)},onBlur:n,onKeyDown:Ut(n,r)})}function Lc({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),d=s.useRef(null);return s.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),a.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":Kt(t),value:i,onChange:c=>{const u=c.target.value===""?"":Number(c.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Ut(n,r)})}function Fc({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{o(!e),n()};return a.jsx("div",{className:"ogx__edit-boolean",children:a.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":Kt(t),checked:!!e,onChange:l,onMouseDown:d=>d.preventDefault(),onBlur:n,onKeyDown:Ut(n,r,!1)})})}const xn=e=>typeof e=="object"?e.value:e,Oc=e=>typeof e=="object"?e.label:String(e);function Ac(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Dc({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],d=l.map(g=>String(xn(g)));let c=l.findIndex(g=>Ac(xn(g),e));c===-1&&e!==null&&e!==void 0&&(c=d.indexOf(String(e)));const u=c===-1;return a.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Kt(t),value:u?"":d[c],onChange:g=>{const w=d.indexOf(g.target.value);o(w===-1?null:xn(l[w]))},onBlur:n,onKeyDown:Ut(n,r),children:[u&&a.jsx("option",{value:""}),l.map((g,w)=>a.jsx("option",{value:d[w],children:Oc(g)},w))]})}const vi=e=>String(e).padStart(2,"0"),yi=/^(\d{4}-\d{2}-\d{2})/;function bn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${vi(e.getMonth()+1)}-${vi(e.getDate())}`;if(typeof e=="string"){const t=yi.exec(e);return t?t[1]:e===""?"":bn(new Date(e))}return typeof e=="number"?bn(new Date(e)):""}function $c(e,t){if(e==="")return null;const[o,n,r]=e.split("-").map(Number),i=l=>{const d=new Date(l.getTime());return d.setFullYear(o,n-1,r),d};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&yi.test(t)&&t.length>10?e+t.slice(10):e}function Gc({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=s.useState(e),[l,d]=s.useState(()=>bn(e)),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus()},[]),a.jsx("input",{ref:c,type:"date",className:"ogx__edit-input","aria-label":Kt(t),value:l,onChange:u=>{d(u.target.value),o($c(u.target.value,i))},onBlur:n,onKeyDown:Ut(n,r)})}function Wc(e){const{colDef:t}=e;switch(t.type){case"number":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Lc,{...e})});case"boolean":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Fc,{...e})});case"singleSelect":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Dc,{...e})});case"date":return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Gc,{...e})});default:return a.jsx("div",{className:"ogx__edit-cell",children:a.jsx(Tc,{...e})})}}function Hc(e){const{onCellClick:t,onCellEditStart:o,onCellValueChange:n,value:r,row:i,colDef:l,rowIndex:d,colIndex:c,ariaColIndex:u,isSelected:g,onClick:w,width:x,pinnedPosition:v,pinnedOffset:p,isPinnedEdge:f,isFocused:m,isFocusVisible:b,isEditable:h,isEditing:y,onEditStart:S,onEditStop:N,onValueChange:T,colSpanInfo:E,rowSpan:I,isHiddenByRowSpan:F,rowMeta:G,valueError:H}=e,_=s.useCallback(z=>{n?n(l.field,z):T?.(z)},[n,T,l.field]),M=G?.isGroupRow===!0,{formattedValue:P,error:C}=s.useMemo(()=>{if(l.valueFormatter&&!(M&&r==null))try{return{formattedValue:l.valueFormatter({value:r,row:i,field:l.field})}}catch(z){return{formattedValue:"",error:z??new Error("valueFormatter failed")}}return{formattedValue:Ko(r,l)}},[r,i,l,M]),L=s.useMemo(()=>{if(!l.cellClassName)return"";if(typeof l.cellClassName=="function")try{return l.cellClassName({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:G})||""}catch{return""}return l.cellClassName},[l,r,P,i,d,c,G]),O=H??C,j=l.field,W=s.useCallback(()=>{N?.(!1,j)},[N,j]),Z=s.useCallback(()=>{N?.(!0,j)},[N,j]),oe=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),ie=s.useRef(!1);if(s.useEffect(()=>{if(!(!y||!N))return ie.current=!0,()=>{ie.current=!1,queueMicrotask(()=>{ie.current||N(!1,j)})}},[y,N,j]),E?.spannedByColSpan)return null;const te=E?.cellProps.colSpan??1,ue=te>1,de=(ue?E?.cellProps.width:void 0)??x??l.width??100,re={width:"var(--width)","--width":typeof de=="number"?`${de}px`:de,flexGrow:(ue?E?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:ue?void 0:l.minWidth,maxWidth:ue?void 0:l.maxWidth};if(F)return a.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:re,role:"presentation","data-field":l.field,"data-colindex":c});const ce=z=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:d,colIndex:c}),w?.(z))},le=()=>{y||!h||(o?o(l.field,r):S?.())},D=l.renderEditCell,ee=v!=null,J=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",m&&"ogx__cell--focused",m&&b&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,ee&&"ogx__cell--pinned",ee&&`ogx__cell--pinned-${v}`,ee&&f&&`ogx__cell--pinned-${v}-${v==="left"?"last":"first"}`,y&&"ogx__cell--editing",I&&I>1&&"ogx__cell--spanned",L].filter(Boolean).join(" "),Y=I||1,Q={...re,position:ee?"sticky":void 0,zIndex:l.zIndex??(ee?3:void 0),padding:y?0:void 0};return Y>1&&(Q.height=`calc(var(--height) * ${Y} - var(--border-width, 1px))`,Q.zIndex=10,ee&&(Q.zIndex=40)),ee&&p!==void 0&&(v==="left"?Q.left=p:Q.right=p),a.jsx("div",{className:J,style:Q,onClick:ce,onDoubleClick:le,role:"gridcell","aria-colindex":u??c+1,"aria-readonly":!h||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":c,...te>1?{"aria-colspan":te}:{},...Y>1?{"aria-rowspan":Y}:{},children:a.jsx("div",{className:"ogx__cell-content",children:y&&(n||T)&&N?D?a.jsx(lt,{field:l.field,resetKey:i,renderFn:()=>D({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:G,onValueChange:_,onCommit:W,onCancel:Z})}):a.jsx(Wc,{value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:G,onValueChange:_,onCommit:W,onCancel:Z}):O!==void 0?a.jsx(lt,{field:l.field,resetKey:i,renderFn:()=>{throw O}}):l.renderCell?a.jsx(lt,{field:l.field,resetKey:oe,renderFn:()=>l.renderCell({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:d,colIndex:c,rowMeta:G})}):l.type==="image"&&typeof r=="string"&&r!==""?a.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):P})})}const Ci=s.memo(Hc),Bc=({className:e="",...t})=>a.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:a.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function zc(e){const{rowId:t,content:o,height:n,isExpanded:r,onHeightChange:i,id:l,colSpan:d}=e,c=s.useRef(null),u=n==="auto";if(s.useLayoutEffect(()=>{const w=c.current;if(!w||!u||!r||!i)return;const x=()=>{w.getClientRects().length!==0&&i(t,w.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(x);return v.observe(w),()=>v.disconnect()},[u,r,i,t]),!r)return null;const g={height:u?"auto":`${n}px`,overflow:u?"visible":"auto"};return a.jsx("div",{ref:c,className:"ogx__detail-panel",style:g,role:"row",id:l,children:a.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":d,children:o})})}const vn=12;function Vc(e,t,o,n){let r=0,i=0,l=0;for(let d=t;d<e.length&&l<o;d++){const c=e[d];if(c.isSpacer)break;r+=nt(c,n),i+=c.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function vo(e){const{row:t,rowId:o,columns:n,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:d,onRowDoubleClick:c,onCellClick:u,onSelectionChange:g,columnWidths:w={},pinnedColumns:x,pinnedRows:v,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:m,detailPanelContent:b,detailPanelHeight:h=Uo,onDetailPanelHeightChange:y,pinCheckboxColumn:S=!0,pinExpandColumn:N=!0,rowReordering:T=!1,onDragStart:E,onDragOver:I,onDragEnd:F,onDrop:G,isDragging:H,isDragOver:_,editingCell:M,onEditStart:P,onEditStop:C,onEditCellValueChange:L,isCellEditable:O,focusedCellField:j,isFocusVisible:W,colspanMap:Z,rowSpanningCaches:oe,rowHeight:ie=52,rowMeta:te,columnIndexMap:ue,ariaRowIndex:de}=e,re=o??t.id,ce=s.useId(),le=s.useId(),D=s.useMemo(()=>Bo(n,w,x,l,S,p,N,T),[n,w,x,l,S,p,N,T]),ee=s.useMemo(()=>zo(n,x),[n,x]),J=te?.hasChildren===!0,Y=te?.isGroupRow===!0,Q=p&&!Y,z=!Y&&!Xe(re),q=s.useCallback((ae,Ce)=>{P?.({id:re,field:ae,value:Ce})},[re,P]),X=s.useCallback((ae,Ce)=>{L?.({id:re,field:ae,value:Ce})},[L,re]),$=s.useCallback((ae,Ce)=>{C?.({cancel:ae,id:re,field:Ce})},[C,re]);if(t._isSkeleton){const ae=Math.max(n.length,5);return a.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ie,minHeight:ie},children:Array.from({length:ae}).map((Ce,Te)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-bar"})},Te))})}const B=ae=>{ae.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:re,rowIndex:r})},A=ae=>{ae.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:re,rowIndex:r})},R=ae=>{ae.stopPropagation(),g?.(re,ae.target.checked)},k=ae=>{ae.stopPropagation(),m?.(re)},K=T?1:0,U=p?K+1:K,V=l?U+1:U,ne=V,fe=ue?.size??n.filter(ae=>!ae.isSpacer).length,pe=te!==void 0,he=te?.hasChildren===!0,ge=qn(re,v),be=ge==="top",ve=ge==="bottom",ye=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",be&&"ogx__row--pinned-top",ve&&"ogx__row--pinned-bottom",H&&"ogx__row--dragging",_&&"ogx__row--drag-over",J&&"ogx__row--group",te?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ye,onClick:B,onDoubleClick:c?A:void 0,role:"row","aria-rowindex":de??r+2,"aria-selected":i,"aria-level":pe?(te?.treeDepth??0)+1:void 0,"aria-expanded":he?te?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:I?I(re):void 0,onDrop:G?G(re):void 0,style:{maxHeight:`${ie}px`,minHeight:`${ie}px`,"--height":`${ie}px`,"--border-width":"1px"},children:[T&&a.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${j==="__reorder_col__"?"ogx__cell--focused":""} ${j==="__reorder_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":E?"Drag to reorder row":void 0,"aria-colindex":K,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:vn},draggable:!!E,onDragStart:E?E(re):void 0,onDragEnd:F,onClick:ae=>ae.stopPropagation(),children:E&&a.jsx(Bc,{})}),p&&a.jsx("div",{className:`ogx__cell ogx__cell--expand ${N?"ogx__cell--pinned-left":""} ${j==="__expand_col__"?"ogx__cell--focused":""} ${j==="__expand_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":Q?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":Q?f:void 0,"aria-controls":Q&&f?le:void 0,"aria-colindex":U,"data-field":"__expand_col__",style:{position:N?"sticky":void 0,left:N?T?48:0:void 0,zIndex:N?vn:void 0},tabIndex:-1,onClick:ae=>{ae.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:Q&&a.jsx(fn,{isExpanded:f,onClick:k,variant:"plus-minus",tabIndex:-1})}),l&&a.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${S?"ogx__cell--pinned-left":""} ${j==="__checkbox_col__"?"ogx__cell--focused":""} ${j==="__checkbox_col__"&&W?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":V,"data-field":"__checkbox_col__",style:{position:S?"sticky":void 0,left:S?(T?48:0)+(p&&N?48:0):void 0,zIndex:S?vn:void 0},tabIndex:-1,onClick:ae=>{ae.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:z&&a.jsx(zt,{id:ce,name:`ogx-select-row-${re}`,checked:i,onChange:R,onClick:ae=>ae.stopPropagation(),"aria-label":i?`Deselect row ${re}`:`Select row ${re}`,tabIndex:-1,onMouseDown:ae=>ae.preventDefault()})}),n.map((ae,Ce)=>{if(ae.isSpacer)return a.jsx("div",{style:{width:ae.width,minWidth:ae.width,flexShrink:0},"aria-hidden":"true"},ae.field);let Te,_e;Y?Te=t[ae.field]:{value:Te,error:_e}=Rn(t,ae.field,ae);const ke=ue?.get(ae.field)??Ce,se=w[ae.field]??ae.width,we=qe(ae.field,x),xe=!!P&&er({row:t,field:ae.field,value:Te,colDef:ae,rowIndex:r,colIndex:ke,rowMeta:te},O),Ne=M?.id===re&&M?.field===ae.field,Qe=Ne?M?.value:Te,Se=Z?.get(re)?.[ae.field],Ze=Se&&!Se.spannedByColSpan&&Se.cellProps.colSpan>1?Vc(n,ke,Se.cellProps.colSpan,w):Se,Qt=Ze&&!Ze.spannedByColSpan?n[ke+Ze.cellProps.colSpan-1]?.field??ae.field:ae.field,Eo=we==="right"?Qt:ae.field,De=we?D[Eo]:void 0,Mo=we==="left"&&Qt===ee.lastLeft||we==="right"&&ae.field===ee.firstRight,He=oe?.spannedCells[re]?.[ae.field],No=oe?.hiddenCells[re]?.[ae.field]||!1;return a.jsx(Ci,{value:Qe,row:t,colDef:ae,rowIndex:r,colIndex:ke,ariaColIndex:ne+ke+1,isSelected:i,onCellClick:u,width:se,pinnedPosition:we,pinnedOffset:De,isPinnedEdge:Mo,isFocused:j===ae.field,isFocusVisible:W,isEditable:xe,isEditing:Ne,onCellEditStart:q,onEditStop:$,onCellValueChange:X,colSpanInfo:Ze,rowSpan:He,isHiddenByRowSpan:No,rowMeta:te,valueError:_e},ae.field)})]}),Q&&a.jsx(zc,{id:le,colSpan:ne+fe,row:t,rowId:re,rowIndex:r,content:b,height:h,isExpanded:f,onHeightChange:y})]})}function _i({getContent:e,params:t}){return a.jsx(lt,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Kc=e=>e.id;function Si({rows:e,position:t,columns:o,selectedRowIds:n,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:w,hasDetailPanel:x,expandedRowIds:v,getDetailPanelContent:p,getDetailPanelHeight:f,onDetailPanelToggle:m,onDetailPanelHeightChange:b,pinCheckboxColumn:h,pinExpandColumn:y,focusedCell:S,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMetaMap:I,getRowId:F=Kc,rowIndexOffset:G=0,ariaRowIndexBase:H,columnIndexMap:_,editingHandlers:M,isCellEditable:P,rowReordering:C=!1}){return e.length===0?null:a.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((L,O)=>{const j=F(L),W=G+O;return a.jsx(vo,{row:L,rowId:j,columns:o,rowIndex:W,ariaRowIndex:H!==void 0?H+O:void 0,columnIndexMap:_,isSelected:n.has(j),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:w,hasDetailPanel:x,isDetailPanelExpanded:v.has(j),detailPanelContent:v.has(j)&&p?a.jsx(_i,{getContent:p,params:{row:L,id:j,rowIndex:W}}):null,detailPanelHeight:v.has(j)?jo(qo(f,{row:L,id:j,rowIndex:W})):void 0,onDetailPanelHeightChange:b,onDetailPanelToggle:m,pinCheckboxColumn:h,pinExpandColumn:y,focusedCellField:S?.id===j?S.field:null,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMeta:I.get(j),editingCell:M?.editingCell,onEditStart:M?.startCellEdit,onEditStop:M?.stopCellEdit,onEditCellValueChange:M?.setEditCellValue,isCellEditable:P,rowReordering:C},j)})})}const Uc=({columns:e,rowHeight:t,checkboxSelection:o=!1,hasDetailPanel:n=!1,rowReordering:r=!1})=>a.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[o&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:a.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const d=typeof i.width=="number"?i.width:150,c=Math.min(d*.7,d-20);return a.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:d,minWidth:i.minWidth,maxWidth:i.maxWidth,left:i.left,right:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&a.jsx("div",{className:"ogx-skeleton-box",style:{width:c,height:16,borderRadius:4}})},i.field||l)})]});function jc({virtualContainerHeight:e,offsetTop:t,effectiveLoading:o,visibleRows:n,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:d,hasDetailPanel:c,rowReordering:u,rowHeight:g,selectedRowIds:w,onRowClick:x,onRowDoubleClick:v,onCellClick:p,onSelectionChange:f,columnWidths:m,pinnedColumns:b,expandedRowIds:h,getDetailPanelContent:y,getDetailPanelHeight:S,onDetailPanelToggle:N,onDetailPanelHeightChange:T,pinCheckboxColumn:E,pinExpandColumn:I,rowReorderHandlers:F,editingHandlers:G,isCellEditable:H,focusedCell:_,colspanMap:M,rowSpanningCaches:P,paginationMode:C,dataSourceLoading:L,sortedUnpinnedRowCount:O,infiniteScrollSkeletonCount:j,unpinnedRowsLength:W,lastRenderedRowIndex:Z,rowMetaMap:oe,loadingOverlay:ie,ariaRowIndexOffset:te,columnIndexMap:ue}){const de=r.length>0?r:(()=>{const le=(l||1e3)-(d?48:0)-(c?48:0)-(u?48:0),D=150,ee=Math.max(1,Math.ceil(le/D));return Array.from({length:ee},(J,Y)=>({field:`placeholder_${Y}`,headerName:"",width:D}))})(),re=n.filter(le=>!le.pinned),ce=C==="infinite"&&L&&O>0&&Z>=W-1;return a.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:a.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[o&&n.length===0&&ie?a.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ie}):o&&n.length===0?Array.from({length:10}).map((le,D)=>a.jsx(Uc,{columns:de,rowHeight:g,checkboxSelection:d,hasDetailPanel:c,rowReordering:u},`skeleton-${D}`)):re.map(({row:le,id:D,rowIndex:ee})=>a.jsx(vo,{row:le,rowId:D,columns:i,rowIndex:ee,ariaRowIndex:te!==void 0?ee+te:void 0,columnIndexMap:ue,isSelected:w.has(D),checkboxSelection:d,onRowClick:x,onRowDoubleClick:v,onCellClick:p,onSelectionChange:f,columnWidths:m,pinnedColumns:b,hasDetailPanel:c,isDetailPanelExpanded:h.has(D),detailPanelContent:h.has(D)&&y?a.jsx(_i,{getContent:y,params:{row:le,id:D,rowIndex:ee}}):null,detailPanelHeight:h.has(D)?jo(qo(S,{row:le,id:D,rowIndex:ee})):void 0,onDetailPanelHeightChange:T,onDetailPanelToggle:N,pinCheckboxColumn:E,pinExpandColumn:I,rowReordering:u,onDragStart:F.canReorderRow(D)?F.onDragStart:void 0,onDragOver:F.onDragOver,onDragEnd:F.onDragEnd,onDrop:F.onDrop,isDragging:F.draggedRowId===D,isDragOver:F.dragOverRowId===D,editingCell:G.editingCell,onEditStart:G.startCellEdit,onEditStop:G.stopCellEdit,onEditCellValueChange:G.setEditCellValue,isCellEditable:H,focusedCellField:_!=null&&_.id===D?_.field:null,colspanMap:M,rowSpanningCaches:P,rowHeight:g,rowMeta:oe.get(D)},D)),ce&&a.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:j}).map((le,D)=>a.jsx(vo,{row:{id:`__skeleton_${D}__`,_isSkeleton:!0},columns:i,rowIndex:W+D,rowHeight:g},`__skeleton_${D}__`))})]})})}function qc(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Xc(){return a.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[a.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),a.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function yn(e){const{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:c}=e,[u,g]=s.useState(""),w=s.useId(),[x,v]=s.useState(null),p=s.useRef(null),f=s.useMemo(()=>t.filter(I=>I.hideable!==!1),[t]),m=f.every(I=>o.has(I.field)),b=s.useMemo(()=>{const I=c?t:f;if(!u)return I;const F=u.toLowerCase();return I.filter(G=>(G.headerName||G.field).toLowerCase().includes(F))},[t,f,u,c]),h=I=>{I.target.checked?r():i()},y=I=>F=>{p.current=I,F.dataTransfer.effectAllowed="move",F.dataTransfer.setDragImage(F.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},S=I=>F=>{F.preventDefault(),F.dataTransfer.dropEffect="move",I!==p.current&&v(I)},N=()=>{v(null)},T=I=>F=>{F.preventDefault();const G=p.current;v(null),p.current=null,G&&G!==I&&l&&l(G,I)},E=()=>{v(null),p.current=null};return a.jsxs("div",{className:"ogx-column-visibility-panel",children:[a.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:a.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[a.jsx(qc,{}),a.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:I=>g(I.target.value)})]})}),a.jsx("div",{className:"ogx-column-visibility-panel__list",children:b.map((I,F)=>{const G=`${w}-col-${F}`,H=o.has(I.field),_=I.hideable!==!1,M=x===I.field,P=!!l&&!u;return a.jsxs("div",{className:["ogx-column-visibility-panel__item",!_&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:P,onDragOver:P?S(I.field):void 0,onDragLeave:P?N:void 0,onDrop:P?T(I.field):void 0,onDragEnd:P?E:void 0,children:[P&&a.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(I.field),title:"Drag to reorder",children:a.jsx(Xc,{})}),a.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:_?"pointer":"not-allowed"},children:[a.jsx(zt,{id:G,checked:H,onChange:C=>n(I.field,C.target.checked),disabled:!_}),a.jsx("label",{htmlFor:G,className:"ogx-column-visibility-panel__label",children:I.headerName||I.field})]})]},I.field)})}),a.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[a.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[a.jsx(zt,{id:`${w}-all`,checked:m,onChange:h}),a.jsx("label",{htmlFor:`${w}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),a.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),d?.()},children:"Reset"})]})]})}function Rc({isOpen:e,containerRef:t,panelRef:o,columns:n,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:d,onColumnMove:c,onColumnOrderReset:u,columnGroupingModel:g}){const[w,x]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const p=t.current.getBoundingClientRect();x({top:p.top+8,right:xt()-p.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!w)return null;const v=i?void 0:(p,f)=>{hn(g,p,f)&&c(p,f)};return ot.createPortal(a.jsxs("div",{ref:o,style:{position:"fixed",top:w.top,right:w.right,zIndex:9999,display:"inline-block"},children:[a.jsx("button",{type:"button",onClick:l,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),a.jsx(yn,{columns:n,visibleColumns:new Set(n.filter(p=>r[p.field]!==!1).map(p=>p.field)),onVisibilityChange:(p,f)=>{d({...r,[p]:f})},onShowAll:()=>{const p={...r};n.forEach(f=>{f.hideable!==!1&&(p[f.field]=!0)}),d(p)},onHideAll:()=>{const p={...r};n.forEach(f=>{f.hideable!==!1&&(p[f.field]=!1)}),d(p)},onColumnReorder:v,onColumnOrderReset:i?void 0:u})]}),w.target)}const ki=[];function Yc(e){const{isPivotActive:t}=e,o=t?ki: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 Jc(e){const{baseColumns:t,pinnedColumns:o,hasGroupingColumn:n,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,d=s.useMemo(()=>n?{...o,left:["__group__",...(o?.left??[]).filter(u=>u!=="__group__")]}:o,[n,o]);return{activeColumns:s.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:d}}function Qc(e){return e.id}function Zc(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),o=s.useRef(t);s.useLayoutEffect(()=>{o.current=t});const n=s.useCallback(r=>o.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:n}}function ed(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function td(e){const{hierarchyHandlers:t,pinnedTopRows:o,sortedUnpinnedRows:n,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:d,dataRows:c}=e,u=t?.getVisibleRows({expandAll:!0,labelField:d});if(!u)return[...o,...n,...r];const g=c?new Set(c):null;return u.filter(w=>!i.get(l(w))?.isGroupRow&&(!g||g.has(w)))}function od(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 nd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>od(o,t[n]))}function rd(e){const[t,o]=s.useState(e),n=nd(t,e);return n||o(e),n?t:e}function id(e){const{rows:t,getRowId:o,rowMetaMap:n,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:d}=e,c=Object.keys(i).length>0,u=new Map(r.map(v=>[v.field,v])),g=[],w=[],x=v=>{for(;w.length>0&&w[w.length-1].header.depth>=v;){const p=w.pop();c&&!d?.(p.id)&&g.push({type:"group-subtotal",depth:p.header.depth,groupField:p.header.groupField,groupValue:p.header.groupValue,groupLabel:p.header.groupLabel,aggregatedValues:uo(p.leaves,i,u,"getGroupedExportRows")})}};for(const v of t){const p=o(v),f=n.get(p);if(!f?.isGroupFooter)if(f?.isGroupRow){const m=f.treeDepth??0;x(m);const b={type:"group-header",depth:m,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(b),w.push({id:p,header:b,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??w.length,row:v}),w.forEach(m=>m.leaves.push(v))}return x(0),c&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function ld(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.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:d,rowGroupingHandlers:c,rowMetaMap:u,columns:g,getRowId:w,hierarchyField:x}=n();return d?id({rows:c.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:w,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&c.rootAggregationPosition!==null?i:null,isSubtotalHidden:v=>c.aggregationPositions.get(v)===null}):null}},[t])}const sd=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!it(t.field)&&!sd.has(t.field))}function Ye(e){return!!e&&e.length>0}function Ei(e,t,o=n=>n.id){const n=new Set(t);return e.filter(r=>n.has(o(r)))}function jt(e,t,o){return Ye(t)?Ei(e,t,o):e}function qt(e,t){return!!e&&e.length>0&&!Ye(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 uo(e,r,i,"export")}function Xt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function yo(e,t,o){if(!t.valueFormatter)return Ko(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 Cn(e,t,o,n){return o==null?"":fo(o,t??"",e,n)}function St(e,t){return t?`${e}: ${t}`:e}function Mi(e,t){const o={};return t.forEach(n=>{Object.prototype.hasOwnProperty.call(e,n.field)&&(o[n.field]=e[n.field])}),o}const ad=/^[=+\-@\t\r]/,cd=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function Co(e,t=!1){return t||!ad.test(e)||cd.test(e)?e:`'${e}`}function Je(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Ee(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const dd=/[\\/?*:[\]]/g,Ni=31;function _n(e,t=new Set){let o=String(e??"").replace(dd,"-").trim().replace(/^'+|'+$/g,"").trim();o||(o="Sheet"),o=o.slice(0,Ni).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,Ni-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const ud=new Set([Re,Ht,Wt]),fd=/[\t\n\r"]/;function Pi(e){return fd.test(e)?`"${e.replace(/"/g,'""')}"`:e}function gd(e){return st(e).filter(t=>!ud.has(t.field))}function pd(e,t){const o=t.map(r=>Pi(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>Pi(yo(r,i,Fe(r,i.field,i)))).join(" "));return[o,...n].join(`
4
+ `)}function Ii(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 hd(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(Ii(e))return;throw o}if(!Ii(e))throw new Error("Clipboard API not available and fallback failed.")}function wd(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 md(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const o=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:d}=t.current,c=new Set(r());if(c.size===0)return;const u=l().filter(w=>c.has(d(w)));if(u.length===0)return;const g=pd(u,gd(i()));await hd(g)},[]),n=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!wd(i))return;const l=document.activeElement,d=l?.tagName.toLowerCase(),c=l?.type;if(d==="input"&&c!=="checkbox"&&c!=="radio"||d==="textarea"||d==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const w=u();if(!w||!l||!w.contains(l))return}const g=window.getSelection();g&&!g.isCollapsed&&g.toString()!==""||o().catch(w=>{console.error("[OpenGridX] Failed to copy to clipboard:",w)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[o,n]),{copySelectedRows:o}}function xd(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=s.useCallback(()=>r.current,[r]),{copySelectedRows:d}=md({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>o,getRows:()=>t.current.getAllFilteredRows(),getRowId:n,getRootElement:l,disableKeyboardShortcut:i});s.useLayoutEffect(()=>{t.current.copySelectedRows=d},[d,t])}function bd(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e}),s.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:n,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:d}=o.current,c=i.current;if(c&&(n!==void 0&&n>=0&&Zn(c,n,l.cumulativeHeights,l.pinnedBottomHeight,d),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;zl(c,l.unpinnedColsWithWidth.findIndex(w=>w.field===g.field),l)}}},[t])}const vd=".ogx";function Ti(e,t){const o=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const n=t.getBoundingClientRect().width;t.style.cssText=o;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,d)=>l+(parseFloat(d)||0),0);return n+i}function yd(e,t){const o=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/"/g,'\\"'),n=l=>l.closest(vd)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${o}"]`).forEach(l=>{if(!n(l))return;const d=l.querySelector(".ogx__header-cell-content");d&&i(Ti(l,d))}),e.querySelectorAll(`[role="gridcell"][data-field="${o}"]`).forEach(l=>{if(!n(l)||l.hasAttribute("aria-colspan"))return;const d=l.querySelector(":scope > .ogx__cell-content");d&&i(Ti(l,d))}),r===null?null:Math.ceil(r)}function Cd(e,t,o){return Math.max(t??Xr,Math.min(o??1/0,e))}function _d(e){const{apiRef:t}=e,o=s.useRef(e);s.useLayoutEffect(()=>{o.current=e});const n=s.useCallback(i=>{const{containerRef:l,columns:d,onColumnResize:c}=o.current,u=l.current;if(!u)return;const g=[];for(const w of i??d.map(x=>x.field)){const x=d.find(p=>p.field===w);if(!x||x.resizable===!1)continue;const v=yd(u,w);v!==null&&g.push([w,Cd(v,x.minWidth,x.maxWidth)])}for(const[w,x]of g)c(w,x)},[]),r=s.useCallback(i=>n([i]),[n]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=n},[t,r,n]),r}function Sd(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function kd(e){const{ensureGridFocus:t,setKeyboardMode:o,setFocusedCell:n,getRowId:r,onCellClick:i}=e,l=s.useCallback(c=>{t(),o(!1),n({id:r(c.row),field:c.field,rowIndex:c.rowIndex}),i?.(c)},[i,o,n,t,r]),d=s.useCallback(c=>{t(),n({id:null,field:c}),o(!1)},[t,n,o]);return{handleCellClick:l,handleHeaderClick:d}}function Ed({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:d}){const c=e||mn;return a.jsx(c,{page:o,pageSize:n.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...n,page:u}),onPageSizeChange:u=>l({...n,pageSize:u,page:0}),localeText:Tr(d),...t})}function Md({loading:e,error:t,noRowsLabel:o,filteredRowCount:n,dataRowCount:r,filterModel:i}){return a.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${qr(t)}`:"",!e&&!t&&(n===0?o:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:"")]})}function Nd(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 Pd(e){const{columnGroupingModel:t,pinnedTopCount:o,pinnedBottomCount:n,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:d,paginatedUnpinnedRowCount:c,sortedUnpinnedRowCount:u}=e,{page:g,pageSize:w}=l;return s.useMemo(()=>Nd({headerRowCount:1+Rr(t),pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r?c:u,totalCenterRowCount:r&&i==="server"?Math.max(d,c):u,pageOffset:r?g*w:0}),[t,o,n,r,c,u,i,d,g,w])}function Id(e){const{toolbar:t,toolbarSlotProps:o,apiRef:n,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,pivotMode:c,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:w,onPivotModelChange:x,filterModel:v,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:m,disableColumnReorder:b,columnGroupingModel:h,moveColumn:y,resetColumnOrder:S,forceColumnsOpen:N,onColumnsPanelClose:T}=e;return s.useMemo(()=>t?{apiRef:n,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:d,...c||u||g?{pivotModel:w,onPivotModelChange:x}:{},filterModel:v,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:m,onColumnReorder:b?void 0:(I,F)=>{hn(h,I,F)&&y(I,F)},onColumnOrderReset:b?void 0:S,forceColumnsOpen:N,onColumnsPanelClose:T,...o}:null,[t,b,y,S,r,n,i,l,d,c,u,g,w,x,v,p,f,m,N,T,o,h])}function Td(e){const{rows:t,columns:o,getRowId:n,rowHeight:r,headerHeight:i,autoHeight:l=!1,density:d,checkboxSelection:c=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:g=!1,disableClipboardCopy:w=!1,rowSelectionModel:x,onRowSelectionModelChange:v,onRowClick:p,onRowDoubleClick:f,onCellClick:m,filterModel:b,onFilterModelChange:h,sortModel:y,onSortModelChange:S,pagination:N=!1,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:I=[10,25,50,100],pinnedColumns:F,onPinnedColumnsChange:G,pinnedRows:H,getDetailPanelContent:_,getDetailPanelHeight:M,detailPanelExpandedRowIds:P,onDetailPanelExpandedRowIdsChange:C,pinCheckboxColumn:L=!0,pinExpandColumn:O=!0,disableColumnReorder:j=!1,columnOrder:W,onColumnOrderChange:Z,onColumnOrderModelChange:oe,height:ie,rowReordering:te=!1,onRowOrderChange:ue,loading:de=!1,treeData:re=!1,getTreeDataPath:ce,defaultGroupingExpansionDepth:le,groupingColDef:D,rowGroupingModel:ee,aggregationModel:J,onAggregationModelChange:Y,getAggregationPosition:Q,isCellEditable:z,processRowUpdate:q,onProcessRowUpdateError:X,dataSource:$,multiSort:B=!1,sortingMode:A="client",filterMode:R="client",paginationMode:k="client",rowCount:K,slots:U,slotProps:V,pivotMode:ne=!1,pivotModel:fe,onPivotModelChange:pe,className:he="",style:ge,onRowsScrollEnd:be,ariaLabel:ve,initialState:ye,onStateChange:ae,columnVisibilityModel:Ce,onColumnVisibilityModelChange:Te,listView:_e=!1,listViewColumn:ke,columnGroupingModel:se,noRowsLabel:we="No Data",localeText:xe,apiRef:Ne,overscanRowCount:Qe=3}=e,Se=rd(o),Ze=xe?.noRowsLabel??we,Qt=ee||ki,Eo=Ss({initialState:ye,sortModel:y,onSortModelChange:S,filterModel:b,onFilterModelChange:h,aggregationModel:J,onAggregationModelChange:Y,columnVisibilityModel:Ce,onColumnVisibilityModelChange:Te,pinnedColumns:F,onPinnedColumnsChange:G,pivotModel:fe,onPivotModelChange:pe,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:I,rowSelectionModel:x,onRowSelectionModelChange:v,density:d}),{sortModel:De,handleSortModelChange:Mo,filterModel:He,handleFilterModelChange:No,aggregationModel:$e,handleAggregationModelChange:Ru,columnVisibilityModel:at,handleColumnVisibilityModelChange:En,pinnedColumns:Mn,handlePinnedColumnsChange:Yu,currentPivotModel:ll,handlePivotModelChange:Ju,effectivePaginationModel:Ae,handlePaginationModelChange:Pt,selectedRowIds:Qu,handleRowSelectionModelChange:Nn,density:sl}=Eo,Zt=Sc({rows:t,columns:Se,pivotMode:ne,pivotModel:ll,filterModel:He,sortModel:De,hasDataSource:!!$,hierarchyRequested:re||Qt.length>0}),ct=Zt.isActive,{rowReordering:dt,hierarchyRowGroupingModel:Zu,isTreeDataRequested:ef,isTreeData:Po,isRowGrouping:It,isHierarchyEnabled:Io,hasGroupingColumn:tf,pagination:Be,listView:eo}=Yc({rowGroupingModel:Qt,treeData:re,hasTreeDataPath:!!ce,isPivotActive:ct,rowReordering:te,hasGroupingColDef:!!D,pagination:N,paginationMode:k,listView:_e,hasListViewColumn:!!ke}),{rowHeight:et,headerHeight:al}=Ps({rowHeight:r,headerHeight:i,density:sl}),of=Zt.rows,nf=Zt.columns,{activeColumns:ut,effectivePinnedColumns:Tt}=Jc({baseColumns:nf,pinnedColumns:Mn,hasGroupingColumn:tf,groupingColDef:D,isTreeData:Po,getTreeDataPath:ce}),Pn=ua(ut,at),[rf,lf]=yc($e),Lt=s.useRef(null),In=s.useRef(null),cl=!ct&&n||Qc,Tn=Sd(Lt),Ln=Ba({rows:of,getRowId:cl,columns:ut,rowHeight:et,headerHeight:al,columnVisibilityModel:at,initialState:e.initialState,syncRows:!$}),{state:Me,apiRef:Ft,setRows:sf,replaceRow:af,setColumns:cf,setDimensions:df,setDataSourceLoading:uf,setDataSourceError:ff,setRowCount:gf}=Ln,{getRowIdOf:Pe,getRowIdOfInEvents:pf}=Zc(Me.rows.idByRow);ed(Ne,Ft);const hf=Me.dataSource.loading,tt=de||hf,To=s.useMemo(()=>Me.rows.allRows.map(pt=>Me.rows.idRowsLookup.get(pt)),[Me.rows]),{treeDataHandlers:Lo,rowGroupingHandlers:Fn,activeHierarchyHandlers:Ot,rowMetaMap:ze}=rc({rows:To,getRowId:Pe,getTreeDataPath:ce,isTreeDataRequested:ef,isTreeData:Po,columns:ut,rowGroupingModel:Zu,isRowGrouping:It,aggregationModel:$e,defaultGroupingExpansionDepth:le,filterModel:He,sortModel:De,getAggregationPosition:Q,columnLookup:Pn,filterMode:R,sortingMode:A}),dl=lc({rows:To,getRowId:Pe,columns:ut,processRowUpdate:q,onProcessRowUpdateError:X,onRowChange:(pt,Kf)=>{af(Kf,pt)}}),to=sa({selectedRowIds:Qu,rowsLookup:Me.rows.idRowsLookup,rowMetaMap:ze,enabled:!$&&!ct&&k==="client"&&R==="client",onSelectionModelChange:Nn}),ul=xc({dataSource:$,sortModel:De,filterModel:He,paginationModel:Ae,paginationMode:k,sortingMode:A,filterMode:R,aggregationModel:$e,rowGroupingActive:It,getRowId:cl,setRows:sf,setRowCount:gf,setDataSourceLoading:uf,setDataSourceError:ff,onAggregationResults:lf,onPaginationModelChange:Pt});vc({enabled:Po&&!!$,treeNodes:Lo.treeNodes,isGroupExpanded:Lo.isGroupExpanded,getNodePath:Lo.getNodePath,toggleExpansion:Lo.toggleExpansion,fetchChildren:ul.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:On,handleDetailPanelToggle:fl,detailPanelHeights:wf,reportDetailPanelHeight:mf}=Xs({hasDetailPanel:!!_,controlledExpandedRowIds:P,onDetailPanelExpandedRowIdsChange:C,rowMetaMap:ze}),{effectiveColumns:gl,hierarchyField:An,orderedColumns:Dn,visibleOrderedColumns:pl,renderOrderedColumns:xf,navigationColumns:hl,columnIndexMap:wl,columnWidths:oo,effectiveColumnOrder:bf,columnReorderHandlers:vf,moveColumn:ml,resetColumnOrder:xl,handleColumnResize:bl}=Ws({activeColumns:ut,isHierarchyEnabled:Io,isRowGrouping:It,isTreeData:Po,activeHierarchyHandlers:Ot,columnVisibilityModel:at,columnOrder:W,onColumnOrderChange:Z,onColumnOrderModelChange:oe,disableColumnReorder:j,pivotMode:ct,checkboxSelection:c,hasDetailPanel:ft,rowReordering:dt,initialState:ye,setColumns:cf,pinnedColumns:Tt,getRowId:pf,aggregationModel:$e,groupingRows:It?Fn.groupingRows:void 0});Js({onStateChange:ae,sortModel:De,filterModel:He,effectivePaginationModel:Ae,columnWidths:oo,effectiveColumnOrder:bf,columnVisibilityModel:at,pinnedColumns:Mn,density:sl});const Fo=Ts({effectiveRows:To,activeHierarchyHandlers:Ot,filterMode:R,filterModel:Zt.pipelineFilterModel,sortModel:Zt.pipelineSortModel,sortingMode:A,pagination:Be,paginationMode:k,effectivePaginationModel:Ae,pinnedRows:H,getRowId:Pe,columnLookup:Pn,hierarchyField:An}),{filteredRows:vl,dataRows:At,pinnedTopRows:Ge,pinnedBottomRows:Ve,sortedUnpinnedRows:je,paginatedUnpinnedRows:Oo,allRenderableRows:Ao}=Fo,$n=Be?Oo:je;fa({paginationModel:Ae,currentPage:Fo.currentPage,enabled:Be&&!tt&&je.length>0,onPaginationModelChange:Pt});const Do=Is({paginationMode:k,hasDataSource:!!$,dataSourceRowCount:Me.pagination.rowCount,rowCountProp:K,clientRowCount:je.length}),{rowSelection:Gn,handleRowClick:Wn,handleSelectionChange:Hn}=la({dataRows:At,getRowId:Pe,isPivotActive:ct,selectedRowIds:to,onSelectionModelChange:Nn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:Io,rowMetaMap:ze,activeHierarchyHandlers:Ot,onRowClick:p});da({apiRef:Ln.apiRef,sortModel:De,multiSort:B,onSortModelChange:Mo,filterModel:He,onFilterModelChange:No,paginationModel:Ae,onPaginationModelChange:Pt,selectedRowIds:to,getPendingRowSelectionModel:Eo.getPendingRowSelectionModel,onRowSelectionModelChange:Nn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>Xe(pt,ze),getVisibleRows:()=>[...Ge,...$n,...Ve],getAllFilteredRows:()=>td({hierarchyHandlers:Ot,pinnedTopRows:Ge,sortedUnpinnedRows:je,pinnedBottomRows:Ve,rowMetaMap:ze,getRowId:Pe,hierarchyField:An,dataRows:At}),visibleColumns:xf});const yf=za({rows:To,getRowId:Pe,onRowOrderChange:ue,rowReordering:dt}),{aggregationResult:Bn,isLoading:Cf}=bi({rows:At,columns:ut,aggregationModel:ct?Vl:$e,isServerSide:Ur({dataSource:$,paginationMode:k,sortingMode:A,filterMode:R}),dataSource:$,filterModel:He,sortModel:De,serverAggregationResults:rf}),zn=Object.keys($e).length>0&&!ct;ld({apiRef:Ft,hasAggregation:zn,aggregationResult:Bn,aggregationModel:$e,isRowGrouping:It,rowGroupingHandlers:Fn,rowMetaMap:ze,columns:ut,getRowId:Pe,hierarchyField:An});const Ie=Hl({rowHeight:et,pagination:Be,paginatedUnpinnedRows:Oo,sortedUnpinnedRows:je,expandedRowIds:On,getDetailPanelHeight:M,detailPanelHeights:wf,pinnedTopRowsLength:Ge.length,pinnedBottomRowsLength:Ve.length,pinnedTopRows:Ge,pinnedBottomRows:Ve,visibleOrderedColumns:pl,pinnedColumns:Tt,columnWidths:oo,viewportWidth:Me.dimensions.viewportWidth||1e3,checkboxSelection:c,hasDetailPanel:ft,rowReordering:dt,pinCheckboxColumn:L,pinExpandColumn:O,paginationMode:k,isLoading:Me.dataSource.loading,pageSize:Ae.pageSize,getRowId:Pe}),no=uc({pinnedTopRows:Ge,centerRows:$n,pinnedBottomRows:Ve,columns:pl,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?On:void 0,rowMetaMap:ze,getRowId:Pe}),yl=s.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);xd({apiRef:Ft,columns:yl,getRowId:Pe,containerRef:Lt,disableKeyboardShortcut:w}),bd({apiRef:Ft,viewportRef:In,layout:Ie,rowHeight:et});const _f=_d({apiRef:Ft,containerRef:Lt,columns:Dn,onColumnResize:bl}),{scrollTop:Sf,scrollLeft:kf,overscanRows:Ef,handleScroll:Mf,setViewportElement:Nf}=js({onRowsScrollEnd:be,overscanRowCount:Qe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:df,viewportRef:In}),Le=Ls({layout:Ie,scrollTop:Sf,scrollLeft:kf,viewportWidth:Me.dimensions.viewportWidth,viewportHeight:Me.dimensions.viewportHeight,autoHeight:l,rowReordering:dt,hasDetailPanel:ft,checkboxSelection:c,pinCheckboxColumn:L,pinExpandColumn:O,overscanRows:Ef}),{handleSort:Cl,handleSortAdd:_l}=aa({sortModel:De,onSortModelChange:Mo}),$o=c||!u,{focusedCell:Sl,setFocusedCell:Pf,viewportTabIndex:If,ensureGridFocus:Tf,handleFocus:Lf,handleBlur:Ff,handleKeyDown:Of,handleMouseDownCapture:Af}=ys({allRenderableRows:Ao,navigationColumns:hl,checkboxSelection:c,selectedRowIds:to,handleSelectionChange:Hn,handleDetailPanelToggle:fl,editingHandlers:dl,setKeyboardMode:Tn,sortModel:De,handleSort:Cl,handleSortAdd:_l,multiSort:B,isCellEditable:z,pagination:Be,pageSize:Ae.pageSize,virtualization:Le,viewportRef:In,pinnedTopRowCount:Ge.length,getRowId:Pe,rowMetaMap:ze,getSpanOrigin:no.getSpanOrigin,onRowActivate:Wn,toggleRowExpansion:Ot?.toggleExpansion,handleSelectAll:Gn.selectAll,rowSelectionEnabled:$o,multipleRowSelectionEnabled:!g,pinCheckboxColumn:L,pinExpandColumn:O,rowHeight:et}),{handleCellClick:Df,handleHeaderClick:$f}=kd({ensureGridFocus:Tf,setKeyboardMode:Tn,setFocusedCell:Pf,getRowId:Pe,onCellClick:m}),{handleHideColumn:Gf,handlePinColumn:Wf}=ca({columnVisibilityModel:at,onColumnVisibilityModelChange:En,pinnedColumns:Mn,onPinnedColumnsChange:Yu}),ro=Pd({columnGroupingModel:se,pinnedTopCount:Ge.length,pinnedBottomCount:Ve.length,pagination:Be,paginationMode:k,paginationModel:Ae,paginationRowCount:Do,paginatedUnpinnedRowCount:Oo.length,sortedUnpinnedRowCount:je.length}),Vn=gc({spanning:no,renderContext:Le.renderContext,offsetTop:Le.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Kn=Bs({renderContext:Vn.renderContext,pinnedTopRows:Ge,pinnedBottomRows:Ve,paginatedUnpinnedRows:Oo,sortedUnpinnedRows:je,pagination:Be,getRowId:Pe}),Go=pc({spanning:no,firstColumnIndex:Le.renderContext.firstColumnIndex,lastColumnIndex:Le.renderContext.lastColumnIndex,virtualColumns:Le.virtualColumns,layout:Ie,rows:Kn});ta({paginationRequested:N,isRowGrouping:It,autoHeight:l,viewportHeight:Me.dimensions.viewportHeight,renderedRowCount:Kn.length,totalRowCount:Ge.length+$n.length+Ve.length,pinnedRowsIgnored:Io&&!!(H?.top?.length||H?.bottom?.length),scrollHeight:Le.totalHeight,listViewWithoutColumn:_e&&!ke,listViewRowCount:eo&&ke?Ao.length:0});const{allSelected:Hf,someSelected:Bf}=Gn,Dt=hc(se,vf),zf=s.useMemo(()=>gl.some(pt=>!!pt.rowSpan),[gl]),gt=ga();na(Lt);const kl=U?.noRowsOverlay,El=U?.loadingOverlay,Un=El?a.jsx(El,{...V?.loadingOverlay}):void 0,Ml=kl?a.jsx(kl,{...V?.noRowsOverlay}):void 0,Wo=U?.footer,Vf=tt&&Ao.length>0&&k!=="infinite",Nl=U?.toolbar,Pl=Id({toolbar:U?.toolbar,toolbarSlotProps:V?.toolbar,apiRef:Ft,orderedColumns:Dn,baseColumns:Se,aggregationModel:$e,onAggregationModelChange:Ru,pivotMode:ne,pivotModelProp:fe,onPivotModelChangeProp:pe,pivotModel:ll,onPivotModelChange:Ju,filterModel:He,onFilterModelChange:No,columnVisibilityModel:at,onColumnVisibilityModelChange:En,disableColumnReorder:j,columnGroupingModel:se,moveColumn:ml,resetColumnOrder:xl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),jn={rowReordering:dt,columnIndexMap:wl,editingHandlers:dl,isCellEditable:z,selectedRowIds:to,checkboxSelection:c,onRowClick:Wn,onRowDoubleClick:f,onCellClick:Df,onSelectionChange:Hn,columnWidths:oo,pinnedColumns:Tt,hasDetailPanel:ft,expandedRowIds:On,getDetailPanelContent:_,getDetailPanelHeight:M,onDetailPanelToggle:fl,onDetailPanelHeightChange:mf,pinCheckboxColumn:L,pinExpandColumn:O,focusedCell:Sl,colspanMap:no.colspanMap,rowSpanningCaches:no.rowSpanningCaches,rowHeight:et,rowMetaMap:ze};return a.jsxs("div",{ref:Lt,className:["ogx",he,l&&"ogx--auto-height",!l&&ie===void 0&&ge?.height===void 0&&"ogx--fill",zf&&"ogx--row-spanning",eo&&"ogx--list-view"].filter(Boolean).join(" "),style:{...ge,height:ie??ge?.height,"--ogx-row-height":`${et}px`,"--ogx-header-height":`${al}px`},"aria-busy":tt,children:[Nl&&Pl&&a.jsx(Vr.Provider,{value:gt.toolbarHost,children:a.jsx(wa,{component:Nl,toolbarProps:Pl})}),a.jsx(Rc,{isOpen:gt.standalonePanelOpen,containerRef:Lt,panelRef:gt.standalonePanelRef,columns:Dn,columnVisibilityModel:at,disableColumnReorder:j,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:En,onColumnMove:ml,onColumnOrderReset:xl,columnGroupingModel:se}),eo&&ke&&a.jsx(Nc,{ariaLabel:ve,allRenderableRows:Ao,dataRowCount:At.length,pinnedTopRowCount:Ge.length,pinnedBottomRowCount:Ve.length,unpinnedRowCount:je.length,pagination:Be,effectivePaginationModel:Ae,currentPage:Fo.currentPage,pageSizeOptions:I,selectedRowIds:to,listViewColumn:ke,columnsByField:Pn.byField,rowMetaMap:ze,noRowsLabel:Ze,rowHeight:et,checkboxSelection:c,paginationMode:k,serverRowCount:Do,paginationSlot:U?.pagination,paginationSlotProps:V?.pagination,localeText:Tr(xe),onRowClick:Wn,onRowDoubleClick:f,onSelectionChange:Hn,onPaginationModelChange:Pt,onRowsScrollEnd:be,getRowId:Pe,multiselectable:$o&&!g,selectable:$o,onToggleExpansion:Ot?.toggleExpansion,loading:tt,loadingOverlay:Un,noRowsOverlay:Ml,showPaginationControls:!Wo}),!eo&&a.jsx("div",{ref:Nf,className:"ogx__viewport",onScroll:Mf,role:"grid","aria-label":ve||"Data grid","aria-rowcount":ro.rowCount,"aria-colcount":hl.length,"aria-multiselectable":$o&&!g,"aria-busy":tt,tabIndex:If,onKeyDownCapture:()=>{Tn(!0)},onMouseDownCapture:Af,onKeyDown:Of,onFocus:Lf,onBlur:Ff,children:a.jsxs("div",{className:"ogx__content",style:{width:Tt?.right?.length?`max(100%, ${Le.totalWidth}px)`:Le.totalWidth},role:"presentation",children:[a.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[a.jsx(Qr,{columns:Go,allColumns:yl,columnGroupingModel:se,checkboxSelection:c,allSelected:Hf,someSelected:Bf,onSelectAll:Gn.selectAll,sortModel:De,onSort:Cl,onSortAdd:_l,multiSort:B,onColumnResize:bl,onColumnAutosize:_f,columnWidths:oo,pinnedColumns:Tt,focusedCell:Sl,columnIndexMap:wl,onHeaderClick:$f,onDragStart:Dt.onDragStart,onDragOver:Dt.onDragOver,onDragEnd:Dt.onDragEnd,onDrop:Dt.onDrop,draggedColumn:Dt.draggedColumn,dragOverColumn:Dt.dragOverColumn,rowReordering:dt,hasDetailPanel:ft,pinCheckboxColumn:L,pinExpandColumn:O,aggregationModel:$e,onHideColumn:Gf,onManageColumns:gt.openColumnsPanel,onPinColumn:Wf}),a.jsx(Si,{...jn,rows:Ge,position:"top",ariaRowIndexBase:ro.topBase,columns:Go,pinnedRows:H,getRowId:Pe})]}),!tt&&!Me.dataSource.error&&vl.length===0&&a.jsx(xa,{noRowsLabel:Ze,width:Le.totalWidth,overlay:Ml}),a.jsx(jc,{...jn,virtualContainerHeight:Le.totalHeight-Le.pinnedTopHeight-Le.pinnedBottomHeight,offsetTop:Vn.offsetTop,effectiveLoading:tt,visibleRows:Kn,baseColumns:Se,virtualColumns:Go,viewportWidth:Me.dimensions.viewportWidth,rowReorderHandlers:yf,paginationMode:k,dataSourceLoading:Me.dataSource.loading,sortedUnpinnedRowCount:je.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:Vn.renderContext.lastRowIndex,ariaRowIndexOffset:ro.centerOffset,loadingOverlay:Un}),a.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[a.jsx(Si,{...jn,rows:Ve,position:"bottom",rowIndexOffset:ro.bottomRowIndexOffset,ariaRowIndexBase:ro.bottomBase,columns:Go,pinnedRows:H,getRowId:Pe}),zn&&Fn.rootAggregationPosition!==null&&a.jsx(ma,{columns:Le.virtualColumns,aggregationModel:$e,aggregationResult:Bn,columnWidths:oo,rowHeight:et,checkboxSelection:c,hasDetailPanel:ft,rowReordering:dt,pinCheckboxColumn:L,pinExpandColumn:O,pinnedColumns:Tt,loading:Cf})]})]})}),Wo&&a.jsx(Wo,{apiRef:Ln.apiRef,aggregationModel:$e,aggregationResult:zn?Bn:null,rowCount:Io&&k!=="server"?At.length:Do,pagination:Be,paginationModel:Ae,pageSizeOptions:I,onPaginationModelChange:Pt,...V?.footer}),!eo&&!Wo&&Be&&a.jsx(Ed,{paginationSlot:U?.pagination,paginationSlotProps:V?.pagination,page:Fo.currentPage,paginationModel:Ae,rowCount:Do,pageSizeOptions:I,onPaginationModelChange:Pt,localeText:xe}),a.jsx(Md,{loading:tt,error:Me.dataSource.error,noRowsLabel:Ze,filteredRowCount:vl.length,dataRowCount:At.length,filterModel:He}),Vf&&a.jsx(Pc,{overlay:Un}),a.jsx(va,{error:Me.dataSource.error,onRetry:$?ul.fetchRows:void 0})]})}function Ld({rows:e=5,columns:t=5}){return a.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((o,n)=>a.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>a.jsx("div",{className:"ogx__skeleton-cell",children:a.jsx("div",{className:"ogx__skeleton-content"})},i))},n))})}const Fd=300;function kt(e){return"field"in e&&!("items"in e)}function Li(e,t){return e.find(o=>kt(o)&&o.field===t)}function Fi(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)=>Fi(o,t[n])):!1}function Od(e,t){return e===t?!0:kt(e)&&kt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Fi(e.value,t.value):!kt(e)&&!kt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&Sn(e.items,t.items):!1}function Sn(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>Od(o,t[n]))}function Ad(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 Oi(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Ai(e,t){return e==null?"":t.type==="date"||e instanceof Date?Yn(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(o=>String(o)).join(", "):String(e)}function Di(e,t){return t==="isAnyOf"?e.split(",").map(o=>o.trim()).filter(o=>o!==""):e}function Dd(e,t){if(!Jo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const $d=({col:e,item:t,resetToken:o,onChange:n})=>{const r=s.useId(),i=Ql(e.type),l=i[0],d=t?.operator??l,c=i.includes(d)?i:[d,...i],u=!!t,g=e.headerName||e.field,[w,x]=s.useState(null),[v,p]=s.useState(o);v!==o&&(p(o),x(null));const f=s.useRef(n),m=s.useRef(t),b=s.useRef(e);s.useLayoutEffect(()=>{f.current=n,m.current=t,b.current=e});const h=s.useCallback((M,P)=>({id:m.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:M,value:P}),[e.field]),y=s.useCallback(M=>{const P=m.current;if(P?M===Ai(P.value,b.current):M.trim()==="")return;const L=P?.operator??l;f.current(h(L,Di(M,L)))},[l,h]),S=s.useRef(null),N=s.useRef(y);s.useLayoutEffect(()=>{S.current=w,N.current=y}),s.useEffect(()=>()=>{const M=S.current;S.current=null,M!==null&&N.current(M)},[]),s.useEffect(()=>{if(w===null)return;const M=setTimeout(()=>{S.current=null,y(w),x(null)},Fd);return()=>clearTimeout(M)},[w,y]);const T=M=>{const P=w!==null?Di(w,M):t?.value;x(null),n(h(M,Dd(P,M)))},E=()=>{x(null),n(null)},I=!Jo.has(d),F=Ad(e),G=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,H=`Filter value for ${g}`;let _=null;if(I&&e.type==="boolean")_=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:M=>{M.target.value===""?n(null):n(h(d,M.target.value))},"aria-label":H,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"true",children:"true"}),a.jsx("option",{value:"false",children:"false"})]});else if(I&&e.type==="singleSelect"&&F.length>0&&d==="isAnyOf"){const M=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];_=a.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(F.length,4),value:F.filter(P=>M.some(C=>Oi(P,C))).map(P=>P.key),onChange:P=>{const C=new Set(Array.from(P.target.selectedOptions,L=>L.value));n(h("isAnyOf",F.filter(L=>C.has(L.key)).map(L=>L.value)))},"aria-label":H,children:F.map(P=>a.jsx("option",{value:P.key,children:P.label},P.key))})}else if(I&&e.type==="singleSelect"&&F.length>0&&(d==="is"||d==="not")){const M=F.find(P=>Oi(P,t?.value));_=a.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${G} ogx-filter__value-select`,value:M?.key??"",onChange:P=>{const C=F.find(L=>L.key===P.target.value);n(h(d,C?C.value:""))},"aria-label":H,children:[a.jsx("option",{value:"",children:"Any"}),F.map(P=>a.jsx("option",{value:P.key,children:P.label},P.key))]})}else I&&(_=a.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:G,type:e.type==="date"?"date":"text",value:w??Ai(t?.value,e),onChange:M=>x(M.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":H}));return a.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[a.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),a.jsxs("div",{className:"ogx-filter__controls",children:[a.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:d,onChange:M=>T(M.target.value),"aria-label":`Filter operator for ${g}`,children:c.map(M=>a.jsx("option",{value:M,children:M},M))}),_,u&&a.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},$i=({filterModel:e,columns:t,onFilterModelChange:o})=>{const n=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[d,c]=s.useState(n),[u,g]=s.useState(0);if(d!==n){c(n);const m=!Sn(d,n),b=i!==null&&Sn(i,n);m&&!b&&g(h=>h+1)}const w=s.useCallback((m,b)=>{const h=n.findIndex(S=>kt(S)&&S.field===m);let y;if(h===-1){if(!b)return;y=[...n,b]}else b?y=n.map((S,N)=>N===h?b:S):y=n.filter((S,N)=>N!==h);l(y),o({...e,items:y})},[n,e,o]),x=s.useCallback(m=>{o({...e,logicOperator:m})},[e,o]),v=t.filter(m=>m.filterable!==!1),p=v.filter(m=>Li(n,m.field)).length,f=n.length-p;return a.jsxs(a.Fragment,{children:[n.length>1&&a.jsxs("div",{className:"ogx-filter__logic-bar",children:[a.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),a.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),f>0&&a.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?a.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):v.map(m=>a.jsx($d,{col:m,item:Li(n,m.field),resetToken:u,onChange:b=>w(m.field,b)},m.field))]})},Gi=["sum","avg","count","min","max"];function Wi(){return a.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),a.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),a.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Gd({anchorRef:e,columns:t,model:o,onChange:n,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),[c,u]=s.useState(null);s.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const C=e.current.getBoundingClientRect();return{top:C.bottom+6,right:xt()-C.right}},[e]);s.useEffect(()=>{d(g());const C=()=>d(g());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[g]),s.useEffect(()=>{function C(O){i.current&&!i.current.contains(O.target)&&e.current&&!e.current.contains(O.target)&&r()}function L(O){O.key==="Escape"&&r()}return document.addEventListener("mousedown",C),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",L)}},[e,r]);const w=new Set(o.rowFields),x=new Set(o.columnFields),v=new Set(o.valueFields.map(C=>C.field)),p=C=>w.has(C)||x.has(C)||v.has(C),f=C=>t.find(L=>L.field===C),m=C=>f(C)?.headerName??C,b=C=>{const L=f(C)?.availableAggregationFunctions;return L?Gi.filter(O=>L.includes(O)):Gi},h=C=>C.aggregable!==!1&&(C.type==="number"||C.aggregable===!0)&&b(C.field).length>0,y=C=>C.groupable!==!1;function S(C){w.has(C)||n({...o,rowFields:[...o.rowFields,C]})}function N(C){x.has(C)||n({...o,columnFields:[...o.columnFields,C]})}function T(C){v.has(C)||n({...o,valueFields:[...o.valueFields,{field:C,aggFn:b(C)[0]??"sum"}]})}function E(C){n({...o,rowFields:o.rowFields.filter((L,O)=>O!==C)})}function I(C){n({...o,columnFields:o.columnFields.filter((L,O)=>O!==C)})}function F(C){n({...o,valueFields:o.valueFields.filter((L,O)=>O!==C)})}function G(C,L){n({...o,valueFields:o.valueFields.map((O,j)=>j===C?{...O,aggFn:L}:O)})}function H(){n({rowFields:[],columnFields:[],valueFields:[]})}const _=o.rowFields.length+o.columnFields.length+o.valueFields.length,M=t.filter(C=>!p(C.field)&&(y(C)||h(C))),P=a.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[a.jsxs("div",{className:"ogx-pivot-panel__header",children:[a.jsxs("span",{className:"ogx-pivot-panel__title",children:[a.jsx(Wi,{}),"Pivot Mode"]}),_>0&&a.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:H,title:"Reset pivot",children:"Reset"})]}),a.jsxs("div",{className:"ogx-pivot-panel__body",children:[a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${o.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:o.rowFields.map((C,L)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[m(C),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(L),title:`Remove ${m(C)}`,"aria-label":`Remove ${m(C)} from Row Fields`,children:"×"})]},`${L}:${C}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),a.jsx("div",{className:`ogx-pivot-chips${o.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:o.columnFields.map((C,L)=>a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[m(C),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>I(L),title:`Remove ${m(C)}`,"aria-label":`Remove ${m(C)} from Column Fields`,children:"×"})]},`${L}:${C}`))})]}),a.jsxs("div",{className:"ogx-pivot-zone",children:[a.jsxs("span",{className:"ogx-pivot-zone__label",children:[a.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),a.jsx("div",{className:`ogx-pivot-chips${o.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:o.valueFields.map((C,L)=>{const O=b(C.field),j=O.includes(C.aggFn)?O:[C.aggFn,...O];return a.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[m(C.field),a.jsx("select",{className:"ogx-pivot-chip__fn-select",value:C.aggFn,onChange:W=>G(L,W.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${m(C.field)}`,children:j.map(W=>a.jsx("option",{value:W,children:W.toUpperCase()},W))}),a.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>F(L),title:`Remove ${m(C.field)}`,"aria-label":`Remove ${m(C.field)} (${C.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${L}:${C.field}:${C.aggFn}`)})})]}),a.jsx("hr",{className:"ogx-pivot-panel__divider"}),a.jsxs("div",{children:[a.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),a.jsxs("div",{className:"ogx-pivot-fields",children:[M.map(C=>{const L=h(C),O=y(C),j=C.headerName??C.field;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[a.jsx("span",{className:`ogx-pivot-field-btn${L?" ogx-pivot-field-btn--numeric":""}`,children:j}),a.jsxs("div",{className:"ogx-pivot-field-actions",children:[O&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>S(C.field),title:"Add to Row Fields","aria-label":`Add ${j} to Row Fields`,children:"Row"}),O&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>N(C.field),title:"Add to Column Fields","aria-label":`Add ${j} to Column Fields`,children:"Col"}),L&&a.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>T(C.field),title:"Add to Value Fields","aria-label":`Add ${j} to Value Fields`,children:"Val"})]})]},C.field)}),M.length===0&&a.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return c?ot.createPortal(P,c):null}function Wd(){return a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hd(){return a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Hi(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Bd({value:e="",onChange:t,placeholder:o="Search...",debounceMs:n=250}){const[r,i]=s.useState(()=>e.length>0),[l,d]=s.useState(e),c=s.useRef(null),u=s.useRef(null),g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t},[t]);const w=s.useRef(e),x=s.useRef(e);s.useEffect(()=>{e!==x.current&&(x.current=e,Hi(e)!==Hi(w.current)&&(d(e),w.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const h=setTimeout(()=>{l!==w.current&&(w.current=l,g.current(l))},n);return()=>clearTimeout(h)},[l,n]);const v=s.useRef(l);s.useLayoutEffect(()=>{v.current=l}),s.useEffect(()=>()=>{const h=v.current;h!==w.current&&(w.current=h,g.current(h))},[]);const p=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>c.current?.focus())},[]),f=s.useCallback(h=>{h.stopPropagation(),d(""),w.current="",g.current(""),c.current?.focus()},[]),m=s.useCallback(()=>{i(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const h=y=>{u.current&&!u.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),a.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:p,children:[a.jsx("div",{className:"ogx-global-search__icon-wrapper",children:a.jsx(Wd,{})}),a.jsx("input",{ref:c,className:"ogx-global-search__input",value:l,onChange:h=>d(h.target.value),onFocus:m,onBlur:b,placeholder:o,"aria-label":"Global Search",autoComplete:"off"}),l&&a.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:a.jsx(Hd,{})})]})}const _o=8;function Rt({title:e,children:t,placement:o="top",enterDelay:n=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[d,c]=s.useState({top:0,left:0}),[u,g]=s.useState(null),w=s.useRef(null),x=s.useRef(null),v=s.useId(),p=s.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":c({top:N.bottom+_o,left:T});break;case"left":c({top:E,left:N.left-_o});break;case"right":c({top:E,left:N.right+_o});break;default:c({top:N.top-_o,left:T})}},[o]),f=s.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;p();const N=T=>{T.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),document.addEventListener("keydown",N),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),document.removeEventListener("keydown",N)}},[i,p,f]),s.useEffect(()=>f,[f]);const m=()=>{f(),w.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},n)},b=()=>{f(),w.current=setTimeout(()=>{l(!1)},r)},h=s.useCallback(N=>{x.current=N?N.firstElementChild??N:null},[]),y=i&&!!e&&u!==null;let S=t;if(y&&s.isValidElement(t)){const N=t,T=N.props["aria-describedby"];S=s.cloneElement(N,{"aria-describedby":T?`${T} ${v}`:v})}return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:h,style:{display:"inline-block",lineHeight:0},onMouseEnter:m,onMouseLeave:b,onFocus:m,onBlur:b,children:S}),y&&u&&ot.createPortal(a.jsx("div",{id:v,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${o}`,style:{top:d.top,left:d.left,position:"fixed",zIndex:99999},children:e}),u)]})}const zd=Object.keys(co);function Vd(e){return Object.prototype.hasOwnProperty.call(co,e)}function Bi(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Vd))):zd}function zi(){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Kd(){return a.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[a.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),a.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),a.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Vi(){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Ud({anchorRef:e,aggregationModel:t,aggregableColumns:o,onFunctionChange:n,onClearAll:r,onClose:i,activeCount:l}){const d=s.useRef(null),[c,u]=s.useState({top:0,right:0}),[g,w]=s.useState(null);s.useLayoutEffect(()=>{w(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:xt()-p.right}},[e]);s.useEffect(()=>{u(x());const p=()=>u(x());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[x]),s.useEffect(()=>{function p(f){d.current&&!d.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,i]),s.useEffect(()=>{function p(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]);const v=a.jsxs("div",{ref:d,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(zi,{}),"Summaries"]}),l>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),a.jsx("div",{className:"ogx-toolbar__panel-body",children:o.length===0?a.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",a.jsx("br",{}),"Set ",a.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):o.map(p=>{const f=t[p.field]||"none";return a.jsxs("div",{className:"ogx-toolbar__agg-row",children:[a.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),a.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Bi(p)].map(m=>a.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===m?" ogx-toolbar__pill--active":""}`,onClick:()=>n(p.field,m),"aria-pressed":f===m,children:m},m))})]},p.field)})})]});return g?ot.createPortal(v,g):null}function jd({anchorRef:e,columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,onClose:c,showNonHideableColumns:u}){const g=s.useRef(null),[w,x]=s.useState({top:0,right:0}),[v,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const b=e.current.getBoundingClientRect();return{top:b.bottom+6,right:xt()-b.right}},[e]);s.useEffect(()=>{x(f());const b=()=>x(f());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[f]),s.useEffect(()=>{function b(h){g.current&&!g.current.contains(h.target)&&e.current&&!e.current.contains(h.target)&&c()}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e,c]),s.useEffect(()=>{function b(h){h.key==="Escape"&&c()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const m=a.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:a.jsx(yn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:d,showNonHideableColumns:u})});return v?ot.createPortal(m,v):null}function qd({anchorRef:e,columns:t,filterModel:o,onFilterModelChange:n,onClose:r}){const i=s.useRef(null),[l,d]=s.useState({top:0,right:0}),c=s.useRef(r);s.useLayoutEffect(()=>{c.current=r},[r]);const[u,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const w=s.useCallback(()=>{if(!e.current)return{top:0,right:0};const f=e.current.getBoundingClientRect();return{top:f.bottom+6,right:xt()-f.right}},[e]);s.useEffect(()=>{d(w());const f=()=>d(w());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[w]),s.useEffect(()=>{function f(m){m.key==="Escape"&&c.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=o.items?.length??0,v=()=>{n({...o,items:[],logicOperator:"and"})},p=a.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:"ogx-toolbar__panel-header",children:[a.jsxs("span",{className:"ogx-toolbar__panel-title",children:[a.jsx(Vi,{}),"Filters",x>0&&a.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&a.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:v,title:"Clear all filters",children:"Clear all"}),a.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>c.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),a.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:a.jsx($i,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?ot.createPortal(p,u):null}const Xd={rowFields:[],columnFields:[],valueFields:[]};function Rd({columns:e=[],baseColumns:t,aggregationModel:o={},onAggregationModelChange:n,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:d,columnVisibilityModel:c={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:w,forceColumnsOpen:x,onColumnsPanelClose:v,children:p,rightContent:f,style:m,renderColumnsButton:b,renderFilterButton:h,renderAggregationButton:y,renderExportButton:S,renderQuickFilter:N,className:T,showNonHideableColumns:E}){const[I,F]=s.useState(null),G=I==="summaries",H=I==="pivot",_=I==="columns",M=I==="filters",P=R=>{I==="columns"&&R!=="columns"&&v?.(),F(R)},C=R=>P(I===R?null:R),L=R=>{I===R&&P(null)};s.useEffect(()=>{x&&F("columns")},[x]);const O=s.useContext(Vr),j=x!==void 0&&!!u;s.useEffect(()=>{if(!(!O||!j))return O.registerColumnsPanel()},[O,j]);const W=s.useRef(null),Z=s.useRef(null),oe=s.useRef(null),ie=s.useRef(null),te=s.useRef(null),ue=s.useRef(null),de=s.useRef(null),re=r??Xd,ce=re.rowFields.length>0||re.columnFields.length>0||re.valueFields.length>0,le=t?new Set(t.map(R=>R.field)):null,D=e.filter(R=>R.aggregable!==!1&&(R.type==="number"||R.aggregable===!0)&&Bi(R).length>0&&(!le||le.has(R.field))),ee=Object.keys(o).filter(R=>o[R]&&o[R]!=="none").length,J=s.useCallback((R,k)=>{if(!n)return;const K={...o};k==="none"?delete K[R]:K[R]=k,n(K)},[o,n]),Y=s.useCallback(()=>{n?.({})},[n]),Q=s.useCallback(R=>{if(!d)return;const k=R.trim().split(/\s+/).filter(Boolean),K={...l||{},quickFilterValues:k,items:l?.items||[]};d(K)},[l,d]),z=(l?.quickFilterValues??[]).join(" "),q=l?.items?.length||0,X=new Set(e.filter(R=>c[R.field]!==!1).map(R=>R.field)),$=s.useCallback((R,k)=>{if(!u)return;const K={...c,[R]:k};u(K)},[c,u]),B=s.useCallback(()=>{if(!u)return;const R={...c};e.forEach(k=>{k.hideable!==!1&&(R[k.field]=!0)}),u(R)},[e,c,u]),A=s.useCallback(()=>{if(!u)return;const R={...c};e.forEach(k=>{k.hideable!==!1&&(R[k.field]=!1)}),u(R)},[e,c,u]);return a.jsxs("div",{className:["ogx-toolbar",T].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:m,children:[p&&a.jsx("div",{className:"ogx-toolbar__left",children:p}),a.jsx("div",{className:"ogx-toolbar__spacer"}),a.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&a.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:z,onChange:Q}):a.jsx(Bd,{value:z,onChange:Q,placeholder:"Search..."})}),u&&a.jsxs("div",{ref:te,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>C("columns"),isOpen:_,activeCount:e.length-X.size}):a.jsx(Rt,{title:"Columns",children:a.jsx("button",{type:"button",ref:oe,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":_,onClick:()=>C("columns"),children:a.jsx(Kd,{})})}),_&&a.jsx(jd,{anchorRef:b?te:oe,columns:e,visibleColumns:X,onVisibilityChange:$,onShowAll:B,onHideAll:A,onColumnReorder:g,onColumnOrderReset:w,onClose:()=>L("columns"),showNonHideableColumns:E})]}),d&&a.jsxs("div",{ref:ue,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[h?h({onClick:()=>C("filters"),isOpen:M,activeCount:q}):a.jsx(Rt,{title:"Filters",children:a.jsxs("button",{type:"button",ref:ie,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":M,onClick:()=>C("filters"),children:[a.jsx(Vi,{}),q>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),M&&a.jsx(qd,{anchorRef:h?ue:ie,columns:e,filterModel:l||{items:[]},onFilterModelChange:d,onClose:()=>L("filters")})]}),i&&a.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[a.jsx(Rt,{title:"Pivot",children:a.jsxs("button",{type:"button",ref:Z,className:`ogx-toolbar__icon-btn${H?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":H,onClick:()=>C("pivot"),children:[a.jsx(Wi,{}),ce&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),H&&a.jsx(Gd,{anchorRef:Z,columns:t??e,model:re,onChange:R=>{i?.(R)},onClose:()=>L("pivot")})]}),n&&a.jsxs("div",{ref:de,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>C("summaries"),isOpen:G,activeCount:ee}):a.jsx(Rt,{title:"Summaries",children:a.jsxs("button",{type:"button",ref:W,className:`ogx-toolbar__icon-btn${G?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":G,onClick:()=>C("summaries"),children:[a.jsx(zi,{}),ee>0&&a.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${ee} active summaries`})]})}),G&&a.jsx(Ud,{anchorRef:y?de:W,aggregationModel:o,aggregableColumns:D,onFunctionChange:J,onClearAll:Y,onClose:()=>L("summaries"),activeCount:ee})]}),S&&S(),f]})]})}function Yd(){const[e]=s.useState(Zr);return s.useRef(e)}const Jd=({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 a.jsxs("div",{className:l,children:[o&&a.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),a.jsx("input",{className:"ogx-input",...i}),n&&a.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 Qd=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 Zd(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 eu(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Qd.has(r)){t+=n;continue}const i=Zd(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const tu={sliceMs:30,renderChunkRows:40},ou=2e4;function Ki(){return new Promise(e=>setTimeout(e,0))}function nu(){return new DOMException("PDF export was aborted","AbortError")}const Mt=()=>typeof performance<"u"?performance.now():Date.now(),Ui=e=>Math.max(2,Math.floor(e/2)*2),ru=[79,70,229],iu=[255,255,255];function ji(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 qi(e,t){return yo(e,t,Xt(e,t))}function Xi(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function lu(e,t){const o=e.reduce((r,i)=>r+Xi(i),0),n={};return e.forEach((r,i)=>{n[i]={cellWidth:Xi(r)/o*t}}),n}const su=new Set(["isEmpty","isNotEmpty"]);function au(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(su.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 Ri(e,t,o,n){const r=e.map(l=>"items"in l?Ri(l.items,l.logicOperator,o,!0):au(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 cu(e,t){const o=[],n=Ri(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 du=1.15*.3528;function uu(e,t,o={}){return fu(e,t,o,tu)}async function fu(e,t,o,n){const{signal:r,onProgress:i}=o,l=()=>{if(r?.aborted)throw nu()};l();let d,c;try{const[U,V]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);d=U.default,c=V.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:u="export",title:g,logoUrl:w,orientation:x="landscape",selectedRows:v,getRowId:p,aggregationResult:f,aggregationModel:m,filterModel:b,alternateRowColor:h=!0,headerBackgroundColor:y="#4f46e5",headerTextColor:S="#ffffff",fontSize:N=9,groupedRows:T,font:E,maxRows:I=ou}=o;l();let F=Mt();const G=async()=>{Mt()-F<n.sliceMs||(await Ki(),l(),F=Mt())},H=(U,V,ne)=>{i?.({phase:U,done:V,total:ne})},_=new d({orientation:x,unit:"mm",format:"a4"}),M=_.internal.pageSize.getWidth(),P=_.internal.pageSize.getHeight(),C=14,L=M-C*2;let O="helvetica";E&&(_.addFileToVFS(`${E.name}-normal.ttf`,E.data),_.addFont(`${E.name}-normal.ttf`,E.name,"normal"),E.boldData&&_.addFileToVFS(`${E.name}-bold.ttf`,E.boldData),_.addFont(E.boldData?`${E.name}-bold.ttf`:`${E.name}-normal.ttf`,E.name,"bold"),O=E.name);let j=!1;const W=U=>{if(E)return U;const V=eu(U);return V.lossy&&(j=!0),V.text},Z=(U,V,ne,fe,pe)=>{const he=_.splitTextToSize(W(U),fe);return _.text(he.length===1?he[0]:he,V,ne),Math.max(0,he.length-1)*pe*du},oe=st(t),ie=qt(T,v),te=jt(e,v,p);let ue=C;if(g){let U=C,V=C+8;if(w)try{_.addImage(w,"PNG",U,C,10,10),U+=14}catch{}const ne=M-C-U;_.setFontSize(16),_.setFont(O,"bold"),_.setTextColor(30,41,59),V+=Z(g,U,V,ne,16),V+=6,_.setFontSize(8),_.setFont(O,"normal"),_.setTextColor(100,116,139);const fe=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),pe=ie?T.filter(he=>he.type==="leaf").length:te.length;if(_.text(W(`Exported: ${fe} • ${pe} row${pe!==1?"s":""}`),U,V),V+=5,b){const he=cu(b,t);he&&(V+=Z(`Filters: ${he}`,U,V,ne,8),V+=5)}_.setDrawColor(226,232,240),_.setLineWidth(.3),_.line(C,V+2,M-C,V+2),ue=V+6}const de=[oe.map(U=>W(U.headerName??U.field))],re=m||{},ce=U=>oe.map(V=>Cn(V,re[V.field],U[V.field],U)),le=[];let D;const ee=U=>{le.push(U.map(W))};if(ie){const U=T.length;H("prepare",0,U);for(let V=0;V<U;V++){const ne=T[V],fe=" ".repeat(ne.depth*2);if(ne.type==="group-header"){const pe=`${fe}${Et(ne,t)}`;ee(oe.map((he,ge)=>ge===0?pe:""))}else if(ne.type==="leaf"&&ne.row){const pe=ne.row;ee(oe.map((he,ge)=>(ge===0?fe:"")+qi(pe,he)))}else if(ne.type==="group-subtotal"&&ne.aggregatedValues){const pe=ce(ne.aggregatedValues);ee(pe.map((he,ge)=>ge===0?`${fe}${St("Subtotal",he)}`:he))}else ne.type==="grand-total"&&ne.aggregatedValues&&(D=[ce(ne.aggregatedValues).map((he,ge)=>ge===0?St("Grand Total",he):he).map(W)]);(V&63)===63&&(H("prepare",V+1,U),await G())}H("prepare",U,U)}else{const U=te.length;H("prepare",0,U);for(let ne=0;ne<U;ne++)ee(oe.map(fe=>qi(te[ne],fe))),(ne&63)===63&&(H("prepare",ne+1,U),await G());const V=m?_t(te,Ye(v),t,f,m):null;if(V&&m){const ne=oe.some(pe=>m[pe.field]);D=[ce(V).map((pe,he)=>he===0&&ne?St("TOTAL",pe):pe).map(W)]}H("prepare",U,U)}l(),le.length>I&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${le.length} table rows (maxRows: ${I}). PDFs this large are slow to build and open and can reach tens of MB. Prefer exportToCsv or exportToExcelAdvanced for full-dataset exports, or pass a larger \`maxRows\` to silence this warning.`),j&&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 J=lu(oe,L),[Y,Q,z]=ji(y,ru),[q,X,$]=ji(S,iu),B={head:de,styles:{fontSize:N,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[Y,Q,z],textColor:[q,X,$],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...D?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:J,showHead:"everyPage",margin:{top:C,left:C,right:C,bottom:C+6}},A=le.length;H("render",0,A);let R=0,k=Ui(n.renderChunkRows);do{const U=le.slice(R,R+k),V=R===0,ne=R+U.length>=A,fe=V?ue:_.lastAutoTable.finalY;let pe=!0;const he=Mt();c(_,{...B,body:U,...ne&&D?{foot:D}:{},startY:V?ue:C,showFoot:ne&&D?"lastPage":"never",...V?{}:{willDrawPage:be=>{pe?(pe=!1,be.settings.showHead="never",be.cursor&&(be.cursor.y=fe)):be.settings.showHead="everyPage"}}}),R+=U.length,H("render",R,A);const ge=Mt()-he;k=Ui(ge>0?Math.min(k*4,k*(n.sliceMs/ge)):k*4),ne||(await Ki(),l(),F=Mt())}while(R<A);const K=_.getNumberOfPages();for(let U=1;U<=K;U++)_.setPage(U),_.setFontSize(8),_.setTextColor(150,150,150),_.text(`Page ${U} of ${K}`,M-C,P-8,{align:"right"}),await G();l(),H("save",0,1),_.save(`${u}.pdf`),H("save",1,1)}function Yt(e,t){const o=Xt(e,t);return{text:yo(e,t,o),raw:o}}function Nt(e,t,o){return e.map(n=>Cn(n,o[n.field],t[n.field],t))}const gu="\uFEFF";function pu(e,t,o={}){const{fileName:n="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:d,escapeFormulas:c=!0,bom:u=!0}=o,g=st(t),w=o.aggregationModel||{},x=(f,m=!1)=>So(c?Co(f,m):f,i),v=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
5
+ `;let p="";if(qt(d,l))r&&(p+=v()),d.forEach(f=>{const m=" ".repeat(f.depth);if(f.type==="group-header"){const b=Et(f,t),h=So(m+(c?Co(b):b),i);p+=g.map((y,S)=>S===0?h:"").join(i)+`
6
+ `}else if(f.type==="leaf"&&f.row){const b=f.row,h=g.map((y,S)=>{const N=Yt(b,y),T=c?Co(N.text,Je(N.raw)):N.text;return So((S===0?m:"")+T,i)});p+=h.join(i)+`
7
+ `}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.aggregatedValues,h=f.type==="grand-total"?"Grand Total":`${m}Subtotal`,y=Nt(g,b,w),S=g.map((N,T)=>T===0?So(St(h,y[0]),i):x(y[T],Je(b[N.field])));p+=S.join(i)+`
8
+ `}});else{const f=jt(e,l,o.getRowId);if(f.length===0){console.warn("No rows to export");return}r&&(p+=v()),f.forEach(b=>{const h=g.map(y=>{const S=Yt(b,y);return x(S.text,Je(S.raw))});p+=h.join(i)+`
9
+ `});const m=_t(f,Ye(l),t,o.aggregationResult,o.aggregationModel);if(m){const b=g.map(y=>x(w[y.field]?w[y.field].toUpperCase():""));p+=b.join(i)+`
10
+ `;const h=Nt(g,m,w);p+=g.map((y,S)=>x(h[S],Je(m[y.field]))).join(i)+`
11
+ `}}kn((u?gu:"")+p,n,"text/csv;charset=utf-8;")}function So(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
12
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const ko="ogx-xls-text";function hu(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Je(t)}function wu(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 mu(e,t,o={}){const{fileName:n="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:d,escapeFormulas:c=!0}=o,u=st(t),g=o.aggregationModel||{},w=(m,b=!1)=>Ee(c?Co(m,b):m),x=m=>`<td class="${ko}">${m}</td>`;let p=`<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>${Ee(_n(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${ko}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(p+="<thead><tr>",u.forEach(m=>{p+=`<th class="${ko}">${w(m.headerName||m.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>";const f=(m,b,h="")=>{const y=h+w(m.text,Je(m.raw));return hu(b,m.raw)?x(y):`<td>${y}</td>`};if(qt(d,l))d.forEach(m=>{const b=" ".repeat(m.depth*2);if(m.type==="group-header")p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${u.length}" class="${ko}">${Ee(b)}${w(Et(m,t))}</td>`,p+="</tr>";else if(m.type==="leaf"&&m.row){const h=m.row;p+="<tr>",u.forEach((y,S)=>{p+=f(Yt(h,y),y,S===0?Ee(b):"")}),p+="</tr>"}else if((m.type==="group-subtotal"||m.type==="grand-total")&&m.aggregatedValues){const h=m.aggregatedValues,y=m.type==="grand-total"?"Grand Total":`${b}Subtotal`,S=Nt(u,h,g);p+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((N,T)=>{if(T===0){p+=x(Ee(St(y,S[0])));return}p+=S[T]?`<td style="text-align:right;">${w(S[T],Je(h[N.field]))}</td>`:"<td></td>"}),p+="</tr>"}});else{const m=jt(e,l,o.getRowId);if(m.length===0){console.warn("No rows to export");return}m.forEach(h=>{p+="<tr>",u.forEach(y=>{p+=f(Yt(h,y),y)}),p+="</tr>"});const b=_t(m,Ye(l),t,o.aggregationResult,o.aggregationModel);if(b){p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(y=>{p+=g[y.field]?`<td style="text-align:right;font-weight:bold;">${Ee(g[y.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const h=Nt(u,b,g);u.forEach((y,S)=>{p+=h[S]?`<td style="text-align:right;">${w(h[S],Je(b[y.field]))}</td>`:"<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",kn(p,wu(n),"application/vnd.ms-excel")}function xu(e,t,o={}){const{fileName:n="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=o,d=st(t),c=g=>{const w={};return d.forEach(x=>{w[x.field]=Xt(g,x)}),w};let u;if(qt(l,i)){const g=[],w=[];let x;l.forEach(v=>{if(v.type==="group-header"){const p={group:Et(v,t),field:v.groupField??"",value:v.groupValue,rows:[],children:[]};for(;g.length>v.depth;)g.pop();g.length===0?w.push(p):(g[g.length-1].children??=[]).push(p),g.push(p)}else v.type==="leaf"&&v.row?g.length>0&&g[g.length-1].rows.push(c(v.row)):v.type==="group-subtotal"&&v.aggregatedValues&&g.length>0?(g[g.length-1].subtotals=Mi(v.aggregatedValues,d),g.pop()):v.type==="grand-total"&&v.aggregatedValues&&(x=Mi(v.aggregatedValues,d))}),u=x?{groups:w,grandTotal:x}:{groups:w}}else{const g=jt(e,i,o.getRowId);if(g.length===0){console.warn("No rows to export");return}const w=g.map(c),x=_t(g,Ye(i),t,o.aggregationResult,o.aggregationModel);if(x){const v=o.aggregationModel||{},p={};d.forEach(m=>{v[m.field]&&(p[m.field]=v[m.field].toUpperCase())});const f={};d.forEach(m=>{x[m.field]!==void 0&&x[m.field]!==null&&(f[m.field]=x[m.field])}),u={data:w,aggregation:{labels:p,values:f}}}else u=w}kn(r?JSON.stringify(u,null,2):JSON.stringify(u),n,"application/json;charset=utf-8;")}const bu=/^(?:https?:|data:image\/|blob:)/i,vu=/^[a-z][a-z\d+.-]*:/i;function yu(e){const t=e.trim();return t?bu.test(t)?t:vu.test(t)?null:t:null}async function Cu(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>
@@ -29,7 +29,7 @@
29
29
  </div>
30
30
  </body>
31
31
  </html>
32
- `),n.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,c=null,d=null,u;typeof o=="string"?r=o:typeof o=="object"&&(r=o.title||"Print",i=o.selectedRows,l=o.getRowId,c=o.aggregationResult||null,d=o.aggregationModel||null,u=o.groupedRows);const g=st(t),m=d||{};let w=`<!DOCTYPE html><html><head><title>${Ee(r||"Print")}</title><style>
32
+ `),n.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,d=null,c=null,u;typeof o=="string"?r=o:typeof o=="object"&&(r=o.title||"Print",i=o.selectedRows,l=o.getRowId,d=o.aggregationResult||null,c=o.aggregationModel||null,u=o.groupedRows);const g=st(t),w=c||{};let x=`<!DOCTYPE html><html><head><title>${Ee(r||"Print")}</title><style>
33
33
  body{font-family:Arial,sans-serif;margin:20px;}
34
34
  h1{font-size:24px;margin-bottom:20px;}
35
35
  table{border-collapse:collapse;width:100%;}
@@ -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&&(w+=`<h1>${Ee(r)}</h1>`),w+="<table><thead><tr>",g.forEach(f=>{w+=`<th>${Ee(f.headerName||f.field)}</th>`}),w+="</tr></thead><tbody>";const v=(f,x,b="",h=!1)=>{const{text:y}=Yt(f,x),C=x.type==="image"?pu(y):null;if(C!==null){const N=`<img src="${Ee(C)}" alt="${Ee(x.headerName||x.field)}" style="max-height:40px;border-radius:4px;">`;return h?`<td><div style="display:flex;justify-content:center;">${N}</div></td>`:`<td>${N}</td>`}return`<td>${b}${Ee(y)}</td>`};if(Ut(u,i))u.forEach(f=>{const x="&nbsp;".repeat(f.depth*4);if(f.type==="group-header")w+=`<tr class="group-header"><td colspan="${g.length}">${x}${Ee(Et(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const b=f.row;w+="<tr>",g.forEach((h,y)=>{w+=v(b,h,y===0?x:"")}),w+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.type==="grand-total",h=Mt(g,f.aggregatedValues,m);w+=`<tr class="${b?"grand-total":"group-subtotal"}">`,g.forEach((y,C)=>{if(C===0){w+=`<td>${b?"":x}${Ee(St(b?"Grand Total":"Subtotal",h[0]))}</td>`;return}w+=h[C]?`<td style="text-align:right;">${Ee(h[C])}</td>`:"<td></td>"}),w+="</tr>"}});else{const f=jt(e,i,l);if(f.length===0){n.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(b=>{w+="<tr>",g.forEach(h=>{w+=v(b,h,"",!0)}),w+="</tr>"});const x=_t(f,Re(i),t,c,d);x&&(w+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(b=>{w+=m[b.field]?`<td style="text-align:right;font-weight:bold;">${Ee(m[b.field].toUpperCase())}</td>`:"<td></td>"}),w+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Mt(g,x,m).forEach(b=>{w+=b?`<td style="text-align:right;">${Ee(b)}</td>`:"<td></td>"}),w+="</tr></tfoot>")}w+="</tbody></table></body></html>",n.document.open(),n.document.write(w),n.document.close(),n.document.title=r||"Print Preview",n.focus();let p=!1;n.onload=()=>{p||(p=!0,n.print(),setTimeout(()=>{n.close()},100))},setTimeout(()=>{!p&&n&&!n.closed&&(p=!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>${Ee(i)}</p></div>`}}}function Sn(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 mu(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 Rt(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 wu=/^(\d{4})-(\d{2})-(\d{2})$/,xu=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,bu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function vu(e){if(e instanceof Date)return Rt(e);if(typeof e=="number")return Number.isFinite(e)?Rt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=wu.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(xu.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:Rt(n)}}function yu(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"&&bu.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 vu(t)}function qi(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 Rt(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function Cu(e,t){const o=qt(e,t),n=mu(t,o);if(n!=="string"){const r=yu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:qi(o)}return t.valueFormatter?vo(e,t,o):qi(o)}const Xi="#,##0",_u="#,##0.##";function Su(e){return Number.isInteger(e)?Xi:_u}function Yi(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ri(e,t,o){if(!(t?.numFmt||typeof o!="number"||e.type!=="number"))return Su(o)}function ku(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function Eu(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 Ji(e,t){const o=qt(e,t);return typeof o=="string"&&o?o:null}async function Mu(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=Eu(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 Nu(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:w,getRowId:v,groupedRows:p,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:x="#f0f4ff"}=o,b=(await import("exceljs")).default,h=new b.Workbook;h.creator="OpenGridX",h.created=new Date;const y=t,C=st(y),N=e,T=Re(w)?ki(N,w,v):[],E=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],I=new Set,F=new Map,G=(_,L)=>{const A=L[_.field],X=m?.[_.field];if(A==null)return{value:null};const z=nr(_,X,A);return typeof z=="number"?Number.isFinite(z)?or(X)?{value:z,numFmt:Xi}:{value:z,numFmt:Ri(_,i[_.field],z)}:{value:null}:z instanceof Date?{value:Rt(z)}:{value:yn(_,X,A,L)}};for(const _ of E){if("type"in _&&_.type==="summary"){if(!g||!m)continue;const W=h.addWorksheet(Cn(_.name??"Summary",I));W.addRow(["Summary / Aggregation Totals"]),W.getRow(1).font={bold:!0,size:d+2,color:{argb:Oe(c)}},W.addRow([]),W.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 K=m[H.field];if(K==null||g[H.field]==null)return;const{value:B,numFmt:Q}=G(H,g),q=W.addRow([H.headerName??H.field,K.toUpperCase(),B]).getCell(3),re=Q??Yi(H,i[H.field]);re&&(q.numFmt=re),q.alignment={horizontal:"right"},q.font={bold:!0,size:u}}),W.getColumn(1).width=20,W.getColumn(2).width=12,W.getColumn(3).width=18;continue}const L=_,{name:A="Data",rows:X="all",includeHeaders:z=!0,includeSummary:J=!1,autoFilter:ee=!0,frozenHeader:ne=!0,alternateRowColor:Z="#f8fafc"}=L,ce=X==="all"&&!!(p&&p.length>0),ae=X==="selected"?T:ce?p.flatMap(W=>W.type==="leaf"&&W.row?[W.row]:[]):N,oe=C.filter(W=>i[W.field]?.embedImage);if(oe.length>0){const W=[],R=new Set;if(ae.forEach(H=>{oe.forEach(K=>{const B=Ji(H,K);B&&!F.has(B)&&!R.has(B)&&(W.push(B),R.add(B))})}),W.length>0){const H=await Mu(W);for(const[K,{buffer:B,extension:Q}]of H){const k=h.addImage({buffer:B,extension:Q});F.set(K,k)}}}const de=h.addWorksheet(Cn(A,I));de.columns=C.map(W=>({key:W.field,width:ku(W,i[W.field]?.width),style:{numFmt:Yi(W,i[W.field])}}));const ie=(W,R)=>{C.forEach((H,K)=>R(W.getCell(K+1),H,K+1))};if(z){const W=C.map(H=>H.headerName??H.field),R=de.addRow(W);R.height=20,ie(R,(H,K)=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.alignment={horizontal:i[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},H.border=Qi()}),ee&&(de.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),ne?de.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:de.views=[{showGridLines:!1}]}let V=z?1:0;const O=(W,R,H)=>{const K=C.map(k=>i[k.field]?.embedImage?"":Cu(W,k)),B=de.addRow(K);B.font={size:u},H>0&&(B.outlineLevel=H);const Q=!!Z&&R%2===1;if(ie(B,(k,q,re)=>{const te=Ri(q,i[q.field],K[re-1]);te&&(k.numFmt=te),Q&&Z&&(k.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(Z)}}),k.alignment={horizontal:i[q.field]?.alignment??(q.type==="number"?"right":"left"),vertical:"middle"},k.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),oe.length>0){const k=oe.reduce((te,ue)=>Math.max(te,i[ue.field]?.imageHeight??40),0),q=Math.ceil(k/1.333),re=q*1.333;B.height=q,oe.forEach(te=>{const ue=C.indexOf(te),ge=Ji(W,te),me=ge?F.get(ge):void 0;if(me===void 0){B.getCell(ue+1).value=ge??"";return}const Se=i[te.field],fe=Se?.imageWidth??40,xe=Se?.imageHeight??40,ve=(de.getColumn(ue+1).width??8)*7+5,se=Math.max(0,ve-fe)/2,ye=Math.max(0,re-xe)/2;de.addImage(me,{tl:{col:ue,row:V,nativeColOff:Math.floor(se*9525),nativeRowOff:Math.floor(ye*9525)},ext:{width:fe,height:xe},editAs:"oneCell"})})}else B.height=16;V++},$=W=>Et(W,y),Y=(W,R,H,K,B)=>{const Q=C.map((q,re)=>re===0&&R[q.field]==null?{value:W}:G(q,R)),k=de.addRow(Q.map(q=>q.value));k.height=18,K>0&&(k.outlineLevel=K),k.font={bold:B,italic:!B,size:u,color:{argb:Oe(c)}},ie(k,(q,re,te)=>{const ue=Q[te-1].numFmt;ue&&(q.numFmt=ue),q.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(H)}},q.alignment={horizontal:te===1?"left":re.type==="number"?"right":"left",vertical:"middle"},q.border=Zi()}),V++};let U=!1;if(ce){let W=0;p.forEach(R=>{if(R.type==="group-header"){const H=de.addRow([$(R)]);H.height=18,R.depth>0&&(H.outlineLevel=R.depth),H.font={bold:!0,size:u,color:{argb:Oe(c)}};for(let K=1;K<=C.length;K++)H.getCell(K).fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(f)}};H.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:R.depth},V++,W=0}else R.type==="leaf"&&R.row?O(R.row,W++,R.depth):R.type==="group-subtotal"&&R.aggregatedValues?Y("Subtotal",R.aggregatedValues,x,R.depth,!1):R.type==="grand-total"&&R.aggregatedValues&&(Y("Grand Total",R.aggregatedValues,l,0,!0),U=!0)}),de.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else ae.forEach((W,R)=>O(W,R,0));const D=_t(ae,X==="selected",y,g,m);if(J&&!U&&D&&m){const W=C.map(B=>{const Q=m[B.field];return Q?Q.toUpperCase():""}),R=de.addRow(W);R.height=16,R.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},ie(R,B=>{B.alignment={horizontal:"right",vertical:"middle"},B.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=C.map(B=>m[B.field]==null?{value:null}:G(B,D)),K=de.addRow(H.map(B=>B.value));K.height=18,K.font={bold:!0,size:u,color:{argb:Oe(c)}},ie(K,(B,Q,k)=>{const q=H[k-1].numFmt;q&&(B.numFmt=q),B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},B.alignment={horizontal:"right",vertical:"middle"},B.border=Zi()})}}const j=await h.xlsx.writeBuffer(),S=new Blob([j],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),M=URL.createObjectURL(S),P=document.createElement("a");P.href=M,P.download=n.endsWith(".xlsx")?n:`${n}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),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 Zi(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Pu(e,t,o,n){return s.useMemo(()=>n?Cr(e,t,o):ln,[e,t,o,n])}const el={"--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)"},tl={"--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",...el},Iu={...tl,"--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",...el,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Tu=[50,100,200,300,400,500,600,700,800,900];function Lu(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 Tu)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 Fu({theme:e,children:t,className:o,style:n}){const r=s.useMemo(()=>({...e.mode==="dark"?Iu:tl,...Lu(e)}),[e]);return a.jsx(Pr.Provider,{value:e,children:a.jsx("div",{className:`ogx-theme-provider ${o||""}`.trim(),style:{...n,...r},children:t})})}const Ou={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"}},Au={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"}},Du={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"}},$u={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"}},Gu={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 Wu(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function ol(e,t){try{const o=t.getItem(e);return o?JSON.parse(o):void 0}catch{return}}function Hu(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 Bu(e){const t=typeof e=="string"?{key:e}:e,{key:o,debounceMs:n=300,include:r,storage:i}=t,[l]=s.useState(Wu),c=i??l,d=s.useRef(r),u=s.useRef(c);s.useLayoutEffect(()=>{d.current=r,u.current=c});const[g,m]=s.useState(()=>({key:o,state:c?ol(o,c):void 0}));let w=g.state;g.key!==o&&(w=c?ol(o,c):void 0,m({key:o,state:w}));const v=s.useRef(null),p=s.useRef(null),f=s.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null);const h=p.current;p.current=null;const y=u.current;h&&y&&Hu(h.key,h.state,d.current,y)},[]),x=s.useCallback(h=>{p.current&&p.current.key!==o&&f(),p.current={key:o,state:h},v.current&&clearTimeout(v.current),v.current=setTimeout(f,n)},[o,f,n]);s.useEffect(()=>f,[f]);const b=s.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),p.current=null;const h=u.current;if(h)try{h.removeItem(o)}catch{}},[o]);return s.useMemo(()=>({initialState:w,onStateChange:x,clearState:b}),[w,x,b])}he.Button=zt,he.Cell=yi,he.Checkbox=Bt,he.ColumnVisibilityPanel=vn,he.DataGrid=Nc,he.DataGridThemeProvider=Fu,he.FilterPanel=Di,he.GridToolbar=Uc,he.GridTooltip=Xt,he.Header=Jr,he.Input=Xc,he.Pagination=mn,he.Row=bo,he.Skeleton=Pc,he.amberTheme=$u,he.compactTheme=Gu,he.darkTheme=Ou,he.emeraldTheme=Du,he.exportToCsv=su,he.exportToExcel=cu,he.exportToExcelAdvanced=Nu,he.exportToJson=uu,he.exportToPdf=iu,he.formatAggregationValue=Yo,he.printGrid=hu,he.roseTheme=Au,he.useAggregation=xi,he.useGridApiRef=qc,he.useGridStateStorage=Bu,he.usePivot=Pu,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})}));
43
+ </style></head><body>`;r&&(x+=`<h1>${Ee(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${Ee(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const v=(f,m,b="",h=!1)=>{const{text:y}=Yt(f,m),S=m.type==="image"?yu(y):null;if(S!==null){const N=`<img src="${Ee(S)}" alt="${Ee(m.headerName||m.field)}" style="max-height:40px;border-radius:4px;">`;return h?`<td><div style="display:flex;justify-content:center;">${N}</div></td>`:`<td>${N}</td>`}return`<td>${b}${Ee(y)}</td>`};if(qt(u,i))u.forEach(f=>{const m="&nbsp;".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${m}${Ee(Et(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const b=f.row;x+="<tr>",g.forEach((h,y)=>{x+=v(b,h,y===0?m:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.type==="grand-total",h=Nt(g,f.aggregatedValues,w);x+=`<tr class="${b?"grand-total":"group-subtotal"}">`,g.forEach((y,S)=>{if(S===0){x+=`<td>${b?"":m}${Ee(St(b?"Grand Total":"Subtotal",h[0]))}</td>`;return}x+=h[S]?`<td style="text-align:right;">${Ee(h[S])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=jt(e,i,l);if(f.length===0){n.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(b=>{x+="<tr>",g.forEach(h=>{x+=v(b,h,"",!0)}),x+="</tr>"});const m=_t(f,Ye(i),t,d,c);m&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(b=>{x+=w[b.field]?`<td style="text-align:right;font-weight:bold;">${Ee(w[b.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Nt(g,m,w).forEach(b=>{x+=b?`<td style="text-align:right;">${Ee(b)}</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 p=!1;n.onload=()=>{p||(p=!0,n.print(),setTimeout(()=>{n.close()},100))},setTimeout(()=>{!p&&n&&!n.closed&&(p=!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>${Ee(i)}</p></div>`}}}function kn(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 _u(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 Jt(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 Su=/^(\d{4})-(\d{2})-(\d{2})$/,ku=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,Eu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function Mu(e){if(e instanceof Date)return Jt(e);if(typeof e=="number")return Number.isFinite(e)?Jt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=Su.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(ku.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:Jt(n)}}function Nu(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"&&Eu.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 Mu(t)}function Yi(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 Jt(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=Xt(e,t),n=_u(t,o);if(n!=="string"){const r=Nu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:Yi(o)}return t.valueFormatter?yo(e,t,o):Yi(o)}const Ji="#,##0",Iu="#,##0.##";function Tu(e){return Number.isInteger(e)?Ji:Iu}function Qi(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Zi(e,t,o){if(!(t?.numFmt||typeof o!="number"||e.type!=="number"))return Tu(o)}function Lu(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function Fu(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 el(e,t){const o=Xt(e,t);return typeof o=="string"&&o?o:null}async function Ou(e){const t=await Promise.allSettled(e.map(async n=>{let r;if(n.startsWith("data:")){const l=n.slice(n.indexOf(",")+1),d=atob(l);r=new Uint8Array(d.length);for(let c=0;c<d.length;c++)r[c]=d.charCodeAt(c)}else{const l=await fetch(n,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=Fu(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 Au(e,t,o={}){const{fileName:n="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:d="#334155",headerFontSize:c=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:w=null,selectedRows:x,getRowId:v,groupedRows:p,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:m="#f0f4ff"}=o,b=(await import("exceljs")).default,h=new b.Workbook;h.creator="OpenGridX",h.created=new Date;const y=t,S=st(y),N=e,T=Ye(x)?Ei(N,x,v):[],E=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],I=new Set,F=new Map,G=(C,L)=>{const O=L[C.field],j=w?.[C.field];if(O==null)return{value:null};const W=rr(C,j,O);return typeof W=="number"?Number.isFinite(W)?nr(j)?{value:W,numFmt:Ji}:{value:W,numFmt:Zi(C,i[C.field],W)}:{value:null}:W instanceof Date?{value:Jt(W)}:{value:Cn(C,j,O,L)}};for(const C of E){if("type"in C&&C.type==="summary"){if(!g||!w)continue;const q=h.addWorksheet(_n(C.name??"Summary",I));q.addRow(["Summary / Aggregation Totals"]),q.getRow(1).font={bold:!0,size:c+2,color:{argb:Oe(d)}},q.addRow([]),q.addRow(["Column","Function","Value"]).eachCell($=>{$.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},$.font={bold:!0,size:c,color:{argb:Oe(d)}},$.border=tl()}),S.forEach($=>{const B=w[$.field];if(B==null||g[$.field]==null)return;const{value:A,numFmt:R}=G($,g),K=q.addRow([$.headerName??$.field,B.toUpperCase(),A]).getCell(3),U=R??Qi($,i[$.field]);U&&(K.numFmt=U),K.alignment={horizontal:"right"},K.font={bold:!0,size:u}}),q.getColumn(1).width=20,q.getColumn(2).width=12,q.getColumn(3).width=18;continue}const L=C,{name:O="Data",rows:j="all",includeHeaders:W=!0,includeSummary:Z=!1,autoFilter:oe=!0,frozenHeader:ie=!0,alternateRowColor:te="#f8fafc"}=L,ue=j==="all"&&!!(p&&p.length>0),de=j==="selected"?T:ue?p.flatMap(q=>q.type==="leaf"&&q.row?[q.row]:[]):N,re=S.filter(q=>i[q.field]?.embedImage);if(re.length>0){const q=[],X=new Set;if(de.forEach($=>{re.forEach(B=>{const A=el($,B);A&&!F.has(A)&&!X.has(A)&&(q.push(A),X.add(A))})}),q.length>0){const $=await Ou(q);for(const[B,{buffer:A,extension:R}]of $){const k=h.addImage({buffer:A,extension:R});F.set(B,k)}}}const ce=h.addWorksheet(_n(O,I));ce.columns=S.map(q=>({key:q.field,width:Lu(q,i[q.field]?.width),style:{numFmt:Qi(q,i[q.field])}}));const le=(q,X)=>{S.forEach(($,B)=>X(q.getCell(B+1),$,B+1))};if(W){const q=S.map($=>$.headerName??$.field),X=ce.addRow(q);X.height=20,le(X,($,B)=>{$.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},$.font={bold:!0,size:c,color:{argb:Oe(d)}},$.alignment={horizontal:i[B.field]?.alignment??(B.type==="number"?"right":"left"),vertical:"middle"},$.border=tl()}),oe&&(ce.autoFilter={from:{row:1,column:1},to:{row:1,column:S.length}}),ie?ce.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:ce.views=[{showGridLines:!1}]}let D=W?1:0;const ee=(q,X,$)=>{const B=S.map(k=>i[k.field]?.embedImage?"":Pu(q,k)),A=ce.addRow(B);A.font={size:u},$>0&&(A.outlineLevel=$);const R=!!te&&X%2===1;if(le(A,(k,K,U)=>{const V=Zi(K,i[K.field],B[U-1]);V&&(k.numFmt=V),R&&te&&(k.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(te)}}),k.alignment={horizontal:i[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},k.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),re.length>0){const k=re.reduce((V,ne)=>Math.max(V,i[ne.field]?.imageHeight??40),0),K=Math.ceil(k/1.333),U=K*1.333;A.height=K,re.forEach(V=>{const ne=S.indexOf(V),fe=el(q,V),pe=fe?F.get(fe):void 0;if(pe===void 0){A.getCell(ne+1).value=fe??"";return}const he=i[V.field],ge=he?.imageWidth??40,be=he?.imageHeight??40,ye=(ce.getColumn(ne+1).width??8)*7+5,ae=Math.max(0,ye-ge)/2,Ce=Math.max(0,U-be)/2;ce.addImage(pe,{tl:{col:ne,row:D,nativeColOff:Math.floor(ae*9525),nativeRowOff:Math.floor(Ce*9525)},ext:{width:ge,height:be},editAs:"oneCell"})})}else A.height=16;D++},J=q=>Et(q,y),Y=(q,X,$,B,A)=>{const R=S.map((K,U)=>U===0&&X[K.field]==null?{value:q}:G(K,X)),k=ce.addRow(R.map(K=>K.value));k.height=18,B>0&&(k.outlineLevel=B),k.font={bold:A,italic:!A,size:u,color:{argb:Oe(d)}},le(k,(K,U,V)=>{const ne=R[V-1].numFmt;ne&&(K.numFmt=ne),K.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe($)}},K.alignment={horizontal:V===1?"left":U.type==="number"?"right":"left",vertical:"middle"},K.border=ol()}),D++};let Q=!1;if(ue){let q=0;p.forEach(X=>{if(X.type==="group-header"){const $=ce.addRow([J(X)]);$.height=18,X.depth>0&&($.outlineLevel=X.depth),$.font={bold:!0,size:u,color:{argb:Oe(d)}};for(let B=1;B<=S.length;B++)$.getCell(B).fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(f)}};$.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:X.depth},D++,q=0}else X.type==="leaf"&&X.row?ee(X.row,q++,X.depth):X.type==="group-subtotal"&&X.aggregatedValues?Y("Subtotal",X.aggregatedValues,m,X.depth,!1):X.type==="grand-total"&&X.aggregatedValues&&(Y("Grand Total",X.aggregatedValues,l,0,!0),Q=!0)}),ce.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else de.forEach((q,X)=>ee(q,X,0));const z=_t(de,j==="selected",y,g,w);if(Z&&!Q&&z&&w){const q=S.map(A=>{const R=w[A.field];return R?R.toUpperCase():""}),X=ce.addRow(q);X.height=16,X.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},le(X,A=>{A.alignment={horizontal:"right",vertical:"middle"},A.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const $=S.map(A=>w[A.field]==null?{value:null}:G(A,z)),B=ce.addRow($.map(A=>A.value));B.height=18,B.font={bold:!0,size:u,color:{argb:Oe(d)}},le(B,(A,R,k)=>{const K=$[k-1].numFmt;K&&(A.numFmt=K),A.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},A.alignment={horizontal:"right",vertical:"middle"},A.border=ol()})}}const H=await h.xlsx.writeBuffer(),_=new Blob([H],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),M=URL.createObjectURL(_),P=document.createElement("a");P.href=M,P.download=n.endsWith(".xlsx")?n:`${n}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),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 tl(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function ol(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Du(e,t,o,n){return s.useMemo(()=>n?_r(e,t,o):sn,[e,t,o,n])}const nl={"--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)"},rl={"--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",...nl},$u={...rl,"--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",...nl,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Gu=[50,100,200,300,400,500,600,700,800,900];function Wu(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 Gu)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 Hu({theme:e,children:t,className:o,style:n}){const r=s.useMemo(()=>({...e.mode==="dark"?$u:rl,...Wu(e)}),[e]);return a.jsx(Ir.Provider,{value:e,children:a.jsx("div",{className:`ogx-theme-provider ${o||""}`.trim(),style:{...n,...r},children:t})})}const Bu={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"}},zu={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"}},Vu={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"}},Ku={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"}},Uu={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 ju(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function il(e,t){try{const o=t.getItem(e);return o?JSON.parse(o):void 0}catch{return}}function qu(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 Xu(e){const t=typeof e=="string"?{key:e}:e,{key:o,debounceMs:n=300,include:r,storage:i}=t,[l]=s.useState(ju),d=i??l,c=s.useRef(r),u=s.useRef(d);s.useLayoutEffect(()=>{c.current=r,u.current=d});const[g,w]=s.useState(()=>({key:o,state:d?il(o,d):void 0}));let x=g.state;g.key!==o&&(x=d?il(o,d):void 0,w({key:o,state:x}));const v=s.useRef(null),p=s.useRef(null),f=s.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null);const h=p.current;p.current=null;const y=u.current;h&&y&&qu(h.key,h.state,c.current,y)},[]),m=s.useCallback(h=>{p.current&&p.current.key!==o&&f(),p.current={key:o,state:h},v.current&&clearTimeout(v.current),v.current=setTimeout(f,n)},[o,f,n]);s.useEffect(()=>f,[f]);const b=s.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),p.current=null;const h=u.current;if(h)try{h.removeItem(o)}catch{}},[o]);return s.useMemo(()=>({initialState:x,onStateChange:m,clearState:b}),[x,m,b])}me.Button=Vt,me.Cell=Ci,me.Checkbox=zt,me.ColumnVisibilityPanel=yn,me.DataGrid=Td,me.DataGridThemeProvider=Hu,me.FilterPanel=$i,me.GridToolbar=Rd,me.GridTooltip=Rt,me.Header=Qr,me.Input=Jd,me.Pagination=mn,me.Row=vo,me.Skeleton=Ld,me.amberTheme=Ku,me.compactTheme=Uu,me.darkTheme=Bu,me.emeraldTheme=Vu,me.exportToCsv=pu,me.exportToExcel=mu,me.exportToExcelAdvanced=Au,me.exportToJson=xu,me.exportToPdf=uu,me.formatAggregationValue=Yo,me.printGrid=Cu,me.roseTheme=zu,me.useAggregation=bi,me.useGridApiRef=Yd,me.useGridStateStorage=Xu,me.usePivot=Du,Object.defineProperty(me,Symbol.toStringTag,{value:"Module"})}));
44
44
  //# sourceMappingURL=opengridx.umd.js.map