@agile-team/mach-table 0.39.1 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/adapter.cjs +1 -1
  3. package/dist/adapter.d.cts +11 -3
  4. package/dist/adapter.d.ts +11 -3
  5. package/dist/adapter.js +1 -1
  6. package/dist/analysis.d.cts +2 -2
  7. package/dist/analysis.d.ts +2 -2
  8. package/dist/business.cjs +1 -1
  9. package/dist/business.js +1 -1
  10. package/dist/{api-ChEKWrvH.d.cts → colDef-BiwNRXwf.d.cts} +256 -256
  11. package/dist/{api-ChEKWrvH.d.ts → colDef-BiwNRXwf.d.ts} +256 -256
  12. package/dist/{configuration-CZm-aiTf.d.cts → configuration-Bxp6fcZt.d.cts} +1 -1
  13. package/dist/{configuration-BPj5MIUw.d.ts → configuration-Cx16Jy5H.d.ts} +1 -1
  14. package/dist/import.cjs +1 -1
  15. package/dist/import.d.cts +1 -1
  16. package/dist/import.d.ts +1 -1
  17. package/dist/import.js +1 -1
  18. package/dist/index.cjs +6 -6
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +6 -6
  22. package/dist/multi-range.d.cts +1 -1
  23. package/dist/multi-range.d.ts +1 -1
  24. package/dist/ordering.d.cts +1 -1
  25. package/dist/ordering.d.ts +1 -1
  26. package/dist/preferences.cjs +1 -1
  27. package/dist/preferences.d.cts +1 -1
  28. package/dist/preferences.d.ts +1 -1
  29. package/dist/preferences.js +1 -1
  30. package/dist/server-side.cjs +1 -1
  31. package/dist/server-side.d.cts +1 -1
  32. package/dist/server-side.d.ts +1 -1
  33. package/dist/server-side.js +1 -1
  34. package/dist/{shared-BIBSfPcs.d.cts → shared-C9SPn-Hh.d.ts} +1 -1
  35. package/dist/{shared-Qnznvth3.d.ts → shared-TcluaEBe.d.cts} +1 -1
  36. package/dist/workbench.cjs +1 -1
  37. package/dist/workbench.d.cts +3 -3
  38. package/dist/workbench.d.ts +3 -3
  39. package/dist/workbench.js +1 -1
  40. package/dist/worker.cjs +1 -1
  41. package/dist/worker.d.cts +2 -2
  42. package/dist/worker.d.ts +2 -2
  43. package/dist/worker.js +1 -1
  44. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var _e="0.39.1";function v(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function E(n,e,t=!1){if(!(typeof n!="number"||!Number.isFinite(n)||n<e))return t?Math.floor(n):n}function O(n){return E(n,0)||void 0}function ze(n){return!n||typeof n.key!="string"||!n.key.trim()?null:{key:n.key.trim(),debounceMs:E(n.debounceMs,0,!0)??160,...n.sections?{sections:[...new Set(n.sections)]}:{},...n.store?{store:n.store}:{}}}function R(n,e,t,r=!1){let i=!1;for(let o of t)(r?v(n,o):n[o]!=null)&&(e[o]=n[o],i=!0);return i}var jt=new WeakMap,We=new WeakMap;function we(n){let e=jt.get(n);return e||(e={},jt.set(n,e)),e}function qt(n){return jt.get(n)}function $e(n,e){e?We.set(n,e):We.delete(n)}function Ke(n){let e=We.get(n);return We.delete(n),e}function Yt(n){if(n==null)return"";if(n instanceof Date)return n.toLocaleDateString();if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function G(n,e){let t=qt(e);if(!t)return;t.flashTimer&&clearTimeout(t.flashTimer),t.flashTimer=void 0;let r=t.destroy;if(t.destroy=void 0,t.refresh=void 0,t.rendererDefinition=void 0,t.rendererRowId=void 0,t.rendererColumnId=void 0,!!r)try{r()}catch(i){n.reportError(i,"cellRenderer.destroy",{colId:e.dataset.colId})}}function ei(n,e,t,r,i,o){let s=n.r.tooltipComponent?"":o,a=r.colDef.tooltipValueGetter;if(a)try{s=a({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i})??o}catch(l){n.reportError(l,"tooltipValueGetter",{colId:r.id,rowId:t.id})}s?e.setAttribute("title",s):e.removeAttribute("title")}function Xn(n,e,t,r,i,o){let s=qt(e);if(!s?.refresh||s.rendererDefinition!==i||s.rendererRowId!==t.id||s.rendererColumnId!==r.id)return!1;try{return e.querySelector(":scope > .mach-cell-edit-trigger")?.remove(),s.refresh(o)!==!1}catch(a){return n.reportError(a,"cellRenderer.refresh",{colId:r.id,rowId:t.id}),!1}}function ce(n,e,t){return K(n,e,t,n.c(e,t))}function K(n,e,t,r){let i=t.colDef.valueFormatter;if(i)try{let o=i({api:n.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r});return o==null?"":String(o)}catch(o){n.reportError(o,"valueFormatter",{colId:t.id,rowId:e.id})}return Yt(r)}function Jn(n,e,t,r){let i=r.colDef.cellStyle,o=we(e),s=o.styleKeys;if(s)for(let d of s)Reflect.set(e.style,d,"");if(!i){o.styleKeys=void 0;return}let a;if(typeof i=="function"){let d=n.c(t,r);try{a=i({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:d,rowIndex:t.rowIndex})}catch(c){n.reportError(c,"cellStyle",{colId:r.id,rowId:t.id}),a=null}}else a=i;if(!a){o.styleKeys=void 0;return}let l=Object.keys(a);for(let d of l)Reflect.set(e.style,d,Reflect.get(a,d));o.styleKeys=l}function Zn(n,e,t,r){let i=n.c(t,r),o=K(n,t,r,i),s=r.colDef.cellRenderer,a=typeof s=="string"?n.nc(s):s;if(a){let l={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,formatted:o,rowIndex:t.rowIndex,rendererParams:r.colDef.cellRendererParams};if(Xn(n,e,t,r,a,l)){ei(n,e,t,r,i,o);return}G(n,e);let d;try{d=a(l)}catch(c){n.reportError(c,"cellRenderer",{colId:r.id,rowId:t.id}),e.textContent=o;return}if(typeof d=="string")e.textContent=d;else if(d instanceof HTMLElement)e.replaceChildren(d);else if(d&&typeof d=="object"&&d.el instanceof HTMLElement){let c=d;e.replaceChildren(c.el);let u=we(e);u.destroy=c.destroy,c.refresh&&(u.refresh=h=>c.refresh(h),u.rendererDefinition=a,u.rendererRowId=t.id,u.rendererColumnId=r.id)}else e.textContent=""}else G(n,e),e.textContent=o;ei(n,e,t,r,i,o)}function Ue(n){let{align:e}=n.colDef;return e==="left"?"mach-cell--left":e==="right"?"mach-cell--right":"mach-cell--center"}function Qn(n,e,t,r,i){let o=r.colDef.cellClass;if(!o)return;if(typeof o=="string"){e.push(o);return}if(Array.isArray(o)){e.push(...o);return}let s={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,rowIndex:t.rowIndex};try{let a=o(s);typeof a=="string"?e.push(a):Array.isArray(a)&&e.push(...a)}catch(a){n.reportError(a,"cellClass",{colId:r.id,rowId:t.id})}}function eo(n,e,t){e.classList.contains("mach-cell--focus")&&n.push("mach-cell--focus"),e.classList.contains("mach-cell--editing")&&n.push("mach-cell--editing"),t.colDef.wrapText&&n.push("mach-cell--wrap")}function Xt(n,e,t,r){let i=n.c(t,r),o=["mach-cell",Ue(r)];Qn(n,o,t,r,i),eo(o,e,r);let s=o.join(" ");e.className!==s&&(e.className=s)}function je(n,e,t,r){Zn(n,e,t,r),Xt(n,e,t,r),Jn(n,e,t,r)}function Ce(n,e){return n&&v(n,e)?n[e]:void 0}function qe(n,e){if(n==null||n===""||!e||typeof e!="object")return;let t=Ce(e,String(n));return typeof t=="string"?{color:t}:t}var Ye=class{constructor(e){this.e=e;this.Xn="";this.xr=!0}Jn(e){let t=getComputedStyle(this.e.o.root),r=`${t.getPropertyValue("--mach-header-font-weight")||650} ${t.fontSize} ${t.fontFamily}`;r!==this.Xn&&(this.xr=!0,e=void 0),this.Xn=r;let i=this.xr?this.ra():void 0,o=i&&ro(i,e),s=e?.columns&&new Set(e.columns),a=!1;for(let l of this.e.n.d()){if(l.minWidth!=null&&(!o||s&&!s.has(l.id)))continue;let d=this.oc(l);if(a=l.minWidth!==d||a,l.minWidth=d,to(l)){let c=this.ia(l,i);a=c!==l.contentWidth||a,l.contentWidth=c}}return this.xr=!1,a}ra(){let e=this.e.i.Ve(),t=Math.min(e.length,100);return Array.from({length:t},(r,i)=>e[Math.floor(i*(e.length-1)/Math.max(t-1,1))])}Zn(e,t){return this.Dr===void 0&&(this.Dr=document.createElement("canvas").getContext("2d")),this.Dr?(this.Dr.font=t??this.Xn,this.Dr.measureText(e).width):t?1/0:e.replace(/[^\x00-\xff]/g,"mm").length*7}oc(e){let t=e.colDef,r=t.headerName??t.field??e.id;return Math.ceil(Math.max(t.minWidth??0,this.Zn(r)+r.length*.15+28+(e.sortable?20:0)+(e.filterable?28:0)+(this.e.r.columnMenu&&!e.hasCheckbox&&!t.suppressColumnMenu?22:0)))}ia(e,t=this.ra()){let r=28;for(let i of t){let o=this.e.c(i,e),s=qe(o,e.colDef.status)?.label??K(this.e,i,e,o);r=Math.max(r,this.Zn(s.slice(0,128))+(e.colDef.status?44:28))}return Math.ceil(Math.min(O(e.colDef.maxWidth)??360,r))}};function to(n){let{width:e,autoWidth:t}=n.colDef;return n.manualWidth==null&&e==null&&t!==!1&&!n.hasCheckbox&&!n.isDetailToggle}function ro(n,e){if(!e?.rowIds&&!e?.rowIndexes)return!0;let t=new Set(e.rowIds),r=new Set(e.rowIndexes);return n.some(i=>t.has(i.id)||r.has(i.rowIndex))}function f(n,e,t){let r=document.createElement(n);if(e&&(r.className=e),t)for(let i of Object.keys(t))r.setAttribute(i,t[i]);return r}function Y(n,e,t){let r=f("button",n);return r.type="button",r.textContent=e,r.addEventListener("click",t),r}function S(n,e,t,r=!1){let i=e?"addEventListener":"removeEventListener";for(let[o,s]of Object.entries(t))n[i](o,s,r)}function V(n,e,t){S(document,n,{mousedown:e,keydown:t},!0)}function I(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let r=0;r<t.length;r++){let i=t.item(r);if(!i.startsWith("--mach-"))continue;let o=t.getPropertyValue(i).trim();o&&n.style.setProperty(i,o)}n.style.colorScheme=t.colorScheme}function T(n,e,t){return n<e?e:n>t?t:n}function X(n,e,t=4){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),o=r.bottom+t,s=o+i.height>window.innerHeight-8?r.top-i.height-t:o;n.style.left=`${T(r.left,8,Math.max(8,window.innerWidth-i.width-8))}px`,n.style.top=`${T(s,8,Math.max(8,window.innerHeight-i.height-8))}px`}var ti=0;function ri(n="rg"){return ti++,`${n}-${ti}`}var ii='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3.5h12L9.5 8v4.5L6.5 14V8L2 3.5z"/></svg>',ni='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 3l4 5H4l4-5z"/></svg>',oi='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 13l4-5H4l4 5z"/></svg>',si='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round"><path d="M2 4h3m3 0h6M2 8h7m3 0h2M2 12h1m3 0h8"/><circle cx="6.5" cy="4" r="1.35"/><circle cx="10.5" cy="8" r="1.35"/><circle cx="4.5" cy="12" r="1.35"/></svg>';var Xe=class{constructor(e){this.sc=e;this.Di=new Map}on(e,t){let r=this.Di.get(e);return r||(r=new Set,this.Di.set(e,r)),r.add(t),()=>{r.delete(t)}}once(e,t){let r=this.on(e,i=>{r(),t(i)});return r}emit(e,t){let r=this.Di.get(e);if(r)for(let i of[...r])try{i(t)}catch(o){console.error(`[mach-table] error in "${e}" listener`,o),this.sc?.(o,e)}}clear(){this.Di.clear()}};var io=new Set(["__proto__","prototype","constructor"]),Te=new Map;function Jt(n){if(typeof n!="string"||n.length===0)return null;let e=Te.get(n);if(e!==void 0)return e;let t=n.split("."),r=t.every(i=>i.length>0&&!io.has(i))?t:null;return n.length<=1024&&(Te.size>=256&&Te.delete(Te.keys().next().value),Te.set(n,r)),r}function Zt(n){return Jt(n)!==null}function W(n,e){if(n==null)return;let t=Jt(e);if(!t)return;let r=n;for(let i of t){if(r==null)return;r=r[i]}return r}function De(n,e,t){if(n==null)return!1;let r=Jt(e);if(!r)return!1;let i=n;for(let o=0;o<r.length-1;o++){if(typeof i!="object"&&typeof i!="function"||i===null)return!1;i[r[o]]==null&&(i[r[o]]={}),i=i[r[o]]}return typeof i!="object"&&typeof i!="function"||i===null?!1:(i[r[r.length-1]]=t,!0)}var ue={text:["contains","notContains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","inRange","blank","notBlank"],date:["equals","notEquals","lessThan","greaterThan","inRange","blank","notBlank"]};var no=16,oo=512,so=20,ao=2e3,lo=2e3,co={text:new Set(ue.text),number:new Set(ue.number),date:new Set(ue.date)};function uo(n){return n==null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}function ho(n,e,t){if(n==null||typeof n!="object")return null;let r=n;return typeof r.match!="string"||!t.has(r.match)?null:{match:r.match,...po(r,e)}}function po(n,e){let t=e==="number"?ai(n.value):typeof n.value=="string"?n.value:void 0,r=e==="number"?ai(n.value2):typeof n.value2=="string"?n.value2:void 0;return{...t!==void 0?{value:t}:{},...r!==void 0?{value2:r}:{}}}function ai(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function fo(n,e){let t=[],r=co[e];for(let i of n.slice(0,so)){let o=ho(i,e,r);o&&t.push(o)}return t}function Qt(n){if(n==null||typeof n!="object")return null;let e=n;return e.type==="set"?Array.isArray(e.values)?{type:"set",values:e.values.filter(uo).slice(0,ao)}:null:e.type!=="text"&&e.type!=="number"&&e.type!=="date"||!Array.isArray(e.conditions)?null:{type:e.type,...e.operator==="or"||e.operator==="and"?{operator:e.operator}:{},conditions:fo(e.conditions,e.type)}}function mo(n,e){if(typeof n.colId!="string"||!n.colId.trim())return null;let t=n.colId.trim();if(e.validColumnIds?.has(t)===!1)return null;let r=Qt(n.filter);return r?{kind:"condition",colId:t,filter:r}:null}function go(n,e,t){if(!Array.isArray(n.children))return null;let r=[];for(let i of n.children){let o=li(i,e+1,t);o&&r.push(o)}return r.length===0?null:{kind:"group",operator:n.operator==="or"?"or":"and",children:r,...n.not===!0?{not:!0}:{}}}function yo(n,e,t){return e<=no&&t.nodes<oo&&n!=null&&typeof n=="object"}function li(n,e,t){if(!yo(n,e,t)||t.ancestors.has(n))return null;t.ancestors.add(n),t.nodes++;let r=n,i=r.kind==="condition"?mo(r,t):r.kind==="group"?go(r,e,t):null;return t.ancestors.delete(n),i}function B(n,e){if(n==null||typeof n!="object")return null;let t=n;if(t.version!==1||t.root==null)return null;let r=li(t.root,0,{ancestors:new WeakSet,nodes:0,validColumnIds:e});return r?{version:1,root:r}:null}function vo(n,e){return{kind:"condition",colId:n,filter:e}}function ne(n,e){if(n==null||typeof n!="object"||Array.isArray(n))return{};let t={};for(let[r,i]of Object.entries(n).slice(0,lo)){let o=r.trim();if(!o||e?.has(o)===!1)continue;let s=Qt(i);s&&(t[o]=s)}return t}function bo(n,e,t={}){return{kind:"group",operator:n,children:e,...t.not?{not:!0}:{}}}var er={align:"center",sortable:!0,resizable:!0,movable:!0,filter:!1,minWidth:80},xe={compact:{rowHeight:30,headerHeight:34,fontSize:12,cellPadding:6},normal:{rowHeight:36,headerHeight:40,fontSize:13,cellPadding:9},large:{rowHeight:44,headerHeight:48,fontSize:14,cellPadding:12}},Ee={multiSort:!0,stripedRows:!1,showCellBorders:!1,quickFilterText:null,suppressCellFocus:!1,suppressRowHoverHighlight:!1,suppressNoRowsOverlay:!1,suppressHeaderFocus:!1,loading:!1,error:null,className:"",singleClickEdit:!1,manualSorting:!1,manualFiltering:!1,showSummary:!1,rowNumber:!1,indexOffset:0,applyRowDrag:!0,masterDetail:!1,detailToggleColumn:!0,treeData:!1,childrenKey:"children",autoCheckedChildren:!0,defaultExpandAll:!1,columnMenu:!1,suppressWarnings:!1,enableRangeSelection:!1,suppressClipboard:!1,contextMenu:!1,flashCells:!0,fillHandle:!0,ariaLabel:"MachTable data grid",ariaLabelledBy:"",ariaDescribedBy:"",overlayNoRowsTemplate:"",overlayLoadingTemplate:"",overlayErrorTemplate:"",allowUnsafeOverlayHtml:!1},wo=Object.keys(Ee);function Co(n){let e={};for(let t of wo)e[t]=n[t]??Ee[t];return e}function N(n,e,t,r=!1){return E(n,t,r)??e}function To(n){return n&&v(xe,n)?n:"normal"}function Do(n){return n.theme==="light"||n.theme==="dark"||n.theme==="auto"?n.theme:"light"}function xo(n,e){let t=typeof n.pagination=="object"&&Array.isArray(n.pagination.pageSizeOptions)?n.pagination.pageSizeOptions:void 0,r=t?[...new Set(t.map(i=>N(i,0,1,!0)).filter(Boolean))]:[10,20,50,100];return r.includes(e)||r.push(e),r.sort((i,o)=>i-o)}function tr(n,e){let t=typeof n=="function"?n(e):W(e,n);return t==null?"":String(t)}function Eo(n){let e=n.rowKey,t=e?({data:r})=>tr(e,r):void 0;return{...t?{resolveRowId:t}:{},...e?{rowKey:e}:{}}}function Ro(n,e){let t=xe[e];return{columnDefs:Array.isArray(n.columnDefs)?n.columnDefs:[],rowData:Array.isArray(n.rowData)?n.rowData:[],defaultColDef:{...er,...n.defaultColDef??{}},columnTypes:n.columnTypes??{},...Eo(n),rowHeight:N(n.rowHeight,t.rowHeight,1),headerHeight:N(n.headerHeight,t.headerHeight,1),rowBuffer:N(n.rowBuffer,8,0,!0),columnLayout:n.columnLayout==="fit"?"fit":"normal",enableColumnResize:n.enableColumnResize===!0,domLayout:n.domLayout==="autoHeight"?"autoHeight":"normal",maxBodyHeight:E(n.maxBodyHeight,1),rowSelection:n.rowSelection==="single"||n.rowSelection==="multiple"?n.rowSelection:"none",size:e,pinnedTopRowData:Array.isArray(n.pinnedTopRowData)?n.pinnedTopRowData:[],pinnedBottomRowData:Array.isArray(n.pinnedBottomRowData)?n.pinnedBottomRowData:[]}}function So(n){return{rowStyleRules:Array.isArray(n.rowStyleRules)?n.rowStyleRules:[],theme:Do(n)}}function Mo(n){return{editType:n.editType==="fullRow"?"fullRow":"cell",editableIndicator:n.editableIndicator==="always"||n.editableIndicator==="none"?n.editableIndicator:"hover",rowDragPolicy:n.rowDragPolicy,undoStackSize:N(n.undoStackSize,100,0,!0),asyncTransactionWaitMillis:N(n.asyncTransactionWaitMillis,16,0,!0)}}function Io(n){return{detailRowHeight:N(n.detailRowHeight,240,1)}}function Ao(n){let e=typeof n.pagination=="object"?n.pagination:void 0,t=N(e?.pageSize,20,1,!0);return{paginationEnabled:n.pagination!==!1&&n.datasource==null,paginationMode:e?.mode==="server"?"server":"client",paginationPage:N(e?.page,1,1,!0),paginationTotal:N(e?.total,0,0,!0),paginationPageSize:t,paginationPageSizeOptions:xo(n,t),paginationShowTotal:e?e.showTotal!==!1:!0,paginationShowSizeSelector:e?e.showPageSizeSelector!==!1:!0}}function rr(n){return{watermarkEnabled:n.watermark!=null&&n.watermark!==!1,watermarkConfig:n.watermark==null||n.watermark===!1?null:n.watermark===!0?{text:"MachTable"}:n.watermark}}function ko(n){return{advancedFilterModel:B(n.advancedFilterModel),persistence:ze(n.persistence),locale:n.locale??{},tooltipShowDelay:N(n.tooltipShowDelay,600,0),statusBarEnabled:n.statusBar===!0||typeof n.statusBar=="object"&&n.statusBar!=null,statusBarPanels:typeof n.statusBar=="object"&&n.statusBar?.panels?n.statusBar.panels:["rowCount","selectedRowCount","rangeAggregate"]}}var ci={blockSize:100,maxBlocksInCache:12,datasourceMaxConcurrentRequests:4},ui={infiniteBufferRows:40,blockPrefetch:1,datasourceRetryCount:2,datasourceRetryDelay:300},Go=Object.keys(ci),Po=Object.keys(ui);function di(n,e,t,r){let i=!1;for(let o of t){let s=E(n[o],r,!0);s===void 0||s===e[o]||(e[o]=s,i=!0)}return i}function ir(n,e){let t=di(n,e,Go,1);di(n,e,Po,0);let r=E(n.datasourceRetryJitter,0);return r!==void 0&&(e.datasourceRetryJitter=Math.min(1,r)),t}function Lo(n){let e={...ci,...ui,datasourceRetryJitter:.15};return ir(n,e),{...e,datasourceMode:n.datasourceMode==="block"?"block":"sequential",datasourceRowCount:n.datasourceRowCount==null?null:N(n.datasourceRowCount,0,0,!0),dataProcessorMinRows:N(n.dataProcessorMinRows,5e3,1,!0)}}var No=["detailRowRenderer","isRowExpandable","aggFuncs","components","actionPolicy","summaryMethod","datasource","getRowHeight","tooltipComponent","getContextMenuItems","initialState","rowEditValidator","isTreeRowExpandable","loadTreeChildren","dataProcessor"];function Fo(n,e){for(let t of No)n[t]&&Reflect.set(e,t,n[t])}function Oo(n,e){for(let t of Object.keys(n))t.startsWith("on")&&typeof n[t]=="function"&&Reflect.set(e,t,n[t])}function hi(n){let e=To(n.size),t={...Co(n),...Ro(n,e),...So(n),...Mo(n),...Io(n),...Ao(n),...rr(n),...ko(n),...Lo(n),features:Array.isArray(n.features)?n.features:[]};return Fo(n,t),Oo(n,t),t}function pi(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0):typeof n=="string"&&n.length>0?[n]:[]}function Re(n,e){return pi(n.type).includes(e)}function fi(n,e,t={}){let r={};for(let o of pi(n.type)){o==="rightAligned"&&(r.align="right");let s=t[o];s&&Object.assign(r,s)}let i={...e,...r,...n};return i.align??(i.align=e.align??"center"),i.status&&!i.cellRenderer&&(i.cellRenderer="statusTag"),i}var J=class{constructor(e,t){this.manualWidth=null;this.contentWidth=null;this.flex=null;this.currentWidth=0;this.parentGroup=null;this.level=0;this.isDetailToggle=!1;this.id=e,this.colDef=t,this.hide=t.hide??!1;let r=t.pinned;this.pinned=r===!0?"left":r===!1||r==null?null:r,this.resetWidth()}get sortable(){return this.colDef.sortable!==!1}get resizable(){return this.colDef.resizable!==!1}get movable(){return this.colDef.movable!==!1}get filterable(){return this.colDef.filter!=null&&this.colDef.filter!==!1}get filterType(){let e=this.colDef.filter;return e===!0?"text":e??"text"}get hasCheckbox(){return this.colDef.checkboxSelection===!0}resetWidth(){this.manualWidth=null,this.contentWidth=null,this.flex=O(this.colDef.flex)??null}};function U(n){return!n.hasCheckbox&&!n.isDetailToggle&&!n.isAutoRowNumber}var Z=class n{constructor(e,t){this.parent=null;this.children=[];this.groupId=e,this.def=t}get headerName(){return this.def.headerName??this.def.groupId??""}getLeafColumns(e=[]){for(let t of this.children)t instanceof n?t.getLeafColumns(e):e.push(t);return e}};function Se(n){return Array.isArray(n.children)}var Je=150,Ho=80;function oe(n,e){let t=O(e.minWidth)??Ho,r=O(e.maxWidth)??Number.MAX_SAFE_INTEGER,i=O(n)??O(e.width)??Je;return Math.max(t,Math.min(r,i))}function Vo(n,e,t,r){let i=e.map((o,s)=>s).filter(o=>r[o]>0);for(;Math.abs(t)>.001&&i.length;){let o=i.reduce((a,l)=>a+r[l],0),s=0;if(i=i.filter(a=>{let l=e[a];return e[a]=oe(l+t*r[a]/o,n[a]),s+=e[a]-l,e[a]!==l}),Math.abs(s)<1e-4)break;t-=s}}function mi(n,e,t){let r=n.map(o=>oe(o.width??Je,o)),i=e-r.reduce((o,s)=>o+s,0);return(t?Number.isFinite(e)&&e>0:i>0)&&Vo(n,r,i,t?[...r]:n.map(o=>o.flex??0)),r}function gi(n,e){return mi(n,e,!1)}function Ze(n,e){return mi(n,e,!0)}var x={matchContains:"\u5305\u542B",matchNotContains:"\u4E0D\u5305\u542B",matchEquals:"\u7B49\u4E8E",matchNotEquals:"\u4E0D\u7B49\u4E8E",matchStartsWith:"\u5F00\u5934\u662F",matchEndsWith:"\u7ED3\u5C3E\u662F",matchBlank:"\u4E3A\u7A7A",matchNotBlank:"\u4E0D\u4E3A\u7A7A",matchLessThan:"\u5C0F\u4E8E",matchLessThanOrEqual:"\u5C0F\u4E8E\u7B49\u4E8E",matchGreaterThan:"\u5927\u4E8E",matchGreaterThanOrEqual:"\u5927\u4E8E\u7B49\u4E8E",matchInRange:"\u5728\u8303\u56F4\u5185",apply:"\u5E94\u7528",reset:"\u91CD\u7F6E",search:"\u641C\u7D22...",emptySetLabel:"(\u7A7A)",selectedCount:"\u5DF2\u9009 {n} \u9879",sortAsc:"\u5347\u5E8F",sortDesc:"\u964D\u5E8F",clearSort:"\u53D6\u6D88\u6392\u5E8F",pinLeft:"\u56FA\u5B9A\u5DE6\u4FA7",pinRight:"\u56FA\u5B9A\u53F3\u4FA7",clearPin:"\u53D6\u6D88\u56FA\u5B9A",autoSize:"\u81EA\u9002\u5E94\u5217\u5BBD",hideColumn:"\u9690\u85CF\u6B64\u5217",columnVisibility:"\u5217\u663E\u793A",resetAll:"\u91CD\u7F6E\u5168\u90E8",autoSizeAll:"\u5168\u90E8\u81EA\u9002\u5E94",columnSettings:"\u5217\u8BBE\u7F6E",totalLabel:"\u5408\u8BA1",totalRowsLabel:"\u5171 {n} \u884C",menuCopy:"\u590D\u5236",menuPaste:"\u7C98\u8D34",menuClearContents:"\u6E05\u9664\u5185\u5BB9",loading:"\u52A0\u8F7D\u4E2D...",statusSelected:"\u5DF2\u9009 {n} \u884C",statusSum:"\u548C {n}",statusAvg:"\u5747 {n}",statusCount:"\u8BA1 {n}",emptyRows:"\u6CA1\u6709\u53EF\u663E\u793A\u7684\u884C",emptyRowsHint:"\u6682\u65E0\u6570\u636E",noMatchingRows:"\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u884C",clearFilters:"\u6E05\u9664\u7B5B\u9009",paginationTotal:"\u5171 {n} \u6761",paginationPage:"\u7B2C {a} / {b} \u9875",perPage:"{n} \u6761/\u9875",pageFirst:"\u9996\u9875",pagePrev:"\u4E0A\u4E00\u9875",pageNext:"\u4E0B\u4E00\u9875",pageLast:"\u672B\u9875",requestFailed:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25",requestFailedHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",actionView:"\u67E5\u770B",actionEdit:"\u7F16\u8F91",actionDelete:"\u5220\u9664",actionConfirm:"\u786E\u8BA4",actionSave:"\u4FDD\u5B58",actionCancel:"\u53D6\u6D88",actionMore:"\u66F4\u591A\u64CD\u4F5C",rowDragHandle:"\u62D6\u52A8\u8C03\u6574\u987A\u5E8F\uFF1BAlt + \u4E0A\u4E0B\u65B9\u5411\u952E\u79FB\u52A8",rowDragUnavailable:"\u5F53\u524D\u6392\u5E8F\u6216\u6570\u636E\u6A21\u5F0F\u4E0D\u652F\u6301\u81EA\u52A8\u8C03\u6574\u987A\u5E8F",rowDragPosition:"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",rowDragOutside:"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"},Bo={matchContains:"Contains",matchNotContains:"Not Contains",matchEquals:"Equals",matchNotEquals:"Not Equals",matchStartsWith:"Starts With",matchEndsWith:"Ends With",matchBlank:"Blank",matchNotBlank:"Not Blank",matchLessThan:"Less Than",matchLessThanOrEqual:"\u2264",matchGreaterThan:"Greater Than",matchGreaterThanOrEqual:"\u2265",matchInRange:"In Range",apply:"Apply",reset:"Reset",search:"Search...",emptySetLabel:"(blank)",selectedCount:"{n} selected",sortAsc:"Ascending",sortDesc:"Descending",clearSort:"Clear Sort",pinLeft:"Pin Left",pinRight:"Pin Right",clearPin:"Unpin",autoSize:"Auto Fit",hideColumn:"Hide Column",columnVisibility:"Columns",resetAll:"Reset All",autoSizeAll:"Fit All",columnSettings:"Column Settings",totalLabel:"Total",totalRowsLabel:"{n} rows",menuCopy:"Copy",menuPaste:"Paste",menuClearContents:"Clear Contents",loading:"Loading...",statusSelected:"{n} selected",statusSum:"Sum {n}",statusAvg:"Avg {n}",statusCount:"Cnt {n}",emptyRows:"No rows to display",emptyRowsHint:"No data is available.",noMatchingRows:"No rows match the filters",clearFilters:"Clear filters",paginationTotal:"{n} items",paginationPage:"Page {a} / {b}",perPage:"{n} / page",pageFirst:"First",pagePrev:"Previous",pageNext:"Next",pageLast:"Last",requestFailed:"Unable to load data",requestFailedHint:"Check your connection and try again",actionView:"View",actionEdit:"Edit",actionDelete:"Delete",actionConfirm:"Confirm",actionSave:"Save",actionCancel:"Cancel",actionMore:"More actions",rowDragHandle:"Drag to reorder; Alt + Up/Down to move",rowDragUnavailable:"Reordering is unavailable in the current sort or data mode",rowDragPosition:"Row {a} \u2192 Row {b}",rowDragOutside:"Move inside to drop \xB7 Esc to cancel",rowDragSelection:"{a} selected rows \u2192 Row {b}",rowDragBefore:"Before",rowDragAfter:"After",rowDragInside:"Inside",rowDragRejected:"This destination is unavailable"},_o={contains:"matchContains",notContains:"matchNotContains",equals:"matchEquals",notEquals:"matchNotEquals",startsWith:"matchStartsWith",endsWith:"matchEndsWith",blank:"matchBlank",notBlank:"matchNotBlank",lessThan:"matchLessThan",lessThanOrEqual:"matchLessThanOrEqual",greaterThan:"matchGreaterThan",greaterThanOrEqual:"matchGreaterThanOrEqual",inRange:"matchInRange"};function nr(n){return _o[n]??"matchEquals"}function $(n,e){return n.replace("{n}",String(e))}function Me(n,e,t){return n.replace("{a}",String(e)).replace("{b}",String(t))}var zo=[[/^(success|ok|done|complete|completed|normal|active|enabled|启用|正常|完成|已完成|运行|运行中|在线|生效|已发运)$/i,"success"],[/^(warning|warn|hold|pending|standby|待机|待审核|暂停|预警|部分完成|待下达|待复核|待发运)$/i,"warning"],[/^(error|fail|failed|danger|fault|offline|disabled|故障|失败|错误|异常|停用|离线|断开)$/i,"danger"],[/^(info|processing|new|draft|进行中|新建|草稿|审批中|同步中|执行中|已下达|装车中)$/i,"info"],[/^(neutral|default)$/i,"neutral"]];function sr(n,e,t){let r=String(n??"");if(e){let i=Ce(e,r);if(i)return i;let o=Ce(e,r.toLowerCase());if(o)return o}for(let[i,o]of zo)if(i.test(r))return o;return t==null?"neutral":sr(t)}function yi(n={}){return e=>{if(e.value==null||e.value==="")return"";let t=String(e.value),r=qe(t,e.colDef.status),i=r?.label??Ce(n.labelMap,t)??(e.formatted||t),o=r?.color,s=sr(o??t,o?void 0:n.variantMap,i),a=document.createElement("span");return a.className=`mach-tag mach-tag--${s}`,a.textContent=i,o&&s!==o&&(a.style.color=o,a.style.backgroundColor=`color-mix(in srgb, ${o} 12%, transparent)`),a}}function vi(n={}){return e=>{let t=Number(e.value);if(isNaN(t))return e.formatted;let r=Math.max(0,Math.min(100,t)),i=f("div","mach-progress"),o=f("div","mach-progress__track"),s=f("div","mach-progress__bar");if(s.style.width=`${r}%`,n.color&&(s.style.background=n.color),o.appendChild(s),i.appendChild(o),n.showValue!==!1){let a=f("span","mach-progress__label");a.textContent=`${Math.round(r)}${n.unit??"%"}`,i.appendChild(a)}return i}}function bi(n){if(n.value==null||n.value==="")return"";let e=f("span","mach-link");return e.textContent=n.formatted||String(n.value),e}var ar={edit:'<path d="M11.5 2.5l2 2L5 13H3v-2l8.5-8.5z"/>',delete:'<path d="M3 5h10M6 5V3h4v2M5 5l.7 8h4.6L11 5"/>',view:'<path d="M1.5 8s2.4-4.2 6.5-4.2S14.5 8 14.5 8s-2.4 4.2-6.5 4.2S1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>',copy:'<rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/>',download:'<path d="M8 2v8m0 0l-3-3m3 3l3-3M2.5 13.5h11"/>',refresh:'<path d="M13 3v4h-4M3 13V9h4"/><path d="M13 7a5.5 5.5 0 00-9.7-2.6M3 9a5.5 5.5 0 009.7 2.6"/>',close:'<path d="M3.5 3.5l9 9m0-9l-9 9"/>',check:'<path d="M2.5 8.5l3.5 3.5 7.5-8"/>',plus:'<path d="M8 2.5v11M2.5 8h11"/>',search:'<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>',more:'<circle cx="3" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="8" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="13" cy="8" r=".9" fill="currentColor" stroke="none"/>'};function Qe(n,e=14){let t=ar[n]??"";return`<svg viewBox="0 0 16 16" width="${e}" height="${e}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}var ee=null,H=null;function wi(n){H&&n.contains(H)&&j()}function j(n=!1){ee?.remove(),ee=null,H&&(H.setAttribute("aria-expanded","false"),n&&H.isConnected&&H.focus({preventScroll:!0})),H=null,document.removeEventListener("mousedown",Ci,!0),document.removeEventListener("keydown",lr,!0)}function Ci(n){ee&&!ee.contains(n.target)&&!H?.contains(n.target)&&j()}function lr(n){if(!ee)return;if(n.key==="Escape"){n.preventDefault(),j(!0);return}let e=[...ee.querySelectorAll("button:not(:disabled)")];if(e.length===0)return;if(n.key==="Tab"){let i=e.indexOf(document.activeElement);(!n.shiftKey&&i===e.length-1||n.shiftKey&&i<=0)&&(n.preventDefault(),e[n.shiftKey?e.length-1:0].focus());return}if(n.key!=="ArrowDown"&&n.key!=="ArrowUp")return;n.preventDefault();let t=e.indexOf(document.activeElement),r=n.key==="ArrowDown"?1:-1;e[(t+r+e.length)%e.length].focus()}function Ti(n,e){let t=document.createElement("button");return t.type="button",t.className=e,n.variant&&n.variant!=="default"&&t.classList.add(`${e}--${n.variant}`),t.disabled=n.disabled===!0,n.icon&&ar[n.icon]?t.innerHTML=`${Qe(n.icon,16)}<span>${n.label}</span>`:t.textContent=n.label,t.addEventListener("click",()=>n.pick(t)),t}function Wo(n,e){j();let t=f("div","mach-context-menu mach-action-menu");t.setAttribute("role","menu");for(let r of e){let i=Ti(r,"mach-context-menu-item");i.setAttribute("role","menuitem"),t.appendChild(i)}I(t,n.closest(".mach-root")),document.body.appendChild(t),X(t,n),ee=t,H=n,n.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",Ci,!0),document.addEventListener("keydown",lr,!0),t.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function $o(n,e,t){j();let r=f("div","mach-action-drawer-backdrop"),i=f("section","mach-action-drawer");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",e);let o=f("header","mach-action-drawer__header"),s=document.createElement("strong");s.textContent=e;let a=document.createElement("button");a.type="button",a.className="mach-action-drawer__close",a.setAttribute("aria-label","Close"),a.title="Close",a.innerHTML=Qe("close",16),a.addEventListener("click",()=>j(!0)),o.append(s,a);let l=f("div","mach-action-drawer__body");for(let d of t)l.appendChild(Ti(d,"mach-action-drawer__item"));i.append(o,l),r.appendChild(i),r.addEventListener("mousedown",d=>{d.target===r&&j(!0)}),I(r,n.closest(".mach-root")),document.body.appendChild(r),ee=r,H=n,n.setAttribute("aria-expanded","true"),document.addEventListener("keydown",lr,!0),i.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function Q(n,e){if(typeof n=="function")try{return n(e)}catch{return!1}return n===!0}function Di(n){return n.variant??"default"}function xi(n){return n.permission?typeof n.permission=="string"?[n.permission]:n.permission:[]}function dr(n,e,t){return{...n.id?{actionId:n.id}:{},permissions:xi(n),...t?{message:t}:{},params:e}}function et(n,e,t){let r=t.api.getOption("actionPolicy");try{r?.onError?r.onError(n,dr(e,t)):console.error("[mach-table] action handler failed",n)}catch(i){console.error("[mach-table] action error policy failed",i,n)}}function Ko(n,e){if(xi(n).length===0)return!0;let r=e.api.getOption("actionPolicy");if(!r?.canAccess)return!0;try{return r.canAccess(dr(n,e))}catch(i){return et(i,n,e),!1}}function Uo(n,e){return n.filter(t=>{if(!Ko(t,e))return!1;if(!t.show)return!0;try{return t.show(e)}catch{return!1}})}function cr(n,e,t){t.isConnected&&(t.disabled=Q(n.disabled,e)||Q(n.loading,e),t.classList.toggle("mach-action-btn--loading",Q(n.loading,e)))}function jo(n,e,t,r){Promise.resolve(n).catch(i=>et(i,e,t)).finally(()=>cr(e,t,r))}function qo(n,e,t){try{jo(n.onClick(e),n,e,t)}catch(r){et(r,n,e),cr(n,e,t)}}function or(n,e,t){if(n===!1)return!1;let r=typeof n=="string"?n:e.label??e.title??"Confirm action",i=t.api.getOption("actionPolicy");return i?.confirm?i.confirm(dr(e,t,r)):typeof window>"u"||typeof window.confirm!="function"?!1:window.confirm(r)}function Yo(n,e){if(n.confirm==null||n.confirm===!1)return!0;if(typeof n.confirm!="function")return or(n.confirm,n,e);let t=n.confirm(e);return t instanceof Promise?t.then(r=>or(r,n,e)):or(t,n,e)}function Xo(n){return(e,t)=>{if(Q(e.disabled,n))return;if(t.disabled=!0,t.classList.add("mach-action-btn--loading"),e.confirm==null||e.confirm===!1){qo(e,n,t);return}(async()=>{await Yo(e,n)&&await e.onClick(n)})().catch(i=>et(i,e,n)).finally(()=>{cr(e,n,t)})}}function Jo(n,e,t){let r=document.createElement("button");r.type="button",r.className="mach-action-btn";let i=Di(n);i!=="default"&&r.classList.add(`mach-action-btn--${i}`);let o=n.title??n.label??"Action";return r.title=o,r.setAttribute("aria-label",o),r.disabled=Q(n.disabled,e),Q(n.loading,e)&&(r.disabled=!0,r.classList.add("mach-action-btn--loading")),n.icon&&ar[n.icon]?(r.innerHTML=Qe(n.icon),r.classList.add("mach-action-btn--icon")):r.textContent=n.label??o,r.addEventListener("mousedown",s=>s.stopPropagation()),r.addEventListener("click",s=>{s.stopPropagation(),t(n,r)}),r}function Zo(n,e,t,r,i){let o=document.createElement("button");o.type="button",o.className="mach-action-btn mach-action-btn--icon";let s=r.api.getOption("locale")??{},a=t.moreLabel??s.actionMore??x.actionMore;return o.title=a,o.setAttribute("aria-label",a),o.setAttribute("aria-haspopup",e==="drawer"?"dialog":"menu"),o.setAttribute("aria-expanded","false"),o.innerHTML=`${Qe("more",16)}<span class="mach-sr-only">\u22EF</span>`,o.addEventListener("mousedown",l=>l.stopPropagation()),o.addEventListener("click",l=>{l.stopPropagation();let d=n.map(c=>({label:c.label??c.title??"Action",icon:c.icon,variant:Di(c),disabled:Q(c.disabled,r)||Q(c.loading,r),pick:u=>{j(),i(c,u)}}));e==="drawer"?$o(o,t.drawerTitle??a,d):Wo(o,d)}),o}function Ie(n){let e=Math.max(0,n.max??3),t=n.overflow??"menu";return r=>{let i=Uo(n.actions,r);if(i.length===0)return"";let o=f("div","mach-actions"),s=t==="inline"?i:i.slice(0,e),a=t==="inline"?[]:i.slice(e),l=Xo(r);for(let d of s)o.appendChild(Jo(d,r,l));return a.length>0&&o.appendChild(Zo(a,t,n,r,l)),{el:o,destroy:()=>{H&&o.contains(H)&&j()}}}}function he(n,e,t){return n??e??t}function Qo(n,e){let t=e.api.getOption("locale")??{};return{view:he(n.labels?.view,t.actionView,x.actionView),edit:he(n.labels?.edit,t.actionEdit,x.actionEdit),delete:he(n.labels?.delete,t.actionDelete,x.actionDelete),confirm:he(n.labels?.confirm,t.actionConfirm,x.actionConfirm),save:he(n.labels?.save,t.actionSave,x.actionSave),cancel:he(n.labels?.cancel,t.actionCancel,x.actionCancel)}}function es(n,e,t){let r=async()=>{if(!await e.api.editing.stop()||!n.onSave)return;let s=e.api.editing.getChanges().filter(a=>a.rowId===e.node.id);try{await n.onSave(e,s),e.api.editing.markSaved([e.node.id])}catch(a){throw e.api.editing.startRow(e.rowIndex),a}},i=n.onSave?t.save:n.labels?.confirm??n.labels?.save??t.confirm;return Ie({actions:[{icon:"check",title:i,variant:"success",onClick:r},{icon:"close",title:t.cancel,variant:"danger",onClick:()=>e.api.editing.stop({cancel:!0}).then(()=>{})}],overflow:"inline"})(e)}function ts(n,e,t){let r=[];return n.onView&&r.push({id:"view",icon:"view",title:t.view,variant:"primary",...n.permissions?.view?{permission:n.permissions.view}:{},onClick:n.onView}),n.edit!==!1&&r.push({id:"edit",icon:"edit",title:t.edit,variant:"warning",...n.permissions?.edit?{permission:n.permissions.edit}:{},onClick:n.onEdit??(()=>{e.api.editing.startRow(e.rowIndex)})}),n.onDelete&&r.push({id:"delete",icon:"delete",title:t.delete,variant:"danger",...n.permissions?.delete?{permission:n.permissions.delete}:{},...n.confirmDelete?{confirm:n.confirmDelete===!0?t.delete:n.confirmDelete}:{},onClick:n.onDelete}),r.push(...n.extraActions??[]),r}function ur(n={}){return e=>{let t=Qo(n,e);if(e.api.editing.isRowActive(e.rowIndex))return es(n,e,t);let r=ts(n,e,t);return Ie({actions:r,max:n.max,overflow:n.overflow??"menu",moreLabel:n.moreLabel,drawerTitle:n.drawerTitle})(e)}}var rs=yi(),is=vi(),Ei=Object.freeze({statusTag:rs,progressBar:is,link:bi});var Ae={sortable:!1,resizable:!1,movable:!1,filter:!1,suppressSizeToFit:!0,suppressColumnMenu:!0};function ns(n={}){let e=n.width??40;return{colId:"sel",headerName:"",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",checkboxSelection:!0,...Ae,...n}}function hr(n={}){let e=n.width??52;return{colId:"idx",headerName:"#",type:"index",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",align:"center",headerAlign:"center",...Ae,...n}}function os(n={}){let e=n.width??40;return{colId:"drag",headerName:"",rowDrag:!0,width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",...Ae,...n}}function ss(n={actions:[]}){let{width:e,pinned:t,...r}=n,i=r.actions?.length??0,o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(1,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(64,a),pinned:t??"right",cellRenderer:Ie(r),...Ae,cellRendererParams:void 0}}function as(n={}){let{width:e,pinned:t,...r}=n,i=(r.onView?1:0)+(r.edit===!1?0:1)+(r.onDelete?1:0)+(r.extraActions?.length??0),o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(2,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(72,a),pinned:t??"right",cellRenderer:ur(r),...Ae,cellRendererParams:void 0}}var pr="__rg_detail_toggle__";function ke(n){return O(n)!==void 0}function Si(n){return n===!0?"left":n||null}function Ri(n,e){let t=e;for(let r=2;n.has(t);r++)t=`${e}_${r}`;return n.add(t),t}function ls(n,e){let t=e.colDef,r=n.colDef;n.manualWidth=e.manualWidth,(t.width===r.width&&t.autoWidth===r.autoWidth||t.width!=null||t.autoWidth===!1)&&(n.contentWidth=e.contentWidth),(e.manualWidth!=null||e.flex!==(O(t.flex)??null))&&(n.flex=e.flex),e.hide!==(t.hide??!1)&&(n.hide=e.hide),e.pinned!==Si(t.pinned)&&(n.pinned=e.pinned)}var tt=class{constructor(e){this.e=e;this.Z=[];this.xi=new Map;this.fe=[];this.Qn=[];this.Ei=[];this.eo=[];this.me=[];this.Ri=[];this.Dt=new Map;this.Xt=1;this.to=new Map;this.ac=0}Er(e){this.Ri=e?[...e]:[];let t=new Map(this.Z.map(c=>[c.id,c])),r=this.e.r.defaultColDef,i=this.e.r.masterDetail&&this.e.r.detailToggleColumn,o=new Set(i?[pr]:[]),s=this.e.r.rowNumber,a=(c,u,h)=>c.map((p,m)=>{if(Se(p)){let _=p.groupId??p.headerName??`group_${m}_${h}`,z=new Z(_,p);return z.parent=u,z.children=a(p.children,z,h+1),z}let g=p,b=Ri(o,g.colId??g.field??`col_${m}`),C=new J(b,fi(g,r,this.e.r.columnTypes));s&&(s=!Re(C.colDef,"index")),C.parentGroup=u,C.level=h;let k=t.get(b);return k&&!k.isAutoRowNumber&&ls(C,k),C});if(this.fe=a(this.Ri,null,0),s&&o.size>Number(i)&&this.lc(Ri(o,"idx"),t),i){let c=new J(pr,{colId:pr,headerName:"",width:38,pinned:"left",sortable:!1,resizable:!1,movable:!1,filter:!1});c.isDetailToggle=!0,this.fe.unshift(c)}this.Dt.size&&this.dc(),this.Z=this.Si(this.fe),this.xi=new Map(this.Z.map(c=>[c.id,c])),this.Xt=this.Z.reduce((c,u)=>Math.max(c,u.level+1),1);let l=this.me.length;this.me=this.me.filter(c=>this.xi.has(c.colId));let d=this.me.length!==l;if(this.me.length===0){let c=[];for(let u of this.Z)u.colDef.initialSort&&!t.has(u.id)&&c.push({colId:u.id,direction:u.colDef.initialSort});this.me=c}return this.Jt(),d}lc(e,t){let r=new J(e,hr({colId:e,headerName:"\u5E8F\u53F7"}));r.isAutoRowNumber=!0;let i=t.get(e);i?.isAutoRowNumber&&(r.hide=i.hide);let o=this.fe.findIndex(s=>!(s instanceof J&&(s.hasCheckbox||s.colDef.rowDrag)));this.fe.splice(o===-1?this.fe.length:o,0,r)}Si(e,t=[]){for(let r of e)r instanceof Z?this.Si(r.children,t):t.push(r);return t}Jt(){let e=this.Z.filter(t=>!t.hide);this.Qn=e.filter(t=>t.pinned==="left"),this.eo=e.filter(t=>t.pinned==="right"),this.Ei=e.filter(t=>t.pinned===null),this.to.clear(),this.d().forEach((t,r)=>this.to.set(t.id,r))}Q(e){return this.to.get(e)??-1}ee(){return this.Z}ro(){return this.Ri}cc(){return this.fe}uc(){return this.Xt}R(e){return this.xi.get(e)}y(e){return e==="left"?this.Qn:e==="right"?this.eo:this.Ei}d(){return[...this.Qn,...this.Ei,...this.eo]}Je(){return this.d().filter(e=>e.colDef.rowGroup===!0)}hc(){return this.d().filter(e=>e.colDef.aggFunc!=null&&e.colDef.rowGroup!==!0)}na(){let e=this.d();return this.Ei.find(U)??e.find(U)??e[0]}Be(e){return e.pinned==="left"?"left":e.pinned==="right"?"right":"center"}oa(e){this.ac=e;let t=e,r=[],i=[];for(let s of this.d()){let a=this.Mi(s);s.pinned!=null||s.colDef.suppressSizeToFit||s.manualWidth!=null?(s.currentWidth=oe(a.width??Je,a),t-=s.currentWidth):(r.push(s),i.push(a))}let o=this.e.r.columnLayout==="fit"?Ze(i,Math.max(0,t)):gi(i,Math.max(0,t));r.forEach((s,a)=>{s.currentWidth=o[a]})}Mi(e){let t=e.colDef;return{width:e.manualWidth??e.contentWidth??t.width??void 0,minWidth:e.minWidth??t.minWidth,maxWidth:t.maxWidth,flex:e.manualWidth==null?e.flex??void 0:void 0}}Me(e,t){return ke(t)?(e.manualWidth=oe(t,this.Mi(e)),e.flex=null,!0):!1}sa(e,t){return ke(t)?(e.resetWidth(),e.contentWidth=oe(t,this.Mi(e)),!0):!1}no(e,t){let r=this.R(e);!r||r.hide===!t||(r.hide=!t,this.Jt())}Rr(e,t){let r=this.R(e);if(!r)return!1;let i=this.Be(r),o=u=>r.parentGroup?!0:this.Be(u)===i,s=r.parentGroup?r.parentGroup.children:this.fe,a=[],l=[];s.forEach((u,h)=>{u instanceof J&&!u.hide&&o(u)&&(a.push(u),l.push(h))});let d=a.indexOf(r);if(d<0)return!1;a.splice(d,1);let c=Math.max(0,Math.min(t,a.length));return a.splice(c,0,r),l.forEach((u,h)=>{s[u]=a[h]}),d!==c&&this.Dt.set(this.aa(r),a.filter(u=>u.movable).map(u=>u.id)),this.Z=this.Si(this.fe),this.Jt(),!0}oo(e,t){let r=this.R(e);!r||!r.movable||(r.pinned=t,this.Jt())}la(e=!0){return(e?this.Z:this.Z.filter(r=>!r.isAutoRowNumber)).map(r=>({colId:r.id,hide:r.hide,width:r.manualWidth??r.currentWidth,flex:r.flex,widthMode:r.manualWidth==null?"auto":"manual",contentWidth:r.contentWidth??void 0,pinned:r.pinned}))}da(e){let t=new Map(e.map(r=>[r.colId,r]));for(let r of this.Z){let i=t.get(r.id);i&&this.pc(r,i)}this.fc(e),this.Jt()}pc(e,t){typeof t.hide=="boolean"&&(e.hide=t.hide),t.widthMode==="auto"?(e.resetWidth(),ke(t.flex)&&(e.flex=t.flex)):ke(t.flex)?(e.flex=t.flex,e.manualWidth=null):this.Me(e,t.width),ke(t.contentWidth)&&(e.contentWidth=oe(t.contentWidth,this.Mi(e))),e.movable&&(t.pinned==="left"||t.pinned==="right"||t.pinned===null)&&(e.pinned=t.pinned)}fc(e){let t=new Map(e.map((r,i)=>[r.colId,i]));this.so(r=>!r.hide&&r.movable&&t.has(r.id),(r,i)=>{let o=[...r];r.sort((s,a)=>t.get(s.id)-t.get(a.id)),r.some((s,a)=>s!==o[a])&&this.Dt.set(i,r.map(s=>s.id))}),this.Z=this.Si(this.fe)}aa(e){if(!e.parentGroup)return this.Be(e);let t=[];for(let r=e.parentGroup;r;r=r.parent)t.push(r.groupId);return JSON.stringify(t)}dc(){let e=new Map;this.so(t=>t.movable,(t,r)=>{let i=this.Dt.get(r);if(!i)return;let o=new Map(t.map(d=>[d.id,d])),s=i.filter(d=>o.has(d));if(s.length<2)return;let a=new Set(s),l=0;t.forEach((d,c)=>{a.has(d.id)&&(t[c]=o.get(s[l++]))}),e.set(r,s)}),this.Dt=e}so(e,t,r=this.fe){let i=new Map;r.forEach((o,s)=>{if(o instanceof Z)this.so(e,t,o.children);else if(e(o)){let a=o.parentGroup?"center":this.Be(o),l=i.get(a)??[];l.push(s),i.set(a,l)}});for(let o of i.values()){if(o.length<2)continue;let s=o.map(a=>r[a]);t(s,this.aa(s[0])),o.forEach((a,l)=>{r[a]=s[l]})}}ao(){for(let e of this.Z)e.resetWidth(),e.hide=e.colDef.hide??!1,e.pinned=Si(e.colDef.pinned);if(this.Dt.size){this.Dt.clear(),this.Er(this.Ri);return}this.Jt()}te(){return this.me.map(e=>({...e}))}Sr(e){if(!e||e.length===0){this.me=[];return}this.me=e.filter(t=>this.xi.has(t.colId)&&(t.direction==="asc"||t.direction==="desc")).map(t=>({colId:t.colId,direction:t.direction}))}Ii(e,t){let r=[...this.me],i=r.findIndex(l=>l.colId===e.id),o=i>=0?r[i].direction:null,s=o===null?"asc":o==="asc"?"desc":null;t&&this.e.r.multiSort?s===null?i>=0&&r.splice(i,1):i>=0?r[i]={colId:e.id,direction:s}:r.push({colId:e.id,direction:s}):(r.length=0,s&&r.push({colId:e.id,direction:s})),this.me=r}};function te(n,e){if(n instanceof Error)return n;let t=new Error(typeof n=="string"?n:e);return t.name="AbortError",t}var ds=()=>te(void 0,"[MachTable] Operation cancelled.");function rt(n,e,t=ds){return e?new Promise((r,i)=>{let o=()=>{e.removeEventListener("abort",o),i(t())};if(n.then(r,i).finally(()=>e.removeEventListener("abort",o)),e.aborted){o();return}e.addEventListener("abort",o,{once:!0})}):n}function Mi(n){return n==null?"":String(n).toLowerCase()}function mr(n,e,t){return n.length===0||(e==="or"?n.some(t):n.every(t))}function cs(n,e,t){let r=Mi(n);return mr(e,t,o=>{let s=(o.value??"").toLowerCase();switch(o.match){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"blank":return r==="";case"notBlank":return r!=="";default:return!0}})}function Ii(n,e,t,r){switch(t){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return n<e;case"lessThanOrEqual":return n<=e;case"greaterThan":return n>e;case"greaterThanOrEqual":return n>=e;case"inRange":return n>=e&&n<=r;default:return!0}}function us(n,e){let t=n==null||n==="";if(e.match==="blank")return t;if(e.match==="notBlank")return!t;if(t)return!1;let r=typeof n=="number"?n:Number(n);if(Number.isNaN(r))return!1;let i=e.value;return i==null||Number.isNaN(i)?!1:Ii(r,i,e.match,e.value2??i)}function hs(n,e,t){return mr(e,t,i=>us(n,i))}function fr(n){if(n==null||n==="")return null;if(typeof n=="number")return n;let e=n instanceof Date?n.getTime():Date.parse(String(n));return isNaN(e)?null:e}function ps(n,e,t){let r=fr(n);return mr(e,t,o=>{let s=r==null;if(o.match==="blank")return s;if(o.match==="notBlank")return!s;if(s)return!1;let a=fr(o.value);if(a==null)return!1;let l=o.match==="inRange"?fr(o.value2)??1/0:a;return Ii(r,a,o.match,l)})}function fs(n,e){return e.length===0?!0:e.some(t=>t==null&&n==null||t===n)}function ms(n,e){let t=e.type!=="set"&&e.operator==="or"?"or":"and";switch(e.type){case"text":return cs(n,e.conditions,t);case"number":return hs(n,e.conditions,t);case"date":return ps(n,e.conditions,t);case"set":return fs(n,e.values);default:return!0}}function Ai(n,e,t){return r=>ms(t(r,n),e)}function ki(n,e,t){if(n.kind==="condition"){let i=e.get(n.colId);return i?Ai(i,n.filter,t):()=>!0}let r=n.children.map(i=>ki(i,e,t));return i=>{let o=n.operator==="or"?r.some(s=>s(i)):r.every(s=>s(i));return n.not?!o:o}}function gr(n,e,t,r,i){let o=new Map(n.map(l=>[l.id,l])),s=Object.entries(e).flatMap(([l,d])=>{let c=o.get(l);return c?[Ai(c,d,i)]:[]});t&&s.push(ki(t.root,o,i));let a=r?.trim().toLowerCase().split(/\s+/).filter(Boolean)??[];return l=>s.every(d=>d(l))&&a.every(d=>n.some(c=>Mi(i(l,c)).includes(d)))}var Gi=typeof Intl<"u"?new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}):null;function gs(n,e){let t=n==null||n==="",r=e==null||e==="";return!t&&!r?null:t&&r?0:t?1:-1}function ys(n,e){let t=Number.isNaN(n),r=Number.isNaN(e);return t||r?t===r?0:t?1:-1:n-e}function vs(n,e){return n===e?0:n?1:-1}function it(n,e){let t=gs(n,e);if(t!==null)return t;if(typeof n=="number"&&typeof e=="number")return ys(n,e);if(n instanceof Date&&e instanceof Date)return n.getTime()-e.getTime();if(typeof n=="boolean"&&typeof e=="boolean")return vs(n,e);let r=String(n),i=String(e);return Gi?Gi.compare(r,i):r.localeCompare(i)}function yr(n,e,t,r){let i=new Map(t.map(a=>[a.id,a])),o=e.flatMap(a=>{let l=i.get(a.colId);return l?[{column:l,compare:l.colDef.comparator??it,direction:a.direction}]:[]}),s=n.map(a=>({node:a,values:o.map(({column:l})=>r(a,l))}));return s.sort((a,l)=>{for(let d=0;d<o.length;d++){let c=o[d],u=c.compare(a.values[d],l.values[d],a.node,l.node);if(u!==0)return c.direction==="asc"?u:-u}return 0}),s.map(({node:a})=>a)}function Pi(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function Li(n,e){n.count++,!(typeof e!="number"||!Number.isFinite(e))&&(n.numeric++,n.sum+=e,n.min=Math.min(n.min,e),n.max=Math.max(n.max,e))}function Ni(n,e){return e==="count"?n?.count??0:n?.numeric?e==="min"?n.min:e==="max"?n.max:Number.isFinite(n.sum)?e==="avg"?n.sum/n.numeric:n.sum:null:null}function nt(n,e){let t=Pi();for(let r of n)Li(t,r);return Ni(t,e)}var ot={sum:n=>nt(n,"sum"),avg:n=>nt(n,"avg"),count:n=>n.length,min:n=>nt(n,"min"),max:n=>nt(n,"max"),first:n=>n.length>0?n[0]:null,last:n=>n.length>0?n[n.length-1]:null};function Fi(n,e,t){if(e===ot.count)return n.length;let r=["sum","avg","min","max"].find(o=>e===ot[o]);if(!r)return e(n.map(t));let i=Pi();for(let o of n)Li(i,t(o));return Ni(i,r)}function vr(n){let e={...ot,...n??{}};return t=>e[t]}var st="group:";function Oi(n){return n==null?"null":n instanceof Date?JSON.stringify(["date",String(n.getTime())]):JSON.stringify([typeof n,br(n)])}function br(n){return n==null?"(\u7A7A)":String(n)}function Hi(n){return st+JSON.stringify(n)}function bs(n,e,t){let r=new Map;for(let i of n){let o=t(i,e),s=Oi(o),a=r.get(s);a||(a={key:s,label:br(o),rows:[]},r.set(s,a)),a.rows.push(i)}return[...r.values()].sort((i,o)=>i.label.localeCompare(o.label,void 0,{numeric:!0,sensitivity:"base"})||i.key.localeCompare(o.key))}function Vi(n,e,t,r,i){let o=[],s=(a,l,d)=>{if(l===e.length)return{display:a,leaves:a};let c=[],u=[];for(let h of bs(a,e[l],t)){let p=[...d,[e[l].id,h.key]],m=Hi(p);o.push(m);let g=s(h.rows,l+1,p);if(c.push({id:m,data:null,rowIndex:-1,selected:!1,isGroup:!0,groupLevel:l,groupKey:h.label,leafNodes:g.leaves,aggValues:r(g.leaves)}),i.has(m))for(let b of g.display)c.push(b);if(l>0)for(let b of g.leaves)u.push(b)}return{display:c,leaves:u}};return{rows:s(n,0,[]).display,ids:o}}function Bi(n,e,t,r){let i=new Set([...n].filter(l=>l.startsWith("/g0:")));if(!i.size)return{expanded:n,ambiguous:[]};let o=new Map;for(let l of e){let d=[],c="";for(let u=0;u<t.length;u++){let h=r(l,t[u]);if(d.push([t[u].id,Oi(h)]),c+=`/g${u}:${br(h)}`,!i.has(c))continue;let p=Hi(d);o.set(c,o.has(c)&&o.get(c)!==p?null:p)}}let s=new Set([...n].filter(l=>!i.has(l))),a=[];for(let l of i){let d=o.get(l);d?s.add(d):d===null?a.push(l):s.add(l)}return{expanded:s,ambiguous:a}}function ws(n,e){let t=n?[n.root]:[];for(;t.length;){let r=t.pop();if(r.kind==="condition")e.add(r.colId);else for(let i of r.children)t.push(i)}}function _i(n){let e=new Set(Object.keys(n.filterModel));ws(n.advancedFilter,e);let t=new Set(n.sortModel.map(a=>a.colId));for(let a of t)e.add(a);let r=n.columns.some(a=>a.colDef.rowGroup===!0),i=!!n.quickFilter?.trim(),o=n.columns.filter(a=>e.has(a.id)||i||a.colDef.rowGroup===!0||r&&a.colDef.aggFunc!=null),s=new Set;for(let a of o){let l=a.colDef;if(r&&l.rowGroup!==!0&&l.aggFunc!=null&&n.customAggregates?.[l.aggFunc]||l.valueGetter||t.has(a.id)&&l.comparator||!l.field)return null;s.add(l.field)}return[...s]}function zi(n){return n!=null&&(typeof n=="object"||typeof n=="function")}function Wi(n,e){if(n.length*(e.length+4)>1e6)return null;let t=new WeakMap;for(let r of n){if(r.data==null)continue;let i=e.map(o=>W(r.data,o));i.some(zi)||t.set(r,i)}return t}function $i(n,e,t,r){return t.length?!r||n===e||n==null||e==null?!0:t.some((i,o)=>{let s=W(e,i);return zi(s)||!Object.is(r[o],s)}):!1}function se(n){return te(n.reason,"Block request aborted")}function at(n){return Number.isFinite(n)?Math.max(1,Math.trunc(n)):1}var lt=class{constructor(e,t,r=4){this.maxBlocks=e;this.ho=t;this.maxConcurrentRequests=r;this.re=new Map;this.q=new Map;this.ca=0;this.lo=0;this.co=0;this.ua=0;this.ha=0;this.Ai=0;this.ki=new Set;this.maxBlocks=at(e),this.maxConcurrentRequests=at(r)}configure(e,t=this.maxConcurrentRequests){this.maxBlocks=at(e),this.maxConcurrentRequests=at(t),this.uo(),this.Gi()}mc(e){this.ki=e,this.uo()}peek(e){let t=this.re.get(e);if(t)return t.touchedAt=++this.ca,t}has(e){return this.re.has(e)}Zt(e){let t=this.q.get(e);t&&(this.q.delete(e),t.controller.abort(),t.state==="queued"&&t.reject(se(t.controller.signal)));let r=this.re.get(e);r&&(this.re.delete(e),this.ho?.(e,r))}load(e,t,r,i=0){if(r?.aborted)return Promise.reject(se(r));let o=this.peek(e);if(o)return this.co++,Promise.resolve(o);let s=this.q.get(e);if(s)return this.co++,s.priority=Math.max(s.priority,i),this.Gi(),this.pa(e,s,r);this.ua++;let a=new AbortController,l,d,c=new Promise((p,m)=>{l=p,d=m}),u={controller:a,promise:c,consumers:0,loader:t,priority:i,state:"queued",resolve:l,reject:d};this.q.set(e,u);let h=this.pa(e,u,r);return this.Gi(),h}gc(){this.lo++,this.ki.clear();for(let e of this.q.values())e.controller.abort(),e.state==="queued"&&e.reject(se(e.controller.signal));this.q.clear();for(let[e,t]of this.re)this.ho?.(e,t);this.re.clear()}snapshot(){let e=0,t=0;for(let r of this.re.values())e+=r.rows.length;for(let r of this.q.values())r.state==="active"&&t++;return{cachedBlockCount:this.re.size,loadingBlockCount:this.q.size,activeRequestCount:t,queuedRequestCount:Math.max(0,this.q.size-t),cachedRowCount:e,hitCount:this.co,missCount:this.ua,evictionCount:this.ha}}Gi(){for(;this.Ai<this.maxConcurrentRequests;){let e,t;for(let[r,i]of this.q)i.state!=="queued"||i.controller.signal.aborted||(!t||i.priority>t.priority)&&(e=r,t=i);if(e==null||!t)return;this.yc(e,t)}}yc(e,t){t.state="active",this.Ai++;let r=this.lo;this.vc(t).then(i=>{r===this.lo&&!t.controller.signal.aborted&&(this.re.set(e,{rows:i.rows,...i.lastRow==null?{}:{lastRow:i.lastRow},touchedAt:++this.ca}),this.uo()),t.resolve(i)},t.reject).finally(()=>{this.Ai=Math.max(0,this.Ai-1),this.q.get(e)===t&&this.q.delete(e),this.Gi()})}vc(e){let{signal:t}=e.controller;return rt(Promise.resolve().then(()=>{if(t.aborted)throw se(t);return e.loader(t)}),t,()=>se(t))}pa(e,t,r){return t.consumers++,new Promise((i,o)=>{let s=!1,a=d=>{s||(s=!0,r?.removeEventListener("abort",l),t.consumers=Math.max(0,t.consumers-1),d())},l=()=>a(()=>{t.consumers===0&&this.q.get(e)===t&&(this.q.delete(e),t.controller.abort(r?.reason),t.state==="queued"&&t.reject(se(t.controller.signal))),o(se(r))});r?.addEventListener("abort",l,{once:!0}),t.promise.then(d=>a(()=>i(d)),d=>a(()=>o(d instanceof Error?d:new Error(String(d??"Block request failed")))))})}uo(){let e=Math.max(this.maxBlocks,this.ki.size+1);for(;this.re.size>e;){let t=-1,r=Number.POSITIVE_INFINITY;for(let[o,s]of this.re)this.ki.has(o)||s.touchedAt<r&&(t=o,r=s.touchedAt);if(t<0)return;let i=this.re.get(t);this.re.delete(t),this.ha++,i&&this.ho?.(t,i)}}};function Ge(n,e){if(n==null||typeof n!="object")return;let t=n[e];return Array.isArray(t)?t:void 0}var dt=class{constructor(e){this.e=e;this.u=[];this.W=[];this.ie=new Map;this.ge=[];this.p=new Map;this.Ie={};this.Ae=null;this._e=null;this.k=new Set;this.$=new Set;this.Mr=[];this.Ir=new Map;this.fa=[];this.G=null;this.Ar=!1;this.ma=!1;this.Ze=0;this.Pi=null;this.Li=new WeakMap;this.Ni=new WeakMap;this.Qe=new Map;this.kr=new Map;this.Fi=0;this.Oi=0;this.et=null;this.tt=new Map;this.xt=new Map;this.Hi=new Set;this.Et=new Map;this.rt=new lt(12,e=>this.ga(e));this.Gr=0;this.Vi=null;this.po=!1;this.ya=0;this.be=[];this.B=1;this.Ae=B(e.r.advancedFilterModel)}resolveRowId(e,t,r){let i=this.e.r.resolveRowId;if(!i)return r;try{let o=i({data:e,index:t,api:this.e.api});if(typeof o=="string"&&o.length>0)return o;this.e.reportError(new Error("rowKey must resolve to a non-empty identifier"),"rowKey",{index:t})}catch(o){this.e.reportError(o,"rowKey",{index:t})}return r}get F(){return this.e.r.treeData}get g(){return this.e.r.datasource!=null}get ye(){return this.g&&this.e.r.datasourceMode==="block"}Pr(){if(this.g){if(this.ye)return this.Qt();let e=Math.max(0,this.ge.length-this.u.length);return(this.G??this.u.length)+e}return this.ge.length}Lr(){return this.Fi}ze(){return this.Oi}bc(){return this.ma}Bi(e){return!this.g||e?.aborted?Promise.resolve():(this.va(!0),this.ye?(this.rt.configure(this.e.r.maxBlocksInCache,this.e.r.datasourceMaxConcurrentRequests),this._i(0,e)):this.ba(0,void 0,e))}Rt(e){this.ma=e,this.e.o.Rt(e,this.e.v("loading"))}ba(e,t,r){if(!this.g||this.Ar||this.G!=null&&e>=this.G)return Promise.resolve();let i=this.e.r.blockSize,o=t??e+i;if(o<=e)return Promise.resolve();let s=++this.Ze,a=new AbortController,l=()=>a.abort(r?.reason);return r?.addEventListener("abort",l,{once:!0}),this.Pi=a,this.Ar=!0,this.Rt(!0),new Promise(d=>{let c=u=>{r?.removeEventListener("abort",l),s===this.Ze&&(this.Ar=!1,this.Pi=null,this.Rt(!1),u!=null&&u?.name!=="AbortError"&&this.e.reportError(u,"datasource.getRows",{startRow:e,endRow:o})),d()};this.wa(e,o,a.signal,(u,h)=>{if(s!==this.Ze||this.e.s()||a.signal.aborted){c();return}typeof h=="number"&&h>=0?this.G=h:u.length<o-e&&(this.G=e+u.length);let p=this.u.length===0;this.wc(u),c(),this.I(),p&&this.e.ve(),this.e.Y.zi()},u=>c(a.signal.aborted||this.e.s()?void 0:u??new Error("Datasource request failed")))})}fo(){this.Ze++,this.Pi?.abort(),this.Pi=null,this.Ar=!1,this.Rt(!1),this.rt.gc(),this.tt.clear(),this.xt.clear(),this.Hi.clear();for(let[e,t]of this.Et)this.p.get(e)===t&&this.p.delete(e);this.Et.clear()}wc(e){for(let t of e){if(t==null)continue;let r=this.u.length,i=this.resolveRowId(t,r,`inf-${this.e.er()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"datasource.getRows",{rowId:i});continue}let o={id:i,data:t,rowIndex:-1,selected:this.e.f.Wi(i)};this.u.push(o),this.p.set(i,o),this.W.push(o)}}_i(e,t,r=0){if(!this.ye||e<0)return Promise.resolve();if(t?.aborted)return Promise.reject(this.Ca(t.reason));let i=this.e.r.blockSize,o=this.Ze,s=e*i;if(s>=this.Qt())return Promise.resolve();let a=this.G==null?s+i:Math.min(this.G,s+i),l=this.rt.load(e,d=>this.Cc(s,a,d),t,r);return this.Rt(this.u.length===0&&this.rt.snapshot().loadingBlockCount>0),l.then(d=>{o!==this.Ze||t?.aborted||this.e.s()||!this.ye||!this.rt.has(e)||this.Hi.has(e)||(this.Tc(e,d),this.I(),this.e.Y.zi(),o===this.Ze&&!this.e.s()&&this.Ta(this.e.a.mo().lastExcl-1))}).catch(d=>{throw d?.name!=="AbortError"&&this.e.reportError(d,"datasource.getRows",{startRow:s,endRow:a}),d}).finally(()=>{o===this.Ze&&this.Rt(this.u.length===0&&this.rt.snapshot().loadingBlockCount>0)})}Cc(e,t,r){return new Promise((i,o)=>{this.wa(e,t,r,(s,a)=>i({rows:s,...typeof a=="number"&&a>=0?{lastRow:a}:{}}),s=>o(s instanceof Error?s:new Error(typeof s=="string"?s:"Datasource request failed")))})}wa(e,t,r,i,o){let s=this.e.r.datasource,a=0,l=null,d=!1,c=()=>d?!1:(d=!0,l!=null&&clearTimeout(l),r.removeEventListener("abort",u),!0),u=()=>{c()&&o(this.Ca(r.reason))};r.addEventListener("abort",u,{once:!0});let h=()=>{if(d)return;if(r.aborted||this.e.s()){u();return}a++;let p=!1,m=g=>{if(!(p||d)){if(p=!0,r.aborted||this.e.s()){u();return}a<=this.e.r.datasourceRetryCount?l=setTimeout(h,this.retryDelay(a)):c()&&o(g)}};try{let g=s.getRows({startRow:e,endRow:t,sortModel:this.e.n.te(),filterModel:this.We(),advancedFilterModel:this.Nr(),quickFilterText:this._e,signal:r,onSuccess:(b,C)=>{!p&&c()&&i(b??[],C)},fail:m});g&&typeof g.catch=="function"&&g.catch(m)}catch(g){m(g)}};h()}Tc(e,t){let r=this.e.r.blockSize,i=e*r;this.ga(e),typeof t.lastRow=="number"&&t.lastRow>=0?this.G=t.lastRow:t.rows.length<r&&(this.G=i+t.rows.length),t.rows.forEach((o,s)=>{if(o==null)return;let a=i+s;if(this.G!=null&&a>=this.G)return;let l=this.resolveRowId(o,a,`block-${a}`),d=this.Et.get(l),c=this.p.get(l);if(c&&c!==d&&c.rowIndex!==a){this.e.reportError(new Error(`Duplicate row id: ${l}`),"datasource.getRows",{rowId:l});return}let u=d??{id:l,data:o,rowIndex:a,selected:this.e.f.Wi(l)};u.rowIndex=a,u.selected=this.e.f.Wi(l),this.Et.delete(l),this.tt.set(a,u),this.xt.delete(a),this.p.set(l,u),this.Ni.set(u,a+1)}),this.Da(),this.Hi.add(e)}ga(e){this.Hi.delete(e);let t=this.e.r.blockSize,r=e*t,i;for(let o=r;o<r+t;o++){let s=this.tt.get(o);s&&(i??(i=new Set(this.e.K.getDirtyRowIds())),this.tt.delete(o),i.has(s.id)?this.Et.set(s.id,s):this.p.get(s.id)===s&&this.p.delete(s.id))}this.Da()}Da(){this.u=[...this.tt.entries()].sort(([e],[t])=>e-t).map(([,e])=>e),this.W=this.u}Qt(){if(this.G!=null)return this.G;if(this.e.r.datasourceRowCount!=null)return this.e.r.datasourceRowCount;if(this.tt.size===0)return this.e.r.blockSize;let e=0;for(let t of this.tt.keys())e=Math.max(e,t+1);return e+this.e.r.blockSize}Dc(e){let t=this.xt.get(e);if(!t&&(t={id:`__mach_loading_${e}`,data:null,rowIndex:e,selected:!1,loading:!0},this.xt.set(e,t),this.xt.size>2e3)){let r=this.xt.keys().next().value;r!=null&&this.xt.delete(r)}return t}Ca(e){return te(e,"Operation aborted")}retryDelay(e){let t=Math.min(this.e.r.datasourceRetryDelay*2**Math.max(0,e-1),3e4),r=this.e.r.datasourceRetryJitter;return Math.max(0,Math.round(t*(1+(Math.random()*2-1)*r)))}xc(e){if(this.ye){this.Ta(e);return}if(!this.g||this.Ar)return;let t=this.u.length;if(this.G!=null&&t>=this.G)return;let r=this.e.r.infiniteBufferRows;if(e+r<t&&e<t)return;let i=this.e.r.blockSize,o=this.G==null?t+i:Math.min(this.G,t+i);this.ba(t,o)}Ta(e){if(e<0)return;this.xa();let t=this.e.r.blockSize,r=Math.floor(e/t),i=Math.floor(this.e.a.mo().first/t),o=this.e.r.blockPrefetch,s=r<this.ya?-1:1;this.ya=r;for(let a=i;a<r;a++)this._i(a,void 0,o+2).catch(()=>{});for(let a=0;a<=o;a++){let l=a===0?[r]:[r+s*a,r-s*a];for(let d of l)d<0||d*t>=this.Qt()||this._i(d,void 0,o-a+1).catch(()=>{})}}Ea(){return this.Bi().catch(()=>{})}Ec(){return this.fo(),this.g?this.Bi().catch(()=>{}):(this.G=null,this.it(this.e.r.rowData),this.e.U({data:!0}),Promise.resolve())}destroy(){this.et=null,this.fo(),this.Ra(),this.go(),this.u=this.W=this.ge=this.be=[],this.p.clear(),this.ie.clear(),this.Ir.clear(),this.fa=[],this.k.clear(),this.$.clear(),this.Mr=[]}yo(e,t,r){if(!this.ye)return Promise.resolve();this.xa();let i=this.e.r.blockSize,o=Math.max(0,Math.trunc(e)),s=Math.min(this.Qt(),Math.max(o,Math.trunc(t))),a=Math.floor(o/i),l=Math.max(a,Math.floor(Math.max(o,s-1)/i)),d=[];for(let c=a;c<=l;c++)d.push(this._i(c,r,100));return Promise.all(d).then(()=>{})}Rc(){this.ye&&this.va(!1)}va(e){this.Sa(),this.e.K.clear(),this.fo(),e&&(this.G=null,this.k.clear()),this.u=[],this.W=[],this.p.clear(),this.e.V.clear(),this.I()}Sa(){this.Oi++,this.e.$e(),this.e.api.editing.stop({cancel:!0})}Sc(){return this.rt.snapshot()}xa(){let e=new Set(this.e.K.getDirtyRowIds());for(let[l,d]of this.Et)e.has(l)||(this.Et.delete(l),this.p.get(l)===d&&this.p.delete(l));let t=this.e.r.blockSize,r=new Set,{first:i,lastExcl:o}=this.e.a.mo();for(let l=i;l<o;l+=t)r.add(Math.floor(l/t));o>i&&r.add(Math.floor((o-1)/t));let s=this.e.a.b;s&&r.add(Math.floor(s.rowIndex/t));let a=this.e.l.Mc();a!=null&&r.add(Math.floor(a/t)),this.rt.mc(r)}it(e){this.Sa(),this.Ra(),this.e.K.clear();let t=this.e.r.resolveRowId,r=this.e.r.childrenKey,i=[],o=[],s=new Map,a=new Map,l=0,d=(c,u,h)=>{let p=l++,m=this.resolveRowId(c,p,`auto-${p}`);if(s.has(m))return this.e.reportError(new Error(`Duplicate row id: ${m}`),"rowData",{rowId:m,index:p}),null;let g=this.F?Ge(c,r):void 0,b={id:m,data:c,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(g)};if(this.Li.set(b,u),i.push(b),s.set(m,b),h!=null){let C=a.get(h)??[];C.push(m),a.set(h,C)}else o.push(b);if(this.F&&Array.isArray(g))for(let C of g)C!=null&&d(C,u+1,m);return b};(e??[]).forEach(c=>{c!=null&&d(c,0,null)}),this.u=i,this.W=o,this.ie=a,this.p=s,this.e.V.clear();for(let c of[...this.k])s.has(c)||this.k.delete(c);if(this.e.r.defaultExpandAll)for(let c of i)this.Ma(c.id)>0&&this.k.add(c.id);this.e.f.Ia(t!=null),this.$i()}Fr(e){return this.ie.get(e)??[]}Ma(e){return this.ie.get(e)?.length??0}vo(e){return this.Ma(e)>0}isTreeRowLoading(e){return this.p.get(e)?.treeLoading===!0}Ra(){for(let e of this.Qe.values())e.abort();this.Qe.clear(),this.kr.clear()}loadTreeChildren(e,t=!1){let r=this.p.get(e),i=this.e.r.loadTreeChildren;if(!this.F||!r?.data||!i)return Promise.resolve([]);if(!t&&r.treeChildrenLoaded)return Promise.resolve(this.Fr(e).flatMap(l=>{let d=this.p.get(l)?.data;return d==null?[]:[d]}));let o=this.kr.get(e);if(o&&!t)return o;this.Qe.get(e)?.abort();let s=new AbortController;this.Qe.set(e,s),r.treeLoading=!0,r.treeLoadError=void 0,this.e.U({data:!0});let a=Promise.resolve().then(()=>i({data:r.data,node:r,api:this.e.api,signal:s.signal})).then(l=>{if(s.signal.aborted||this.e.s())return[];if(!Array.isArray(l))throw new TypeError("[MachTable] loadTreeChildren must resolve to an array.");return this.Ic(r,l),r.treeChildrenLoaded=!0,r.treeLoadError=void 0,this.e.emit("treeChildrenLoaded",{rowId:e,rowNode:r,children:l}),l}).catch(l=>{if(s.signal.aborted||l?.name==="AbortError")return[];throw r.treeLoadError=l,r.treeChildrenLoaded=!1,this.e.reportError(l,"treeData.loadChildren",{rowId:e}),this.e.emit("treeChildrenLoadFailed",{rowId:e,rowNode:r,error:l}),l}).finally(()=>{this.Qe.get(e)===s&&(this.Qe.delete(e),this.kr.delete(e),r.treeLoading=!1,this.e.U({data:!0}))});return this.kr.set(e,a),a}Ic(e,t){let r=new Set,i=[...this.Fr(e.id)];for(;i.length>0;){let s=i.pop();r.has(s)||(r.add(s),i.push(...this.Fr(s)))}this.Ac(t,r);for(let s of r)this.Qe.get(s)?.abort(),this.Qe.delete(s),this.kr.delete(s),this.ie.delete(s),this.p.delete(s),this.k.delete(s);this.ie.delete(e.id);let o=this.bo(e)+1;for(let s of t)s!=null&&this.wo(e,s,o);this.Aa(),this.e.f.Ia(this.e.r.resolveRowId!=null),this.I()}Ac(e,t){let r=this.e.r.resolveRowId,i=r?new Set([...this.p.keys()].filter(l=>!t.has(l))):null,o=new WeakSet,s=[...e],a=0;for(;s.length>0;){let l=s.pop();if(l==null)continue;if(typeof l=="object"){if(o.has(l))throw new TypeError("[MachTable] Lazy tree children contain a cyclic object graph.");o.add(l)}if(r&&i){let c=r({data:l,index:a++,api:this.e.api});if(typeof c!="string"||c.length===0)throw new TypeError("[MachTable] rowKey must resolve to a non-empty identifier for lazy tree children.");if(i.has(c))throw new Error(`Duplicate row id: ${c}`);i.add(c)}let d=Ge(l,this.e.r.childrenKey);d&&s.push(...d)}}Or(e,t=!0){let r=this.e.r.resolveRowId,i=[],o=[];if(e.remove?.length){let a=new Set,l=new Set,d=u=>{if(r){let p=[this.resolveRowId(u,-1,`__missing_remove_${this.e.er()}`)];for(;p.length>0;){let m=p.pop();if(!a.has(m)){a.add(m);for(let g of this.ie.get(m)??[])p.push(g)}}}else{let h=[u];for(;h.length>0;){let p=h.pop();l.add(p);let m=this.F?Ge(p,this.e.r.childrenKey):void 0;if(m)for(let g of m)h.push(g)}}};e.remove.forEach(d),this.u=this.u.filter(u=>{let h=a.has(u.id)||u.data!=null&&l.has(u.data);return h&&(o.push(u.id),this.p.delete(u.id),this.ie.delete(u.id)),!h});let c=new Set(this.u);this.W=this.W.filter(u=>c.has(u))}if(e.update?.length)for(let a of e.update){let l;r?l=this.p.get(this.resolveRowId(a,-1,`__missing_update_${this.e.er()}`)):l=this.u.find(d=>d.data===a),l&&(i.push({node:l,before:l.data,after:a}),l.data=a,o.push(l.id),this.e.a.Ki(l))}if(e.add?.length){let a=e.addIndex!=null?Math.max(0,Math.min(e.addIndex,this.W.length)):this.W.length,l=[];e.add.forEach((d,c)=>{let u=this.resolveRowId(d,a+c,`add-${this.e.er()}`);if(this.p.has(u)){this.e.reportError(new Error(`Duplicate row id: ${u}`),"transaction.add",{rowId:u});return}let h={id:u,data:d,rowIndex:-1,selected:!1};this.p.set(u,h),this.Li.set(h,0);let p=this.F?Ge(d,this.e.r.childrenKey):void 0;if(p)for(let m of p)m!=null&&this.wo(h,m,1);l.push(h)}),this.W=this.W.slice(0,a).concat(l,this.W.slice(a)),this.Aa()}let s={pipelineChanged:this.kc(e,i),updatedRowIds:i.map(({node:a})=>a.id)};return this.e.V.Gc(o),this.Pc(s,t),this.e.K.Lc(o),s}Pc(e,t){e.pipelineChanged&&(this.et=null),t&&(e.pipelineChanged?this.$i():e.updatedRowIds.length&&this.ka())}Nc(e){if(e.length===0)return{pipelineChanged:!1,updatedRowIds:[]};let t=this.Oi,r=!1,i=new Set;for(let o of e){let s=this.Or(o,!1);if(this.Oi!==t)return{pipelineChanged:!1,updatedRowIds:[]};r||(r=s.pipelineChanged);for(let a of s.updatedRowIds)i.add(a)}return r?this.$i():i.size>0&&this.ka(),{pipelineChanged:r,updatedRowIds:[...i]}}kc(e,t){if(e.add?.length||e.remove?.length)return!0;if(!t.length)return!1;let r=this.Ga();if(r===null)return!0;if(!r.length)return!1;let i=this.et;return!i||r.length!==i.fields.length||r.some((o,s)=>o!==i.fields[s])?!0:t.some(({node:o,before:s,after:a})=>$i(s,a,r,i.values.get(o)))}Ga(){if(this.F||this.e.r.masterDetail||this.Pa())return null;let e=this.e.n.d();if(e.some(r=>r.colDef.autoHeight===!0||r.colDef.autoRowSpan===!0||r.colDef.rowSpan!=null))return null;let t=!this.e.r.manualFiltering;return _i({columns:e,customAggregates:this.e.r.aggFuncs,sortModel:this.e.r.manualSorting?[]:this.e.n.te(),filterModel:t?this.Ie:{},advancedFilter:t?this.Ae:null,quickFilter:t?this._e:null})}Fc(){let e=this.Ga(),t=e?.length?Wi(this.u,e):null;this.et=e&&t?{fields:e,values:t}:null}ka(){this.e.emit("modelUpdated",{rowCount:this.be.length})}wo(e,t,r){let i=this.resolveRowId(t,-1,`add-${this.e.er()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"transaction.add",{rowId:i});return}let o=Ge(t,this.e.r.childrenKey),s={id:i,data:t,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(o)};this.p.set(i,s),this.Li.set(s,r);let a=this.ie.get(e.id)??[];if(a.push(s.id),this.ie.set(e.id,a),!!o)for(let l of o)l!=null&&this.wo(s,l,r+1)}Aa(){this.u=[];let e=t=>{this.u.push(t),this.p.has(t.id)||this.p.set(t.id,t);for(let r of this.ie.get(t.id)??[]){let i=this.p.get(r);i&&e(i)}};for(let t of this.W)e(t)}St(e){let t=JSON.stringify(this.Ie),r=new Set(this.e.n.ee().map(o=>o.id));this.Ie=ne(e,r);let i=JSON.stringify(this.Ie)!==t;return i&&(this.et=null),i}We(){return{...this.Ie}}Oc(e=this.Ae){let t=Object.keys(this.Ie).length>0&&this.St(this.Ie),r=(e!=null||this.Ae!=null)&&this.nt(e);return t||r}nt(e){let t=new Set(this.e.n.ee().map(s=>s.id)),r=B(e,t),i=JSON.stringify(this.Ae);this.Ae=r,this.e.r.advancedFilterModel=r;let o=JSON.stringify(r)!==i;return o&&(this.et=null),o}Nr(){return B(this.Ae)}Mt(e){let t=e!=null&&e.trim()!==""?e:null;return t===this._e?!1:(this._e=t,this.et=null,!0)}Co(){return this._e}Hr(){return Object.keys(this.Ie).length>0||this.Ae!=null||this._e!=null}I(){this.$i(),this.e.U({data:!0})}To(){this.g?this.Ea():this.I()}$i(){this.et=null;let e=this.e.we.start(),t=this.e.n.d(),r=(s,a)=>this.e.c(s,a);if(this.g){this.Hc(e);return}if(this.Vc(e))return;let i,o=[];if(this.F)i=this.Bc(t,r);else{i=this.u,this.Hr()&&!this.e.r.manualFiltering&&(i=i.filter(gr(t,this.Ie,this.Ae,this._e,r)));let a=this.e.n.te();if(a.length>0&&!this.e.r.manualSorting)try{i=yr(i,a,t,r)}catch(d){this.e.reportError(d,"comparator",{sortModel:a})}let l=this.e.n.Je();if(l.length>0){let d=this._c(i,l);i=d.rows,o=d.ambiguousExpansions}else if(this.e.r.masterDetail){let d=[];for(let c of i)d.push(c),this.k.has(c.id)&&this.isRowExpandable(c)&&d.push({id:`__detail__${c.id}`,data:c.data,rowIndex:-1,selected:!1,isDetail:!0,masterId:c.id});i=d}}this.La(i,e,!0),this.zc(o)}La(e,t,r=!1){for(let o of this.u)o.rowIndex=-1;let i=0;e.forEach((o,s)=>{o.rowIndex=s,!o.isDetail&&!o.isGroup&&this.Ni.set(o,++i)}),this.be=e,this.Vr(),r&&this.Fc(),this.Wc((o,s)=>this.e.c(o,s)),this.e.emit("modelUpdated",{rowCount:e.length}),this.e.we.Na(t)}Hc(e){this.u.forEach((t,r)=>{this.ye||(t.rowIndex=r),this.Ni.set(t,this.ye?t.rowIndex+1:r+1)}),this.ge=this.u,this.be=this.u,this.Ir.clear(),this.e.r.getRowHeight&&this.e.a.It(),this.Fi++,this.e.emit("modelUpdated",{rowCount:this.u.length}),this.e.we.Na(e)}Vc(e){let t=this.po;return this.po=!1,!t&&this.Pa()?(this.$c(e),!0):(this.go(),!1)}Pa(){if(!this.e.r.dataProcessor||this.u.length<this.e.r.dataProcessorMinRows||this.F||this.e.r.masterDetail||this.e.n.Je().length>0)return!1;let e=!this.e.r.manualFiltering&&this.Hr(),t=!this.e.r.manualSorting&&this.e.n.te().length>0;return e||t}$c(e){this.go();let t=this.e.r.dataProcessor;if(!t)return;let r=++this.Gr,i=new AbortController;this.Vi=i;let o=this.e.n.d(),s=this.u.flatMap(d=>d.data==null?[]:[{id:d.id,data:d.data}]),a=!this.e.r.manualFiltering,l=!this.e.r.manualSorting;Promise.resolve().then(()=>t.process({rows:s,columns:o.map(d=>({colId:d.id,...d.colDef.field?{field:d.colDef.field}:{}})),sortModel:l?this.e.n.te():[],filterModel:a?this.We():{},advancedFilterModel:a?this.Nr():null,quickFilterText:a?this._e:null,signal:i.signal})).then(d=>{if(r!==this.Gr||i.signal.aborted||this.e.s())return;let c=new Set,u=[];for(let h of d.rowIds){if(c.has(h))continue;c.add(h);let p=this.p.get(h);p&&!p.isDetail&&!p.isGroup&&u.push(p)}this.La(u,e),this.e.U({data:!0})}).catch(d=>{r!==this.Gr||i.signal.aborted||this.e.s()||(this.e.reportError(d,"dataProcessor.process"),this.po=!0,this.I())}).finally(()=>{r===this.Gr&&(this.Vi=null)})}go(){this.Gr++,this.Vi?.abort(),this.Vi=null}get Ce(){return this.e.r.paginationEnabled&&!this.g}Vr(){if(this.e.r.getRowHeight&&this.e.a.It(),!this.Ce){this.ge=this.be,this.Fi++;return}let e=this.Br(),t=this.getPageCount();this.B>t&&(this.B=t),this.B<1&&(this.B=1),this.e.r.paginationPage=this.B;let r=(this.B-1)*e;this.ge=this.e.r.paginationMode==="server"?this.be:this.be.slice(r,r+e),this.ge.forEach((i,o)=>{i.rowIndex=o}),this.Fi++}Br(){return Math.max(1,this.e.r.paginationPageSize)}tr(){return this.Ce?this.B:1}getTotalRowCount(){return this.g?this.Pr():this.Ce&&this.e.r.paginationMode==="server"?this.e.r.paginationTotal:this.be.length}getPageCount(){return this.Ce?Math.max(1,Math.ceil(this.getTotalRowCount()/this.Br())):1}Fa(){return this.be}setPage(e,t=!1){if(!this.Ce)return;let r=this.getPageCount(),i=Math.max(1,Math.min(Math.round(e)||1,r));i!==this.B&&(this.B=i,this.e.r.paginationPage=i,this.Vr(),this.e.U({data:!0}),this.e.a.Ui(0,"top"),t||this._r())}setPageSize(e){if(!this.Ce)return;let t=Math.max(1,Math.round(e)||this.Br()),r=(this.B-1)*this.Br();this.e.r.paginationPageSize=t,this.B=Math.floor(r/t)+1,this.e.r.paginationPage=this.B,this.Vr(),this.e.U({data:!0}),this._r()}Oa(e,t){this.e.r.paginationPageSize=Math.max(1,Math.round(t)||1),this.B=Math.max(1,Math.round(e)||1),this.e.r.paginationPage=this.B}Ha(e){this.e.r.paginationEnabled!==e&&(this.e.r.paginationEnabled=e&&!this.g,this.e.r.paginationEnabled&&(this.B=1),e||this.be.forEach((t,r)=>{t.rowIndex=r}),this.Vr(),this.e.U({data:!0}),this._r())}Kc(){this.Ce&&(this.B=this.e.r.paginationMode==="server"?this.e.r.paginationPage:1,this.Vr(),this.e.U({data:!0}),this._r())}_r(e=this.Br()){this.e.emit("paginationChanged",{page:this.tr(),pageSize:e,pageCount:this.getPageCount(),total:this.getTotalRowCount()})}Bc(e,t){let r=this.e.r.manualSorting?[]:this.e.n.te(),i=new Map,o=this.Hr()&&!this.e.r.manualFiltering,s=gr(e,this.Ie,this.Ae,this._e,t),a=c=>{let u=i.get(c.id);if(u!==void 0)return u;let h=!0;if(o){h=s(c);for(let p of this.ie.get(c.id)??[]){let m=this.p.get(p);m&&a(m)&&(h=!0)}}return i.set(c.id,h),h},l=[],d=c=>{let u=c;r.length>0&&(u=yr(c,r,e,t));for(let h of u)if(a(h)&&(l.push(h),this.k.has(h.id))){let p=(this.ie.get(h.id)??[]).map(m=>this.p.get(m)).filter(m=>m!=null);d(p)}};return d(this.W),l}Uc(){let e=this.fa,t=0;for(let r of this.ge)!r.isDetail&&!r.isGroup&&(e[t++]=r);return e.length=t,e}jc(e,t,r,i){let o=t.colDef.rowSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r,rowIndex:e.rowIndex});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"rowSpan",{colId:t.id,rowId:e.id}),1}}qc(e,t,r,i,o){if(!r.colDef.autoRowSpan||i==null||i==="")return 1;let s=1;for(;t+s<e.length&&it(i,o(e[t+s],r))===0;)s++;return s}Yc(e,t,r){let i=new Int32Array(e.length),o=0;for(;o<e.length;){let s=e[o],a=r(s,t),l=t.colDef.rowSpan?this.jc(s,t,a,e.length-o):this.qc(e,o,t,a,r);i[o]=l;for(let d=1;d<l;d++)i[o+d]=-1;o+=l}return i}Wc(e){if(this.Ir.clear(),this.F||this.e.r.masterDetail||this.e.n.Je().length>0)return;let t=this.e.n.d().filter(i=>i.colDef.rowSpan!=null||i.colDef.autoRowSpan===!0);if(t.length===0)return;let r=this.Uc();if(r.length!==0)for(let i of t)this.Ir.set(i.id,this.Yc(r,i,e))}Xc(e){return this.Ir.get(e)}Va(e){return this.Ni.get(e)??0}bo(e){return this.Li.get(e)??0}_c(e,t){let r=vr(this.e.r.aggFuncs),i=this.e.n.hc();this.Mr=[];let o=l=>{let d={};for(let c of i){let u=r(c.colDef.aggFunc);if(u)try{d[c.id]=Fi(l,u,h=>this.e.c(h,c))}catch(h){this.e.reportError(h,"aggFunc",{colId:c.id,aggFunc:c.colDef.aggFunc}),d[c.id]=null}}return d},s=Bi(this.$,this.u,t,(l,d)=>this.e.c(l,d));this.$=s.expanded;let a=Vi(e,t,(l,d)=>this.e.c(l,d),o,this.$);return this.Mr=a.ids,{rows:a.rows,ambiguousExpansions:s.ambiguous}}zc(e){for(let t of e){if(this.e.s())return;this.e.reportError(new Error(`Ambiguous legacy group expansion: ${t}`),"gridState.groupExpansion",{groupId:t})}}isRowExpandable(e){let t=this.F;if(t){if(this.vo(e.id)||e.treeLoading)return!0;if(e.treeChildrenLoaded||!e.data||!this.e.r.loadTreeChildren)return!1}else if(!this.e.r.masterDetail)return!1;let r=t?"isTreeRowExpandable":"isRowExpandable",i=this.e.r[r];if(!i)return!t;try{return i({data:e.data,node:e,api:this.e.api})}catch(o){return this.e.reportError(o,r,{rowId:e.id}),!1}}isRowExpanded(e){return this.k.has(e)}Jc(){return[...this.k]}Zc(){return[...this.$]}Qc(e,t){this.k=new Set(e.filter(r=>this.p.has(r))),this.$=new Set(t)}eu(e){return this.Do(e,!0)}tu(e){return this.Do(e,!1)}ji(e){return this.Do(e,!this.k.has(e))}Do(e,t){let r=this.p.get(e);return!r||t&&!this.isRowExpandable(r)?!1:(t===this.k.has(e)||(t?this.k.add(e):this.k.delete(e),this.I(),this.e.emit("detailToggled",{rowId:e,rowNode:r,expanded:t}),t&&this.F&&!this.vo(e)&&!r.treeLoading&&this.loadTreeChildren(e).catch(()=>{})),t)}setAllDetailsExpanded(e){let t=!1;if(e)for(let r of this.u)!this.k.has(r.id)&&this.isRowExpandable(r)&&(this.k.add(r.id),t=!0);else this.k.size>0&&(this.k.clear(),t=!0);t&&this.I()}xo(e){return this.setGroupExpanded(e,!this.$.has(e))}isGroupExpanded(e){return this.$.has(e)}setAllGroupsExpanded(e){let t=this.$.size;if(e)for(let r of this.Mr)this.$.add(r);else this.$.clear();this.$.size!==t&&this.I()}setGroupExpanded(e,t){return!this.Mr.includes(e)||t===this.$.has(e)||(t?this.$.add(e):this.$.delete(e),this.I()),t}Ba(){return!this.F&&!this.g&&!this.e.r.dataProcessor&&this.e.r.paginationMode!=="server"&&this.e.n.te().length===0&&this.e.n.Je().length===0}_a(e,t){if(!this.Ba()||!Number.isInteger(e)||!Number.isInteger(t))return!1;let r=this.h(e),i=this.h(t);if(!r||!i||r.isDetail||i.isDetail||r.isGroup||i.isGroup)return!1;let o=this.u.indexOf(r),s=this.u.indexOf(i);return o<0||s<0||o===s?!1:(this.u.splice(o,1),this.u.splice(s,0,r),this.I(),!0)}Ve(){return this.u}ru(){return this.W}At(){return this.ge}P(){return this.ye?this.Qt():this.ge.length}h(e){return this.ye?e<0||e>=this.Qt()?void 0:this.tt.get(e)??this.Dc(e):this.ge[e]}O(e){return this.p.get(e)}iu(e){this.u.forEach(e)}nu(e){let t=0;for(let r of this.be)r.isDetail||r.isGroup||e(r,t++)}};var ct=class{constructor(e){this.e=e;this.L=new Set;this.kt=null;this.zr=new Set}Wi(e){return this.L.has(e)}ou(e){return this.zr.has(e)}Ke(e,t){if(e.loading)return!1;if(e.isGroup||e.isDetail)return!0;let r=t===void 0?this.Eo():t,i=r?.colDef.selectable;if(!r||!i)return!0;try{return i({api:this.e.api,colDef:r.colDef,column:r,node:e,data:e.data,value:this.e.c(e,r),rowIndex:e.rowIndex})}catch(o){return this.e.reportError(o,"selectable",{rowId:e.id,colId:r.id}),!1}}Eo(){return this.e.n.d().find(e=>e.hasCheckbox&&e.colDef.selectable!=null)}rr(){return this.e.i.Ve().filter(e=>this.L.has(e.id))}za(e=this.rr()){return e.filter(t=>t.data!=null).map(t=>t.data)}Ro(){return[...this.L]}Wa(e){let t=new Set(e),r=this.Eo()??null,i=this.e.i.Ve().filter(o=>t.has(o.id)&&!o.isDetail&&!o.isGroup&&this.Ke(o,r)).map(o=>({node:o,selected:!0}));this.Gt(i,!0)}su(){this.Wa(this.e.r.rowSelection==="none"?[]:this.Ro())}Ia(e){let t=this.e.i;if(!e)this.L.clear(),this.kt=null;else{for(let r of this.L)t.O(r)||this.L.delete(r);this.kt!=null&&!t.O(this.kt)&&(this.kt=null)}this.$a(null);for(let r of t.Ve())r.selected=this.L.has(r.id)}Ka(e){let{selectable:t,selected:r}=this.Ua(e.leafNodes??[],!1);return{all:r>0&&r===t,some:r>0}}au(e,t){let r=(e.leafNodes??[]).filter(i=>this.Ke(i));r.length!==0&&this.Gt(r.map(i=>({node:i,selected:t})))}So(e,t,r=!1){this.Gt([{node:e,selected:t,clearOthers:r}])}lu(e,t=!0,r=!0){let i=this.e.i.O(e);i&&this.So(i,t,r)}du(e,t,r){if(!r||!t.shiftKey||this.kt==null)return!1;let i=this.e.i.O(this.kt);if(!i||i.rowIndex<0||e.rowIndex<0)return!1;let o=Math.min(i.rowIndex,e.rowIndex),s=Math.max(i.rowIndex,e.rowIndex),a=[];for(let l=o;l<=s;l++){let d=this.e.i.h(l);d&&!d.isDetail&&!d.isGroup&&a.push({node:d,selected:!0})}return this.Gt(a),!0}ja(e,t,r){let i=this.e.r.rowSelection;if(i==="none"||!this.Ke(e))return;let o=i==="multiple",s=o&&(r||t.ctrlKey||t.metaKey);!s&&this.du(e,t,o)||(this.So(e,!s||!e.selected,!s),this.kt=e.id)}selectAll(e=!0){if(this.e.r.rowSelection==="none")return;let r=e?this.e.i.At():this.e.i.Ve();this.Gt(r.filter(i=>!i.isDetail&&!i.isGroup).map(i=>({node:i,selected:!0})))}deselectAll(){this.Gt([],!0)}cu(){let e=this.e.i,{selectable:t,selected:r}=this.Ua(e.At(),!0),i=r>0&&r===t&&(!e.g||t>=e.Pr());return{all:i,some:r>0&&!i}}Ua(e,t){let r=0,i=0;for(let o of e)t&&(o.isDetail||o.isGroup)||!this.Ke(o)||(r++,this.L.has(o.id)&&i++);return{selectable:r,selected:i}}uu(e,t){let r=this.e.i,i=this.e.r.rowSelection==="single",o=!i&&r.F&&this.e.r.autoCheckedChildren,s=(a,l,d=!1)=>{if(l?(d||this.Ke(a,t))&&this.L.add(a.id):this.L.delete(a.id),!!o)for(let c of r.Fr(a.id)){let u=r.O(c);u&&s(u,l)}};for(let{node:a,selected:l}of e)if(s(a,l,!0),i&&l)break}hu(e){let t=new Set(e);for(let r of this.L)t.delete(r)||t.add(r);return t}pu(e){let t=[];for(let r of this.e.i.Ve()){let i=this.L.has(r.id);(r.selected!==i||e.has(r.id)||this.zr.has(r.id))&&r.rowIndex>=0&&t.push(r.rowIndex),r.selected=i}return t}Gt(e,t=!1){let r=this.e.r.rowSelection,i=this.Eo()??null,o=e.filter(c=>!c.selected||r!=="none"&&this.Ke(c.node,i));if(e.length>0&&o.length===0)return;let s=new Set(this.L);(t||o.some(c=>c.selected?r==="single"||c.clearOthers:c.clearOthers&&this.Ke(c.node,i)))&&this.L.clear(),this.uu(o,i);let a=new Set(this.zr);this.$a(i);let l=this.hu(s),d=this.pu(a);if(l.size>0){this.e.a.I(d),this.e.Y.zi();let c=this.rr();this.e.emit("selectionChanged",{selectedNodes:c,selectedRows:this.za(c)})}}$a(e){this.zr.clear();let t=this.e.i;if(this.e.r.rowSelection!=="multiple"||!t.F||this.L.size===0)return;let r=i=>{let o=e&&t.O(i),s=!o||this.Ke(o,e),a=!0,l=!1;for(let d of t.Fr(i)){let c=r(d);a&&(a=c.all),l||(l=c.some)}if(a&&!l){s||this.L.delete(i);let d=this.L.has(i);return{all:d||!s,some:d}}return s&&a?this.L.add(i):(this.L.delete(i),s&&l&&this.zr.add(i)),{all:a,some:l}};for(let i of t.ru())r(i.id)}};var ut=class{constructor(e){this.e=e;this.Pt=null;this.ne=0;this.ot=0;this.ke=null;this.Lt=null;this.Wr=e=>{let t=this.Ao(e);t&&(this.ot=this.Ya(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.ot-t.startWidth)>=.5),!this.ne&&(this.ne=requestAnimationFrame(()=>{this.ne=0,this.gu()})))};this.nr=e=>{let t=this.Ao(e);t&&(this.ot=this.Ya(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.ot-t.startWidth)>=.5),this.yu(t))};this.qi=e=>{this.Ao(e)&&this.Nt()};this.vu=()=>{this.Nt()}}fu(e,t){if(!this.e.r.enableColumnResize||!t.resizable||e.isPrimary===!1)return;this.Nt();let r=e.currentTarget,i=t.currentWidth;this.ot=i,this.Pt={column:t,didResize:!1,handle:r,pointerId:e.pointerId,startFlex:t.flex,startManualWidth:t.manualWidth,startWidth:i,startX:e.clientX},this.Mo(r,!0);try{r.setPointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.add("mach-root--resizing"),r.classList.add("mach-header-resize--active"),this.mu(this.Pt)}Nt(e=!0){let t=this.Pt;t&&(this.Pt=null,this.Io(),this.Mo(t.handle,!1),e&&(t.column.manualWidth=t.startManualWidth,t.column.flex=t.startFlex,this.e.ir()),this.e.o.root.classList.remove("mach-root--resizing"),this.qa(t))}yu(e){this.Pt=null,this.Io(),e.didResize&&(Math.abs(this.ot-e.startWidth)<.5?(e.column.manualWidth=e.startManualWidth,e.column.flex=e.startFlex):this.e.n.Me(e.column,this.ot),this.e.ir()),this.Mo(e.handle,!1);try{e.handle.releasePointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.remove("mach-root--resizing"),this.qa(e),e.didResize&&this.e.st([e.column])}gu(){let e=this.Pt;!e||!this.e.n.Me(e.column,this.ot)||(this.e.ir(),this.$r(e),this.e.Xa(e.column,!1))}mu(e){this.ke=document.createElement("div"),this.ke.className="mach-column-resize-guide",this.ke.setAttribute("aria-hidden","true"),this.Lt=document.createElement("span"),this.Lt.className="mach-column-resize-label",this.ke.appendChild(this.Lt),this.e.o.root.appendChild(this.ke),this.$r(e)}$r(e){if(!this.ke||!this.Lt)return;let t=this.e.o.root,r=t.getBoundingClientRect(),i=e.handle.parentElement.getBoundingClientRect(),o=Math.max(0,Math.min(t.clientWidth,i.right-r.left-t.clientLeft)),s=Math.max(32,Math.min(t.clientWidth-32,o));this.ke.style.left=`${o}px`,this.ke.style.top=`${Math.max(0,i.top-r.top-t.clientTop)}px`,this.Lt.style.left=`${s-o}px`,this.Lt.textContent=`${Math.round(e.column.currentWidth)} px`}qa(e){e.handle.classList.remove("mach-header-resize--active"),this.ke?.remove(),this.ke=null,this.Lt=null}Ya(e,t){let r=Number.isFinite(t)?t:e.startX;return Math.max(1,e.startWidth+r-e.startX)}Ao(e){let t=this.Pt;return t&&e.pointerId===t.pointerId?t:null}Io(){this.ne&&cancelAnimationFrame(this.ne),this.ne=0}Mo(e,t){S(window,t,{pointermove:this.Wr}),S(window,t,{pointerup:this.nr,pointercancel:this.qi},!0),S(e,t,{lostpointercapture:this.vu})}destroy(){this.Nt(!1),this.Io(),this.e.o.root?.classList.remove("mach-root--resizing")}};var Ki=6,ht=class{constructor(e){this.e=e;this.Kr=null;this.or=null;this.ko=!1;this.le=0;this.Yi=null;this.Wr=e=>{if(this.or){this.Cu(e);return}let t=this.Kr;t&&(Math.abs(e.clientX-t.startX)<Ki&&Math.abs(e.clientY-t.startY)<Ki||this.Tu(e))};this.nr=e=>{this.Kr=null,e.type!=="pointercancel"&&this.or&&this.Lo(e.clientX,e.clientY),this.Go();let t=this.Ja();t&&e.type!=="pointercancel"&&t.targetIndex>=0&&this.e.Rr(t.column.id,t.targetIndex)}}bu(e,t){e.button===0&&t.movable&&(this.Kr={column:t,startX:e.clientX,startY:e.clientY},this.Ur(!0))}Ur(e){S(window,e,{pointermove:this.Wr,pointerup:this.nr,pointercancel:this.nr})}wu(){let e=this.ko;return this.ko=!1,e}Tu(e){let t=this.Kr;if(!t)return;let r=this.Du(t.column);if(!r||!r.parentElement){this.Go();return}this.ko=!0;let i=f("div","mach-drop-indicator"),o=f("div","mach-column-drag-ghost");o.textContent=t.column.colDef.headerName??t.column.colDef.field??t.column.id,o.ariaHidden="true",I(o,this.e.o.root),document.body.appendChild(o),r.parentElement.appendChild(i),r.classList.add("mach-header-cell--dragging"),this.e.o.root.classList.add("mach-root--dragging");let s=this.e.a.Po(t.column),a=this.e.o.sr[s],l=this.e.n.y(s),d=new Float64Array(l.length+1),c=new Float64Array(l.length);for(let h=0;h<l.length;h++){let p=l[h].currentWidth;c[h]=d[h]+p/2,d[h+1]=d[h]+p}let u=o.getBoundingClientRect();this.or={column:t.column,cellEl:r,ghost:o,indicator:i,targetIndex:-1,pane:s,containerLeft:a.getBoundingClientRect().left,startScrollLeft:this.e.o.T.center.scrollLeft,fromIndex:l.indexOf(t.column),midpoints:c,offsets:d,ghostWidth:u.width,ghostHeight:u.height},this.Lo(e.clientX,e.clientY)}Du(e){let t=this.e.a.Po(e);return this.e.o.sr[t].querySelector(`.mach-header-cell[data-col-id="${Cs(e.id)}"]`)}Cu(e){this.Yi={clientX:e.clientX,clientY:e.clientY},!this.le&&(this.le=requestAnimationFrame(()=>{this.le=0;let t=this.Yi;this.Yi=null,t&&this.Lo(t.clientX,t.clientY)}))}Lo(e,t){let r=this.or;if(!r)return;let i=T(e+12,8,window.innerWidth-r.ghostWidth-8),o=T(t+12,8,window.innerHeight-r.ghostHeight-8);r.ghost.style.transform=`translate3d(${i}px, ${o}px, 0)`;let s=r.pane==="center"?this.e.o.T.center.scrollLeft-r.startScrollLeft:0,a=e-(r.containerLeft-s),l=r.midpoints.length;for(let d=0;d<r.midpoints.length;d++)if(a<r.midpoints[d]){l=d;break}r.targetIndex=l>r.fromIndex?l-1:l,r.indicator.style.transform=`translate3d(${r.offsets[l]}px, 0, 0)`}Ja(){let e=this.or;return e?(this.or=null,e.cellEl.classList.remove("mach-header-cell--dragging"),e.ghost.remove(),e.indicator.remove(),this.e.o.root.classList.remove("mach-root--dragging"),e):null}Go(){this.Ur(!1),this.le&&cancelAnimationFrame(this.le),this.le=0,this.Yi=null}destroy(){this.Go(),this.Ja(),this.Kr=null}};function Cs(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/[^a-zA-Z0-9_-]/g,"\\$&")}var wr=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function pt(n,e=!0){if(n==="")return null;if(!e||typeof n!="string"||!wr.test(n)||/^[+-]?0\d/.test(n))return n;let t=Number(n);return Number.isFinite(t)&&(!Number.isInteger(t)||Number.isSafeInteger(t))?t:n}function Ts(n,e){let t=n==null?"":String(n);return t.includes(e)||t.includes('"')||t.includes(`
2
- `)||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t}function pe(n){return typeof n!="string"||n===""||wr.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function Ui(n,e={}){let t=e.columnSeparator??",",r=e.protectFormulas??!0,i=n.map(o=>o.map(s=>Ts(r?pe(s):s,t)).join(t)).join(`\r
3
- `);return e.prependBOM?"\uFEFF"+i:i}function Cr(n){return n==null?"":String(n)}function Ds(n,e){let t=e?pe(n):n,r=Cr(t);return/["\t\n\r]/.test(r)?'"'+r.replace(/"/g,'""')+'"':r}function Tr(n,e=!0){return n.map(t=>t.map(r=>Ds(r,e)).join(" ")).join(`
4
- `)}function Dr(n){return Er(n," ")}function xr(n,e=","){return Er(n,e)}function Er(n,e){let t=[],r=[],i="",o=!1,s=0;for(;s<n.length;){let a=n[s];a==='"'&&(o||i==="")?o&&n[s+1]==='"'?(i+=a,s++):o=!o:o?i+=a:a===e?(r.push(i),i=""):a===`
5
- `||a==="\r"?(r.push(i),t.push(r),r=[],i="",a==="\r"&&n[s+1]===`
6
- `&&s++):i+=a,s++}return(i!==""||r.length>0)&&(r.push(i),t.push(r)),t}function xs(n){let e=null;try{return e=document.createElement("textarea"),e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy")}catch{return!1}finally{e?.remove()}}async function Pe(n){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(n),!0}catch{}return xs(n)}var ji=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Es=new Set([...ji,"Enter","F2","Tab"," ","Escape","Delete","Backspace"]),ft=class{constructor(e){this.e=e;this.Qa=e=>{if(this.No(e)||this.e.s()||this.e.r.suppressClipboard)return;let t=this.e.a.ar();if(!t)return;let r=this.e.rl(t),i=e.clipboardData;if(e.preventDefault(),i&&typeof i.setData=="function"){try{i.setData("text/plain",r)}catch{return}e.type==="cut"&&this.e.Fo(t)}else e.type==="cut"?this.e.Ru(t,r):Pe(r)};this.Eu=e=>{if(this.No(e)||this.e.r.suppressClipboard)return;let t=this.e.a.Oo();if(!t)return;let r=e.clipboardData,i=r&&typeof r.getData=="function"?r.getData("text/plain"):null;typeof i!="string"||i===""||(e.preventDefault(),this.e.il(i,t.row,t.colIdx))};this.xu=e=>{this.No(e)||this.e.s()||this.Su(e)||Es.has(e.key)&&(this.Mu(e)||this.Iu(e)||this.Au(e))}}init(){this.Za(!0)}destroy(){this.Za(!1)}Za(e){S(this.e.o.root,e,{keydown:this.xu,copy:this.Qa,cut:this.Qa,paste:this.Eu})}tl(e,t,r){let i=this.e.n.d(),o=this.e.n.Q(t);if(o<0)return null;let s=this.e.i.P(),a=o,l=e;for(let d=0;d<(i.length+1)*(s+1);d++){if(a+=r,a>=i.length){if(l>=s-1)return null;a=0,l=this.Ft(l+1,1)}else if(a<0){if(l<=0)return null;a=i.length-1,l=this.Ft(l-1,-1)}if(l<0||l>=s)return null;let c=this.e.i.h(l);if(c&&!c.isDetail&&this.e.l.oe(c,i[a]))return{rowIndex:l,column:i[a]}}return null}Ft(e,t){let r=this.e.i.P();for(;e>=0&&e<r;){let i=this.e.i.h(e);if(!i||!i.isDetail)return e;e+=t}return-1}No(e){let t=e.target;return e.defaultPrevented||t instanceof HTMLElement&&(t.isContentEditable||!!t.closest("button,a[href],input,textarea,select"))||this.e.l.isEditing()}Su(e){if(!e.ctrlKey&&!e.metaKey)return!1;let t=e.key.toLowerCase();return t==="a"?(this.e.r.rowSelection==="multiple"&&(e.preventDefault(),this.e.f.selectAll(!0)),!0):e.altKey||t!=="z"&&t!=="y"?!1:(e.preventDefault(),t==="z"&&!e.shiftKey?this.e.V.undo():this.e.V.redo(),!0)}Mu(e){let t=this.e.a;if(e.key==="Escape")return this.e.$e(),this.e.r.enableRangeSelection&&t.Te()&&(e.preventDefault(),t.lr()),!0;if(e.key!=="Delete"&&e.key!=="Backspace")return!1;let r=t.ar();return r&&(e.preventDefault(),this.e.Fo(r)),!0}Iu(e){if(this.e.a.b)return!1;let t=this.e.n.d();return this.e.i.P()>0&&t.length>0&&(e.preventDefault(),this.e.a.Ge(0,t[0].id)),!0}Au(e){let t=this.e.a,r=t.b;if(!r)return;let i=this.e.n.d(),o=this.e.n.Q(r.colId),s=this.e.i.P();if(o<0||s===0)return;let a={row:r.rowIndex,colIdx:o},l=this.ku(e,a,i,s);if(!l)return;e.preventDefault();let d=l.row!==a.row||l.colIdx!==a.colIdx;if(e.shiftKey&&this.e.r.enableRangeSelection&&d){t.Gu(l.row,l.colIdx);return}d&&t.Ge(l.row,i[l.colIdx].id)}ku(e,t,r,i){return ji.has(e.key)?this.Pu(e,t,r.length,i):e.key==="Enter"||e.key==="F2"?this.Lu(e,t,r,i):e.key===" "?(this.Nu(t.row),t):e.key==="Tab"?this.Fu(e,t,r):null}Pu(e,t,r,i){let{row:o,colIdx:s}=t;switch(e.key){case"ArrowUp":o=this.Xi(o,this.Ft(o-1,-1),i);break;case"ArrowDown":o=this.Xi(o,this.Ft(o+1,1),i);break;case"ArrowLeft":s=Math.max(0,s-1);break;case"ArrowRight":s=Math.min(r-1,s+1);break;case"Home":s=0,e.ctrlKey&&(o=0);break;case"End":s=r-1,e.ctrlKey&&(o=Math.max(0,this.Ft(i-1,-1)));break;case"PageUp":case"PageDown":o=this.Ou(e.key,o,i);break}return{row:o,colIdx:s}}Xi(e,t,r){return t>=0&&t<r?t:e}Ou(e,t,r){let i=this.e.o.T.center,o=Math.max(1,Math.floor(i.clientHeight/this.e.r.rowHeight)),s=e==="PageUp"?-1:1,a=Math.max(0,Math.min(r-1,t+o*s));return this.Xi(t,this.Ft(a,s),r)}Lu(e,t,r,i){let o=this.e.i.h(t.row),s=r[t.colIdx];if(o&&!o.isDetail&&s&&this.e.l.oe(o,s))return this.e.l.start(t.row,s,e.key==="F2"?e.key:null),t;let a=this.Ft(t.row+1,1);return{...t,row:this.Xi(t.row,a,i)}}Nu(e){let t=this.e.i.h(e);if(!(!t||t.isDetail)){if(t.isGroup){this.e.i.xo(t.id);return}this.e.r.rowSelection!=="none"&&this.e.f.So(t,!t.selected,this.e.r.rowSelection==="single")}}Fu(e,t,r){let i=this.tl(t.row,r[t.colIdx].id,e.shiftKey?-1:1);return i?(this.e.a.Ge(i.rowIndex,i.column.id),this.e.l.start(i.rowIndex,i.column),t):null}};var A=null;function Yi(n){A?.owner&&(n===A.owner||n.contains(A.owner))&&A.close()}function Rs(n){let e=n.target;A?.contains(e)||A?.close()}function qi(){A?.reposition()}function Ss(n){n.key!=="Escape"||!A||(n.preventDefault(),n.stopImmediatePropagation(),A.close(!0))}function Xi(n){V(n,Rs,Ss);let e=n?"addEventListener":"removeEventListener";window[e]("resize",qi),window[e]("scroll",qi,!0)}function Ms(n){A?.close!==n.close&&A?.close(),!A&&(A=n,Xi(!0))}function Is(n){A?.close===n&&(A=null,Xi(!1))}function ae(n,e){return e?`${n} ${e}`:n}function Le(n,e,t){let r=n[e]&&!n[e].disabled,i=r?e+t:t>0?0:n.length-1;for(let o=i;o>=0&&o<n.length;o+=t)if(!n[o].disabled)return o;return r?e:-1}function mt(n,e){return n.findIndex(t=>t.value===e&&!t.disabled)}function re(n){let e=f("div",ae("mach-select-control",n.classNames?.root)),t=f("select",ae("mach-select-native",n.classNames?.native));t.hidden=!0,t.tabIndex=-1,t.setAttribute("aria-hidden","true");let r=f("button",ae("mach-select-trigger",n.classNames?.trigger));r.type="button",r.setAttribute("role","combobox"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-label",n.ariaLabel);let i=f("span",ae("mach-select-value",n.classNames?.value)),o=f("span",ae("mach-select-caret",n.classNames?.caret));o.setAttribute("aria-hidden","true"),r.append(i,o);let s=f("div",ae("mach-select-listbox",n.classNames?.listbox));s.id=ri("mach-select-listbox"),s.setAttribute("role","listbox"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-controls",s.id),e.append(t,r);let a=[...n.options],l=[],d=-1,c=!1,u=()=>n.themeSource??e.closest(".mach-root")??e,h=y=>e.contains(y)||s.contains(y),p=()=>s.classList.contains("mach-select-listbox--open"),m=()=>{let y=a.find(D=>D.value===t.value);i.textContent=y?.label??t.value,l.forEach((D,de)=>{let M=a[de]?.value===t.value;D.setAttribute("aria-selected",M?"true":"false"),D.classList.toggle("mach-select-option--selected",M),D.classList.toggle("mach-select-option--active",de===d)}),r.setAttribute("aria-activedescendant",d>=0?l[d]?.id??"":"")},g=()=>{let y=r.getBoundingClientRect(),D=s.getBoundingClientRect(),de=Math.max(y.width,D.width),M=T(y.left,8,Math.max(8,window.innerWidth-de-8)),be=window.innerHeight-y.bottom-8,ie=be<Math.min(D.height,240)&&y.top>be,L=ie?Math.max(8,y.top-D.height-5):Math.min(window.innerHeight-D.height-8,y.bottom+5);s.style.minWidth=`${y.width}px`,s.style.left=`${M}px`,s.style.top=`${Math.max(8,L)}px`,s.classList.toggle("mach-select-listbox--above",ie)},b=(y=!1)=>p()?(s.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),r.removeAttribute("aria-activedescendant"),s.remove(),Is(b),y&&!c&&r.focus({preventScroll:!0}),!0):!1,C=(y,D=!0)=>{!a[y]||a[y].disabled||(d=y,m(),D&&l[y]?.scrollIntoView?.({block:"nearest"}))},k=()=>{if(c||r.disabled||p())return;let y=u();Ms({owner:y,close:b,contains:h,reposition:g}),d=mt(a,t.value),d<0&&(d=Le(a,-1,1)),I(s,y),document.body.appendChild(s),s.classList.add("mach-select-listbox--open"),s.setAttribute("aria-hidden","false"),r.setAttribute("aria-expanded","true"),g(),m(),l[d]?.scrollIntoView?.({block:"nearest"})},_=y=>{let D=a[y];!D||D.disabled||(t.value=D.value,d=y,m(),b(!0),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))},z=(y,D)=>{a=[...y],t.replaceChildren(),s.replaceChildren(),l=a.map((M,be)=>{let ie=document.createElement("option");ie.value=M.value,ie.textContent=M.label,ie.disabled=M.disabled===!0,t.appendChild(ie);let L=f("button",ae("mach-select-option",n.classNames?.option));return L.id=`${s.id}-option-${be}`,L.type="button",L.tabIndex=-1,L.dataset.value=M.value,L.disabled=M.disabled===!0,L.setAttribute("role","option"),L.textContent=M.label,L.addEventListener("mousedown",qn=>qn.preventDefault()),L.addEventListener("click",()=>_(be)),s.appendChild(L),L});let de=a.find(M=>!M.disabled)?.value??"";t.value=D!=null&&a.some(M=>M.value===D)?D:de,d=mt(a,t.value),m()},Zr=y=>{if(y.key==="Tab"){b();return}if(y.key==="Escape"){if(!b(!0))return;y.preventDefault(),y.stopPropagation();return}if(y.key==="Enter"||y.key===" "){y.preventDefault(),y.stopPropagation(),p()?_(d):k();return}let D=d;if(y.key==="ArrowDown")D=Le(a,d,1);else if(y.key==="ArrowUp")D=Le(a,d,-1);else if(y.key==="Home")D=Le(a,-1,1);else if(y.key==="End")D=Le(a,-1,-1);else return;y.preventDefault(),y.stopPropagation(),p()||k(),C(D)},Qr=()=>{d=mt(a,t.value),m(),n.onChange?.(t.value)};return r.addEventListener("click",()=>{b()||k()}),r.addEventListener("keydown",Zr),t.addEventListener("change",Qr),z(a,n.value),{el:e,native:t,trigger:r,listbox:s,contains:h,isOpen:p,open:k,close:b,focus:()=>r.focus({preventScroll:!0}),getValue:()=>t.value,setValue:y=>{t.value=y,d=mt(a,y),m()},setOptions:z,destroy:()=>{c||(c=!0,b(),r.removeEventListener("keydown",Zr),t.removeEventListener("change",Qr),e.remove())}}}function Ji(n,e){let t=document.createElement("input");return t.type=n,t.className="mach-editor-input",e!=null&&e!==""&&(t.value=n==="date"?String(e).slice(0,10):String(e)),t}function As(n){return n?.options?.length?n.options:(n?.values??[]).map(e=>({label:String(e),value:e}))}function ks(n,e){return e?.options?.length||e?.values?.length?"select":typeof n=="number"?"number":n instanceof Date||typeof n=="string"&&/^\d{4}-\d{2}-\d{2}/.test(n)?"date":"text"}function Rr(n,e,t){let r=n.colDef,i=typeof r.cellEditor=="string"?r.cellEditor:ks(e,r.cellEditorParams);if(i==="date"){let a=Ji("date",e),d=(e==null?"":String(e)).match(/T(\d{2}:\d{2})/);return{el:a,getValue:()=>a.value===""?null:d?`${a.value}T${d[1]}`:a.value,focus:()=>a.focus({preventScroll:!0})}}if(i==="select"){let a=As(r.cellEditorParams),l=re({ariaLabel:r.headerName??r.field??n.id,options:a.map(d=>({value:String(d.value),label:d.label,disabled:d.disabled})),value:String(e??""),classNames:{root:"mach-editor-select-control",native:"mach-editor-select"}});return{el:l.el,getValue:()=>{let d=l.getValue();return a.find(u=>String(u.value)===d)?.value??d},focus:()=>l.focus(),destroy:()=>l.destroy()}}let o=i==="number",s=Ji(o?"number":"text",e);return!o&&t&&t.length===1&&(s.value=t),{el:s,getValue:()=>o?s.value===""?null:Number(s.value):s.value,focus:()=>{s.focus({preventScroll:!0}),s.select()}}}function fe(n){return n!=null&&typeof n.then=="function"}var gt=class{constructor(e){this.e=e;this.Ho=0}Hu(){this.Ho++}Ji(){let e=++this.Ho;return()=>e===this.Ho&&!this.e.s()}Zi(e){let t=e[0].node,r=this.e.n.ee(),i=r.map(a=>this.e.c(t,a)),o=this.jr(e),s=e.every(a=>Object.is(this.e.c(t,a.column),a.oldValue));return()=>s&&o()&&r.every((a,l)=>Object.is(this.e.c(t,a),i[l]))}jr(e){let t=e[0].node,r=t.data,i=this.e.n,o=i.ee(),s=e.every(a=>a.node===t&&i.R(a.column.id)===a.column);return()=>s&&!this.e.s()&&this.e.i.O(t.id)===t&&t.data===r&&i.ee()===o}Vo(e,t){let r=e.map(o=>this.Vu(o,t)),i=o=>{let s=o.filter(a=>a!=null);return s.length||!t()?s:this.Bu(e,t)};return r.some(fe)?Promise.all(r.map(o=>Promise.resolve(o))).then(i):i(r)}Vu(e,t){let{node:r,column:i,oldValue:o,newValue:s}=e,a=d=>(t()&&this.e.reportError(d,"validate",{colId:i.id,rowId:r.id}),{colId:i.id,message:"Validation failed"}),l=d=>typeof d=="string"?{colId:i.id,message:d}:null;try{let d=i.colDef.validate?.(s,{oldValue:o,newValue:s,node:r,data:r.data,column:i,colDef:i.colDef,api:this.e.api});return fe(d)?d.then(l,a):l(d)}catch(d){return a(d)}}Bu(e,t){let r=this.e.r.rowEditValidator;if(!r)return[];let i=e[0].node,o=Object.create(null);for(let l of this.e.n.ee())o[l.id]=this.e.c(i,l);for(let l of e)o[l.column.id]=l.newValue;let s=l=>typeof l=="string"?[{colId:e[0].column.id,message:l}]:l&&typeof l=="object"?Object.entries(l).filter(([,d])=>typeof d=="string"&&d).map(([d,c])=>({colId:d,message:c})):[],a=l=>(t()&&this.e.reportError(l,"validate",{rowId:i.id}),[{colId:e[0].column.id,message:"Row validation failed"}]);try{let l=r({data:i.data,node:i,values:o,api:this.e.api,changes:e.map(({column:d,oldValue:c,newValue:u})=>({colId:d.id,oldValue:c,newValue:u}))});return fe(l)?l.then(s,a):s(l)}catch(l){return a(l)}}Bo(e,t){let r=[],i=this.jr(e);for(let o of e){if(!t()||!i()||!Object.is(this.e.c(o.node,o.column),o.oldValue)||!this.e.l.oe(o.node,o.column)||!this.e.Qi(o.node,o.column,o.newValue,o.oldValue)){for(let s of r.reverse()){if(!t()||!i())break;this.e.Qi(s.node,s.column,s.oldValue,s.newValue)||this.e.reportError(new Error("A valueSetter rejected input rollback"),"inputRollback",{rowId:s.node.id})}return{colId:o.column.id,message:"Value was rejected by the column setter"}}r.push(o)}return t()&&i()?null:{colId:e[0].column.id,message:"Input target changed during commit"}}_u(e){let t=this.Ji();if(this.e.s()||this.e.l.isEditing())return;let r=new Map;for(let a of e){if(a.newValue===void 0||Object.is(a.oldValue,a.newValue)||!this.e.l.oe(a.node,a.column))continue;let l=r.get(a.node)??[];l.push(a),r.set(a.node,l)}let i=[...r.values()].map(a=>{let l=this.Zi(a),d=()=>t()&&l();return{changes:a,current:d,validation:this.Vo(a,d)}}),o=a=>{this.nl(i,a,t)},s=i.map(a=>a.validation);s.some(fe)?Promise.all(s.map(a=>Promise.resolve(a))).then(o):o(s)}nl(e,t,r){let i=e.map(()=>({applied:!1,errors:[]}));if(!r())return i;let o=new Set;this.e.V.ol();try{e.forEach(({changes:s,current:a},l)=>{let d=i[l];if(!a()||!s.length)return;d.errors=[...t[l]];let c=d.errors.length?null:this.Bo(s,r);if(!r())return;if(c&&d.errors.push(c),d.errors.length){this.e.reportError(new Error(d.errors.map(h=>h.message).join("; ")),"validate",{rowId:s[0].node.id,errors:d.errors});return}let u=this.jr(s);d.applied=!0;for(let h of s){if(!r()||!u()){d.applied=!1;break}this.e._o(h.node,h.column,h.oldValue,h.newValue),h.node.rowIndex>=0&&o.add(h.node.rowIndex)}})}finally{this.e.V.sl()}return o.size&&r()&&(this.e.a.I([...o]),this.e.De.refresh(),this.e.at.refresh()),i}};function le(n,e,t,r,i,o){let s=t.colDef.valueParser;if(!s)return r;let a=s({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:r,oldValue:o,source:i});if(a!=null&&typeof a.then=="function")throw new TypeError("valueParser must return a synchronous value");return a}function Ne(n,e,t,r){let i=n.c(e,t),o=t.colDef.valueSerializer;if(o)try{let s=o({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:i,target:r});if(s!=null&&typeof s.then=="function")throw new TypeError("valueSerializer must return a synchronous value");return s}catch(s){throw n.reportError(s,"valueSerializer",{colId:t.id,rowId:e.id}),s}return r==="xlsx"||r==="csv"&&typeof i=="number"?i:K(n,e,t,i)}var Gs='<path d="M3 8.5 6.4 12 13.5 4"/>',Ps='<path d="m4 4 8 8m0-8-8 8"/>';function Zi(n,e){let t=document.createElement("button");return t.type="button",t.className=`mach-edit-control mach-edit-control--${n}`,t.setAttribute("aria-label",e),t.title=e,t.innerHTML=`<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${n==="confirm"?Gs:Ps}</svg>`,t.addEventListener("mousedown",r=>{r.preventDefault(),r.stopPropagation()}),t}var yt=class{constructor(e){this.e=e;this.D=null;this.M=null;this.Pe=null;this.lt=0;this.en=0;this.zu=e=>{if(this.D&&!(e.isComposing||e.keyCode===229)){if(e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.xe(!1);else if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),this.xe(!0);else if(e.key==="Tab"){e.preventDefault(),e.stopPropagation();let t=this.D,r=this.e.Xo.tl(t.node.rowIndex,t.column.id,e.shiftKey?-1:1);r?this.start(r.rowIndex,r.column,null,!0):this.xe(!1)}}}}isEditing(e,t){return this.D?e==null&&t==null?!0:this.D.node.rowIndex===e&&this.D.column.id===t:this.M?e==null&&t==null?!0:this.qr(this.M)!==e?!1:t==null||this.M.drafts.has(t):!1}tn(){return this.D!=null}Mc(){return this.D?.node.rowIndex??(this.M?this.qr(this.M):null)}al(e){return this.M?e==null||this.qr(this.M)===e:!1}oe(e,t){if(e.isDetail||e.isGroup||e.data==null)return!1;let r=t.colDef.editable;if(!r)return!1;if(typeof r=="function")try{return r({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.c(e,t),rowIndex:e.rowIndex})}catch(i){return this.e.reportError(i,"editable",{colId:t.id,rowId:e.id}),!1}return!0}start(e,t,r,i=!1){if(this.en++,this.e.s())return!1;let o=this.e.i.h(e);if(!o||o.data==null)return!1;if(this.e.r.editType==="fullRow")return this.startRow(e,t.id);if(this.M)return!1;if(this.D)return!this.Pe&&this.D.node===o&&this.D.column===t||this.ll(o,t).then(m=>{m&&this.start(o.rowIndex,t,r,i)}),!0;if(!this.oe(o,t))return!1;i&&(this.e.a.Ui(e,"nearest"),this.e.a.Ge(e,t.id));let s=this.e.a.rn(e,t.id);if(!s)return!1;this.e.$e();let a=this.e.c(o,t),l=this.dl(o,t,e,a,r);if(!l)return!1;let d=f("div","mach-cell-editor-controls"),c=Zi("confirm","Confirm edit"),u=Zi("cancel","Cancel edit");d.append(c,u);let h=this.cl(l,s,d),p=this.zu;return l.el.addEventListener("keydown",p),c.addEventListener("click",m=>{m.stopPropagation(),this.xe(!1)}),u.addEventListener("click",m=>{m.stopPropagation(),this.xe(!0)}),this.D={node:o,column:t,editor:l,oldValue:a,cell:s,shell:h,keydown:p,confirmButton:c,cancelButton:u},this.zo(l,t,o),this.e.emit("cellEditingStarted",{rowIndex:e,colId:t.id,rowNode:o}),!0}ll(e,t){let r=++this.en;return this.xe(!1).then(i=>i&&r===this.en&&!this.isEditing()&&this.e.i.h(e.rowIndex)===e&&(t==null||this.e.n.R(t.id)===t))}startRow(e,t){if(this.D||this.M)return!1;let r=this.e.i.h(e);if(!r||r.data==null||r.isDetail||r.isGroup)return!1;this.e.$e();let i=new Map;for(let l of this.e.n.d()){if(!this.oe(r,l))continue;let d=this.e.c(r,l);i.set(l.id,{column:l,oldValue:d,value:d,mounted:null})}if(i.size===0)return!1;let o={node:r,rowIndex:e,drafts:i,validating:!1};if(this.M=o,this.e.a.I([e]),i.size===0)return this.M=null,this.e.a.I([e]),!1;let s=i.values().next().value,a=(t?i.get(t):void 0)??s;return a?.mounted&&this.zo(a.mounted.editor,a.column,r),this.e.emit("rowEditingStarted",{rowIndex:e,rowNode:r,data:r.data}),!0}ul(e,t,r,i){if(this.D)return this.D.node===t&&this.D.column.id===r.id;let o=this.M;if(!o||o.node!==t)return!1;let s=o.drafts.get(r.id);return s?s.mounted?.cell!==i&&(this.hl(s),!this.Wu(e,o,s,i))?(o.drafts.delete(r.id),!1):!0:!1}Wo(e,t,r){let i=this.M;if(i&&this.qr(i)===e){let o=i.drafts.get(t);o?.mounted?.cell===r&&this.hl(o);return}if(this.D?.cell===r){let o=this.D;this.xe(!1),this.D===o&&this.xe(!0)}}stop(e=!1){this.xe(e)}xe(e=!1){if(e&&this.en++,this.M)return this.$o(e);let t=this.D;if(!t)return Promise.resolve(!1);if(e)return this.lt++,this.Pe=null,Promise.resolve(this.Yr(t,!0,t.oldValue));if(this.Pe)return this.Pe;let r,i="cellEditor.getValue";try{if(r=t.editor.getValue(),Object.is(r,t.oldValue)||(i="valueParser",r=le(this.e,t.node,t.column,r,"editor",t.oldValue)),i="cellEditor.isCancelAfterEnd",t.editor.isCancelAfterEnd?.(r))return Promise.resolve(this.Yr(t,!0,t.oldValue))}catch(c){return this.e.reportError(c,i,{colId:t.column.id,rowId:t.node.id}),i!=="valueParser"?Promise.resolve(this.Yr(t,!0,t.oldValue)):(this.Xr(t.editor,c instanceof Error?c.message:String(c)),Promise.resolve(!1))}let o=[{node:t.node,column:t.column,oldValue:t.oldValue,newValue:r}],s=this.e._.Zi(o),a=++this.lt,l=()=>a===this.lt&&this.D===t&&s(),d=c=>l()?c.length?(this.Ko(t,!1),this.Xr(t.editor,c[0].message),!1):this.Yr(t,!1,r):(a===this.lt&&this.D===t&&this.Yr(t,!0,t.oldValue),!1);return this.pl(o,l,d,()=>this.Ko(t,!0))}$o(e=!1){let t=this.M;if(!t)return Promise.resolve(!1);if(e)return this.lt++,this.Pe=null,Promise.resolve(this.nn(t,!0));if(this.Pe)return this.Pe;for(let c of t.drafts.values())this.Uo(c);let r=[];for(let c of t.drafts.values())if(!Object.is(c.oldValue,c.value))try{let u=le(this.e,t.node,c.column,c.value,"editor",c.oldValue);u!==void 0&&!Object.is(c.oldValue,u)&&r.push({node:t.node,column:c.column,oldValue:c.oldValue,newValue:u})}catch(u){return this.e.reportError(u,"valueParser",{colId:c.column.id,rowId:t.node.id}),this.jo(t,[{draft:c,message:u instanceof Error?u.message:String(u)}]),Promise.resolve(!1)}if(r.length===0)return Promise.resolve(this.nn(t,!1,r));let i=r.map(c=>t.drafts.get(c.column.id)),o=i.map(c=>c.value),s=this.e._.Zi(r),a=++this.lt,l=()=>a===this.lt&&this.M===t&&s();for(let c of i)c.error=void 0;let d=c=>l()?c.length?(this.jo(t,c.map(({colId:u,message:h})=>({draft:t.drafts.get(u)??i[0],message:h}))),!1):i.some((u,h)=>!Object.is(u.value,o[h]))?(t.validating=!1,this.qo(t,!1),!1):this.nn(t,!1,r):(a===this.lt&&this.M===t&&this.nn(t,!0),!1);return this.pl(r,l,d,()=>{t.validating=!0,this.qo(t,!0)})}pl(e,t,r,i){let o=this.e._.Vo(e,t);if(!fe(o))return Promise.resolve(r(o));i();let s=o.then(r).finally(()=>{this.Pe===s&&(this.Pe=null)});return this.Pe=s,s}Yr(e,t,r){if(this.D!==e)return!1;let i={node:e.node,column:e.column,oldValue:e.oldValue,newValue:r},o=!t&&r!==void 0&&!Object.is(e.oldValue,r);if(o){let s=this.e._.Bo([i],()=>!this.e.s());if(s)return this.Ko(e,!1),this.Xr(e.editor,s.message),!1}return this.D=null,o&&this.e._o(e.node,e.column,e.oldValue,r),this.Yo(e),this.e.s()||(this.e.emit("cellEditingStopped",{rowIndex:e.node.rowIndex,colId:e.column.id,rowNode:e.node,oldValue:e.oldValue,newValue:o?r:e.oldValue}),this.fl(e.node.rowIndex)),!0}nn(e,t,r=[]){if(this.M!==e)return!1;let i=t?[]:this.$u(e,r);if(i==null)return!1;for(let s of e.drafts.values())s.mounted&&this.Yo(s.mounted),s.mounted=null;if(this.M=null,this.e.s())return!0;let o=this.qr(e);return this.e.emit("rowEditingStopped",{rowIndex:o,rowNode:e.node,data:e.node.data,cancelled:t,changes:i}),this.fl(o),!0}fl(e){e>=0&&this.e.a.I([e]),this.e.De.refresh(),this.e.at.refresh()}$u(e,t){if(t.length===0)return[];let r=this.e._.Bo(t,()=>!this.e.s());if(r)return this.jo(e,[{draft:e.drafts.get(r.colId)??e.drafts.get(t[0].column.id),message:r.message}]),null;let i=this.e._.jr(t);this.e.V.ol();try{for(let o of t){if(!i())break;this.e._o(e.node,o.column,o.oldValue,o.newValue)}}finally{this.e.V.sl()}return t.map(({column:o,oldValue:s,newValue:a})=>({colId:o.id,oldValue:s,newValue:a}))}Wu(e,t,r,i){let o=this.dl(t.node,r.column,e,r.value,null);if(!o)return!1;this.cl(o,i);let s=l=>this.Ku(l,t,r),a=()=>{try{r.value=o.getValue(),r.error=void 0}catch{}};return o.el.addEventListener("keydown",s),o.el.addEventListener("input",a),r.mounted={editor:o,cell:i,keydown:s,input:a},r.error&&this.Xr(o,r.error),t.validating&&this.Jr(o.el,!0),!0}cl(e,t,r){G(this.e,t);let i=f("div",r?"mach-cell-editor-shell":"mach-row-editor-shell");return i.appendChild(e.el),r&&i.appendChild(r),t.replaceChildren(i),t.classList.add("mach-cell--editing"),r||t.classList.add("mach-cell--row-editing"),t.removeAttribute("title"),i}hl(e){e.mounted&&(this.Uo(e),this.Yo(e.mounted),e.mounted=null)}Uo(e){if(e.mounted)try{let t=e.mounted.editor.getValue();t!==void 0&&(e.value=t)}catch(t){this.e.reportError(t,"cellEditor.getValue",{colId:e.column.id,rowId:this.M?.node.id})}}dl(e,t,r,i,o){let s=t.colDef,a;try{let l={api:this.e.api,colDef:s,column:t,node:e,data:e.data,value:i,rowIndex:r,keyPress:o};typeof s.cellEditor=="function"?a=s.cellEditor(l):typeof s.cellEditor=="string"&&!["text","number","date","select"].includes(s.cellEditor)?a=this.e.Uu(s.cellEditor)?.(l)??Rr(t,i,o):a=Rr(t,i,o)}catch(l){return this.e.reportError(l,"cellEditor",{colId:t.id,rowId:e.id}),null}if(!a||!(a.el instanceof HTMLElement))return this.e.reportError(new Error("cellEditor must return an editor with an HTMLElement el"),"cellEditor",{colId:t.id,rowId:e.id}),null;try{if(a.isCancelBeforeStart?.())return a.destroy?.(),null}catch(l){this.e.reportError(l,"cellEditor.isCancelBeforeStart",{colId:t.id,rowId:e.id});try{a.destroy?.()}catch{}return null}return a}jo(e,t){e.validating=!1,this.qo(e,!1);for(let{draft:r,message:i}of t)r.error=i,r.mounted&&this.Xr(r.mounted.editor,i);t[0].draft.mounted?.editor.focus?.()}Xr(e,t){let r=e.el;r.classList.add("mach-editor-invalid"),r.setAttribute("title",t),r.setAttribute("aria-invalid","true"),this.Jr(r,!1),(r.querySelector(".mach-select-trigger, input:not([type='hidden']), select:not([hidden]), textarea")??r).focus?.();let o=()=>{r.classList.remove("mach-editor-invalid"),r.removeAttribute("title"),r.removeAttribute("aria-invalid")};r.addEventListener("input",o,{once:!0})}Ko(e,t){this.Jr(e.editor.el,t),e.confirmButton.disabled=t,e.cancelButton.disabled=!1,e.shell.classList.toggle("mach-editor-shell--busy",t)}qo(e,t){for(let r of e.drafts.values()){let i=r.mounted?.editor.el;i&&this.Jr(i,t)}}Jr(e,t){e.classList.toggle("mach-editor-validating",t),t?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"),e.inert=t}zo(e,t,r){try{e.focus?.()}catch(i){this.e.reportError(i,"cellEditor.focus",{colId:t.id,rowId:r.id})}}Yo(e){e.editor.el.removeEventListener("keydown",e.keydown),e.input&&e.editor.el.removeEventListener("input",e.input),this.Jr(e.editor.el,!1);try{e.editor.destroy?.()}catch(t){this.e.reportError(t,"cellEditor.destroy",{colId:e.cell.dataset.colId})}e.cell.classList.remove("mach-cell--editing","mach-cell--row-editing","mach-cell--error")}qr(e){return e.node.rowIndex>=0?e.node.rowIndex:e.rowIndex}Ku(e,t,r){if(this.M!==t)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.$o(!0);return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),this.$o(!1);return}if(e.key!=="Tab")return;e.preventDefault(),e.stopPropagation(),this.Uo(r);let i=[...t.drafts.values()],o=i.indexOf(r),s=e.shiftKey?-1:1;for(let a=1;a<=i.length;a++){let l=i[(o+s*a+i.length)%i.length];if(l.mounted){this.zo(l.mounted.editor,l.column,t.node);break}}}destroy(){this.xe(!0)}};function Sr(n){return n==="blank"||n==="notBlank"}function vt(n){return n===null?"null:":`${typeof n}:${String(n)}`}var bt=class{constructor(e){this.e=e;this.w=null;this.dt=null;this.dr=null;this.ct=e=>{if(!this.w)return;let t=e.target;if(!this.dr?.contains(t)){if(!this.w.contains(t)){this.close();return}(!(t instanceof Element)||!t.closest(".mach-filter-select-control"))&&this.dr?.close()}};this.ut=e=>{if(e.key==="Escape"){if(this.dr?.close(!0)){e.preventDefault(),e.stopPropagation();return}this.close()}}}toggle(e,t){if(this.dt===e.id){this.close();return}this.close(),this.open(e,t)}open(e,t){let r=this.e.i.We()[e.id]??null,i=r?.type??e.filterType,o=f("div","mach-filter-panel");o.setAttribute("role","dialog"),o.setAttribute("aria-label",`${e.id} filter`);let s=c=>{this.e.ju(e,c),this.close()},a=i==="set"?this.qu(o,e,r):this.Yu(o,i,r,s),l=f("div","mach-filter-footer");l.append(Y("mach-filter-btn-reset",this.e.v("reset"),()=>s(null)),Y("mach-filter-btn-apply",this.e.v("apply"),()=>s(a()))),o.appendChild(l),I(o,this.e.o.root),document.body.appendChild(o),this.w=o,this.dt=e.id,X(o,t),V(!0,this.ct,this.ut),o.querySelector(".mach-filter-select-trigger, input")?.focus()}close(){this.w&&(this.dr?.destroy(),this.dr=null,this.w.remove(),this.w=null,this.dt=null,V(!1,this.ct,this.ut))}destroy(){this.close()}Yu(e,t,r,i){let o=r&&r.type!=="set"&&r.conditions.length>0?r.conditions[0]:null,s=o?.match??(t==="text"?"contains":"equals"),{el:a,native:l}=this.Xu(t,s),d=this.ml(t),c=this.ml(t,!0);this.Ju(t,s,o,d,c),this.gl(s,d,c),l.addEventListener("change",()=>{this.gl(l.value,d,c)});let u=f("div","mach-filter-body");u.append(a,d,c),e.appendChild(u);let h=()=>this.Zu(t,l.value,d.value,c.value),p=m=>{m.key==="Enter"&&i(h())};return d.addEventListener("keydown",p),c.addEventListener("keydown",p),h}Xu(e,t){let r=re({ariaLabel:"Filter condition",options:ue[e].map(i=>({value:i,label:this.e.v(nr(i))})),value:t,classNames:{root:"mach-filter-select-control",native:"mach-filter-select",trigger:"mach-filter-select-trigger",value:"mach-filter-select-value",caret:"mach-filter-select-caret",listbox:"mach-filter-listbox",option:"mach-filter-listbox-option"},themeSource:this.e.o.root});return this.dr=r,r}ml(e,t=!1){let i=f("input",`mach-filter-input${t?" mach-filter-input--second":""}`);return i.type=e,i}Ju(e,t,r,i,o){r?.value!=null&&!Sr(t)&&(i.value=e==="date"?String(r.value).slice(0,10):String(r.value)),r&&"value2"in r&&r.value2!=null&&(o.value=e==="date"?String(r.value2).slice(0,10):String(r.value2))}gl(e,t,r){t.style.display=Sr(e)?"none":"",r.style.display=e==="inRange"?"":"none"}qu(e,t,r){let o=t.colDef.filterParams,s;if(o?.values)s=o.values;else{let p=new Set;s=[];let m=this.e.i.Ve(),g=Math.min(m.length,o?.maxValues??500);for(let b=0;b<g;b++){let C=this.e.c(m[b],t),k=vt(C??null);p.has(k)||(p.add(k),s.push(C))}}let a=new Set((r?.type==="set"?r.values:s).map(vt)),l=f("input","mach-filter-input mach-filter-input--search");l.type="text",l.placeholder=this.e.v("search");let d=f("div","mach-filter-set-list"),c=new Map(s.map(p=>[vt(p),p??null])),u=p=>{d.textContent="";let m=p.trim().toLowerCase();for(let g of s){let b=g==null?this.e.v("emptySetLabel"):String(g);if(m&&!b.toLowerCase().includes(m))continue;let C=vt(g),k=f("label","mach-filter-set-item"),_=document.createElement("input");_.type="checkbox",_.checked=a.has(C),_.addEventListener("change",()=>{_.checked?a.add(C):a.delete(C)});let z=f("span");z.textContent=b,k.append(_,z),d.appendChild(k)}};l.addEventListener("input",()=>u(l.value)),u("");let h=f("div","mach-filter-body mach-filter-body--set");return h.append(l,d),e.appendChild(h),()=>{let p=[];for(let[m,g]of c)a.has(m)&&p.push(g);return p.length&&p.length<c.size?{type:"set",values:p}:null}}Zu(e,t,r,i){if(Sr(t))return{type:e,conditions:[{match:t}]};if(r===""&&t!=="inRange")return null;let o=e==="number",s=o?Number(r):r;if(Number.isNaN(s))return null;if(e==="text"||t!=="inRange")return{type:e,conditions:[{match:t,value:s}]};let a=i?o?Number(i):i:s;return Number.isNaN(a)?null:{type:e,conditions:[{match:t,value:s,value2:a}]}}};var wt=class{constructor(e){this.e=e;this.w=null;this.dt=null;this.sn=null;this.an="";this.Zr=new Set;this.ct=e=>{let t=e.target;this.w&&!this.w.contains(t)&&!this.eh(t)&&this.close()};this.ut=e=>{if(e.key==="Escape"){for(let t of this.Zr)if(t.close(!0)){e.preventDefault(),e.stopImmediatePropagation();return}this.close()}}}toggle(e,t){let r=this.dt===e.id;this.close(),r||this.open(e,t)}Qu(e){this.close();let t=e??(()=>{let i=this.e.o.root.getBoundingClientRect(),o=document.createElement("div");return o.style.position="fixed",o.style.left=`${i.right-16}px`,o.style.top=`${i.top+this.e.r.headerHeight}px`,o.style.width="1px",o.style.height="1px",document.body.appendChild(o),this.sn=o,o})();this.open(null,t)}close(){this.yl(),this.sn&&(this.sn.remove(),this.sn=null),this.w?.remove(),this.w=null,this.dt=null,V(!1,this.ct,this.ut)}destroy(){this.close()}open(e,t){let r=this.e.api,i=f("div","mach-filter-panel mach-column-panel");i.setAttribute("role",e?"menu":"dialog"),e||(i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",this.e.v("columnSettings")));let o=f("div","mach-column-panel-title");o.textContent=e?e.colDef.headerName??e.colDef.field??e.id:this.e.v("columnSettings"),i.appendChild(o);let s=(u,h,p="mach-column-panel-btn")=>Y(p,this.e.v(u),()=>{h(),this.close()});if(e){let u=e.id,h=(...p)=>{let m=f("div","mach-column-panel-actions");m.append(...p),i.appendChild(m)};e.sortable&&h(s("sortAsc",()=>r.sorting.setModel([{colId:u,direction:"asc"}])),s("sortDesc",()=>r.sorting.setModel([{colId:u,direction:"desc"}])),s("clearSort",()=>r.sorting.setModel([]))),h(s("pinLeft",()=>r.columns.setPinned(u,"left")),s("pinRight",()=>r.columns.setPinned(u,"right")),s("clearPin",()=>r.columns.setPinned(u,null))),h(s("autoSize",()=>r.columns.autoSize(u)),s("hideColumn",()=>r.columns.setVisible(u,!1)))}let a=f("div","mach-column-panel-divider");i.appendChild(a);let l=f("div","mach-column-panel-subtitle");if(l.textContent=this.e.v("columnVisibility"),i.appendChild(l),!e){let u=document.createElement("input");u.type="search",u.className="mach-column-workbench-search",u.placeholder=this.e.v("search"),u.setAttribute("aria-label",this.e.v("search")),u.value=this.an,u.addEventListener("input",()=>{this.an=u.value.trim().toLocaleLowerCase(),this.Jo(d,!0)}),i.appendChild(u)}let d=f("div","mach-column-panel-list");this.Jo(d,!e),i.appendChild(d);let c=f("div","mach-filter-footer");c.append(s("resetAll",()=>r.columns.resetState(),"mach-filter-btn-reset"),s("autoSizeAll",()=>r.columns.autoSizeAll(),"mach-filter-btn-apply")),i.appendChild(c),I(i,this.e.o.root),document.body.appendChild(i),this.w=i,this.dt=e?e.id:"__standalone__",X(i,t),V(!0,this.ct,this.ut)}Zo(){if(!this.w)return;let e=this.w.querySelector(".mach-column-panel-list");e&&this.Jo(e,this.dt==="__standalone__")}Jo(e,t){let r=this.e.api;this.yl(e),e.replaceChildren();let i=this.e.n.ee().filter(o=>o.isDetailToggle?!1:!t||!this.an?!0:`${o.colDef.headerName??o.colDef.field??o.id} ${o.id}`.toLocaleLowerCase().includes(this.an));for(let o of i){let s=f("div",t?"mach-column-workbench-item":"mach-filter-set-item"),a=f("label","mach-column-workbench-label"),l=document.createElement("input");l.type="checkbox",l.checked=!o.hide,l.disabled=o.hasCheckbox,l.addEventListener("change",()=>{r.columns.setVisible(o.id,l.checked),this.Zo()});let d=f("span","mach-column-workbench-name");if(d.textContent=o.colDef.headerName??o.colDef.field??o.id,d.title=`${d.textContent} (${o.id})`,a.append(l,d),s.appendChild(a),t){let c=re({ariaLabel:`${d.textContent} ${this.e.v("clearPin")}`,options:[{value:"",label:this.e.v("clearPin")},{value:"left",label:this.e.v("pinLeft")},{value:"right",label:this.e.v("pinRight")}],value:o.pinned??"",classNames:{root:"mach-column-workbench-pin-control",native:"mach-column-workbench-pin"},themeSource:this.e.o.root,onChange:m=>{r.columns.setPinned(o.id,m==="left"||m==="right"?m:null),this.Zo()}});c.trigger.disabled=!o.movable,c.native.disabled=!o.movable,this.Zr.add(c),s.appendChild(c.el);let u=this.e.n.ee().filter(m=>!m.hide&&m.parentGroup===o.parentGroup&&(o.parentGroup!=null||m.pinned===o.pinned)),h=u.indexOf(o),p=(m,g,b)=>{let C=Y("mach-column-workbench-move",m,()=>{r.columns.move(o.id,g),this.Zo()});return C.disabled=b||o.hide||!o.movable,C};s.append(p("\u2191",h-1,h<=0),p("\u2193",h+1,h<0||h>=u.length-1))}e.appendChild(s)}}eh(e){for(let t of this.Zr)if(t.contains(e))return!0;return!1}yl(e){for(let t of this.Zr)e&&!e.contains(t.el)||(t.destroy(),this.Zr.delete(t))}};var Ct=class{constructor(e){this.e=e;this.w=null;this.ct=e=>{this.w&&!this.w.contains(e.target)&&this.close()};this.ut=e=>{e.key==="Escape"&&this.close()}}th(e){if(e){let o=this.e.i.h(e.rowIndex),s=this.e.n.R(e.colId);return o&&s?{node:o,column:s}:null}let t=this.e.a.ar();if(!t)return null;let r=this.e.i.h(t.r1),i=this.e.n.d()[t.c1];return r&&i?{node:r,column:i}:null}rh(e,t){let r=this.e.r.getContextMenuItems;if(!r)return null;try{return r({data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.c(e,t),rowIndex:e.rowIndex})??null}catch(i){return this.e.reportError(i,"getContextMenuItems",{colId:t.id,rowId:e.id}),null}}ih(e,t,r,i){let o=!1;for(let s of t){if(s.separator){e.appendChild(f("div","mach-context-menu-separator"));continue}let a=f("button","mach-context-menu-item");a.type="button",a.textContent=s.label??"",s.danger&&a.classList.add("mach-context-menu-item--danger"),a.disabled=s.disabled===!0,a.disabled||(o=!0,a.addEventListener("click",()=>this.nh(s,r,i))),e.appendChild(a)}return o}nh(e,t,r){this.close();try{e.action?.()}catch(i){this.e.reportError(i,"contextMenu.action",{colId:r.id,rowId:t.id})}}oh(e){let t=this.e,r=(i,o)=>{e.append(Y("mach-context-menu-item",t.v(i),()=>{o(),this.close()}))};t.r.suppressClipboard||(r("menuCopy",()=>{t.vl()}),r("menuPaste",()=>{t.sh()})),r("menuClearContents",()=>{let i=t.a.ar();i&&t.Fo(i)})}open(e,t,r){this.close();let i=this.th(r);if(!i)return;let o=f("div","mach-context-menu");if(o.setAttribute("role","menu"),this.e.r.getContextMenuItems){let s=this.rh(i.node,i.column);if(!s||!this.ih(o,s,i.node,i.column))return;this.bl(o,e,t);return}this.oh(o),this.bl(o,e,t)}bl(e,t,r){I(e,this.e.o.root),document.body.appendChild(e),this.w=e;let i=e.getBoundingClientRect(),o=T(t,8,Math.max(8,window.innerWidth-i.width-8)),s=T(r,8,Math.max(8,window.innerHeight-i.height-8));e.style.left=`${o}px`,e.style.top=`${s}px`,V(!0,this.ct,this.ut)}close(){this.w&&(this.w.remove(),this.w=null,V(!1,this.ct,this.ut))}destroy(){this.close()}};var Tt=class{constructor(e){this.e=e;this.w=null;this.ln=0;this.dn=null;this.cn=e=>{if(this.e.s()||!this.e.r.tooltipComponent)return;let r=e.target.closest(".mach-cell");if(!r||r===this.dn)return;this.Cl(),this.Qo(),this.dn=r;let i=this.ah(r);if(!i||r.classList.contains("mach-cell--editing"))return;let o=this.lh(i.node,i.column,i.index);this.dh(o,i.column)&&(this.ln=window.setTimeout(()=>{this.e.s()||this.dn!==r||this.ch(r,o)},Math.max(0,this.e.r.tooltipShowDelay)))};this.wl=()=>{this.hide()}}init(){S(this.e.o.Le,!0,{mouseover:this.cn,mouseleave:this.wl})}destroy(){this.hide(),S(this.e.o.Le,!1,{mouseover:this.cn,mouseleave:this.wl})}hide(){this.Cl(),this.Qo(),this.dn=null}Cl(){this.ln&&(clearTimeout(this.ln),this.ln=0)}Qo(){this.w?.remove(),this.w=null}ah(e){let t=e.dataset.colId??"",r=Number(e.closest(".mach-row")?.dataset.index);if(Number.isNaN(r))return null;let i=this.e.i.h(r),o=t?this.e.n.R(t):void 0;return!i||!o||i.isDetail||i.isGroup?null:{node:i,column:o,index:r}}lh(e,t,r){return{data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.c(e,t),formatted:ce(this.e,e,t),rowIndex:r}}dh(e,t){let r=t.colDef.tooltipValueGetter;if(!r)return!!e.formatted;try{r({...e,colDef:t.colDef,column:t})}catch(i){this.e.reportError(i,"tooltipValueGetter",{colId:t.id,rowId:e.node.id})}return!0}ch(e,t){this.Qo();let r=this.e.r.tooltipComponent;if(!r)return;let i=f("div","mach-tooltip");i.setAttribute("role","tooltip");let o;try{o=r(t)}catch(s){this.e.reportError(s,"tooltipComponent",{colId:t.colId,rowIndex:t.rowIndex});return}typeof o=="string"?i.textContent=o:i.appendChild(o),I(i,this.e.o.root),document.body.appendChild(i),this.w=i,X(i,e,6)}};var Dt=class{constructor(e){this.e=e;this.X=null}init(){this.X=document.createElement("div"),this.X.className="mach-watermark",this.X.setAttribute("aria-hidden","true"),this.X.style.pointerEvents="none",this.e.o.root.appendChild(this.X),this.apply()}apply(){if(!this.X||this.e.s())return;let e=this.e.r.watermarkEnabled?this.e.r.watermarkConfig:null;if(!e||!e.text){this.X.style.display="none",this.X.style.backgroundImage="";return}let t=this.uh(e);this.X.style.display="",t?(this.X.style.backgroundImage=`url(${t})`,this.X.style.backgroundColor=""):this.X.style.backgroundImage=""}uh(e){try{let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return null;let i=e.fontSize??14,o=e.gap??160,s=e.angle??-22,a=e.color??(this.hh()?"rgba(255,255,255,0.9)":"rgba(31,55,88,0.9)"),l=e.opacity??.06;r.font=`500 ${i}px sans-serif`;let d=r.measureText(e.text),c=Math.ceil(d.width),u=Math.max(o,c+40);t.width=u,t.height=u;let h=t.getContext("2d");return h.clearRect(0,0,u,u),h.globalAlpha=l,h.fillStyle=a,h.font=`500 ${i}px sans-serif`,h.translate(u/2,u/2),h.rotate(s*Math.PI/180),h.textAlign="center",h.textBaseline="middle",h.fillText(e.text,0,0),t.toDataURL("image/png")}catch{return null}}hh(){return this.e.o.root.classList.contains("mach-theme-dark")}refresh(){this.apply()}destroy(){this.X?.remove(),this.X=null}};var xt=class{constructor(e){this.e=e;this.H=[];this.J=-1;this.de=null}ol(){this.de===null&&(this.de=[])}sl(){let e=this.de;this.de=null,e&&e.length>0&&this.push(e)}es(e){if(this.de!==!1){if(this.de){this.de.push(e);return}this.push([e])}}push(e){let t=Math.max(0,this.e.r.undoStackSize);if(t!==0){for(this.H.length=this.J+1,this.H.push(e);this.H.length>t;)this.H.shift();this.J=this.H.length-1}}ph(){let e=Math.max(0,this.e.r.undoStackSize);if(e===0){this.clear();return}for(;this.H.length>e;)this.H.shift(),this.J--;this.J<-1&&(this.J=-1)}canUndo(){return this.J>=0}canRedo(){return this.J<this.H.length-1}undo(){if(this.e.$e(),!this.canUndo())return!1;let e=this.H[this.J];return this.J--,this.apply(e,!1),!0}redo(){return this.e.$e(),this.canRedo()?(this.J++,this.apply(this.H[this.J],!0),!0):!1}apply(e,t){let r=this.e,i=[],o=this.H;for(let s of e){if(o!==this.H&&(o=this.H,!o.includes(e)))break;let a=r.i.O(s.nodeId),l=r.n.R(s.columnId);if(!a||!l||a.data==null)continue;let d=t?s.newValue:s.oldValue,c=t?s.oldValue:s.newValue;!l.colDef.valueGetter&&!l.colDef.valueSetter&&!Object.is(r.c(a,l),c)||r.Qi(a,l,d,c)&&(r.a.Ki(a),r.a.Tl([a.rowIndex],[l.id]),a.rowIndex>=0&&i.push(a.rowIndex),r.emit("cellValueChanged",{oldValue:c,newValue:d,rowNode:a,rowIndex:a.rowIndex,column:l,colDef:l.colDef,data:a.data}))}i.length>0&&r.a.I(i),r.De.refresh(),r.at.refresh()}Gc(e){if(e.length===0||!this.H.length&&!this.de)return;let t=new Set(e),r=o=>o.some(s=>t.has(s.nodeId)),i=this.J;this.H=this.H.filter((o,s)=>r(o)?(s<=i&&this.J--,!1):!0),this.de&&r(this.de)&&(this.de=!1)}clear(){this.H=[],this.J=-1,this.de=null}};var Et=class{constructor(e){this.e=e;this.z=new Map;this.ts=!1;this.rs=null}init(){this.rs=this.e.ce.on("cellValueChanged",e=>{this.ts||this.es(e)})}es(e){let t=`${e.rowNode.id}\0${e.column.id}`,r=this.z.get(t),i=r?r.originalValue:e.oldValue;Object.is(e.newValue,i)?this.z.delete(t):this.z.set(t,{rowId:e.rowNode.id,colId:e.column.id,originalValue:i,value:e.newValue}),this.Qr()}getDirtyRowIds(){let e=new Set;for(let{rowId:t}of this.z.values())e.add(t);return[...e]}getChanges(){let e=new Map;for(let t of this.z.values()){let r=this.e.i.O(t.rowId);if(!r?.data)continue;let i=e.get(t.rowId);i||(i={rowId:t.rowId,data:r.data,cells:[]},e.set(t.rowId,i)),i.cells.push({colId:t.colId,originalValue:t.originalValue,value:t.value})}return[...e.values()]}markSaved(e){if(!e)this.z.clear();else{let t=new Set(e);for(let[r,i]of this.z)t.has(i.rowId)&&this.z.delete(r)}this.Qr()}fh(e){for(let t of e)for(let r of t.cells){let i=`${t.rowId}\0${r.colId}`,o=this.z.get(i);if(o){Object.is(o.value,r.value)?this.z.delete(i):o.originalValue=r.value;continue}let s=this.e.i.O(t.rowId),a=this.e.n.R(r.colId);if(!s||!a||s.data==null)continue;let l=this.e.c(s,a);Object.is(l,r.value)||this.z.set(i,{rowId:t.rowId,colId:r.colId,originalValue:r.value,value:l})}this.Qr()}rollback(e){let t=e?new Set(e):null,r=[...this.z.entries()].filter(([,s])=>!t||t.has(s.rowId));if(r.length===0)return!1;let i=new Set,o=new Set;this.ts=!0;try{for(let[s,a]of r){let l=this.e.i.O(a.rowId),d=this.e.n.R(a.colId);if(!l||!d||l.data==null)continue;let c=this.e.c(l,d);if(Object.is(c,a.originalValue)){o.add(s);continue}this.e.Qi(l,d,a.originalValue,c)&&(o.add(s),this.e.a.Ki(l),l.rowIndex>=0&&i.add(l.rowIndex),this.e.emit("cellValueChanged",{oldValue:c,newValue:a.originalValue,rowNode:l,rowIndex:l.rowIndex,column:d,colDef:d.colDef,data:l.data}))}}finally{this.ts=!1}for(let s of o)this.z.delete(s);return i.size>0&&this.e.a.I([...i]),this.e.De.refresh(),this.e.at.refresh(),this.Qr(),o.size>0}Lc(e){e.length>0&&this.markSaved(e)}clear(){this.z.size!==0&&(this.z.clear(),this.Qr())}destroy(){this.rs?.(),this.rs=null,this.z.clear()}Qr(){this.e.emit("dirtyStateChanged",{dirtyRowIds:this.getDirtyRowIds()})}};var Ir=class{constructor(){this.ei=null;this.un=0;this.Dl=0;this.xl=0}acquire(){this.un++,this.mh();let e=!1;return()=>{e||(e=!0,this.un=Math.max(0,this.un-1),this.un===0&&this.disconnect())}}snapshot(){return{count:this.Dl,totalMs:this.xl}}mh(){if(!(this.ei||typeof PerformanceObserver>"u"))try{this.ei=new PerformanceObserver(e=>{for(let t of e.getEntries())this.Dl++,this.xl+=t.duration}),this.ei.observe({entryTypes:["longtask"]})}catch{this.disconnect()}}disconnect(){let e=this.ei;this.ei=null;try{e?.disconnect()}catch{}}},Rt=new Ir;function Mr(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var St=class{constructor(){this.Ot=[];this.hn=[];this.pn=[];this.ns=Rt.acquire(),this.fn=Rt.snapshot()}start(){return Mr()}gh(e,t,r){this.Ot.push({duration:Math.max(0,Mr()-e),rows:t,columns:r}),this.Ot.length>120&&this.Ot.shift()}yh(e){this.El(this.hn,e)}Na(e){this.El(this.pn,e)}snapshot(){let e=this.Ot.map(o=>o.duration),t=this.Ot[this.Ot.length-1],r=[...e].sort((o,s)=>o-s),i=Rt.snapshot();return{sampleCount:e.length,lastRenderMs:t?.duration??0,averageRenderMs:this.vh(e),maxRenderMs:r[r.length-1]??0,p95RenderMs:this.os(r,!0),longRenderCount:e.filter(o=>o>16.7).length,renderedRows:t?.rows??0,renderedColumns:t?.columns??0,renderedCells:(t?.rows??0)*(t?.columns??0),layoutSampleCount:this.hn.length,p95LayoutMs:this.os(this.hn),modelSampleCount:this.pn.length,p95ModelMs:this.os(this.pn),longTaskCount:Math.max(0,i.count-this.fn.count),longTaskTotalMs:Math.max(0,i.totalMs-this.fn.totalMs),usedHeapBytes:this.usedHeapBytes()}}reset(){this.Ot=[],this.hn=[],this.pn=[],this.fn=Rt.snapshot()}destroy(){this.ns?.(),this.ns=null}El(e,t){e.push(Math.max(0,Mr()-t)),e.length>120&&e.shift()}vh(e){return e.length===0?0:e.reduce((t,r)=>t+r,0)/e.length}usedHeapBytes(){let e=typeof performance>"u"?void 0:performance.memory?.usedJSHeapSize;return typeof e=="number"&&Number.isFinite(e)?e:null}os(e,t=!1){if(e.length===0)return 0;let r=t?e:[...e].sort((i,o)=>i-o);return r[Math.max(0,Math.ceil(r.length*.95)-1)]??0}};function Ar(n,e){if(!(n==null||e==null))return[...new Set([...n,...e])]}function Ls(n,e){return n===!0||e===!0?!0:n?e?{rowIds:Ar(n.rowIds,e.rowIds),rowIndexes:Ar(n.rowIndexes,e.rowIndexes),columns:Ar(n.columns,e.columns),force:n.force===!0||e.force===!0,includePinned:n.includePinned===!0||e.includePinned===!0}:n:e}var Ns=["columns","header","pool","data","layout","pinned","summary","overlays"];function Fs(n,e){let t={cells:Ls(n.cells,e.cells)};for(let r of Ns)t[r]=n[r]===!0||e[r]===!0;return t}var Mt=class{constructor(e){this.apply=e;this.Ht=0;this.ht=null;this.Rl=0;this.Sl=0;this.Ml=0;this.mn=!1}batch(e){if(this.mn)return e();this.Ht++;try{return e()}finally{this.Ht--,this.Ht===0&&this.flush()}}Il(e){this.mn||(this.Sl++,this.ht&&this.Ml++,this.ht=Fs(this.ht??{},e),this.Ht===0&&this.flush())}flush(){if(this.mn||this.Ht>0||!this.ht)return;let e=this.ht;this.ht=null,this.Rl++,this.apply(e)}snapshot(){return{batchDepth:this.Ht,flushCount:this.Rl,requestCount:this.Sl,coalescedRequestCount:this.Ml,pending:this.ht!=null}}destroy(){this.mn=!0,this.ht=null,this.Ht=0}};var Qi=Symbol.for("mach-table.adapter.lifecycle.v1");function en(n,e){Object.defineProperty(n,Qi,{value:e})}function kr(n){let e=n[Qi]?.rowDrag;return e?.policy===n.getOption("rowDragPolicy")?e?.factory:void 0}var tn=Symbol.for("mach-table.import.v1");function rn(n,e){Object.defineProperty(n,tn,{value:{begin:()=>e._.Ji(),revision:()=>e.i.ze(),isEditing:()=>e.l.isEditing(),columns:()=>e.n.ee(),visibleColumns:()=>e.n.d(),read:(r,i)=>e.c(r,i),editable:(r,i)=>e.l.oe(r,i),parse:(r,i,o,s)=>le(e,r,i,o,"import",s),pasteRows:r=>{let i=[];for(let o of e.i.At())if(!o.isGroup&&!o.isDetail&&i.push(o),i.length>=r)break;return i},resolveId:(r,i)=>e.r.resolveRowId?.({data:r,index:i,api:n}),validate:(r,i)=>e._.Vo(r,i),guard:r=>e._.Zi(r),commitRows:(r,i,o)=>e._.nl(r,i,o)}})}function nn(n){let e=n[tn];if(!e)throw new TypeError("Import plans require a MachTable GridApi");return e}function Os(n,e,t,r){let i=n.columns().filter(u=>u.colDef.field),o=t.columns??e,s=new Map(i.map(u=>[u.id,u])),a=new Map,l=new Map;for(let u of i){let h=u.colDef.field;a.set(h,a.has(h)?null:u);let p=u.colDef.headerName;p&&l.set(p,l.has(p)?null:u)}let d=[],c=new Set;return o.forEach((u,h)=>{let p=(typeof u=="string"||typeof u=="number"?String(u):"").replace(/^\uFEFF/,"").trim(),m=s.get(p)??(a.has(p)?a.get(p):l.get(p));if(!m){if(r||t.columns||a.has(p)||l.has(p))throw new TypeError(`Unknown or ambiguous import column: ${p}`);return}if(c.has(m.colDef.field))throw new TypeError(`Duplicate import column: ${m.id}`);c.add(m.colDef.field),d.push({column:m,index:h})}),d.length?d:n.visibleColumns().filter(u=>u.colDef.field).map((u,h)=>({column:u,index:h}))}function Hs(n,e){if(!Array.isArray(n)||n.some(t=>!Array.isArray(t)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(e)||e<-1||e>=n.length)throw new RangeError("Invalid import header row");if(n.length-e-1>1e4||n.reduce((t,r)=>t+r.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function Vs(n,e,t,r,i,o){let s=t.colDef.field,a=n.read(e.node,t),l=o.parseValue?o.parseValue({value:i,field:s,rowIndex:e.rowIndex,columnIndex:r}):t.colDef.valueParser?n.parse(e.node,t,i,a):pt(i,o.coerceNumbers!==!1);if(l!=null&&typeof l.then=="function")throw new TypeError("Import parsers must return synchronous values");if(!De(e.data,s,l))throw new TypeError(`Unsafe import field: ${s}`);e.changes.push({node:e.node,column:t,oldValue:a,newValue:l})}function Bs(n,e,t,r,i,o,s,a){let l=a?.[t]??{},d=s?.[t]??{id:`import:${t}`,rowIndex:t,data:l,selected:!1},c={data:l,node:d,changes:[],rowIndex:t};for(let{column:u,index:h}of r)if(!(e[h]===void 0||s&&!n.editable(d,u)))try{Vs(n,c,u,h,e[h],i)}catch(p){o.issues.push({rowIndex:t,columnIndex:h,colId:u.id,code:"PARSE",message:p instanceof Error?p.message:String(p)})}o.rows.push(c)}function on(n,e,t={},r,i=!1,o){let s=t.headerRowIndex??(t.columns?-1:0);Hs(e,s);let a=Os(n,s<0?[]:e[s],t,i);if(!a.length)throw new TypeError("Import requires a writable field column");let l={rows:[],issues:[]};for(let d=s+1;d<e.length;d++){let c=e[d];c.some(u=>u!==""&&u!==void 0)&&Bs(n,c,d-s-1,a,t,l,r,o)}return l}function me(n){return(n==null?"":String(n)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Gr(n,e,t="text/plain;charset=utf-8"){try{if(typeof document>"u"||typeof Blob>"u")return!1;let r=document.createElement("a");if(typeof URL<"u"&&typeof URL.createObjectURL=="function"){let i=new Blob([e],{type:t}),o=URL.createObjectURL(i);r.href=o,r.download=n,r.click();let s=typeof URL.revokeObjectURL=="function"?URL.revokeObjectURL.bind(URL):null;s&&setTimeout(()=>{try{s(o)}catch{}},0)}else r.href=`data:${t},${encodeURIComponent(e)}`,r.download=n,r.click();return!0}catch{return!1}}var Pr=["gridReady","gridDestroyed","modelUpdated","cellClicked","cellDoubleClicked","cellContextMenu","rowClicked","rowDoubleClicked","selectionChanged","sortChanged","filterChanged","columnResized","columnMoved","columnVisibilityChanged","cellValueChanged","cellEditingStarted","cellEditingStopped","rowEditingStarted","rowEditingStopped","detailToggled","treeChildrenLoaded","treeChildrenLoadFailed","rowDragEnd","rangeSelectionChanged","paginationChanged","displayedColumnsChanged","gridError","dirtyStateChanged"];var ge={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",maxBodyHeight:"number",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",rowNumber:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};var Lr=Object.freeze(Object.keys(ge));var Fe=new Set(Pr.map(n=>`on${n.charAt(0).toUpperCase()}${n.slice(1)}`));function Nr(n,e){let t=ge[n];return e==null||t==="unknown"?!0:t==="array"?Array.isArray(e):t==="number"?E(e,n==="maxBodyHeight"?1:-1/0)!==void 0:t==="boolean-object"&&typeof e=="boolean"||t==="object-function"&&typeof e=="function"?!0:t==="object"||t==="boolean-object"||t==="object-function"?typeof e=="object"&&!Array.isArray(e):typeof e===t}function sn(n){let e={};for(let[t,r]of Object.entries(n)){if(Fe.has(t)){(r==null||typeof r=="function")&&(e[t]=r);continue}!v(ge,t)||!Nr(t,r)||(e[t]=r)}return e}var cn=2e3,Fr=1e5,Oe=512,zs=1e4;function an(n){return Array.isArray(n)?[...new Set(n.slice(0,Fr).filter(e=>typeof e=="string"&&e.length>0&&e.length<=Oe))]:[]}function Ws(n){if(!Array.isArray(n))return[];let e=new Set,t=Fr*Oe;for(let r of n.slice(0,Fr)){if(typeof r!="string"||!r.length||e.has(r))continue;let i=r.startsWith(st)?65536:Oe;r.length>i||r.length>t||(e.add(r),t-=r.length)}return[...e]}function ln(n,e){return typeof n=="number"&&Number.isFinite(n)&&n>=1?Math.floor(n):e}function dn(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function $s(n,e){let t=dn(e.flex);for(let r of["width","contentWidth"]){let i=dn(e[r]);i!==void 0&&(n[r]=i)}e.flex===null?n.flex=null:t!==void 0&&(n.flex=t),(e.widthMode==="auto"||e.widthMode==="manual")&&(n.widthMode=e.widthMode)}function Ks(n,e){typeof e.hide=="boolean"&&(n.hide=e.hide),(e.pinned===null||e.pinned==="left"||e.pinned==="right")&&(n.pinned=e.pinned)}function Us(n,e){if(n==null||typeof n!="object")return null;let t=n,r=typeof t.colId=="string"?t.colId.trim():"";if(!r||r.length>Oe||e.has(r))return null;e.add(r);let i={colId:r};return Ks(i,t),$s(i,t),i}function js(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,cn)){let i=Us(r,t);i&&e.push(i)}return e}function qs(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,cn)){if(r==null||typeof r!="object")continue;let i=r,o=typeof i.colId=="string"?i.colId.trim():"";!o||o.length>Oe||t.has(o)||i.direction!=="asc"&&i.direction!=="desc"||(t.add(o),e.push({colId:o,direction:i.direction}))}return e}function q(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==2||!Array.isArray(e.columns)||!Array.isArray(e.sortModel))return null;let t=e.pagination!=null&&typeof e.pagination=="object"?e.pagination:{};return{version:2,columns:js(e.columns),sortModel:qs(e.sortModel),filterModel:ne(e.filterModel),advancedFilterModel:B(e.advancedFilterModel),quickFilterText:typeof e.quickFilterText=="string"&&e.quickFilterText.trim()?e.quickFilterText.slice(0,zs):null,pagination:{enabled:t.enabled===!0,page:ln(t.page,1),pageSize:ln(t.pageSize,20)},selectedRowIds:an(e.selectedRowIds),expandedRowIds:an(e.expandedRowIds),expandedGroupIds:Ws(e.expandedGroupIds)}}function un(n,e){let t=q(n);if(!t)throw new TypeError("[MachTable] Cannot persist an invalid GridState snapshot.");let r=new Set(e);return{version:2,columns:r.has("columns")?t.columns:[],sortModel:r.has("sort")?t.sortModel:[],filterModel:r.has("filter")?t.filterModel:{},advancedFilterModel:r.has("filter")?t.advancedFilterModel:null,quickFilterText:r.has("filter")?t.quickFilterText:null,pagination:r.has("pagination")?t.pagination:{enabled:!1,page:1,pageSize:20},selectedRowIds:r.has("selection")?t.selectedRowIds:[],expandedRowIds:r.has("expansion")?t.expandedRowIds:[],expandedGroupIds:r.has("expansion")?t.expandedGroupIds:[]}}function Ys(n){try{if(typeof structuredClone=="function")return structuredClone(n)}catch{}return Array.isArray(n)?[...n]:n!=null&&typeof n=="object"?{...n}:n}function pn(n,e){let t=e?new Set(e.map(String)):null;return n.filter(r=>!t||t.has(r.rowId)).map(r=>({...r,data:Ys(r.data),cells:r.cells.map(i=>({...i}))}))}function Xs(n,e){let t=typeof n?.rowId=="string"?n.rowId:"";return!e.has(t)||typeof n.message!="string"||!n.message.trim()?null:{...n,rowId:t,message:n.message.trim(),...typeof n.code=="string"&&n.code.trim()?{code:n.code.trim()}:{},...Array.isArray(n.colIds)?{colIds:[...new Set(n.colIds.filter(r=>typeof r=="string"&&r.length>0))]}:{}}}function hn(n,e){let t=new Map;for(let r of n??[]){let i=Xs(r,e);i&&!t.has(i.rowId)&&t.set(i.rowId,i)}return[...t.values()]}function fn(n,e){let t=new Set(n.map(d=>d.rowId)),r=hn(e?.conflicts,t),i=new Set(r.map(d=>d.rowId)),o=hn(e?.failures,t).filter(d=>!i.has(d.rowId)),s=new Set([...o,...r].map(d=>d.rowId)),a=e?.savedRowIds==null?null:new Set(e.savedRowIds.map(String).filter(d=>t.has(d))),l=n.filter(d=>!s.has(d.rowId)&&(a==null||a.has(d.rowId)));return{submitted:n,saved:l,failures:o,conflicts:r}}function Js(n,e){if(e.serverData===void 0)return null;let t=n.rows.getById(e.rowId);if(!t||t.data==null)return null;let r=n.getOption("rowKey");if(r){let s=typeof r=="function"?r(e.serverData):W(e.serverData,r);return String(s)===e.rowId?{data:e.serverData,mergeIntoCurrent:!1}:null}let i=t.data;return i!=null&&e.serverData!=null&&typeof i=="object"&&typeof e.serverData=="object"?{data:i,mergeIntoCurrent:!0}:null}function Zs(n,e,t){if(n.isDestroyed())return!1;if(t==="keepLocal")return!0;let r=Js(n,e);return r?(n.editing.rollback([e.rowId]),r.mergeIntoCurrent&&Object.assign(r.data,e.serverData),n.rows.transact({update:[r.data]}),n.editing.markSaved([e.rowId]),!0):!1}var Qs=["compact","normal","large"],w=["left","center","right"];function At(n,e){let t=n.r,r;if(e==="loading")r=t.overlayLoadingTemplate||n.bh();else if(e==="noRows")r=t.overlayNoRowsTemplate||n.wh();else if(e==="error")r=t.overlayErrorTemplate||n.Ch();else{n.o.Th();return}n.o.Dh(e,r,t.allowUnsafeOverlayHtml)}var It=class{constructor(e){this.e=e;this.ii=null;this.ls=null;this.ds=!1;this.bn=null;this.cs=[];this.wn=null;this.cr=0;this.Al=-1;this.kl=-1;this.Xt=1;this.ur=null}init(e,t){let r=["mach-root",`mach-size--${t.size}`];t.stripedRows&&r.push("mach-striped"),t.showCellBorders&&r.push("mach-cell-borders"),t.domLayout==="autoHeight"&&r.push("mach-dom-layout--auto-height"),this.root=f("div",r.join(" ")),this.Gl(t.className),this.root.style.setProperty("--mach-row-h",`${t.rowHeight}px`),this.root.style.setProperty("--mach-header-h",`${t.headerHeight}px`),this.root.setAttribute("role","grid"),this.root.tabIndex=0,this.Pl(t),this.ti=f("div","mach-header"),this.ti.setAttribute("role","rowgroup"),this.ri={left:[],center:[],right:[]},this.ss={},this.sr={};for(let i of w){let o=f("div",`mach-pane mach-pane--${i} mach-header-pane`),s=f("div","mach-header-rows");if(i==="center"){let a=f("div","mach-header-viewport");a.appendChild(s),o.appendChild(a)}else o.appendChild(s);this.ti.appendChild(o),this.ss[i]=o,this.sr[i]=s}this.Ll(1),this.Le=f("div","mach-body"),this.gn=f("div","mach-pinned-rows mach-pinned-rows--top"),this.gn.style.display="none",this.yn=f("div","mach-pinned-rows mach-pinned-rows--bottom"),this.yn.style.display="none",this.T={},this.Ee={},this.as={};for(let i of w){let o=f("div",`mach-pane mach-pane--${i} mach-body-pane`),s=f("div",`mach-body-viewport${i==="center"?" mach-body-viewport--scroll":""}`),a=f("div","mach-row-container");s.appendChild(a),o.appendChild(s),this.Le.appendChild(o),this.as[i]=o,this.T[i]=s,this.Ee[i]=a}this.Ue=f("div","mach-overlay"),this.Ue.style.display="none",this.Ue.setAttribute("role","status"),this.Ue.setAttribute("aria-live","polite"),this.je=f("div","mach-overlay-content"),this.Ue.appendChild(this.je),this.pt=f("div","mach-infinite-loading"),this.pt.style.display="none",this.pt.appendChild(f("div","mach-spinner")),this.vn=f("span"),this.pt.appendChild(this.vn),this.root.append(this.ti,this.gn,this.Le,this.yn,this.Ue,this.pt),e.appendChild(this.root),typeof ResizeObserver<"u"&&(this.wn=new ResizeObserver(i=>{let o=i[i.length-1]?.contentRect;if(!o)return;let s=Math.round(o.width),a=Math.round(o.height);s===this.Al&&a===this.kl||(this.Al=s,this.kl=a,!this.cr&&(this.cr=requestAnimationFrame(()=>{this.cr=0,this.e.ve()})))}),this.wn.observe(this.root)),this.Nl(t.theme)}Pl(e){e.ariaLabelledBy?(this.root.setAttribute("aria-labelledby",e.ariaLabelledBy),this.root.removeAttribute("aria-label")):(this.root.removeAttribute("aria-labelledby"),this.root.setAttribute("aria-label",e.ariaLabel)),e.ariaDescribedBy?this.root.setAttribute("aria-describedby",e.ariaDescribedBy):this.root.removeAttribute("aria-describedby")}Ll(e){this.Xt=e;for(let t of w){let r=this.sr[t],i=this.ri[t];for(;i.length<e;){let o=f("div","mach-header-row");o.setAttribute("role","row"),o.setAttribute("aria-rowindex",String(i.length+1)),r.appendChild(o),i.push(o)}for(;i.length>e;)i.pop().remove()}this.Fl()}Ol(){return this.Xt}Fl(){this.ti.style.height=`${this.Xt*this.e.r.headerHeight}px`;for(let e of w)this.ri[e].forEach((r,i)=>{r.style.top=`${i*this.e.r.headerHeight}px`,r.style.height=`${this.e.r.headerHeight}px`})}xh(e,t){this.Hl("left",e),this.Hl("right",t)}Hl(e,t){let r=this.ss[e],i=this.as[e];r.style.width=`${t}px`,i.style.width=`${t}px`;let o=t<=0;r.classList.toggle("mach-pane--hidden",o),i.classList.toggle("mach-pane--hidden",o)}us(){let e=this.T.center,t=Math.max(0,e.offsetWidth-e.clientWidth);return Math.max(0,this.Le.clientWidth-t)}Eh(e,t){this.root.style.setProperty("--mach-row-h",`${e}px`),this.root.style.setProperty("--mach-header-h",`${t}px`),this.Fl()}Rh(e){for(let t of Qs)this.root.classList.toggle(`mach-size--${t}`,t===e)}Nl(e){if(!this.root)return;this.ur?.(),this.ur=null;let t=e==="dark"||e==="auto"&&this.Sh();if(this.root.classList.toggle("mach-theme-dark",t),e==="auto"&&typeof window<"u"&&typeof window.matchMedia=="function"){let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>this.root.classList.toggle("mach-theme-dark",r.matches);typeof r.addEventListener=="function"?(r.addEventListener("change",i),this.ur=()=>r.removeEventListener("change",i)):typeof r.addListener=="function"&&(r.addListener(i),this.ur=()=>r.removeListener(i))}}Sh(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}Mh(e){this.root.classList.toggle("mach-striped",e)}Ih(e){this.root.classList.toggle("mach-cell-borders",e)}Ah(e){this.root.classList.toggle("mach-dom-layout--auto-height",e==="autoHeight")}Gl(e){for(let t of this.cs)this.root.classList.remove(t);this.cs=[];for(let t of String(e??"").split(/\s+/).filter(Boolean))this.root.classList.contains(t)||(this.root.classList.add(t),this.cs.push(t))}kh(e){try{return typeof e=="function"?e():e}catch(t){return this.e.reportError(t,"overlayTemplate"),""}}Gh(e,t,r){if(typeof t=="object"&&t!=null&&"el"in t){this.je.appendChild(t.el),this.bn=t.destroy??null;return}if(t instanceof HTMLElement){this.je.appendChild(t);return}if(t){r?this.je.innerHTML=t:this.je.textContent=t;return}if(e!=="loading")return;let i=f("div","mach-spinner");i.setAttribute("aria-label","loading"),this.je.appendChild(i)}Dh(e,t,r=!1){this.ii===e&&this.ls===t&&this.ds===r||(this.ii=e,this.ls=t,this.ds=r,this.hs(),this.je.replaceChildren(),this.Gh(e,this.kh(t),r),this.Ue.style.display="",this.root.classList.add("mach-has-overlay"),this.Ue.setAttribute("role",e==="error"?"alert":"status"),this.root.setAttribute("aria-busy",e==="loading"?"true":"false"))}Th(){this.ii&&(this.ii=null,this.ls=null,this.ds=!1,this.Ue.style.display="none",this.root.classList.remove("mach-has-overlay"),this.hs(),this.je.replaceChildren(),this.root.setAttribute("aria-busy","false"))}Rt(e,t){this.pt&&(e?(this.vn.textContent!==t&&(this.vn.textContent=t),this.pt.style.display="",this.root.setAttribute("aria-busy","true")):(this.pt.style.display="none",this.ii!=="loading"&&this.root.setAttribute("aria-busy","false")))}destroy(){this.ur?.(),this.ur=null,this.wn?.disconnect(),this.wn=null,this.cr&&cancelAnimationFrame(this.cr),this.cr=0,this.hs(),this.root?.remove()}hs(){if(!this.bn)return;let e=this.bn;this.bn=null;try{e()}catch(t){this.e.reportError(t,"overlayTemplate.destroy")}}};function mn(n,e){return{setData:t=>n.it(t),transact:t=>n.Or(t),transactAsync:(t,r)=>n.Ph(t,r),flushTransactions:()=>n.Vl(),getCount:()=>e.i.P(),getAt:t=>e.i.h(t),getById:t=>e.i.O(t),forEach:t=>e.i.iu(t),forEachDisplayed:t=>e.i.nu(t),reorder:(t,r)=>!e.s()&&!e.l.isEditing()&&e.i._a(t,r),isRemote:()=>e.i.g,reload:t=>n.reload(t),ensureLoaded:(t,r,i)=>n.yo(t,r,i),purgeCache:()=>{e.s()||e.i.Rc()},getCacheSnapshot:()=>e.i.Sc()}}function gn(n,e){return{getDefinitions:()=>e.n.ro(),setDefinitions:t=>n.Er(t),getState:()=>e.n.la(),setState:t=>n.Lh(t),resetState:()=>n.ao(),setVisible:(t,r)=>n.no(t,r),setPinned:(t,r)=>n.oo(t,r),move:(t,r)=>{e.s()||e.Rr(t,r)},setWidth:(t,r)=>n.Me(t,r),fit:t=>n.Nh(t),autoSize:t=>n.Fh(t),autoSizeAll:()=>n.Oh(),getWorkbenchItems:()=>n.Hh(),openWorkbench:t=>{e.s()||e.columnMenu.Qu(t)},closeWorkbench:()=>e.columnMenu.close()}}function yn(n,e){return{getRows:()=>e.f.za(),getVisibleRows:()=>n.Vh(),getNodes:()=>e.f.rr(),getIds:()=>e.f.Ro(),setRows:(t,r)=>n.Bh(t,r),setById:(t,r,i)=>e.f.lu(t,r,i),selectAll:t=>e.f.selectAll(t),clear:()=>e.f.deselectAll(),getMode:()=>e.r.rowSelection,setMode:t=>n._h(t),getRange:()=>e.a.ni(),clearRange:()=>n.lr()}}function vn(n,e){return{startCell:t=>n.zh(t),startRow:t=>e.l.startRow(t),isRowActive:t=>e.l.al(t),stop:t=>e.l.xe(t?.cancel===!0),getChanges:()=>e.K.getChanges(),getDirtyRowIds:()=>e.K.getDirtyRowIds(),markSaved:t=>e.K.markSaved(t),rollback:t=>e.K.rollback(t),save:(t,r)=>n.Wh(t,r),undo:()=>!e.s()&&e.V.undo(),redo:()=>!e.s()&&e.V.redo(),canUndo:()=>e.V.canUndo(),canRedo:()=>e.V.canRedo()}}function bn(n){return{get:()=>n.getState(),apply:(e,t)=>n.Bl(e,t)}}function wn(n,e){return{get:()=>e.$h(),getPerformance:()=>e.we.snapshot(),resetPerformance:()=>e.we.reset()}}function Cn(n,e){return{getModel:()=>e.i.We(),setModel:t=>n.St(t),getAdvancedModel:()=>e.i.Nr(),setAdvancedModel:t=>n.nt(t),getQuickText:()=>e.i.Co(),setQuickText:t=>n.Mt(t),isPresent:t=>t==null?e.i.Hr():v(e.i.We(),t)}}function Tn(n,e){return{getModel:()=>e.n.te(),setModel:t=>n.Kh(t)}}function Dn(n,e){return{isEnabled:()=>e.i.Ce,setEnabled:t=>{e.s()||e.i.Ha(t)},getPage:()=>e.i.tr(),setPage:t=>{e.s()||e.i.setPage(t)},getPageSize:()=>e.r.paginationPageSize,setPageSize:t=>{e.s()||e.i.setPageSize(t)},getPageCount:()=>e.i.getPageCount(),getTotalRowCount:()=>e.i.getTotalRowCount()}}function xn(n,e){return{isRowExpanded:t=>e.i.isRowExpanded(t),setRowExpanded:(t,r)=>e.s()||e.i.isRowExpanded(t)===r?!1:(r?e.i.eu(t):e.i.tu(t),e.i.isRowExpanded(t)===r),isTreeRowLoading:t=>!e.s()&&e.i.isTreeRowLoading(t),loadTreeChildren:(t,r)=>e.s()?Promise.resolve([]):e.i.loadTreeChildren(t,r?.force===!0),isGroupExpanded:t=>e.i.isGroupExpanded(t),setGroupExpanded:(t,r)=>e.s()||e.i.isGroupExpanded(t)===r?!1:(e.i.xo(t),e.i.isGroupExpanded(t)===r),setAllGroupsExpanded:t=>{e.s()||e.i.setAllGroupsExpanded(t)},setAllDetailsExpanded:t=>{e.s()||e.i.setAllDetailsExpanded(t)}}}function En(n,e){return{getRoot:()=>e.s()?null:e.o.root,scrollToRow:(t,r)=>e.a.Ui(t,r),refreshCells:t=>n.refreshCells(t),refreshLayout:()=>n.refreshLayout(),flush:()=>e.hr.flush(),setOverlay:t=>At(e,t),getPinnedRows:t=>e.Ne.getRows(t),setPinnedRows:(t,r)=>n.setPinnedRows(t,r)}}function Rn(n,e){return{exportCsv:t=>n.Uh(t),importCsv:(t,r)=>n.importCsv(t,r),exportMatrix:t=>n._l(t),importMatrix:(t,r)=>n.importMatrix(t,r),print:t=>n.print(t),copyRange:()=>e.s()?Promise.resolve(!1):e.vl()}}function kt(n){return te(n?.reason,"The operation was aborted")}function Sn(n,e){return rt(n,e,()=>kt(e))}function Or(n,e,t,r=!1){let i=E(n,t,r);return i===void 0||i===e?void 0:i}function F(n,e,t){let r=n[t];return r==null||r===e[t]?!1:(e[t]=r,!0)}var Hr=class{constructor(e){this.e=e;this.ps=[];this.oi=null}batch(e){return this.e.zl(()=>e(this.e.api))}it(e){this.e.s()||(this.e.r.rowData=e??[],!this.e.i.g&&(this.e.i.it(e),this.e.U({data:!0})))}Or(e){if(this.e.s()||this.e.i.g)return;let t=this.e.i.Or(e);this.Wl(t)}Ph(e,t={}){if(this.e.s()||this.e.i.g)return Promise.resolve();if(t.signal?.aborted)return Promise.reject(kt(t.signal));let r=new Promise((i,o)=>{let s={transaction:e,revision:this.e.i.ze(),resolve:i,reject:o,signal:t.signal,aborted:!1};t.signal&&(s.onAbort=()=>{s.aborted||(s.aborted=!0,o(kt(t.signal)))},t.signal.addEventListener("abort",s.onAbort,{once:!0})),this.ps.push(s)});return this.oi==null&&(this.oi=setTimeout(()=>this.Vl(),this.e.r.asyncTransactionWaitMillis)),r}$l(){this.oi!=null&&clearTimeout(this.oi),this.oi=null;let e=this.ps;return this.ps=[],e}Vl(){let e=this.$l(),t=this.e.i,r=t.ze(),i=e.filter(s=>!s.aborted&&s.revision===r).map(s=>s.transaction);if(i.length>0&&!this.e.s()&&!t.g){let s=t.Nc(i);t.ze()===r&&this.Wl(s)}let o=t.ze()===r;for(let s of e)s.signal&&s.onAbort&&s.signal.removeEventListener("abort",s.onAbort),!s.aborted&&(o&&s.revision===r?s.resolve():s.reject(te(void 0,"The table data changed before the transaction could complete")))}Wl(e){if(!(!e.pipelineChanged&&e.updatedRowIds.length===0)){if(e.pipelineChanged||this.e.r.getRowHeight){this.e.U({data:!0});return}this.e.U({cells:{rowIds:e.updatedRowIds},summary:!0,overlays:!0})}}Er(e){this.updateOptions({columnDefs:[...e??[]]})}Lh(e){this.e.s()||(this.e.n.da(e),this.fs())}ao(){this.e.s()||(this.e.n.ao(),this.fs())}no(e,t){this.e.s()||(this.e.n.no(e,t),this.e.si(),this.e.emit("columnVisibilityChanged",{colId:e,visible:t}))}oo(e,t){this.e.s()||(this.e.n.oo(e,t),this.fs())}fs(){this.e.si(),this.e.Cn()}Me(e,t){if(this.e.s())return!1;let r=this.e.n.R(e);return!r||!this.e.n.Me(r,t)?!1:(this.st([r]),!0)}Nh(e){if(this.e.s())return;let t=this.e.n.d(),r=t.filter(d=>d.pinned===null&&!d.colDef.suppressSizeToFit);if(r.length===0)return;let i=e??this.e.o.us();if(!Number.isFinite(i)||i<=0)return;let o=t.reduce((d,c)=>d+(c.pinned!==null||c.colDef.suppressSizeToFit?c.currentWidth:0),0),s=Ze(r.map(d=>({width:d.currentWidth,minWidth:d.colDef.minWidth,maxWidth:d.colDef.maxWidth})),Math.max(0,i-o)),a=this.e.r.columnLayout==="fit"&&e===void 0,l=r.filter((d,c)=>a?this.e.n.sa(d,s[c]):this.e.n.Me(d,s[c]));this.st(l)}Fh(e){if(this.e.s())return;let t=this.e.n.R(e);t&&this.Kl(t)&&this.st([t])}Kl(e){return this.e.r.columnLayout==="fit"&&e.colDef.suppressSizeToFit?!1:e.hasCheckbox||e.isDetailToggle?this.e.n.Me(e,e.isDetailToggle?38:46):this.jh(e,this.e.ft.ia(e))}jh(e,t){return this.e.r.columnLayout==="fit"?this.e.n.sa(e,t):this.e.n.Me(e,t)}Oh(){if(this.e.s())return;let e=[];for(let t of this.e.n.d())this.Kl(t)&&e.push(t);e.length>0&&this.st(e)}st(e){this.e.ir(),this.e.st(e)}Kh(e){this.e.s()||(this.e.n.Sr(e),this.e.Sr())}St(e){this.e.s()||(this.e.i.St(e),this.e.ai())}nt(e){this.e.s()||!this.e.i.nt(e)||this.e.ai()}Mt(e){if(this.e.s())return;let t=this.e.i.Mt(e);this.e.r.quickFilterText=this.e.i.Co(),t&&this.e.ai()}_h(e){this.e.r.rowSelection!==e&&this.updateOptions({rowSelection:e})}Bh(e,t=!0){if(this.e.s())return;let r=this.e.r.resolveRowId,i=[];for(let o of e){let s=r?this.e.i.O(this.e.i.resolveRowId(o,-1,`__missing_selection_${this.e.er()}`)):this.e.i.Ve().find(a=>a.data===o);s&&i.push({node:s,selected:!0})}i.length>0?this.e.f.Gt(i,t):t&&this.e.f.deselectAll()}Vh(){let e=this.e.f;return this.e.i.At().filter(t=>!t.isDetail&&!t.isGroup&&e.Wi(t.id)).map(t=>t.data).filter(Boolean)}async Wh(e,t){let r=pn(this.e.K.getChanges(),t);if(r.length===0)return{submitted:[],saved:[],failures:[],conflicts:[]};let i=this.e.i.ze(),o=fn(r,await e(r));return!this.e.s()&&i===this.e.i.ze()&&this.e.K.fh(o.saved),o}setPinnedRows(e,t){if(this.e.s())return;let r=e==="top"?"pinnedTopRowData":"pinnedBottomRowData";this.e.r[r]=t??[],this.e.Ne.setRows(e,this.e.r[r])}lr(){this.e.s()||this.e.a.lr()}Hh(){return this.e.n.ee().filter(e=>!e.isDetailToggle).map(e=>({colId:e.id,label:e.colDef.headerName??e.colDef.field??e.id,visible:!e.hide,pinned:e.pinned,width:e.currentWidth||e.manualWidth||e.colDef.width||0,movable:e.movable,hideable:!e.hasCheckbox}))}refreshLayout(){this.e.s()||(this.e.ve(),this.e.a.Tn(!0))}reload(e={}){return this.e.s()?Promise.resolve():e.signal?.aborted?Promise.reject(kt(e.signal)):this.e.i.g?Sn(this.e.i.Bi(e.signal),e.signal):(this.it(this.e.r.rowData),Promise.resolve())}yo(e,t,r={}){return this.e.s()?Promise.resolve():Sn(this.e.i.yo(e,t,r.signal),r.signal)}importCsv(e,t={}){if(!e)return!1;let{parseValue:r,...i}=t;return this.importMatrix(xr(e,t.separator??","),{...i,parseValue:r?o=>r({...o,value:o.value}):void 0})}importMatrix(e,t={}){if(this.e.s()||this.e.i.g||!Array.isArray(e)||!e.length)return!1;try{let r=nn(this.e.api),i=t.mode==="paste"?r.pasteRows(e.length):void 0,o=on(r,e,t,i);if(o.issues.length)return this.e.reportError(new Error(o.issues.map(s=>s.message).join("; ")),"import",{issues:o.issues}),!1;if(t.mode==="paste")this.e.pr(o.rows.flatMap(s=>s.changes));else{let s=o.rows.map(a=>a.data);t.mode==="append"?this.Or({add:s}):this.it(s)}return!0}catch(r){return this.e.reportError(r,"import"),!1}}print(e={}){if(this.e.s())return!1;try{let t=window.open("","_blank","width=980,height=720");if(!t)return!1;let r=this.e.n.d().filter(d=>U(d)&&!d.colDef.rowDrag),i=this.e.i.Fa().filter(d=>!d.isDetail&&!d.isGroup),s=e.includeHeader!==!1?`<tr>${r.map(d=>`<th>${me(d.colDef.headerName??d.colDef.field??d.id)}</th>`).join("")}</tr>`:"",a=i.map(d=>`<tr>${r.map(c=>{let u=ce(this.e,d,c);return`<td>${me(u)}</td>`}).join("")}</tr>`).join(""),l=`<!doctype html><html><head><meta charset="utf-8"><title>${me(e.title??"MachTable")}</title><style>body{font-family:system-ui,"PingFang SC","Microsoft YaHei",sans-serif;padding:20px}h3{margin:0 0 12px;font-size:16px}table{border-collapse:collapse;width:100%;font-size:12px}th,td{border:1px solid #bbb;padding:5px 8px;text-align:left;word-break:break-all}th{background:#f2f5f9;font-weight:600}@page{margin:12mm}</style></head><body><h3>${me(e.title??"")}</h3><table>${s}${a}</table></body></html>`;return t.document.write(l),t.document.close(),t.focus(),t.print(),!0}catch{return!1}}zh(e){let t=this.e.n.R(e.colId);return t?this.e.l.start(e.rowIndex,t,e.keyPress??null):!1}refreshCells(e){let t=e==null||e.rowIds==null&&e.rowIndexes==null&&e.columns==null;this.e.U({cells:e??!0,pinned:e?.includePinned??t,summary:t})}getOption(e){return this.e.r[e]}updateOptions(e){this.e.s()||(this.e.ms(e),e=sn(e),Object.keys(e).length!==0&&this.e.zl(()=>{let t={},r=this.e.r.columnMenu;this.qh(e,t),this.Yh(e,t),this.Xh(e,t),this.Jh(e,t),this.Zh(e),this.Qh(e,t),this.ep(e,t),this.tp(e,t),this.rp(e,t),this.ip(e,t),this.np(e,t,r)}))}qh(e,t){let r=this.e.r;v(e,"columnDefs")&&e.columnDefs!==r.columnDefs&&(r.columnDefs=Array.isArray(e.columnDefs)?e.columnDefs:[],t.needsColumnRebuild=!0,t.columnDefsChanged=!0),R(e,r,["rowNumber"])&&(t.needsColumnRebuild=!0),v(e,"rowData")&&e.rowData!==r.rowData&&(r.rowData=Array.isArray(e.rowData)?e.rowData:[],t.needsRowRebuild=!0),v(e,"initialState")&&e.initialState&&(r.initialState=e.initialState,t.stateToApply=e.initialState),this.op(e)}op(e){for(let t of Fe){let r=t;v(e,r)&&Object.assign(this.e.r,{[r]:e[r]})}}Yh(e,t){let r=this.e.r;for(let o of["rowHeight","headerHeight","rowBuffer"]){let s=Or(e[o],r[o],o==="rowBuffer"?0:1,o==="rowBuffer");s!==void 0&&(r[o]=s,t.layout=!0,o==="headerHeight"&&(t.header=!0))}e.columnLayout!=null&&e.columnLayout!==r.columnLayout&&(r.columnLayout=e.columnLayout==="fit"?"fit":"normal",t.layout=!0),e.domLayout!=null&&e.domLayout!==r.domLayout&&(r.domLayout=e.domLayout==="autoHeight"?"autoHeight":"normal",this.e.o.Ah(r.domLayout),t.pool=!0),v(e,"maxBodyHeight")&&(r.maxBodyHeight=E(e.maxBodyHeight,1),t.layout=!0),R(e,r,["multiSort"]);let i=Or(e.detailRowHeight,r.detailRowHeight,1);i!==void 0&&(r.detailRowHeight=i,this.e.a.Dn(),this.e.a.li(!0))}Xh(e,t){let r=this.e.r;e.editType!=null&&e.editType!==r.editType&&(this.e.l.stop(!0),r.editType=e.editType==="fullRow"?"fullRow":"cell",t.cells=!0),e.editableIndicator!=null&&e.editableIndicator!==r.editableIndicator&&(r.editableIndicator=e.editableIndicator==="always"||e.editableIndicator==="none"?e.editableIndicator:"hover",t.cells=!0),R(e,r,["rowEditValidator"],!0),R(e,r,["singleClickEdit","manualSorting","manualFiltering"])}Jh(e,t){let r=this.e.r;typeof e.enableColumnResize=="boolean"&&e.enableColumnResize!==r.enableColumnResize&&(this.e.di.Nt(),r.enableColumnResize=e.enableColumnResize,t.header=!0),F(e,r,"locale")&&(t.header=!0,t.cells=!0,this.e.fr.Re(),this.e.at.Re()),F(e,r,"indexOffset")&&(t.cells=!0),F(e,r,"showSummary")&&(t.summary=!0,t.layout=!0);let i=Or(e.undoStackSize,r.undoStackSize,0,!0);i!==void 0&&(r.undoStackSize=i,this.e.V.ph());let o=E(e.asyncTransactionWaitMillis,0,!0);o!==void 0&&(r.asyncTransactionWaitMillis=o),this.sp(e,t),this.ap(e)}sp(e,t){v(e,"getRowHeight")&&(this.e.r.getRowHeight=e.getRowHeight,this.e.a.It(),t.layout=!0)}ap(e){let t=this.e.r;e.enableRangeSelection!=null&&(t.enableRangeSelection=e.enableRangeSelection,e.enableRangeSelection||this.lr()),R(e,t,["tooltipComponent"],!0);let r=E(e.tooltipShowDelay,0);r!==void 0&&(t.tooltipShowDelay=r),R(e,t,["flashCells"]),R(e,t,["getContextMenuItems"],!0),F(e,t,"theme")&&(this.e.o.Nl(t.theme),this.e.xn.refresh())}Zh(e){if(!v(e,"pagination"))return;let t=this.e.r,r=e.pagination,i=r!==!1&&t.datasource==null;i!==t.paginationEnabled&&this.e.i.Ha(i),typeof r=="object"&&r&&this.lp(r),t.paginationEnabled&&this.e.i.Kc(),this.e.fr.Re()}lp(e){let t=this.e.r;t.paginationMode=e.mode==="server"?"server":"client";let r=E(e.page,1,!0),i=E(e.total,0,!0);r!==void 0&&(t.paginationPage=r),i!==void 0&&(t.paginationTotal=i),e.pageSize!=null&&(t.paginationPageSize=e.pageSize),e.pageSizeOptions!=null&&(t.paginationPageSizeOptions=e.pageSizeOptions),e.showTotal!=null&&(t.paginationShowTotal=e.showTotal),e.showPageSizeSelector!=null&&(t.paginationShowSizeSelector=e.showPageSizeSelector)}Qh(e,t){v(e,"rowStyleRules")&&(this.e.r.rowStyleRules=Array.isArray(e.rowStyleRules)?e.rowStyleRules:[],t.cells=!0,this.e.U({pinned:!0})),this.dp(e,t),this.cp(e,t);let r=this.e.r;F(e,r,"stripedRows")&&this.e.o.Mh(r.stripedRows),F(e,r,"showCellBorders")&&this.e.o.Ih(r.showCellBorders)}dp(e,t){let r=this.e.r;e.watermark!==void 0&&(Object.assign(r,rr(e)),this.e.xn.refresh()),this.up(e),v(e,"summaryMethod")&&(r.summaryMethod=e.summaryMethod,t.summary=!0)}up(e){let t=this.e.r;R(e,t,["suppressClipboard","contextMenu","columnMenu","fillHandle"]),e.statusBar!==void 0&&(t.statusBarEnabled=e.statusBar===!0||typeof e.statusBar=="object"&&e.statusBar!=null,typeof e.statusBar=="object"&&e.statusBar?.panels&&(t.statusBarPanels=e.statusBar.panels),this.e.at.Re())}cp(e,t){let{size:r}=e;if(r==null||!v(xe,r)||r===this.e.r.size)return;let i=xe[r];this.e.r.size=r,this.e.r.rowHeight=e.rowHeight??i.rowHeight,this.e.r.headerHeight=e.headerHeight??i.headerHeight,this.e.o.Rh(r),t.layout=!0,t.header=!0}ep(e,t){let r=this.e.r;R(e,r,["suppressCellFocus","suppressRowHoverHighlight","suppressNoRowsOverlay"]),F(e,r,"suppressHeaderFocus")&&(t.header=!0),this.hp(e),this.pp(e)}hp(e){let t=this.e.r,r=!1;for(let i of["ariaLabel","ariaLabelledBy","ariaDescribedBy"])v(e,i)&&(t[i]=e[i]??Ee[i],r=!0);r&&this.e.o.Pl(t)}pp(e){let t=this.e.r;for(let r of["overlayNoRowsTemplate","overlayLoadingTemplate","overlayErrorTemplate"])v(e,r)&&(t[r]=e[r]??Ee[r]);R(e,t,["allowUnsafeOverlayHtml"]),v(e,"className")&&(t.className=e.className??"",this.e.o.Gl(t.className)),R(e,t,["loading"]),v(e,"error")&&(t.error=e.error??null)}tp(e,t){this.fp(e,t),this.mp(e,t);let r=this.e.r;R(e,r,["autoCheckedChildren"]),F(e,r,"defaultExpandAll")&&(t.needsRowRebuild=!0),e.applyRowDrag!=null&&(r.applyRowDrag=e.applyRowDrag,t.cells=!0),v(e,"rowDragPolicy")&&(r.rowDragPolicy=e.rowDragPolicy,t.cells=!0),R(e,r,["suppressWarnings"])}fp(e,t){let r=this.e.r;if(F(e,r,"rowSelection")&&(this.e.f.su(),t.header=!0,t.pool=!0,this.e.En()),e.quickFilterText!==void 0&&this.Mt(e.quickFilterText),e.defaultColDef!==void 0&&e.defaultColDef!==r.defaultColDef&&(r.defaultColDef={...er,...e.defaultColDef},t.needsColumnRebuild=!0),v(e,"columnTypes")&&e.columnTypes!==r.columnTypes&&(r.columnTypes=e.columnTypes??{},t.needsColumnRebuild=!0),v(e,"rowKey")){r.rowKey=e.rowKey;let i=e.rowKey;r.resolveRowId=i?({data:o})=>tr(i,o):void 0,t.needsRowRebuild=!0}}mp(e,t){let r=this.e.r;F(e,r,"masterDetail")&&(t.needsColumnRebuild=!0,t.needsRowRebuild=!0),F(e,r,"detailToggleColumn")&&(t.needsColumnRebuild=!0),F(e,r,"treeData")&&(t.needsRowRebuild=!0,t.needsColumnRebuild=!0,this.e.En()),F(e,r,"childrenKey")&&(t.needsRowRebuild=!0),R(e,r,["isTreeRowExpandable","loadTreeChildren"],!0)&&(t.cells=!0)}rp(e,t){let r=this.e.r;R(e,r,["aggFuncs"],!0)&&(t.needsRowRebuild=!0),R(e,r,["components","actionPolicy"],!0)&&(t.cells=!0),v(e,"features")&&(r.features=Array.isArray(e.features)?e.features:[],t.needsFeatureReload=!0),this.gp(e,t),this.yp(e,t)}gp(e,t){let r=this.e.r;v(e,"dataProcessor")&&this.e.Ul(e.dataProcessor)&&(t.needsRowRebuild=!0);let i=E(e.dataProcessorMinRows,1,!0);i!==void 0&&i!==r.dataProcessorMinRows&&(r.dataProcessorMinRows=i,t.needsRowRebuild=!0)}yp(e,t){let r=this.e.r;v(e,"persistence")&&(r.persistence=ze(e.persistence),t.needsStateLoad=!0)}ip(e,t){let r=this.e.r;ir(e,r)&&r.datasourceMode==="block"&&(t.datasourceChanged=!0),this.vp(e,t),this.bp(e,t),this.wp(e)}vp(e,t){let r=this.e.r;if(v(e,"datasourceMode")){let i=e.datasourceMode==="block"?"block":"sequential";i!==r.datasourceMode&&(r.datasourceMode=i,t.datasourceChanged=!0)}if(v(e,"datasourceRowCount")){let i=e.datasourceRowCount==null?null:E(e.datasourceRowCount,0,!0)??null;i!==r.datasourceRowCount&&(r.datasourceRowCount=i,t.datasourceChanged=!0)}}bp(e,t){let r=this.e.r;v(e,"datasource")&&e.datasource!==r.datasource&&(r.datasource=e.datasource,r.paginationEnabled=e.datasource==null&&r.paginationEnabled,t.datasourceChanged=!0,this.e.fr.Re()),R(e,r,["detailRowRenderer","isRowExpandable"],!0)&&(t.cells=!0)}wp(e){e.pinnedTopRowData!==void 0&&this.setPinnedRows("top",e.pinnedTopRowData),e.pinnedBottomRowData!==void 0&&this.setPinnedRows("bottom",e.pinnedBottomRowData)}np(e,t,r){let i=this.e.r;t.needsColumnRebuild?this.Cp(e,t):v(e,"advancedFilterModel")&&(t.filterChanged=this.e.i.nt(e.advancedFilterModel)),t.needsFeatureReload&&this.e.jl(i.features),this.Tp(t),t.filterChanged&&this.e.gs(!t.needsColumnRebuild),t.layout&&this.e.o.Eh(i.rowHeight,i.headerHeight),e.columnMenu!=null&&e.columnMenu!==r&&(t.header=!0),t.stateToApply&&this.Bl(t.stateToApply),t.pool&&(t.cells=void 0),t.overlays=!0,this.e.U(t)}Cp(e,t){t.columnDefsChanged&&!t.needsRowRebuild&&(this.e.$e(),this.e.l.stop(!0));let r=this.e.n.Er(this.e.r.columnDefs);t.filterChanged=this.e.i.Oc(v(e,"advancedFilterModel")?e.advancedFilterModel??null:void 0),r&&this.e.emit("sortChanged",{sortModel:this.e.n.te()},!1),this.e.si(),t.header=!1,t.pool=!1}Tp(e){let t=e.needsStateLoad||e.needsColumnRebuild,r=e.datasourceChanged||e.needsRowRebuild||e.columnDefsChanged||e.filterChanged,i=this.e.r.persistence?.sections,o=r&&(this.e.i.g||i?.length===1&&i[0]==="columns");t&&o&&this.e.ys(!e.needsStateLoad,!0),this.Dp(e,r),t&&!o&&this.e.ys(!e.needsStateLoad)}Dp(e,t){if(e.datasourceChanged){this.e.i.Ec();return}t&&(!this.e.i.g&&e.needsRowRebuild?this.it(this.e.r.rowData):this.e.i.To())}Uh(e={}){let t=this._l({...e,target:"csv",protectFormulas:!1});return Ui(t,e)}_l(e={}){let t=this.e.n.d().filter(U),r=e.includeHeader===!1?[]:[t.map(o=>o.colDef.headerName??o.colDef.field??o.id)];if(e.headersOnly)return r;let i=e.onlySelected?this.e.f.rr().sort((o,s)=>o.rowIndex-s.rowIndex):e.onlyAllDisplayed?this.e.i.At():this.e.i.Fa();return[...r,...i.filter(o=>!o.isDetail&&!o.isGroup).map(o=>t.map(s=>{let a=Ne(this.e,o,s,e.target??"xlsx");return e.protectFormulas===!1?a:pe(a)}))]}getState(){return{version:2,columns:this.e.n.la(!1),sortModel:this.e.n.te(),filterModel:this.e.i.We(),advancedFilterModel:this.e.i.Nr(),quickFilterText:this.e.i.Co(),pagination:{enabled:this.e.i.Ce,page:this.e.i.tr(),pageSize:this.e.r.paginationPageSize},selectedRowIds:this.e.f.Ro(),expandedRowIds:this.e.i.Jc(),expandedGroupIds:this.e.i.Zc()}}Bl(e,t={}){if(this.e.s())return;let r=q(e);if(!r){this.e.reportError(new TypeError("[MachTable] GridState must use the current version 2 schema."),"gridState.apply");return}let i=["columns","sort","filter","pagination","selection","expansion"],o=new Set(t.sections??i);this.e.l.stop(!0),this.xp(r,o),this.Ep(r,o),t.emitEvents!==!1&&this.Rp(o),o.has("columns")&&this.e.Cn()}xp(e,t){t.has("columns")&&this.e.n.da(e.columns??[]),t.has("sort")&&this.e.n.Sr(e.sortModel??[]),t.has("filter")&&(this.e.i.St(e.filterModel??{}),this.e.i.nt(e.advancedFilterModel),this.e.i.Mt(e.quickFilterText)),t.has("expansion")&&this.e.i.Qc(e.expandedRowIds??[],e.expandedGroupIds??[]),t.has("pagination")&&e.pagination&&(this.e.r.paginationEnabled=e.pagination.enabled&&!this.e.i.g,this.e.i.Oa(e.pagination.page,e.pagination.pageSize),this.e.fr.Re())}Ep(e,t){t.has("columns")&&this.e.si(),this.e.Sp()||(this.e.i.g?(t.has("sort")||t.has("filter"))&&this.e.i.Ea():this.e.i.I()),this.e.Y.vs(),this.e.Y.bs(),t.has("selection")&&this.e.f.Wa(e.selectedRowIds??[])}Rp(e){e.has("sort")&&this.e.emit("sortChanged",{sortModel:this.e.n.te()}),e.has("filter")&&this.e.gs(),e.has("pagination")&&this.e.i._r(this.e.r.paginationPageSize)}destroy(){let e=this.$l();for(let t of e)t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort),t.aborted||t.resolve();this.e.destroy()}},ea={rows:mn,columns:gn,selection:yn,editing:vn,filtering:Cn,sorting:Tn,pagination:Dn,hierarchy:xn,view:En,state:bn,io:Rn,diagnostics:wn};function Mn(n){let e=new Hr(n),t={};for(let[r,i]of Object.entries(ea)){let o;Object.defineProperty(t,r,{enumerable:!0,get:()=>o??(o=Object.freeze(i(e,n)))})}return Object.assign(t,{batch:r=>e.batch(r),whenReady:()=>n.whenReady(),getOption:r=>e.getOption(r),updateOptions:r=>e.updateOptions(r),on:(r,i)=>n.ce.on(r,i),destroy:()=>e.destroy(),isDestroyed:()=>n.s()}),rn(t,n),en(t,{suspend:()=>n.suspend(),resume:()=>t.view.refreshLayout(),canReplaceData:()=>!n.l.isEditing()&&n.K.getDirtyRowIds().length===0,readCell:(r,i)=>{let o=n.i.O(r),s=n.n.R(i);return o&&s?Cr(Ne(n,o,s,"clipboard")):""},writeInput:r=>n.pr(r.flatMap(({rowId:i,colId:o,value:s})=>{let a=n.i.O(i),l=n.n.R(o);return a&&l?[{node:a,column:l,oldValue:n.c(a,l),newValue:s}]:[]}))}),Object.freeze(t)}var ta={contains:"\u5305\u542B",notContains:"\u4E0D\u5305\u542B",equals:"=",notEquals:"\u2260",startsWith:"\u5F00\u5934",endsWith:"\u7ED3\u5C3E",blank:"\u4E3A\u7A7A",notBlank:"\u975E\u7A7A",lessThan:"<",lessThanOrEqual:"\u2264",greaterThan:">",greaterThanOrEqual:"\u2265",inRange:"\u8303\u56F4"};function Vr(n){if(!n)return"";if(n.type==="set")return`\u5DF2\u9009 ${n.values.length} \u9879`;let e=[];for(let r of n.conditions){let i=ta[r.match]??r.match,o=r.value,s="value2"in r?r.value2:void 0;r.match==="blank"||r.match==="notBlank"?e.push(i):r.match==="inRange"&&o!=null?e.push(`${i} ${o}~${s??o}`):o!=null&&String(o)!==""?e.push(`${i} ${o}`):e.push(i)}let t=n.operator==="or"?" \u6216 ":" \u4E14 ";return e.join(t)}function Br(n,e,t=!1){let r=0,i=n.length;for(;r<i;){let o=r+i>>1;n[o]<e||t&&n[o]===e?r=o+1:i=o}return r}var ye=class{constructor(){this.ue=new Float64Array(1)}update(e){let t=0,r=this.ue.length!==e.length+1;for(let o=0;o<e.length;o++)t+=e[o].currentWidth,!r&&this.ue[o+1]!==t&&(r=!0);if(!r)return!1;let i=new Float64Array(e.length+1);for(let o=0;o<e.length;o++)i[o+1]=i[o]+e[o].currentWidth;return this.ue=i,!0}ql(){return this.ue[this.ue.length-1]??0}qe(e){let t=Math.max(0,Math.min(Math.trunc(e),this.ue.length-1));return this.ue[t]??0}Mp(e){let t=Math.max(0,this.ue.length-1);return t===0?-1:Math.min(t-1,Math.max(0,Br(this.ue,Math.max(0,e),!0)-1))}Yl(e,t,r=2){let i=Math.max(0,this.ue.length-1);if(i===0||t<=0||this.ql()<=t)return{first:0,lastExcl:i};let o=Math.max(0,e),s=o+t,a=Math.max(0,Br(this.ue,o,!0)-1),l=Math.min(i,Br(this.ue,s));return{first:Math.max(0,a-r),lastExcl:Math.min(i,l+r)}}Rn(e,t,r){let i=t.indexOf(r);if(i<0)return;this.update(t);let o=this.qe(i),s=o+r.currentWidth;o<e.scrollLeft?e.scrollLeft=o:s>e.scrollLeft+e.clientWidth&&(e.scrollLeft=s-e.clientWidth)}};var ra=".mach-header-resize, .mach-filter-btn, .mach-menu-btn, .mach-select-all";function _r(n){return n instanceof HTMLElement&&n.closest(ra)!=null}function zr(n){return n==="ArrowLeft"||n==="ArrowRight"}function In(n,e){typeof e=="string"?n.classList.add(e):Array.isArray(e)&&n.classList.add(...e)}var Gt=class{constructor(e){this.e=e;this.se=[];this.ws=[];this.N=new ye;this.mt=0;this.Vt=Number.MAX_SAFE_INTEGER}Sn(){this.Xl(),this.e.di.Nt(),this.mr(!1);let e=this.e.n,t=e.uc();this.e.o.Ll(t);let r=new Set(e.y("center").slice(this.mt,this.Vt)),i=e.cc(),o=this.e.r.headerHeight;for(let s of w){let a=this.e.o.ri[s];for(let d of a)d.textContent="";let l=(d,c)=>{let u=a[Math.min(c,a.length-1)];for(let h of d)if(h instanceof Z){let p=this.se.length;if(l(h.children,c+1),this.se.length===p)continue;let m=this.Ip(h);u.appendChild(m),this.ws.push({group:h,el:m,pane:s})}else if(!h.hide&&e.Be(h)===s&&(s!=="center"||r.has(h))){let p=this.Ap(h,t-c,o);u.appendChild(p.el),this.se.push(p)}};l(i,0)}this.e.r.suppressHeaderFocus||this.se.forEach((s,a)=>{s.el.tabIndex=a===0?0:-1}),this.gt(),this.vs(),this.bs(),this.zi()}Jl(){let e=this.mt,t=this.Vt;this.Xl(),(e!==this.mt||t!==this.Vt)&&this.Sn()}Xl(){let e=this.e.n.y("center"),t=this.e.o.T.center;this.N.update(e);let r=e.length>20?this.N.Yl(t.scrollLeft,t.clientWidth,2):{first:0,lastExcl:e.length};this.mt=r.first,this.Vt=r.lastExcl}Ap(e,t,r){let i=f("div","mach-header-cell mach-header-cell--leaf");e.hasCheckbox&&i.classList.add("mach-header-cell--selection"),i.dataset.colId=e.id,i.setAttribute("role","columnheader"),i.style.height=`${t*r}px`,this.kp(i,e),this.Gp(i,e);let o=this.Pp(i,e);this.Lp(i,e);let s=f("span","mach-sort-indicator");i.appendChild(s);let{filterBtn:a,filterTagEl:l}=this.Np(i,e);return this.Fp(i,e),this.Op(i,e),this.Hp(i,e),{column:e,el:i,sortEl:s,filterBtn:a,filterTagEl:l,selectAllEl:o}}kp(e,t){let r=t.colDef;In(e,r.headerClass),r.headerTooltip&&e.setAttribute("title",r.headerTooltip);let i=r.headerAlign??r.align;i==="center"?e.classList.add("mach-header-cell--center"):i==="right"&&e.classList.add("mach-header-cell--right")}Gp(e,t){this.e.r.suppressHeaderFocus||(e.tabIndex=-1,e.addEventListener("mousedown",()=>this.Cs(t)),e.addEventListener("keydown",r=>this.Vp(r,t)))}Pp(e,t){if(!t.hasCheckbox||this.e.r.rowSelection!=="multiple")return;let r=document.createElement("input");return r.type="checkbox",r.className="mach-select-all",r.setAttribute("aria-label","select all rows"),r.addEventListener("click",i=>i.stopPropagation()),r.addEventListener("change",()=>{r.checked?this.e.f.selectAll(!0):this.e.f.deselectAll()}),e.appendChild(r),r}Lp(e,t){let r=t.colDef,i;try{i=r.headerComponent?.({colDef:r,column:t,api:this.e.api})}catch(s){this.e.reportError(s,"headerComponent",{colId:t.id}),i=null}i instanceof HTMLElement&&(i={el:i});let o=f("span","mach-header-label");i&&typeof i=="object"&&i.el instanceof HTMLElement?(o.classList.add("mach-header-label--custom"),o.appendChild(i.el),$e(e,i.destroy)):o.textContent=typeof i=="string"?i:r.headerName??r.field??t.id,e.appendChild(o)}Np(e,t){if(!t.filterable)return{};let r=document.createElement("button");r.type="button",r.className="mach-filter-btn",r.setAttribute("aria-label",`filter ${t.id}`),r.innerHTML=ii,r.addEventListener("click",o=>{o.stopPropagation(),this.e.Ts.toggle(t,r)}),e.appendChild(r);let i=f("span","mach-filter-tag");return e.appendChild(i),{filterBtn:r,filterTagEl:i}}Fp(e,t){if(!this.e.r.columnMenu||t.hasCheckbox||t.colDef.suppressColumnMenu)return;let r=document.createElement("button");r.type="button",r.className="mach-menu-btn";let o=`${t.colDef.headerName??t.colDef.field??t.id} \xB7 ${this.e.v("columnSettings")}`;r.setAttribute("aria-label",o),r.title=o,r.innerHTML=si,r.addEventListener("click",s=>{s.stopPropagation(),this.e.columnMenu.toggle(t,r)}),e.appendChild(r)}Op(e,t){if(!this.Zl(t))return;let r=f("div","mach-header-resize");r.setAttribute("aria-hidden","true"),r.addEventListener("pointerdown",i=>{i.button===0&&(i.preventDefault(),i.stopPropagation(),this.e.di.fu(i,t))}),r.addEventListener("dblclick",i=>{i.stopPropagation(),this.e.api.columns.autoSize(t.id)}),r.addEventListener("click",i=>i.stopPropagation()),e.appendChild(r)}Hp(e,t){e.addEventListener("click",r=>{this.e.Mn.wu()||_r(r.target)||t.sortable&&this.e.Ii(t,r.shiftKey)}),e.addEventListener("pointerdown",r=>{r.button!==0||_r(r.target)||this.e.Mn.bu(r,t)})}Ip(e){let t=f("div","mach-header-cell mach-header-cell--group");e.groupId&&(t.dataset.groupId=e.groupId),t.setAttribute("role","columnheader"),In(t,e.def.headerClass);let r=f("span","mach-header-label mach-header-label--group");return r.textContent=e.headerName,t.appendChild(r),t}gt(){let e={left:0,center:0,right:0};for(let t of w){let r=this.e.o.ri[t],i=0,o=new Map;for(let a of this.e.n.y(t))o.set(a.id,i),i+=a.currentWidth;let s=this.e.r.headerHeight;for(let a of this.se){if(this.e.n.Be(a.column)!==t)continue;let l=o.get(a.column.id)??0;a.el.style.width=`${a.column.currentWidth}px`,a.el.style.left=`${l}px`,a.el.setAttribute("aria-colindex",String(this.e.n.Q(a.column.id)+1))}for(let a of this.ws){if(a.pane!==t)continue;let l=a.group.getLeafColumns().filter(u=>!u.hide&&this.e.n.Be(u)===t);if(l.length===0)continue;let d=o.get(l[0].id)??0,c=0;for(let u of l)c+=u.currentWidth;a.el.style.left=`${d}px`,a.el.style.width=`${c}px`,a.el.style.height=`${s}px`,a.el.setAttribute("aria-colspan",String(l.length))}for(let a of r)a.style.width=`${i}px`;e[t]=i}this.e.o.xh(e.left,e.right)}Vp(e,t){this.e.s()||this.Bp(e,t)||this._p(e,t)||this.zp(e,t)||this.Wp(e,t)||this.$p(e)}Bp(e,t){return e.key!=="Enter"&&e.key!==" "?!1:(_r(e.target)||(e.preventDefault(),t.sortable&&this.e.Ii(t,e.shiftKey)),!0)}_p(e,t){if(!e.altKey||!zr(e.key))return!1;if(!this.Zl(t))return!0;let r=e.key==="ArrowRight"?24:-24;return this.e.n.Me(t,t.currentWidth+r),this.e.ir(),this.e.st([t]),e.preventDefault(),!0}zp(e,t){if(!e.ctrlKey||!zr(e.key))return!1;if(!t.movable)return!0;e.preventDefault();let r=this.e.n.Be(t),i=this.e.n.y(r),o=i.indexOf(t),s=e.key==="ArrowRight"?1:-1,a=Math.max(0,Math.min(i.length-1,o+s));return a!==o&&this.e.Rr(t.id,a),!0}Wp(e,t){if(e.altKey||e.ctrlKey||e.metaKey||!zr(e.key))return!1;e.preventDefault();let r=this.e.n.d(),i=r.indexOf(t);if(i<0)return!0;let o=e.key==="ArrowRight"?1:-1,s=Math.max(0,Math.min(r.length-1,i+o));return this.Cs(r[s]),!0}$p(e){if(e.key!=="Home"&&e.key!=="End")return!1;e.preventDefault();let t=this.e.n.d();if(t.length===0)return!0;let r=e.key==="Home"?0:t.length-1;return this.Cs(t[r]),!0}Cs(e){let t=this.se.find(r=>r.column.id===e.id);if(!t&&!e.pinned&&(this.Rn(e),this.Jl(),t=this.se.find(r=>r.column.id===e.id)),!!t){for(let r of this.se)r.el.tabIndex=r===t?0:-1;t.el.focus({preventScroll:!0})}}Rn(e){this.N.Rn(this.e.o.T.center,this.e.n.y("center"),e)}Zl(e){return this.e.r.enableColumnResize&&e.resizable}vs(){let e=this.e.n.te(),t=e.length>1;for(let r of this.se){let i=e.findIndex(o=>o.colId===r.column.id);if(i>=0){let o=e[i].direction,s=t?`<span class="mach-sort-badge">${i+1}</span>`:"";r.sortEl.innerHTML=(o==="asc"?ni:oi)+s,r.el.setAttribute("aria-sort",o==="asc"?"ascending":"descending"),r.el.classList.add("mach-header-cell--sorted")}else r.sortEl.innerHTML="",r.el.removeAttribute("aria-sort"),r.el.classList.remove("mach-header-cell--sorted")}}bs(){let e=this.e.i.We();for(let t of this.se){if(!t.filterBtn)continue;let r=e[t.column.id],i=r!=null;if(t.filterBtn.classList.toggle("mach-filter-btn--active",i),t.filterTagEl){let o=i?Vr(r):"";t.filterTagEl.style.display=o?"":"none",o&&(t.filterTagEl.textContent=o)}}}zi(){for(let e of this.se){if(!e.selectAllEl)continue;let{all:t,some:r}=this.e.f.cu();e.selectAllEl.checked=t,e.selectAllEl.indeterminate=r}}destroy(){this.mr(!0)}mr(e){for(let t of this.se){let r=Ke(t.el);if(r)try{r()}catch(i){e?console.error("[mach-table] headerComponent destroy error",i):this.e.reportError(i,"headerComponent.destroy",{colId:t.column.id})}}this.se=[],this.ws=[]}};var Pt=class{constructor(){this.he=null;this.Ye=null;this.gr=!1;this.Ds=-1;this.xs=-1}Kp(){return this.he}Es(){return this.Ye}Up(){return this.he!=null}start(e,t){(!t||!this.he)&&(this.he={...e}),this.Ye={...e},this.Zt()}jp(e){return this.he?!0:e.colIdx<0?!1:(this.he={...e},this.Zt(),!0)}setEnd(e){this.Ye={...e},this.Zt()}clear(){this.he=null,this.Ye=null,this.Zt()}Zt(){this.gr=!1,this.Ds=-1,this.xs=-1}normalize(e,t){return this.gr!==!1&&this.Ds===e&&this.xs===t?this.gr:(this.Ds=e,this.xs=t,!this.he||!this.Ye||e<=0||t<=0?(this.gr=null,null):(this.gr={r1:Math.max(0,Math.min(this.he.row,this.Ye.row,e-1)),r2:Math.max(0,Math.min(Math.max(this.he.row,this.Ye.row),e-1)),c1:Math.max(0,Math.min(this.he.colIdx,this.Ye.colIdx,t-1)),c2:Math.max(0,Math.min(Math.max(this.he.colIdx,this.Ye.colIdx),t-1))},this.gr))}};var Lt=class{constructor(e){this.host=e;this.Fe=null;this.le=0;this.In=0;this.Wr=e=>{let t=this.Fe;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(r=>r.classList.toggle("mach-row--drag-source",this.sourceContains(r.dataset.id??"")))}this.Ql()}};this.Jp=()=>{if(this.le=0,!!this.Fe?.active){if(!this.current()){this.destroy();return}this.$r(),this.Zp()&&this.Ql()}};this.nr=e=>{let t=this.Fe;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.$r(),this.ed();try{t.active&&t.drop?.valid&&this.Rs(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.qp=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.qi=e=>{e.type==="pointercancel"&&e.pointerId!==this.Fe?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(i=>{let o=f("div","mach-row-drop-indicator");return o.hidden=!0,i.append(o),o}),r=f("div","mach-row-drag-preview");r.setAttribute("role","status"),r.hidden=!0,this.host.root.append(r),this.Fe={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:r,drop:null,active:!1},this.Ur(!0)}Ur(e){S(window,e,{pointermove:this.Wr,pointerup:this.nr,pointercancel:this.qi,keydown:this.qp,blur:this.qi})}Yp(e){return this.Fe?.active===!0&&this.sourceContains(e)}Xp(e,t=()=>!0){this.In=requestAnimationFrame(()=>{this.In=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(r=>r.closest(".mach-row")?.dataset.id===e)?.focus()})}Ql(){this.le||(this.le=requestAnimationFrame(this.Jp))}Rs(e,t,r=0){let i=this.host.body.getBoundingClientRect();return e>=i.left&&e<=i.right&&t>=i.top-r&&t<=i.bottom+r}Zp(){let e=this.Fe;if(!e||!this.Rs(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,r=t.getBoundingClientRect(),i=Math.min(36,r.height/3);if(i<=0)return!1;let o=e.clientY<r.top+i?-Math.ceil(14*T((r.top+i-e.clientY)/i,0,1)):Math.ceil(14*T((e.clientY-r.bottom+i)/i,0,1));if(this.host.scrollBy)return this.host.scrollBy(o);let s=t.scrollTop;return t.scrollTop=T(s+o,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}$r(){let e=this.Fe;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,r=this.describe(t);e.drop=r;let i=this.Rs(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!i||!r?.valid,!r)continue;s.dataset.dropPosition=r.position??"",s.style.cssText=r.style??"";let a=parseFloat(s.parentElement.style.height),l=Math.min(this.host.getRowTop(r.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${l}px, 0)`}let o=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=i?r?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${T(e.clientX-o.left+16,8,Math.max(8,o.width-224))}px, ${T(e.clientY-o.top+16,8,Math.max(8,o.height-48))}px, 0)`}ed(){let e=this.Fe;this.Fe=null,this.Ur(!1),cancelAnimationFrame(this.le),this.le=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.ed(),this.release(),cancelAnimationFrame(this.In),this.In=0}};function An(n,e,t,r,i){let o=r==="before"?-1:1,s=t.rowIndex+o,a=e(s);for(;a&&(a===n||a.isDetail);)s+=o,a=e(s);let l=a&&!a.loading?a.id:null;return{rowIds:[n.id],targetId:t.id,position:r,beforeId:r==="before"?l:t.id,afterId:r==="before"?t.id:l,expectedRevision:i}}var Nt=class extends Lt{constructor(t,r,i,o){super({get root(){return t.o.root},get body(){return t.o.Le},get viewport(){return t.o.T.center},get containers(){return Object.values(t.o.Ee)},getRowTop:r,findRowAt:i,scrollBy:o});this.e=t;this.Bt=null}rd(t){return!t.loading&&!t.treeLoading&&!t.isGroup}nd(t){if(this.e.l.isEditing()||t.isDetail||!this.rd(t)||t.data==null||this.e.n.Je().length||this.e.r.applyRowDrag&&!this.e.i.Ba())return!1;let r=this.yr("canDrag",()=>this.e.r.rowDragPolicy?.canDrag?.({node:t,api:this.e.api})??!0,!1);return r!==!0?r:!this.e.i.F||!!kr(this.e.api)}canDrag(t){return this.nd(t)===!0}isSource(t){return this.Ss()?.isSource(t)??this.Yp(t.id)}start(t,r){if(this.destroy(),!this.canDrag(r)||t.isPrimary===!1)return;let i=this.Ss();if(i){i.start(t,r);return}let o=this.yr("getRevision",()=>this.Ms(r),null);o&&(this.Bt={node:r,from:r.rowIndex,guard:o},this.begin(t))}moveWithKeyboard(t,r){if(!t.altKey||t.key!=="ArrowUp"&&t.key!=="ArrowDown"||(t.preventDefault(),t.stopPropagation(),!this.canDrag(r)))return;let i=this.Ss();if(i){i.moveWithKeyboard(t,r);return}let o=t.key==="ArrowUp"?-1:1,s=r.rowIndex+o;for(;this.e.i.h(s)?.isDetail;)s+=o;let a=this.e.i.h(s),l=this.yr("getRevision",()=>this.Ms(r),null);if(!(!a||!l)){this.Bt={node:r,from:r.rowIndex,guard:l};try{this.commitDrop(this.destination(a,o>0))&&this.Xp(r.id)}finally{this.release()}}}yr(t,r,i){try{return r()}catch(o){return this.e.reportError(o,`rowDragPolicy.${t}`),i}}Ms(t){let r=this.e.i,i=this.e.n.ee(),o=this.e.r.rowDragPolicy,s=r.ze(),a=r.Lr(),l=this.e.r.applyRowDrag,d=o?.getRevision?.();return{revision:d,current:()=>this.yr("getRevision",()=>o?.getRevision?.()===d&&s===r.ze()&&a===r.Lr()&&r.O(t.id)===t&&i===this.e.n.ee()&&o===this.e.r.rowDragPolicy&&l===this.e.r.applyRowDrag,!1)}}Ss(){let t=kr(this.e.api);return t!==this.td&&(this.An?.destroy(),this.td=t,this.An=t?this.yr("driver",()=>t({...this.host,api:this.e.api,capture:r=>this.Ms(r),emit:(r,i,o,s,a)=>{this.e.emit("rowDragEnd",{rowNode:r,fromIndex:i,toIndex:o,targetIndex:s,applied:!1,intent:a})},report:(r,i)=>this.e.reportError(r,`rowDragPolicy.${i}`)}),void 0):void 0),this.An}current(){return this.Bt?.guard.current()??!1}release(){this.Bt=null}sourceContains(t){return this.Bt?.node.id===t}outsideText(){return this.e.r.locale.rowDragOutside??x.rowDragOutside}describe(t){let r=T(this.host.findRowAt(t),0,this.e.i.P()-1),i=this.e.i.h(r);if(i?.isDetail&&(i=this.e.i.O(i.masterId)),!i)return null;let o=this.host.getRowTop(i.rowIndex),s=this.host.getRowTop(i.rowIndex+1);return this.destination(i,t>=(o+s)/2)}destination(t,r){let i=this.Bt,o=t.rowIndex+Number(r);for(;this.e.i.h(o)?.isDetail;)o++;let s=this.e.r.rowDragPolicy,a=!this.e.r.applyRowDrag||s?.canDrop?An(i.node,u=>this.e.i.h(u),t,r?"after":"before",i.guard.revision):void 0,l=s?.canDrop&&a?this.yr("canDrop",()=>s.canDrop({node:i.node,api:this.e.api,targetNode:t,intent:a}),!1):!0,d=l===!0&&this.rd(t),c=typeof l=="string"?l:Me(this.e.r.locale.rowDragPosition??x.rowDragPosition,i.from+1,this.od(i.from,o)+1);return{node:t,intent:a,boundary:o,valid:d,text:c,position:r?"after":"before"}}commitDrop(t){let r=this.Bt;if(!r||!this.current()||!this.canDrag(r.node)||!this.current())return!1;let i=this.destination(t.node,t.boundary>t.node.rowIndex);if(!i.valid||!this.current())return!1;let o=i.boundary>r.from?i.boundary-1:i.boundary;for(;this.e.i.h(o)?.isDetail;)o--;if(r.from===o)return!1;let s=this.e.r.applyRowDrag&&this.e.i._a(r.from,o);return this.e.r.applyRowDrag&&!s?!1:(this.e.emit("rowDragEnd",{rowNode:r.node,fromIndex:r.from,toIndex:i.boundary,targetIndex:s?r.node.rowIndex:this.od(r.from,i.boundary),applied:s,intent:i.intent}),!0)}od(t,r){let i=t+1;for(;this.e.i.h(i)?.isDetail;)i++;return r>t?r-(i-t):r}destroy(){this.An?.destroy(),super.destroy()}};var ia=new Set(["warning","danger","success","info"]);function He(n,e,t=null){if(!(e.data==null||e.isGroup||e.isDetail||e.loading))for(let r of n.r.rowStyleRules)try{if(r.when({data:e.data,node:e,api:n.api,rowPinned:t})===!0)return r}catch(i){n.reportError(i,"rowStyleRules",{rowId:e.id})}}function ve(n,e){n.style.removeProperty("--mach-row-rule-bg"),n.style.removeProperty("--mach-row-rule-fg"),e?.tone&&ia.has(e.tone)?n.dataset.rowTone=e.tone:delete n.dataset.rowTone,e?.backgroundColor&&n.style.setProperty("--mach-row-rule-bg",e.backgroundColor),e?.color&&n.style.setProperty("--mach-row-rule-fg",e.color),n.classList.toggle("mach-row--styled",!!e)}var Ft=class{constructor(){this.ae=new Float64Array(0);this.vr=new Float64Array(1);this.Is=new WeakMap;this._t=new Map;this.yt=0}reset(e,t){this.ae=new Float64Array(e.length),this.vr=new Float64Array(e.length+1),this.Is=new WeakMap,this._t=new Map,this.yt=0;for(let r=0;r<e.length;r++){this.Is.set(e[r],r);let i=Math.max(1,t(e[r],r));this.ae[r]=i,this.As(i,1),this.add(r,i)}}get length(){return this.ae.length}indexOf(e){return this.Is.get(e)??-1}update(e,t){if(e<0||e>=this.ae.length)return!1;let r=Math.max(1,t),i=r-this.ae[e];return Math.abs(i)<.01?!1:(this.As(this.ae[e],-1),this.ae[e]=r,this.As(r,1),this.add(e,i),!0)}qe(e){let t=Math.max(0,Math.min(Math.trunc(e),this.ae.length)),r=0;for(;t>0;)r+=this.vr[t],t-=t&-t;return r}ks(){return this.qe(this.ae.length)}Qp(){return this.yt}findIndex(e){if(this.ae.length===0)return 0;let t=Math.max(0,e),r=0,i=0,o=1;for(;o<<1<=this.ae.length;)o<<=1;for(;o>0;){let s=r+o;s<=this.ae.length&&i+this.vr[s]<=t&&(r=s,i+=this.vr[s]),o>>=1}return Math.min(r,this.ae.length-1)}add(e,t){for(let r=e+1;r<this.vr.length;r+=r&-r)this.vr[r]+=t}As(e,t){let r=(this._t.get(e)??0)+t;if(r<=0?this._t.delete(e):this._t.set(e,r),this._t.size===0)this.yt=0;else if(t>0&&(this.yt===0||e<this.yt))this.yt=e;else if(t<0&&e===this.yt&&!this._t.has(e)){let i=Number.POSITIVE_INFINITY;for(let o of this._t.keys())i=Math.min(i,o);this.yt=Number.isFinite(i)?i:0}}};var na=16e6,Ot=class{constructor(){this.height=0;this.zt=0;this.br=0;this.kn=NaN;this.Gs=0}configure(e,t,r=!0){this.height=r?Math.min(e,na):e,this.zt=Math.max(0,e-t),this.br=Math.max(0,this.height-t),this.kn=NaN}get vt(){return this.zt>this.br}ef(e){return this.zt?T(e,0,this.zt)*this.br/this.zt:0}read(e){return e!==this.kn&&(this.kn=e,this.Gs=this.br>0?T(e,0,this.br)*this.zt/this.br:0),this.Gs}anchor(e,t){this.Gs=T(e,0,this.zt),this.kn=t}};function kn(n){return!!n&&!n.hasCheckbox&&!n.isDetailToggle&&!n.colDef.rowDrag}function oa(n){let e=n.length>1&&n.every(i=>typeof i=="number"&&!Number.isNaN(i)),t=e?(n[n.length-1]-n[0])/(n.length-1):0,r=!e||n.every(i=>Number.isInteger(i));return{difference:t,integer:r,numeric:e,values:n}}function sa(n,e){let t=n.values.length;if(t===1)return n.values[0];if(!n.numeric)return n.values[e%t];let r=n.values[t-1]+n.difference*(e-t+1);return n.integer?Math.round(r):Math.round(r*1e6)/1e6}var Ht=class{constructor(e){this.e=e;this.m=[];this.bt=0;this.Xe=-1;this.ne=0;this.Ps=0;this.Ls=0;this.sd=0;this.S=new Ot;this.wt=0;this.Ns=!1;this.Gn=-1;this.j=new Ft;this.N=new ye;this.pe=new Pt;this.Pn=!1;this.Nn=[];this.mt=0;this.Vt=0;this.Fs=!1;this.b=null;this.Os=()=>{this.ne||(this.ne=requestAnimationFrame(()=>{this.ne=0,this.Tn()}))};this.Bn=0;this._n=new WeakMap;this.$t=new Set;this.zn="";this.Ct=!1;this.ci=[];this.Se=null;this.ud="";this.Vs="";this.hd=0;this.pd=0;this.Hs=e=>{if(e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||!e.deltaY||!e.cancelable)return;let t=this.e.o.T.center,r=e.deltaMode===1?this.e.r.rowHeight:e.deltaMode===2?t.clientHeight:1,i=this.S.read(t.scrollTop);this.Wn(i+e.deltaY*r),this.S.read(t.scrollTop)!==i&&(e.preventDefault(),t.scrollLeft+=e.deltaX*r,this.Os())};this.Hn=null;this.pi=null;this.Ks=!1;this.em=e=>{let t=this.pi;if(!t)return;let r=e;if(typeof r.clientX!="number")return;if(!t.active){let o=Math.abs(r.clientX-t.startX),s=Math.abs(r.clientY-t.startY);if(o<4&&s<4)return;t.active=!0,t.axis=o>=s?"h":"v",this.e.o.root.classList.add("mach-root--filling")}let i=t.axis!=="v";this.Fd(i,i?Math.max(t.c2+1,this.Nd(r)):this.Ld(r),!0)};this.tm=e=>{let t=this.pi;if(!t)return;let r=e;if(!t.active){this.On();return}let i=t.axis==="h",o=i?t.c2:t.r2,s=o;i?s=Math.max(o+1,typeof r.clientX=="number"?this.Nd(r):o+1):typeof r.clientY=="number"&&(s=this.Ld(r)),this.On(),s>o?(this.rm(t,s,i),this.wr()):this.Fd(i,o,!1)};this.rf=e=>{if(this.e.s())return;let t=e.target,r=this.jt(e);if(r&&!t.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-row-drag-handle")&&!(e.detail>1&&this.e.l.tn())){if(this.e.l.tn()){let i=r.cellEl?.dataset.colId??"";if(this.e.l.isEditing(r.index,i))return;let o=i?this.e.n.R(i):void 0;this.e.l.ll(r.node,o).then(s=>{if(!s||this.e.s())return;this.Vd(e,t,{...r,index:r.node.rowIndex});let a=i?this.e.n.R(i):void 0;a&&!this.e.l.tn()&&this.e.l.start(r.node.rowIndex,a)});return}this.Vd(e,t,r)}};this.nf=e=>{if(this.e.s()||e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell"))return;let t=this.jt(e);if(!t)return;let{node:r,index:i,cellEl:o}=t;if(r.isDetail||r.isGroup||!o)return;let s=o.dataset.colId??"",a=this.e.n.R(s);if(!a)return;let l=this.e.c(r,a),d=this.e.emit("cellDoubleClicked",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:l});a.colDef.onCellDoubleClick?.(d),this.e.emit("rowDoubleClicked",{event:e,rowNode:r,rowIndex:i}),this.e.l.oe(r,a)&&this.e.l.start(i,a)};this.of=e=>{if(this.e.s())return;let t=this.jt(e);if(!t||t.node.isDetail||t.node.isGroup||!t.cellEl)return;let{node:r,index:i,cellEl:o}=t,s=o.dataset.colId??"",a=this.e.n.R(s);if(a&&(this.e.emit("cellContextMenu",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:this.e.c(r,a)}),this.e.r.contextMenu)){if(e.preventDefault(),this.e.r.enableRangeSelection&&!this.Te()){let l=this.e.n.Q(s);l>=0&&this.$s(i,l,!1)}this.e.Us.open(e.clientX,e.clientY,{rowIndex:i,colId:s})}};this.sf=e=>{if(!this.hm(e)&&this.e.r.enableRangeSelection&&e.button===0){let t=this.jt(e);if(t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl&&!t.cellEl.classList.contains("mach-cell--selection")){let r=this.e.n.Q(t.cellEl.dataset.colId??"");r>=0&&(this.$s(t.index,r,e.shiftKey),this.Pn=!0,!e.shiftKey&&!this.e.r.suppressCellFocus&&this.Ge(t.index,t.cellEl.dataset.colId??""))}}};this.ld=()=>{this.Pn=!1};this.cn=e=>{if(this.e.s())return;let t=this.jt(e);if(this.Pn&&t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl){let r=this.e.n.Q(t.cellEl.dataset.colId??""),i=this.pe.Es();r>=0&&i&&(i.row!==t.index||i.colIdx!==r)&&this.$s(t.index,r,!0)}this.e.r.suppressRowHoverHighlight||!t||t.node.isDetail||this.Od(t.index)};this.af=()=>{this.Od(-1)};this.lf=e=>{if(this.e.s()||e.button!==0||!e.target.closest(".mach-row-drag-handle"))return;let r=this.jt(e);!r||r.node.isDetail||r.node.isGroup||(this.Wt.start(e,r.node),e.preventDefault())};this.df=e=>{if(!e.target.closest(".mach-row-drag-handle"))return;let t=this.jt(e);t&&this.Wt.moveWithKeyboard(e,t.node)};this.Wt=new Nt(e,t=>this.Oe(t)-this.wt,t=>this.Fn(t+this.wt,this.e.i.P()),t=>this.tf(t))}init(){let e=this.e.o.T.center;this.Ps=e.scrollLeft,this.Ls=e.scrollTop,e.addEventListener("scroll",this.Os,{passive:!0}),this.ad(!0),window.addEventListener("mouseup",this.ld)}ad(e){S(this.e.o.Le,e,{click:this.rf,dblclick:this.nf,contextmenu:this.of,mousedown:this.sf,mouseover:this.cn,mouseleave:this.af,pointerdown:this.lf,keydown:this.df})}suspend(){cancelAnimationFrame(this.ne),this.ne=0,this.On(),this.Wt.destroy(),this.Pn=!1}destroy(){cancelAnimationFrame(this.ne);let e=this.e.o.T.center;e.removeEventListener("scroll",this.Os),e.removeEventListener("wheel",this.Hs),this.ad(!1),window.removeEventListener("mouseup",this.ld),this.On(),this.Wt.destroy(),this.dd(!1),this.Hn?.remove(),this.ci=[],this.$t.clear(),this.j.reset([],()=>this.e.r.rowHeight),this.N.update([]),this.Se?.remove(),this.Se=null}Po(e){return this.e.n.Be(e)}Tn(e=!1){if(this.e.s())return;let t=this.e.o,r=t.T.center,i=r.scrollLeft,o=r.scrollTop,s=this.S.read(o),a=e||i!==this.Ps,l=e||o!==this.Ls||s!==this.sd;!a&&!l||(this.Ps=i,this.Ls=o,this.sd=s,a&&(t.sr.center.style.transform=`translate3d(${-i}px, 0, 0)`,this.e.Y.Jl(),this.e.Ne.cf(i)),l&&this.cd(o),this.e.Vn.hide(),this.li(!1,a),l&&this.e.i.xc(this.Xe-1))}uf(){let e={left:0,center:0,right:0};for(let t of w)e[t]=this.e.n.y(t).reduce((r,i)=>r+i.currentWidth,0);return e}Dn(){let e=this.e.o,t=this.uf();this.N.update(this.e.n.y("center")),t.center=this.N.ql();let r=this.e.i.At(),i=this.hf(r.length);this.pf(r,i);let o=this.ff(i);this.mf(o),this.gf(t,o),e.root.setAttribute("aria-rowcount",String(i.rowCount+e.Ol()))}hf(e){let t=this.e.i.Pr(),r=this.e.r.rowHeight,i=this.e.r.masterDetail?[]:this.yf();i.length&&this.vf();let o=this.e.r.datasourceMode!=="block"&&(this.e.r.masterDetail||this.e.r.getRowHeight!=null||i.length>0),s=o?this.bf(r,i):`fixed|${r}`;return{autoHeightColumns:i,positionedCount:Math.min(t,e),rowCount:t,rowHeight:r,signature:s,variable:o}}bf(e,t){let r=t.map(i=>`${i.id}:${i.currentWidth}`).join(",");return`${this.e.i.Lr()}|${e}|${this.e.r.detailRowHeight}|${r}`}pf(e,t){if(!t.variable){this.wf(t);return}if(t.signature!==this.zn||this.j.length!==t.positionedCount){let r=e.slice(0,t.positionedCount);this.j.reset(r,i=>this.fd(i,t.autoHeightColumns)),this.md(t);return}if(this.$t.size!==0){for(let r of this.$t){let i=this.j.indexOf(r);i>=0&&this.j.update(i,this.fd(r,t.autoHeightColumns))}this.md(t)}}wf(e){this.j.length>0&&this.j.reset([],()=>e.rowHeight),this.zn=e.signature,this.$t.clear(),this.Bn=e.rowHeight}md(e){this.zn=e.signature,this.$t.clear(),this.Bn=this.j.Qp()||e.rowHeight}ff(e){return(e.variable?this.j.ks():e.positionedCount*e.rowHeight)+Math.max(0,e.rowCount-e.positionedCount)*e.rowHeight}gf(e,t){let r=this.e.o,i=r.T.center,o=this.S.read(i.scrollTop),s=this.S.vt;this.S.configure(t,i.clientHeight,!this.Ct);let a=Math.max(0,i.clientWidth-e.left-e.right),l=Math.max(e.center,a);for(let d of w){let c=r.Ee[d];c.style.height=`${this.S.height}px`,c.style.overflow=this.S.vt?"hidden":"",d==="center"&&(c.style.width=`${l}px`)}(s||this.S.vt)&&this.Wn(o),this.cd(i.scrollTop),this.Ns!==this.S.vt&&(this.Ns=this.S.vt,this.Ns?i.addEventListener("wheel",this.Hs,{passive:!1}):i.removeEventListener("wheel",this.Hs))}Wn(e){let t=this.e.o.T.center;t.scrollTop=this.S.ef(e),this.S.anchor(e,t.scrollTop)}cd(e){let t=this.S.vt;for(let r of["left","right"]){let i=this.e.o.Ee[r].style;i.top=t?`${-e}px`:"",i.transform=t?"":`translate3d(0, ${-e}px, 0)`}}tf(e){let t=this.e.o.T.center,r=this.S.read(t.scrollTop);this.Wn(r+e);let i=this.S.read(t.scrollTop)!==r;return i&&this.Tn(),i}Ki(e){this._n.delete(e),this.$t.add(e)}mf(e){let{Le:t,T:r}=this.e.o,{domLayout:i,maxBodyHeight:o}=this.e.r,s=i==="autoHeight",a=Math.min(e,o??e);this.Ct=s&&a===e,t.style.height=s?`${a}px`:"",r.center.style.overflowY=s&&!this.Ct?"auto":"",this.Ct&&r.center.scrollTop&&(r.center.scrollTop=0)}It(){this._n=new WeakMap,this.$t.clear(),this.zn=""}fd(e,t){if(e.isDetail)return this.e.r.detailRowHeight;let r=this._n.get(e);if(r!==void 0)return r;let i=this.e.r.rowHeight,o=this.e.r.getRowHeight;if(o)try{let s=o({data:e.data,node:e,api:this.e.api});i=Number.isFinite(s)?Math.max(1,s||i):i}catch(s){this.e.reportError(s,"getRowHeight",{rowId:e.id})}return t.length>0&&(i=Math.max(i,this.Cf(e,t))),this._n.set(e,i),i}Oe(e){let t=this.j.length;return t===0?Math.max(0,e)*this.e.r.rowHeight:e<=t?this.j.qe(e):this.j.ks()+(e-t)*this.e.r.rowHeight}Fn(e,t){if(t<=0)return 0;let r=this.j.length,i=this.j.ks();if(r>0&&e<i)return this.j.findIndex(e);let o=r+Math.floor(Math.max(0,e-i)/this.e.r.rowHeight);return Math.max(0,Math.min(o,t-1))}yf(){return this.e.n.d().filter(e=>e.colDef.autoHeight===!0)}get Tf(){return this.e.n.d().some(e=>e.colDef.autoHeight===!0)}vf(){this.Se||(this.Se=f("div","mach-cell mach-cell--wrap",{"aria-hidden":"true"}),this.Se.style.cssText="height:auto;visibility:hidden;pointer-events:none",this.e.o.root.appendChild(this.Se));let e=window.getComputedStyle(this.Se),t=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`,r=[t,e.lineHeight,e.letterSpacing,e.wordSpacing,e.padding,e.boxSizing].join("|");r!==this.ud&&(this.ud=r,this.It(),this.Vs=parseFloat(e.letterSpacing)||parseFloat(e.wordSpacing)?"":t,this.hd=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth),this.Se.style.width="10000px",this.Se.textContent="M",this.pd=Math.ceil(this.Se.getBoundingClientRect().height))}Cf(e,t){let r=this.Se,i=0;for(let o of t){let s=ce(this.e,e,o);if(!s)continue;let a=this.pd;if(!this.Vs||this.e.ft.Zn(s,this.Vs)>o.currentWidth-this.hd){let l=`${o.currentWidth}px`;r.style.width!==l&&(r.style.width=l),r.textContent!==s&&(r.textContent=s),a=Math.ceil(r.getBoundingClientRect().height),s.length>4096&&(r.textContent="")}i=Math.max(i,a)}return i}Tl(e,t){if(this.e.r.flashCells)for(let r of e)for(let i of t)this.ci.push([r,i])}gd(){if(this.ci.length===0)return;let e=this.ci;this.ci=[];for(let[t,r]of e){let i=this.rn(t,r);if(!i)continue;i.classList.remove("mach-cell--flash"),i.offsetWidth,i.classList.add("mach-cell--flash");let o=we(i),s=o.flashTimer;s&&clearTimeout(s),o.flashTimer=window.setTimeout(()=>{i.classList.remove("mach-cell--flash"),o.flashTimer=void 0},800)}}ve(){this.Dn();let e=this.e.o.T.center,r=this.e.r.rowHeight;this.e.r.masterDetail&&(r=Math.min(r,this.e.r.detailRowHeight)),this.Bn>0&&(r=Math.min(r,this.Bn));let i=Math.ceil(e.clientHeight/Math.max(1,r)),o=this.Ct?this.e.i.P():i+this.e.r.rowBuffer*2+1,s=o%2===0?o:o+1;this.yd(),s>this.m.length&&this.vd(s),this.$n(),this.li(!0,!1),this.Bs()}vd(e){for(;this.m.length<e;){let t={index:-1,nodeId:"",kind:"master",rows:{},cells:{}},r=this.e.o;for(let i of w){if(this.e.n.y(i).length===0)continue;let s=f("div","mach-row");s.style.height=`${this.e.r.rowHeight}px`,s.setAttribute("role","row"),s.style.display="none",r.Ee[i].appendChild(s),t.rows[i]=s,t.cells[i]=this.Kt(i).map(a=>s.appendChild(this.bd(a)))}if(this.e.r.masterDetail){let i=f("div","mach-row mach-detail-row");i.style.height=`${this.e.r.detailRowHeight}px`,i.setAttribute("role","row"),i.style.display="none",r.Ee.center.appendChild(i),t.detailRow=i}this.m.push(t)}}Kt(e){return e==="center"?this.Nn:this.e.n.y(e)}bd(e){let t=f("div","mach-cell");if(t.dataset.colId=e.id,t.setAttribute("role","gridcell"),e.hasCheckbox){let r=document.createElement("input");r.type=this.e.r.rowSelection==="single"?"radio":"checkbox",r.className="mach-row-checkbox",r.type==="radio"&&(r.name=`mach-radio-${this.e.gridId}`),r.setAttribute("aria-label","select row"),t.appendChild(r),t.classList.add("mach-cell--selection")}return t}Df(e){let t=new Map(this.Nn.map((i,o)=>[i.id,o])),r=e.map(i=>{let o=t.get(i.id);return t.delete(i.id),o});for(let i of this.m){let o=i.rows.center,s=i.cells.center;if(!o||!s)continue;for(let l of t.values()){let d=s[l];i.index>=0&&this.e.l.Wo(i.index,d.dataset.colId??"",d),G(this.e,d),d.remove()}let a=o.firstElementChild;i.cells.center=e.map((l,d)=>{let c=r[d],u=c===void 0?this.bd(l):s[c];return u!==a&&o.insertBefore(u,a),a=u.nextElementSibling,u})}}wd(){this.ui=void 0,this.Cd(),this.dd(!0),this.bt=0,this.Xe=-1,this.ve()}dd(e){this.Td(0,e),this.Ln=void 0,this.Nn=[]}Td(e,t){for(let r=e;r<this.m.length;r++){let i=this.m[r];i.detailRow&&this._s(i.detailRow);for(let o of w){for(let s of i.cells[o]??[])!t&&i.index>=0&&this.e.l.Wo(i.index,s.dataset.colId??"",s),G(this.e,s);t&&i.rows[o]?.remove()}t&&i.detailRow?.remove()}this.m.length=e}$n(){let e=this.xf();for(let t of w){let r=this.e.n.y(t),i=this.Kt(t),o=this.Ef(t,i,r);this.Rf(t,i,o,e)}this.Sf()}xf(){return this.e.r.masterDetail||this.e.r.getRowHeight!=null||this.Tf}Ef(e,t,r){if(e==="center"){this.N.update(r);let s=this.e.n.y("left").length;return t.map(a=>this.N.qe(this.e.n.Q(a.id)-s))}let i=0,o=[];for(let s of t)o.push(i),i+=s.currentWidth;return o}Rf(e,t,r,i){for(let o of this.m){let s=o.cells[e],a=o.rows[e];if(!s||!a)continue;i||(a.style.height=`${this.e.r.rowHeight}px`);let l=Math.min(t.length,s.length);for(let d=0;d<l;d++){let c=t[d];s[d].style.width=`${c.currentWidth}px`,s[d].style.left=`${r[d]}px`,s[d].setAttribute("aria-colindex",String(this.e.n.Q(c.id)+1))}}}Sf(){if(!this.e.r.masterDetail)return;let e=`${this.e.r.detailRowHeight}px`;for(let t of this.m)t.detailRow?.style.setProperty("--mach-detail-h",e)}yd(){let e=this.e.o.T.center,t=this.e.n.y("center");this.N.update(t);let{first:r,lastExcl:i}=t.length>20?this.N.Yl(e.scrollLeft,e.clientWidth,2):{first:0,lastExcl:t.length};if(t===this.Ln&&r===this.mt&&i===this.Vt)return!1;let o=t.slice(r,i),s=r>0?t.slice(0,r).filter(a=>a.colDef.colSpan!=null).concat(o):o;return this.m.length>0&&this.Df(s),this.Ln=t,this.Nn=s,this.mt=r,this.Vt=i,this.Fs=s.some(a=>a.colDef.colSpan!=null),!0}mo(){return{first:this.bt,lastExcl:this.Xe}}li(e=!1,t=!0){let r=this.e.we.start();if(!this.Mf(e,t))return;let i=Math.max(0,this.Xe-this.bt);if(this.m.length>Math.max(32,i*2)){let s=i+i%2+8,a=new Map(this.m.filter(d=>d.index>=0).map(d=>[d.index%s,d])),l=this.m.filter(d=>d.index<0);this.m=Array.from({length:s},(d,c)=>a.get(c)??l.pop()).concat(l),this.Td(s,!0)}this.wr();let o=this.e.n.y("left").length+this.Kt("center").length+this.e.n.y("right").length;this.e.we.gh(r,i,o)}Mf(e,t){let r=this.e.o.T.center,i=this.S.read(r.scrollTop)-r.scrollTop,o=i!==this.wt;this.wt=i;let s=this.e.i.P(),a=this.e.r.rowBuffer,l=t&&this.yd();if(l&&this.$n(),s===0){for(let u of this.m)this.Dd(u);return this.bt=0,this.Xe=0,!0}let{first:d,lastExcl:c}=this.If(r,s,a);return!e&&!l&&d===this.bt&&c===this.Xe?(o&&this.xd(),l||o):(this.Af(d,c),this.bt=d,this.Xe=c,this.kf(d,c,e,l),l&&this.hi(),o&&this.xd(),!0)}If(e,t,r){if(this.Ct)return{first:0,lastExcl:t};let i=this.S.read(e.scrollTop),o=this.Fn(i,t),s=i+e.clientHeight,a=Math.min(t,this.Fn(s,t)+1);return{first:T(o-r,0,t-1),lastExcl:T(a+r,1,t)}}Af(e,t){if(!(this.Ct&&this.bt===0&&t>=this.Xe))for(let r of this.m)r.index!==-1&&(r.index<e||r.index>=t)&&this.Dd(r)}kf(e,t,r,i){let o=t-e;o>this.m.length&&(this.vd(o+o%2),this.$n());for(let s=e;s<t;s++){let a=this.e.i.h(s),l=this.m[s%this.m.length];if(!(!l||!a)){if(!r&&l.index===s&&l.nodeId===a.id){i&&l.kind==="master"&&this.Kn(l,a,"center");continue}this.Gf(l,s,a)}}}Dd(e){if(this.Ed(e),this.Ct&&e.index>=0)for(let t of w)for(let r of e.cells[t]??[])G(this.e,r);this.b?.rowIndex===e.index&&this.e.o.root.removeAttribute("aria-activedescendant"),e.index=-1,e.nodeId="",e.kind="master";for(let t of w){let r=e.rows[t];r&&(r.style.display="none",delete r.dataset.id,delete r.dataset.index,ve(r,void 0),r.classList.remove("mach-row--drag-source"))}e.detailRow&&(this._s(e.detailRow),e.detailRow.style.display="none")}Gf(e,t,r){e.index>=0&&e.index!==t&&this.Ed(e),e.index=t,e.nodeId=r.id;let i=this.Oe(t),o=i-this.wt,s=this.Oe(t+1)-i;if(r.isDetail){this.Pf(e,r,t,o,s);return}this.Lf(e,r,t,o,s)}xd(){for(let e of this.m){if(e.index<this.bt||e.index>=this.Xe)continue;let t=`translateY(${this.Oe(e.index)-this.wt}px)`;for(let r of Object.values(e.rows))r.style.transform=t;e.detailRow&&(e.detailRow.style.transform=t)}}Pf(e,t,r,i,o){e.kind="detail";for(let a of w){let l=e.rows[a];l&&(l.style.display="none")}let s=e.detailRow;s&&(this.Rd(s,r,i,o),this.zs(s,t))}Lf(e,t,r,i,o){e.kind="master",e.detailRow&&(e.detailRow.style.display="none");let s=this.Nf(t),a=He(this.e,t);for(let l of w){let d=e.rows[l];d&&(this.Ff(d,t,r,i,o,s),ve(d,a),this.Kn(e,t,l))}this.b&&this.b.rowIndex===r&&this.hi()}Nf(e){let t=this.e.i.F,r=e.isGroup===!0,i=t&&this.e.i.vo(e.id),o=r||i||this.e.r.masterDetail&&this.e.i.isRowExpandable(e),s=r?this.e.i.isGroupExpanded(e.id):this.e.i.isRowExpanded(e.id),a=null;return r?a=(e.groupLevel??0)+1:t&&(a=this.e.i.bo(e)+1),{expanded:s,expandable:o,level:a}}Ff(e,t,r,i,o,s){this.Rd(e,r,i,o,t.id),this.Sd(e,t);let a=this.Gn===r&&!this.e.r.suppressRowHoverHighlight;e.classList.toggle("mach-row--hover",a),e.classList.toggle("mach-row--odd",r%2===1),e.classList.toggle("mach-row--drag-source",this.Wt.isSource(t)),this.Of(e,s)}Rd(e,t,r,i,o){e.style.display="",e.style.transform=`translateY(${r}px)`,e.style.height=`${i}px`,e.dataset.index=String(t),o!==void 0&&(e.dataset.id=o),e.setAttribute("aria-rowindex",String(t+this.e.o.Ol()+1))}Sd(e,t){e.classList.toggle("mach-row--selected",t.selected),e.setAttribute("aria-selected",t.selected?"true":"false")}Of(e,t){t.expandable?e.setAttribute("aria-expanded",t.expanded?"true":"false"):e.removeAttribute("aria-expanded"),t.level!=null?e.setAttribute("aria-level",String(t.level)):e.removeAttribute("aria-level")}Kn(e,t,r){let i=this.Kt(r),o=e.cells[r];if(!o)return;let s=e.index,a=this.e.n,l=r==="center"&&this.Fs,d=l?a.y("left").length:0,c=0;e.rows[r]?.classList.toggle("mach-row--editing",this.e.l.al(s));for(let u=0;u<i.length;u++){let h=i[u],p=o[u];if(l){let m=a.Q(h.id)-d,g=m<c?0:this.Hf(t,h,s,this.Ln.length-m);if(g>0&&(c=m+g),g===0||c<=this.mt){G(this.e,p),p.setAttribute("aria-hidden","true"),p.style.display="none";continue}(g>1||p.hasAttribute("aria-colspan"))&&this.Vf(p,m,g)}p.style.display==="none"&&(p.style.display=""),p.removeAttribute("aria-hidden"),!this.e.l.ul(s,t,h,p)&&(this.Md(p,t,h),this.Ws(p,s,h))}}Hf(e,t,r,i){let o=t.colDef.colSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.c(e,t),rowIndex:r});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"colSpan",{colId:t.id,rowId:e.id}),1}}Vf(e,t,r){let i=`${this.N.qe(t+r)-this.N.qe(t)}px`;e.style.width!==i&&(e.style.width=i),r>1?e.setAttribute("aria-colspan",String(r)):e.removeAttribute("aria-colspan")}zs(e,t){this._s(e);let r=t.masterId!=null?this.e.i.O(t.masterId):t,i=f("div","mach-detail");e.appendChild(i);let o=this.e.r.detailRowRenderer;if(o){let s={data:t.data,node:r??t,api:this.e.api},a;try{a=o(s)}catch(l){this.e.reportError(l,"detailRowRenderer",{rowId:t.id}),a=null}typeof a=="string"?i.textContent=a:a instanceof HTMLElement?i.appendChild(a):a&&typeof a=="object"&&a.el instanceof HTMLElement&&(i.appendChild(a.el),$e(e,a.destroy))}}_s(e){let t=Ke(e);if(t)try{t()}catch(r){this.e.reportError(r,"detailRowRenderer.destroy")}e.textContent=""}Md(e,t,r){if(t.loading){G(this.e,e),e.className="mach-cell mach-cell--loading",e.setAttribute("aria-readonly","true"),e.setAttribute("aria-busy","true");let o=f("span","mach-cell-loading-bar");o.style.width=`${34+(r.id.length*13+t.rowIndex*7)%44}%`,e.replaceChildren(o),this.Ut(e);return}e.removeAttribute("aria-busy"),e.setAttribute("aria-readonly",this.e.l.oe(t,r)?"false":"true"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-level");let i=this.Bf(t,r);if(i!=="standard"){G(this.e,e),this._f(i,e,t,r);return}je(this.e,e,t,r),this.Id(e,t,r),this.zf(e,t,r)}Bf(e,t){return e.isGroup?"group":t.isDetailToggle?"detail":t.hasCheckbox?"checkbox":t.colDef.rowDrag?"drag":Re(t.colDef,"index")?"index":this.e.i.F&&this.Ad()?.id===t.id?"tree":"standard"}_f(e,t,r,i){if(e==="group")this.Wf(t,r,i);else if(e==="detail"){let o=this.e.i.isRowExpanded(r.id),s=f("span",`mach-detail-toggle${o?" mach-detail-toggle--open":""}`);s.textContent="\u25B6",t.replaceChildren(s),t.classList.add("mach-cell--detail-toggle"),this.Ut(t)}else if(e==="checkbox"){let o=t.querySelector(".mach-row-checkbox");o&&(o.checked=r.selected,o.indeterminate=this.e.f.ou(r.id),o.disabled=!this.e.f.Ke(r)),t.className!=="mach-cell mach-cell--selection"&&(t.className="mach-cell mach-cell--selection"),this.Ut(t)}else if(e==="drag")this.$f(t,r),t.className!=="mach-cell mach-cell--drag"&&(t.className="mach-cell mach-cell--drag"),this.Ut(t);else if(e==="index"){t.textContent=String(this.e.i.Va(r)+this.e.r.indexOffset);let o=`mach-cell mach-cell--index ${Ue(i)}`;t.className!==o&&(t.className=o),this.Id(t,r,i)}else this.Kf(t,r,i)}zf(e,t,r){if(this.e.r.editType!=="cell"||this.e.r.editableIndicator==="none"||!this.e.l.oe(t,r))return;let i=document.createElement("button");i.type="button",i.className=`mach-cell-edit-trigger mach-cell-edit-trigger--${this.e.r.editableIndicator}`,i.tabIndex=-1,i.title="Edit cell",i.setAttribute("aria-label","Edit cell"),i.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10.8 2.7 2.5 2.5L5.5 13H3v-2.5z"/><path d="m9.5 4 2.5 2.5"/></svg>',i.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.Ge(t.rowIndex,r.id),this.e.l.start(t.rowIndex,r)}),e.appendChild(i)}Ed(e){if(!(e.index<0))for(let t of w)for(let r of e.cells[t]??[])this.e.l.Wo(e.index,r.dataset.colId??"",r)}Ad(){return this.ui!==void 0?this.ui:(this.ui=this.e.n.d().find(e=>!e.hasCheckbox&&!e.isDetailToggle&&!e.colDef.rowDrag&&!Re(e.colDef,"index"))??null,this.ui)}Kf(e,t,r){let i=this.e.i.isRowExpandable(t),o=this.e.i.bo(t),s=K(this.e,t,r,this.e.c(t,r)),a=f("span","mach-tree-indent");a.style.width=`${o*16}px`;let l=f("span","mach-tree-cell");if(o>0&&l.appendChild(a),i){let c=this.e.i.isRowExpanded(t.id);e.setAttribute("aria-expanded",c?"true":"false"),e.setAttribute("aria-level",String(o+1));let u=t.treeLoading?" mach-detail-toggle--loading":t.treeLoadError?" mach-detail-toggle--error":"",h=document.createElement("button");h.type="button",h.tabIndex=-1,h.className="mach-tree-toggle",h.setAttribute("aria-label",t.treeLoadError?"Retry loading children":c?"Collapse row":"Expand row"),h.setAttribute("aria-expanded",String(c)),t.treeLoadError&&(h.title="Retry loading children");let p=f("span",`mach-detail-toggle${c?" mach-detail-toggle--open":""}${u}`);p.setAttribute("aria-hidden","true"),p.textContent="\u25B6",h.appendChild(p),h.addEventListener("keydown",m=>{(m.key==="Enter"||m.key===" ")&&m.stopPropagation()}),l.appendChild(h)}else{let c=f("span","mach-tree-toggle-spacer");l.appendChild(c)}let d=f("span","mach-tree-text");d.textContent=s,l.appendChild(d),e.replaceChildren(l),s&&!this.e.r.tooltipComponent?e.title=s:e.removeAttribute("title"),Xt(this.e,e,t,r)}Ut(e){e.style.height!==""&&(e.style.height=""),e.style.zIndex!==""&&(e.style.zIndex=""),e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-rowspan")}Id(e,t,r){let i=this.e.i.Xc(r.id);if(!i||t.isDetail){this.Ut(e);return}let o=this.e.i.Va(t)-1;if(o<0||o>=i.length){this.Ut(e);return}let s=i[o];if(s===-1){e.style.display="none",e.setAttribute("aria-hidden","true");return}if(e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-hidden"),s>1){let a=Math.min(o+s,this.e.i.P()),l=this.Oe(a)-this.Oe(o);e.style.height=`${l>0?l:s*this.e.r.rowHeight}px`,e.style.zIndex="1",e.setAttribute("aria-rowspan",String(s))}else this.Ut(e)}Wf(e,t,r){if(r.hasCheckbox){this.Uf(e,t);return}if(r.isDetailToggle){this.kd(e);return}let i=this.e.n.na();if(i&&r.id===i.id){this.jf(e,t);return}this.qf(e,t,r)||this.kd(e)}Uf(e,t){let r=e.querySelector(".mach-row-checkbox");if(r){let i=this.e.f.Ka(t);r.checked=i.all,r.indeterminate=i.some&&!i.all}e.className!=="mach-cell mach-cell--selection"&&(e.className="mach-cell mach-cell--selection")}jf(e,t){let r=this.e.i.isGroupExpanded(t.id),i=t.groupLevel??0;e.setAttribute("aria-expanded",r?"true":"false"),e.setAttribute("aria-level",String(i+1));let o=f("span","mach-group-label");o.style.paddingLeft=`${i*16}px`;let s=f("span",`mach-detail-toggle${r?" mach-detail-toggle--open":""}`);s.textContent="\u25B6";let a=f("span","mach-group-text"),l=this.e.n.Je()[i],d=l?.colDef.headerName?`${l.colDef.headerName}: `:"";a.textContent=`${d}${t.groupKey??""}`;let c=f("span","mach-group-count");c.textContent=`(${t.leafNodes?.length??0})`,o.append(s,a,c),e.replaceChildren(o),e.className!=="mach-cell mach-cell--group"&&(e.className="mach-cell mach-cell--group")}qf(e,t,r){if(!r.colDef.aggFunc||!t.aggValues||!v(t.aggValues,r.id))return!1;let i=t.aggValues[r.id];e.textContent=r.colDef.valueFormatter!=null?K(this.e,t,r,i):Yt(i);let o=`mach-cell ${Ue(r)}`;return e.className!==o&&(e.className=o),!0}kd(e){e.textContent="",e.className!=="mach-cell"&&(e.className="mach-cell")}I(e){if(this.e.s())return;let t=new Set;for(let r of e){if(r<0||t.has(r))continue;t.add(r);let i=this.m[r%this.m.length];if(!i||i.index!==r)continue;let o=this.e.i.h(r);if(o){if(i.kind==="detail"){i.detailRow&&this.zs(i.detailRow,o);continue}for(let s of w){let a=i.rows[s];a&&this.Sd(a,o),i.cells[s]&&this.Kn(i,o,s)}}}this.hi(),this.gd()}refreshCells(e={}){if(this.e.s())return;let t=e.rowIds==null?null:new Set(e.rowIds),r=e.rowIndexes==null?null:new Set(e.rowIndexes),i=e.columns==null?null:new Set(e.columns);for(let o of this.m){let s=this.e.i.h(o.index);!s||!this.Yf(o,s,t,r)||this.Xf(o,s,i,e.force===!0)}this.hi(),this.gd()}Yf(e,t,r,i){return e.index<0?!1:r==null&&i==null?!0:r?.has(t.id)===!0||i?.has(e.index)===!0}Xf(e,t,r,i){if(e.kind==="detail"){r==null&&e.detailRow&&this.zs(e.detailRow,t);return}let o=r==null||this.Fs,s=He(this.e,t);for(let a of w){let l=e.rows[a];l&&ve(l,s),o?this.Kn(e,t,a):this.Jf(e,t,a,r,i)}}Jf(e,t,r,i,o){let s=this.Kt(r),a=e.cells[r];if(a)for(let l=0;l<s.length;l++){let d=s[l];if(!i.has(d.id))continue;let c=a[l];c&&(this.e.l.ul(e.index,t,d,c)||(o&&G(this.e,c),this.Md(c,t,d),this.Ws(c,e.index,d)))}}Zf(){this.e.s()||(this.b&&this.b.rowIndex>=this.e.i.P()&&this.Ge(null,null),this.Cd(),this.Dn(),this.li(!0),this.Bs(),this.e.De.refresh())}Bs(){let e=this.e.r,t=e.loading?"loading":e.error!=null?"error":this.e.i.P()===0&&!e.suppressNoRowsOverlay?"noRows":null;At(this.e,t)}rn(e,t){let r=this.e.n.R(t);if(!r)return null;let i=this.Po(r),o=this.Kt(i).indexOf(r);if(o<0)return null;let s=this.m[e%this.m.length];return!s||s.index!==e||s.kind!=="master"?null:s.cells[i]?.[o]??null}Cd(){this.pe.Zt()}Te(){let e=this.e.i.P(),t=this.e.n.d().length;return this.pe.normalize(e,t)}ar(){let e=this.Te();if(e)return e;let t=this.b;if(t){let r=this.e.n.Q(t.colId);if(r>=0)return{r1:t.rowIndex,c1:r,r2:t.rowIndex,c2:r}}return null}ni(){let e=this.Te();if(!e)return null;let t=this.e.n.d();return{row1:e.r1,row2:e.r2,colId1:t[e.c1]?.id??"",colId2:t[e.c2]?.id??""}}Oo(){let e=this.pe.Kp();if(e)return{row:e.row,colIdx:e.colIdx};let t=this.ar();return t?{row:t.r1,colIdx:t.c1}:null}lr(){let e=this.Te();this.pe.clear(),e&&(this.Un(),this.wr(),this.e.emit("rangeSelectionChanged",{range:null}))}Un(){for(let e of this.m)if(!(e.index<0||e.kind!=="master"))for(let t of w){let r=this.Kt(t);e.cells[t]?.forEach((i,o)=>{let s=r[o];s&&this.Ws(i,e.index,s)})}}$s(e,t,r){this.pe.start({row:e,colIdx:t},r),this.Un(),this.wr(),this.e.emit("rangeSelectionChanged",{range:this.ni()})}Gu(e,t){if(!this.pe.Up()){let a=this.b;if(!a)return;let l=this.e.n.Q(a.colId);if(!this.pe.jp({row:a.rowIndex,colIdx:l}))return}let r=this.e.i.P(),i=this.e.n.d().length;this.pe.setEnd({row:Math.max(0,Math.min(e,r-1)),colIdx:Math.max(0,Math.min(t,i-1))}),this.Un(),this.wr();let o=this.e.n.d(),s=this.pe.Es();s&&s.colIdx<o.length&&this.Ge(s.row,o[s.colIdx].id),this.e.emit("rangeSelectionChanged",{range:this.ni()})}Ws(e,t,r){let i=this.Te();if(!i){e.classList.contains("mach-cell--range")&&e.classList.remove("mach-cell--range","mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right");return}let o=this.e.n.Q(r.id);if(o<0)return;let s=t>=i.r1&&t<=i.r2&&o>=i.c1&&o<=i.c2;e.classList.toggle("mach-cell--range",s),s?(e.classList.toggle("mach-cell--range-top",t===i.r1),e.classList.toggle("mach-cell--range-bottom",t===i.r2),e.classList.toggle("mach-cell--range-left",o===i.c1),e.classList.toggle("mach-cell--range-right",o===i.c2)):e.classList.remove("mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right")}Qf(){if(this.Hn)return this.Hn;let e=f("div","mach-fill-handle");return e.style.display="none",e.addEventListener("pointerdown",t=>{this.Ks=!0,this.Gd(t)}),e.addEventListener("mousedown",t=>{this.Ks||this.Gd(t)}),this.e.o.Ee.center.appendChild(e),this.Hn=e,e}wr(){let e=this.Qf(),t=this.Te();if(!this.e.r.enableRangeSelection||!this.e.r.fillHandle||!t){e.style.display="none";return}let r=this.e.n,i=r.y("left").length,o=r.y("center");if(t.c2<i||t.c2>=i+o.length){e.style.display="none";return}let s=t.c2-i;this.N.update(o);let a=this.N.qe(s+1),l=this.Oe(Math.min(t.r2+1,this.e.i.P()))-this.wt,d=this.e.o.T.center;if(this.S.vt&&(l<d.scrollTop||l>d.scrollTop+d.clientHeight)){e.style.display="none";return}e.style.display="",e.style.left=`${this.S.vt?Math.min(a-4,parseFloat(this.e.o.Ee.center.style.width)-8):a-4}px`,e.style.top=`${Math.min(l-4,this.S.height-8)}px`}Gd(e){if(this.e.s()||e.button!==0)return;let t=this.Te();t&&(e.preventDefault(),e.stopPropagation(),this.pi={r1:t.r1,r2:t.r2,c1:t.c1,c2:t.c2,startX:e.clientX,startY:e.clientY,axis:null,active:!1},this.Pd(!0))}Ld(e){let r=this.e.o.Ee.center.getBoundingClientRect(),i=e.clientY-r.top+this.wt,o=this.e.i.P(),s=this.Fn(i,o);return Math.max(this.pi.r2,Math.min(s,o-1))}Nd(e){let r=this.e.o.Ee.center.getBoundingClientRect(),i=e.clientX-r.left,o=this.e.n,s=o.y("left").length,a=o.y("center");this.N.update(a);let l=this.N.Mp(i);if(l<0)return s;let d=this.N.qe(l)+a[l].currentWidth/2;return i<d?s+l:l+1<a.length?s+l+1:s+a.length-1}Pd(e){let t=e?"addEventListener":"removeEventListener";for(let r of["pointermove","mousemove"])window[t](r,this.em);for(let r of["pointerup","mouseup","pointercancel"])window[t](r,this.tm)}On(){this.pi=null,this.Ks=!1,this.Pd(!1),this.e.o.root.classList.remove("mach-root--filling")}Fd(e,t,r){let i=this.pe.Es();!i||t===(e?i.colIdx:i.row)||(this.pe.setEnd(e?{row:i.row,colIdx:t}:{row:t,colIdx:i.colIdx}),this.Un(),r&&(e&&this.wr(),this.e.emit("rangeSelectionChanged",{range:this.ni()})))}rm({r1:e,r2:t,c1:r,c2:i},o,s){let a=this.e.n.d(),l=[],d=s?r:e,c=s?i:t,u=s?t:i;for(let h=s?e:r;h<=u;h++){let p=s?this.e.i.h(h):void 0,m=s?void 0:a[h];(s?!p||p.isDetail||p.isGroup:!kn(m))||this.im(a,d,c,o,l,p,m)}this.e.pr(l),this.e.emit("rangeSelectionChanged",{range:this.ni()})}im(e,t,r,i,o,s,a){let l=[];for(let c=t;c<=r;c++){let u=s??this.e.i.h(c),h=a??e[c];l.push(u&&h?this.e.c(u,h):void 0)}if(a&&l.length===1&&l[0]===void 0)return;let d=oa(l);for(let c=r+1;c<=i;c++){let u=s??this.e.i.h(c),h=a??e[c];if(!u||!kn(h)||!this.e.l.oe(u,h))continue;let p=sa(d,c-t),m=this.e.c(u,h);o.push({node:u,column:h,oldValue:m,newValue:p})}}Ge(e,t){if(this.nm(),e==null||t==null){this.b=null;return}this.b={rowIndex:e,colId:t},this.hi(),this.om()}hi(){if(!this.b)return;let e=this.rn(this.b.rowIndex,this.b.colId);if(e&&e.style.display!=="none"){let t=Math.max(0,this.e.n.Q(this.b.colId));e.id=`mach-grid-${this.e.gridId}-r${this.b.rowIndex}-c${t}`,e.classList.add("mach-cell--focus"),this.e.o.root.setAttribute("aria-activedescendant",e.id)}else this.e.o.root.removeAttribute("aria-activedescendant")}nm(){if(this.b){let e=this.rn(this.b.rowIndex,this.b.colId);e&&(e.classList.remove("mach-cell--focus"),e.removeAttribute("id"))}this.e.o.root.removeAttribute("aria-activedescendant")}om(){if(!this.b)return;this.Ui(this.b.rowIndex,"nearest");let e=this.e.n.R(this.b.colId);!e||e.pinned||this.N.Rn(this.e.o.T.center,this.e.n.y("center"),e)}Ui(e,t="top"){let r=this.e.o.T.center,i=this.e.i.P();if(i===0)return;let o=T(e,0,i-1),s=r.clientHeight,a=this.S.read(r.scrollTop),l=this.Oe(o),d=this.Oe(o+1),c=a;t==="top"?c=l:t==="bottom"?c=d-s:t==="middle"?c=l-(s-(d-l))/2:l<a?c=l:d>a+s&&(c=d-s);let u=Math.max(0,this.Oe(i)-s);this.Wn(T(c,0,u)),this.Tn()}Od(e){if(this.Gn===e)return;let t=this.Gn;this.Gn=e,this.Hd(t,!1),this.Hd(e,!0)}Hd(e,t){if(e<0)return;let r=this.m[e%this.m.length];if(!(!r||r.index!==e||r.kind!=="master"))for(let i of w)r.rows[i]?.classList.toggle("mach-row--hover",t)}fi(){this.e.o.root.focus({preventScroll:!0})}jt(e){let t=e.target,r=t.closest(".mach-row");if(!r)return null;let i=Number(r.dataset.index);if(Number.isNaN(i))return null;let o=this.e.i.h(i);if(!o)return null;let s=t.closest(".mach-cell");return{node:o,index:i,cellEl:s}}Vd(e,t,r){let{node:i,index:o,cellEl:s}=r;if(this.sm(t,i,s)||this.am(t,i,s))return;let a=s?.dataset.colId??"",l=a?this.e.n.R(a):void 0;this.lm(i,l)||i.isDetail||this.dm(t,i,o,e)||!s||!l||(this.fi(),this.e.r.suppressCellFocus||this.Ge(o,a),this.e.f.ja(i,e,!1),this.cm(e,i,o,l),this.um(i,o,l))}sm(e,t,r){if(!t.isGroup)return!1;if(this.fi(),e.closest(".mach-row-checkbox")){let o=this.e.f.Ka(t).all;return this.e.f.au(t,!o),!0}let i=this.e.n.na();return(!i||!r||r.dataset.colId===i.id)&&this.e.i.xo(t.id),!0}lm(e,t){return!t?.isDetailToggle||e.isDetail?!1:(this.fi(),this.e.ji(e.id),!0)}dm(e,t,r,i){let o=e.closest(".mach-cell--selection");return o?(this.fi(),this.e.r.suppressCellFocus||this.Ge(r,o.dataset.colId??""),this.lr(),this.e.f.ja(t,i,!0),!0):!1}cm(e,t,r,i){let o=this.e.c(t,i),s=this.e.emit("cellClicked",{event:e,rowNode:t,rowIndex:r,column:i,colDef:i.colDef,value:o});i.colDef.onCellClick?.(s),this.e.emit("rowClicked",{event:e,rowNode:t,rowIndex:r})}um(e,t,r){(this.e.r.singleClickEdit||r.colDef.singleClickEdit===!0)&&this.e.l.oe(e,r)&&this.e.l.start(t,r)}am(e,t,r){if(!this.e.i.F||!e.closest(".mach-tree-toggle"))return!1;let i=this.Ad();return!i||r?.dataset.colId!==i.id||!this.e.i.isRowExpandable(t)?!1:(this.fi(),t.treeLoadError?this.e.i.loadTreeChildren(t.id,!0).catch(()=>{}):this.e.i.ji(t.id),!0)}hm(e){return!!(e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-tree-toggle, .mach-row-drag-handle")||this.e.l.tn())}$f(e,t){let r=e.querySelector("button.mach-row-drag-handle"),i=r?.value===t.id?r:f("button","mach-row-drag-handle");i.type="button",i.value=t.id;let o=this.Wt.nd(t);i.disabled=o!==!0;let s=this.e.r.locale.rowDragHandle??x.rowDragHandle;i.setAttribute("aria-label",s),i.title=typeof o=="string"?o:i.disabled?this.e.r.locale.rowDragUnavailable??x.rowDragUnavailable:s,i.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown"),i!==r&&e.replaceChildren(i)}};var Vt=class{constructor(e){this.e=e;this.He=null;this.Bd={left:void 0,center:void 0,right:void 0};this.js={left:[],center:[],right:[]}}init(){this.He=f("div","mach-footer"),this.He.style.display="none",this.He.setAttribute("role","row"),this.e.o.root.appendChild(this.He);for(let e of w){let t=f("div",`mach-footer-row mach-footer-row--${e}`);t.style.height=`${this.e.r.rowHeight}px`,this.He.appendChild(t),this.Bd[e]=t}}setVisible(e){this.He&&(this.He.style.display=e?"":"none")}refresh(){if(!this.He||this.e.s())return;let e=this.e.r.showSummary;if(this.setVisible(e),!e)return;let t=this.e.r.summaryMethod,r=this.e.i.At().filter(o=>!o.isDetail&&!o.isGroup),i={...x,...this.e.r.locale};for(let o of w){let s=this.e.n.y(o),a=this.Bd[o];this.js[o].length!==s.length&&(a.textContent="",this.js[o]=s.map(()=>{let d=f("div","mach-footer-cell");return d.setAttribute("role","cell"),a.appendChild(d),d}));let l=0;s.forEach((d,c)=>{let u=this.js[o][c];if(u.style.left=`${l}px`,u.style.width=`${d.currentWidth}px`,l+=d.currentWidth,d.hasCheckbox||d.isDetailToggle||d.colDef.rowDrag){u.textContent="";return}if(t)try{u.textContent=t({colId:d.id,column:d,values:r.map(h=>this.e.c(h,d))})}catch(h){this.e.reportError(h,"summaryMethod",{colId:d.id}),u.textContent=""}else c===0&&o==="left"?u.textContent=$(i.totalRowsLabel,r.length):u.textContent=""})}}destroy(){this.He?.remove(),this.He=null}};var Bt=class{constructor(e){this.e=e;this.C=null;this.jn=null;this.qs=null;this.Cr=null;this.qt=null;this.mi=null;this.gi=null;this.yi=null;this.vi=null;this.Yt=[]}init(){this.C=f("div","mach-pagination"),this.C.style.display="none",this.C.setAttribute("role","navigation");let e=(t,r,i)=>{let o=f("button",`mach-pagination-btn ${t}`);return o.type="button",o.title=r,o.setAttribute("aria-label",r),o.textContent=i,o};this.jn=f("span","mach-pagination-total"),this.mi=e("mach-pagination-first",this.t("pageFirst"),"\xAB"),this.gi=e("mach-pagination-prev",this.t("pagePrev"),"\u2039"),this.qs=f("span","mach-pagination-page"),this.yi=e("mach-pagination-next",this.t("pageNext"),"\u203A"),this.vi=e("mach-pagination-last",this.t("pageLast"),"\xBB"),this.mi.addEventListener("click",()=>this.e.i.setPage(1)),this.gi.addEventListener("click",()=>this.e.i.setPage(this.e.i.tr()-1)),this.yi.addEventListener("click",()=>this.e.i.setPage(this.e.i.tr()+1)),this.vi.addEventListener("click",()=>this.e.i.setPage(this.e.i.getPageCount())),this.C.append(this.jn,this.mi,this.gi,this.qs,this.yi,this.vi),this.e.r.paginationShowSizeSelector&&(this.qt=re({ariaLabel:"page size",options:[],classNames:{root:"mach-pagination-size-control",native:"mach-pagination-size"},themeSource:this.e.o.root,onChange:t=>{let r=Number(t);Number.isNaN(r)||this.e.i.setPageSize(r)}}),this.Cr=this.qt.native,this._d(),this.C.appendChild(this.qt.el)),this.e.o.root.appendChild(this.C),this.Yt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("paginationChanged",()=>this.refresh())),this.refresh()}_d(){if(!this.Cr)return;let e=this.e.r.paginationPageSizeOptions,t=this.e.r.paginationPageSize;e.includes(t)||(e.push(t),e.sort((r,i)=>r-i)),this.qt?.setOptions(e.map(r=>({value:String(r),label:$(this.t("perPage"),r)})),String(t))}t(e){return this.e.r.locale?.[e]??x[e]}Re(){this.C&&(this.Cr&&this.e.r.paginationShowSizeSelector&&this._d(),this.refresh())}zd(e,t){e&&e.textContent!==t&&(e.textContent=t)}pm(e,t){let r=e<=1,i=e>=t;this.mi&&(this.mi.disabled=r),this.gi&&(this.gi.disabled=r),this.yi&&(this.yi.disabled=i),this.vi&&(this.vi.disabled=i)}refresh(){if(!this.C||this.e.s())return;let e=this.e.i,t=e.Ce,r=e.getTotalRowCount(),i=t&&r>0;if(this.C.style.display=i?"":"none",!i)return;let o=e.tr(),s=e.getPageCount();this.jn&&this.e.r.paginationShowTotal&&this.zd(this.jn,$(this.t("paginationTotal"),r)),this.zd(this.qs,Me(this.t("paginationPage"),o,s)),this.pm(o,s),this.Cr&&Number(this.Cr.value)!==this.e.r.paginationPageSize&&this.qt?.setValue(String(this.e.r.paginationPageSize))}destroy(){for(let e of this.Yt)e();this.Yt=[],this.qt?.destroy(),this.qt=null,this.Cr=null,this.C?.remove(),this.C=null}};var _t=class{constructor(e){this.e=e;this.top=null;this.bottom=null}init(){this.top=this.Wd(this.e.o.gn),this.bottom=this.Wd(this.e.o.yn)}Wd(e){let t={root:e,segments:{left:f("div"),center:f("div"),right:f("div")},centerViewport:f("div","mach-pinned-viewport"),rowWrappers:{left:[],center:[],right:[]},cells:[],data:[]};for(let r of w)t.segments[r].className=`mach-pinned-seg mach-pinned-seg--${r}`,r!=="center"&&t.segments[r].classList.add("mach-pane--hidden"),r==="center"&&t.centerViewport.appendChild(t.segments[r]);return e.append(t.segments.left,t.centerViewport,t.segments.right),t}setData(e,t){this.e.s()||!this.top||!this.bottom||(this.top.data=e??[],this.bottom.data=t??[],this.refresh(),this.e.ve())}setRows(e,t){let r=this[e];this.e.s()||!r||(r.data=t??[],this.Ys(r,e),this.gt(),this.e.ve())}getRows(e){return this[e]?.data.slice()??[]}Re(){!this.top||!this.bottom||(this.Ys(this.top,"top"),this.Ys(this.bottom,"bottom"))}Ys(e,t){this.mr(e);for(let o of w){for(let s of e.rowWrappers[o])s.remove();e.rowWrappers[o]=[]}if(e.root.style.display=e.data.length>0?"":"none",e.data.length===0)return;let r=this.e.r.rowHeight,i=this.e.n;e.data.forEach((o,s)=>{let a={id:`__pinned_${t}_${s}`,data:o,rowIndex:-1,selected:!1},l={},d=He(this.e,a,t);for(let c of w){let u=f("div","mach-pinned-row");ve(u,d),u.style.height=`${r}px`,u.setAttribute("role","row"),l[c]=[];for(let h of i.y(c)){let p=f("div","mach-cell");if(p.dataset.colId=h.id,p.setAttribute("role","gridcell"),h.hasCheckbox&&p.classList.add("mach-cell--selection"),!h.hasCheckbox&&!h.isDetailToggle&&!h.colDef.rowDrag&&h.colDef.type!=="index")try{je(this.e,p,a,h)}catch(m){this.e.reportError(m,"pinnedRow.render",{colId:h.id,side:t,rowIndex:s})}u.appendChild(p),l[c].push(p)}e.segments[c].appendChild(u),e.rowWrappers[c].push(u)}e.cells.push(l)})}gt(){if(!this.top||!this.bottom)return;let e=this.e.n,t={left:0,center:0,right:0},r={left:[],center:[],right:[]};for(let i of w){let o=0;for(let s of e.y(i))r[i].push(o),o+=s.currentWidth;t[i]=o}for(let i of[this.top,this.bottom]){let o=i.data.length===0;i.segments.left.classList.toggle("mach-pane--hidden",o||t.left<=0),i.segments.right.classList.toggle("mach-pane--hidden",o||t.right<=0),i.segments.left.style.width=`${t.left}px`,i.segments.right.style.width=`${t.right}px`,i.segments.center.style.width=`${t.center}px`,i.cells.forEach(s=>{let a=0;for(let l of w){let d=e.y(l);s[l].forEach((c,u)=>{c.style.width=`${d[u].currentWidth}px`,c.style.left=`${r[l][u]}px`,c.setAttribute("aria-colindex",String(a+u+1))}),a+=d.length}})}}cf(e){this.top&&(this.top.segments.center.style.transform=`translateX(${-e}px)`),this.bottom&&(this.bottom.segments.center.style.transform=`translateX(${-e}px)`)}refresh(){this.Re(),this.gt()}destroy(){this.top&&this.mr(this.top),this.bottom&&this.mr(this.bottom),this.top=null,this.bottom=null}mr(e){for(let t of e.cells)for(let r of w)for(let i of t[r])G(this.e,i);e.cells=[]}};var zt=class{constructor(e){this.e=e;this.C=null;this.Tr={};this.Yt=[]}init(){this.C=f("div","mach-statusbar"),this.C.style.display="none",this.C.setAttribute("role","status"),this.e.o.root.appendChild(this.C),this.Re(),this.Yt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("selectionChanged",()=>this.refresh()),this.e.ce.on("rangeSelectionChanged",()=>this.refresh()),this.e.ce.on("cellValueChanged",()=>this.refresh()))}Re(){if(!this.C)return;this.C.textContent="",this.Tr={};let e=this.e.r;if(!e.statusBarEnabled){this.C.style.display="none";return}for(let t of e.statusBarPanels){let r=f("span",`mach-statusbar-item mach-statusbar-item--${t}`);this.C.appendChild(r),this.Tr[t]=r}this.refresh()}text(e,t,r){let i=e[t]??x[t];if(r===void 0)return i;let o=typeof r=="number"?r:parseFloat(String(r))||0;return $(i,o)}Xs(e,t){let r=this.Tr[e];r&&r.textContent!==t&&(r.textContent=t)}fm(e){let t=this.e.i,r=t.Pr(),i=t.Ce?t.getTotalRowCount():t.P(),o=$(this.text(e,"totalRowsLabel"),i);return t.g&&r>i?`${o} / ${r}`:o}mm(e){let t=this.e.a.Te();if(!t)return"";let r=this.e.n.d(),i=0,o=0;for(let l=t.r1;l<=t.r2;l++){let d=this.e.i.h(l);if(!(!d||d.isDetail||d.isGroup))for(let c=t.c1;c<=t.c2;c++){let u=r[c];if(!u)continue;let h=this.e.c(d,u);typeof h!="number"||Number.isNaN(h)||(i+=h,o++)}}if(o===0)return"";let s=Math.round(i/o*100)/100,a=Number.isInteger(i)?String(i):String(Math.round(i*100)/100);return`${this.text(e,"statusSum",a)} \xB7 ${this.text(e,"statusAvg",String(s))} \xB7 ${this.text(e,"statusCount",String(o))}`}refresh(){if(!this.C||this.e.s())return;let e=this.e.r;if(this.C.style.display=e.statusBarEnabled?"":"none",!e.statusBarEnabled)return;let t={...x,...e.locale};if(this.Tr.rowCount&&this.Xs("rowCount",this.fm(t)),this.Tr.selectedRowCount){let r=this.e.f.rr().length;this.Xs("selectedRowCount",$(this.text(t,"statusSelected"),r))}this.Tr.rangeAggregate&&this.Xs("rangeAggregate",this.mm(t))}destroy(){for(let e of this.Yt)e();this.Yt=[],this.C?.remove(),this.C=null}};function Wr(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Gn(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function Pn(n={}){let e=(n.namespace??"mach-table:grid-state").replace(/:+$/,""),t=Math.max(1024,Math.floor(n.maxBytes??512*1024)),r=o=>`${e}:${o}`,i=(o,s,a)=>{try{n.onError?.(o,s,a)}catch{}};return{storageKey:r,load(o){try{let s=(n.storage??Wr())?.getItem(r(o));if(!s)return null;if(Gn(s)>t)throw new RangeError(`[MachTable] Stored grid state for "${o}" exceeds ${t} bytes.`);let a=JSON.parse(s);if(a?.schemaVersion!==2)throw new TypeError(`[MachTable] Stored grid state for "${o}" uses an unsupported schema.`);let l=q(a.state);if(!l)throw new TypeError(`[MachTable] Stored grid state for "${o}" is invalid.`);return l}catch(s){return i(s,"load",o),null}},save(o,s){try{let a=q(s);if(!a)throw new TypeError(`[MachTable] Invalid grid state for "${o}".`);let l=JSON.stringify({schemaVersion:2,savedAt:Date.now(),state:a});if(Gn(l)>t)throw new RangeError(`[MachTable] Grid state for "${o}" exceeds ${t} bytes.`);(n.storage??Wr())?.setItem(r(o),l)}catch(a){i(a,"save",o)}},clear(o){try{(n.storage??Wr())?.removeItem(r(o))}catch(s){i(s,"clear",o)}}}}var $r=Pn();function Kr(n,e){$r.save(n,e)}function Ur(n){return $r.load(n)}function aa(n){$r.clear(n)}var Ve=class{constructor(e){this.onError=e;this.qn=new Set;this.disposed=!1}add(e){let t=!0,r=()=>{if(t){t=!1,this.qn.delete(r);try{e()}catch(i){try{this.onError(i)}catch{}}}};return this.disposed?r():this.qn.add(r),r}A(e){return this.add(()=>e.destroy()),e}dispose(){if(this.disposed)return;this.disposed=!0;let e=[...this.qn].reverse();this.qn.clear();for(let t of e)t()}};function la(n){return!!(n.field||n.valueGetter||n.cellRenderer||n.checkboxSelection||n.rowDrag||n.type||n.autoRowSpan||n.rowSpan)}function da(n,e,t){n.width!=null&&n.minWidth!=null&&n.width<n.minWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5C0F\u4E8E minWidth(${n.minWidth})\uFF0C\u5C06\u6309 minWidth \u6E32\u67D3`),n.width!=null&&n.maxWidth!=null&&n.width>n.maxWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5927\u4E8E maxWidth(${n.maxWidth})\uFF0C\u5C06\u6309 maxWidth \u6E32\u67D3`)}function ca(n,e){let t=n.colId??n.field??`col_${e.leafIndex}`;e.seenIds.set(t,(e.seenIds.get(t)??0)+1),n.field&&!Zt(n.field)&&e.issues.push(`\u5217 "${t}" \u7684 field \u8DEF\u5F84\u4E0D\u5B89\u5168\u6216\u65E0\u6548\uFF0C\u5DF2\u7981\u6B62\u8BFB\u53D6\u548C\u5199\u5165`),la(n)||e.issues.push(`\u5217 "${t}" \u65E2\u65E0 field \u4E5F\u65E0 valueGetter\uFF0C\u5C06\u59CB\u7EC8\u663E\u793A\u7A7A\u503C\uFF08\u7EAF\u5DE5\u5177\u5217\u8BF7\u5FFD\u7565\u6B64\u63D0\u793A\uFF09`),da(n,t,e.issues)}function Ln(n,e){for(let t of n){if(Se(t)){!Array.isArray(t.children)||t.children.length===0?e.issues.push(`\u5217\u5206\u7EC4 "${t.headerName??t.groupId??"?"}" \u7684 children \u4E3A\u7A7A`):Ln(t.children,e);continue}e.leafIndex++,ca(t,e)}}function Nn(n){if(!n||n.length===0)return[];let e={issues:[],seenIds:new Map,leafIndex:0};Ln(n,e);for(let[t,r]of e.seenIds)r>1&&e.issues.push(`\u5B58\u5728 ${r} \u4E2A\u91CD\u590D\u7684 colId/field "${t}"\uFF0C\u5DF2\u81EA\u52A8\u52A0\u540E\u7F00\u533A\u5206\uFF0C\u5EFA\u8BAE\u663E\u5F0F\u547D\u540D colId`);return e.issues}var Fn=new Set([...Lr,...Fe]),ua=new Set(["enableColumnResize","pagination","rowKey"]);function ha(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:e.length+1},(r,i)=>i);for(let r=1;r<=n.length;r++){let i=t[0];t[0]=r;for(let o=1;o<=e.length;o++){let s=t[o];t[o]=Math.min(t[o-1]+1,s+1,i+(n[r-1]===e[o-1]?0:1)),i=s}}return t[e.length]}function pa(n){let e,t=Math.max(2,Math.floor(n.length*.3))+1,r=n.toLowerCase();for(let i of Fn){if(Math.abs(r.length-i.length)>=t)continue;let o=ha(r,i.toLowerCase());o<t&&(t=o,e=i)}return e}function fa(n,e){n.rowKey!=null&&typeof n.rowKey!="string"&&typeof n.rowKey!="function"&&e("INVALID_OPTION_VALUE","rowKey","rowKey \u5FC5\u987B\u662F\u5B57\u6BB5\u8DEF\u5F84\u6216\u8FD4\u56DE\u7A33\u5B9A\u4E1A\u52A1\u4E3B\u952E\u7684\u51FD\u6570"),n.domLayout==="autoHeight"&&n.datasource!=null&&e("OPTION_CONFLICT","domLayout","autoHeight \u4F1A\u6E32\u67D3\u5168\u90E8\u5DF2\u52A0\u8F7D\u884C\uFF0C\u4E0D\u9002\u7528\u4E8E datasource \u65E0\u9650\u6EDA\u52A8\u6A21\u5F0F"),ma(n,e),n.enableColumnResize!=null&&typeof n.enableColumnResize!="boolean"&&e("INVALID_OPTION_VALUE","enableColumnResize","enableColumnResize \u5FC5\u987B\u662F boolean\uFF1B\u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u5173\u95ED")}function ma(n,e){n.datasourceMode==="block"&&(n.datasource==null&&e("OPTION_CONFLICT","datasourceMode","datasourceMode='block' requires a datasource"),typeof n.getRowHeight=="function"&&e("OPTION_CONFLICT","getRowHeight","Random-access block rows require fixed rowHeight so unloaded offsets remain deterministic"),n.masterDetail===!0&&e("OPTION_CONFLICT","masterDetail","masterDetail is not supported by the sparse random-access block row model"),n.treeData===!0&&e("OPTION_CONFLICT","treeData","treeData requires the local/tree row model and cannot use random-access blocks"),n.rowKey==null&&e("MISSING_STABLE_ROW_ID","rowKey","Random-access blocks require rowKey to preserve selection and identity after eviction"))}function ga(n,e){for(let t of Lr)if(!(ua.has(t)||!v(n,t))&&!Nr(t,n[t])){let r=t==="maxBodyHeight"?"maxBodyHeight \u5FC5\u987B\u662F\u81F3\u5C11 1px \u7684\u6709\u9650\u6570":`${t} \u503C\u7C7B\u578B\u65E0\u6548\uFF0C\u671F\u671B ${ge[t]}`;e("INVALID_OPTION_VALUE",t,r)}}function ya(n){let e=[];for(let t of Object.keys(n)){if(Fn.has(t))continue;let r=pa(t);e.push({code:"UNKNOWN_OPTION",option:t,...r?{suggestion:r}:{},message:r?`\u672A\u77E5 GridOption "${t}"\uFF0C\u662F\u5426\u60F3\u4F7F\u7528 "${r}"\uFF1F`:`\u672A\u77E5 GridOption "${t}"\uFF0C\u8BE5\u503C\u4E0D\u4F1A\u751F\u6548`})}return e}function va(n,e,t){if(e.mode!=="server")return;n.rowKey==null&&t("MISSING_STABLE_ROW_ID","rowKey","\u670D\u52A1\u7AEF\u5206\u9875\u5EFA\u8BAE\u63D0\u4F9B\u7A33\u5B9A rowKey\uFF0C\u5426\u5219\u8DE8\u9875\u9009\u62E9\u4E0E\u589E\u91CF\u66F4\u65B0\u65E0\u6CD5\u53EF\u9760\u4FDD\u6301");let r=e.total;r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||r<0)&&t("INVALID_OPTION_VALUE","pagination.total","\u670D\u52A1\u7AEF\u5206\u9875 total \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u6570")}function ba(n,e){let t=n.pagination;t!=null&&typeof t!="boolean"&&typeof t!="object"&&e("INVALID_OPTION_VALUE","pagination","pagination \u5FC5\u987B\u662F boolean \u6216\u914D\u7F6E\u5BF9\u8C61"),n.datasource!=null&&t!==void 0&&t!==!1&&e("OPTION_CONFLICT","pagination","datasource \u987A\u5E8F\u65E0\u9650\u6A21\u5F0F\u4E0E pagination \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF1B\u666E\u901A\u670D\u52A1\u7AEF\u5206\u9875\u8BF7\u4F7F\u7528 pagination.mode='server'"),t&&typeof t=="object"&&va(n,t,e)}function jr(n){let e=n,t=ya(e),r=(i,o,s)=>{t.push({code:i,option:o,message:s})};return ba(e,r),e.treeData===!0&&e.masterDetail===!0&&r("OPTION_CONFLICT","masterDetail","treeData \u4E0E masterDetail \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF0C\u4E3B\u4ECE\u660E\u7EC6\u5C06\u88AB\u5FFD\u7565"),ga(e,r),fa(e,r),t}function On(n){let e=/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(n.trim());return e?[Number(e[1]),Number(e[2]??0),Number(e[3]??0)]:null}function qr(n,e){for(let t=0;t<3;t++)if(n[t]!==e[t])return n[t]<e[t]?-1:1;return 0}function wa(n){return n[0]>0?[n[0]+1,0,0]:n[1]>0?[0,n[1]+1,0]:[0,0,n[2]+1]}function Ca(n,e){if(e==="*"||e.toLowerCase()==="latest")return!0;let t=/^(\^|~|>=|<=|>|<|=)?\s*(.+)$/.exec(e);if(!t)return!1;let r=On(t[2]);if(!r)return!1;let i=qr(n,r);switch(t[1]??"="){case">=":return i>=0;case"<=":return i<=0;case">":return i>0;case"<":return i<0;case"^":return i>=0&&qr(n,wa(r))<0;case"~":return i>=0&&qr(n,[r[0],r[1]+1,0])<0;default:return i===0}}function Hn(n,e){if(!e?.trim())return!0;let t=n?On(n):null;return t?e.split("||").some(r=>{let i=r.trim().split(/\s+/).filter(Boolean);return i.length>0&&i.every(o=>Ca(t,o))}):!1}function Ta(n){return[...new Set((n??[]).map(e=>e.trim()).filter(Boolean))]}function Wt(n){let e=new Map;for(let t of n??[]){let r=(typeof t=="string"?t:t?.key??"").trim();if(!r||e.has(r))continue;let i=typeof t=="object"?t.version?.trim():void 0;e.set(r,{key:r,...i?{version:i}:{}})}return[...e.values()]}function Yr(n){let e=[],t=new Map;for(let l of n){let d=typeof l?.key=="string"?l.key.trim():"";if(!d){e.push({code:"INVALID_FEATURE_KEY",message:"GridFeature.key must be a non-empty string"});continue}if(t.has(d)){e.push({code:"DUPLICATE_FEATURE",feature:d,message:`Duplicate GridFeature key: ${d}`});continue}t.set(d,l)}let r=new Set;for(let[l,d]of t){for(let c of Wt(d.requires)){let u=t.get(c.key);u?Hn(u.version,c.version)||(r.add(l),e.push({code:"UNSUPPORTED_FEATURE_VERSION",feature:l,dependency:c.key,message:`GridFeature "${l}" requires "${c.key}" ${c.version}, received ${u.version??"unversioned"}`})):(r.add(l),e.push({code:"MISSING_FEATURE_DEPENDENCY",feature:l,dependency:c.key,message:`GridFeature "${l}" requires missing feature "${c.key}"`}))}for(let c of Ta(d.conflicts))if(t.has(c)){r.add(l),e.push({code:"FEATURE_CONFLICT",feature:l,dependency:c,message:`GridFeature "${l}" conflicts with "${c}"`});break}}let i=[],o=new Set,s=new Set,a=l=>{if(s.has(l))return!r.has(l);if(o.has(l))return r.add(l),e.push({code:"FEATURE_CYCLE",feature:l,message:`GridFeature dependency cycle includes "${l}"`}),!1;let d=t.get(l);if(!d||r.has(l))return!1;o.add(l);let c=!0;for(let u of Wt(d.requires))a(u.key)||(c=!1);return o.delete(l),s.add(l),c?(i.push(d),!0):(r.add(l),!1)};for(let l of t.keys())a(l);return{features:i.filter(l=>!r.has(l.key.trim())),issues:e}}var Da=new Set(["valueFormatter","cellStyle","cellClass"]),xa=new Set(["selectionChanged","sortChanged","filterChanged","columnMoved","columnVisibilityChanged","paginationChanged","detailToggled"]),Ea=0,$t=class{constructor(e,t){this.x=!1;this.gm=0;this.bi=0;this.$d=!1;this.Js="";this.E=new Ve(e=>console.error("[mach-table] resource cleanup error",e));this.activeFeatures=new Map;this.Yd=0;this.wi=0;this.recentErrors=[];this.Tt=null;this.Xd=0;this.Ci=null;this.Zs=0;this.Ti=null;this.Qs=!1;this.ea=null;this.ic=null;this.Yn=new Set;let r;this.Kd=new Promise(i=>{r=i}),this.Ud=r,this.gridId=++Ea,this.r=hi(t),this.ce=new Xe((i,o)=>{o==="gridError"?console.error("[mach-table] error in gridError listener",i):this.reportError(i,"eventBus.listener",{eventType:o})});try{if(this.Ul(t.dataProcessor),this.n=new tt(this),this.i=this.E.A(new dt(this)),this.f=new ct(this),this.o=this.E.A(new It(this)),this.Y=this.E.A(new Gt(this)),this.a=this.E.A(new Ht(this)),this.di=this.E.A(new ut(this)),this.Mn=this.E.A(new ht(this)),this.Xo=this.E.A(new ft(this)),this.l=this.E.A(new yt(this)),this._=new gt(this),this.V=new xt(this),this.we=this.E.A(new St),this.hr=this.E.A(new Mt(i=>this.ym(i))),this.Ts=this.E.A(new bt(this)),this.columnMenu=this.E.A(new wt(this)),this.Us=this.E.A(new Ct(this)),this.Vn=this.E.A(new Tt(this)),this.xn=this.E.A(new Dt(this)),this.fr=this.E.A(new Bt(this)),this.Ne=this.E.A(new _t(this)),this.De=this.E.A(new Vt(this)),this.at=this.E.A(new zt(this)),this.api=Mn(this),this.ft=new Ye(this),this.K=this.E.A(new Et(this)),this.E.add(()=>this.Jd()),this.K.init(),this.o.init(e,this.r),this.xn.init(),this.a.init(),this.Xo.init(),this.Vn.init(),this.fr.init(),this.De.init(),this.at.init(),this.Ne.init(),this.i.Oa(this.r.paginationPage,this.r.paginationPageSize),this.n.Er(this.r.columnDefs),this.i.nt(this.r.advancedFilterModel),this.i.Mt(this.r.quickFilterText),this.En(),this.Zd(this.r.columnDefs),this.ms(t),this.Y.Sn(),this.r.datasource?this.i.Bi().catch(()=>{}):this.i.it(this.r.rowData),this.r.initialState&&this.api.state.apply(this.r.initialState,{emitEvents:!1}),this.ys(),this.ve(),this.Ne.setData(this.r.pinnedTopRowData,this.r.pinnedBottomRowData),this.jl(this.r.features),this.x)return;this.bi=requestAnimationFrame(()=>{this.bi=0,this.x||this.emit("gridReady",{}),this.Qd()})}catch(i){throw this.api&&this.reportError(i,"grid.constructor"),this.destroy(),i}}Ul(e){if(e===this.jd)return!1;let t=++this.Yd,r=typeof e=="function"?e():e;if(this.x||t!==this.Yd)return r?.destroy?.(),!1;let i=this.qd;return this.jd=e,r===this.r.dataProcessor&&i?!1:(this.r.dataProcessor=r,this.qd=r?this.E.add(()=>r.destroy?.()):void 0,i?.(),!0)}whenReady(){return this.Kd}Qd(){this.$d||(this.$d=!0,this.Ud(this.api))}nc(e){return this.r.components?.cellRenderers?.[e]??Ei[e]}Uu(e){return this.r.components?.cellEditors?.[e]}vm(e){return Wt(e.requires).map(t=>t.key).find(t=>!this.activeFeatures.has(t))}jl(e){let t=this.wi+1;if(this.Jd(),this.x||this.wi!==t)return;let r=Yr(e??[]);for(let i of r.issues)this.reportError(new Error(i.message),"feature.manifest",{code:i.code,...i.feature?{key:i.feature}:{},...i.dependency?{dependency:i.dependency}:{}});for(let i of r.features){if(this.x||this.wi!==t)return;let o=i.key.trim(),s=this.vm(i);if(s){this.reportError(new Error(`GridFeature "${o}" dependency "${s}" did not initialise`),"feature.manifest",{code:"FEATURE_DEPENDENCY_SETUP_FAILED",key:o,dependency:s});continue}let a=new Ve(c=>this.reportError(c,"feature.cleanup",{key:o})),l=c=>a.add(c),d={api:this.api,root:this.o.root,getOptions:()=>this.r,addEventListener:(c,u)=>l(this.ce.on(c,u)),onCleanup:c=>{l(c)},addManagedDomListener:(c,u,h,p)=>(c.addEventListener(u,h,p),l(()=>c.removeEventListener(u,h,p))),setManagedTimeout:(c,u)=>{let h=setTimeout(()=>{p(),c()},Math.max(0,u)),p=l(()=>clearTimeout(h));return h},createAbortController:()=>{let c=new AbortController;return l(()=>c.abort()),c},reportError:(c,u,h)=>this.reportError(c,`feature.${u}`,h)};try{let c=i.setup(d);if(typeof c=="function"&&l(c),this.x||this.wi!==t){this.ec(o,{feature:i,scope:a});return}this.activeFeatures.set(o,{feature:i,scope:a})}catch(c){a.dispose(),this.reportError(c,"feature.setup",{key:o})}}}Jd(){this.wi++;let e=[...this.activeFeatures.entries()].reverse();this.activeFeatures.clear();for(let[t,r]of e)this.ec(t,r)}ec(e,t){t.scope.dispose();try{t.feature.destroy?.()}catch(r){this.reportError(r,"feature.destroy",{key:e})}}s(){return this.x}suspend(){this.$e(),this.api.editing.stop({cancel:!0}),this.Ts.close(),this.columnMenu.close(),this.Us.close(),this.Vn.hide(),this.di.Nt(),this.Mn.destroy(),this.a.suspend(),Yi(this.o.root),wi(this.o.root);let e=document.activeElement;e instanceof HTMLElement&&this.o.root.contains(e)&&e.blur()}er(){return++this.gm}c(e,t){let r=t.colDef;if(r.valueGetter)try{return r.valueGetter({api:this.api,colDef:r,column:t,node:e,data:e.data})}catch(i){this.reportError(i,"valueGetter",{colId:t.id,rowId:e.id});return}if(r.field)return W(e.data,r.field)}v(e){return this.r.locale[e]??x[e]}Qi(e,t,r,i){let o=t.colDef;if(o.valueSetter)try{return o.valueSetter({oldValue:i,newValue:r,data:e.data,node:e,colDef:o,column:t,api:this.api})}catch(s){return this.reportError(s,"valueSetter",{colId:t.id,rowId:e.id}),!1}return o.field?De(e.data,o.field,r):!1}_o(e,t,r,i){this.a.Ki(e),this.a.Tl([e.rowIndex],[t.id]),this.V.es({nodeId:e.id,columnId:t.id,oldValue:r,newValue:i}),this.emit("cellValueChanged",{oldValue:r,newValue:i,rowNode:e,rowIndex:e.rowIndex,column:t,colDef:t.colDef,data:e.data})}rl(e){let r=this.n.d().slice(e.c1,e.c2+1).filter(o=>!o.isAutoRowNumber),i=[];for(let o=e.r1;o<=e.r2;o++){let s=this.i.h(o);i.push(r.map(a=>!s||s.isDetail||s.isGroup?"":Ne(this,s,a,"clipboard")))}return Tr(i)}vl(){let e=this.a.ar();return e?Pe(this.rl(e)):Promise.resolve(!1)}Fo(e){this.x||this.pr(this.tc(e,this.n.d()))}async Ru(e,t){let{a:r,n:i,i:o}=this,s=this._.Ji(),a=o.Lr(),l=r.b,d=r.Te(),c=i.d(),u=this.tc(e,c),h=u.map(({node:m})=>m.data);if(!await Pe(t)||!s()||this.r.suppressClipboard||a!==o.Lr()||l!==r.b||d!==r.Te())return;let p=i.d();c.slice(e.c1,e.c2+1).some((m,g)=>m!==p[e.c1+g])||u.every(({node:m,column:g,oldValue:b},C)=>m.data===h[C]&&Object.is(this.c(m,g),b))&&this.pr(u)}tc(e,t){let r=[];for(let i=e.r1;i<=e.r2;i++){let o=this.i.h(i);if(!(!o||o.isDetail||o.isGroup))for(let s=e.c1;s<=e.c2;s++){let a=t[s];!a||!U(a)||a.colDef.rowDrag||r.push({node:o,column:a,oldValue:this.c(o,a),newValue:null})}}return r}pr(e){this._._u(e)}$e(){this._?.Hu()}il(e,t,r){if(this.x)return;let i=Dr(e);if(i.length===0)return;let o=this.n.d(),s=this.i.P(),a=[],l=t;for(let d of i){let c=this.bm(l,s);if(!c)break;this.wm(c.node,d,o,r,a),l=c.index+1}this.pr(a)}bm(e,t){for(let r=e;r<t;r++){let i=this.i.h(r);if(i&&!i.isDetail&&!i.isGroup)return{index:r,node:i}}return null}Cm(e,t){let r=t;for(;r<e.length;){let i=e[r];if(U(i)&&!i.colDef.rowDrag)break;r++}return r}wm(e,t,r,i,o){let s=i,a=o.length;for(let l of t){if(s=this.Cm(r,s),s>=r.length)return;let d=r[s];if(!this.l.oe(e,d)){s++;continue}let c=this.c(e,d);try{let u=d.colDef.valueParser?le(this,e,d,l,"clipboard",c):pt(l,typeof c=="number"||d.colDef.cellEditor==="number");o.push({node:e,column:d,oldValue:c,newValue:u})}catch(u){o.splice(a),this.reportError(u,"validate",{rowId:e.id,colId:d.id});return}s++}}sh(){let e=this.a.Oo();if(!e)return Promise.resolve();let t=this._.Ji(),r=this.i.h(e.row),i=this.n.d()[e.colIdx];if(!r||!i)return Promise.resolve();let o=this.c(r,i),s=this._.jr([{node:r,column:i,oldValue:o,newValue:o}]);try{if(typeof navigator<"u"&&navigator.clipboard?.readText)return navigator.clipboard.readText().then(a=>{let l=this.a.Oo();a&&t()&&s()&&l?.row===e.row&&l.colIdx===e.colIdx&&this.i.h(e.row)===r&&this.n.d()[e.colIdx]===i&&this.il(a,e.row,e.colIdx)}).catch(()=>{})}catch{}return Promise.resolve()}emit(e,t,r=!0){let i={type:e,api:this.api,...t};this.ce.emit(e,i);let o="on"+e.charAt(0).toUpperCase()+e.slice(1),s=this.r[o];if(typeof s=="function")try{s(i)}catch(l){e==="gridError"?console.error("[mach-table] error in onGridError",l):this.reportError(l,`eventHandler.${String(o)}`,{eventType:e})}let a=e==="columnResized"&&!!i.finished;return r&&(a||xa.has(e))&&this.Cn(),i}reportError(e,t,r){let i=e instanceof Error?e.message:String(e),o=this.Tm(t,i);this.recentErrors.push({code:o,source:t,message:i,timestamp:Date.now(),...r?{context:r}:{}}),this.recentErrors.length>50&&this.recentErrors.shift(),console.error(`[mach-table] ${o} (${t})`,e),!this.x&&this.emit("gridError",{code:o,error:e,source:t,context:r})}Tm(e,t){return/^(datasource|treeData)/.test(e)?"DATA_SOURCE_ERROR":e==="rowKey"||t.includes("Duplicate row id")?"DATA_INTEGRITY_ERROR":e==="validate"?"VALIDATION_ERROR":e.toLowerCase().includes("renderer")||Da.has(e)?"RENDERER_ERROR":e.toLowerCase().includes("editor")||e==="editable"?"EDITOR_ERROR":e.startsWith("feature.")?"FEATURE_ERROR":/^(columnState|gridState)\./.test(e)?"STATE_ERROR":/^(eventBus|eventHandler)\./.test(e)?"EVENT_HANDLER_ERROR":"GRID_ERROR"}$h(){return{gridId:this.gridId,version:_e,destroyed:this.x,infinite:this.i.g,loading:this.i.bc()||this.r.loading,rowCount:this.i.Pr(),renderedRowCount:this.o.Le.querySelectorAll(".mach-row[data-index]").length,columnCount:this.n.ee().length,selectedRowCount:this.f.rr().length,dirtyRowCount:this.K.getDirtyRowIds().length,activeFeatures:[...this.activeFeatures].map(([e,t])=>({key:e,...t.feature.version?{version:t.feature.version}:{}})),performance:this.we.snapshot(),updates:this.hr.snapshot(),recentErrors:this.recentErrors.map(e=>({...e,...e.context?{context:{...e.context}}:{}}))}}Ii(e,t){this.n.Ii(e,t),this.Sr()}Sr(){this.Y.vs(),this.emit("sortChanged",{sortModel:this.n.te()}),this.i.To()}ju(e,t){let r=this.i.We();t?r[e.id]=t:delete r[e.id],this.i.St(r),this.ai()}ai(){this.Y.bs(),this.gs(),this.i.To()}gs(e=!0){this.emit("filterChanged",{filterModel:this.i.We(),advancedFilterModel:this.i.Nr()},e)}Rr(e,t){this.n.Rr(e,t)&&(this.si(),this.emit("columnMoved",{colId:e,toIndex:t}))}ji(e){return this.i.ji(e)}Xa(e,t){this.emit("columnResized",{colId:e.id,width:e.currentWidth,finished:t})}st(e){if(!(this.x||e.length===0))for(let t of e){if(this.x)break;this.Xa(t,!0)}}ys(e=!1,t=!1){let r=this.Zs,i=this.Ci,o=this.n.ro().length>0;if(e){if(i==null||!o)return;if(i!==r){this.Ci=null,this.Cn();return}}this.Ci=null;let s=++this.Xd,a=this.r.persistence;if(!a)return;let{key:l,store:d,sections:c}=a;if(!o&&(!c||c.some(p=>p==="columns"||p==="sort"||p==="filter"))){this.Ci=r;return}let u;try{u=d?d.load(l):Ur(l)}catch(p){this.reportError(p,"gridState.load");return}let h=(p,m=!1)=>{if(this.x||s!==this.Xd||r!==this.Zs||!p)return;let g=this.Ti;this.Ti=m?"beforeRows":"normal";try{this.api.state.apply(p,{emitEvents:!1,sections:c})}finally{this.Ti=g}};u&&typeof u.then=="function"?Promise.resolve(u).then(h).catch(p=>this.reportError(p,"gridState.load")):h(u,t)}Sp(){return this.Ti==="beforeRows"}Cn(){let e=this.r.persistence;if(!(!e||this.x||this.Ti)&&(this.Zs++,this.Ci==null)){if(this.Tt&&clearTimeout(this.Tt),e.debounceMs===0){this.Tt=null,this.ta();return}this.Tt=setTimeout(()=>{this.Tt=null,this.ta()},e.debounceMs)}}ta(){let e=this.r.persistence;if(!e||this.x)return;let{key:t,store:r,sections:i}=e,o=this.api.state.get(),s=i?un(o,i):o,a={key:t,...r?{store:r}:{},state:s};if(this.Qs){this.ea=a;return}this.rc(a)}rc(e){try{let t=e.store?e.store.save(e.key,e.state):Kr(e.key,e.state);if(!t||typeof t.then!="function")return;this.Qs=!0,Promise.resolve(t).catch(r=>this.reportError(r,"gridState.save")).finally(()=>{this.Qs=!1;let r=this.ea;this.ea=null,r&&this.rc(r)})}catch(t){this.reportError(t,"gridState.save")}}Ch(){let e=f("div","mach-empty mach-empty--error"),t=f("div","mach-empty__title");t.textContent=this.v("requestFailed");let r=f("div","mach-empty__hint");return r.textContent=this.v("requestFailedHint"),e.append(t,r),e}bh(){let e=f("div","mach-loading"),t=f("div","mach-loading__visual");t.setAttribute("aria-hidden","true");for(let s=0;s<4;s+=1){let a=f("span","mach-loading__row");t.appendChild(a)}let r=f("div","mach-loading__status"),i=f("span","mach-spinner mach-loading__spinner");i.setAttribute("aria-hidden","true");let o=f("span","mach-loading__label");return o.textContent=this.v("loading"),r.append(i,o),e.append(t,r),e}wh(){let e=f("div","mach-empty");e.innerHTML='<svg class="mach-empty__icon" viewBox="0 0 96 84" aria-hidden="true"><rect stroke-opacity=".3" x="8" y="6" width="76" height="66" rx="9"/><path fill="#8b98ff" opacity=".12" stroke="none" d="M17 6H75Q84 6 84 15V26H8V15Q8 6 17 6Z"/><path stroke="var(--mach-body-fg)" opacity=".06" d="M8 26h76M38 26v46M61 26v46M8 42h76M8 57h76"/><path stroke-width="5" opacity=".5" d="M19 15h12m17 0h7m15 0h7"/><path stroke="var(--mach-body-fg)" opacity=".06" stroke-width="4" d="M19 34h12m14 0h8m15 0h8M19 49h12m14 0h8m15 0h8M19 64h12m14 0h8"/><circle stroke-opacity=".3" cx="72" cy="55" r="19"/><circle cx="70" cy="53" r="9"/><path d="m77 60 6 6m-16-16 6 6m0-6-6 6"/></svg>';let{locale:t,manualFiltering:r}=this.r,i=!r&&!this.i.g&&this.i.Ve().length>0&&this.i.Hr(),o=f("div","mach-empty__title");o.textContent=i?t.noMatchingRows??t.emptyRows??this.v("noMatchingRows"):this.v("emptyRows");let s=f("div","mach-empty__hint");if(s.textContent=this.v("emptyRowsHint"),e.append(o),(!i||t.emptyRowsHint)&&e.append(s),i){let a=f("button","mach-toolbar__select-host");a.type="button",a.textContent=this.v("clearFilters"),a.onclick=()=>{this.i.St({}),this.i.nt(null),this.i.Mt(null),this.r.quickFilterText=null,this.ai(),this.o.root.focus({preventScroll:!0})},e.append(a)}return e}ms(e){if(!(this.r.suppressWarnings||this.x)){if(e)for(let t of jr(e)){let r=`${t.code}:${t.option??""}:${t.message}`;this.Yn.has(r)||(this.Yn.add(r),console.warn(`[mach-table:${t.code}] ${t.message}`))}this.r.treeData&&this.n.Je().length>0&&console.warn("[mach-table] treeData \u4E0E rowGroup \u4E0D\u652F\u6301\u540C\u65F6\u542F\u7528\uFF0C\u884C\u5206\u7EC4\u5DF2\u88AB\u5FFD\u7565")}}Zd(e){if(!(this.r.suppressWarnings||this.x)&&this.ic!==e){this.ic=e;for(let t of Nn(e))this.Yn.has(t)||(this.Yn.add(t),console.warn(`[mach-table] ${t}`))}}si(){this.ft.xr=!0,this.hr.Il({columns:!0})}U(e){(e.data||e.cells)&&(this.ft.xr=!0),this.hr.Il(e)}zl(e){return this.hr.batch(e)}ym(e){this.x||(e.columns?this.Dm():(e.header&&this.Y.Sn(),e.pool?this.a.wd():e.layout&&this.ve()),this.xm(e),e.data&&!e.pool&&!e.columns?this.a.Zf():e.cells&&this.a.refreshCells(e.cells===!0?void 0:e.cells),e.pinned&&this.Ne.refresh(),e.summary&&this.De.refresh(),e.overlays&&this.a.Bs())}xm(e){if(!(e.data||e.cells)||e.layout||e.columns||e.pool)return;let t=e.data||e.cells===!0?void 0:e.cells;this.ft.Jn(t)&&this.ir()}Dm(){this.ms(),this.Zd(this.n.ro()),this.a.It(),this.Y.Sn(),this.a.wd(),this.ve(),this.Ne.Re(),this.De.refresh(),this.emit("displayedColumnsChanged",{})}ve(){if(this.x)return;let e=this.we.start();this.En(),this.ft.Jn(),this.n.oa(this.o.us());let t=this.n.d().map(r=>`${r.id}:${r.currentWidth}`).join("|");this.Js&&t!==this.Js&&this.a.It(),this.Js=t,this.o.root.setAttribute("aria-colcount",String(this.n.d().length)),this.Y.gt(),this.a.ve(),this.Ne.gt(),this.De.refresh(),this.we.yh(e)}En(){if(!this.o.root)return;let e=this.r.treeData||this.n.Je().length>0;this.o.root.setAttribute("role",e?"treegrid":"grid"),this.r.rowSelection==="multiple"?this.o.root.setAttribute("aria-multiselectable","true"):this.o.root.removeAttribute("aria-multiselectable"),this.n.d().some(r=>!!r.colDef.editable)?this.o.root.removeAttribute("aria-readonly"):this.o.root.setAttribute("aria-readonly","true")}ir(e=!0){this.x||(this.ft.Jn(),this.n.oa(this.o.us()),e&&this.a.It(),this.Y.gt(),this.a.Dn(),this.a.$n(),this.a.li(!0),this.Ne.gt(),this.De.refresh())}destroy(){if(!this.x){if(this.Tt&&(clearTimeout(this.Tt),this.Tt=null,this.ta()),this.x=!0,this.$e(),this.bi&&cancelAnimationFrame(this.bi),this.bi=0,this.api){this.Qd();try{this.emit("gridDestroyed",{})}catch(e){console.error("[mach-table] grid destroy event",e)}}this.E.dispose(),this.ce.clear()}}};function Ra(n,e={}){if(!n)throw new Error("[mach-table] createGrid requires a container element");if(typeof document>"u")throw new Error("[mach-table] createGrid can only be used in a browser environment");return new $t(n,e).api}function Sa(n){return n.mode==="allMatching"?{mode:"allMatching",excludedKeys:[...n.excludedKeys]}:{mode:"explicit",selectedKeys:[...n.selectedKeys]}}function Ma(n,e){if(e.scope!=="filtered"&&e.scope!=="selected")throw new TypeError("[MachTable] Remote export scope must be filtered or selected.");let t=n.state.get();return{version:1,scope:e.scope,columnIds:t.columns.filter(r=>!r.hide).map(r=>r.colId),sortModel:t.sortModel.map(r=>({...r})),filterModel:ne(t.filterModel),advancedFilterModel:B(t.advancedFilterModel),quickFilterText:t.quickFilterText,...e.scope==="selected"?{selection:Sa(e.selection??{mode:"explicit",selectedKeys:t.selectedRowIds})}:{}}}function Ia(n){return n.value===!0?"\u662F":n.value===!1?"\u5426":""}function Aa(n){return e=>{if(e.value==null||e.value==="")return"";let t=e.value instanceof Date?e.value.toISOString():String(e.value);return n==="datetime"?t.slice(0,16).replace("T"," "):t.slice(0,10)}}function ka(n){return e=>{if(e.value==null)return"";let t=n.find(r=>r.value===e.value);return t?t.label:String(e.value)}}function Ga(n,e){return n.filterable===!1?!1:e==="number"?"number":e==="date"?"date":e==="select"||e==="boolean"?"set":"text"}function Pa(n,e,t){if(e.editable&&(t==="number"||t==="date")&&(n.cellEditor=t),t==="date"){n.valueFormatter=Aa(e.format);return}if(t==="boolean"){n.valueFormatter=Ia;return}if(t!=="select")return;let r=e.options??[];n.valueFormatter=ka(r),e.editable&&(n.cellEditor="select",n.cellEditorParams={options:r})}function Vn(n){let e=n.type??"string",t={colId:n.field,field:n.field,headerName:n.title??n.field,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth,flex:n.flex,pinned:n.pinned??void 0,hide:n.hidden??!1,editable:n.editable??!1,sortable:n.sortable??!0,resizable:n.resizable??!0,filter:Ga(n,e),cellClass:n.cellClass};return Pa(t,n,e),t}function La(n){let e=new Map(n.fields.map(s=>[s.field,s])),t=n.groups??[],r=new Set(t.flatMap(s=>s.fields)),i=new Set,o=[];for(let s of n.fields)i.has(s.field)||r.has(s.field)||(o.push(Vn(s)),i.add(s.field));for(let s of t){let a=[];for(let l of s.fields){let d=e.get(l);!d||i.has(l)||(a.push(Vn(d)),i.add(l))}a.length>0&&o.push({groupId:s.groupId,headerName:s.title,children:a})}return o}function P(n){let e=n();return e&&!e.isDestroyed()?e:null}function Na(n){let e=()=>n.getApi();return{search(t){P(e)?.filtering.setQuickText(t)},async refresh(){if(n.reload){await n.reload();return}let t=P(e);t&&(t.rows.isRemote()?await t.rows.reload():t.view.refreshCells())},openColumns(t){P(e)?.columns.openWorkbench(t)},setDensity(t){P(e)?.updateOptions({size:t})},selectAll(t=!0){P(e)?.selection.selectAll(t)},clearSelection(){let t=P(e);t?.selection.clear(),t?.selection.clearRange()},resetColumns(){P(e)?.columns.resetState()},resetView(){P(e)?.batch(t=>{t.selection.clear(),t.selection.clearRange(),t.filtering.setModel(null),t.filtering.setAdvancedModel(null),t.sorting.setModel(null),t.pagination.setPage(1),t.columns.resetState()})},undo(){return P(e)?.editing.undo()??!1},redo(){return P(e)?.editing.redo()??!1},canUndo(){return P(e)?.editing.canUndo()??!1},canRedo(){return P(e)?.editing.canRedo()??!1},exportCsv(t="mach-table.csv"){let r=P(e);return r?Gr(t,r.io.exportCsv({prependBOM:!0}),"text/csv;charset=utf-8"):!1},async toggleFullscreen(){if(typeof document>"u")return!1;if(document.fullscreenElement)return await document.exitFullscreen?.(),!1;let r=P(e)?.view.getRoot(),i=n.getFullscreenElement?.()??r?.parentElement??r;return i?.requestFullscreen?(await i.requestFullscreen(),!0):!1}}}function Fa(){return{accessor:(n,e={})=>({...e,field:n}),display:n=>({...n}),group:n=>({...n,children:[...n.children]})}}function Oa(n){return[...n]}function Xr(n,e){return e===void 0?n:typeof e!="object"||e===null||typeof n!="object"||n===null?e:{...n,...e}}function Ha(n,e){return typeof n!="function"?e:typeof e!="function"?n:(...t)=>{let r;try{n(...t)}catch(i){r=i}try{e(...t)}catch(i){r??(r=i)}if(r!==void 0)throw r}}function Va(n,e){if(!(!n.components&&!e.components))return{cellRenderers:{...n.components?.cellRenderers,...e.components?.cellRenderers},cellEditors:{...n.components?.cellEditors,...e.components?.cellEditors}}}function Ba(n,e){if(!n.columnTypes&&!e.columnTypes)return;let t={},r=new Set([...Object.keys(n.columnTypes??{}),...Object.keys(e.columnTypes??{})]);for(let i of r)t[i]={...n.columnTypes?.[i],...e.columnTypes?.[i]};return t}function _a(n,e,t){for(let r of new Set([...Object.keys(e),...Object.keys(t)])){if(!/^on[A-Z]/.test(r))continue;let i=e[r],o=t[r];typeof i!="function"||typeof o!="function"||(n[r]=Ha(i,o))}}function za(n,e){let t={...n,...e,features:e.features??n.features};(n.defaultColDef||e.defaultColDef)&&(t.defaultColDef={...n.defaultColDef,...e.defaultColDef}),(n.locale||e.locale)&&(t.locale={...n.locale,...e.locale});let r=Va(n,e);r&&(t.components=r);let i=Ba(n,e);return i&&(t.columnTypes=i),(n.aggFuncs||e.aggFuncs)&&(t.aggFuncs={...n.aggFuncs,...e.aggFuncs}),t.pagination=Xr(n.pagination,e.pagination),t.statusBar=Xr(n.statusBar,e.statusBar),t.watermark=Xr(n.watermark,e.watermark),_a(t,n,e),t}function Bn(...n){return n.reduce(za,{})}function Wa(n={}){return Bn({defaultColDef:{sortable:!0,resizable:!0,movable:!0,filter:!0},enableColumnResize:!0,rowSelection:"multiple",columnMenu:!0,contextMenu:!0,enableRangeSelection:!0,fillHandle:!0,statusBar:!0,stripedRows:!0},n)}function $a(n){return n}function Ka(n){return n}function Ua(n){return n}function Ut(n){return n!=null&&n!==""}function ja(n){if(!Ut(n))return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function Kt(n,e){try{return new Intl.NumberFormat(n,e)}catch{return new Intl.NumberFormat(void 0,e)}}function _n(n,e){try{return new Intl.DateTimeFormat(n,e)}catch{let t={...e};return delete t.timeZone,new Intl.DateTimeFormat(void 0,t)}}function qa(n){if(!Ut(n))return null;let e=n instanceof Date?n:new Date(n);return Number.isFinite(e.getTime())?e:null}function Ya(n={}){let e=n.emptyText??"",t=n.invalidText??"\u2014",r=Kt(n.locale,{maximumFractionDigits:n.maximumFractionDigits??2}),i=Kt(n.locale,{maximumFractionDigits:0}),o=Kt(n.locale,{style:"currency",currency:n.currency??"CNY",currencyDisplay:n.currencyDisplay??"symbol",maximumFractionDigits:n.maximumFractionDigits??2}),s=Kt(n.locale,{style:"percent",maximumFractionDigits:n.maximumFractionDigits??2}),a=_n(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",...n.timeZone?{timeZone:n.timeZone}:{}}),l=_n(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,...n.timeZone?{timeZone:n.timeZone}:{}}),d=(u,h=1)=>({value:p})=>{if(!Ut(p))return e;let m=ja(p);return m==null?t:u.format(m*h)},c=u=>({value:h})=>{if(!Ut(h))return e;let p=qa(h);return p==null?t:u.format(p)};return Object.freeze({text:{align:"left",filter:"text"},number:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(r)},integer:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(i)},money:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(o)},percent:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s)},percentage:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s,.01)},date:{align:"center",filter:"date",cellEditor:"date",valueFormatter:c(a)},datetime:{align:"center",filter:"date",valueFormatter:c(l)},boolean:{align:"center",filter:"set",valueFormatter:({value:u})=>u===!0?n.trueText??"\u662F":u===!1?n.falseText??"\u5426":e},status:{filter:"set",cellRenderer:"statusTag"},link:{filter:"text",cellRenderer:"link"}})}function zn(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Wn(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function $n(n){if(typeof n!="string")return null;let e=n.trim();return e&&e.length<=256?e:null}function Jr(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==1)return null;let t=q({version:2,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pagination:{enabled:!0,page:1,pageSize:e.pageSize},selectedRowIds:[],expandedRowIds:[],expandedGroupIds:[]});return t?{version:1,columns:t.columns,sortModel:t.sortModel,filterModel:t.filterModel,advancedFilterModel:t.advancedFilterModel,quickFilterText:t.quickFilterText,pageSize:t.pagination.pageSize}:null}function Be(n){if(n==null||typeof n!="object")return null;let e=n,t=$n(e.id),r=typeof e.name=="string"?e.name.trim().slice(0,120):"",i=Jr(e.state);if(e.schemaVersion!==1||!t||!r||!i)return null;let o=typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:Date.now(),s=typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)?e.updatedAt:o;return{schemaVersion:1,id:t,name:r,createdAt:o,updatedAt:s,state:i}}function Kn(n){let e=n.state.get();return{version:1,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pageSize:e.pagination.pageSize}}function Un(n,e,t={}){let r=Jr(e);if(!r||n.isDestroyed())return!1;let i=n.state.get();return n.state.apply({...i,columns:r.columns,sortModel:r.sortModel,filterModel:r.filterModel,advancedFilterModel:r.advancedFilterModel,quickFilterText:r.quickFilterText,pagination:{...i.pagination,page:1,pageSize:r.pageSize}},{sections:["columns","sort","filter","pagination"],emitEvents:t.emitEvents}),!0}function jn(n={}){let e=(n.namespace??"mach-table:views").replace(/:+$/,""),t=Math.max(1,Math.floor(n.maxViews??50)),r=Math.max(4096,Math.floor(n.maxBytes??512*1024)),i=l=>`${e}:${encodeURIComponent(l)}`,o=(l,d,c)=>{try{n.onError?.(l,d,c)}catch{}},s=l=>{let d=(n.storage??zn())?.getItem(i(l));if(!d||Wn(d)>r)return[];let c=JSON.parse(d);return c.schemaVersion!==1||!Array.isArray(c.views)?[]:c.views.flatMap(u=>{let h=Be(u);return h?[h]:[]}).slice(0,t)},a=(l,d)=>{let c=JSON.stringify({schemaVersion:1,savedAt:Date.now(),views:d});if(Wn(c)>r)throw new RangeError(`[MachTable] Saved views for "${l}" exceed ${r} bytes.`);let u=n.storage??zn();if(!u)throw new Error("[MachTable] Saved view storage is unavailable.");u.setItem(i(l),c)};return{list(l){try{return s(l)}catch(d){return o(d,"list",l),[]}},save(l,d){try{let c=Be(d);if(!c)throw new TypeError(`[MachTable] Invalid saved view for "${l}".`);let u=s(l).filter(h=>h.id!==c.id);u.unshift(c),a(l,u.slice(0,t))}catch(c){throw o(c,"save",l),c}},remove(l,d){try{a(l,s(l).filter(c=>c.id!==d))}catch(c){throw o(c,"remove",l),c}}}}function Xa(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ja(n,e){let t=e.scope.trim();if(!t||t.length>512)throw new TypeError("[MachTable] Grid view scope must contain between 1 and 512 characters.");let r=e.store??jn(),i=async()=>(await r.list(t)).flatMap(s=>{let a=Be(s);return a?[a]:[]}).sort((s,a)=>a.updatedAt-s.updatedAt);return{list:i,async save(o,s){let a=o.trim().slice(0,120);if(!a)throw new TypeError("[MachTable] Grid view name must be a non-empty string.");let l=$n(s)??Xa(),d=(await i()).find(h=>h.id===l),c=Date.now(),u={schemaVersion:1,id:l,name:a,createdAt:d?.createdAt??c,updatedAt:c,state:Kn(n)};return await r.save(t,u),u},async apply(o,s){let a=typeof o=="string"?(await i()).find(d=>d.id===o):Be(o),l=typeof o=="string"?o:"provided view";if(!a)throw new Error(`[MachTable] Grid view "${l}" was not found.`);if(!Un(n,a.state,s))throw new Error(`[MachTable] Grid view "${a.id}" could not be applied.`);return a},async remove(o){await r.remove(t,o)}}}var ip=_e;export{ot as BUILTIN_AGG_FUNCS,x as DEFAULT_LOCALE,Pr as EVENT_TYPES,Bo as LOCALE_EN,ss as actionsColumn,vo as advancedFilterCondition,bo as advancedFilterGroup,Un as applyGridViewState,La as buildColDefsFromSchema,Kn as captureGridViewState,aa as clearGridState,Ie as createActionButtonsRenderer,vr as createAggResolver,Ya as createBusinessColumnTypes,Fa as createColumnHelper,Wa as createEnterprisePreset,Ra as createGrid,Ja as createGridViewManager,Pn as createLocalGridStateStore,jn as createLocalGridViewStore,Na as createMachTableCommands,Bn as createMachTablePreset,vi as createProgressBarRenderer,Ma as createRemoteExportRequest,ur as createRowActionsRenderer,yi as createStatusTagRenderer,Oa as defineColumns,Ka as defineGridOptions,Ua as defineMachTableConfig,$a as defineMachTablePreset,Vr as describeFilter,Gr as downloadFile,os as dragColumn,me as escapeHtml,$ as formatText,Me as formatTwo,W as getByPath,hr as indexColumn,Se as isColDefGroup,Zt as isSafePath,bi as linkRenderer,Ur as loadGridState,nr as matchLocaleKey,B as normalizeAdvancedFilterModel,Qt as normalizeColumnFilter,ne as normalizeFilterModel,q as normalizeGridState,Jr as normalizeGridViewState,Be as normalizeSavedGridView,xr as parseCsv,Er as parseDelimited,Dr as parseTsv,Yr as resolveGridFeatures,Zs as resolveSaveConflict,sr as resolveTagVariant,as as rowActionsColumn,pe as sanitizeFormulaCell,Kr as saveGridState,ns as selectionColumn,De as setByPath,Tr as toTsv,jr as validateGridOptions,ip as version};
1
+ var We="0.39.2";function v(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function x(n,e,t=!1){if(!(typeof n!="number"||!Number.isFinite(n)||n<e))return t?Math.floor(n):n}function E(n,e,t,i=!1){return x(n,t,i)??e}function I(n){return x(n,0)||void 0}function $e(n){return!n||typeof n.key!="string"||!n.key.trim()?null:{key:n.key.trim(),debounceMs:x(n.debounceMs,0,!0)??160,...n.sections?{sections:[...new Set(n.sections)]}:{},...n.store?{store:n.store}:{}}}function R(n,e,t,i=!1){let r=!1;for(let o of t)(i?v(n,o):n[o]!=null)&&(e[o]=n[o],r=!0);return r}var Xt=new WeakMap,Ke=new WeakMap;function De(n){let e=Xt.get(n);return e||(e={},Xt.set(n,e)),e}function Jt(n){return Xt.get(n)}function Ue(n,e){e?Ke.set(n,e):Ke.delete(n)}function je(n){let e=Ke.get(n);return Ke.delete(n),e}function ue(n,e,t,i,r=e.rowIndex){return{api:n.api,colDef:t.colDef,column:t,node:e,data:e.data,value:i,rowIndex:r}}function Zt(n){if(n==null)return"";if(n instanceof Date)return n.toLocaleDateString();if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function L(n,e){let t=Jt(e);if(!t)return;t.flashTimer&&clearTimeout(t.flashTimer),t.flashTimer=void 0;let i=t.destroy;if(t.destroy=void 0,t.refresh=void 0,t.rendererDefinition=void 0,t.rendererRowId=void 0,t.rendererColumnId=void 0,!!i)try{i()}catch(r){n.reportError(r,"cellRenderer.destroy",{colId:e.dataset.colId})}}function rr(n,e,t,i,r,o){let s=n.t.tooltipComponent?"":o,a=i.colDef.tooltipValueGetter;if(a)try{s=a({api:n.api,colDef:i.colDef,column:i,node:t,data:t.data,value:r})??o}catch(l){n.reportError(l,"tooltipValueGetter",{colId:i.id,rowId:t.id})}s?e.setAttribute("title",s):e.removeAttribute("title")}function Xn(n,e,t,i,r,o){let s=Jt(e);if(!s?.refresh||s.rendererDefinition!==r||s.rendererRowId!==t.id||s.rendererColumnId!==i.id)return!1;try{return e.querySelector(":scope > .mach-cell-edit-trigger")?.remove(),s.refresh(o)!==!1}catch(a){return n.reportError(a,"cellRenderer.refresh",{colId:i.id,rowId:t.id}),!1}}function he(n,e,t){return j(n,e,t,n.d(e,t))}function j(n,e,t,i){let r=t.colDef.valueFormatter;if(r)try{let o=r({api:n.api,colDef:t.colDef,column:t,node:e,data:e.data,value:i});return o==null?"":String(o)}catch(o){n.reportError(o,"valueFormatter",{colId:t.id,rowId:e.id})}return Zt(i)}function Jn(n,e,t,i){let r=i.colDef.cellStyle,o=De(e),s=o.styleKeys;if(s)for(let d of s)Reflect.set(e.style,d,"");if(!r){o.styleKeys=void 0;return}let a;if(typeof r=="function"){let d=n.d(t,i);try{a=r(ue(n,t,i,d))}catch(c){n.reportError(c,"cellStyle",{colId:i.id,rowId:t.id}),a=null}}else a=r;if(!a){o.styleKeys=void 0;return}let l=Object.keys(a);for(let d of l)Reflect.set(e.style,d,Reflect.get(a,d));o.styleKeys=l}function Zn(n,e,t,i){let r=n.d(t,i),o=j(n,t,i,r),s=i.colDef.cellRenderer,a=typeof s=="string"?n.lc(s):s;if(a){let l={api:n.api,colDef:i.colDef,column:i,node:t,data:t.data,value:r,formatted:o,rowIndex:t.rowIndex,rendererParams:i.colDef.cellRendererParams};if(Xn(n,e,t,i,a,l)){rr(n,e,t,i,r,o);return}L(n,e);let d;try{d=a(l)}catch(c){n.reportError(c,"cellRenderer",{colId:i.id,rowId:t.id}),e.textContent=o;return}if(typeof d=="string")e.textContent=d;else if(d instanceof HTMLElement)e.replaceChildren(d);else if(d&&typeof d=="object"&&d.el instanceof HTMLElement){let c=d;e.replaceChildren(c.el);let u=De(e);u.destroy=c.destroy,c.refresh&&(u.refresh=h=>c.refresh(h),u.rendererDefinition=a,u.rendererRowId=t.id,u.rendererColumnId=i.id)}else e.textContent=""}else L(n,e),e.textContent=o;rr(n,e,t,i,r,o)}function qe(n){let{align:e}=n.colDef;return e==="left"?"mach-cell--left":e==="right"?"mach-cell--right":"mach-cell--center"}function Qn(n,e,t,i,r){let o=i.colDef.cellClass;if(!o)return;if(typeof o=="string"){e.push(o);return}if(Array.isArray(o)){e.push(...o);return}let s=ue(n,t,i,r);try{let a=o(s);typeof a=="string"?e.push(a):Array.isArray(a)&&e.push(...a)}catch(a){n.reportError(a,"cellClass",{colId:i.id,rowId:t.id})}}function eo(n,e,t){e.classList.contains("mach-cell--focus")&&n.push("mach-cell--focus"),e.classList.contains("mach-cell--editing")&&n.push("mach-cell--editing"),t.colDef.wrapText&&n.push("mach-cell--wrap")}function Qt(n,e,t,i){let r=n.d(t,i),o=["mach-cell",qe(i)];Qn(n,o,t,i,r),eo(o,e,i);let s=o.join(" ");e.className!==s&&(e.className=s)}function Ye(n,e,t,i){Zn(n,e,t,i),Qt(n,e,t,i),Jn(n,e,t,i)}function xe(n,e){return n&&v(n,e)?n[e]:void 0}function Xe(n,e){if(n==null||n===""||!e||typeof e!="object")return;let t=xe(e,String(n));return typeof t=="string"?{color:t}:t}var Je=class{constructor(e){this.e=e;this.Xn="";this.Jn=[];this.ra=0;this.xi=!0}Zn(e){this.dc()&&(this.xi=!0,e=void 0);let t=this.xi?this.na():void 0,i=t&&io(t,e),r=e?.columns&&new Set(e.columns),o=!1;for(let s of this.e.r.l()){if(s.minWidth!=null&&(!i||r&&!r.has(s.id)))continue;let a=this.cc(s);if(o=s.minWidth!==a||o,s.minWidth=a,to(s)){let l=this.oa(s,t);o=l!==s.contentWidth||o,s.contentWidth=l}}return this.xi=!1,o}dc(){let e=Array.from(document.fonts??[]).filter(s=>s.status==="loaded"),t=e.length!==this.Jn.length||e.some((s,a)=>s!==this.Jn[a]);t&&(this.Jn=e,this.ra++);let i=getComputedStyle(this.e.n.root),r=`${i.getPropertyValue("--mach-header-font-weight")||650} ${i.fontSize} ${i.fontFamily}`,o=r!==this.Xn||t;return this.Xn=r,o}na(){let e=this.e.i.He(),t=Math.min(e.length,100);return Array.from({length:t},(i,r)=>e[Math.floor(r*(e.length-1)/Math.max(t-1,1))])}Qn(e,t){return this.Di===void 0&&(this.Di=document.createElement("canvas").getContext("2d")),this.Di?(this.Di.font=t??this.Xn,this.Di.measureText(e).width):t?1/0:e.replace(/[^\x00-\xff]/g,"mm").length*7}cc(e){let t=e.colDef,i=t.headerName??t.field??e.id;return Math.ceil(Math.max(t.minWidth??0,this.Qn(i)+i.length*.15+28+(e.sortable?20:0)+(e.filterable?28:0)+(this.e.t.columnMenu&&!e.hasCheckbox&&!t.suppressColumnMenu?22:0)))}oa(e,t=this.na()){let i=28;for(let r of t){let o=this.e.d(r,e),s=Xe(o,e.colDef.status)?.label??j(this.e,r,e,o);i=Math.max(i,this.Qn(s.slice(0,128))+(e.colDef.status?44:28))}return Math.ceil(Math.min(I(e.colDef.maxWidth)??360,i))}};function to(n){let{width:e,autoWidth:t}=n.colDef;return n.manualWidth==null&&e==null&&t!==!1&&!n.hasCheckbox&&!n.isDetailToggle}function io(n,e){if(!e?.rowIds&&!e?.rowIndexes)return!0;let t=new Set(e.rowIds),i=new Set(e.rowIndexes);return n.some(r=>t.has(r.id)||i.has(r.rowIndex))}function p(n,e,t){let i=document.createElement(n);if(e&&(i.className=e),t)for(let r of Object.keys(t))i.setAttribute(r,t[r]);return i}function $(n,e,t){let i=p("button",n);return i.type="button",i.textContent=e,i.addEventListener("click",t),i}function S(n,e,t,i=!1){let r=e?"addEventListener":"removeEventListener";for(let[o,s]of Object.entries(t))n[r](o,s,i)}function V(n,e,t){S(document,n,{mousedown:e,keydown:t},!0)}function A(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let i=0;i<t.length;i++){let r=t.item(i);if(!r.startsWith("--mach-"))continue;let o=t.getPropertyValue(r).trim();o&&n.style.setProperty(r,o)}n.style.colorScheme=t.colorScheme}function T(n,e,t){return n<e?e:n>t?t:n}function J(n,e,t=4){let i=e.getBoundingClientRect(),r=n.getBoundingClientRect(),o=i.bottom+t,s=o+r.height>window.innerHeight-8?i.top-r.height-t:o;n.style.left=`${T(i.left,8,Math.max(8,window.innerWidth-r.width-8))}px`,n.style.top=`${T(s,8,Math.max(8,window.innerHeight-r.height-8))}px`}var nr=0;function or(n="rg"){return nr++,`${n}-${nr}`}var sr='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3.5h12L9.5 8v4.5L6.5 14V8L2 3.5z"/></svg>',ar='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 3l4 5H4l4-5z"/></svg>',lr='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 13l4-5H4l4 5z"/></svg>',dr='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round"><path d="M2 4h3m3 0h6M2 8h7m3 0h2M2 12h1m3 0h8"/><circle cx="6.5" cy="4" r="1.35"/><circle cx="10.5" cy="8" r="1.35"/><circle cx="4.5" cy="12" r="1.35"/></svg>';var Ze=class{constructor(e){this.uc=e;this.br=new Map}on(e,t){let i=this.br.get(e);return i||(i=new Set,this.br.set(e,i)),i.add(t),()=>{i.delete(t)}}once(e,t){let i=this.on(e,r=>{i(),t(r)});return i}emit(e,t){let i=this.br.get(e);if(i)for(let r of[...i])try{r(t)}catch(o){console.error(`[mach-table] error in "${e}" listener`,o),this.uc?.(o,e)}}clear(){this.br.clear()}};var ro=new Set(["__proto__","prototype","constructor"]),Re=new Map;function ei(n){if(typeof n!="string"||n.length===0)return null;let e=Re.get(n);if(e!==void 0)return e;let t=n.split("."),i=t.every(r=>r.length>0&&!ro.has(r))?t:null;return n.length<=1024&&(Re.size>=256&&Re.delete(Re.keys().next().value),Re.set(n,i)),i}function ti(n){return ei(n)!==null}function K(n,e){if(n==null)return;let t=ei(e);if(!t)return;let i=n;for(let r of t){if(i==null)return;i=i[r]}return i}function Ee(n,e,t){if(n==null)return!1;let i=ei(e);if(!i)return!1;let r=n;for(let o=0;o<i.length-1;o++){if(typeof r!="object"&&typeof r!="function"||r===null)return!1;r[i[o]]==null&&(r[i[o]]={}),r=r[i[o]]}return typeof r!="object"&&typeof r!="function"||r===null?!1:(r[i[i.length-1]]=t,!0)}var pe={text:["contains","notContains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","inRange","blank","notBlank"],date:["equals","notEquals","lessThan","greaterThan","inRange","blank","notBlank"]};var no=16,oo=512,so=20,ao=2e3,lo=2e3,co={text:new Set(pe.text),number:new Set(pe.number),date:new Set(pe.date)};function uo(n){return n==null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}function ho(n,e,t){if(n==null||typeof n!="object")return null;let i=n;return typeof i.match!="string"||!t.has(i.match)?null:{match:i.match,...po(i,e)}}function po(n,e){let t=e==="number"?x(n.value,-1/0):typeof n.value=="string"?n.value:void 0,i=e==="number"?x(n.value2,-1/0):typeof n.value2=="string"?n.value2:void 0;return{...t!==void 0?{value:t}:{},...i!==void 0?{value2:i}:{}}}function fo(n,e){let t=[],i=co[e];for(let r of n.slice(0,so)){let o=ho(r,e,i);o&&t.push(o)}return t}function ii(n){if(n==null||typeof n!="object")return null;let e=n;return e.type==="set"?Array.isArray(e.values)?{type:"set",values:e.values.filter(uo).slice(0,ao)}:null:e.type!=="text"&&e.type!=="number"&&e.type!=="date"||!Array.isArray(e.conditions)?null:{type:e.type,...e.operator==="or"||e.operator==="and"?{operator:e.operator}:{},conditions:fo(e.conditions,e.type)}}function mo(n,e){if(typeof n.colId!="string"||!n.colId.trim())return null;let t=n.colId.trim();if(e.validColumnIds?.has(t)===!1)return null;let i=ii(n.filter);return i?{kind:"condition",colId:t,filter:i}:null}function go(n,e,t){if(!Array.isArray(n.children))return null;let i=[];for(let r of n.children){let o=cr(r,e+1,t);o&&i.push(o)}return i.length===0?null:{kind:"group",operator:n.operator==="or"?"or":"and",children:i,...n.not===!0?{not:!0}:{}}}function yo(n,e,t){return e<=no&&t.nodes<oo&&n!=null&&typeof n=="object"}function cr(n,e,t){if(!yo(n,e,t)||t.ancestors.has(n))return null;t.ancestors.add(n),t.nodes++;let i=n,r=i.kind==="condition"?mo(i,t):i.kind==="group"?go(i,e,t):null;return t.ancestors.delete(n),r}function B(n,e){if(n==null||typeof n!="object")return null;let t=n;if(t.version!==1||t.root==null)return null;let i=cr(t.root,0,{ancestors:new WeakSet,nodes:0,validColumnIds:e});return i?{version:1,root:i}:null}function vo(n,e){return{kind:"condition",colId:n,filter:e}}function oe(n,e){if(n==null||typeof n!="object"||Array.isArray(n))return{};let t={};for(let[i,r]of Object.entries(n).slice(0,lo)){let o=i.trim();if(!o||e?.has(o)===!1)continue;let s=ii(r);s&&(t[o]=s)}return t}function bo(n,e,t={}){return{kind:"group",operator:n,children:e,...t.not?{not:!0}:{}}}var ri={align:"center",sortable:!0,resizable:!0,movable:!0,filter:!1,minWidth:80},Se={compact:{rowHeight:30,headerHeight:34,fontSize:12,cellPadding:6},normal:{rowHeight:36,headerHeight:40,fontSize:13,cellPadding:9},large:{rowHeight:44,headerHeight:48,fontSize:14,cellPadding:12}},Me={multiSort:!0,stripedRows:!1,showCellBorders:!1,quickFilterText:null,suppressCellFocus:!1,suppressRowHoverHighlight:!1,suppressNoRowsOverlay:!1,suppressHeaderFocus:!1,loading:!1,error:null,className:"",singleClickEdit:!1,manualSorting:!1,manualFiltering:!1,showSummary:!1,rowNumber:!1,indexOffset:0,applyRowDrag:!0,masterDetail:!1,detailToggleColumn:!0,treeData:!1,childrenKey:"children",autoCheckedChildren:!0,defaultExpandAll:!1,columnMenu:!1,suppressWarnings:!1,enableRangeSelection:!1,suppressClipboard:!1,contextMenu:!1,flashCells:!0,fillHandle:!0,ariaLabel:"MachTable data grid",ariaLabelledBy:"",ariaDescribedBy:"",overlayNoRowsTemplate:"",overlayLoadingTemplate:"",overlayErrorTemplate:"",allowUnsafeOverlayHtml:!1},wo=Object.keys(Me);function Co(n){let e={};for(let t of wo)e[t]=n[t]??Me[t];return e}function To(n){return n&&v(Se,n)?n:"normal"}function Do(n,e){let t=typeof n.pagination=="object"&&Array.isArray(n.pagination?.pageSizeOptions)?n.pagination.pageSizeOptions:void 0,i=t?[...new Set(t.map(r=>E(r,0,1,!0)).filter(Boolean))]:[10,20,50,100];return i.includes(e)||i.push(e),i.sort((r,o)=>r-o)}function ni(n,e){let t=typeof n=="function"?n(e):K(e,n);return t==null?"":String(t)}function xo(n,e){let t=Se[e],i=n.rowKey;return{columnDefs:Array.isArray(n.columnDefs)?n.columnDefs:[],rowData:Array.isArray(n.rowData)?n.rowData:[],defaultColDef:{...ri,...n.defaultColDef??{}},columnTypes:n.columnTypes??{},...i?{resolveRowId:({data:r})=>ni(i,r),rowKey:i}:{},rowHeight:E(n.rowHeight,t.rowHeight,1),detailRowHeight:E(n.detailRowHeight,240,1),headerHeight:E(n.headerHeight,t.headerHeight,1),rowBuffer:E(n.rowBuffer,8,0,!0),columnLayout:n.columnLayout==="fit"?"fit":"normal",enableColumnResize:n.enableColumnResize===!0,domLayout:n.domLayout==="autoHeight"?"autoHeight":"normal",maxBodyHeight:x(n.maxBodyHeight,1),rowSelection:n.rowSelection==="single"||n.rowSelection==="multiple"?n.rowSelection:"none",size:e,pinnedTopRowData:Array.isArray(n.pinnedTopRowData)?n.pinnedTopRowData:[],pinnedBottomRowData:Array.isArray(n.pinnedBottomRowData)?n.pinnedBottomRowData:[]}}function Ro(n){let e=typeof n.pagination=="object"?n.pagination:void 0,t=E(e?.pageSize,20,1,!0);return{paginationEnabled:n.pagination!==!1&&n.datasource==null,paginationMode:e?.mode==="server"?"server":"client",paginationPage:E(e?.page,1,1,!0),paginationTotal:E(e?.total,0,0,!0),paginationPageSize:t,paginationPageSizeOptions:Do(n,t),paginationShowTotal:e?e.showTotal!==!1:!0,paginationShowSizeSelector:e?e.showPageSizeSelector!==!1:!0}}function oi(n){let e=n.watermark==null||n.watermark===!1?null:n.watermark===!0?{text:"MachTable"}:n.watermark;return{watermarkEnabled:e!==null,watermarkConfig:e}}function Eo(n){return{advancedFilterModel:B(n.advancedFilterModel),persistence:$e(n.persistence),locale:n.locale??{},tooltipShowDelay:E(n.tooltipShowDelay,600,0),statusBarEnabled:n.statusBar===!0||typeof n.statusBar=="object"&&n.statusBar!=null,statusBarPanels:typeof n.statusBar=="object"&&n.statusBar?.panels?n.statusBar.panels:["rowCount","selectedRowCount","rangeAggregate"]}}var hr={blockSize:100,maxBlocksInCache:12,datasourceMaxConcurrentRequests:4},pr={infiniteBufferRows:40,blockPrefetch:1,datasourceRetryCount:2,datasourceRetryDelay:300},So=Object.keys(hr),Mo=Object.keys(pr);function ur(n,e,t,i){let r=!1;for(let o of t){let s=x(n[o],i,!0);s===void 0||s===e[o]||(e[o]=s,r=!0)}return r}function si(n,e){let t=ur(n,e,So,1);ur(n,e,Mo,0);let i=x(n.datasourceRetryJitter,0);return i!==void 0&&(e.datasourceRetryJitter=Math.min(1,i)),t}function Io(n){let e={...hr,...pr,datasourceRetryJitter:.15};return si(n,e),{...e,datasourceMode:n.datasourceMode==="block"?"block":"sequential",datasourceRowCount:n.datasourceRowCount==null?null:E(n.datasourceRowCount,0,0,!0),dataProcessorMinRows:E(n.dataProcessorMinRows,5e3,1,!0)}}var Ao=["detailRowRenderer","isRowExpandable","aggFuncs","components","actionPolicy","summaryMethod","datasource","getRowHeight","tooltipComponent","getContextMenuItems","initialState","rowEditValidator","isTreeRowExpandable","loadTreeChildren","dataProcessor"];function fr(n){let e=To(n.size),t={...Co(n),...xo(n,e),rowStyleRules:Array.isArray(n.rowStyleRules)?n.rowStyleRules:[],theme:n.theme==="dark"||n.theme==="auto"?n.theme:"light",editType:n.editType==="fullRow"?"fullRow":"cell",editableIndicator:n.editableIndicator==="always"||n.editableIndicator==="none"?n.editableIndicator:"hover",rowDragPolicy:n.rowDragPolicy,undoStackSize:E(n.undoStackSize,100,0,!0),asyncTransactionWaitMillis:E(n.asyncTransactionWaitMillis,16,0,!0),...Ro(n),...oi(n),...Eo(n),...Io(n),features:Array.isArray(n.features)?n.features:[]};for(let i of Ao)n[i]&&Reflect.set(t,i,n[i]);for(let i of Object.keys(n))i.startsWith("on")&&typeof n[i]=="function"&&Reflect.set(t,i,n[i]);return t}function mr(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0):typeof n=="string"&&n.length>0?[n]:[]}function Ie(n,e){return mr(n.type).includes(e)}function gr(n,e,t={}){let i={};for(let o of mr(n.type)){o==="rightAligned"&&(i.align="right");let s=t[o];s&&Object.assign(i,s)}let r={...e,...i,...n};return r.align??(r.align=e.align??"center"),r.status&&!r.cellRenderer&&(r.cellRenderer="statusTag"),r}var Z=class{constructor(e,t){this.manualWidth=null;this.contentWidth=null;this.flex=null;this.currentWidth=0;this.parentGroup=null;this.level=0;this.isDetailToggle=!1;this.id=e,this.colDef=t,this.hide=t.hide??!1;let i=t.pinned;this.pinned=i===!0?"left":i===!1||i==null?null:i,this.resetWidth()}get sortable(){return this.colDef.sortable!==!1}get resizable(){return this.colDef.resizable!==!1}get movable(){return this.colDef.movable!==!1}get filterable(){return this.colDef.filter!=null&&this.colDef.filter!==!1}get filterType(){let e=this.colDef.filter;return e===!0?"text":e??"text"}get hasCheckbox(){return this.colDef.checkboxSelection===!0}resetWidth(){this.manualWidth=null,this.contentWidth=null,this.flex=I(this.colDef.flex)??null}};function q(n){return!n.hasCheckbox&&!n.isDetailToggle&&!n.isAutoRowNumber}function Qe(n){return n.colDef.autoHeight===!0&&!!(n.colDef.valueGetter||n.colDef.valueFormatter)}var Q=class n{constructor(e,t){this.parent=null;this.children=[];this.groupId=e,this.def=t}get headerName(){return this.def.headerName??this.def.groupId??""}getLeafColumns(e=[]){for(let t of this.children)t instanceof n?t.getLeafColumns(e):e.push(t);return e}};function Ae(n){return Array.isArray(n.children)}var et=150,ko=80;function se(n,e){let t=I(e.minWidth)??ko,i=I(e.maxWidth)??Number.MAX_SAFE_INTEGER,r=I(n)??I(e.width)??et;return Math.max(t,Math.min(i,r))}function Po(n,e,t,i){let r=e.map((o,s)=>s).filter(o=>i[o]>0);for(;Math.abs(t)>.001&&r.length;){let o=r.reduce((a,l)=>a+i[l],0),s=0;if(r=r.filter(a=>{let l=e[a];return e[a]=se(l+t*i[a]/o,n[a]),s+=e[a]-l,e[a]!==l}),Math.abs(s)<1e-4)break;t-=s}}function yr(n,e,t){let i=n.map(o=>se(o.width??et,o)),r=e-i.reduce((o,s)=>o+s,0);return(t?Number.isFinite(e)&&e>0:r>0)&&Po(n,i,r,t?[...i]:n.map(o=>o.flex??0)),i}function vr(n,e){return yr(n,e,!1)}function tt(n,e){return yr(n,e,!0)}var _={matchContains:"\u5305\u542B",matchNotContains:"\u4E0D\u5305\u542B",matchEquals:"\u7B49\u4E8E",matchNotEquals:"\u4E0D\u7B49\u4E8E",matchStartsWith:"\u5F00\u5934\u662F",matchEndsWith:"\u7ED3\u5C3E\u662F",matchBlank:"\u4E3A\u7A7A",matchNotBlank:"\u4E0D\u4E3A\u7A7A",matchLessThan:"\u5C0F\u4E8E",matchLessThanOrEqual:"\u5C0F\u4E8E\u7B49\u4E8E",matchGreaterThan:"\u5927\u4E8E",matchGreaterThanOrEqual:"\u5927\u4E8E\u7B49\u4E8E",matchInRange:"\u5728\u8303\u56F4\u5185",apply:"\u5E94\u7528",reset:"\u91CD\u7F6E",search:"\u641C\u7D22...",emptySetLabel:"(\u7A7A)",selectedCount:"\u5DF2\u9009 {n} \u9879",sortAsc:"\u5347\u5E8F",sortDesc:"\u964D\u5E8F",clearSort:"\u53D6\u6D88\u6392\u5E8F",pinLeft:"\u56FA\u5B9A\u5DE6\u4FA7",pinRight:"\u56FA\u5B9A\u53F3\u4FA7",clearPin:"\u53D6\u6D88\u56FA\u5B9A",autoSize:"\u81EA\u9002\u5E94\u5217\u5BBD",hideColumn:"\u9690\u85CF\u6B64\u5217",columnVisibility:"\u5217\u663E\u793A",resetAll:"\u91CD\u7F6E\u5168\u90E8",autoSizeAll:"\u5168\u90E8\u81EA\u9002\u5E94",columnSettings:"\u5217\u8BBE\u7F6E",totalLabel:"\u5408\u8BA1",totalRowsLabel:"\u5171 {n} \u884C",menuCopy:"\u590D\u5236",menuPaste:"\u7C98\u8D34",menuClearContents:"\u6E05\u9664\u5185\u5BB9",loading:"\u52A0\u8F7D\u4E2D...",statusSelected:"\u5DF2\u9009 {n} \u884C",statusSum:"\u548C {n}",statusAvg:"\u5747 {n}",statusCount:"\u8BA1 {n}",emptyRows:"\u6CA1\u6709\u53EF\u663E\u793A\u7684\u884C",emptyRowsHint:"\u6682\u65E0\u6570\u636E",noMatchingRows:"\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u884C",clearFilters:"\u6E05\u9664\u7B5B\u9009",paginationTotal:"\u5171 {n} \u6761",paginationPage:"\u7B2C {a} / {b} \u9875",perPage:"{n} \u6761/\u9875",pageFirst:"\u9996\u9875",pagePrev:"\u4E0A\u4E00\u9875",pageNext:"\u4E0B\u4E00\u9875",pageLast:"\u672B\u9875",requestFailed:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25",requestFailedHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",actionView:"\u67E5\u770B",actionEdit:"\u7F16\u8F91",actionDelete:"\u5220\u9664",actionConfirm:"\u786E\u8BA4",actionSave:"\u4FDD\u5B58",actionCancel:"\u53D6\u6D88",actionMore:"\u66F4\u591A\u64CD\u4F5C",rowDragHandle:"\u62D6\u52A8\u8C03\u6574\u987A\u5E8F\uFF1BAlt + \u4E0A\u4E0B\u65B9\u5411\u952E\u79FB\u52A8",rowDragUnavailable:"\u5F53\u524D\u6392\u5E8F\u6216\u6570\u636E\u6A21\u5F0F\u4E0D\u652F\u6301\u81EA\u52A8\u8C03\u6574\u987A\u5E8F",rowDragPosition:"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",rowDragOutside:"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"},Go={matchContains:"Contains",matchNotContains:"Not Contains",matchEquals:"Equals",matchNotEquals:"Not Equals",matchStartsWith:"Starts With",matchEndsWith:"Ends With",matchBlank:"Blank",matchNotBlank:"Not Blank",matchLessThan:"Less Than",matchLessThanOrEqual:"\u2264",matchGreaterThan:"Greater Than",matchGreaterThanOrEqual:"\u2265",matchInRange:"In Range",apply:"Apply",reset:"Reset",search:"Search...",emptySetLabel:"(blank)",selectedCount:"{n} selected",sortAsc:"Ascending",sortDesc:"Descending",clearSort:"Clear Sort",pinLeft:"Pin Left",pinRight:"Pin Right",clearPin:"Unpin",autoSize:"Auto Fit",hideColumn:"Hide Column",columnVisibility:"Columns",resetAll:"Reset All",autoSizeAll:"Fit All",columnSettings:"Column Settings",totalLabel:"Total",totalRowsLabel:"{n} rows",menuCopy:"Copy",menuPaste:"Paste",menuClearContents:"Clear Contents",loading:"Loading...",statusSelected:"{n} selected",statusSum:"Sum {n}",statusAvg:"Avg {n}",statusCount:"Cnt {n}",emptyRows:"No rows to display",emptyRowsHint:"No data is available.",noMatchingRows:"No rows match the filters",clearFilters:"Clear filters",paginationTotal:"{n} items",paginationPage:"Page {a} / {b}",perPage:"{n} / page",pageFirst:"First",pagePrev:"Previous",pageNext:"Next",pageLast:"Last",requestFailed:"Unable to load data",requestFailedHint:"Check your connection and try again",actionView:"View",actionEdit:"Edit",actionDelete:"Delete",actionConfirm:"Confirm",actionSave:"Save",actionCancel:"Cancel",actionMore:"More actions",rowDragHandle:"Drag to reorder; Alt + Up/Down to move",rowDragUnavailable:"Reordering is unavailable in the current sort or data mode",rowDragPosition:"Row {a} \u2192 Row {b}",rowDragOutside:"Move inside to drop \xB7 Esc to cancel",rowDragSelection:"{a} selected rows \u2192 Row {b}",rowDragBefore:"Before",rowDragAfter:"After",rowDragInside:"Inside",rowDragRejected:"This destination is unavailable"},Lo={contains:"matchContains",notContains:"matchNotContains",equals:"matchEquals",notEquals:"matchNotEquals",startsWith:"matchStartsWith",endsWith:"matchEndsWith",blank:"matchBlank",notBlank:"matchNotBlank",lessThan:"matchLessThan",lessThanOrEqual:"matchLessThanOrEqual",greaterThan:"matchGreaterThan",greaterThanOrEqual:"matchGreaterThanOrEqual",inRange:"matchInRange"};function ai(n){return Lo[n]??"matchEquals"}function U(n,e){return n.replace("{n}",String(e))}function ke(n,e,t){return n.replace("{a}",String(e)).replace("{b}",String(t))}var No=[[/^(success|ok|done|complete|completed|normal|active|enabled|启用|正常|完成|已完成|运行|运行中|在线|生效|已发运)$/i,"success"],[/^(warning|warn|hold|pending|standby|待机|待审核|暂停|预警|部分完成|待下达|待复核|待发运)$/i,"warning"],[/^(error|fail|failed|danger|fault|offline|disabled|故障|失败|错误|异常|停用|离线|断开)$/i,"danger"],[/^(info|processing|new|draft|进行中|新建|草稿|审批中|同步中|执行中|已下达|装车中)$/i,"info"],[/^(neutral|default)$/i,"neutral"]];function di(n,e,t){let i=String(n??"");if(e){let r=xe(e,i);if(r)return r;let o=xe(e,i.toLowerCase());if(o)return o}for(let[r,o]of No)if(r.test(i))return o;return t==null?"neutral":di(t)}function br(n={}){return e=>{if(e.value==null||e.value==="")return"";let t=String(e.value),i=Xe(t,e.colDef.status),r=i?.label??xe(n.labelMap,t)??(e.formatted||t),o=i?.color,s=di(o??t,o?void 0:n.variantMap,r),a=p("span",`mach-tag mach-tag--${s}`);return a.textContent=r,o&&s!==o&&(a.style.color=o,a.style.backgroundColor=`color-mix(in srgb, ${o} 12%, transparent)`),a}}function wr(n={}){return e=>{let t=Number(e.value);if(isNaN(t))return e.formatted;let i=Math.max(0,Math.min(100,t)),r=p("div","mach-progress"),o=p("div","mach-progress__track"),s=p("div","mach-progress__bar");if(s.style.width=`${i}%`,n.color&&(s.style.background=n.color),o.appendChild(s),r.appendChild(o),n.showValue!==!1){let a=p("span","mach-progress__label");a.textContent=`${Math.round(i)}${n.unit??"%"}`,r.appendChild(a)}return r}}function Cr(n){if(n.value==null||n.value==="")return"";let e=p("span","mach-link");return e.textContent=n.formatted||String(n.value),e}var ci={edit:'<path d="M11.5 2.5l2 2L5 13H3v-2l8.5-8.5z"/>',delete:'<path d="M3 5h10M6 5V3h4v2M5 5l.7 8h4.6L11 5"/>',view:'<path d="M1.5 8s2.4-4.2 6.5-4.2S14.5 8 14.5 8s-2.4 4.2-6.5 4.2S1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>',copy:'<rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/>',download:'<path d="M8 2v8m0 0l-3-3m3 3l3-3M2.5 13.5h11"/>',refresh:'<path d="M13 3v4h-4M3 13V9h4"/><path d="M13 7a5.5 5.5 0 00-9.7-2.6M3 9a5.5 5.5 0 009.7 2.6"/>',close:'<path d="M3.5 3.5l9 9m0-9l-9 9"/>',check:'<path d="M2.5 8.5l3.5 3.5 7.5-8"/>',plus:'<path d="M8 2.5v11M2.5 8h11"/>',search:'<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>',more:'<circle cx="3" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="8" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="13" cy="8" r=".9" fill="currentColor" stroke="none"/>'};function it(n,e=14){let t=ci[n]??"";return`<svg viewBox="0 0 16 16" width="${e}" height="${e}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}var te=null,H=null;function Tr(n){H&&n.contains(H)&&Y()}function Y(n=!1){te?.remove(),te=null,H&&(H.setAttribute("aria-expanded","false"),n&&H.isConnected&&H.focus({preventScroll:!0})),H=null,document.removeEventListener("mousedown",Dr,!0),document.removeEventListener("keydown",ui,!0)}function Dr(n){te&&!te.contains(n.target)&&!H?.contains(n.target)&&Y()}function ui(n){if(!te)return;if(n.key==="Escape"){n.preventDefault(),Y(!0);return}let e=[...te.querySelectorAll("button:not(:disabled)")];if(e.length===0)return;if(n.key==="Tab"){let r=e.indexOf(document.activeElement);(!n.shiftKey&&r===e.length-1||n.shiftKey&&r<=0)&&(n.preventDefault(),e[n.shiftKey?e.length-1:0].focus());return}if(n.key!=="ArrowDown"&&n.key!=="ArrowUp")return;n.preventDefault();let t=e.indexOf(document.activeElement),i=n.key==="ArrowDown"?1:-1;e[(t+i+e.length)%e.length].focus()}function xr(n,e){let t=p("button",e);return t.type="button",n.variant&&n.variant!=="default"&&t.classList.add(`${e}--${n.variant}`),t.disabled=n.disabled===!0,n.icon&&ci[n.icon]?(t.innerHTML=it(n.icon,16),t.appendChild(p("span")).textContent=n.label):t.textContent=n.label,t.addEventListener("click",()=>n.pick(t)),t}function Fo(n,e){Y();let t=p("div","mach-context-menu mach-action-menu");t.setAttribute("role","menu");for(let i of e){let r=xr(i,"mach-context-menu-item");r.setAttribute("role","menuitem"),t.appendChild(r)}A(t,n.closest(".mach-root")),document.body.appendChild(t),J(t,n),te=t,H=n,n.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",Dr,!0),document.addEventListener("keydown",ui,!0),t.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function Oo(n,e,t){Y();let i=p("div","mach-action-drawer-backdrop"),r=p("section","mach-action-drawer");r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label",e);let o=p("header","mach-action-drawer__header"),s=p("strong");s.textContent=e;let a=p("button","mach-action-drawer__close");a.type="button",a.setAttribute("aria-label","Close"),a.title="Close",a.innerHTML=it("close",16),a.addEventListener("click",()=>Y(!0)),o.append(s,a);let l=p("div","mach-action-drawer__body");for(let d of t)l.appendChild(xr(d,"mach-action-drawer__item"));r.append(o,l),i.appendChild(r),i.addEventListener("mousedown",d=>{d.target===i&&Y(!0)}),A(i,n.closest(".mach-root")),document.body.appendChild(i),te=i,H=n,n.setAttribute("aria-expanded","true"),document.addEventListener("keydown",ui,!0),r.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function ee(n,e){if(typeof n=="function")try{return n(e)}catch{return!1}return n===!0}function Rr(n){return n.variant??"default"}function Er(n){return n.permission?typeof n.permission=="string"?[n.permission]:n.permission:[]}function hi(n,e,t){return{...n.id?{actionId:n.id}:{},permissions:Er(n),...t?{message:t}:{},params:e}}function rt(n,e,t){let i=t.api.getOption("actionPolicy");try{i?.onError?i.onError(n,hi(e,t)):console.error("[mach-table] action handler failed",n)}catch(r){console.error("[mach-table] action error policy failed",r,n)}}function Ho(n,e){if(Er(n).length===0)return!0;let i=e.api.getOption("actionPolicy");if(!i?.canAccess)return!0;try{return i.canAccess(hi(n,e))}catch(r){return rt(r,n,e),!1}}function Vo(n,e){return n.filter(t=>{if(!Ho(t,e))return!1;if(!t.show)return!0;try{return t.show(e)}catch{return!1}})}function pi(n,e,t){t.isConnected&&(t.disabled=ee(n.disabled,e)||ee(n.loading,e),t.classList.toggle("mach-action-btn--loading",ee(n.loading,e)))}function Bo(n,e,t,i){Promise.resolve(n).catch(r=>rt(r,e,t)).finally(()=>pi(e,t,i))}function _o(n,e,t){try{Bo(n.onClick(e),n,e,t)}catch(i){rt(i,n,e),pi(n,e,t)}}function li(n,e,t){if(n===!1)return!1;let i=typeof n=="string"?n:e.label??e.title??"Confirm action",r=t.api.getOption("actionPolicy");return r?.confirm?r.confirm(hi(e,t,i)):typeof window>"u"||typeof window.confirm!="function"?!1:window.confirm(i)}function zo(n,e){if(n.confirm==null||n.confirm===!1)return!0;if(typeof n.confirm!="function")return li(n.confirm,n,e);let t=n.confirm(e);return t instanceof Promise?t.then(i=>li(i,n,e)):li(t,n,e)}function Wo(n){return(e,t)=>{if(ee(e.disabled,n))return;if(t.disabled=!0,t.classList.add("mach-action-btn--loading"),e.confirm==null||e.confirm===!1){_o(e,n,t);return}(async()=>{await zo(e,n)&&await e.onClick(n)})().catch(r=>rt(r,e,n)).finally(()=>{pi(e,n,t)})}}function $o(n,e,t){let i=p("button","mach-action-btn");i.type="button";let r=Rr(n);r!=="default"&&i.classList.add(`mach-action-btn--${r}`);let o=n.title??n.label??"Action";return i.title=o,i.setAttribute("aria-label",o),i.disabled=ee(n.disabled,e),ee(n.loading,e)&&(i.disabled=!0,i.classList.add("mach-action-btn--loading")),n.icon&&ci[n.icon]?(i.innerHTML=it(n.icon),i.classList.add("mach-action-btn--icon")):i.textContent=n.label??o,i.addEventListener("mousedown",s=>s.stopPropagation()),i.addEventListener("click",s=>{s.stopPropagation(),t(n,i)}),i}function Ko(n,e,t,i,r){let o=p("button","mach-action-btn mach-action-btn--icon");o.type="button";let s=i.api.getOption("locale")??{},a=t.moreLabel??s.actionMore??_.actionMore;return o.title=a,o.setAttribute("aria-label",a),o.setAttribute("aria-haspopup",e==="drawer"?"dialog":"menu"),o.setAttribute("aria-expanded","false"),o.innerHTML=`${it("more",16)}<span class="mach-sr-only">\u22EF</span>`,o.addEventListener("mousedown",l=>l.stopPropagation()),o.addEventListener("click",l=>{l.stopPropagation();let d=n.map(c=>({label:c.label??c.title??"Action",icon:c.icon,variant:Rr(c),disabled:ee(c.disabled,i)||ee(c.loading,i),pick:u=>{Y(),r(c,u)}}));e==="drawer"?Oo(o,t.drawerTitle??a,d):Fo(o,d)}),o}function Pe(n){let e=Math.max(0,n.max??3),t=n.overflow??"menu";return i=>{let r=Vo(n.actions,i);if(r.length===0)return"";let o=p("div","mach-actions"),s=t==="inline"?r:r.slice(0,e),a=t==="inline"?[]:r.slice(e),l=Wo(i);for(let d of s)o.appendChild($o(d,i,l));return a.length>0&&o.appendChild(Ko(a,t,n,i,l)),{el:o,destroy:()=>{H&&o.contains(H)&&Y()}}}}function fe(n,e,t){return n??e??t}function Uo(n,e){let t=e.api.getOption("locale")??{};return{view:fe(n.labels?.view,t.actionView,_.actionView),edit:fe(n.labels?.edit,t.actionEdit,_.actionEdit),delete:fe(n.labels?.delete,t.actionDelete,_.actionDelete),confirm:fe(n.labels?.confirm,t.actionConfirm,_.actionConfirm),save:fe(n.labels?.save,t.actionSave,_.actionSave),cancel:fe(n.labels?.cancel,t.actionCancel,_.actionCancel)}}function jo(n,e,t){let i=async()=>{if(!await e.api.editing.stop()||!n.onSave)return;let s=e.api.editing.getChanges().filter(a=>a.rowId===e.node.id);try{await n.onSave(e,s),e.api.editing.markSaved([e.node.id])}catch(a){throw e.api.editing.startRow(e.rowIndex),a}},r=n.onSave?t.save:n.labels?.confirm??n.labels?.save??t.confirm;return Pe({actions:[{icon:"check",title:r,variant:"success",onClick:i},{icon:"close",title:t.cancel,variant:"danger",onClick:()=>e.api.editing.stop({cancel:!0}).then(()=>{})}],overflow:"inline"})(e)}function qo(n,e,t){let i=[];return n.onView&&i.push({id:"view",icon:"view",title:t.view,variant:"primary",...n.permissions?.view?{permission:n.permissions.view}:{},onClick:n.onView}),n.edit!==!1&&i.push({id:"edit",icon:"edit",title:t.edit,variant:"warning",...n.permissions?.edit?{permission:n.permissions.edit}:{},onClick:n.onEdit??(()=>{e.api.editing.startRow(e.rowIndex)})}),n.onDelete&&i.push({id:"delete",icon:"delete",title:t.delete,variant:"danger",...n.permissions?.delete?{permission:n.permissions.delete}:{},...n.confirmDelete?{confirm:n.confirmDelete===!0?t.delete:n.confirmDelete}:{},onClick:n.onDelete}),i.push(...n.extraActions??[]),i}function fi(n={}){return e=>{let t=Uo(n,e);if(e.api.editing.isRowActive(e.rowIndex))return jo(n,e,t);let i=qo(n,e,t);return Pe({actions:i,max:n.max,overflow:n.overflow??"menu",moreLabel:n.moreLabel,drawerTitle:n.drawerTitle})(e)}}var Yo=br(),Xo=wr(),Sr=Object.freeze({statusTag:Yo,progressBar:Xo,link:Cr});var Ge={sortable:!1,resizable:!1,movable:!1,filter:!1,suppressSizeToFit:!0,suppressColumnMenu:!0};function Jo(n={}){let e=n.width??40;return{colId:"sel",headerName:"",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",checkboxSelection:!0,...Ge,...n}}function mi(n={}){let e=n.width??52;return{colId:"idx",headerName:"#",type:"index",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",align:"center",headerAlign:"center",...Ge,...n}}function Zo(n={}){let e=n.width??40;return{colId:"drag",headerName:"",rowDrag:!0,width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",...Ge,...n}}function Qo(n={actions:[]}){let{width:e,pinned:t,...i}=n,r=i.actions?.length??0,o=i.overflow==="inline"?r:Math.min(r,i.max??3),s=i.overflow!=="inline"&&r>o,a=Math.max(1,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(64,a),pinned:t??"right",cellRenderer:Pe(i),...Ge,cellRendererParams:void 0}}function es(n={}){let{width:e,pinned:t,...i}=n,r=(i.onView?1:0)+(i.edit===!1?0:1)+(i.onDelete?1:0)+(i.extraActions?.length??0),o=i.overflow==="inline"?r:Math.min(r,i.max??3),s=i.overflow!=="inline"&&r>o,a=Math.max(2,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(72,a),pinned:t??"right",cellRenderer:fi(i),...Ge,cellRendererParams:void 0}}var gi="__rg_detail_toggle__";function Le(n){return I(n)!==void 0}function Ir(n){return n===!0?"left":n||null}function Mr(n,e){let t=e;for(let i=2;n.has(t);i++)t=`${e}_${i}`;return n.add(t),t}function ts(n,e){let t=e.colDef,i=n.colDef;n.manualWidth=e.manualWidth,(t.width===i.width&&t.autoWidth===i.autoWidth||t.width!=null||t.autoWidth===!1)&&(n.contentWidth=e.contentWidth),(e.manualWidth!=null||e.flex!==(I(t.flex)??null))&&(n.flex=e.flex),e.hide!==(t.hide??!1)&&(n.hide=e.hide),e.pinned!==Ir(t.pinned)&&(n.pinned=e.pinned)}var nt=class{constructor(e){this.e=e;this.Z=[];this.wr=new Map;this.pe=[];this.eo=[];this.Cr=[];this.to=[];this.fe=[];this.Tr=[];this.Dt=new Map;this.qt=1;this.ro=new Map;this.hc=0}Ri(e){this.Tr=e?[...e]:[];let t=new Map(this.Z.map(c=>[c.id,c])),i=this.e.t.defaultColDef,r=this.e.t.masterDetail&&this.e.t.detailToggleColumn,o=new Set(r?[gi]:[]),s=this.e.t.rowNumber,a=(c,u,h)=>c.map((f,m)=>{if(Ae(f)){let z=f.groupId??f.headerName??`group_${m}_${h}`,W=new Q(z,f);return W.parent=u,W.children=a(f.children,W,h+1),W}let g=f,b=Mr(o,g.colId??g.field??`col_${m}`),C=new Z(b,gr(g,i,this.e.t.columnTypes));s&&(s=!Ie(C.colDef,"index")),C.parentGroup=u,C.level=h;let G=t.get(b);return G&&!G.isAutoRowNumber&&ts(C,G),C});if(this.pe=a(this.Tr,null,0),s&&o.size>Number(r)&&this.pc(Mr(o,"idx"),t),r){let c=new Z(gi,{colId:gi,headerName:"",width:38,pinned:"left",sortable:!1,resizable:!1,movable:!1,filter:!1});c.isDetailToggle=!0,this.pe.unshift(c)}this.Dt.size&&this.fc(),this.Z=this.Dr(this.pe),this.wr=new Map(this.Z.map(c=>[c.id,c])),this.qt=this.Z.reduce((c,u)=>Math.max(c,u.level+1),1);let l=this.fe.length;this.fe=this.fe.filter(c=>this.wr.has(c.colId));let d=this.fe.length!==l;if(this.fe.length===0){let c=[];for(let u of this.Z)u.colDef.initialSort&&!t.has(u.id)&&c.push({colId:u.id,direction:u.colDef.initialSort});this.fe=c}return this.Yt(),d}pc(e,t){let i=new Z(e,mi({colId:e,headerName:"\u5E8F\u53F7"}));i.isAutoRowNumber=!0;let r=t.get(e);r?.isAutoRowNumber&&(i.hide=r.hide);let o=this.pe.findIndex(s=>!(s instanceof Z&&(s.hasCheckbox||s.colDef.rowDrag)));this.pe.splice(o===-1?this.pe.length:o,0,i)}Dr(e,t=[]){for(let i of e)i instanceof Q?this.Dr(i.children,t):t.push(i);return t}Yt(){let e=this.Z.filter(t=>!t.hide);this.eo=e.filter(t=>t.pinned==="left"),this.to=e.filter(t=>t.pinned==="right"),this.Cr=e.filter(t=>t.pinned===null),this.ro.clear(),this.l().forEach((t,i)=>this.ro.set(t.id,i))}Q(e){return this.ro.get(e)??-1}ee(){return this.Z}no(){return this.Tr}mc(){return this.pe}gc(){return this.qt}R(e){return this.wr.get(e)}y(e){return e==="left"?this.eo:e==="right"?this.to:this.Cr}l(){return[...this.eo,...this.Cr,...this.to]}Je(){return this.l().filter(e=>e.colDef.rowGroup===!0)}yc(){return this.l().filter(e=>e.colDef.aggFunc!=null&&e.colDef.rowGroup!==!0)}sa(){let e=this.l();return this.Cr.find(q)??e.find(q)??e[0]}me(e){return e.pinned==="left"?"left":e.pinned==="right"?"right":"center"}aa(e){this.hc=e;let t=e,i=[],r=[];for(let s of this.l()){let a=this.xr(s);s.pinned!=null||s.colDef.suppressSizeToFit||s.manualWidth!=null?(s.currentWidth=se(a.width??et,a),t-=s.currentWidth):(i.push(s),r.push(a))}let o=this.e.t.columnLayout==="fit"?tt(r,Math.max(0,t)):vr(r,Math.max(0,t));i.forEach((s,a)=>{s.currentWidth=o[a]})}xr(e){let t=e.colDef;return{width:e.manualWidth??e.contentWidth??t.width??void 0,minWidth:e.minWidth??t.minWidth,maxWidth:t.maxWidth,flex:e.manualWidth==null?e.flex??void 0:void 0}}Ee(e,t){return Le(t)?(e.manualWidth=se(t,this.xr(e)),e.flex=null,!0):!1}la(e,t){return Le(t)?(e.resetWidth(),e.contentWidth=se(t,this.xr(e)),!0):!1}oo(e,t){let i=this.R(e);!i||i.hide===!t||(i.hide=!t,this.Yt())}Ei(e,t){let i=this.R(e);if(!i)return!1;let r=this.me(i),o=u=>i.parentGroup?!0:this.me(u)===r,s=i.parentGroup?i.parentGroup.children:this.pe,a=[],l=[];s.forEach((u,h)=>{u instanceof Z&&!u.hide&&o(u)&&(a.push(u),l.push(h))});let d=a.indexOf(i);if(d<0)return!1;a.splice(d,1);let c=Math.max(0,Math.min(t,a.length));return a.splice(c,0,i),l.forEach((u,h)=>{s[u]=a[h]}),d!==c&&this.Dt.set(this.da(i),a.filter(u=>u.movable).map(u=>u.id)),this.Z=this.Dr(this.pe),this.Yt(),!0}so(e,t){let i=this.R(e);!i||!i.movable||(i.pinned=t,this.Yt())}ca(e=!0){return(e?this.Z:this.Z.filter(i=>!i.isAutoRowNumber)).map(i=>({colId:i.id,hide:i.hide,width:i.manualWidth??i.currentWidth,flex:i.flex,widthMode:i.manualWidth==null?"auto":"manual",contentWidth:i.contentWidth??void 0,pinned:i.pinned}))}ua(e){let t=new Map(e.map(i=>[i.colId,i]));for(let i of this.Z){let r=t.get(i.id);r&&this.vc(i,r)}this.bc(e),this.Yt()}vc(e,t){typeof t.hide=="boolean"&&(e.hide=t.hide),t.widthMode==="auto"?(e.resetWidth(),Le(t.flex)&&(e.flex=t.flex)):Le(t.flex)?(e.flex=t.flex,e.manualWidth=null):this.Ee(e,t.width),Le(t.contentWidth)&&(e.contentWidth=se(t.contentWidth,this.xr(e))),e.movable&&(t.pinned==="left"||t.pinned==="right"||t.pinned===null)&&(e.pinned=t.pinned)}bc(e){let t=new Map(e.map((i,r)=>[i.colId,r]));this.ao(i=>!i.hide&&i.movable&&t.has(i.id),(i,r)=>{let o=[...i];i.sort((s,a)=>t.get(s.id)-t.get(a.id)),i.some((s,a)=>s!==o[a])&&this.Dt.set(r,i.map(s=>s.id))}),this.Z=this.Dr(this.pe)}da(e){if(!e.parentGroup)return this.me(e);let t=[];for(let i=e.parentGroup;i;i=i.parent)t.push(i.groupId);return JSON.stringify(t)}fc(){let e=new Map;this.ao(t=>t.movable,(t,i)=>{let r=this.Dt.get(i);if(!r)return;let o=new Map(t.map(d=>[d.id,d])),s=r.filter(d=>o.has(d));if(s.length<2)return;let a=new Set(s),l=0;t.forEach((d,c)=>{a.has(d.id)&&(t[c]=o.get(s[l++]))}),e.set(i,s)}),this.Dt=e}ao(e,t,i=this.pe){let r=new Map;i.forEach((o,s)=>{if(o instanceof Q)this.ao(e,t,o.children);else if(e(o)){let a=o.parentGroup?"center":this.me(o),l=r.get(a)??[];l.push(s),r.set(a,l)}});for(let o of r.values()){if(o.length<2)continue;let s=o.map(a=>i[a]);t(s,this.da(s[0])),o.forEach((a,l)=>{i[a]=s[l]})}}lo(){for(let e of this.Z)e.resetWidth(),e.hide=e.colDef.hide??!1,e.pinned=Ir(e.colDef.pinned);if(this.Dt.size){this.Dt.clear(),this.Ri(this.Tr);return}this.Yt()}te(){return this.fe.map(e=>({...e}))}Si(e){if(!e||e.length===0){this.fe=[];return}this.fe=e.filter(t=>this.wr.has(t.colId)&&(t.direction==="asc"||t.direction==="desc")).map(t=>({colId:t.colId,direction:t.direction}))}Rr(e,t){let i=[...this.fe],r=i.findIndex(l=>l.colId===e.id),o=r>=0?i[r].direction:null,s=o===null?"asc":o==="asc"?"desc":null;t&&this.e.t.multiSort?s===null?r>=0&&i.splice(r,1):r>=0?i[r]={colId:e.id,direction:s}:i.push({colId:e.id,direction:s}):(i.length=0,s&&i.push({colId:e.id,direction:s})),this.fe=i}};function k(n){return n!=null&&typeof n.then=="function"}function ie(n,e){if(n instanceof Error)return n;let t=new Error(typeof n=="string"?n:e);return t.name="AbortError",t}var is=()=>ie(void 0,"[MachTable] Operation cancelled.");function ot(n,e,t=is){return e?new Promise((i,r)=>{let o=()=>{e.removeEventListener("abort",o),r(t())};if(n.then(i,r).finally(()=>e.removeEventListener("abort",o)),e.aborted){o();return}e.addEventListener("abort",o,{once:!0})}):n}function Ar(n){return n==null?"":String(n).toLowerCase()}function vi(n,e,t){return n.length===0||(e==="or"?n.some(t):n.every(t))}function rs(n,e,t){let i=Ar(n);return vi(e,t,o=>{let s=(o.value??"").toLowerCase();switch(o.match){case"contains":return i.includes(s);case"notContains":return!i.includes(s);case"equals":return i===s;case"notEquals":return i!==s;case"startsWith":return i.startsWith(s);case"endsWith":return i.endsWith(s);case"blank":return i==="";case"notBlank":return i!=="";default:return!0}})}function kr(n,e,t,i){switch(t){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return n<e;case"lessThanOrEqual":return n<=e;case"greaterThan":return n>e;case"greaterThanOrEqual":return n>=e;case"inRange":return n>=e&&n<=i;default:return!0}}function ns(n,e){let t=n==null||n==="";if(e.match==="blank")return t;if(e.match==="notBlank")return!t;if(t)return!1;let i=typeof n=="number"?n:Number(n);if(Number.isNaN(i))return!1;let r=e.value;return r==null||Number.isNaN(r)?!1:kr(i,r,e.match,e.value2??r)}function os(n,e,t){return vi(e,t,r=>ns(n,r))}function yi(n){if(n==null||n==="")return null;if(typeof n=="number")return n;let e=n instanceof Date?n.getTime():Date.parse(String(n));return isNaN(e)?null:e}function ss(n,e,t){let i=yi(n);return vi(e,t,o=>{let s=i==null;if(o.match==="blank")return s;if(o.match==="notBlank")return!s;if(s)return!1;let a=yi(o.value);if(a==null)return!1;let l=o.match==="inRange"?yi(o.value2)??1/0:a;return kr(i,a,o.match,l)})}function as(n,e){return e.length===0?!0:e.some(t=>t==null&&n==null||t===n)}function ls(n,e){let t=e.type!=="set"&&e.operator==="or"?"or":"and";switch(e.type){case"text":return rs(n,e.conditions,t);case"number":return os(n,e.conditions,t);case"date":return ss(n,e.conditions,t);case"set":return as(n,e.values);default:return!0}}function Pr(n,e,t){return i=>ls(t(i,n),e)}function Gr(n,e,t){if(n.kind==="condition"){let r=e.get(n.colId);return r?Pr(r,n.filter,t):()=>!0}let i=n.children.map(r=>Gr(r,e,t));return r=>{let o=n.operator==="or"?i.some(s=>s(r)):i.every(s=>s(r));return n.not?!o:o}}function bi(n,e,t,i,r){let o=new Map(n.map(l=>[l.id,l])),s=Object.entries(e).flatMap(([l,d])=>{let c=o.get(l);return c?[Pr(c,d,r)]:[]});t&&s.push(Gr(t.root,o,r));let a=i?.trim().toLowerCase().split(/\s+/).filter(Boolean)??[];return l=>s.every(d=>d(l))&&a.every(d=>n.some(c=>Ar(r(l,c)).includes(d)))}var Lr=typeof Intl<"u"?new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}):null;function ds(n,e){let t=n==null||n==="",i=e==null||e==="";return!t&&!i?null:t&&i?0:t?1:-1}function cs(n,e){let t=Number.isNaN(n),i=Number.isNaN(e);return t||i?t===i?0:t?1:-1:n-e}function us(n,e){return n===e?0:n?1:-1}function st(n,e){let t=ds(n,e);if(t!==null)return t;if(typeof n=="number"&&typeof e=="number")return cs(n,e);if(n instanceof Date&&e instanceof Date)return n.getTime()-e.getTime();if(typeof n=="boolean"&&typeof e=="boolean")return us(n,e);let i=String(n),r=String(e);return Lr?Lr.compare(i,r):i.localeCompare(r)}function wi(n,e,t,i){let r=new Map(t.map(a=>[a.id,a])),o=e.flatMap(a=>{let l=r.get(a.colId);return l?[{column:l,compare:l.colDef.comparator??st,direction:a.direction}]:[]}),s=n.map(a=>({node:a,values:o.map(({column:l})=>i(a,l))}));return s.sort((a,l)=>{for(let d=0;d<o.length;d++){let c=o[d],u=c.compare(a.values[d],l.values[d],a.node,l.node);if(u!==0)return c.direction==="asc"?u:-u}return 0}),s.map(({node:a})=>a)}function Nr(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function Fr(n,e){n.count++,!(typeof e!="number"||!Number.isFinite(e))&&(n.numeric++,n.sum+=e,n.min=Math.min(n.min,e),n.max=Math.max(n.max,e))}function Or(n,e){return e==="count"?n?.count??0:n?.numeric?e==="min"?n.min:e==="max"?n.max:Number.isFinite(n.sum)?e==="avg"?n.sum/n.numeric:n.sum:null:null}function at(n,e){let t=Nr();for(let i of n)Fr(t,i);return Or(t,e)}var lt={sum:n=>at(n,"sum"),avg:n=>at(n,"avg"),count:n=>n.length,min:n=>at(n,"min"),max:n=>at(n,"max"),first:n=>n.length>0?n[0]:null,last:n=>n.length>0?n[n.length-1]:null};function Hr(n,e,t){if(e===lt.count)return n.length;let i=["sum","avg","min","max"].find(o=>e===lt[o]);if(!i)return e(n.map(t));let r=Nr();for(let o of n)Fr(r,t(o));return Or(r,i)}function Ci(n){let e={...lt,...n??{}};return t=>e[t]}var dt="group:";function Vr(n){return n==null?"null":n instanceof Date?JSON.stringify(["date",String(n.getTime())]):JSON.stringify([typeof n,Ti(n)])}function Ti(n){return n==null?"(\u7A7A)":String(n)}function Br(n){return dt+JSON.stringify(n)}function hs(n,e,t){let i=new Map;for(let r of n){let o=t(r,e),s=Vr(o),a=i.get(s);a||(a={key:s,label:Ti(o),rows:[]},i.set(s,a)),a.rows.push(r)}return[...i.values()].sort((r,o)=>r.label.localeCompare(o.label,void 0,{numeric:!0,sensitivity:"base"})||r.key.localeCompare(o.key))}function _r(n,e,t,i,r){let o=[],s=(a,l,d)=>{if(l===e.length)return{display:a,leaves:a};let c=[],u=[];for(let h of hs(a,e[l],t)){let f=[...d,[e[l].id,h.key]],m=Br(f);o.push(m);let g=s(h.rows,l+1,f);if(c.push({id:m,data:null,rowIndex:-1,selected:!1,isGroup:!0,groupLevel:l,groupKey:h.label,leafNodes:g.leaves,aggValues:i(g.leaves)}),r.has(m))for(let b of g.display)c.push(b);if(l>0)for(let b of g.leaves)u.push(b)}return{display:c,leaves:u}};return{rows:s(n,0,[]).display,ids:o}}function zr(n,e,t,i){let r=new Set([...n].filter(l=>l.startsWith("/g0:")));if(!r.size)return{expanded:n,ambiguous:[]};let o=new Map;for(let l of e){let d=[],c="";for(let u=0;u<t.length;u++){let h=i(l,t[u]);if(d.push([t[u].id,Vr(h)]),c+=`/g${u}:${Ti(h)}`,!r.has(c))continue;let f=Br(d);o.set(c,o.has(c)&&o.get(c)!==f?null:f)}}let s=new Set([...n].filter(l=>!r.has(l))),a=[];for(let l of r){let d=o.get(l);d?s.add(d):d===null?a.push(l):s.add(l)}return{expanded:s,ambiguous:a}}function ps(n,e){let t=n?[n.root]:[];for(;t.length;){let i=t.pop();if(i.kind==="condition")e.add(i.colId);else for(let r of i.children)t.push(r)}}function Wr(n){let e=new Set(Object.keys(n.filterModel));ps(n.advancedFilter,e);let t=new Set(n.sortModel.map(a=>a.colId));for(let a of t)e.add(a);let i=n.columns.some(a=>a.colDef.rowGroup===!0),r=!!n.quickFilter?.trim(),o=n.columns.filter(a=>e.has(a.id)||r||a.colDef.rowGroup===!0||i&&a.colDef.aggFunc!=null),s=new Set;for(let a of o){let l=a.colDef;if(i&&l.rowGroup!==!0&&l.aggFunc!=null&&n.customAggregates?.[l.aggFunc]||l.valueGetter||t.has(a.id)&&l.comparator||!l.field)return null;s.add(l.field)}return[...s]}function $r(n){return n!=null&&(typeof n=="object"||typeof n=="function")}function Kr(n,e){if(n.length*(e.length+4)>1e6)return null;let t=new WeakMap;for(let i of n){if(i.data==null)continue;let r=e.map(o=>K(i.data,o));r.some($r)||t.set(i,r)}return t}function Ur(n,e,t,i){return t.length?!i||n===e||n==null||e==null?!0:t.some((r,o)=>{let s=K(e,r);return $r(s)||!Object.is(i[o],s)}):!1}function ae(n){return ie(n.reason,"Block request aborted")}function ct(n){return Number.isFinite(n)?Math.max(1,Math.trunc(n)):1}var ut=class{constructor(e,t,i=4){this.maxBlocks=e;this.po=t;this.maxConcurrentRequests=i;this.ie=new Map;this.q=new Map;this.ha=0;this.co=0;this.uo=0;this.pa=0;this.fa=0;this.Er=0;this.Sr=new Set;this.maxBlocks=ct(e),this.maxConcurrentRequests=ct(i)}configure(e,t=this.maxConcurrentRequests){this.maxBlocks=ct(e),this.maxConcurrentRequests=ct(t),this.ho(),this.Mr()}wc(e){this.Sr=e,this.ho()}peek(e){let t=this.ie.get(e);if(t)return t.touchedAt=++this.ha,t}has(e){return this.ie.has(e)}Xt(e){let t=this.q.get(e);t&&(this.q.delete(e),t.controller.abort(),t.state==="queued"&&t.reject(ae(t.controller.signal)));let i=this.ie.get(e);i&&(this.ie.delete(e),this.po?.(e,i))}load(e,t,i,r=0){if(i?.aborted)return Promise.reject(ae(i));let o=this.peek(e);if(o)return this.uo++,Promise.resolve(o);let s=this.q.get(e);if(s)return this.uo++,s.priority=Math.max(s.priority,r),this.Mr(),this.ma(e,s,i);this.pa++;let a=new AbortController,l,d,c=new Promise((f,m)=>{l=f,d=m}),u={controller:a,promise:c,consumers:0,loader:t,priority:r,state:"queued",resolve:l,reject:d};this.q.set(e,u);let h=this.ma(e,u,i);return this.Mr(),h}Cc(){this.co++,this.Sr.clear();for(let e of this.q.values())e.controller.abort(),e.state==="queued"&&e.reject(ae(e.controller.signal));this.q.clear();for(let[e,t]of this.ie)this.po?.(e,t);this.ie.clear()}snapshot(){let e=0,t=0;for(let i of this.ie.values())e+=i.rows.length;for(let i of this.q.values())i.state==="active"&&t++;return{cachedBlockCount:this.ie.size,loadingBlockCount:this.q.size,activeRequestCount:t,queuedRequestCount:Math.max(0,this.q.size-t),cachedRowCount:e,hitCount:this.uo,missCount:this.pa,evictionCount:this.fa}}Mr(){for(;this.Er<this.maxConcurrentRequests;){let e,t;for(let[i,r]of this.q)r.state!=="queued"||r.controller.signal.aborted||(!t||r.priority>t.priority)&&(e=i,t=r);if(e==null||!t)return;this.Tc(e,t)}}Tc(e,t){t.state="active",this.Er++;let i=this.co;this.Dc(t).then(r=>{i===this.co&&!t.controller.signal.aborted&&(this.ie.set(e,{rows:r.rows,...r.lastRow==null?{}:{lastRow:r.lastRow},touchedAt:++this.ha}),this.ho()),t.resolve(r)},t.reject).finally(()=>{this.Er=Math.max(0,this.Er-1),this.q.get(e)===t&&this.q.delete(e),this.Mr()})}Dc(e){let{signal:t}=e.controller;return ot(Promise.resolve().then(()=>{if(t.aborted)throw ae(t);return e.loader(t)}),t,()=>ae(t))}ma(e,t,i){return t.consumers++,new Promise((r,o)=>{let s=!1,a=d=>{s||(s=!0,i?.removeEventListener("abort",l),t.consumers=Math.max(0,t.consumers-1),d())},l=()=>a(()=>{t.consumers===0&&this.q.get(e)===t&&(this.q.delete(e),t.controller.abort(i?.reason),t.state==="queued"&&t.reject(ae(t.controller.signal))),o(ae(i))});i?.addEventListener("abort",l,{once:!0}),t.promise.then(d=>a(()=>r(d)),d=>a(()=>o(d instanceof Error?d:new Error(String(d??"Block request failed")))))})}ho(){let e=Math.max(this.maxBlocks,this.Sr.size+1);for(;this.ie.size>e;){let t=-1,i=Number.POSITIVE_INFINITY;for(let[o,s]of this.ie)this.Sr.has(o)||s.touchedAt<i&&(t=o,i=s.touchedAt);if(t<0)return;let r=this.ie.get(t);this.ie.delete(t),this.fa++,r&&this.po?.(t,r)}}};function me(n,e){if(n==null||typeof n!="object")return;let t=n[e];return Array.isArray(t)?t:void 0}function ge(n,e,t=0,i=new Set){for(let r of n){if(r==null)continue;if(t>=256)throw new RangeError("[MachTable] Tree data exceeds 256 levels.");if(i.has(r))throw new TypeError("[MachTable] Tree data contains a cyclic object graph.");let o=me(r,e);o?.length&&(i.add(r),ge(o,e,t+1,i),i.delete(r))}}var ht=class{constructor(e){this.e=e;this.u=[];this._=[];this.re=new Map;this.ge=[];this.p=new Map;this.Se={};this.Me=null;this.Ve=null;this.k=new Set;this.z=new Set;this.Mi=[];this.Ii=new Map;this.ga=[];this.P=null;this.Ai=!1;this.ya=!1;this.Ze=0;this.Ir=null;this.Ar=new WeakMap;this.kr=new WeakMap;this.Qe=new Map;this.ki=new Map;this.Pr=0;this.Gr=0;this.et=null;this.tt=new Map;this.xt=new Map;this.Lr=new Set;this.Rt=new Map;this.it=new ut(12,e=>this.va(e));this.Pi=0;this.Nr=null;this.fo=!1;this.ba=0;this.ve=[];this.H=1;this.Me=B(e.t.advancedFilterModel)}resolveRowId(e,t,i){let r=this.e.t.resolveRowId;if(!r)return i;try{let o=r({data:e,index:t,api:this.e.api});if(typeof o=="string"&&o.length>0)return o;this.e.reportError(new Error("rowKey must resolve to a non-empty identifier"),"rowKey",{index:t})}catch(o){this.e.reportError(o,"rowKey",{index:t})}return i}get M(){return this.e.t.treeData}get g(){return this.e.t.datasource!=null}get ye(){return this.g&&this.e.t.datasourceMode==="block"}Gi(){if(this.g){if(this.ye)return this.Jt();let e=Math.max(0,this.ge.length-this.u.length);return(this.P??this.u.length)+e}return this.ge.length}Li(){return this.Pr}Be(){return this.Gr}xc(){return this.ya}Fr(e){return!this.g||e?.aborted?Promise.resolve():(this.wa(!0),this.ye?(this.it.configure(this.e.t.maxBlocksInCache,this.e.t.datasourceMaxConcurrentRequests),this.Or(0,e)):this.Ca(0,void 0,e))}Et(e){this.ya=e,this.e.n.Et(e,this.e.c("loading"))}Ca(e,t,i){if(!this.g||this.Ai||this.P!=null&&e>=this.P)return Promise.resolve();let r=this.e.t.blockSize,o=t??e+r;if(o<=e)return Promise.resolve();let s=++this.Ze,a=new AbortController,l=()=>a.abort(i?.reason);return i?.addEventListener("abort",l,{once:!0}),this.Ir=a,this.Ai=!0,this.Et(!0),new Promise(d=>{let c=u=>{i?.removeEventListener("abort",l),s===this.Ze&&(this.Ai=!1,this.Ir=null,this.Et(!1),u!=null&&u?.name!=="AbortError"&&this.e.reportError(u,"datasource.getRows",{startRow:e,endRow:o})),d()};this.Ta(e,o,a.signal,(u,h)=>{if(s!==this.Ze||this.e.o()||a.signal.aborted){c();return}typeof h=="number"&&h>=0?this.P=h:u.length<o-e&&(this.P=e+u.length);let f=this.u.length===0;this.Rc(u),c(),this.I(),f&&this.e.Ie(),this.e.W.Hr()},u=>c(a.signal.aborted||this.e.o()?void 0:u??new Error("Datasource request failed")))})}mo(){this.Ze++,this.Ir?.abort(),this.Ir=null,this.Ai=!1,this.Et(!1),this.it.Cc(),this.tt.clear(),this.xt.clear(),this.Lr.clear();for(let[e,t]of this.Rt)this.p.get(e)===t&&this.p.delete(e);this.Rt.clear()}Rc(e){for(let t of e){if(t==null)continue;let i=this.u.length,r=this.resolveRowId(t,i,`inf-${this.e.Zt()}`);if(this.p.has(r)){this.e.reportError(new Error(`Duplicate row id: ${r}`),"datasource.getRows",{rowId:r});continue}let o={id:r,data:t,rowIndex:-1,selected:this.e.f.Vr(r)};this.u.push(o),this.p.set(r,o),this._.push(o)}}Or(e,t,i=0){if(!this.ye||e<0)return Promise.resolve();if(t?.aborted)return Promise.reject(this.Da(t.reason));let r=this.e.t.blockSize,o=this.Ze,s=e*r;if(s>=this.Jt())return Promise.resolve();let a=this.P==null?s+r:Math.min(this.P,s+r),l=this.it.load(e,d=>this.Ec(s,a,d),t,i);return this.Et(this.u.length===0&&this.it.snapshot().loadingBlockCount>0),l.then(d=>{o!==this.Ze||t?.aborted||this.e.o()||!this.ye||!this.it.has(e)||this.Lr.has(e)||(this.Sc(e,d),this.I(),this.e.W.Hr(),o===this.Ze&&!this.e.o()&&this.xa(this.e.s.go().lastExcl-1))}).catch(d=>{throw d?.name!=="AbortError"&&this.e.reportError(d,"datasource.getRows",{startRow:s,endRow:a}),d}).finally(()=>{o===this.Ze&&this.Et(this.u.length===0&&this.it.snapshot().loadingBlockCount>0)})}Ec(e,t,i){return new Promise((r,o)=>{this.Ta(e,t,i,(s,a)=>r({rows:s,...typeof a=="number"&&a>=0?{lastRow:a}:{}}),s=>o(s instanceof Error?s:new Error(typeof s=="string"?s:"Datasource request failed")))})}Ta(e,t,i,r,o){let s=this.e.t.datasource,a=0,l=null,d=!1,c=()=>d?!1:(d=!0,l!=null&&clearTimeout(l),i.removeEventListener("abort",u),!0),u=()=>{c()&&o(this.Da(i.reason))};i.addEventListener("abort",u,{once:!0});let h=()=>{if(d)return;if(i.aborted||this.e.o()){u();return}a++;let f=!1,m=g=>{if(!(f||d)){if(f=!0,i.aborted||this.e.o()){u();return}a<=this.e.t.datasourceRetryCount?l=setTimeout(h,this.retryDelay(a)):c()&&o(g)}};try{let g=s.getRows({startRow:e,endRow:t,sortModel:this.e.r.te(),filterModel:this._e(),advancedFilterModel:this.Ni(),quickFilterText:this.Ve,signal:i,onSuccess:(b,C)=>{!f&&c()&&r(b??[],C)},fail:m});g&&typeof g.catch=="function"&&g.catch(m)}catch(g){m(g)}};h()}Sc(e,t){let i=this.e.t.blockSize,r=e*i;this.va(e),typeof t.lastRow=="number"&&t.lastRow>=0?this.P=t.lastRow:t.rows.length<i&&(this.P=r+t.rows.length),t.rows.forEach((o,s)=>{if(o==null)return;let a=r+s;if(this.P!=null&&a>=this.P)return;let l=this.resolveRowId(o,a,`block-${a}`),d=this.Rt.get(l),c=this.p.get(l);if(c&&c!==d&&c.rowIndex!==a){this.e.reportError(new Error(`Duplicate row id: ${l}`),"datasource.getRows",{rowId:l});return}let u=d??{id:l,data:o,rowIndex:a,selected:this.e.f.Vr(l)};u.rowIndex=a,u.selected=this.e.f.Vr(l),this.Rt.delete(l),this.tt.set(a,u),this.xt.delete(a),this.p.set(l,u),this.kr.set(u,a+1)}),this.Ra(),this.Lr.add(e)}va(e){this.Lr.delete(e);let t=this.e.t.blockSize,i=e*t,r;for(let o=i;o<i+t;o++){let s=this.tt.get(o);s&&(r??(r=new Set(this.e.$.getDirtyRowIds())),this.tt.delete(o),r.has(s.id)?this.Rt.set(s.id,s):this.p.get(s.id)===s&&this.p.delete(s.id))}this.Ra()}Ra(){this.u=[...this.tt.entries()].sort(([e],[t])=>e-t).map(([,e])=>e),this._=this.u}Jt(){if(this.P!=null)return this.P;if(this.e.t.datasourceRowCount!=null)return this.e.t.datasourceRowCount;if(this.tt.size===0)return this.e.t.blockSize;let e=0;for(let t of this.tt.keys())e=Math.max(e,t+1);return e+this.e.t.blockSize}Mc(e){let t=this.xt.get(e);if(!t&&(t={id:`__mach_loading_${e}`,data:null,rowIndex:e,selected:!1,loading:!0},this.xt.set(e,t),this.xt.size>2e3)){let i=this.xt.keys().next().value;i!=null&&this.xt.delete(i)}return t}Da(e){return ie(e,"Operation aborted")}retryDelay(e){let t=Math.min(this.e.t.datasourceRetryDelay*2**Math.max(0,e-1),3e4),i=this.e.t.datasourceRetryJitter;return Math.max(0,Math.round(t*(1+(Math.random()*2-1)*i)))}Ic(e){if(this.ye){this.xa(e);return}if(!this.g||this.Ai)return;let t=this.u.length;if(this.P!=null&&t>=this.P)return;let i=this.e.t.infiniteBufferRows;if(e+i<t&&e<t)return;let r=this.e.t.blockSize,o=this.P==null?t+r:Math.min(this.P,t+r);this.Ca(t,o)}xa(e){if(e<0)return;this.Ea();let t=this.e.t.blockSize,i=Math.floor(e/t),r=Math.floor(this.e.s.go().first/t),o=this.e.t.blockPrefetch,s=i<this.ba?-1:1;this.ba=i;for(let a=r;a<i;a++)this.Or(a,void 0,o+2).catch(()=>{});for(let a=0;a<=o;a++){let l=a===0?[i]:[i+s*a,i-s*a];for(let d of l)d<0||d*t>=this.Jt()||this.Or(d,void 0,o-a+1).catch(()=>{})}}Sa(){return this.Fr().catch(()=>{})}Ac(){return this.mo(),this.g?this.Fr().catch(()=>{}):(this.P=null,this.rt(this.e.t.rowData),this.e.K({data:!0}),Promise.resolve())}destroy(){this.et=null,this.mo(),this.Ma(),this.yo(),this.u=this._=this.ge=this.ve=[],this.p.clear(),this.re.clear(),this.Ii.clear(),this.ga=[],this.k.clear(),this.z.clear(),this.Mi=[]}vo(e,t,i){if(!this.ye)return Promise.resolve();this.Ea();let r=this.e.t.blockSize,o=Math.max(0,Math.trunc(e)),s=Math.min(this.Jt(),Math.max(o,Math.trunc(t))),a=Math.floor(o/r),l=Math.max(a,Math.floor(Math.max(o,s-1)/r)),d=[];for(let c=a;c<=l;c++)d.push(this.Or(c,i,100));return Promise.all(d).then(()=>{})}kc(){this.ye&&this.wa(!1)}wa(e){this.Ia(),this.e.$.clear(),this.mo(),e&&(this.P=null,this.k.clear()),this.u=[],this._=[],this.p.clear(),this.e.O.clear(),this.I()}Ia(){this.Gr++,this.e.ze(),this.e.api.editing.stop({cancel:!0})}Pc(){return this.it.snapshot()}Ea(){let e=new Set(this.e.$.getDirtyRowIds());for(let[l,d]of this.Rt)e.has(l)||(this.Rt.delete(l),this.p.get(l)===d&&this.p.delete(l));let t=this.e.t.blockSize,i=new Set,{first:r,lastExcl:o}=this.e.s.go();for(let l=r;l<o;l+=t)i.add(Math.floor(l/t));o>r&&i.add(Math.floor((o-1)/t));let s=this.e.s.v;s&&i.add(Math.floor(s.rowIndex/t));let a=this.e.a.Gc();a!=null&&i.add(Math.floor(a/t)),this.it.wc(i)}rt(e){let t=this.e.t.resolveRowId,i=this.e.t.childrenKey;this.M&&ge(e??[],i);let r=[],o=[],s=new Map,a=new Map,l=0,d=(c,u,h)=>{let f=l++,m=this.resolveRowId(c,f,`auto-${f}`);if(s.has(m))return this.e.reportError(new Error(`Duplicate row id: ${m}`),"rowData",{rowId:m,index:f}),null;let g=this.M?me(c,i):void 0,b={id:m,data:c,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(g)};if(this.Ar.set(b,u),r.push(b),s.set(m,b),h!=null){let C=a.get(h)??[];C.push(m),a.set(h,C)}else o.push(b);if(this.M&&Array.isArray(g))for(let C of g)C!=null&&d(C,u+1,m);return b};(e??[]).forEach(c=>{c!=null&&d(c,0,null)}),this.e.t.rowData=e??[],this.Ia(),this.Ma(),this.e.$.clear(),this.u=r,this._=o,this.re=a,this.p=s,this.e.O.clear();for(let c of[...this.k])s.has(c)||this.k.delete(c);if(this.e.t.defaultExpandAll)for(let c of r)this.Aa(c.id)>0&&this.k.add(c.id);this.e.f.ka(t!=null),this.Br()}Fi(e){return this.re.get(e)??[]}Aa(e){return this.re.get(e)?.length??0}bo(e){return this.Aa(e)>0}isTreeRowLoading(e){return this.p.get(e)?.treeLoading===!0}Ma(){for(let e of this.Qe.values())e.abort();this.Qe.clear(),this.ki.clear()}loadTreeChildren(e,t=!1){let i=this.p.get(e),r=this.e.t.loadTreeChildren;if(!this.M||!i?.data||!r)return Promise.resolve([]);if(!t&&i.treeChildrenLoaded)return Promise.resolve(this.Fi(e).flatMap(l=>{let d=this.p.get(l)?.data;return d==null?[]:[d]}));let o=this.ki.get(e);if(o&&!t)return o;this.Qe.get(e)?.abort();let s=new AbortController;this.Qe.set(e,s),i.treeLoading=!0,i.treeLoadError=void 0,this.e.K({data:!0});let a=Promise.resolve().then(()=>r({data:i.data,node:i,api:this.e.api,signal:s.signal})).then(l=>{if(s.signal.aborted||this.e.o())return[];if(!Array.isArray(l))throw new TypeError("[MachTable] loadTreeChildren must resolve to an array.");return this.Lc(i,l),i.treeChildrenLoaded=!0,i.treeLoadError=void 0,this.e.emit("treeChildrenLoaded",{rowId:e,rowNode:i,children:l}),l}).catch(l=>{if(s.signal.aborted||l?.name==="AbortError")return[];throw i.treeLoadError=l,i.treeChildrenLoaded=!1,this.e.reportError(l,"treeData.loadChildren",{rowId:e}),this.e.emit("treeChildrenLoadFailed",{rowId:e,rowNode:i,error:l}),l}).finally(()=>{this.Qe.get(e)===s&&(this.Qe.delete(e),this.ki.delete(e),i.treeLoading=!1,this.e.K({data:!0}))});return this.ki.set(e,a),a}Lc(e,t){let i=new Set,r=[...this.Fi(e.id)];for(;r.length>0;){let s=r.pop();i.has(s)||(i.add(s),r.push(...this.Fi(s)))}this.Nc(t,i,this._r(e)+1);for(let s of i)this.Qe.get(s)?.abort(),this.Qe.delete(s),this.ki.delete(s),this.re.delete(s),this.p.delete(s),this.k.delete(s);this.re.delete(e.id);let o=this._r(e)+1;for(let s of t)s!=null&&this.wo(e,s,o);this.Pa(),this.e.f.ka(this.e.t.resolveRowId!=null),this.I()}Nc(e,t,i){ge(e,this.e.t.childrenKey,i);let r=this.e.t.resolveRowId,o=r?new Set([...this.p.keys()].filter(l=>!t.has(l))):null,s=[...e],a=0;for(;s.length>0;){let l=s.pop();if(l==null)continue;if(r&&o){let c=r({data:l,index:a++,api:this.e.api});if(typeof c!="string"||c.length===0)throw new TypeError("[MachTable] rowKey must resolve to a non-empty identifier for lazy tree children.");if(o.has(c))throw new Error(`Duplicate row id: ${c}`);o.add(c)}let d=me(l,this.e.t.childrenKey);d&&s.push(...d)}}Oi(e,t=!0){this.M&&e.add?.length&&ge(e.add,this.e.t.childrenKey);let i=this.e.t.resolveRowId,r=[],o=[];if(e.remove?.length){let a=new Set,l=new Set,d=u=>{if(i){let f=[this.resolveRowId(u,-1,`__missing_remove_${this.e.Zt()}`)];for(;f.length>0;){let m=f.pop();if(!a.has(m)){a.add(m);for(let g of this.re.get(m)??[])f.push(g)}}}else{let h=[u];for(;h.length>0;){let f=h.pop();l.add(f);let m=this.M?me(f,this.e.t.childrenKey):void 0;if(m)for(let g of m)h.push(g)}}};e.remove.forEach(d),this.u=this.u.filter(u=>{let h=a.has(u.id)||u.data!=null&&l.has(u.data);return h&&(o.push(u.id),this.p.delete(u.id),this.re.delete(u.id)),!h});let c=new Set(this.u);this._=this._.filter(u=>c.has(u))}if(e.update?.length)for(let a of e.update){let l;i?l=this.p.get(this.resolveRowId(a,-1,`__missing_update_${this.e.Zt()}`)):l=this.u.find(d=>d.data===a),l&&(r.push({node:l,before:l.data,after:a}),l.data=a,o.push(l.id),this.e.s.zr(l))}if(e.add?.length){let a=e.addIndex!=null?Math.max(0,Math.min(e.addIndex,this._.length)):this._.length,l=[];e.add.forEach((d,c)=>{let u=this.resolveRowId(d,a+c,`add-${this.e.Zt()}`);if(this.p.has(u)){this.e.reportError(new Error(`Duplicate row id: ${u}`),"transaction.add",{rowId:u});return}let h={id:u,data:d,rowIndex:-1,selected:!1};this.p.set(u,h),this.Ar.set(h,0);let f=this.M?me(d,this.e.t.childrenKey):void 0;if(f)for(let m of f)m!=null&&this.wo(h,m,1);l.push(h)}),this._=this._.slice(0,a).concat(l,this._.slice(a)),this.Pa()}let s={pipelineChanged:this.Fc(e,r),updatedRowIds:r.map(({node:a})=>a.id)};return this.e.O.Oc(o),this.Hc(s,t),this.e.$.Vc(o),s}Hc(e,t){e.pipelineChanged&&(this.et=null),t&&(e.pipelineChanged?this.Br():e.updatedRowIds.length&&this.Ga())}Bc(e){if(e.length===0)return{pipelineChanged:!1,updatedRowIds:[]};let t=this.Gr,i=!1,r=new Set;for(let o of e){let s=this.Oi(o,!1);if(this.Gr!==t)return{pipelineChanged:!1,updatedRowIds:[]};i||(i=s.pipelineChanged);for(let a of s.updatedRowIds)r.add(a)}return i?this.Br():r.size>0&&this.Ga(),{pipelineChanged:i,updatedRowIds:[...r]}}Fc(e,t){if(e.add?.length||e.remove?.length)return!0;if(!t.length)return!1;let i=this.La();if(i===null)return!0;if(!i.length)return!1;let r=this.et;return!r||i.length!==r.fields.length||i.some((o,s)=>o!==r.fields[s])?!0:t.some(({node:o,before:s,after:a})=>Ur(s,a,i,r.values.get(o)))}La(){if(this.M||this.e.t.masterDetail||this.Na())return null;let e=this.e.r.l();if(e.some(i=>Qe(i)||i.colDef.autoRowSpan===!0||i.colDef.rowSpan!=null))return null;let t=!this.e.t.manualFiltering;return Wr({columns:e,customAggregates:this.e.t.aggFuncs,sortModel:this.e.t.manualSorting?[]:this.e.r.te(),filterModel:t?this.Se:{},advancedFilter:t?this.Me:null,quickFilter:t?this.Ve:null})}_c(){let e=this.La(),t=e?.length?Kr(this.u,e):null;this.et=e&&t?{fields:e,values:t}:null}Ga(){this.e.emit("modelUpdated",{rowCount:this.ve.length})}wo(e,t,i){let r=this.resolveRowId(t,-1,`add-${this.e.Zt()}`);if(this.p.has(r)){this.e.reportError(new Error(`Duplicate row id: ${r}`),"transaction.add",{rowId:r});return}let o=me(t,this.e.t.childrenKey),s={id:r,data:t,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(o)};this.p.set(r,s),this.Ar.set(s,i);let a=this.re.get(e.id)??[];if(a.push(s.id),this.re.set(e.id,a),!!o)for(let l of o)l!=null&&this.wo(s,l,i+1)}Pa(){this.u=[];let e=t=>{this.u.push(t),this.p.has(t.id)||this.p.set(t.id,t);for(let i of this.re.get(t.id)??[]){let r=this.p.get(i);r&&e(r)}};for(let t of this._)e(t)}St(e){let t=JSON.stringify(this.Se),i=new Set(this.e.r.ee().map(o=>o.id));this.Se=oe(e,i);let r=JSON.stringify(this.Se)!==t;return r&&(this.et=null),r}_e(){return{...this.Se}}zc(e=this.Me){let t=Object.keys(this.Se).length>0&&this.St(this.Se),i=(e!=null||this.Me!=null)&&this.nt(e);return t||i}nt(e){let t=new Set(this.e.r.ee().map(s=>s.id)),i=B(e,t),r=JSON.stringify(this.Me);this.Me=i,this.e.t.advancedFilterModel=i;let o=JSON.stringify(i)!==r;return o&&(this.et=null),o}Ni(){return B(this.Me)}Mt(e){let t=e!=null&&e.trim()!==""?e:null;return t===this.Ve?!1:(this.Ve=t,this.et=null,!0)}Co(){return this.Ve}Hi(){return Object.keys(this.Se).length>0||this.Me!=null||this.Ve!=null}I(){this.Br(),this.e.K({data:!0})}To(){this.g?this.Sa():this.I()}Br(){this.et=null;let e=this.e.be.start(),t=this.e.r.l(),i=(s,a)=>this.e.d(s,a);if(this.g){this.Wc(e);return}if(this.$c(e))return;let r,o=[];if(this.M)r=this.Kc(t,i);else{r=this.u,this.Hi()&&!this.e.t.manualFiltering&&(r=r.filter(bi(t,this.Se,this.Me,this.Ve,i)));let a=this.e.r.te();if(a.length>0&&!this.e.t.manualSorting)try{r=wi(r,a,t,i)}catch(d){this.e.reportError(d,"comparator",{sortModel:a})}let l=this.e.r.Je();if(l.length>0){let d=this.Uc(r,l);r=d.rows,o=d.ambiguousExpansions}else if(this.e.t.masterDetail){let d=[];for(let c of r)d.push(c),this.k.has(c.id)&&this.isRowExpandable(c)&&d.push({id:`__detail__${c.id}`,data:c.data,rowIndex:-1,selected:!1,isDetail:!0,masterId:c.id});r=d}}this.Fa(r,e,!0),this.jc(o)}Fa(e,t,i=!1){for(let o of this.u)o.rowIndex=-1;let r=0;e.forEach((o,s)=>{o.rowIndex=s,!o.isDetail&&!o.isGroup&&this.kr.set(o,++r)}),this.ve=e,this.Vi(),i&&this._c(),this.qc((o,s)=>this.e.d(o,s)),this.e.emit("modelUpdated",{rowCount:e.length}),this.e.be.Oa(t)}Wc(e){this.u.forEach((t,i)=>{this.ye||(t.rowIndex=i),this.kr.set(t,this.ye?t.rowIndex+1:i+1)}),this.ge=this.u,this.ve=this.u,this.Ii.clear(),this.e.t.getRowHeight&&this.e.s.ot(),this.Pr++,this.e.emit("modelUpdated",{rowCount:this.u.length}),this.e.be.Oa(e)}$c(e){let t=this.fo;return this.fo=!1,!t&&this.Na()?(this.Yc(e),!0):(this.yo(),!1)}Na(){if(!this.e.t.dataProcessor||this.u.length<this.e.t.dataProcessorMinRows||this.M||this.e.t.masterDetail||this.e.r.Je().length>0)return!1;let e=!this.e.t.manualFiltering&&this.Hi(),t=!this.e.t.manualSorting&&this.e.r.te().length>0;return e||t}Yc(e){this.yo();let t=this.e.t.dataProcessor;if(!t)return;let i=++this.Pi,r=new AbortController;this.Nr=r;let o=this.e.r.l(),s=this.u.flatMap(d=>d.data==null?[]:[{id:d.id,data:d.data}]),a=!this.e.t.manualFiltering,l=!this.e.t.manualSorting;Promise.resolve().then(()=>t.process({rows:s,columns:o.map(d=>({colId:d.id,...d.colDef.field?{field:d.colDef.field}:{}})),sortModel:l?this.e.r.te():[],filterModel:a?this._e():{},advancedFilterModel:a?this.Ni():null,quickFilterText:a?this.Ve:null,signal:r.signal})).then(d=>{if(i!==this.Pi||r.signal.aborted||this.e.o())return;let c=new Set,u=[];for(let h of d.rowIds){if(c.has(h))continue;c.add(h);let f=this.p.get(h);f&&!f.isDetail&&!f.isGroup&&u.push(f)}this.Fa(u,e),this.e.K({data:!0})}).catch(d=>{i!==this.Pi||r.signal.aborted||this.e.o()||(this.e.reportError(d,"dataProcessor.process"),this.fo=!0,this.I())}).finally(()=>{i===this.Pi&&(this.Nr=null)})}yo(){this.Pi++,this.Nr?.abort(),this.Nr=null}get we(){return this.e.t.paginationEnabled&&!this.g}Vi(){if(this.e.t.getRowHeight&&this.e.s.ot(),!this.we){this.ge=this.ve,this.Pr++;return}let e=this.Bi(),t=this.getPageCount();this.H>t&&(this.H=t),this.H<1&&(this.H=1),this.e.t.paginationPage=this.H;let i=(this.H-1)*e;this.ge=this.e.t.paginationMode==="server"?this.ve:this.ve.slice(i,i+e),this.ge.forEach((r,o)=>{r.rowIndex=o}),this.Pr++}Bi(){return Math.max(1,this.e.t.paginationPageSize)}Qt(){return this.we?this.H:1}getTotalRowCount(){return this.g?this.Gi():this.we&&this.e.t.paginationMode==="server"?this.e.t.paginationTotal:this.ve.length}getPageCount(){return this.we?Math.max(1,Math.ceil(this.getTotalRowCount()/this.Bi())):1}Ha(){return this.ve}setPage(e,t=!1){if(!this.we)return;let i=this.getPageCount(),r=Math.max(1,Math.min(Math.round(e)||1,i));r!==this.H&&(this.H=r,this.e.t.paginationPage=r,this.Vi(),this.e.K({data:!0}),this.e.s.Wr(0,"top"),t||this._i())}setPageSize(e){if(!this.we)return;let t=Math.max(1,Math.round(e)||this.Bi()),i=(this.H-1)*this.Bi();this.e.t.paginationPageSize=t,this.H=Math.floor(i/t)+1,this.e.t.paginationPage=this.H,this.Vi(),this.e.K({data:!0}),this._i()}Va(e,t){this.e.t.paginationPageSize=t,this.H=e,this.e.t.paginationPage=this.H}Ba(e){this.e.t.paginationEnabled!==e&&(this.e.t.paginationEnabled=e&&!this.g,this.e.t.paginationEnabled&&(this.H=1),e||this.ve.forEach((t,i)=>{t.rowIndex=i}),this.Vi(),this.e.K({data:!0}),this._i())}Xc(){this.we&&(this.H=this.e.t.paginationMode==="server"?this.e.t.paginationPage:1,this.Vi(),this.e.K({data:!0}),this._i())}_i(e=this.Bi()){this.e.emit("paginationChanged",{page:this.Qt(),pageSize:e,pageCount:this.getPageCount(),total:this.getTotalRowCount()})}Kc(e,t){let i=this.e.t.manualSorting?[]:this.e.r.te(),r=new Map,o=this.Hi()&&!this.e.t.manualFiltering,s=bi(e,this.Se,this.Me,this.Ve,t),a=c=>{let u=r.get(c.id);if(u!==void 0)return u;let h=!0;if(o){h=s(c);for(let f of this.re.get(c.id)??[]){let m=this.p.get(f);m&&a(m)&&(h=!0)}}return r.set(c.id,h),h},l=[],d=c=>{let u=c;i.length>0&&(u=wi(c,i,e,t));for(let h of u)if(a(h)&&(l.push(h),this.k.has(h.id))){let f=(this.re.get(h.id)??[]).map(m=>this.p.get(m)).filter(m=>m!=null);d(f)}};return d(this._),l}Jc(){let e=this.ga,t=0;for(let i of this.ge)!i.isDetail&&!i.isGroup&&(e[t++]=i);return e.length=t,e}Zc(e,t,i,r){let o=t.colDef.rowSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:i,rowIndex:e.rowIndex});return Math.max(1,Math.min(Math.round(s)||1,r))}catch(s){return this.e.reportError(s,"rowSpan",{colId:t.id,rowId:e.id}),1}}Qc(e,t,i,r,o){if(!i.colDef.autoRowSpan||r==null||r==="")return 1;let s=1;for(;t+s<e.length&&st(r,o(e[t+s],i))===0;)s++;return s}eu(e,t,i){let r=new Int32Array(e.length),o=0;for(;o<e.length;){let s=e[o],a=i(s,t),l=t.colDef.rowSpan?this.Zc(s,t,a,e.length-o):this.Qc(e,o,t,a,i);r[o]=l;for(let d=1;d<l;d++)r[o+d]=-1;o+=l}return r}qc(e){if(this.Ii.clear(),this.M||this.e.t.masterDetail||this.e.r.Je().length>0)return;let t=this.e.r.l().filter(r=>r.colDef.rowSpan!=null||r.colDef.autoRowSpan===!0);if(t.length===0)return;let i=this.Jc();if(i.length!==0)for(let r of t)this.Ii.set(r.id,this.eu(i,r,e))}tu(e){return this.Ii.get(e)}_a(e){return this.kr.get(e)??0}_r(e){return this.Ar.get(e)??0}Uc(e,t){let i=Ci(this.e.t.aggFuncs),r=this.e.r.yc();this.Mi=[];let o=l=>{let d={};for(let c of r){let u=i(c.colDef.aggFunc);if(u)try{d[c.id]=Hr(l,u,h=>this.e.d(h,c))}catch(h){this.e.reportError(h,"aggFunc",{colId:c.id,aggFunc:c.colDef.aggFunc}),d[c.id]=null}}return d},s=zr(this.z,this.u,t,(l,d)=>this.e.d(l,d));this.z=s.expanded;let a=_r(e,t,(l,d)=>this.e.d(l,d),o,this.z);return this.Mi=a.ids,{rows:a.rows,ambiguousExpansions:s.ambiguous}}jc(e){for(let t of e){if(this.e.o())return;this.e.reportError(new Error(`Ambiguous legacy group expansion: ${t}`),"gridState.groupExpansion",{groupId:t})}}isRowExpandable(e){let t=this.M;if(t){if(this.bo(e.id)||e.treeLoading)return!0;if(e.treeChildrenLoaded||!e.data||!this.e.t.loadTreeChildren)return!1}else if(!this.e.t.masterDetail)return!1;let i=t?"isTreeRowExpandable":"isRowExpandable",r=this.e.t[i];if(!r)return!t;try{return r({data:e.data,node:e,api:this.e.api})}catch(o){return this.e.reportError(o,i,{rowId:e.id}),!1}}isRowExpanded(e){return this.k.has(e)}iu(){return[...this.k]}ru(){return[...this.z]}nu(e,t){this.k=new Set(e.filter(i=>this.p.has(i))),this.z=new Set(t)}ou(e){return this.Do(e,!0)}su(e){return this.Do(e,!1)}$r(e){return this.Do(e,!this.k.has(e))}Do(e,t){let i=this.p.get(e);return!i||t&&!this.isRowExpandable(i)?!1:(t===this.k.has(e)||(t?this.k.add(e):this.k.delete(e),this.I(),this.e.emit("detailToggled",{rowId:e,rowNode:i,expanded:t}),t&&this.M&&!this.bo(e)&&!i.treeLoading&&this.loadTreeChildren(e).catch(()=>{})),t)}setAllDetailsExpanded(e){let t=!1;if(e)for(let i of this.u)!this.k.has(i.id)&&this.isRowExpandable(i)&&(this.k.add(i.id),t=!0);else this.k.size>0&&(this.k.clear(),t=!0);t&&this.I()}xo(e){return this.setGroupExpanded(e,!this.z.has(e))}isGroupExpanded(e){return this.z.has(e)}setAllGroupsExpanded(e){let t=this.z.size;if(e)for(let i of this.Mi)this.z.add(i);else this.z.clear();this.z.size!==t&&this.I()}setGroupExpanded(e,t){return!this.Mi.includes(e)||t===this.z.has(e)||(t?this.z.add(e):this.z.delete(e),this.I()),t}za(){return!this.M&&!this.g&&!this.e.t.dataProcessor&&this.e.t.paginationMode!=="server"&&this.e.r.te().length===0&&this.e.r.Je().length===0}Wa(e,t){if(!this.za()||!Number.isInteger(e)||!Number.isInteger(t))return!1;let i=this.h(e),r=this.h(t);if(!i||!r||i.isDetail||r.isDetail||i.isGroup||r.isGroup)return!1;let o=this.u.indexOf(i),s=this.u.indexOf(r);return o<0||s<0||o===s?!1:(this.u.splice(o,1),this.u.splice(s,0,i),this.I(),!0)}He(){return this.u}au(){return this._}It(){return this.ge}G(){return this.ye?this.Jt():this.ge.length}h(e){return this.ye?e<0||e>=this.Jt()?void 0:this.tt.get(e)??this.Mc(e):this.ge[e]}F(e){return this.p.get(e)}lu(e){this.u.forEach(e)}du(e){let t=0;for(let i of this.ve)i.isDetail||i.isGroup||e(i,t++)}};var pt=class{constructor(e){this.e=e;this.L=new Set;this.At=null;this.zi=new Set}Vr(e){return this.L.has(e)}cu(e){return this.zi.has(e)}We(e,t){if(e.loading)return!1;if(e.isGroup||e.isDetail)return!0;let i=t===void 0?this.Ro():t,r=i?.colDef.selectable;if(!i||!r)return!0;try{return r({api:this.e.api,colDef:i.colDef,column:i,node:e,data:e.data,value:this.e.d(e,i),rowIndex:e.rowIndex})}catch(o){return this.e.reportError(o,"selectable",{rowId:e.id,colId:i.id}),!1}}Ro(){return this.e.r.l().find(e=>e.hasCheckbox&&e.colDef.selectable!=null)}ei(){return this.e.i.He().filter(e=>this.L.has(e.id))}$a(e=this.ei()){return e.filter(t=>t.data!=null).map(t=>t.data)}Eo(){return[...this.L]}Ka(e){let t=new Set(e),i=this.Ro()??null,r=this.e.i.He().filter(o=>t.has(o.id)&&!o.isDetail&&!o.isGroup&&this.We(o,i)).map(o=>({node:o,selected:!0}));this.kt(r,!0)}uu(){this.Ka(this.e.t.rowSelection==="none"?[]:this.Eo())}ka(e){let t=this.e.i;if(!e)this.L.clear(),this.At=null;else{for(let i of this.L)t.F(i)||this.L.delete(i);this.At!=null&&!t.F(this.At)&&(this.At=null)}this.Ua(null);for(let i of t.He())i.selected=this.L.has(i.id)}ja(e){let{selectable:t,selected:i}=this.qa(e.leafNodes??[],!1);return{all:i>0&&i===t,some:i>0}}hu(e,t){let i=(e.leafNodes??[]).filter(r=>this.We(r));i.length!==0&&this.kt(i.map(r=>({node:r,selected:t})))}So(e,t,i=!1){this.kt([{node:e,selected:t,clearOthers:i}])}pu(e,t=!0,i=!0){let r=this.e.i.F(e);r&&this.So(r,t,i)}fu(e,t,i){if(!i||!t.shiftKey||this.At==null)return!1;let r=this.e.i.F(this.At);if(!r||r.rowIndex<0||e.rowIndex<0)return!1;let o=Math.min(r.rowIndex,e.rowIndex),s=Math.max(r.rowIndex,e.rowIndex),a=[];for(let l=o;l<=s;l++){let d=this.e.i.h(l);d&&!d.isDetail&&!d.isGroup&&a.push({node:d,selected:!0})}return this.kt(a),!0}Ya(e,t,i){let r=this.e.t.rowSelection;if(r==="none"||!this.We(e))return;let o=r==="multiple",s=o&&(i||t.ctrlKey||t.metaKey);!s&&this.fu(e,t,o)||(this.So(e,!s||!e.selected,!s),this.At=e.id)}selectAll(e=!0){if(this.e.t.rowSelection==="none")return;let i=e?this.e.i.It():this.e.i.He();this.kt(i.filter(r=>!r.isDetail&&!r.isGroup).map(r=>({node:r,selected:!0})))}deselectAll(){this.kt([],!0)}mu(){let e=this.e.i,{selectable:t,selected:i}=this.qa(e.It(),!0),r=i>0&&i===t&&(!e.g||t>=e.Gi());return{all:r,some:i>0&&!r}}qa(e,t){let i=0,r=0;for(let o of e)t&&(o.isDetail||o.isGroup)||!this.We(o)||(i++,this.L.has(o.id)&&r++);return{selectable:i,selected:r}}gu(e,t){let i=this.e.i,r=this.e.t.rowSelection==="single",o=!r&&i.M&&this.e.t.autoCheckedChildren,s=(a,l,d=!1)=>{if(l?(d||this.We(a,t))&&this.L.add(a.id):this.L.delete(a.id),!!o)for(let c of i.Fi(a.id)){let u=i.F(c);u&&s(u,l)}};for(let{node:a,selected:l}of e)if(s(a,l,!0),r&&l)break}yu(e){let t=new Set(e);for(let i of this.L)t.delete(i)||t.add(i);return t}vu(e){let t=[];for(let i of this.e.i.He()){let r=this.L.has(i.id);(i.selected!==r||e.has(i.id)||this.zi.has(i.id))&&i.rowIndex>=0&&t.push(i.rowIndex),i.selected=r}return t}kt(e,t=!1){let i=this.e.t.rowSelection,r=this.Ro()??null,o=e.filter(c=>!c.selected||i!=="none"&&this.We(c.node,r));if(e.length>0&&o.length===0)return;let s=new Set(this.L);(t||o.some(c=>c.selected?i==="single"||c.clearOthers:c.clearOthers&&this.We(c.node,r)))&&this.L.clear(),this.gu(o,r);let a=new Set(this.zi);this.Ua(r);let l=this.yu(s),d=this.vu(a);if(l.size>0){this.e.s.I(d),this.e.W.Hr();let c=this.ei();this.e.emit("selectionChanged",{selectedNodes:c,selectedRows:this.$a(c)})}}Ua(e){this.zi.clear();let t=this.e.i;if(this.e.t.rowSelection!=="multiple"||!t.M||this.L.size===0)return;let i=r=>{let o=e&&t.F(r),s=!o||this.We(o,e),a=!0,l=!1;for(let d of t.Fi(r)){let c=i(d);a&&(a=c.all),l||(l=c.some)}if(a&&!l){s||this.L.delete(r);let d=this.L.has(r);return{all:d||!s,some:d}}return s&&a?this.L.add(r):(this.L.delete(r),s&&l&&this.zi.add(r)),{all:a,some:l}};for(let r of t.au())i(r.id)}};var ft=class{constructor(e){this.e=e;this.Pt=null;this.ne=0;this.st=0;this.$e=null;this.ti=null;this.Wi=e=>{let t=this.Ao(e);t&&(this.st=this.Ja(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.st-t.startWidth)>=.5),!this.ne&&(this.ne=requestAnimationFrame(()=>{this.ne=0,this.Cu()})))};this.ri=e=>{let t=this.Ao(e);t&&(this.st=this.Ja(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.st-t.startWidth)>=.5),this.Tu(t))};this.Kr=e=>{this.Ao(e)&&this.Gt()};this.Du=()=>{this.Gt()}}bu(e,t){if(!this.e.t.enableColumnResize||!t.resizable||e.isPrimary===!1)return;this.Gt();let i=e.currentTarget,r=t.currentWidth;this.st=r,this.Pt={column:t,didResize:!1,handle:i,pointerId:e.pointerId,startFlex:t.flex,startManualWidth:t.manualWidth,startWidth:r,startX:e.clientX},this.Mo(i,!0);try{i.setPointerCapture?.(e.pointerId)}catch{}this.e.n.root.classList.add("mach-root--resizing"),i.classList.add("mach-header-resize--active"),this.wu(this.Pt)}Gt(e=!0){let t=this.Pt;t&&(this.Pt=null,this.Io(),this.Mo(t.handle,!1),e&&(t.column.manualWidth=t.startManualWidth,t.column.flex=t.startFlex,this.e.ii()),this.e.n.root.classList.remove("mach-root--resizing"),this.Xa(t))}Tu(e){this.Pt=null,this.Io(),e.didResize&&(Math.abs(this.st-e.startWidth)<.5?(e.column.manualWidth=e.startManualWidth,e.column.flex=e.startFlex):this.e.r.Ee(e.column,this.st),this.e.ii()),this.Mo(e.handle,!1);try{e.handle.releasePointerCapture?.(e.pointerId)}catch{}this.e.n.root.classList.remove("mach-root--resizing"),this.Xa(e),e.didResize&&this.e.at([e.column])}Cu(){let e=this.Pt;!e||!this.e.r.Ee(e.column,this.st)||(this.e.ii(),this.$i(e),this.e.Za(e.column,!1))}wu(e){this.$e=p("div","mach-column-resize-guide"),this.$e.setAttribute("aria-hidden","true"),this.ti=p("span","mach-column-resize-label"),this.$e.appendChild(this.ti),this.e.n.root.appendChild(this.$e),this.$i(e)}$i(e){if(!this.$e||!this.ti)return;let t=this.e.n.root,i=t.getBoundingClientRect(),r=e.handle.parentElement.getBoundingClientRect(),o=Math.max(0,Math.min(t.clientWidth,r.right-i.left-t.clientLeft)),s=Math.max(32,Math.min(t.clientWidth-32,o));this.$e.style.left=`${o}px`,this.$e.style.top=`${Math.max(0,r.top-i.top-t.clientTop)}px`,this.ti.style.left=`${s-o}px`,this.ti.textContent=`${Math.round(e.column.currentWidth)} px`}Xa(e){e.handle.classList.remove("mach-header-resize--active"),this.$e?.remove(),this.$e=null,this.ti=null}Ja(e,t){let i=Number.isFinite(t)?t:e.startX;return Math.max(1,e.startWidth+i-e.startX)}Ao(e){let t=this.Pt;return t&&e.pointerId===t.pointerId?t:null}Io(){this.ne&&cancelAnimationFrame(this.ne),this.ne=0}Mo(e,t){S(window,t,{pointermove:this.Wi}),S(window,t,{pointerup:this.ri,pointercancel:this.Kr},!0),S(e,t,{lostpointercapture:this.Du})}destroy(){this.Gt(!1),this.Io(),this.e.n.root?.classList.remove("mach-root--resizing")}};var jr=6,mt=class{constructor(e){this.e=e;this.Ki=null;this.ni=null;this.ko=!1;this.ae=0;this.Ur=null;this.Wi=e=>{if(this.ni){this.Eu(e);return}let t=this.Ki;t&&(Math.abs(e.clientX-t.startX)<jr&&Math.abs(e.clientY-t.startY)<jr||this.Su(e))};this.ri=e=>{this.Ki=null,e.type!=="pointercancel"&&this.ni&&this.Go(e.clientX,e.clientY),this.Po();let t=this.Qa();t&&e.type!=="pointercancel"&&t.targetIndex>=0&&this.e.Ei(t.column.id,t.targetIndex)}}xu(e,t){e.button===0&&t.movable&&(this.Ki={column:t,startX:e.clientX,startY:e.clientY},this.Ui(!0))}Ui(e){S(window,e,{pointermove:this.Wi,pointerup:this.ri,pointercancel:this.ri})}Ru(){let e=this.ko;return this.ko=!1,e}Su(e){let t=this.Ki;if(!t)return;let i=this.e.W.oi(t.column.id,this.e.r.me(t.column));if(!i||!i.parentElement){this.Po();return}this.ko=!0;let r=p("div","mach-drop-indicator"),o=p("div","mach-column-drag-ghost");o.textContent=t.column.colDef.headerName??t.column.colDef.field??t.column.id,o.ariaHidden="true",A(o,this.e.n.root),document.body.appendChild(o),i.parentElement.appendChild(r),i.classList.add("mach-header-cell--dragging"),this.e.n.root.classList.add("mach-root--dragging");let s=this.e.r.me(t.column),a=this.e.n.si[s],l=this.e.r.y(s),d=new Float64Array(l.length+1),c=new Float64Array(l.length);for(let h=0;h<l.length;h++){let f=l[h].currentWidth;c[h]=d[h]+f/2,d[h+1]=d[h]+f}let u=o.getBoundingClientRect();this.ni={column:t.column,cellEl:i,ghost:o,indicator:r,targetIndex:-1,pane:s,containerLeft:a.getBoundingClientRect().left,startScrollLeft:this.e.n.C.center.scrollLeft,fromIndex:l.indexOf(t.column),midpoints:c,offsets:d,ghostWidth:u.width,ghostHeight:u.height},this.Go(e.clientX,e.clientY)}Eu(e){this.Ur={clientX:e.clientX,clientY:e.clientY},!this.ae&&(this.ae=requestAnimationFrame(()=>{this.ae=0;let t=this.Ur;this.Ur=null,t&&this.Go(t.clientX,t.clientY)}))}Go(e,t){let i=this.ni;if(!i)return;let r=T(e+12,8,window.innerWidth-i.ghostWidth-8),o=T(t+12,8,window.innerHeight-i.ghostHeight-8);i.ghost.style.transform=`translate3d(${r}px, ${o}px, 0)`;let s=i.pane==="center"?this.e.n.C.center.scrollLeft-i.startScrollLeft:0,a=e-(i.containerLeft-s),l=i.midpoints.length;for(let d=0;d<i.midpoints.length;d++)if(a<i.midpoints[d]){l=d;break}i.targetIndex=l>i.fromIndex?l-1:l,i.indicator.style.transform=`translate3d(${i.offsets[l]}px, 0, 0)`}Qa(){let e=this.ni;return e?(this.ni=null,e.cellEl.classList.remove("mach-header-cell--dragging"),e.ghost.remove(),e.indicator.remove(),this.e.n.root.classList.remove("mach-root--dragging"),e):null}Po(){this.Ui(!1),this.ae&&cancelAnimationFrame(this.ae),this.ae=0,this.Ur=null}destroy(){this.Po(),this.Qa(),this.Ki=null}};var Di=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function gt(n,e=!0){if(n==="")return null;if(!e||typeof n!="string"||!Di.test(n)||/^[+-]?0\d/.test(n))return n;let t=Number(n);return Number.isFinite(t)&&(!Number.isInteger(t)||Number.isSafeInteger(t))?t:n}function fs(n,e){let t=n==null?"":String(n);return t.includes(e)||t.includes('"')||t.includes(`
2
+ `)||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t}function ye(n){return typeof n!="string"||n===""||Di.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function qr(n,e={}){let t=e.columnSeparator??",",i=e.protectFormulas??!0,r=n.map(o=>o.map(s=>fs(i?ye(s):s,t)).join(t)).join(`\r
3
+ `);return e.prependBOM?"\uFEFF"+r:r}function xi(n){return n==null?"":String(n)}function ms(n,e){let t=e?ye(n):n,i=xi(t);return/["\t\n\r]/.test(i)?'"'+i.replace(/"/g,'""')+'"':i}function Ri(n,e=!0){return n.map(t=>t.map(i=>ms(i,e)).join(" ")).join(`
4
+ `)}function Ei(n){return Mi(n," ")}function Si(n,e=","){return Mi(n,e)}function Mi(n,e){let t=[],i=[],r="",o=!1,s=0;for(;s<n.length;){let a=n[s];a==='"'&&(o||r==="")?o&&n[s+1]==='"'?(r+=a,s++):o=!o:o?r+=a:a===e?(i.push(r),r=""):a===`
5
+ `||a==="\r"?(i.push(r),t.push(i),i=[],r="",a==="\r"&&n[s+1]===`
6
+ `&&s++):r+=a,s++}return(r!==""||i.length>0)&&(i.push(r),t.push(i)),t}function gs(n){let e=null;try{return e=document.createElement("textarea"),e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy")}catch{return!1}finally{e?.remove()}}async function Ne(n){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(n),!0}catch{}return gs(n)}var Yr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),ys=new Set([...Yr,"Enter","F2","Tab"," ","Escape","Delete","Backspace"]),yt=class{constructor(e){this.e=e;this.il=e=>{if(this.Lo(e)||this.e.o()||this.e.t.suppressClipboard)return;let t=this.e.s.ai();if(!t)return;let i=this.e.nl(t),r=e.clipboardData;if(e.preventDefault(),r&&typeof r.setData=="function"){try{r.setData("text/plain",i)}catch{return}e.type==="cut"&&this.e.No(t)}else e.type==="cut"?this.e.Au(t,i):Ne(i)};this.Iu=e=>{if(this.Lo(e)||this.e.t.suppressClipboard)return;let t=this.e.s.Fo();if(!t)return;let i=e.clipboardData,r=i&&typeof i.getData=="function"?i.getData("text/plain"):null;typeof r!="string"||r===""||(e.preventDefault(),this.e.ol(r,t.row,t.colIdx))};this.Mu=e=>{this.Lo(e)||this.e.o()||this.ku(e)||ys.has(e.key)&&(this.Pu(e)||this.Gu(e)||this.Lu(e))}}init(){this.tl(!0)}destroy(){this.tl(!1)}tl(e){S(this.e.n.root,e,{keydown:this.Mu,copy:this.il,cut:this.il,paste:this.Iu})}rl(e,t,i){let r=this.e.r.l(),o=this.e.r.Q(t);if(o<0)return null;let s=this.e.i.G(),a=o,l=e;for(let d=0;d<(r.length+1)*(s+1);d++){if(a+=i,a>=r.length){if(l>=s-1)return null;a=0,l=this.Lt(l+1,1)}else if(a<0){if(l<=0)return null;a=r.length-1,l=this.Lt(l-1,-1)}if(l<0||l>=s)return null;let c=this.e.i.h(l);if(c&&!c.isDetail&&this.e.a.oe(c,r[a]))return{rowIndex:l,column:r[a]}}return null}Lt(e,t){let i=this.e.i.G();for(;e>=0&&e<i;){let r=this.e.i.h(e);if(!r||!r.isDetail)return e;e+=t}return-1}Lo(e){let t=e.target;return e.defaultPrevented||t instanceof HTMLElement&&(t.isContentEditable||!!t.closest("button,a[href],input,textarea,select"))||this.e.a.isEditing()}ku(e){if(!e.ctrlKey&&!e.metaKey)return!1;let t=e.key.toLowerCase();return t==="a"?(this.e.t.rowSelection==="multiple"&&(e.preventDefault(),this.e.f.selectAll(!0)),!0):e.altKey||t!=="z"&&t!=="y"?!1:(e.preventDefault(),t==="z"&&!e.shiftKey?this.e.O.undo():this.e.O.redo(),!0)}Pu(e){let t=this.e.s;if(e.key==="Escape")return this.e.ze(),this.e.t.enableRangeSelection&&t.Ce()&&(e.preventDefault(),t.li()),!0;if(e.key!=="Delete"&&e.key!=="Backspace")return!1;let i=t.ai();return i&&(e.preventDefault(),this.e.No(i)),!0}Gu(e){if(this.e.s.v)return!1;let t=this.e.r.l();return this.e.i.G()>0&&t.length>0&&(e.preventDefault(),this.e.s.Ae(0,t[0].id)),!0}Lu(e){let t=this.e.s,i=t.v;if(!i)return;let r=this.e.r.l(),o=this.e.r.Q(i.colId),s=this.e.i.G();if(o<0||s===0)return;let a={row:i.rowIndex,colIdx:o},l=this.Nu(e,a,r,s);if(!l)return;e.preventDefault();let d=l.row!==a.row||l.colIdx!==a.colIdx;if(e.shiftKey&&this.e.t.enableRangeSelection&&d){t.Fu(l.row,l.colIdx);return}d&&t.Ae(l.row,r[l.colIdx].id)}Nu(e,t,i,r){return Yr.has(e.key)?this.Ou(e,t,i.length,r):e.key==="Enter"||e.key==="F2"?this.Hu(e,t,i,r):e.key===" "?(this.Vu(t.row),t):e.key==="Tab"?this.Bu(e,t,i):null}Ou(e,t,i,r){let{row:o,colIdx:s}=t;switch(e.key){case"ArrowUp":o=this.jr(o,this.Lt(o-1,-1),r);break;case"ArrowDown":o=this.jr(o,this.Lt(o+1,1),r);break;case"ArrowLeft":s=Math.max(0,s-1);break;case"ArrowRight":s=Math.min(i-1,s+1);break;case"Home":s=0,e.ctrlKey&&(o=0);break;case"End":s=i-1,e.ctrlKey&&(o=Math.max(0,this.Lt(r-1,-1)));break;case"PageUp":case"PageDown":o=this._u(e.key,o,r);break}return{row:o,colIdx:s}}jr(e,t,i){return t>=0&&t<i?t:e}_u(e,t,i){let r=this.e.n.C.center,o=Math.max(1,Math.floor(r.clientHeight/this.e.t.rowHeight)),s=e==="PageUp"?-1:1,a=Math.max(0,Math.min(i-1,t+o*s));return this.jr(t,this.Lt(a,s),i)}Hu(e,t,i,r){let o=this.e.i.h(t.row),s=i[t.colIdx];if(o&&!o.isDetail&&s&&this.e.a.oe(o,s))return this.e.a.start(t.row,s,e.key==="F2"?e.key:null),t;let a=this.Lt(t.row+1,1);return{...t,row:this.jr(t.row,a,r)}}Vu(e){let t=this.e.i.h(e);if(!(!t||t.isDetail)){if(t.isGroup){this.e.i.xo(t.id);return}this.e.t.rowSelection!=="none"&&this.e.f.So(t,!t.selected,this.e.t.rowSelection==="single")}}Bu(e,t,i){let r=this.rl(t.row,i[t.colIdx].id,e.shiftKey?-1:1);return r?(this.e.s.Ae(r.rowIndex,r.column.id),this.e.a.start(r.rowIndex,r.column),t):null}};var P=null;function Jr(n){P?.owner&&(n===P.owner||n.contains(P.owner))&&P.close()}function vs(n){let e=n.target;P?.contains(e)||P?.close()}function Xr(){P?.reposition()}function bs(n){n.key!=="Escape"||!P||(n.preventDefault(),n.stopImmediatePropagation(),P.close(!0))}function Zr(n){V(n,vs,bs);let e=n?"addEventListener":"removeEventListener";window[e]("resize",Xr),window[e]("scroll",Xr,!0)}function ws(n){P?.close!==n.close&&P?.close(),!P&&(P=n,Zr(!0))}function Cs(n){P?.close===n&&(P=null,Zr(!1))}function le(n,e){return e?`${n} ${e}`:n}function Fe(n,e,t){let i=n[e]&&!n[e].disabled,r=i?e+t:t>0?0:n.length-1;for(let o=r;o>=0&&o<n.length;o+=t)if(!n[o].disabled)return o;return i?e:-1}function vt(n,e){return n.findIndex(t=>t.value===e&&!t.disabled)}function re(n){let e=p("div",le("mach-select-control",n.classNames?.root)),t=p("select",le("mach-select-native",n.classNames?.native));t.hidden=!0,t.tabIndex=-1,t.setAttribute("aria-hidden","true");let i=p("button",le("mach-select-trigger",n.classNames?.trigger));i.type="button",i.setAttribute("role","combobox"),i.setAttribute("aria-haspopup","listbox"),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-label",n.ariaLabel);let r=p("span",le("mach-select-value",n.classNames?.value)),o=p("span",le("mach-select-caret",n.classNames?.caret));o.setAttribute("aria-hidden","true"),i.append(r,o);let s=p("div",le("mach-select-listbox",n.classNames?.listbox));s.id=or("mach-select-listbox"),s.setAttribute("role","listbox"),s.setAttribute("aria-hidden","true"),i.setAttribute("aria-controls",s.id),e.append(t,i);let a=[...n.options],l=[],d=-1,c=!1,u=()=>n.themeSource??e.closest(".mach-root")??e,h=y=>e.contains(y)||s.contains(y),f=()=>s.classList.contains("mach-select-listbox--open"),m=()=>{let y=a.find(D=>D.value===t.value);r.textContent=y?.label??t.value,l.forEach((D,ce)=>{let M=a[ce]?.value===t.value;D.setAttribute("aria-selected",M?"true":"false"),D.classList.toggle("mach-select-option--selected",M),D.classList.toggle("mach-select-option--active",ce===d)}),i.setAttribute("aria-activedescendant",d>=0?l[d]?.id??"":"")},g=()=>{let y=i.getBoundingClientRect(),D=s.getBoundingClientRect(),ce=Math.max(y.width,D.width),M=T(y.left,8,Math.max(8,window.innerWidth-ce-8)),Te=window.innerHeight-y.bottom-8,ne=Te<Math.min(D.height,240)&&y.top>Te,F=ne?Math.max(8,y.top-D.height-5):Math.min(window.innerHeight-D.height-8,y.bottom+5);s.style.minWidth=`${y.width}px`,s.style.left=`${M}px`,s.style.top=`${Math.max(8,F)}px`,s.classList.toggle("mach-select-listbox--above",ne)},b=(y=!1)=>f()?(s.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),s.setAttribute("aria-hidden","true"),i.setAttribute("aria-expanded","false"),i.removeAttribute("aria-activedescendant"),s.remove(),Cs(b),y&&!c&&i.focus({preventScroll:!0}),!0):!1,C=(y,D=!0)=>{!a[y]||a[y].disabled||(d=y,m(),D&&l[y]?.scrollIntoView?.({block:"nearest"}))},G=()=>{if(c||i.disabled||f())return;let y=u();ws({owner:y,close:b,contains:h,reposition:g}),d=vt(a,t.value),d<0&&(d=Fe(a,-1,1)),A(s,y),document.body.appendChild(s),s.classList.add("mach-select-listbox--open"),s.setAttribute("aria-hidden","false"),i.setAttribute("aria-expanded","true"),g(),m(),l[d]?.scrollIntoView?.({block:"nearest"})},z=y=>{let D=a[y];!D||D.disabled||(t.value=D.value,d=y,m(),b(!0),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))},W=(y,D)=>{a=[...y],t.replaceChildren(),s.replaceChildren(),l=a.map((M,Te)=>{let ne=p("option");ne.value=M.value,ne.textContent=M.label,ne.disabled=M.disabled===!0,t.appendChild(ne);let F=p("button",le("mach-select-option",n.classNames?.option));return F.id=`${s.id}-option-${Te}`,F.type="button",F.tabIndex=-1,F.dataset.value=M.value,F.disabled=M.disabled===!0,F.setAttribute("role","option"),F.textContent=M.label,F.addEventListener("mousedown",qn=>qn.preventDefault()),F.addEventListener("click",()=>z(Te)),s.appendChild(F),F});let ce=a.find(M=>!M.disabled)?.value??"";t.value=D!=null&&a.some(M=>M.value===D)?D:ce,d=vt(a,t.value),m()},tr=y=>{if(y.key==="Tab"){b();return}if(y.key==="Escape"){if(!b(!0))return;y.preventDefault(),y.stopPropagation();return}if(y.key==="Enter"||y.key===" "){y.preventDefault(),y.stopPropagation(),f()?z(d):G();return}let D=d;if(y.key==="ArrowDown")D=Fe(a,d,1);else if(y.key==="ArrowUp")D=Fe(a,d,-1);else if(y.key==="Home")D=Fe(a,-1,1);else if(y.key==="End")D=Fe(a,-1,-1);else return;y.preventDefault(),y.stopPropagation(),f()||G(),C(D)},ir=()=>{d=vt(a,t.value),m(),n.onChange?.(t.value)};return i.addEventListener("click",()=>{b()||G()}),i.addEventListener("keydown",tr),t.addEventListener("change",ir),W(a,n.value),{el:e,native:t,trigger:i,listbox:s,contains:h,isOpen:f,open:G,close:b,focus:()=>i.focus({preventScroll:!0}),getValue:()=>t.value,setValue:y=>{t.value=y,d=vt(a,y),m()},setOptions:W,destroy:()=>{c||(c=!0,b(),i.removeEventListener("keydown",tr),t.removeEventListener("change",ir),e.remove())}}}function Qr(n,e){let t=p("input","mach-editor-input");return t.type=n,e!=null&&e!==""&&(t.value=n==="date"?String(e).slice(0,10):String(e)),t}function Ts(n){return n?.options?.length?n.options:(n?.values??[]).map(e=>({label:String(e),value:e}))}function Ds(n,e){return e?.options?.length||e?.values?.length?"select":typeof n=="number"?"number":n instanceof Date||typeof n=="string"&&/^\d{4}-\d{2}-\d{2}/.test(n)?"date":"text"}function Ii(n,e,t){let i=n.colDef,r=typeof i.cellEditor=="string"?i.cellEditor:Ds(e,i.cellEditorParams);if(r==="date"){let a=Qr("date",e),d=(e==null?"":String(e)).match(/T(\d{2}:\d{2})/);return{el:a,getValue:()=>a.value===""?null:d?`${a.value}T${d[1]}`:a.value,focus:()=>a.focus({preventScroll:!0})}}if(r==="select"){let a=Ts(i.cellEditorParams),l=re({ariaLabel:i.headerName??i.field??n.id,options:a.map(d=>({value:String(d.value),label:d.label,disabled:d.disabled})),value:String(e??""),classNames:{root:"mach-editor-select-control",native:"mach-editor-select"}});return{el:l.el,getValue:()=>{let d=l.getValue();return a.find(u=>String(u.value)===d)?.value??d},focus:()=>l.focus(),destroy:()=>l.destroy()}}let o=r==="number",s=Qr(o?"number":"text",e);return!o&&t&&t.length===1&&(s.value=t),{el:s,getValue:()=>o?s.value===""?null:Number(s.value):s.value,focus:()=>{s.focus({preventScroll:!0}),s.select()}}}function de(n,e,t,i,r,o){let s=t.colDef.valueParser;if(!s)return i;let a=s({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:i,oldValue:o,source:r});if(k(a))throw new TypeError("valueParser must return a synchronous value");return a}function Oe(n,e,t,i){let r=n.d(e,t),o=t.colDef.valueSerializer;if(o)try{let s=o({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:r,target:i});if(k(s))throw new TypeError("valueSerializer must return a synchronous value");return s}catch(s){throw n.reportError(s,"valueSerializer",{colId:t.id,rowId:e.id}),s}return i==="xlsx"||i==="csv"&&typeof r=="number"?r:j(n,e,t,r)}var xs='<path d="M3 8.5 6.4 12 13.5 4"/>',Rs='<path d="m4 4 8 8m0-8-8 8"/>';function en(n,e){let t=p("button",`mach-edit-control mach-edit-control--${n}`);return t.type="button",t.setAttribute("aria-label",e),t.title=e,t.innerHTML=`<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${n==="confirm"?xs:Rs}</svg>`,t.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation()}),t}var bt=class{constructor(e){this.e=e;this.T=null;this.S=null;this.ke=null;this.lt=0;this.qr=0;this.zu=e=>{if(this.T&&!(e.isComposing||e.keyCode===229)){if(e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.Te(!1);else if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),this.Te(!0);else if(e.key==="Tab"){e.preventDefault(),e.stopPropagation();let t=this.T,i=this.e.qo.rl(t.node.rowIndex,t.column.id,e.shiftKey?-1:1);i?this.start(i.rowIndex,i.column,null,!0):this.Te(!1)}}}}isEditing(e,t){return this.T?e==null&&t==null?!0:this.T.node.rowIndex===e&&this.T.column.id===t:this.S?e==null&&t==null?!0:this.ji(this.S)!==e?!1:t==null||this.S.drafts.has(t):!1}Yr(){return this.T!=null}Gc(){return this.T?.node.rowIndex??(this.S?this.ji(this.S):null)}sl(e){return this.S?e==null||this.ji(this.S)===e:!1}oe(e,t){if(e.isDetail||e.isGroup||e.data==null)return!1;let i=t.colDef.editable;if(!i)return!1;if(typeof i=="function")try{return i(ue(this.e,e,t,this.e.d(e,t)))}catch(r){return this.e.reportError(r,"editable",{colId:t.id,rowId:e.id}),!1}return!0}start(e,t,i,r=!1){if(this.qr++,this.e.o())return!1;let o=this.e.i.h(e);if(!o||o.data==null)return!1;if(this.e.t.editType==="fullRow")return this.startRow(e,t.id);if(this.S)return!1;if(this.T)return!this.ke&&this.T.node===o&&this.T.column===t||this.al(o,t).then(m=>{m&&this.start(o.rowIndex,t,i,r)}),!0;if(!this.oe(o,t))return!1;r&&(this.e.s.Wr(e,"nearest"),this.e.s.Ae(e,t.id));let s=this.e.s.oi(e,t.id);if(!s)return!1;this.e.ze();let a=this.e.d(o,t),l=this.ll(o,t,e,a,i);if(!l)return!1;let d=p("div","mach-cell-editor-controls"),c=en("confirm","Confirm edit"),u=en("cancel","Cancel edit");d.append(c,u);let h=this.dl(l,s,d),f=this.zu;return l.el.addEventListener("keydown",f),c.addEventListener("click",m=>{m.stopPropagation(),this.Te(!1)}),u.addEventListener("click",m=>{m.stopPropagation(),this.Te(!0)}),this.T={node:o,column:t,editor:l,oldValue:a,cell:s,shell:h,keydown:f,confirmButton:c,cancelButton:u},this.Oo(l,t,o),this.e.emit("cellEditingStarted",{rowIndex:e,colId:t.id,rowNode:o}),!0}al(e,t){let i=++this.qr;return this.Te(!1).then(r=>r&&i===this.qr&&!this.isEditing()&&this.e.i.h(e.rowIndex)===e&&(t==null||this.e.r.R(t.id)===t))}startRow(e,t){if(this.T||this.S)return!1;let i=this.e.i.h(e);if(!i||i.data==null||i.isDetail||i.isGroup)return!1;this.e.ze();let r=new Map;for(let l of this.e.r.l()){if(!this.oe(i,l))continue;let d=this.e.d(i,l);r.set(l.id,{column:l,oldValue:d,value:d,mounted:null})}if(r.size===0)return!1;let o={node:i,rowIndex:e,drafts:r,validating:!1};if(this.S=o,this.e.s.I([e]),r.size===0)return this.S=null,this.e.s.I([e]),!1;let s=r.values().next().value,a=(t?r.get(t):void 0)??s;return a?.mounted&&this.Oo(a.mounted.editor,a.column,i),this.e.emit("rowEditingStarted",{rowIndex:e,rowNode:i,data:i.data}),!0}cl(e,t,i,r){if(this.T)return this.T.node===t&&this.T.column.id===i.id;let o=this.S;if(!o||o.node!==t)return!1;let s=o.drafts.get(i.id);return s?s.mounted?.cell!==r&&(this.ul(s),!this.Wu(e,o,s,r))?(o.drafts.delete(i.id),!1):!0:!1}Ho(e,t,i){let r=this.S;if(r&&this.ji(r)===e){let o=r.drafts.get(t);o?.mounted?.cell===i&&this.ul(o);return}if(this.T?.cell===i){let o=this.T;this.Te(!1),this.T===o&&this.Te(!0)}}stop(e=!1){this.Te(e)}Te(e=!1){if(e&&this.qr++,this.S)return this.Vo(e);let t=this.T;if(!t)return Promise.resolve(!1);if(e)return this.lt++,this.ke=null,Promise.resolve(this.qi(t,!0,t.oldValue));if(this.ke)return this.ke;let i,r="cellEditor.getValue";try{if(i=t.editor.getValue(),Object.is(i,t.oldValue)||(r="valueParser",i=de(this.e,t.node,t.column,i,"editor",t.oldValue)),r="cellEditor.isCancelAfterEnd",t.editor.isCancelAfterEnd?.(i))return Promise.resolve(this.qi(t,!0,t.oldValue))}catch(c){return this.e.reportError(c,r,{colId:t.column.id,rowId:t.node.id}),r!=="valueParser"?Promise.resolve(this.qi(t,!0,t.oldValue)):(this.Yi(t.editor,c instanceof Error?c.message:String(c)),Promise.resolve(!1))}let o=[{node:t.node,column:t.column,oldValue:t.oldValue,newValue:i}],s=this.e.V.Xr(o),a=++this.lt,l=()=>a===this.lt&&this.T===t&&s(),d=c=>l()?c.length?(this.Bo(t,!1),this.Yi(t.editor,c[0].message),!1):this.qi(t,!1,i):(a===this.lt&&this.T===t&&this.qi(t,!0,t.oldValue),!1);return this.hl(o,l,d,()=>this.Bo(t,!0))}Vo(e=!1){let t=this.S;if(!t)return Promise.resolve(!1);if(e)return this.lt++,this.ke=null,Promise.resolve(this.Jr(t,!0));if(this.ke)return this.ke;for(let c of t.drafts.values())this._o(c);let i=[];for(let c of t.drafts.values())if(!Object.is(c.oldValue,c.value))try{let u=de(this.e,t.node,c.column,c.value,"editor",c.oldValue);u!==void 0&&!Object.is(c.oldValue,u)&&i.push({node:t.node,column:c.column,oldValue:c.oldValue,newValue:u})}catch(u){return this.e.reportError(u,"valueParser",{colId:c.column.id,rowId:t.node.id}),this.zo(t,[{draft:c,message:u instanceof Error?u.message:String(u)}]),Promise.resolve(!1)}if(i.length===0)return Promise.resolve(this.Jr(t,!1,i));let r=i.map(c=>t.drafts.get(c.column.id)),o=r.map(c=>c.value),s=this.e.V.Xr(i),a=++this.lt,l=()=>a===this.lt&&this.S===t&&s();for(let c of r)c.error=void 0;let d=c=>l()?c.length?(this.zo(t,c.map(({colId:u,message:h})=>({draft:t.drafts.get(u)??r[0],message:h}))),!1):r.some((u,h)=>!Object.is(u.value,o[h]))?(t.validating=!1,this.Wo(t,!1),!1):this.Jr(t,!1,i):(a===this.lt&&this.S===t&&this.Jr(t,!0),!1);return this.hl(i,l,d,()=>{t.validating=!0,this.Wo(t,!0)})}hl(e,t,i,r){let o=this.e.V.$o(e,t);if(!k(o))return Promise.resolve(i(o));r();let s=o.then(i).finally(()=>{this.ke===s&&(this.ke=null)});return this.ke=s,s}qi(e,t,i){if(this.T!==e)return!1;let r={node:e.node,column:e.column,oldValue:e.oldValue,newValue:i},o=!t&&i!==void 0&&!Object.is(e.oldValue,i);if(o){let s=this.e.V.Ko([r],()=>!this.e.o());if(s)return this.Bo(e,!1),this.Yi(e.editor,s.message),!1}return this.T=null,o&&this.e.Uo(e.node,e.column,e.oldValue,i),this.jo(e),this.e.o()||(this.e.emit("cellEditingStopped",{rowIndex:e.node.rowIndex,colId:e.column.id,rowNode:e.node,oldValue:e.oldValue,newValue:o?i:e.oldValue}),this.pl(e.node.rowIndex)),!0}Jr(e,t,i=[]){if(this.S!==e)return!1;let r=t?[]:this.$u(e,i);if(r==null)return!1;for(let s of e.drafts.values())s.mounted&&this.jo(s.mounted),s.mounted=null;if(this.S=null,this.e.o())return!0;let o=this.ji(e);return this.e.emit("rowEditingStopped",{rowIndex:o,rowNode:e.node,data:e.node.data,cancelled:t,changes:r}),this.pl(o),!0}pl(e){e>=0&&this.e.s.I([e]),this.e.Pe.refresh(),this.e.dt.refresh()}$u(e,t){if(t.length===0)return[];let i=this.e.V.Ko(t,()=>!this.e.o());if(i)return this.zo(e,[{draft:e.drafts.get(i.colId)??e.drafts.get(t[0].column.id),message:i.message}]),null;let r=this.e.V.Xi(t);this.e.O.fl();try{for(let o of t){if(!r())break;this.e.Uo(e.node,o.column,o.oldValue,o.newValue)}}finally{this.e.O.ml()}return t.map(({column:o,oldValue:s,newValue:a})=>({colId:o.id,oldValue:s,newValue:a}))}Wu(e,t,i,r){let o=this.ll(t.node,i.column,e,i.value,null);if(!o)return!1;this.dl(o,r);let s=l=>this.Ku(l,t,i),a=()=>{try{i.value=o.getValue(),i.error=void 0}catch{}};return o.el.addEventListener("keydown",s),o.el.addEventListener("input",a),i.mounted={editor:o,cell:r,keydown:s,input:a},i.error&&this.Yi(o,i.error),t.validating&&this.Ji(o.el,!0),!0}dl(e,t,i){L(this.e,t);let r=p("div",i?"mach-cell-editor-shell":"mach-row-editor-shell");return r.appendChild(e.el),i&&r.appendChild(i),t.replaceChildren(r),t.classList.add("mach-cell--editing"),i||t.classList.add("mach-cell--row-editing"),t.removeAttribute("title"),r}ul(e){e.mounted&&(this._o(e),this.jo(e.mounted),e.mounted=null)}_o(e){if(e.mounted)try{let t=e.mounted.editor.getValue();t!==void 0&&(e.value=t)}catch(t){this.e.reportError(t,"cellEditor.getValue",{colId:e.column.id,rowId:this.S?.node.id})}}ll(e,t,i,r,o){let s=t.colDef,a;try{let l={api:this.e.api,colDef:s,column:t,node:e,data:e.data,value:r,rowIndex:i,keyPress:o};typeof s.cellEditor=="function"?a=s.cellEditor(l):typeof s.cellEditor=="string"&&!["text","number","date","select"].includes(s.cellEditor)?a=this.e.Uu(s.cellEditor)?.(l)??Ii(t,r,o):a=Ii(t,r,o)}catch(l){return this.e.reportError(l,"cellEditor",{colId:t.id,rowId:e.id}),null}if(!a||!(a.el instanceof HTMLElement))return this.e.reportError(new Error("cellEditor must return an editor with an HTMLElement el"),"cellEditor",{colId:t.id,rowId:e.id}),null;try{if(a.isCancelBeforeStart?.())return a.destroy?.(),null}catch(l){this.e.reportError(l,"cellEditor.isCancelBeforeStart",{colId:t.id,rowId:e.id});try{a.destroy?.()}catch{}return null}return a}zo(e,t){e.validating=!1,this.Wo(e,!1);for(let{draft:i,message:r}of t)i.error=r,i.mounted&&this.Yi(i.mounted.editor,r);t[0].draft.mounted?.editor.focus?.()}Yi(e,t){let i=e.el;i.classList.add("mach-editor-invalid"),i.setAttribute("title",t),i.setAttribute("aria-invalid","true"),this.Ji(i,!1),(i.querySelector(".mach-select-trigger, input:not([type='hidden']), select:not([hidden]), textarea")??i).focus?.();let o=()=>{i.classList.remove("mach-editor-invalid"),i.removeAttribute("title"),i.removeAttribute("aria-invalid")};i.addEventListener("input",o,{once:!0})}Bo(e,t){this.Ji(e.editor.el,t),e.confirmButton.disabled=t,e.cancelButton.disabled=!1,e.shell.classList.toggle("mach-editor-shell--busy",t)}Wo(e,t){for(let i of e.drafts.values()){let r=i.mounted?.editor.el;r&&this.Ji(r,t)}}Ji(e,t){e.classList.toggle("mach-editor-validating",t),t?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"),e.inert=t}Oo(e,t,i){try{e.focus?.()}catch(r){this.e.reportError(r,"cellEditor.focus",{colId:t.id,rowId:i.id})}}jo(e){e.editor.el.removeEventListener("keydown",e.keydown),e.input&&e.editor.el.removeEventListener("input",e.input),this.Ji(e.editor.el,!1);try{e.editor.destroy?.()}catch(t){this.e.reportError(t,"cellEditor.destroy",{colId:e.cell.dataset.colId})}e.cell.classList.remove("mach-cell--editing","mach-cell--row-editing","mach-cell--error")}ji(e){return e.node.rowIndex>=0?e.node.rowIndex:e.rowIndex}Ku(e,t,i){if(this.S!==t||e.isComposing||e.keyCode===229)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.Vo(!0);return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),this.Vo(!1);return}if(e.key!=="Tab")return;e.preventDefault(),e.stopPropagation(),this._o(i);let r=[...t.drafts.values()],o=r.indexOf(i),s=e.shiftKey?-1:1;for(let a=1;a<=r.length;a++){let l=r[(o+s*a+r.length)%r.length];if(l.mounted){this.Oo(l.mounted.editor,l.column,t.node);break}}}destroy(){this.Te(!0)}};var wt=class{constructor(e){this.e=e;this.Yo=0}ju(){this.Yo++}Zr(){let e=++this.Yo;return()=>e===this.Yo&&!this.e.o()}Xr(e){let t=e[0].node,i=this.e.r.ee(),r=i.map(a=>this.e.d(t,a)),o=this.Xi(e),s=e.every(a=>Object.is(this.e.d(t,a.column),a.oldValue));return()=>s&&o()&&i.every((a,l)=>Object.is(this.e.d(t,a),r[l]))}Xi(e){let t=e[0].node,i=t.data,r=this.e.r,o=r.ee(),s=e.every(a=>a.node===t&&r.R(a.column.id)===a.column);return()=>s&&!this.e.o()&&this.e.i.F(t.id)===t&&t.data===i&&r.ee()===o}$o(e,t){let i=e.map(o=>this.qu(o,t)),r=o=>{let s=o.filter(a=>a!=null);return s.length||!t()?s:this.Yu(e,t)};return i.some(k)?Promise.all(i.map(o=>Promise.resolve(o))).then(r):r(i)}qu(e,t){let{node:i,column:r,oldValue:o,newValue:s}=e,a=d=>(t()&&this.e.reportError(d,"validate",{colId:r.id,rowId:i.id}),{colId:r.id,message:"Validation failed"}),l=d=>typeof d=="string"?{colId:r.id,message:d}:null;try{let d=r.colDef.validate?.(s,{oldValue:o,newValue:s,node:i,data:i.data,column:r,colDef:r.colDef,api:this.e.api});return k(d)?d.then(l,a):l(d)}catch(d){return a(d)}}Yu(e,t){let i=this.e.t.rowEditValidator;if(!i)return[];let r=e[0].node,o=Object.create(null);for(let l of this.e.r.ee())o[l.id]=this.e.d(r,l);for(let l of e)o[l.column.id]=l.newValue;let s=l=>typeof l=="string"?[{colId:e[0].column.id,message:l}]:l&&typeof l=="object"?Object.entries(l).filter(([,d])=>typeof d=="string"&&d).map(([d,c])=>({colId:d,message:c})):[],a=l=>(t()&&this.e.reportError(l,"validate",{rowId:r.id}),[{colId:e[0].column.id,message:"Row validation failed"}]);try{let l=i({data:r.data,node:r,values:o,api:this.e.api,changes:e.map(({column:d,oldValue:c,newValue:u})=>({colId:d.id,oldValue:c,newValue:u}))});return k(l)?l.then(s,a):s(l)}catch(l){return a(l)}}Ko(e,t){let i=[],r=this.Xi(e);for(let o of e){if(!t()||!r()||!Object.is(this.e.d(o.node,o.column),o.oldValue)||!this.e.a.oe(o.node,o.column)||!this.e.Qr(o.node,o.column,o.newValue,o.oldValue)){for(let s of i.reverse()){if(!t()||!r())break;this.e.Qr(s.node,s.column,s.oldValue,s.newValue)||this.e.reportError(new Error("A valueSetter rejected input rollback"),"inputRollback",{rowId:s.node.id})}return{colId:o.column.id,message:"Value was rejected by the column setter"}}i.push(o)}return t()&&r()?null:{colId:e[0].column.id,message:"Input target changed during commit"}}Xu(e){let t=this.Zr();if(this.e.o()||this.e.a.isEditing())return;let i=new Map;for(let a of e){if(a.newValue===void 0||Object.is(a.oldValue,a.newValue)||!this.e.a.oe(a.node,a.column))continue;let l=i.get(a.node)??[];l.push(a),i.set(a.node,l)}let r=[...i.values()].map(a=>{let l=this.Xr(a),d=()=>t()&&l();return{changes:a,current:d,validation:this.$o(a,d)}}),o=a=>{this.gl(r,a,t)},s=r.map(a=>a.validation);s.some(k)?Promise.all(s.map(a=>Promise.resolve(a))).then(o):o(s)}gl(e,t,i){let r=e.map(()=>({applied:!1,errors:[]}));if(!i())return r;let o=new Set;this.e.O.fl();try{e.forEach(({changes:s,current:a},l)=>{let d=r[l];if(!a()||!s.length)return;d.errors=[...t[l]];let c=d.errors.length?null:this.Ko(s,i);if(!i())return;if(c&&d.errors.push(c),d.errors.length){this.e.reportError(new Error(d.errors.map(h=>h.message).join("; ")),"validate",{rowId:s[0].node.id,errors:d.errors});return}let u=this.Xi(s);d.applied=!0;for(let h of s){if(!i()||!u()){d.applied=!1;break}this.e.Uo(h.node,h.column,h.oldValue,h.newValue),h.node.rowIndex>=0&&o.add(h.node.rowIndex)}})}finally{this.e.O.ml()}return o.size&&i()&&(this.e.s.I([...o]),this.e.Pe.refresh(),this.e.dt.refresh()),r}};function Ai(n){return n==="blank"||n==="notBlank"}function Ct(n){return n===null?"null:":`${typeof n}:${String(n)}`}var Tt=class{constructor(e){this.e=e;this.b=null;this.ct=null;this.di=null;this.ut=e=>{if(!this.b)return;let t=e.target;if(!this.di?.contains(t)){if(!this.b.contains(t)){this.close();return}(!(t instanceof Element)||!t.closest(".mach-filter-select-control"))&&this.di?.close()}};this.ht=e=>{if(e.key==="Escape"){if(this.di?.close(!0)){e.preventDefault(),e.stopPropagation();return}this.close()}}}toggle(e,t){if(this.ct===e.id){this.close();return}this.close(),this.open(e,t)}open(e,t){let i=this.e.i._e()[e.id]??null,r=i?.type??e.filterType,o=p("div","mach-filter-panel");o.setAttribute("role","dialog"),o.setAttribute("aria-label",`${e.id} filter`);let s=c=>{this.e.Ju(e,c),this.close()},a=r==="set"?this.Zu(o,e,i):this.Qu(o,r,i,s),l=p("div","mach-filter-footer");l.append($("mach-filter-btn-reset",this.e.c("reset"),()=>s(null)),$("mach-filter-btn-apply",this.e.c("apply"),()=>s(a()))),o.appendChild(l),A(o,this.e.n.root),document.body.appendChild(o),this.b=o,this.ct=e.id,J(o,t),V(!0,this.ut,this.ht),o.querySelector(".mach-filter-select-trigger, input")?.focus()}close(){this.b&&(this.di?.destroy(),this.di=null,this.b.remove(),this.b=null,this.ct=null,V(!1,this.ut,this.ht))}destroy(){this.close()}Qu(e,t,i,r){let o=i&&i.type!=="set"&&i.conditions.length>0?i.conditions[0]:null,s=o?.match??(t==="text"?"contains":"equals"),{el:a,native:l}=this.eh(t,s),d=this.yl(t),c=this.yl(t,!0);this.th(t,s,o,d,c),this.vl(s,d,c),l.addEventListener("change",()=>{this.vl(l.value,d,c)});let u=p("div","mach-filter-body");u.append(a,d,c),e.appendChild(u);let h=()=>this.ih(t,l.value,d.value,c.value),f=m=>{m.key==="Enter"&&r(h())};return d.addEventListener("keydown",f),c.addEventListener("keydown",f),h}eh(e,t){let i=re({ariaLabel:"Filter condition",options:pe[e].map(r=>({value:r,label:this.e.c(ai(r))})),value:t,classNames:{root:"mach-filter-select-control",native:"mach-filter-select",trigger:"mach-filter-select-trigger",value:"mach-filter-select-value",caret:"mach-filter-select-caret",listbox:"mach-filter-listbox",option:"mach-filter-listbox-option"},themeSource:this.e.n.root});return this.di=i,i}yl(e,t=!1){let r=p("input",`mach-filter-input${t?" mach-filter-input--second":""}`);return r.type=e,r}th(e,t,i,r,o){i?.value!=null&&!Ai(t)&&(r.value=e==="date"?String(i.value).slice(0,10):String(i.value)),i&&"value2"in i&&i.value2!=null&&(o.value=e==="date"?String(i.value2).slice(0,10):String(i.value2))}vl(e,t,i){t.style.display=Ai(e)?"none":"",i.style.display=e==="inRange"?"":"none"}Zu(e,t,i){let o=t.colDef.filterParams,s;if(o?.values)s=o.values;else{let f=new Set;s=[];let m=this.e.i.He(),g=Math.min(m.length,o?.maxValues??500);for(let b=0;b<g;b++){let C=this.e.d(m[b],t),G=Ct(C??null);f.has(G)||(f.add(G),s.push(C))}}let a=new Set((i?.type==="set"?i.values:s).map(Ct)),l=p("input","mach-filter-input mach-filter-input--search");l.type="text",l.placeholder=this.e.c("search");let d=p("div","mach-filter-set-list"),c=new Map(s.map(f=>[Ct(f),f??null])),u=f=>{d.textContent="";let m=f.trim().toLowerCase();for(let g of s){let b=g==null?this.e.c("emptySetLabel"):String(g);if(m&&!b.toLowerCase().includes(m))continue;let C=Ct(g),G=p("label","mach-filter-set-item"),z=document.createElement("input");z.type="checkbox",z.checked=a.has(C),z.addEventListener("change",()=>{z.checked?a.add(C):a.delete(C)});let W=p("span");W.textContent=b,G.append(z,W),d.appendChild(G)}};l.addEventListener("input",()=>u(l.value)),u("");let h=p("div","mach-filter-body mach-filter-body--set");return h.append(l,d),e.appendChild(h),()=>{let f=[];for(let[m,g]of c)a.has(m)&&f.push(g);return f.length&&f.length<c.size?{type:"set",values:f}:null}}ih(e,t,i,r){if(Ai(t))return{type:e,conditions:[{match:t}]};if(i===""&&t!=="inRange")return null;let o=e==="number",s=o?Number(i):i;if(Number.isNaN(s))return null;if(e==="text"||t!=="inRange")return{type:e,conditions:[{match:t,value:s}]};let a=r?o?Number(r):r:s;return Number.isNaN(a)?null:{type:e,conditions:[{match:t,value:s,value2:a}]}}};var Dt=class{constructor(e){this.e=e;this.b=null;this.ct=null;this.en=null;this.tn="";this.Zi=new Set;this.ut=e=>{let t=e.target;this.b&&!this.b.contains(t)&&!this.nh(t)&&this.close()};this.ht=e=>{if(e.key==="Escape"){for(let t of this.Zi)if(t.close(!0)){e.preventDefault(),e.stopImmediatePropagation();return}this.close()}}}toggle(e,t){let i=this.ct===e.id;this.close(),i||this.open(e,t)}rh(e){this.close();let t=e??(()=>{let r=this.e.n.root.getBoundingClientRect(),o=p("div");return o.style.position="fixed",o.style.left=`${r.right-16}px`,o.style.top=`${r.top+this.e.t.headerHeight}px`,o.style.width="1px",o.style.height="1px",document.body.appendChild(o),this.en=o,o})();this.open(null,t)}close(){this.bl(),this.en&&(this.en.remove(),this.en=null),this.b?.remove(),this.b=null,this.ct=null,V(!1,this.ut,this.ht)}destroy(){this.close()}open(e,t){let i=this.e.api,r=p("div","mach-filter-panel mach-column-panel");r.setAttribute("role",e?"menu":"dialog"),e||(r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",this.e.c("columnSettings")));let o=p("div","mach-column-panel-title");o.textContent=e?e.colDef.headerName??e.colDef.field??e.id:this.e.c("columnSettings"),r.appendChild(o);let s=(u,h,f="mach-column-panel-btn")=>$(f,this.e.c(u),()=>{h(),this.close()});if(e){let u=e.id,h=(...f)=>{let m=p("div","mach-column-panel-actions");m.append(...f),r.appendChild(m)};e.sortable&&h(s("sortAsc",()=>i.sorting.setModel([{colId:u,direction:"asc"}])),s("sortDesc",()=>i.sorting.setModel([{colId:u,direction:"desc"}])),s("clearSort",()=>i.sorting.setModel([]))),h(s("pinLeft",()=>i.columns.setPinned(u,"left")),s("pinRight",()=>i.columns.setPinned(u,"right")),s("clearPin",()=>i.columns.setPinned(u,null))),h(s("autoSize",()=>i.columns.autoSize(u)),s("hideColumn",()=>i.columns.setVisible(u,!1)))}let a=p("div","mach-column-panel-divider");r.appendChild(a);let l=p("div","mach-column-panel-subtitle");if(l.textContent=this.e.c("columnVisibility"),r.appendChild(l),!e){let u=p("input","mach-column-workbench-search");u.type="search",u.placeholder=this.e.c("search"),u.setAttribute("aria-label",this.e.c("search")),u.value=this.tn,u.addEventListener("input",()=>{this.tn=u.value.trim().toLocaleLowerCase(),this.Xo(d,!0)}),r.appendChild(u)}let d=p("div","mach-column-panel-list");this.Xo(d,!e),r.appendChild(d);let c=p("div","mach-filter-footer");c.append(s("resetAll",()=>i.columns.resetState(),"mach-filter-btn-reset"),s("autoSizeAll",()=>i.columns.autoSizeAll(),"mach-filter-btn-apply")),r.appendChild(c),A(r,this.e.n.root),document.body.appendChild(r),this.b=r,this.ct=e?e.id:"__standalone__",J(r,t),V(!0,this.ut,this.ht)}Jo(){if(!this.b)return;let e=this.b.querySelector(".mach-column-panel-list");e&&this.Xo(e,this.ct==="__standalone__")}Xo(e,t){let i=this.e.api;this.bl(e),e.replaceChildren();let r=this.e.r.ee().filter(o=>o.isDetailToggle?!1:!t||!this.tn?!0:`${o.colDef.headerName??o.colDef.field??o.id} ${o.id}`.toLocaleLowerCase().includes(this.tn));for(let o of r){let s=p("div",t?"mach-column-workbench-item":"mach-filter-set-item"),a=p("label","mach-column-workbench-label"),l=p("input");l.type="checkbox",l.checked=!o.hide,l.disabled=o.hasCheckbox,l.addEventListener("change",()=>{i.columns.setVisible(o.id,l.checked),this.Jo()});let d=p("span","mach-column-workbench-name");if(d.textContent=o.colDef.headerName??o.colDef.field??o.id,d.title=`${d.textContent} (${o.id})`,a.append(l,d),s.appendChild(a),t){let c=re({ariaLabel:`${d.textContent} ${this.e.c("clearPin")}`,options:[{value:"",label:this.e.c("clearPin")},{value:"left",label:this.e.c("pinLeft")},{value:"right",label:this.e.c("pinRight")}],value:o.pinned??"",classNames:{root:"mach-column-workbench-pin-control",native:"mach-column-workbench-pin"},themeSource:this.e.n.root,onChange:m=>{i.columns.setPinned(o.id,m==="left"||m==="right"?m:null),this.Jo()}});c.trigger.disabled=!o.movable,c.native.disabled=!o.movable,this.Zi.add(c),s.appendChild(c.el);let u=this.e.r.ee().filter(m=>!m.hide&&m.parentGroup===o.parentGroup&&(o.parentGroup!=null||m.pinned===o.pinned)),h=u.indexOf(o),f=(m,g,b)=>{let C=$("mach-column-workbench-move",m,()=>{i.columns.move(o.id,g),this.Jo()});return C.disabled=b||o.hide||!o.movable,C};s.append(f("\u2191",h-1,h<=0),f("\u2193",h+1,h<0||h>=u.length-1))}e.appendChild(s)}}nh(e){for(let t of this.Zi)if(t.contains(e))return!0;return!1}bl(e){for(let t of this.Zi)e&&!e.contains(t.el)||(t.destroy(),this.Zi.delete(t))}};var xt=class{constructor(e){this.e=e;this.b=null;this.ut=e=>{this.b&&!this.b.contains(e.target)&&this.close()};this.ht=e=>{e.key==="Escape"&&this.close()}}oh(e){if(e){let o=this.e.i.h(e.rowIndex),s=this.e.r.R(e.colId);return o&&s?{node:o,column:s}:null}let t=this.e.s.ai();if(!t)return null;let i=this.e.i.h(t.r1),r=this.e.r.l()[t.c1];return i&&r?{node:i,column:r}:null}sh(e,t){let i=this.e.t.getContextMenuItems;if(!i)return null;try{return i({data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.d(e,t),rowIndex:e.rowIndex})??null}catch(r){return this.e.reportError(r,"getContextMenuItems",{colId:t.id,rowId:e.id}),null}}ah(e,t,i,r){let o=!1;for(let s of t){if(s.separator){e.appendChild(p("div","mach-context-menu-separator"));continue}let a=p("button","mach-context-menu-item");a.type="button",a.textContent=s.label??"",s.danger&&a.classList.add("mach-context-menu-item--danger"),a.disabled=s.disabled===!0,a.disabled||(o=!0,a.addEventListener("click",()=>this.lh(s,i,r))),e.appendChild(a)}return o}lh(e,t,i){this.close();try{e.action?.()}catch(r){this.e.reportError(r,"contextMenu.action",{colId:i.id,rowId:t.id})}}dh(e){let t=this.e,i=(r,o)=>{e.append($("mach-context-menu-item",t.c(r),()=>{o(),this.close()}))};t.t.suppressClipboard||(i("menuCopy",()=>{t.wl()}),i("menuPaste",()=>{t.ch()})),i("menuClearContents",()=>{let r=t.s.ai();r&&t.No(r)})}open(e,t,i){this.close();let r=this.oh(i);if(!r)return;let o=p("div","mach-context-menu");if(o.setAttribute("role","menu"),this.e.t.getContextMenuItems){let s=this.sh(r.node,r.column);if(!s||!this.ah(o,s,r.node,r.column))return;this.Cl(o,e,t);return}this.dh(o),this.Cl(o,e,t)}Cl(e,t,i){A(e,this.e.n.root),document.body.appendChild(e),this.b=e;let r=e.getBoundingClientRect(),o=T(t,8,Math.max(8,window.innerWidth-r.width-8)),s=T(i,8,Math.max(8,window.innerHeight-r.height-8));e.style.left=`${o}px`,e.style.top=`${s}px`,V(!0,this.ut,this.ht)}close(){this.b&&(this.b.remove(),this.b=null,V(!1,this.ut,this.ht))}destroy(){this.close()}};var Rt=class{constructor(e){this.e=e;this.b=null;this.rn=0;this.nn=null;this.sn=e=>{if(this.e.o()||!this.e.t.tooltipComponent)return;let i=e.target.closest(".mach-cell");if(!i||i===this.nn)return;this.Dl(),this.Zo(),this.nn=i;let r=this.uh(i);if(!r||i.classList.contains("mach-cell--editing"))return;let o=this.hh(r.node,r.column,r.index);this.ph(o,r.column)&&(this.rn=window.setTimeout(()=>{this.e.o()||this.nn!==i||this.fh(i,o)},Math.max(0,this.e.t.tooltipShowDelay)))};this.Tl=()=>{this.hide()}}init(){S(this.e.n.Ge,!0,{mouseover:this.sn,mouseleave:this.Tl})}destroy(){this.hide(),S(this.e.n.Ge,!1,{mouseover:this.sn,mouseleave:this.Tl})}hide(){this.Dl(),this.Zo(),this.nn=null}Dl(){this.rn&&(clearTimeout(this.rn),this.rn=0)}Zo(){this.b?.remove(),this.b=null}uh(e){let t=e.dataset.colId??"",i=Number(e.closest(".mach-row")?.dataset.index);if(Number.isNaN(i))return null;let r=this.e.i.h(i),o=t?this.e.r.R(t):void 0;return!r||!o||r.isDetail||r.isGroup?null:{node:r,column:o,index:i}}hh(e,t,i){return{data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.d(e,t),formatted:he(this.e,e,t),rowIndex:i}}ph(e,t){let i=t.colDef.tooltipValueGetter;if(!i)return!!e.formatted;try{i({...e,colDef:t.colDef,column:t})}catch(r){this.e.reportError(r,"tooltipValueGetter",{colId:t.id,rowId:e.node.id})}return!0}fh(e,t){this.Zo();let i=this.e.t.tooltipComponent;if(!i)return;let r=p("div","mach-tooltip");r.setAttribute("role","tooltip");let o;try{o=i(t)}catch(s){this.e.reportError(s,"tooltipComponent",{colId:t.colId,rowIndex:t.rowIndex});return}typeof o=="string"?r.textContent=o:r.appendChild(o),A(r,this.e.n.root),document.body.appendChild(r),this.b=r,J(r,e,6)}};var Et=class{constructor(e){this.e=e;this.Y=null}init(){this.Y=document.createElement("div"),this.Y.className="mach-watermark",this.Y.setAttribute("aria-hidden","true"),this.Y.style.pointerEvents="none",this.e.n.root.appendChild(this.Y),this.apply()}apply(){if(!this.Y||this.e.o())return;let e=this.e.t.watermarkEnabled?this.e.t.watermarkConfig:null;if(!e||!e.text){this.Y.style.display="none",this.Y.style.backgroundImage="";return}let t=this.mh(e);this.Y.style.display="",t?(this.Y.style.backgroundImage=`url(${t})`,this.Y.style.backgroundColor=""):this.Y.style.backgroundImage=""}mh(e){try{let t=document.createElement("canvas"),i=t.getContext("2d");if(!i)return null;let r=e.fontSize??14,o=e.gap??160,s=e.angle??-22,a=e.color??(this.gh()?"rgba(255,255,255,0.9)":"rgba(31,55,88,0.9)"),l=e.opacity??.06;i.font=`500 ${r}px sans-serif`;let d=i.measureText(e.text),c=Math.ceil(d.width),u=Math.max(o,c+40);t.width=u,t.height=u;let h=t.getContext("2d");return h.clearRect(0,0,u,u),h.globalAlpha=l,h.fillStyle=a,h.font=`500 ${r}px sans-serif`,h.translate(u/2,u/2),h.rotate(s*Math.PI/180),h.textAlign="center",h.textBaseline="middle",h.fillText(e.text,0,0),t.toDataURL("image/png")}catch{return null}}gh(){return this.e.n.root.classList.contains("mach-theme-dark")}refresh(){this.apply()}destroy(){this.Y?.remove(),this.Y=null}};var St=class{constructor(e){this.e=e;this.U=[];this.X=-1;this.le=null}fl(){this.le===null&&(this.le=[])}ml(){let e=this.le;this.le=null,e&&e.length>0&&this.push(e)}Qo(e){if(this.le!==!1){if(this.le){this.le.push(e);return}this.push([e])}}push(e){this.e.t.undoStackSize!==0&&(this.U.length=this.X+1,this.U.push(e),this.X=this.U.length-1,this.xl())}xl(){let e=this.e.t.undoStackSize;if(e===0){this.clear();return}for(;this.U.length>e;)this.U.shift(),this.X--;this.X<-1&&(this.X=-1)}canUndo(){return this.X>=0}canRedo(){return this.X<this.U.length-1}undo(){if(this.e.ze(),!this.canUndo())return!1;let e=this.U[this.X];return this.X--,this.apply(e,!1),!0}redo(){return this.e.ze(),this.canRedo()?(this.X++,this.apply(this.U[this.X],!0),!0):!1}apply(e,t){let i=this.e,r=[],o=this.U;for(let s of e){if(o!==this.U&&(o=this.U,!o.includes(e)))break;let a=i.i.F(s.nodeId),l=i.r.R(s.columnId);if(!a||!l||a.data==null)continue;let d=t?s.newValue:s.oldValue,c=t?s.oldValue:s.newValue;!l.colDef.valueGetter&&!l.colDef.valueSetter&&!Object.is(i.d(a,l),c)||i.Qr(a,l,d,c)&&(i.s.zr(a),i.s.Rl([a.rowIndex],[l.id]),a.rowIndex>=0&&r.push(a.rowIndex),i.emit("cellValueChanged",{oldValue:c,newValue:d,rowNode:a,rowIndex:a.rowIndex,column:l,colDef:l.colDef,data:a.data}))}r.length>0&&i.s.I(r),i.Pe.refresh(),i.dt.refresh()}Oc(e){if(e.length===0||!this.U.length&&!this.le)return;let t=new Set(e),i=o=>o.some(s=>t.has(s.nodeId)),r=this.X;this.U=this.U.filter((o,s)=>i(o)?(s<=r&&this.X--,!1):!0),this.le&&i(this.le)&&(this.le=!1)}clear(){this.U=[],this.X=-1,this.le=null}};var Mt=class{constructor(e){this.e=e;this.B=new Map;this.es=!1;this.ts=null}init(){this.ts=this.e.de.on("cellValueChanged",e=>{this.es||this.Qo(e)})}Qo(e){let t=`${e.rowNode.id}\0${e.column.id}`,i=this.B.get(t),r=i?i.originalValue:e.oldValue;Object.is(e.newValue,r)?this.B.delete(t):this.B.set(t,{rowId:e.rowNode.id,colId:e.column.id,originalValue:r,value:e.newValue}),this.Qi()}getDirtyRowIds(){let e=new Set;for(let{rowId:t}of this.B.values())e.add(t);return[...e]}getChanges(){let e=new Map;for(let t of this.B.values()){let i=this.e.i.F(t.rowId);if(!i?.data)continue;let r=e.get(t.rowId);r||(r={rowId:t.rowId,data:i.data,cells:[]},e.set(t.rowId,r)),r.cells.push({colId:t.colId,originalValue:t.originalValue,value:t.value})}return[...e.values()]}markSaved(e){if(!e)this.B.clear();else{let t=new Set(e);for(let[i,r]of this.B)t.has(r.rowId)&&this.B.delete(i)}this.Qi()}yh(e){for(let t of e)for(let i of t.cells){let r=`${t.rowId}\0${i.colId}`,o=this.B.get(r);if(o){Object.is(o.value,i.value)?this.B.delete(r):o.originalValue=i.value;continue}let s=this.e.i.F(t.rowId),a=this.e.r.R(i.colId);if(!s||!a||s.data==null)continue;let l=this.e.d(s,a);Object.is(l,i.value)||this.B.set(r,{rowId:t.rowId,colId:i.colId,originalValue:i.value,value:l})}this.Qi()}rollback(e){let t=e?new Set(e):null,i=[...this.B.entries()].filter(([,s])=>!t||t.has(s.rowId));if(i.length===0)return!1;let r=new Set,o=new Set;this.es=!0;try{for(let[s,a]of i){let l=this.e.i.F(a.rowId),d=this.e.r.R(a.colId);if(!l||!d||l.data==null)continue;let c=this.e.d(l,d);if(Object.is(c,a.originalValue)){o.add(s);continue}this.e.Qr(l,d,a.originalValue,c)&&(o.add(s),this.e.s.zr(l),l.rowIndex>=0&&r.add(l.rowIndex),this.e.emit("cellValueChanged",{oldValue:c,newValue:a.originalValue,rowNode:l,rowIndex:l.rowIndex,column:d,colDef:d.colDef,data:l.data}))}}finally{this.es=!1}for(let s of o)this.B.delete(s);return r.size>0&&this.e.s.I([...r]),this.e.Pe.refresh(),this.e.dt.refresh(),this.Qi(),o.size>0}Vc(e){e.length>0&&this.markSaved(e)}clear(){this.B.size!==0&&(this.B.clear(),this.Qi())}destroy(){this.ts?.(),this.ts=null,this.B.clear()}Qi(){this.e.emit("dirtyStateChanged",{dirtyRowIds:this.getDirtyRowIds()})}};var Pi=class{constructor(){this.er=null;this.an=0;this.El=0;this.Sl=0}acquire(){this.an++,this.vh();let e=!1;return()=>{e||(e=!0,this.an=Math.max(0,this.an-1),this.an===0&&this.disconnect())}}snapshot(){return{count:this.El,totalMs:this.Sl}}vh(){if(!(this.er||typeof PerformanceObserver>"u"))try{this.er=new PerformanceObserver(e=>{for(let t of e.getEntries())this.El++,this.Sl+=t.duration}),this.er.observe({entryTypes:["longtask"]})}catch{this.disconnect()}}disconnect(){let e=this.er;this.er=null;try{e?.disconnect()}catch{}}},It=new Pi;function ki(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var At=class{constructor(){this.Nt=[];this.ln=[];this.dn=[];this.rs=It.acquire(),this.cn=It.snapshot()}start(){return ki()}bh(e,t,i){this.Nt.push({duration:Math.max(0,ki()-e),rows:t,columns:i}),this.Nt.length>120&&this.Nt.shift()}wh(e){this.Ml(this.ln,e)}Oa(e){this.Ml(this.dn,e)}snapshot(){let e=this.Nt.map(r=>r.duration),t=this.Nt[this.Nt.length-1],i=It.snapshot();return{sampleCount:e.length,lastRenderMs:t?.duration??0,averageRenderMs:this.Ch(e),maxRenderMs:Math.max(0,...e),p95RenderMs:this.ns(e),longRenderCount:e.filter(r=>r>16.7).length,renderedRows:t?.rows??0,renderedColumns:t?.columns??0,renderedCells:(t?.rows??0)*(t?.columns??0),layoutSampleCount:this.ln.length,p95LayoutMs:this.ns(this.ln),modelSampleCount:this.dn.length,p95ModelMs:this.ns(this.dn),longTaskCount:Math.max(0,i.count-this.cn.count),longTaskTotalMs:Math.max(0,i.totalMs-this.cn.totalMs),usedHeapBytes:this.usedHeapBytes()}}reset(){this.Nt=[],this.ln=[],this.dn=[],this.cn=It.snapshot()}destroy(){this.rs?.(),this.rs=null}Ml(e,t){e.push(Math.max(0,ki()-t)),e.length>120&&e.shift()}Ch(e){return e.length===0?0:e.reduce((t,i)=>t+i,0)/e.length}usedHeapBytes(){let e=typeof performance>"u"?void 0:performance.memory?.usedJSHeapSize;return typeof e=="number"&&Number.isFinite(e)?e:null}ns(e){if(e.length===0)return 0;let t=[...e].sort((i,r)=>i-r);return t[Math.max(0,Math.ceil(t.length*.95)-1)]??0}};function Gi(n,e){if(!(n==null||e==null))return[...new Set([...n,...e])]}function Es(n,e){return n===!0||e===!0?!0:n?e?{rowIds:Gi(n.rowIds,e.rowIds),rowIndexes:Gi(n.rowIndexes,e.rowIndexes),columns:Gi(n.columns,e.columns),force:n.force===!0||e.force===!0,includePinned:n.includePinned===!0||e.includePinned===!0}:n:e}var Ss=["columns","header","pool","data","layout","pinned","summary","overlays"];function Ms(n,e){let t={cells:Es(n.cells,e.cells)};for(let i of Ss)t[i]=n[i]===!0||e[i]===!0;return t}var kt=class{constructor(e){this.apply=e;this.Ft=0;this.pt=null;this.Il=0;this.Al=0;this.kl=0;this.un=!1}batch(e){if(this.un)return e();this.Ft++;try{return e()}finally{this.Ft--,this.Ft===0&&this.flush()}}Pl(e){this.un||(this.Al++,this.pt&&this.kl++,this.pt=Ms(this.pt??{},e),this.Ft===0&&this.flush())}flush(){if(this.un||this.Ft>0||!this.pt)return;let e=this.pt;this.pt=null,this.Il++,this.apply(e)}snapshot(){return{batchDepth:this.Ft,flushCount:this.Il,requestCount:this.Al,coalescedRequestCount:this.kl,pending:this.pt!=null}}destroy(){this.un=!0,this.pt=null,this.Ft=0}};var tn=Symbol.for("mach-table.adapter.lifecycle.v1");function rn(n,e){Object.defineProperty(n,tn,{value:e})}function Li(n){let e=n[tn]?.rowDrag;return e?.policy===n.getOption("rowDragPolicy")?e?.factory:void 0}var nn=Symbol.for("mach-table.import.v1");function on(n,e){Object.defineProperty(n,nn,{value:{begin:()=>e.V.Zr(),revision:()=>e.i.Be(),isEditing:()=>e.a.isEditing(),columns:()=>e.r.ee(),visibleColumns:()=>e.r.l(),read:(i,r)=>e.d(i,r),editable:(i,r)=>e.a.oe(i,r),parse:(i,r,o,s)=>de(e,i,r,o,"import",s),pasteRows:i=>{let r=[];for(let o of e.i.It())if(!o.isGroup&&!o.isDetail&&r.push(o),r.length>=i)break;return r},resolveId:(i,r)=>e.t.resolveRowId?.({data:i,index:r,api:n}),validate:(i,r)=>e.V.$o(i,r),guard:i=>e.V.Xr(i),commitRows:(i,r,o)=>e.V.gl(i,r,o)}})}function sn(n){let e=n[nn];if(!e)throw new TypeError("Import plans require a MachTable GridApi");return e}function Is(n,e,t,i){let r=n.columns().filter(u=>u.colDef.field),o=t.columns??e,s=new Map(r.map(u=>[u.id,u])),a=new Map,l=new Map;for(let u of r){let h=u.colDef.field;a.set(h,a.has(h)?null:u);let f=u.colDef.headerName;f&&l.set(f,l.has(f)?null:u)}let d=[],c=new Set;return o.forEach((u,h)=>{let f=(typeof u=="string"||typeof u=="number"?String(u):"").replace(/^\uFEFF/,"").trim(),m=s.get(f)??(a.has(f)?a.get(f):l.get(f));if(!m){if(i||t.columns||a.has(f)||l.has(f))throw new TypeError(`Unknown or ambiguous import column: ${f}`);return}if(c.has(m.colDef.field))throw new TypeError(`Duplicate import column: ${m.id}`);c.add(m.colDef.field),d.push({column:m,index:h})}),d.length?d:n.visibleColumns().filter(u=>u.colDef.field).map((u,h)=>({column:u,index:h}))}function As(n,e){if(!Array.isArray(n)||n.some(t=>!Array.isArray(t)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(e)||e<-1||e>=n.length)throw new RangeError("Invalid import header row");if(n.length-e-1>1e4||n.reduce((t,i)=>t+i.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function ks(n,e,t,i,r,o){let s=t.colDef.field,a=n.read(e.node,t),l=o.parseValue?o.parseValue({value:r,field:s,rowIndex:e.rowIndex,columnIndex:i}):t.colDef.valueParser?n.parse(e.node,t,r,a):gt(r,o.coerceNumbers!==!1);if(k(l))throw new TypeError("Import parsers must return synchronous values");if(!Ee(e.data,s,l))throw new TypeError(`Unsafe import field: ${s}`);e.changes.push({node:e.node,column:t,oldValue:a,newValue:l})}function Ps(n,e,t,i,r,o,s,a){let l=a?.[t]??{},d=s?.[t]??{id:`import:${t}`,rowIndex:t,data:l,selected:!1},c={data:l,node:d,changes:[],rowIndex:t};for(let{column:u,index:h}of i)if(!(e[h]===void 0||s&&!n.editable(d,u)))try{ks(n,c,u,h,e[h],r)}catch(f){o.issues.push({rowIndex:t,columnIndex:h,colId:u.id,code:"PARSE",message:f instanceof Error?f.message:String(f)})}o.rows.push(c)}function an(n,e,t={},i,r=!1,o){let s=t.headerRowIndex??(t.columns?-1:0);As(e,s);let a=Is(n,s<0?[]:e[s],t,r);if(!a.length)throw new TypeError("Import requires a writable field column");let l={rows:[],issues:[]};for(let d=s+1;d<e.length;d++){let c=e[d];c.some(u=>u!==""&&u!==void 0)&&Ps(n,c,d-s-1,a,t,l,i,o)}return l}function ve(n){return(n==null?"":String(n)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ni(n,e,t="text/plain;charset=utf-8"){try{if(typeof document>"u"||typeof Blob>"u")return!1;let i=document.createElement("a");if(typeof URL<"u"&&typeof URL.createObjectURL=="function"){let r=new Blob([e],{type:t}),o=URL.createObjectURL(r);i.href=o,i.download=n,i.click();let s=typeof URL.revokeObjectURL=="function"?URL.revokeObjectURL.bind(URL):null;s&&setTimeout(()=>{try{s(o)}catch{}},0)}else i.href=`data:${t},${encodeURIComponent(e)}`,i.download=n,i.click();return!0}catch{return!1}}var Fi=["gridReady","gridDestroyed","modelUpdated","cellClicked","cellDoubleClicked","cellContextMenu","rowClicked","rowDoubleClicked","selectionChanged","sortChanged","filterChanged","columnResized","columnMoved","columnVisibilityChanged","cellValueChanged","cellEditingStarted","cellEditingStopped","rowEditingStarted","rowEditingStopped","detailToggled","treeChildrenLoaded","treeChildrenLoadFailed","rowDragEnd","rangeSelectionChanged","paginationChanged","displayedColumnsChanged","gridError","dirtyStateChanged"];var be={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",maxBodyHeight:"number",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",rowNumber:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};var Oi=Object.freeze(Object.keys(be));var He=new Set(Fi.map(n=>`on${n.charAt(0).toUpperCase()}${n.slice(1)}`));function Hi(n,e){let t=be[n];return e==null||t==="unknown"?!0:t==="array"?Array.isArray(e):t==="number"?x(e,n==="maxBodyHeight"?1:-1/0)!==void 0:t==="boolean-object"&&typeof e=="boolean"||t==="object-function"&&typeof e=="function"?!0:t==="object"||t==="boolean-object"||t==="object-function"?typeof e=="object"&&!Array.isArray(e):typeof e===t}function ln(n){let e={};for(let[t,i]of Object.entries(n)){if(He.has(t)){(i==null||typeof i=="function")&&(e[t]=i);continue}!v(be,t)||!Hi(t,i)||(e[t]=i)}return e}var cn=2e3,Vi=1e5,Ve=512,Ls=1e4;function dn(n){return Array.isArray(n)?[...new Set(n.slice(0,Vi).filter(e=>typeof e=="string"&&e.length>0&&e.length<=Ve))]:[]}function Ns(n){if(!Array.isArray(n))return[];let e=new Set,t=Vi*Ve;for(let i of n.slice(0,Vi)){if(typeof i!="string"||!i.length||e.has(i))continue;let r=i.startsWith(dt)?65536:Ve;i.length>r||i.length>t||(e.add(i),t-=i.length)}return[...e]}function Fs(n,e){let t=I(e.flex);for(let i of["width","contentWidth"]){let r=I(e[i]);r!==void 0&&(n[i]=r)}e.flex===null?n.flex=null:t!==void 0&&(n.flex=t),(e.widthMode==="auto"||e.widthMode==="manual")&&(n.widthMode=e.widthMode)}function Os(n,e){typeof e.hide=="boolean"&&(n.hide=e.hide),(e.pinned===null||e.pinned==="left"||e.pinned==="right")&&(n.pinned=e.pinned)}function Hs(n,e){if(n==null||typeof n!="object")return null;let t=n,i=typeof t.colId=="string"?t.colId.trim():"";if(!i||i.length>Ve||e.has(i))return null;e.add(i);let r={colId:i};return Os(r,t),Fs(r,t),r}function Vs(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let i of n.slice(0,cn)){let r=Hs(i,t);r&&e.push(r)}return e}function Bs(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let i of n.slice(0,cn)){if(i==null||typeof i!="object")continue;let r=i,o=typeof r.colId=="string"?r.colId.trim():"";!o||o.length>Ve||t.has(o)||r.direction!=="asc"&&r.direction!=="desc"||(t.add(o),e.push({colId:o,direction:r.direction}))}return e}function X(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==2||!Array.isArray(e.columns)||!Array.isArray(e.sortModel))return null;let t=e.pagination!=null&&typeof e.pagination=="object"?e.pagination:{};return{version:2,columns:Vs(e.columns),sortModel:Bs(e.sortModel),filterModel:oe(e.filterModel),advancedFilterModel:B(e.advancedFilterModel),quickFilterText:typeof e.quickFilterText=="string"&&e.quickFilterText.trim()?e.quickFilterText.slice(0,Ls):null,pagination:{enabled:t.enabled===!0,page:E(t.page,1,1,!0),pageSize:E(t.pageSize,20,1,!0)},selectedRowIds:dn(e.selectedRowIds),expandedRowIds:dn(e.expandedRowIds),expandedGroupIds:Ns(e.expandedGroupIds)}}function un(n,e){let t=X(n);if(!t)throw new TypeError("[MachTable] Cannot persist an invalid GridState snapshot.");let i=new Set(e);return{version:2,columns:i.has("columns")?t.columns:[],sortModel:i.has("sort")?t.sortModel:[],filterModel:i.has("filter")?t.filterModel:{},advancedFilterModel:i.has("filter")?t.advancedFilterModel:null,quickFilterText:i.has("filter")?t.quickFilterText:null,pagination:i.has("pagination")?t.pagination:{enabled:!1,page:1,pageSize:20},selectedRowIds:i.has("selection")?t.selectedRowIds:[],expandedRowIds:i.has("expansion")?t.expandedRowIds:[],expandedGroupIds:i.has("expansion")?t.expandedGroupIds:[]}}function _s(n){try{if(typeof structuredClone=="function")return structuredClone(n)}catch{}return Array.isArray(n)?[...n]:n!=null&&typeof n=="object"?{...n}:n}function pn(n,e){let t=e?new Set(e.map(String)):null;return n.filter(i=>!t||t.has(i.rowId)).map(i=>({...i,data:_s(i.data),cells:i.cells.map(r=>({...r}))}))}function zs(n,e){let t=typeof n?.rowId=="string"?n.rowId:"";return!e.has(t)||typeof n.message!="string"||!n.message.trim()?null:{...n,rowId:t,message:n.message.trim(),...typeof n.code=="string"&&n.code.trim()?{code:n.code.trim()}:{},...Array.isArray(n.colIds)?{colIds:[...new Set(n.colIds.filter(i=>typeof i=="string"&&i.length>0))]}:{}}}function hn(n,e){let t=new Map;for(let i of n??[]){let r=zs(i,e);r&&!t.has(r.rowId)&&t.set(r.rowId,r)}return[...t.values()]}function fn(n,e){let t=new Set(n.map(d=>d.rowId)),i=hn(e?.conflicts,t),r=new Set(i.map(d=>d.rowId)),o=hn(e?.failures,t).filter(d=>!r.has(d.rowId)),s=new Set([...o,...i].map(d=>d.rowId)),a=e?.savedRowIds==null?null:new Set(e.savedRowIds.map(String).filter(d=>t.has(d))),l=n.filter(d=>!s.has(d.rowId)&&(a==null||a.has(d.rowId)));return{submitted:n,saved:l,failures:o,conflicts:i}}function Ws(n,e){if(e.serverData===void 0)return null;let t=n.rows.getById(e.rowId);if(!t||t.data==null)return null;let i=n.getOption("rowKey");if(i){let s=typeof i=="function"?i(e.serverData):K(e.serverData,i);return String(s)===e.rowId?{data:e.serverData,mergeIntoCurrent:!1}:null}let r=t.data;return r!=null&&e.serverData!=null&&typeof r=="object"&&typeof e.serverData=="object"?{data:r,mergeIntoCurrent:!0}:null}function $s(n,e,t){if(n.isDestroyed())return!1;if(t==="keepLocal")return!0;let i=Ws(n,e);return i?(n.editing.rollback([e.rowId]),i.mergeIntoCurrent&&Object.assign(i.data,e.serverData),n.rows.transact({update:[i.data]}),n.editing.markSaved([e.rowId]),!0):!1}var Ks=["compact","normal","large"],w=["left","center","right"];function Gt(n,e){let t=n.t,i;if(e==="loading")i=t.overlayLoadingTemplate||n.Th();else if(e==="noRows")i=t.overlayNoRowsTemplate||n.Dh();else if(e==="error")i=t.overlayErrorTemplate||n.xh();else{n.n.Rh();return}n.n.Eh(e,i,t.allowUnsafeOverlayHtml)}var Pt=class{constructor(e){this.e=e;this.rr=null;this.as=null;this.ls=!1;this.mn=null;this.ds=[];this.gn=null;this.ci=0;this.Gl=-1;this.Ll=-1;this.qt=1;this.cs=()=>{document.fonts.ready.then(this.Hl)};this.Hl=()=>{this.ci||this.e.o()||(this.ci=requestAnimationFrame(()=>{this.ci=0,this.e.Ie()}))};this.ui=null}init(e,t){let i=["mach-root",`mach-size--${t.size}`];t.stripedRows&&i.push("mach-striped"),t.showCellBorders&&i.push("mach-cell-borders"),t.domLayout==="autoHeight"&&i.push("mach-dom-layout--auto-height"),this.root=p("div",i.join(" ")),this.Nl(t.className),this.root.style.setProperty("--mach-row-h",`${t.rowHeight}px`),this.root.style.setProperty("--mach-header-h",`${t.headerHeight}px`),this.root.setAttribute("role","grid"),this.root.tabIndex=0,this.Fl(t),this.tr=p("div","mach-header"),this.tr.setAttribute("role","rowgroup"),this.ir={left:[],center:[],right:[]},this.os={},this.si={};for(let r of w){let o=p("div",`mach-pane mach-pane--${r} mach-header-pane`),s=p("div","mach-header-rows");if(r==="center"){let a=p("div","mach-header-viewport");a.appendChild(s),o.appendChild(a)}else o.appendChild(s);this.tr.appendChild(o),this.os[r]=o,this.si[r]=s}this.Ol(1),this.Ge=p("div","mach-body"),this.hn=p("div","mach-pinned-rows mach-pinned-rows--top"),this.hn.style.display="none",this.pn=p("div","mach-pinned-rows mach-pinned-rows--bottom"),this.pn.style.display="none",this.C={},this.De={},this.ss={};for(let r of w){let o=p("div",`mach-pane mach-pane--${r} mach-body-pane`),s=p("div",`mach-body-viewport${r==="center"?" mach-body-viewport--scroll":""}`),a=p("div","mach-row-container");s.appendChild(a),o.appendChild(s),this.Ge.appendChild(o),this.ss[r]=o,this.C[r]=s,this.De[r]=a}this.Ke=p("div","mach-overlay"),this.Ke.style.display="none",this.Ke.setAttribute("role","status"),this.Ke.setAttribute("aria-live","polite"),this.Ue=p("div","mach-overlay-content"),this.Ke.appendChild(this.Ue),this.ft=p("div","mach-infinite-loading"),this.ft.style.display="none",this.ft.appendChild(p("div","mach-spinner")),this.fn=p("span"),this.ft.appendChild(this.fn),this.root.append(this.tr,this.hn,this.Ge,this.pn,this.Ke,this.ft),e.appendChild(this.root),document.fonts?.addEventListener("loading",this.cs),document.fonts?.status==="loading"&&this.cs(),typeof ResizeObserver<"u"&&(this.gn=new ResizeObserver(r=>{let o=r[r.length-1]?.contentRect;if(!o)return;let s=Math.round(o.width),a=Math.round(o.height);s===this.Gl&&a===this.Ll||(this.Gl=s,this.Ll=a,this.Hl())}),this.gn.observe(this.root)),this.Vl(t.theme)}Fl(e){e.ariaLabelledBy?(this.root.setAttribute("aria-labelledby",e.ariaLabelledBy),this.root.removeAttribute("aria-label")):(this.root.removeAttribute("aria-labelledby"),this.root.setAttribute("aria-label",e.ariaLabel)),e.ariaDescribedBy?this.root.setAttribute("aria-describedby",e.ariaDescribedBy):this.root.removeAttribute("aria-describedby")}Ol(e){this.qt=e;for(let t of w){let i=this.si[t],r=this.ir[t];for(;r.length<e;){let o=p("div","mach-header-row");o.setAttribute("role","row"),o.setAttribute("aria-rowindex",String(r.length+1)),i.appendChild(o),r.push(o)}for(;r.length>e;)r.pop().remove()}this.Bl()}_l(){return this.qt}Bl(){this.tr.style.height=`${this.qt*this.e.t.headerHeight}px`;for(let e of w)this.ir[e].forEach((i,r)=>{i.style.top=`${r*this.e.t.headerHeight}px`,i.style.height=`${this.e.t.headerHeight}px`})}Sh(e,t){this.zl("left",e),this.zl("right",t)}zl(e,t){let i=this.os[e],r=this.ss[e];i.style.width=`${t}px`,r.style.width=`${t}px`;let o=t<=0;i.classList.toggle("mach-pane--hidden",o),r.classList.toggle("mach-pane--hidden",o)}us(){let e=this.C.center,t=Math.max(0,e.offsetWidth-e.clientWidth);return Math.max(0,this.Ge.clientWidth-t)}Mh(e,t){this.root.style.setProperty("--mach-row-h",`${e}px`),this.root.style.setProperty("--mach-header-h",`${t}px`),this.Bl()}Ih(e){for(let t of Ks)this.root.classList.toggle(`mach-size--${t}`,t===e)}Vl(e){if(!this.root)return;this.ui?.(),this.ui=null;let t=e==="dark"||e==="auto"&&this.Ah();if(this.root.classList.toggle("mach-theme-dark",t),e==="auto"&&typeof window<"u"&&typeof window.matchMedia=="function"){let i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.root.classList.toggle("mach-theme-dark",i.matches);typeof i.addEventListener=="function"?(i.addEventListener("change",r),this.ui=()=>i.removeEventListener("change",r)):typeof i.addListener=="function"&&(i.addListener(r),this.ui=()=>i.removeListener(r))}}Ah(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}kh(e){this.root.classList.toggle("mach-striped",e)}Ph(e){this.root.classList.toggle("mach-cell-borders",e)}Gh(e){this.root.classList.toggle("mach-dom-layout--auto-height",e==="autoHeight")}Nl(e){for(let t of this.ds)this.root.classList.remove(t);this.ds=[];for(let t of String(e??"").split(/\s+/).filter(Boolean))this.root.classList.contains(t)||(this.root.classList.add(t),this.ds.push(t))}Lh(e){try{return typeof e=="function"?e():e}catch(t){return this.e.reportError(t,"overlayTemplate"),""}}Nh(e,t,i){if(typeof t=="object"&&t!=null&&"el"in t){this.Ue.appendChild(t.el),this.mn=t.destroy??null;return}if(t instanceof HTMLElement){this.Ue.appendChild(t);return}if(t){i?this.Ue.innerHTML=t:this.Ue.textContent=t;return}if(e!=="loading")return;let r=p("div","mach-spinner");r.setAttribute("aria-label","loading"),this.Ue.appendChild(r)}Eh(e,t,i=!1){this.rr===e&&this.as===t&&this.ls===i||(this.rr=e,this.as=t,this.ls=i,this.hs(),this.Ue.replaceChildren(),this.Nh(e,this.Lh(t),i),this.Ke.style.display="",this.root.classList.add("mach-has-overlay"),this.Ke.setAttribute("role",e==="error"?"alert":"status"),this.root.setAttribute("aria-busy",e==="loading"?"true":"false"))}Rh(){this.rr&&(this.rr=null,this.as=null,this.ls=!1,this.Ke.style.display="none",this.root.classList.remove("mach-has-overlay"),this.hs(),this.Ue.replaceChildren(),this.root.setAttribute("aria-busy","false"))}Et(e,t){this.ft&&(e?(this.fn.textContent!==t&&(this.fn.textContent=t),this.ft.style.display="",this.root.setAttribute("aria-busy","true")):(this.ft.style.display="none",this.rr!=="loading"&&this.root.setAttribute("aria-busy","false")))}destroy(){document.fonts?.removeEventListener("loading",this.cs),this.ui?.(),this.ui=null,this.gn?.disconnect(),this.gn=null,this.ci&&cancelAnimationFrame(this.ci),this.ci=0,this.hs(),this.root?.remove()}hs(){if(!this.mn)return;let e=this.mn;this.mn=null;try{e()}catch(t){this.e.reportError(t,"overlayTemplate.destroy")}}};function mn(n,e){return{setData:t=>n.rt(t),transact:t=>n.Oi(t),transactAsync:(t,i)=>n.Fh(t,i),flushTransactions:()=>n.Wl(),getCount:()=>e.i.G(),getAt:t=>e.i.h(t),getById:t=>e.i.F(t),forEach:t=>e.i.lu(t),forEachDisplayed:t=>e.i.du(t),reorder:(t,i)=>!e.o()&&!e.a.isEditing()&&e.i.Wa(t,i),isRemote:()=>e.i.g,reload:t=>n.reload(t),ensureLoaded:(t,i,r)=>n.vo(t,i,r),purgeCache:()=>{e.o()||e.i.kc()},getCacheSnapshot:()=>e.i.Pc()}}function gn(n,e){return{getDefinitions:()=>e.r.no(),setDefinitions:t=>n.Ri(t),getState:()=>e.r.ca(),setState:t=>n.Oh(t),resetState:()=>n.lo(),setVisible:(t,i)=>n.oo(t,i),setPinned:(t,i)=>n.so(t,i),move:(t,i)=>{e.o()||e.Ei(t,i)},setWidth:(t,i)=>n.Ee(t,i),fit:t=>n.Hh(t),autoSize:t=>n.Vh(t),autoSizeAll:()=>n.Bh(),getWorkbenchItems:()=>n._h(),openWorkbench:t=>{e.o()||e.columnMenu.rh(t)},closeWorkbench:()=>e.columnMenu.close()}}function yn(n,e){return{getRows:()=>e.f.$a(),getVisibleRows:()=>n.zh(),getNodes:()=>e.f.ei(),getIds:()=>e.f.Eo(),setRows:(t,i)=>n.Wh(t,i),setById:(t,i,r)=>e.f.pu(t,i,r),selectAll:t=>e.f.selectAll(t),clear:()=>e.f.deselectAll(),getMode:()=>e.t.rowSelection,setMode:t=>n.$h(t),getRange:()=>e.s.nr(),clearRange:()=>n.li()}}function vn(n,e){return{startCell:t=>n.Kh(t),startRow:t=>e.a.startRow(t),isRowActive:t=>e.a.sl(t),stop:t=>e.a.Te(t?.cancel===!0),getChanges:()=>e.$.getChanges(),getDirtyRowIds:()=>e.$.getDirtyRowIds(),markSaved:t=>e.$.markSaved(t),rollback:t=>e.$.rollback(t),save:(t,i)=>n.Uh(t,i),undo:()=>!e.o()&&e.O.undo(),redo:()=>!e.o()&&e.O.redo(),canUndo:()=>e.O.canUndo(),canRedo:()=>e.O.canRedo()}}function bn(n){return{get:()=>n.getState(),apply:(e,t)=>n.$l(e,t)}}function wn(n,e){return{get:()=>e.jh(),getPerformance:()=>e.be.snapshot(),resetPerformance:()=>e.be.reset()}}function Cn(n,e){return{getModel:()=>e.i._e(),setModel:t=>n.St(t),getAdvancedModel:()=>e.i.Ni(),setAdvancedModel:t=>n.nt(t),getQuickText:()=>e.i.Co(),setQuickText:t=>n.Mt(t),isPresent:t=>t==null?e.i.Hi():v(e.i._e(),t)}}function Tn(n,e){return{getModel:()=>e.r.te(),setModel:t=>n.qh(t)}}function Dn(n,e){return{isEnabled:()=>e.i.we,setEnabled:t=>{e.o()||e.i.Ba(t)},getPage:()=>e.i.Qt(),setPage:t=>{e.o()||e.i.setPage(t)},getPageSize:()=>e.t.paginationPageSize,setPageSize:t=>{e.o()||e.i.setPageSize(t)},getPageCount:()=>e.i.getPageCount(),getTotalRowCount:()=>e.i.getTotalRowCount()}}function xn(n,e){return{isRowExpanded:t=>e.i.isRowExpanded(t),setRowExpanded:(t,i)=>e.o()||e.i.isRowExpanded(t)===i?!1:(i?e.i.ou(t):e.i.su(t),e.i.isRowExpanded(t)===i),isTreeRowLoading:t=>!e.o()&&e.i.isTreeRowLoading(t),loadTreeChildren:(t,i)=>e.o()?Promise.resolve([]):e.i.loadTreeChildren(t,i?.force===!0),isGroupExpanded:t=>e.i.isGroupExpanded(t),setGroupExpanded:(t,i)=>e.o()||e.i.isGroupExpanded(t)===i?!1:(e.i.xo(t),e.i.isGroupExpanded(t)===i),setAllGroupsExpanded:t=>{e.o()||e.i.setAllGroupsExpanded(t)},setAllDetailsExpanded:t=>{e.o()||e.i.setAllDetailsExpanded(t)}}}function Rn(n,e){return{getRoot:()=>e.o()?null:e.n.root,scrollToRow:(t,i)=>e.s.Wr(t,i),refreshCells:t=>n.refreshCells(t),refreshLayout:()=>n.refreshLayout(),flush:()=>e.hi.flush(),setOverlay:t=>Gt(e,t),getPinnedRows:t=>e.Le.getRows(t),setPinnedRows:(t,i)=>n.setPinnedRows(t,i)}}function En(n,e){return{exportCsv:t=>n.Yh(t),importCsv:(t,i)=>n.importCsv(t,i),exportMatrix:t=>n.Kl(t),importMatrix:(t,i)=>n.importMatrix(t,i),print:t=>n.print(t),copyRange:()=>e.o()?Promise.resolve(!1):e.wl()}}function Lt(n){return ie(n?.reason,"The operation was aborted")}function Sn(n,e){return ot(n,e,()=>Lt(e))}function Bi(n,e,t,i=!1){let r=x(n,t,i);return r===void 0||r===e?void 0:r}function O(n,e,t){let i=n[t];return i==null||i===e[t]?!1:(e[t]=i,!0)}var _i=class{constructor(e){this.e=e;this.ps=[];this.or=null}batch(e){return this.e.Ul(()=>e(this.e.api))}rt(e){if(!this.e.o()){if(this.e.i.g){this.e.t.rowData=e??[];return}this.e.i.rt(e),this.e.K({data:!0})}}Oi(e){if(this.e.o()||this.e.i.g)return;let t=this.e.i.Oi(e);this.jl(t)}Fh(e,t={}){if(this.e.o()||this.e.i.g)return Promise.resolve();if(t.signal?.aborted)return Promise.reject(Lt(t.signal));let i=new Promise((r,o)=>{let s={transaction:e,revision:this.e.i.Be(),resolve:r,reject:o,signal:t.signal,aborted:!1};t.signal&&(s.onAbort=()=>{s.aborted||(s.aborted=!0,o(Lt(t.signal)))},t.signal.addEventListener("abort",s.onAbort,{once:!0})),this.ps.push(s)});return this.or==null&&(this.or=setTimeout(()=>this.Wl(),this.e.t.asyncTransactionWaitMillis)),i}ql(){this.or!=null&&clearTimeout(this.or),this.or=null;let e=this.ps;return this.ps=[],e}Wl(){let e=this.ql(),t=this.e.i,i=t.Be(),r=e.filter(s=>!s.aborted&&s.revision===i).map(s=>s.transaction);if(r.length>0&&!this.e.o()&&!t.g){let s=t.Bc(r);t.Be()===i&&this.jl(s)}let o=t.Be()===i;for(let s of e)s.signal&&s.onAbort&&s.signal.removeEventListener("abort",s.onAbort),!s.aborted&&(o&&s.revision===i?s.resolve():s.reject(ie(void 0,"The table data changed before the transaction could complete")))}jl(e){if(!(!e.pipelineChanged&&e.updatedRowIds.length===0)){if(e.pipelineChanged||this.e.t.getRowHeight||this.e.r.l().some(t=>t.colDef.autoHeight===!0)){this.e.K({data:!0});return}this.e.K({cells:{rowIds:e.updatedRowIds},summary:!0,overlays:!0})}}Ri(e){this.updateOptions({columnDefs:[...e??[]]})}Oh(e){this.e.o()||(this.e.r.ua(e),this.fs())}lo(){this.e.o()||(this.e.r.lo(),this.fs())}oo(e,t){this.e.o()||(this.e.r.oo(e,t),this.e.sr(),this.e.emit("columnVisibilityChanged",{colId:e,visible:t}))}so(e,t){this.e.o()||(this.e.r.so(e,t),this.fs())}fs(){this.e.sr(),this.e.yn()}Ee(e,t){if(this.e.o())return!1;let i=this.e.r.R(e);return!i||!this.e.r.Ee(i,t)?!1:(this.at([i]),!0)}Hh(e){if(this.e.o())return;let t=this.e.r.l(),i=t.filter(d=>d.pinned===null&&!d.colDef.suppressSizeToFit);if(i.length===0)return;let r=e??this.e.n.us();if(!Number.isFinite(r)||r<=0)return;let o=t.reduce((d,c)=>d+(c.pinned!==null||c.colDef.suppressSizeToFit?c.currentWidth:0),0),s=tt(i.map(d=>({width:d.currentWidth,minWidth:d.colDef.minWidth,maxWidth:d.colDef.maxWidth})),Math.max(0,r-o)),a=this.e.t.columnLayout==="fit"&&e===void 0,l=i.filter((d,c)=>a?this.e.r.la(d,s[c]):this.e.r.Ee(d,s[c]));this.at(l)}Vh(e){if(this.e.o())return;let t=this.e.r.R(e);t&&this.Yl(t)&&this.at([t])}Yl(e){return this.e.t.columnLayout==="fit"&&e.colDef.suppressSizeToFit?!1:e.hasCheckbox||e.isDetailToggle?this.e.r.Ee(e,e.isDetailToggle?38:46):this.Xh(e,this.e.je.oa(e))}Xh(e,t){return this.e.t.columnLayout==="fit"?this.e.r.la(e,t):this.e.r.Ee(e,t)}Bh(){if(this.e.o())return;let e=[];for(let t of this.e.r.l())this.Yl(t)&&e.push(t);e.length>0&&this.at(e)}at(e){this.e.ii(),this.e.at(e)}qh(e){this.e.o()||(this.e.r.Si(e),this.e.Si())}St(e){this.e.o()||(this.e.i.St(e),this.e.ar())}nt(e){this.e.o()||!this.e.i.nt(e)||this.e.ar()}Mt(e){if(this.e.o())return;let t=this.e.i.Mt(e);this.e.t.quickFilterText=this.e.i.Co(),t&&this.e.ar()}$h(e){this.e.t.rowSelection!==e&&this.updateOptions({rowSelection:e})}Wh(e,t=!0){if(this.e.o())return;let i=this.e.t.resolveRowId,r=[];for(let o of e){let s=i?this.e.i.F(this.e.i.resolveRowId(o,-1,`__missing_selection_${this.e.Zt()}`)):this.e.i.He().find(a=>a.data===o);s&&r.push({node:s,selected:!0})}r.length>0?this.e.f.kt(r,t):t&&this.e.f.deselectAll()}zh(){let e=this.e.f;return this.e.i.It().filter(t=>!t.isDetail&&!t.isGroup&&e.Vr(t.id)).map(t=>t.data).filter(Boolean)}async Uh(e,t){let i=pn(this.e.$.getChanges(),t);if(i.length===0)return{submitted:[],saved:[],failures:[],conflicts:[]};let r=this.e.i.Be(),o=fn(i,await e(i));return!this.e.o()&&r===this.e.i.Be()&&this.e.$.yh(o.saved),o}setPinnedRows(e,t){if(this.e.o())return;let i=e==="top"?"pinnedTopRowData":"pinnedBottomRowData";this.e.t[i]=t??[],this.e.Le.setRows(e,this.e.t[i])}li(){this.e.o()||this.e.s.li()}_h(){return this.e.r.ee().filter(e=>!e.isDetailToggle).map(e=>({colId:e.id,label:e.colDef.headerName??e.colDef.field??e.id,visible:!e.hide,pinned:e.pinned,width:e.currentWidth||e.manualWidth||e.colDef.width||0,movable:e.movable,hideable:!e.hasCheckbox}))}refreshLayout(){this.e.o()||(this.e.Ie(),this.e.s.vn(!0))}reload(e={}){return this.e.o()?Promise.resolve():e.signal?.aborted?Promise.reject(Lt(e.signal)):this.e.i.g?Sn(this.e.i.Fr(e.signal),e.signal):(this.rt(this.e.t.rowData),Promise.resolve())}vo(e,t,i={}){return this.e.o()?Promise.resolve():Sn(this.e.i.vo(e,t,i.signal),i.signal)}importCsv(e,t={}){if(!e)return!1;let{parseValue:i,...r}=t;return this.importMatrix(Si(e,t.separator??","),{...r,parseValue:i?o=>i({...o,value:o.value}):void 0})}importMatrix(e,t={}){if(this.e.o()||this.e.i.g||!Array.isArray(e)||!e.length)return!1;try{let i=sn(this.e.api),r=t.mode==="paste"?i.pasteRows(e.length):void 0,o=an(i,e,t,r);if(o.issues.length)return this.e.reportError(new Error(o.issues.map(s=>s.message).join("; ")),"import",{issues:o.issues}),!1;if(t.mode==="paste")this.e.pi(o.rows.flatMap(s=>s.changes));else{let s=o.rows.map(a=>a.data);t.mode==="append"?this.Oi({add:s}):this.rt(s)}return!0}catch(i){return this.e.reportError(i,"import"),!1}}print(e={}){if(this.e.o())return!1;try{let t=window.open("","_blank","width=980,height=720");if(!t)return!1;let i=this.e.r.l().filter(d=>q(d)&&!d.colDef.rowDrag),r=this.e.i.Ha().filter(d=>!d.isDetail&&!d.isGroup),s=e.includeHeader!==!1?`<tr>${i.map(d=>`<th>${ve(d.colDef.headerName??d.colDef.field??d.id)}</th>`).join("")}</tr>`:"",a=r.map(d=>`<tr>${i.map(c=>{let u=he(this.e,d,c);return`<td>${ve(u)}</td>`}).join("")}</tr>`).join(""),l=`<!doctype html><html><head><meta charset="utf-8"><title>${ve(e.title??"MachTable")}</title><style>body{font-family:system-ui,"PingFang SC","Microsoft YaHei",sans-serif;padding:20px}h3{margin:0 0 12px;font-size:16px}table{border-collapse:collapse;width:100%;font-size:12px}th,td{border:1px solid #bbb;padding:5px 8px;text-align:left;word-break:break-all}th{background:#f2f5f9;font-weight:600}@page{margin:12mm}</style></head><body><h3>${ve(e.title??"")}</h3><table>${s}${a}</table></body></html>`;return t.document.write(l),t.document.close(),t.focus(),t.print(),!0}catch{return!1}}Kh(e){let t=this.e.r.R(e.colId);return t?this.e.a.start(e.rowIndex,t,e.keyPress??null):!1}refreshCells(e){let t=e==null||e.rowIds==null&&e.rowIndexes==null&&e.columns==null;this.e.K({cells:e??!0,pinned:e?.includePinned??t,summary:t})}getOption(e){return this.e.t[e]}updateOptions(e){if(this.e.o()||(this.e.ms(e),e=ln(e),Object.keys(e).length===0))return;let t=this.e.t;if((e.treeData??t.treeData)&&(e.rowData!==void 0||e.treeData!=null||e.childrenKey!=null)){let i=v(e,"rowData")?e.rowData:t.rowData;ge(Array.isArray(i)?i:[],e.childrenKey??t.childrenKey)}this.e.Ul(()=>{let i={},r=this.e.t.columnMenu;this.Jh(e,i),this.Zh(e,i),this.Qh(e,i),this.ep(e,i),this.tp(e),this.ip(e,i),this.rp(e,i),this.np(e,i),this.op(e,i),this.sp(e,i),this.ap(e,i,r)})}Jh(e,t){let i=this.e.t;v(e,"columnDefs")&&e.columnDefs!==i.columnDefs&&(i.columnDefs=Array.isArray(e.columnDefs)?e.columnDefs:[],t.needsColumnRebuild=!0,t.columnDefsChanged=!0),R(e,i,["rowNumber"])&&(t.needsColumnRebuild=!0),v(e,"rowData")&&e.rowData!==i.rowData&&(i.rowData=Array.isArray(e.rowData)?e.rowData:[],t.needsRowRebuild=!0),v(e,"initialState")&&e.initialState&&(i.initialState=e.initialState,t.stateToApply=e.initialState),this.lp(e)}lp(e){for(let t of He){let i=t;v(e,i)&&Reflect.set(this.e.t,i,e[i])}}Zh(e,t){let i=this.e.t;for(let o of["rowHeight","headerHeight","rowBuffer"]){let s=Bi(e[o],i[o],o==="rowBuffer"?0:1,o==="rowBuffer");s!==void 0&&(i[o]=s,t.layout=!0,o==="headerHeight"&&(t.header=!0))}e.columnLayout!=null&&e.columnLayout!==i.columnLayout&&(i.columnLayout=e.columnLayout==="fit"?"fit":"normal",t.layout=!0),e.domLayout!=null&&e.domLayout!==i.domLayout&&(i.domLayout=e.domLayout==="autoHeight"?"autoHeight":"normal",this.e.n.Gh(i.domLayout),t.pool=!0),v(e,"maxBodyHeight")&&(i.maxBodyHeight=x(e.maxBodyHeight,1),t.layout=!0),R(e,i,["multiSort"]);let r=Bi(e.detailRowHeight,i.detailRowHeight,1);r!==void 0&&(i.detailRowHeight=r,this.e.s.bn(),this.e.s.lr(!0))}Qh(e,t){let i=this.e.t;e.editType!=null&&e.editType!==i.editType&&(this.e.a.stop(!0),i.editType=e.editType==="fullRow"?"fullRow":"cell",t.cells=!0),e.editableIndicator!=null&&e.editableIndicator!==i.editableIndicator&&(i.editableIndicator=e.editableIndicator==="always"||e.editableIndicator==="none"?e.editableIndicator:"hover",t.cells=!0),R(e,i,["rowEditValidator"],!0),R(e,i,["singleClickEdit","manualSorting","manualFiltering"])}ep(e,t){let i=this.e.t;typeof e.enableColumnResize=="boolean"&&e.enableColumnResize!==i.enableColumnResize&&(this.e.dr.Gt(),i.enableColumnResize=e.enableColumnResize,t.header=!0),O(e,i,"locale")&&(t.header=!0,t.cells=!0,this.e.fi.xe(),this.e.dt.xe()),O(e,i,"indexOffset")&&(t.cells=!0),O(e,i,"showSummary")&&(t.summary=!0,t.layout=!0);let r=Bi(e.undoStackSize,i.undoStackSize,0,!0);r!==void 0&&(i.undoStackSize=r,this.e.O.xl());let o=x(e.asyncTransactionWaitMillis,0,!0);o!==void 0&&(i.asyncTransactionWaitMillis=o),this.dp(e,t),this.cp(e)}dp(e,t){v(e,"getRowHeight")&&(this.e.t.getRowHeight=e.getRowHeight,this.e.s.ot(),t.layout=!0)}cp(e){let t=this.e.t;e.enableRangeSelection!=null&&(t.enableRangeSelection=e.enableRangeSelection,e.enableRangeSelection||this.li()),R(e,t,["tooltipComponent"],!0);let i=x(e.tooltipShowDelay,0);i!==void 0&&(t.tooltipShowDelay=i),R(e,t,["flashCells"]),R(e,t,["getContextMenuItems"],!0),O(e,t,"theme")&&(this.e.n.Vl(t.theme),this.e.wn.refresh())}tp(e){if(!v(e,"pagination"))return;let t=this.e.t,i=e.pagination,r=i!==!1&&t.datasource==null;r!==t.paginationEnabled&&this.e.i.Ba(r),typeof i=="object"&&i&&this.up(i),t.paginationEnabled&&this.e.i.Xc(),this.e.fi.xe()}up(e){let t=this.e.t;t.paginationMode=e.mode==="server"?"server":"client";let i=x(e.page,1,!0),r=x(e.total,0,!0);i!==void 0&&(t.paginationPage=i),r!==void 0&&(t.paginationTotal=r),e.pageSize!=null&&(t.paginationPageSize=e.pageSize),e.pageSizeOptions!=null&&(t.paginationPageSizeOptions=e.pageSizeOptions),e.showTotal!=null&&(t.paginationShowTotal=e.showTotal),e.showPageSizeSelector!=null&&(t.paginationShowSizeSelector=e.showPageSizeSelector)}ip(e,t){v(e,"rowStyleRules")&&(this.e.t.rowStyleRules=Array.isArray(e.rowStyleRules)?e.rowStyleRules:[],t.cells=!0,this.e.K({pinned:!0})),this.hp(e,t),this.pp(e,t);let i=this.e.t;O(e,i,"stripedRows")&&this.e.n.kh(i.stripedRows),O(e,i,"showCellBorders")&&this.e.n.Ph(i.showCellBorders)}hp(e,t){let i=this.e.t;e.watermark!==void 0&&(Object.assign(i,oi(e)),this.e.wn.refresh()),this.fp(e),v(e,"summaryMethod")&&(i.summaryMethod=e.summaryMethod,t.summary=!0)}fp(e){let t=this.e.t;R(e,t,["suppressClipboard","contextMenu","columnMenu","fillHandle"]),e.statusBar!==void 0&&(t.statusBarEnabled=e.statusBar===!0||typeof e.statusBar=="object"&&e.statusBar!=null,typeof e.statusBar=="object"&&e.statusBar?.panels&&(t.statusBarPanels=e.statusBar.panels),this.e.dt.xe())}pp(e,t){let{size:i}=e;if(i==null||!v(Se,i)||i===this.e.t.size)return;let r=Se[i];this.e.t.size=i,this.e.t.rowHeight=e.rowHeight??r.rowHeight,this.e.t.headerHeight=e.headerHeight??r.headerHeight,this.e.n.Ih(i),t.layout=!0,t.header=!0}rp(e,t){let i=this.e.t;R(e,i,["suppressCellFocus","suppressRowHoverHighlight","suppressNoRowsOverlay"]),O(e,i,"suppressHeaderFocus")&&(t.header=!0),this.mp(e),this.gp(e)}mp(e){let t=this.e.t,i=!1;for(let r of["ariaLabel","ariaLabelledBy","ariaDescribedBy"])v(e,r)&&(t[r]=e[r]??Me[r],i=!0);i&&this.e.n.Fl(t)}gp(e){let t=this.e.t;for(let i of["overlayNoRowsTemplate","overlayLoadingTemplate","overlayErrorTemplate"])v(e,i)&&(t[i]=e[i]??Me[i]);R(e,t,["allowUnsafeOverlayHtml"]),v(e,"className")&&(t.className=e.className??"",this.e.n.Nl(t.className)),R(e,t,["loading"]),v(e,"error")&&(t.error=e.error??null)}np(e,t){this.yp(e,t),this.vp(e,t);let i=this.e.t;R(e,i,["autoCheckedChildren"]),O(e,i,"defaultExpandAll")&&(t.needsRowRebuild=!0),e.applyRowDrag!=null&&(i.applyRowDrag=e.applyRowDrag,t.cells=!0),v(e,"rowDragPolicy")&&(i.rowDragPolicy=e.rowDragPolicy,t.cells=!0),R(e,i,["suppressWarnings"])}yp(e,t){let i=this.e.t;if(O(e,i,"rowSelection")&&(this.e.f.uu(),t.header=!0,t.pool=!0,this.e.Cn()),e.quickFilterText!==void 0&&this.Mt(e.quickFilterText),e.defaultColDef!==void 0&&e.defaultColDef!==i.defaultColDef&&(i.defaultColDef={...ri,...e.defaultColDef},t.needsColumnRebuild=!0),v(e,"columnTypes")&&e.columnTypes!==i.columnTypes&&(i.columnTypes=e.columnTypes??{},t.needsColumnRebuild=!0),v(e,"rowKey")){i.rowKey=e.rowKey;let r=e.rowKey;i.resolveRowId=r?({data:o})=>ni(r,o):void 0,t.needsRowRebuild=!0}}vp(e,t){let i=this.e.t;O(e,i,"masterDetail")&&(t.needsColumnRebuild=!0,t.needsRowRebuild=!0),O(e,i,"detailToggleColumn")&&(t.needsColumnRebuild=!0),O(e,i,"treeData")&&(t.needsRowRebuild=!0,t.needsColumnRebuild=!0,this.e.Cn()),O(e,i,"childrenKey")&&(t.needsRowRebuild=!0),R(e,i,["isTreeRowExpandable","loadTreeChildren"],!0)&&(t.cells=!0)}op(e,t){let i=this.e.t;R(e,i,["aggFuncs"],!0)&&(t.needsRowRebuild=!0),R(e,i,["components","actionPolicy"],!0)&&(t.cells=!0),v(e,"features")&&(i.features=Array.isArray(e.features)?e.features:[],t.needsFeatureReload=!0),this.bp(e,t),this.wp(e,t)}bp(e,t){let i=this.e.t;v(e,"dataProcessor")&&this.e.Xl(e.dataProcessor)&&(t.needsRowRebuild=!0);let r=x(e.dataProcessorMinRows,1,!0);r!==void 0&&r!==i.dataProcessorMinRows&&(i.dataProcessorMinRows=r,t.needsRowRebuild=!0)}wp(e,t){let i=this.e.t;v(e,"persistence")&&(i.persistence=$e(e.persistence),t.needsStateLoad=!0)}sp(e,t){let i=this.e.t;si(e,i)&&i.datasourceMode==="block"&&(t.datasourceChanged=!0),this.Cp(e,t),this.Tp(e,t),this.Dp(e)}Cp(e,t){let i=this.e.t;if(v(e,"datasourceMode")){let r=e.datasourceMode==="block"?"block":"sequential";r!==i.datasourceMode&&(i.datasourceMode=r,t.datasourceChanged=!0)}if(v(e,"datasourceRowCount")){let r=e.datasourceRowCount==null?null:x(e.datasourceRowCount,0,!0)??null;r!==i.datasourceRowCount&&(i.datasourceRowCount=r,t.datasourceChanged=!0)}}Tp(e,t){let i=this.e.t;v(e,"datasource")&&e.datasource!==i.datasource&&(i.datasource=e.datasource,i.paginationEnabled=e.datasource==null&&i.paginationEnabled,t.datasourceChanged=!0,this.e.fi.xe()),R(e,i,["detailRowRenderer","isRowExpandable"],!0)&&(t.cells=!0)}Dp(e){e.pinnedTopRowData!==void 0&&this.setPinnedRows("top",e.pinnedTopRowData),e.pinnedBottomRowData!==void 0&&this.setPinnedRows("bottom",e.pinnedBottomRowData)}ap(e,t,i){let r=this.e.t;t.needsColumnRebuild?this.xp(e,t):v(e,"advancedFilterModel")&&(t.filterChanged=this.e.i.nt(e.advancedFilterModel)),t.needsFeatureReload&&this.e.Jl(r.features),this.Rp(t),t.filterChanged&&this.e.gs(!t.needsColumnRebuild),t.layout&&this.e.n.Mh(r.rowHeight,r.headerHeight),e.columnMenu!=null&&e.columnMenu!==i&&(t.header=!0),t.stateToApply&&this.$l(t.stateToApply),t.pool&&(t.cells=void 0),t.overlays=!0,this.e.K(t)}xp(e,t){t.columnDefsChanged&&!t.needsRowRebuild&&(this.e.ze(),this.e.a.stop(!0));let i=this.e.r.Ri(this.e.t.columnDefs);t.filterChanged=this.e.i.zc(v(e,"advancedFilterModel")?e.advancedFilterModel??null:void 0),i&&this.e.emit("sortChanged",{sortModel:this.e.r.te()},!1),this.e.sr(),t.header=!1,t.pool=!1}Rp(e){let t=e.needsStateLoad||e.needsColumnRebuild,i=e.datasourceChanged||e.needsRowRebuild||e.columnDefsChanged||e.filterChanged,r=this.e.t.persistence?.sections,o=i&&(this.e.i.g||r?.length===1&&r[0]==="columns");t&&o&&this.e.ys(!e.needsStateLoad,!0),this.Ep(e,i),t&&!o&&this.e.ys(!e.needsStateLoad)}Ep(e,t){if(e.datasourceChanged){this.e.i.Ac();return}t&&(!this.e.i.g&&e.needsRowRebuild?this.rt(this.e.t.rowData):this.e.i.To())}Yh(e={}){let t=this.Kl({...e,target:"csv",protectFormulas:!1});return qr(t,e)}Kl(e={}){let t=this.e.r.l().filter(q),i=e.includeHeader===!1?[]:[t.map(o=>o.colDef.headerName??o.colDef.field??o.id)];if(e.headersOnly)return i;let r=e.onlySelected?this.e.f.ei().sort((o,s)=>o.rowIndex-s.rowIndex):e.onlyAllDisplayed?this.e.i.It():this.e.i.Ha();return[...i,...r.filter(o=>!o.isDetail&&!o.isGroup).map(o=>t.map(s=>{let a=Oe(this.e,o,s,e.target??"xlsx");return e.protectFormulas===!1?a:ye(a)}))]}getState(){return{version:2,columns:this.e.r.ca(!1),sortModel:this.e.r.te(),filterModel:this.e.i._e(),advancedFilterModel:this.e.i.Ni(),quickFilterText:this.e.i.Co(),pagination:{enabled:this.e.i.we,page:this.e.i.Qt(),pageSize:this.e.t.paginationPageSize},selectedRowIds:this.e.f.Eo(),expandedRowIds:this.e.i.iu(),expandedGroupIds:this.e.i.ru()}}$l(e,t={}){if(this.e.o())return;let i=X(e);if(!i){this.e.reportError(new TypeError("[MachTable] GridState must use the current version 2 schema."),"gridState.apply");return}let r=["columns","sort","filter","pagination","selection","expansion"],o=new Set(t.sections??r);this.e.a.stop(!0),this.Sp(i,o),this.Mp(i,o),t.emitEvents!==!1&&this.Ip(o),o.has("columns")&&this.e.yn()}Sp(e,t){t.has("columns")&&this.e.r.ua(e.columns??[]),t.has("sort")&&this.e.r.Si(e.sortModel??[]),t.has("filter")&&(this.e.i.St(e.filterModel??{}),this.e.i.nt(e.advancedFilterModel),this.e.i.Mt(e.quickFilterText)),t.has("expansion")&&this.e.i.nu(e.expandedRowIds??[],e.expandedGroupIds??[]),t.has("pagination")&&e.pagination&&(this.e.t.paginationEnabled=e.pagination.enabled&&!this.e.i.g,this.e.i.Va(e.pagination.page,e.pagination.pageSize),this.e.fi.xe())}Mp(e,t){t.has("columns")&&this.e.sr(),this.e.Ap()||(this.e.i.g?(t.has("sort")||t.has("filter"))&&this.e.i.Sa():this.e.i.I()),this.e.W.vs(),this.e.W.bs(),t.has("selection")&&this.e.f.Ka(e.selectedRowIds??[])}Ip(e){e.has("sort")&&this.e.emit("sortChanged",{sortModel:this.e.r.te()}),e.has("filter")&&this.e.gs(),e.has("pagination")&&this.e.i._i(this.e.t.paginationPageSize)}destroy(){let e=this.ql();for(let t of e)t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort),t.aborted||t.resolve();this.e.destroy()}},Us={rows:mn,columns:gn,selection:yn,editing:vn,filtering:Cn,sorting:Tn,pagination:Dn,hierarchy:xn,view:Rn,state:bn,io:En,diagnostics:wn};function Mn(n){let e=new _i(n),t={};for(let[i,r]of Object.entries(Us)){let o;Object.defineProperty(t,i,{enumerable:!0,get:()=>o??(o=Object.freeze(r(e,n)))})}return Object.assign(t,{batch:i=>e.batch(i),whenReady:()=>n.whenReady(),getOption:i=>e.getOption(i),updateOptions:i=>e.updateOptions(i),on:(i,r)=>n.de.on(i,r),destroy:()=>e.destroy(),isDestroyed:()=>n.o()}),on(t,n),rn(t,{suspend:()=>n.suspend(),resume:()=>t.view.refreshLayout(),canReplaceData:()=>!n.a.isEditing()&&n.$.getDirtyRowIds().length===0,readCell:(i,r)=>{let o=n.i.F(i),s=n.r.R(r);return o&&s?xi(Oe(n,o,s,"clipboard")):""},writeInput:i=>n.pi(i.flatMap(({rowId:r,colId:o,value:s})=>{let a=n.i.F(r),l=n.r.R(o);return a&&l?[{node:a,column:l,oldValue:n.d(a,l),newValue:s}]:[]}))}),Object.freeze(t)}var js={contains:"\u5305\u542B",notContains:"\u4E0D\u5305\u542B",equals:"=",notEquals:"\u2260",startsWith:"\u5F00\u5934",endsWith:"\u7ED3\u5C3E",blank:"\u4E3A\u7A7A",notBlank:"\u975E\u7A7A",lessThan:"<",lessThanOrEqual:"\u2264",greaterThan:">",greaterThanOrEqual:"\u2265",inRange:"\u8303\u56F4"};function zi(n){if(!n)return"";if(n.type==="set")return`\u5DF2\u9009 ${n.values.length} \u9879`;let e=[];for(let i of n.conditions){let r=js[i.match]??i.match,o=i.value,s="value2"in i?i.value2:void 0;i.match==="blank"||i.match==="notBlank"?e.push(r):i.match==="inRange"&&o!=null?e.push(`${r} ${o}~${s??o}`):o!=null&&String(o)!==""?e.push(`${r} ${o}`):e.push(r)}let t=n.operator==="or"?" \u6216 ":" \u4E14 ";return e.join(t)}function Wi(n,e,t=!1){let i=0,r=n.length;for(;i<r;){let o=i+r>>1;n[o]<e||t&&n[o]===e?i=o+1:r=o}return i}var we=class{constructor(){this.ce=new Float64Array(1)}update(e){let t=0,i=this.ce.length!==e.length+1;for(let o=0;o<e.length;o++)t+=e[o].currentWidth,!i&&this.ce[o+1]!==t&&(i=!0);if(!i)return!1;let r=new Float64Array(e.length+1);for(let o=0;o<e.length;o++)r[o+1]=r[o]+e[o].currentWidth;return this.ce=r,!0}Zl(){return this.ce[this.ce.length-1]??0}qe(e){let t=Math.max(0,Math.min(Math.trunc(e),this.ce.length-1));return this.ce[t]??0}kp(e){let t=Math.max(0,this.ce.length-1);return t===0?-1:Math.min(t-1,Math.max(0,Wi(this.ce,Math.max(0,e),!0)-1))}Ql(e,t,i=2){let r=Math.max(0,this.ce.length-1);if(r===0||t<=0||this.Zl()<=t)return{first:0,lastExcl:r};let o=Math.max(0,e),s=o+t,a=Math.max(0,Wi(this.ce,o,!0)-1),l=Math.min(r,Wi(this.ce,s));return{first:Math.max(0,a-i),lastExcl:Math.min(r,l+i)}}Tn(e,t,i){let r=t.indexOf(i);if(r<0)return;this.update(t);let o=this.qe(r),s=o+i.currentWidth;o<e.scrollLeft?e.scrollLeft=o:s>e.scrollLeft+e.clientWidth&&(e.scrollLeft=s-e.clientWidth)}};var qs=".mach-header-resize, .mach-filter-btn, .mach-menu-btn, .mach-select-all";function $i(n){return n instanceof HTMLElement&&n.closest(qs)!=null}function Ki(n){return n==="ArrowLeft"||n==="ArrowRight"}function In(n,e){typeof e=="string"?n.classList.add(e):Array.isArray(e)&&n.classList.add(...e)}var Nt=class{constructor(e){this.e=e;this.J=[];this.ws=[];this.N=new we;this.mt=0;this.Ot=Number.MAX_SAFE_INTEGER}Dn(){this.ed(),this.e.dr.Gt(),this.mi(!1);let e=this.e.r,t=e.gc();this.e.n.Ol(t);let i=new Set(e.y("center").slice(this.mt,this.Ot)),r=e.mc(),o=this.e.t.headerHeight;for(let s of w){let a=this.e.n.ir[s];for(let d of a)d.textContent="";let l=(d,c)=>{let u=a[Math.min(c,a.length-1)];for(let h of d)if(h instanceof Q){let f=this.J.length;if(l(h.children,c+1),this.J.length===f)continue;let m=this.Pp(h);u.appendChild(m),this.ws.push({group:h,el:m,pane:s})}else if(!h.hide&&e.me(h)===s&&(s!=="center"||i.has(h))){let f=this.Gp(h,t-c,o);u.appendChild(f.el),this.J.push(f)}};l(r,0)}this.e.t.suppressHeaderFocus||this.J.forEach((s,a)=>{s.el.tabIndex=a===0?0:-1}),this.gt(),this.vs(),this.bs(),this.Hr()}td(){let e=this.mt,t=this.Ot;this.ed(),(e!==this.mt||t!==this.Ot)&&this.Dn()}oi(e,t){let i=this.e.n.si[t];return this.J.find(r=>r.column.id===e&&i.contains(r.el))?.el??null}ed(){let e=this.e.r.y("center"),t=this.e.n.C.center;this.N.update(e);let i=e.length>20?this.N.Ql(t.scrollLeft,t.clientWidth,2):{first:0,lastExcl:e.length};this.mt=i.first,this.Ot=i.lastExcl}Gp(e,t,i){let r=p("div","mach-header-cell mach-header-cell--leaf");e.hasCheckbox&&r.classList.add("mach-header-cell--selection"),r.dataset.colId=e.id,r.setAttribute("role","columnheader"),r.style.height=`${t*i}px`,this.Lp(r,e),this.Np(r,e);let o=this.Fp(r,e);this.Op(r,e);let s=p("span","mach-sort-indicator");r.appendChild(s);let{filterBtn:a,filterTagEl:l}=this.Hp(r,e);return this.Vp(r,e),this.Bp(r,e),this._p(r,e),{column:e,el:r,sortEl:s,filterBtn:a,filterTagEl:l,selectAllEl:o}}Lp(e,t){let i=t.colDef;In(e,i.headerClass),i.headerTooltip&&e.setAttribute("title",i.headerTooltip);let r=i.headerAlign??i.align;r==="center"?e.classList.add("mach-header-cell--center"):r==="right"&&e.classList.add("mach-header-cell--right")}Np(e,t){this.e.t.suppressHeaderFocus||(e.tabIndex=-1,e.addEventListener("mousedown",()=>this.Cs(t)),e.addEventListener("keydown",i=>this.zp(i,t)))}Fp(e,t){if(!t.hasCheckbox||this.e.t.rowSelection!=="multiple")return;let i=p("input","mach-select-all");return i.type="checkbox",i.setAttribute("aria-label","select all rows"),i.addEventListener("click",r=>r.stopPropagation()),i.addEventListener("change",()=>{i.checked?this.e.f.selectAll(!0):this.e.f.deselectAll()}),e.appendChild(i),i}Op(e,t){let i=t.colDef,r;try{r=i.headerComponent?.({colDef:i,column:t,api:this.e.api})}catch(s){this.e.reportError(s,"headerComponent",{colId:t.id}),r=null}r instanceof HTMLElement&&(r={el:r});let o=p("span","mach-header-label");r&&typeof r=="object"&&r.el instanceof HTMLElement?(o.classList.add("mach-header-label--custom"),o.appendChild(r.el),Ue(e,r.destroy)):o.textContent=typeof r=="string"?r:i.headerName??i.field??t.id,e.appendChild(o)}Hp(e,t){if(!t.filterable)return{};let i=p("button","mach-filter-btn");i.type="button",i.setAttribute("aria-label",`filter ${t.id}`),i.innerHTML=sr,i.addEventListener("click",o=>{o.stopPropagation(),this.e.Ts.toggle(t,i)}),e.appendChild(i);let r=p("span","mach-filter-tag");return e.appendChild(r),{filterBtn:i,filterTagEl:r}}Vp(e,t){if(!this.e.t.columnMenu||t.hasCheckbox||t.colDef.suppressColumnMenu)return;let i=p("button","mach-menu-btn");i.type="button";let o=`${t.colDef.headerName??t.colDef.field??t.id} \xB7 ${this.e.c("columnSettings")}`;i.setAttribute("aria-label",o),i.title=o,i.innerHTML=dr,i.addEventListener("click",s=>{s.stopPropagation(),this.e.columnMenu.toggle(t,i)}),e.appendChild(i)}Bp(e,t){if(!this.rd(t))return;let i=p("div","mach-header-resize");i.setAttribute("aria-hidden","true"),i.addEventListener("pointerdown",r=>{r.button===0&&(r.preventDefault(),r.stopPropagation(),this.e.dr.bu(r,t))}),i.addEventListener("dblclick",r=>{r.stopPropagation(),this.e.api.columns.autoSize(t.id)}),i.addEventListener("click",r=>r.stopPropagation()),e.appendChild(i)}_p(e,t){e.addEventListener("click",i=>{this.e.xn.Ru()||$i(i.target)||t.sortable&&this.e.Rr(t,i.shiftKey)}),e.addEventListener("pointerdown",i=>{i.button!==0||$i(i.target)||this.e.xn.xu(i,t)})}Pp(e){let t=p("div","mach-header-cell mach-header-cell--group");e.groupId&&(t.dataset.groupId=e.groupId),t.setAttribute("role","columnheader"),In(t,e.def.headerClass);let i=p("span","mach-header-label mach-header-label--group");return i.textContent=e.headerName,t.appendChild(i),t}gt(){let e={left:0,center:0,right:0};for(let t of w){let i=this.e.n.ir[t],r=0,o=new Map;for(let a of this.e.r.y(t))o.set(a.id,r),r+=a.currentWidth;let s=this.e.t.headerHeight;for(let a of this.J){if(this.e.r.me(a.column)!==t)continue;let l=o.get(a.column.id)??0;a.el.style.width=`${a.column.currentWidth}px`,a.el.style.left=`${l}px`,a.el.setAttribute("aria-colindex",String(this.e.r.Q(a.column.id)+1))}for(let a of this.ws){if(a.pane!==t)continue;let l=a.group.getLeafColumns().filter(u=>!u.hide&&this.e.r.me(u)===t);if(l.length===0)continue;let d=o.get(l[0].id)??0,c=0;for(let u of l)c+=u.currentWidth;a.el.style.left=`${d}px`,a.el.style.width=`${c}px`,a.el.style.height=`${s}px`,a.el.setAttribute("aria-colspan",String(l.length))}for(let a of i)a.style.width=`${r}px`;e[t]=r}this.e.n.Sh(e.left,e.right)}zp(e,t){this.e.o()||this.Wp(e,t)||this.$p(e,t)||this.Kp(e,t)||this.Up(e,t)||this.jp(e)}Wp(e,t){return e.key!=="Enter"&&e.key!==" "?!1:($i(e.target)||(e.preventDefault(),t.sortable&&this.e.Rr(t,e.shiftKey)),!0)}$p(e,t){if(!e.altKey||!Ki(e.key))return!1;if(!this.rd(t))return!0;let i=e.key==="ArrowRight"?24:-24;return this.e.r.Ee(t,t.currentWidth+i),this.e.ii(),this.e.at([t]),e.preventDefault(),!0}Kp(e,t){if(!e.ctrlKey||!Ki(e.key))return!1;if(!t.movable)return!0;e.preventDefault();let i=this.e.r.me(t),r=this.e.r.y(i),o=r.indexOf(t),s=e.key==="ArrowRight"?1:-1,a=Math.max(0,Math.min(r.length-1,o+s));return a!==o&&this.e.Ei(t.id,a),!0}Up(e,t){if(e.altKey||e.ctrlKey||e.metaKey||!Ki(e.key))return!1;e.preventDefault();let i=this.e.r.l(),r=i.indexOf(t);if(r<0)return!0;let o=e.key==="ArrowRight"?1:-1,s=Math.max(0,Math.min(i.length-1,r+o));return this.Cs(i[s]),!0}jp(e){if(e.key!=="Home"&&e.key!=="End")return!1;e.preventDefault();let t=this.e.r.l();if(t.length===0)return!0;let i=e.key==="Home"?0:t.length-1;return this.Cs(t[i]),!0}Cs(e){let t=this.J.find(i=>i.column.id===e.id);if(!t&&!e.pinned&&(this.Tn(e),this.td(),t=this.J.find(i=>i.column.id===e.id)),!!t){for(let i of this.J)i.el.tabIndex=i===t?0:-1;t.el.focus({preventScroll:!0})}}Tn(e){this.N.Tn(this.e.n.C.center,this.e.r.y("center"),e)}rd(e){return this.e.t.enableColumnResize&&e.resizable}vs(){let e=this.e.r.te(),t=e.length>1;for(let i of this.J){let r=e.findIndex(o=>o.colId===i.column.id);if(r>=0){let o=e[r].direction,s=t?`<span class="mach-sort-badge">${r+1}</span>`:"";i.sortEl.innerHTML=(o==="asc"?ar:lr)+s,i.el.setAttribute("aria-sort",o==="asc"?"ascending":"descending"),i.el.classList.add("mach-header-cell--sorted")}else i.sortEl.innerHTML="",i.el.removeAttribute("aria-sort"),i.el.classList.remove("mach-header-cell--sorted")}}bs(){let e=this.e.i._e();for(let t of this.J){if(!t.filterBtn)continue;let i=e[t.column.id],r=i!=null;if(t.filterBtn.classList.toggle("mach-filter-btn--active",r),t.filterTagEl){let o=r?zi(i):"";t.filterTagEl.style.display=o?"":"none",o&&(t.filterTagEl.textContent=o)}}}Hr(){for(let e of this.J){if(!e.selectAllEl)continue;let{all:t,some:i}=this.e.f.mu();e.selectAllEl.checked=t,e.selectAllEl.indeterminate=i}}destroy(){this.mi(!0)}mi(e){for(let t of this.J){let i=je(t.el);if(i)try{i()}catch(r){e?console.error("[mach-table] headerComponent destroy error",r):this.e.reportError(r,"headerComponent.destroy",{colId:t.column.id})}}this.J=[],this.ws=[]}};var Ft=class{constructor(){this.ue=null;this.Ye=null;this.gi=!1;this.Ds=-1;this.xs=-1}qp(){return this.ue}Rs(){return this.Ye}Yp(){return this.ue!=null}start(e,t){(!t||!this.ue)&&(this.ue={...e}),this.Ye={...e},this.Xt()}Xp(e){return this.ue?!0:e.colIdx<0?!1:(this.ue={...e},this.Xt(),!0)}setEnd(e){this.Ye={...e},this.Xt()}clear(){this.ue=null,this.Ye=null,this.Xt()}Xt(){this.gi=!1,this.Ds=-1,this.xs=-1}normalize(e,t){return this.gi!==!1&&this.Ds===e&&this.xs===t?this.gi:(this.Ds=e,this.xs=t,!this.ue||!this.Ye||e<=0||t<=0?(this.gi=null,null):(this.gi={r1:Math.max(0,Math.min(this.ue.row,this.Ye.row,e-1)),r2:Math.max(0,Math.min(Math.max(this.ue.row,this.Ye.row),e-1)),c1:Math.max(0,Math.min(this.ue.colIdx,this.Ye.colIdx,t-1)),c2:Math.max(0,Math.min(Math.max(this.ue.colIdx,this.Ye.colIdx),t-1))},this.gi))}};var Ot=class{constructor(e){this.host=e;this.Ne=null;this.ae=0;this.Rn=0;this.Wi=e=>{let t=this.Ne;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(i=>i.classList.toggle("mach-row--drag-source",this.sourceContains(i.dataset.id??"")))}this.nd()}};this.ef=()=>{if(this.ae=0,!!this.Ne?.active){if(!this.current()){this.destroy();return}this.$i(),this.tf()&&this.nd()}};this.ri=e=>{let t=this.Ne;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.$i(),this.od();try{t.active&&t.drop?.valid&&this.Es(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.Jp=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.Kr=e=>{e.type==="pointercancel"&&e.pointerId!==this.Ne?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(r=>{let o=p("div","mach-row-drop-indicator");return o.hidden=!0,r.append(o),o}),i=p("div","mach-row-drag-preview");i.setAttribute("role","status"),i.hidden=!0,this.host.root.append(i),this.Ne={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:i,drop:null,active:!1},this.Ui(!0)}Ui(e){S(window,e,{pointermove:this.Wi,pointerup:this.ri,pointercancel:this.Kr,keydown:this.Jp,blur:this.Kr})}Zp(e){return this.Ne?.active===!0&&this.sourceContains(e)}Qp(e,t=()=>!0){this.Rn=requestAnimationFrame(()=>{this.Rn=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(i=>i.closest(".mach-row")?.dataset.id===e)?.focus()})}nd(){this.ae||(this.ae=requestAnimationFrame(this.ef))}Es(e,t,i=0){let r=this.host.body.getBoundingClientRect();return e>=r.left&&e<=r.right&&t>=r.top-i&&t<=r.bottom+i}tf(){let e=this.Ne;if(!e||!this.Es(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,i=t.getBoundingClientRect(),r=Math.min(36,i.height/3);if(r<=0)return!1;let o=e.clientY<i.top+r?-Math.ceil(14*T((i.top+r-e.clientY)/r,0,1)):Math.ceil(14*T((e.clientY-i.bottom+r)/r,0,1));if(this.host.scrollBy)return this.host.scrollBy(o);let s=t.scrollTop;return t.scrollTop=T(s+o,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}$i(){let e=this.Ne;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,i=this.describe(t);e.drop=i;let r=this.Es(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!r||!i?.valid,!i)continue;s.dataset.dropPosition=i.position??"",s.style.cssText=i.style??"";let a=parseFloat(s.parentElement.style.height),l=Math.min(this.host.getRowTop(i.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${l}px, 0)`}let o=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=r?i?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${T(e.clientX-o.left+16,8,Math.max(8,o.width-224))}px, ${T(e.clientY-o.top+16,8,Math.max(8,o.height-48))}px, 0)`}od(){let e=this.Ne;this.Ne=null,this.Ui(!1),cancelAnimationFrame(this.ae),this.ae=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.od(),this.release(),cancelAnimationFrame(this.Rn),this.Rn=0}};function An(n,e,t,i,r){let o=i==="before"?-1:1,s=t.rowIndex+o,a=e(s);for(;a&&(a===n||a.isDetail);)s+=o,a=e(s);let l=a&&!a.loading?a.id:null;return{rowIds:[n.id],targetId:t.id,position:i,beforeId:i==="before"?l:t.id,afterId:i==="before"?t.id:l,expectedRevision:r}}var Ht=class extends Ot{constructor(t,i,r,o){super({get root(){return t.n.root},get body(){return t.n.Ge},get viewport(){return t.n.C.center},get containers(){return Object.values(t.n.De)},getRowTop:i,findRowAt:r,scrollBy:o});this.e=t;this.Ht=null}ad(t){return!t.loading&&!t.treeLoading&&!t.isGroup}ld(t){if(this.e.a.isEditing()||t.isDetail||!this.ad(t)||t.data==null||this.e.r.Je().length||this.e.t.applyRowDrag&&!this.e.i.za())return!1;let i=this.yi("canDrag",()=>this.e.t.rowDragPolicy?.canDrag?.({node:t,api:this.e.api})??!0,!1);return i!==!0?i:!this.e.i.M||!!Li(this.e.api)}canDrag(t){return this.ld(t)===!0}isSource(t){return this.Ss()?.isSource(t)??this.Zp(t.id)}start(t,i){if(this.destroy(),!this.canDrag(i)||t.isPrimary===!1)return;let r=this.Ss();if(r){r.start(t,i);return}let o=this.yi("getRevision",()=>this.Ms(i),null);o&&(this.Ht={node:i,from:i.rowIndex,guard:o},this.begin(t))}moveWithKeyboard(t,i){if(!t.altKey||t.key!=="ArrowUp"&&t.key!=="ArrowDown"||(t.preventDefault(),t.stopPropagation(),!this.canDrag(i)))return;let r=this.Ss();if(r){r.moveWithKeyboard(t,i);return}let o=t.key==="ArrowUp"?-1:1,s=i.rowIndex+o;for(;this.e.i.h(s)?.isDetail;)s+=o;let a=this.e.i.h(s),l=this.yi("getRevision",()=>this.Ms(i),null);if(!(!a||!l)){this.Ht={node:i,from:i.rowIndex,guard:l};try{this.commitDrop(this.destination(a,o>0))&&this.Qp(i.id)}finally{this.release()}}}yi(t,i,r){try{return i()}catch(o){return this.e.reportError(o,`rowDragPolicy.${t}`),r}}Ms(t){let i=this.e.i,r=this.e.r.ee(),o=this.e.t.rowDragPolicy,s=i.Be(),a=i.Li(),l=this.e.t.applyRowDrag,d=o?.getRevision?.();return{revision:d,current:()=>this.yi("getRevision",()=>o?.getRevision?.()===d&&s===i.Be()&&a===i.Li()&&i.F(t.id)===t&&r===this.e.r.ee()&&o===this.e.t.rowDragPolicy&&l===this.e.t.applyRowDrag,!1)}}Ss(){let t=Li(this.e.api);return t!==this.sd&&(this.En?.destroy(),this.sd=t,this.En=t?this.yi("driver",()=>t({...this.host,api:this.e.api,capture:i=>this.Ms(i),emit:(i,r,o,s,a)=>{this.e.emit("rowDragEnd",{rowNode:i,fromIndex:r,toIndex:o,targetIndex:s,applied:!1,intent:a})},report:(i,r)=>this.e.reportError(i,`rowDragPolicy.${r}`)}),void 0):void 0),this.En}current(){return this.Ht?.guard.current()??!1}release(){this.Ht=null}sourceContains(t){return this.Ht?.node.id===t}outsideText(){return this.e.c("rowDragOutside")}describe(t){let i=T(this.host.findRowAt(t),0,this.e.i.G()-1),r=this.e.i.h(i);if(r?.isDetail&&(r=this.e.i.F(r.masterId)),!r)return null;let o=this.host.getRowTop(r.rowIndex),s=this.host.getRowTop(r.rowIndex+1);return this.destination(r,t>=(o+s)/2)}destination(t,i){let r=this.Ht,o=t.rowIndex+Number(i);for(;this.e.i.h(o)?.isDetail;)o++;let s=this.e.t.rowDragPolicy,a=!this.e.t.applyRowDrag||s?.canDrop?An(r.node,u=>this.e.i.h(u),t,i?"after":"before",r.guard.revision):void 0,l=s?.canDrop&&a?this.yi("canDrop",()=>s.canDrop({node:r.node,api:this.e.api,targetNode:t,intent:a}),!1):!0,d=l===!0&&this.ad(t),c=typeof l=="string"?l:ke(this.e.c("rowDragPosition"),r.from+1,this.dd(r.from,o)+1);return{node:t,intent:a,boundary:o,valid:d,text:c,position:i?"after":"before"}}commitDrop(t){let i=this.Ht;if(!i||!this.current()||!this.canDrag(i.node)||!this.current())return!1;let r=this.destination(t.node,t.boundary>t.node.rowIndex);if(!r.valid||!this.current())return!1;let o=r.boundary>i.from?r.boundary-1:r.boundary;for(;this.e.i.h(o)?.isDetail;)o--;if(i.from===o)return!1;let s=this.e.t.applyRowDrag&&this.e.i.Wa(i.from,o);return this.e.t.applyRowDrag&&!s?!1:(this.e.emit("rowDragEnd",{rowNode:i.node,fromIndex:i.from,toIndex:r.boundary,targetIndex:s?i.node.rowIndex:this.dd(i.from,r.boundary),applied:s,intent:r.intent}),!0)}dd(t,i){let r=t+1;for(;this.e.i.h(r)?.isDetail;)r++;return i>t?i-(r-t):i}destroy(){this.En?.destroy(),super.destroy()}};var Ys=new Set(["warning","danger","success","info"]);function Be(n,e,t=null){if(!(e.data==null||e.isGroup||e.isDetail||e.loading))for(let i of n.t.rowStyleRules)try{if(i.when({data:e.data,node:e,api:n.api,rowPinned:t})===!0)return i}catch(r){n.reportError(r,"rowStyleRules",{rowId:e.id})}}function Ce(n,e){n.style.removeProperty("--mach-row-rule-bg"),n.style.removeProperty("--mach-row-rule-fg"),e?.tone&&Ys.has(e.tone)?n.dataset.rowTone=e.tone:delete n.dataset.rowTone,e?.backgroundColor&&n.style.setProperty("--mach-row-rule-bg",e.backgroundColor),e?.color&&n.style.setProperty("--mach-row-rule-fg",e.color),n.classList.toggle("mach-row--styled",!!e)}var Vt=class{constructor(){this.se=new Float64Array(0);this.vi=new Float64Array(1);this.Is=new WeakMap;this.Vt=new Map;this.yt=0}reset(e,t){this.se=new Float64Array(e.length),this.vi=new Float64Array(e.length+1),this.Is=new WeakMap,this.Vt=new Map,this.yt=0;for(let i=0;i<e.length;i++){this.Is.set(e[i],i);let r=Math.max(1,t(e[i],i));this.se[i]=r,this.As(r,1),this.add(i,r)}}get length(){return this.se.length}indexOf(e){return this.Is.get(e)??-1}update(e,t){if(e<0||e>=this.se.length)return!1;let i=Math.max(1,t),r=i-this.se[e];return Math.abs(r)<.01?!1:(this.As(this.se[e],-1),this.se[e]=i,this.As(i,1),this.add(e,r),!0)}qe(e){let t=Math.max(0,Math.min(Math.trunc(e),this.se.length)),i=0;for(;t>0;)i+=this.vi[t],t-=t&-t;return i}ks(){return this.qe(this.se.length)}rf(){return this.yt}findIndex(e){if(this.se.length===0)return 0;let t=Math.max(0,e),i=0,r=0,o=1;for(;o<<1<=this.se.length;)o<<=1;for(;o>0;){let s=i+o;s<=this.se.length&&r+this.vi[s]<=t&&(i=s,r+=this.vi[s]),o>>=1}return Math.min(i,this.se.length-1)}add(e,t){for(let i=e+1;i<this.vi.length;i+=i&-i)this.vi[i]+=t}As(e,t){let i=(this.Vt.get(e)??0)+t;if(i<=0?this.Vt.delete(e):this.Vt.set(e,i),this.Vt.size===0)this.yt=0;else if(t>0&&(this.yt===0||e<this.yt))this.yt=e;else if(t<0&&e===this.yt&&!this.Vt.has(e)){let r=Number.POSITIVE_INFINITY;for(let o of this.Vt.keys())r=Math.min(r,o);this.yt=Number.isFinite(r)?r:0}}};var Xs=16e6,Bt=class{constructor(){this.height=0;this.Bt=0;this.bi=0;this.Sn=NaN;this.Ps=0}configure(e,t,i=!0){this.height=i?Math.min(e,Xs):e,this.Bt=Math.max(0,e-t),this.bi=Math.max(0,this.height-t),this.Sn=NaN}get vt(){return this.Bt>this.bi}nf(e){return this.Bt?T(e,0,this.Bt)*this.bi/this.Bt:0}read(e){return e!==this.Sn&&(this.Sn=e,this.Ps=this.bi>0?T(e,0,this.bi)*this.Bt/this.bi:0),this.Ps}anchor(e,t){this.Ps=T(e,0,this.Bt),this.Sn=t}};function kn(n){return!!n&&!n.hasCheckbox&&!n.isDetailToggle&&!n.colDef.rowDrag}function Js(n){let e=n.length>1&&n.every(r=>typeof r=="number"&&!Number.isNaN(r)),t=e?(n[n.length-1]-n[0])/(n.length-1):0,i=!e||n.every(r=>Number.isInteger(r));return{difference:t,integer:i,numeric:e,values:n}}function Zs(n,e){let t=n.values.length;if(t===1)return n.values[0];if(!n.numeric)return n.values[e%t];let i=n.values[t-1]+n.difference*(e-t+1);return n.integer?Math.round(i):Math.round(i*1e6)/1e6}var _t=class{constructor(e){this.e=e;this.m=[];this.bt=0;this.Xe=-1;this.ne=0;this.Gs=0;this.Ls=0;this.cd=0;this.E=new Bt;this.wt=0;this.Ns=!1;this.Mn=-1;this.j=new Vt;this.N=new we;this.he=new Ft;this.In=!1;this.kn=[];this.mt=0;this.Ot=0;this.Fs=!1;this.v=null;this.Os=()=>{this.ne||(this.ne=requestAnimationFrame(()=>{this.ne=0,this.vn()}))};this.Fn=0;this.On=new WeakMap;this.zt=new Set;this.Hn="";this.Ct=!1;this.cr=[];this.Re=null;this.md="";this.Vs="";this.gd=0;this.yd=0;this.Hs=e=>{if(e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||!e.deltaY||!e.cancelable)return;let t=this.e.n.C.center,i=e.deltaMode===1?this.e.t.rowHeight:e.deltaMode===2?t.clientHeight:1,r=this.E.read(t.scrollTop);this.Vn(r+e.deltaY*i),this.E.read(t.scrollTop)!==r&&(e.preventDefault(),t.scrollLeft+=e.deltaX*i,this.Os())};this.Ln=null;this.pr=null;this.Ks=!1;this.nm=e=>{let t=this.pr;if(!t)return;let i=e;if(typeof i.clientX!="number")return;if(!t.active){let o=Math.abs(i.clientX-t.startX),s=Math.abs(i.clientY-t.startY);if(o<4&&s<4)return;t.active=!0,t.axis=o>=s?"h":"v",this.e.n.root.classList.add("mach-root--filling")}let r=t.axis!=="v";this.Bd(r,r?Math.max(t.c2+1,this.Vd(i)):this.Hd(i),!0)};this.om=e=>{let t=this.pr;if(!t)return;let i=e;if(!t.active){this.Gn();return}let r=t.axis==="h",o=r?t.c2:t.r2,s=o;r?s=Math.max(o+1,typeof i.clientX=="number"?this.Vd(i):o+1):typeof i.clientY=="number"&&(s=this.Hd(i)),this.Gn(),s>o?(this.sm(t,s,r),this.wi()):this.Bd(r,o,!1)};this.sf=e=>{if(this.e.o())return;let t=e.target,i=this.Kt(e);if(i&&!t.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-row-drag-handle")&&!(e.detail>1&&this.e.a.Yr())){if(this.e.a.Yr()){let r=i.cellEl?.dataset.colId??"";if(this.e.a.isEditing(i.index,r))return;let o=r?this.e.r.R(r):void 0;this.e.a.al(i.node,o).then(s=>{if(!s||this.e.o())return;this.Wd(e,t,{...i,index:i.node.rowIndex});let a=r?this.e.r.R(r):void 0;a&&!this.e.a.Yr()&&this.e.a.start(i.node.rowIndex,a)});return}this.Wd(e,t,i)}};this.af=e=>{if(this.e.o()||e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell"))return;let t=this.Kt(e);if(!t)return;let{node:i,index:r,cellEl:o}=t;if(i.isDetail||i.isGroup||!o)return;let s=o.dataset.colId??"",a=this.e.r.R(s);if(!a)return;let l=this.e.d(i,a),d=this.e.emit("cellDoubleClicked",{event:e,rowNode:i,rowIndex:r,column:a,colDef:a.colDef,value:l});a.colDef.onCellDoubleClick?.(d),this.e.emit("rowDoubleClicked",{event:e,rowNode:i,rowIndex:r}),this.e.a.oe(i,a)&&this.e.a.start(r,a)};this.lf=e=>{if(this.e.o())return;let t=this.Kt(e);if(!t||t.node.isDetail||t.node.isGroup||!t.cellEl)return;let{node:i,index:r,cellEl:o}=t,s=o.dataset.colId??"",a=this.e.r.R(s);if(a&&(this.e.emit("cellContextMenu",{event:e,rowNode:i,rowIndex:r,column:a,colDef:a.colDef,value:this.e.d(i,a)}),this.e.t.contextMenu)){if(e.preventDefault(),this.e.t.enableRangeSelection&&!this.Ce()){let l=this.e.r.Q(s);l>=0&&this.$s(r,l,!1)}this.e.Us.open(e.clientX,e.clientY,{rowIndex:r,colId:s})}};this.df=e=>{if(!this.gm(e)&&this.e.t.enableRangeSelection&&e.button===0){let t=this.Kt(e);if(t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl&&!t.cellEl.classList.contains("mach-cell--selection")){let i=this.e.r.Q(t.cellEl.dataset.colId??"");i>=0&&(this.$s(t.index,i,e.shiftKey),this.In=!0,!e.shiftKey&&!this.e.t.suppressCellFocus&&this.Ae(t.index,t.cellEl.dataset.colId??""))}}};this.hd=()=>{this.In=!1};this.sn=e=>{if(this.e.o())return;let t=this.Kt(e);if(this.In&&t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl){let i=this.e.r.Q(t.cellEl.dataset.colId??""),r=this.he.Rs();i>=0&&r&&(r.row!==t.index||r.colIdx!==i)&&this.$s(t.index,i,!0)}this.e.t.suppressRowHoverHighlight||!t||t.node.isDetail||this._d(t.index)};this.cf=()=>{this._d(-1)};this.uf=e=>{if(this.e.o()||e.button!==0||!e.target.closest(".mach-row-drag-handle"))return;let i=this.Kt(e);!i||i.node.isDetail||i.node.isGroup||(this._t.start(e,i.node),e.preventDefault())};this.hf=e=>{if(!e.target.closest(".mach-row-drag-handle"))return;let t=this.Kt(e);t&&this._t.moveWithKeyboard(e,t.node)};this._t=new Ht(e,t=>this.Fe(t)-this.wt,t=>this.Pn(t+this.wt,this.e.i.G()),t=>this.of(t))}init(){let e=this.e.n.C.center;this.Gs=e.scrollLeft,this.Ls=e.scrollTop,e.addEventListener("scroll",this.Os,{passive:!0}),this.ud(!0),window.addEventListener("mouseup",this.hd)}ud(e){S(this.e.n.Ge,e,{click:this.sf,dblclick:this.af,contextmenu:this.lf,mousedown:this.df,mouseover:this.sn,mouseleave:this.cf,pointerdown:this.uf,keydown:this.hf})}suspend(){cancelAnimationFrame(this.ne),this.ne=0,this.Gn(),this._t.destroy(),this.In=!1}destroy(){cancelAnimationFrame(this.ne);let e=this.e.n.C.center;e.removeEventListener("scroll",this.Os),e.removeEventListener("wheel",this.Hs),this.ud(!1),window.removeEventListener("mouseup",this.hd),this.Gn(),this._t.destroy(),this.pd(!1),this.Ln?.remove(),this.cr=[],this.zt.clear(),this.j.reset([],()=>this.e.t.rowHeight),this.N.update([]),this.Re?.remove(),this.Re=null}pf(e){return this.e.r.me(e)}vn(e=!1){if(this.e.o())return;let t=this.e.n,i=t.C.center,r=i.scrollLeft,o=i.scrollTop,s=this.E.read(o),a=e||r!==this.Gs,l=e||o!==this.Ls||s!==this.cd;!a&&!l||(this.Gs=r,this.Ls=o,this.cd=s,a&&(t.si.center.style.transform=`translate3d(${-r}px, 0, 0)`,this.e.W.td(),this.e.Le.ff(r)),l&&this.fd(o),this.e.Nn.hide(),this.lr(!1,a),l&&this.e.i.Ic(this.Xe-1))}mf(){let e={left:0,center:0,right:0};for(let t of w)e[t]=this.e.r.y(t).reduce((i,r)=>i+r.currentWidth,0);return e}bn(){let e=this.e.n,t=this.mf();this.N.update(this.e.r.y("center")),t.center=this.N.Zl();let i=this.e.i.It(),r=this.gf(i.length);this.yf(i,r);let o=this.vf(r);this.bf(o),this.wf(t,o),e.root.setAttribute("aria-rowcount",String(r.rowCount+e._l()))}gf(e){let t=this.e.i.Gi(),i=this.e.t.rowHeight,r=this.e.t.masterDetail?[]:this.Cf();r.length&&this.Tf();let o=this.e.t.datasourceMode!=="block"&&(this.e.t.masterDetail||this.e.t.getRowHeight!=null||r.length>0),s=o?this.Df(i,r):`fixed|${i}`;return{autoHeightColumns:r,positionedCount:Math.min(t,e),rowCount:t,rowHeight:i,signature:s,variable:o}}Df(e,t){let i=t.map(r=>`${r.id}:${r.currentWidth}`).join(",");return`${this.e.i.Li()}|${e}|${this.e.t.detailRowHeight}|${i}`}yf(e,t){if(!t.variable){this.xf(t);return}if(t.signature!==this.Hn||this.j.length!==t.positionedCount){t.autoHeightColumns.some(Qe)&&this.ot();let i=e.slice(0,t.positionedCount);this.j.reset(i,r=>this.vd(r,t.autoHeightColumns)),this.bd(t);return}if(this.zt.size!==0){for(let i of this.zt){let r=this.j.indexOf(i);r>=0&&this.j.update(r,this.vd(i,t.autoHeightColumns))}this.bd(t)}}xf(e){this.j.length>0&&this.j.reset([],()=>e.rowHeight),this.Hn=e.signature,this.zt.clear(),this.Fn=e.rowHeight}bd(e){this.Hn=e.signature,this.zt.clear(),this.Fn=this.j.rf()||e.rowHeight}vf(e){return(e.variable?this.j.ks():e.positionedCount*e.rowHeight)+Math.max(0,e.rowCount-e.positionedCount)*e.rowHeight}wf(e,t){let i=this.e.n,r=i.C.center,o=this.E.read(r.scrollTop),s=this.E.vt;this.E.configure(t,r.clientHeight,!this.Ct);let a=Math.max(0,r.clientWidth-e.left-e.right),l=Math.max(e.center,a);for(let d of w){let c=i.De[d];c.style.height=`${this.E.height}px`,c.style.overflow=this.E.vt?"hidden":"",d==="center"&&(c.style.width=`${l}px`)}(s||this.E.vt)&&this.Vn(o),this.fd(r.scrollTop),this.Ns!==this.E.vt&&(this.Ns=this.E.vt,this.Ns?r.addEventListener("wheel",this.Hs,{passive:!1}):r.removeEventListener("wheel",this.Hs))}Vn(e){let t=this.e.n.C.center;t.scrollTop=this.E.nf(e),this.E.anchor(e,t.scrollTop)}fd(e){let t=this.E.vt;for(let i of["left","right"]){let r=this.e.n.De[i].style;r.top=t?`${-e}px`:"",r.transform=t?"":`translate3d(0, ${-e}px, 0)`}}of(e){let t=this.e.n.C.center,i=this.E.read(t.scrollTop);this.Vn(i+e);let r=this.E.read(t.scrollTop)!==i;return r&&this.vn(),r}zr(e){this.On.delete(e),this.zt.add(e)}bf(e){let{Ge:t,C:i}=this.e.n,{domLayout:r,maxBodyHeight:o}=this.e.t,s=r==="autoHeight",a=Math.min(e,o??e);this.Ct=s&&a===e,t.style.height=s?`${a}px`:"",i.center.style.overflowY=s&&!this.Ct?"auto":"",this.Ct&&i.center.scrollTop&&(i.center.scrollTop=0)}ot(){this.On=new WeakMap,this.zt.clear(),this.Hn=""}vd(e,t){if(e.isDetail)return this.e.t.detailRowHeight;let i=this.On.get(e);if(i!==void 0)return i;let r=this.e.t.rowHeight,o=this.e.t.getRowHeight;if(o)try{let s=o({data:e.data,node:e,api:this.e.api});r=Number.isFinite(s)?Math.max(1,s||r):r}catch(s){this.e.reportError(s,"getRowHeight",{rowId:e.id})}return t.length>0&&(r=Math.max(r,this.Rf(e,t))),this.On.set(e,r),r}Fe(e){let t=this.j.length;return t===0?Math.max(0,e)*this.e.t.rowHeight:e<=t?this.j.qe(e):this.j.ks()+(e-t)*this.e.t.rowHeight}Pn(e,t){if(t<=0)return 0;let i=this.j.length,r=this.j.ks();if(i>0&&e<r)return this.j.findIndex(e);let o=i+Math.floor(Math.max(0,e-r)/this.e.t.rowHeight);return Math.max(0,Math.min(o,t-1))}Cf(){return this.e.r.l().filter(e=>e.colDef.autoHeight===!0)}get Ef(){return this.e.r.l().some(e=>e.colDef.autoHeight===!0)}Tf(){this.Re||(this.Re=p("div","mach-cell mach-cell--wrap",{"aria-hidden":"true"}),this.Re.style.cssText="height:auto;visibility:hidden;pointer-events:none",this.e.n.root.appendChild(this.Re));let e=window.getComputedStyle(this.Re),t=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`,i=[t,e.lineHeight,e.letterSpacing,e.wordSpacing,e.padding,e.boxSizing,this.e.je.ra].join("|");i!==this.md&&(this.md=i,this.ot(),this.Vs=parseFloat(e.letterSpacing)||parseFloat(e.wordSpacing)?"":t,this.gd=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth),this.Re.style.width="10000px",this.Re.textContent="M",this.yd=Math.ceil(this.Re.getBoundingClientRect().height))}Rf(e,t){let i=this.Re,r=0;for(let o of t){let s=he(this.e,e,o);if(!s)continue;let a=this.yd;if(!this.Vs||this.e.je.Qn(s,this.Vs)>o.currentWidth-this.gd){let l=`${o.currentWidth}px`;i.style.width!==l&&(i.style.width=l),i.textContent!==s&&(i.textContent=s),a=Math.ceil(i.getBoundingClientRect().height),s.length>4096&&(i.textContent="")}r=Math.max(r,a)}return r}Rl(e,t){if(this.e.t.flashCells)for(let i of e)for(let r of t)this.cr.push([i,r])}wd(){if(this.cr.length===0)return;let e=this.cr;this.cr=[];for(let[t,i]of e){let r=this.oi(t,i);if(!r)continue;r.classList.remove("mach-cell--flash"),r.offsetWidth,r.classList.add("mach-cell--flash");let o=De(r),s=o.flashTimer;s&&clearTimeout(s),o.flashTimer=window.setTimeout(()=>{r.classList.remove("mach-cell--flash"),o.flashTimer=void 0},800)}}Ie(){this.bn();let e=this.e.n.C.center,i=this.e.t.rowHeight;this.e.t.masterDetail&&(i=Math.min(i,this.e.t.detailRowHeight)),this.Fn>0&&(i=Math.min(i,this.Fn));let r=Math.ceil(e.clientHeight/Math.max(1,i)),o=this.Ct?this.e.i.G():r+this.e.t.rowBuffer*2+1,s=o%2===0?o:o+1;this.Cd(),s>this.m.length&&this.Td(s),this.Bn(),this.lr(!0,!1),this.Bs()}Td(e){for(;this.m.length<e;){let t={index:-1,nodeId:"",kind:"master",rows:{},cells:{}},i=this.e.n;for(let r of w){if(this.e.r.y(r).length===0)continue;let s=p("div","mach-row");s.style.height=`${this.e.t.rowHeight}px`,s.setAttribute("role","row"),s.style.display="none",i.De[r].appendChild(s),t.rows[r]=s,t.cells[r]=this.Wt(r).map(a=>s.appendChild(this.Dd(a)))}if(this.e.t.masterDetail){let r=p("div","mach-row mach-detail-row");r.style.height=`${this.e.t.detailRowHeight}px`,r.setAttribute("role","row"),r.style.display="none",i.De.center.appendChild(r),t.detailRow=r}this.m.push(t)}}Wt(e){return e==="center"?this.kn:this.e.r.y(e)}Dd(e){let t=p("div","mach-cell");if(t.dataset.colId=e.id,t.setAttribute("role","gridcell"),e.hasCheckbox){let i=p("input","mach-row-checkbox");i.type=this.e.t.rowSelection==="single"?"radio":"checkbox",i.type==="radio"&&(i.name=`mach-radio-${this.e.gridId}`),i.setAttribute("aria-label","select row"),t.appendChild(i),t.classList.add("mach-cell--selection")}return t}Sf(e){let t=new Map(this.kn.map((r,o)=>[r.id,o])),i=e.map(r=>{let o=t.get(r.id);return t.delete(r.id),o});for(let r of this.m){let o=r.rows.center,s=r.cells.center;if(!o||!s)continue;for(let l of t.values()){let d=s[l];r.index>=0&&this.e.a.Ho(r.index,d.dataset.colId??"",d),L(this.e,d),d.remove()}let a=o.firstElementChild;r.cells.center=e.map((l,d)=>{let c=i[d],u=c===void 0?this.Dd(l):s[c];return u!==a&&o.insertBefore(u,a),a=u.nextElementSibling,u})}}xd(){this.ur=void 0,this.Rd(),this.pd(!0),this.bt=0,this.Xe=-1}pd(e){this.Ed(0,e),this.An=void 0,this.kn=[]}Ed(e,t){for(let i=e;i<this.m.length;i++){let r=this.m[i];r.detailRow&&this._s(r.detailRow);for(let o of w){for(let s of r.cells[o]??[])!t&&r.index>=0&&this.e.a.Ho(r.index,s.dataset.colId??"",s),L(this.e,s);t&&r.rows[o]?.remove()}t&&r.detailRow?.remove()}this.m.length=e}Bn(){let e=this.Mf();for(let t of w){let i=this.e.r.y(t),r=this.Wt(t),o=this.If(t,r,i);this.Af(t,r,o,e)}this.kf()}Mf(){return this.e.t.masterDetail||this.e.t.getRowHeight!=null||this.Ef}If(e,t,i){if(e==="center"){this.N.update(i);let s=this.e.r.y("left").length;return t.map(a=>this.N.qe(this.e.r.Q(a.id)-s))}let r=0,o=[];for(let s of t)o.push(r),r+=s.currentWidth;return o}Af(e,t,i,r){for(let o of this.m){let s=o.cells[e],a=o.rows[e];if(!s||!a)continue;r||(a.style.height=`${this.e.t.rowHeight}px`);let l=Math.min(t.length,s.length);for(let d=0;d<l;d++){let c=t[d];s[d].style.width=`${c.currentWidth}px`,s[d].style.left=`${i[d]}px`,s[d].setAttribute("aria-colindex",String(this.e.r.Q(c.id)+1))}}}kf(){if(!this.e.t.masterDetail)return;let e=`${this.e.t.detailRowHeight}px`;for(let t of this.m)t.detailRow?.style.setProperty("--mach-detail-h",e)}Cd(){let e=this.e.n.C.center,t=this.e.r.y("center");this.N.update(t);let{first:i,lastExcl:r}=t.length>20?this.N.Ql(e.scrollLeft,e.clientWidth,2):{first:0,lastExcl:t.length};if(t===this.An&&i===this.mt&&r===this.Ot)return!1;let o=t.slice(i,r),s=i>0?t.slice(0,i).filter(a=>a.colDef.colSpan!=null).concat(o):o;return this.m.length>0&&this.Sf(s),this.An=t,this.kn=s,this.mt=i,this.Ot=r,this.Fs=s.some(a=>a.colDef.colSpan!=null),!0}go(){return{first:this.bt,lastExcl:this.Xe}}lr(e=!1,t=!0){let i=this.e.be.start();if(!this.Pf(e,t))return;let r=Math.max(0,this.Xe-this.bt);if(this.m.length>Math.max(32,r*2)){let s=r+r%2+8,a=new Map(this.m.filter(d=>d.index>=0).map(d=>[d.index%s,d])),l=this.m.filter(d=>d.index<0);this.m=Array.from({length:s},(d,c)=>a.get(c)??l.pop()).concat(l),this.Ed(s,!0)}this.wi();let o=this.e.r.y("left").length+this.Wt("center").length+this.e.r.y("right").length;this.e.be.bh(i,r,o)}Pf(e,t){let i=this.e.n.C.center,r=this.E.read(i.scrollTop)-i.scrollTop,o=r!==this.wt;this.wt=r;let s=this.e.i.G(),a=this.e.t.rowBuffer,l=t&&this.Cd();if(l&&this.Bn(),s===0){for(let u of this.m)this.Sd(u);return this.bt=0,this.Xe=0,!0}let{first:d,lastExcl:c}=this.Gf(i,s,a);return!e&&!l&&d===this.bt&&c===this.Xe?(o&&this.Md(),l||o):(this.Lf(d,c),this.bt=d,this.Xe=c,this.Nf(d,c,e,l),l&&this.hr(),o&&this.Md(),!0)}Gf(e,t,i){if(this.Ct)return{first:0,lastExcl:t};let r=this.E.read(e.scrollTop),o=this.Pn(r,t),s=r+e.clientHeight,a=Math.min(t,this.Pn(s,t)+1);return{first:T(o-i,0,t-1),lastExcl:T(a+i,1,t)}}Lf(e,t){if(!(this.Ct&&this.bt===0&&t>=this.Xe))for(let i of this.m)i.index!==-1&&(i.index<e||i.index>=t)&&this.Sd(i)}Nf(e,t,i,r){let o=t-e;o>this.m.length&&(this.Td(o+o%2),this.Bn());for(let s=e;s<t;s++){let a=this.e.i.h(s),l=this.m[s%this.m.length];if(!(!l||!a)){if(!i&&l.index===s&&l.nodeId===a.id){r&&l.kind==="master"&&this._n(l,a,"center");continue}this.Ff(l,s,a)}}}Sd(e){if(this.Id(e),this.Ct&&e.index>=0)for(let t of w)for(let i of e.cells[t]??[])L(this.e,i);this.v?.rowIndex===e.index&&this.e.n.root.removeAttribute("aria-activedescendant"),e.index=-1,e.nodeId="",e.kind="master";for(let t of w){let i=e.rows[t];i&&(i.style.display="none",delete i.dataset.id,delete i.dataset.index,Ce(i,void 0),i.classList.remove("mach-row--drag-source"))}e.detailRow&&(this._s(e.detailRow),e.detailRow.style.display="none")}Ff(e,t,i){e.index>=0&&e.index!==t&&this.Id(e),e.index=t,e.nodeId=i.id;let r=this.Fe(t),o=r-this.wt,s=this.Fe(t+1)-r;if(i.isDetail){this.Of(e,i,t,o,s);return}this.Hf(e,i,t,o,s)}Md(){for(let e of this.m){if(e.index<this.bt||e.index>=this.Xe)continue;let t=`translateY(${this.Fe(e.index)-this.wt}px)`;for(let i of Object.values(e.rows))i.style.transform=t;e.detailRow&&(e.detailRow.style.transform=t)}}Of(e,t,i,r,o){e.kind="detail";for(let a of w){let l=e.rows[a];l&&(l.style.display="none")}let s=e.detailRow;s&&(this.Ad(s,i,r,o),this.zs(s,t))}Hf(e,t,i,r,o){e.kind="master",e.detailRow&&(e.detailRow.style.display="none");let s=this.Vf(t),a=Be(this.e,t);for(let l of w){let d=e.rows[l];d&&(this.Bf(d,t,i,r,o,s),Ce(d,a),this._n(e,t,l))}this.v&&this.v.rowIndex===i&&this.hr()}Vf(e){let t=this.e.i.M,i=e.isGroup===!0,r=t&&this.e.i.bo(e.id),o=i||r||this.e.t.masterDetail&&this.e.i.isRowExpandable(e),s=i?this.e.i.isGroupExpanded(e.id):this.e.i.isRowExpanded(e.id),a=null;return i?a=(e.groupLevel??0)+1:t&&(a=this.e.i._r(e)+1),{expanded:s,expandable:o,level:a}}Bf(e,t,i,r,o,s){this.Ad(e,i,r,o,t.id),this.kd(e,t);let a=this.Mn===i&&!this.e.t.suppressRowHoverHighlight;e.classList.toggle("mach-row--hover",a),e.classList.toggle("mach-row--odd",i%2===1),e.classList.toggle("mach-row--drag-source",this._t.isSource(t)),this._f(e,s)}Ad(e,t,i,r,o){e.style.display="",e.style.transform=`translateY(${i}px)`,e.style.height=`${r}px`,e.dataset.index=String(t),o!==void 0&&(e.dataset.id=o),e.setAttribute("aria-rowindex",String(t+this.e.n._l()+1))}kd(e,t){e.classList.toggle("mach-row--selected",t.selected),e.setAttribute("aria-selected",t.selected?"true":"false")}_f(e,t){t.expandable?e.setAttribute("aria-expanded",t.expanded?"true":"false"):e.removeAttribute("aria-expanded"),t.level!=null?e.setAttribute("aria-level",String(t.level)):e.removeAttribute("aria-level")}_n(e,t,i){let r=this.Wt(i),o=e.cells[i];if(!o)return;let s=e.index,a=this.e.r,l=i==="center"&&this.Fs,d=l?a.y("left").length:0,c=0;e.rows[i]?.classList.toggle("mach-row--editing",this.e.a.sl(s));for(let u=0;u<r.length;u++){let h=r[u],f=o[u];if(l){let m=a.Q(h.id)-d,g=m<c?0:this.zf(t,h,s,this.An.length-m);if(g>0&&(c=m+g),g===0||c<=this.mt){L(this.e,f),f.setAttribute("aria-hidden","true"),f.style.display="none";continue}(g>1||f.hasAttribute("aria-colspan"))&&this.Wf(f,m,g)}f.style.display==="none"&&(f.style.display=""),f.removeAttribute("aria-hidden"),!this.e.a.cl(s,t,h,f)&&(this.Pd(f,t,h),this.Ws(f,s,h))}}zf(e,t,i,r){let o=t.colDef.colSpan;if(!o)return 1;try{let s=o(ue(this.e,e,t,this.e.d(e,t),i));return Math.max(1,Math.min(Math.round(s)||1,r))}catch(s){return this.e.reportError(s,"colSpan",{colId:t.id,rowId:e.id}),1}}Wf(e,t,i){let r=`${this.N.qe(t+i)-this.N.qe(t)}px`;e.style.width!==r&&(e.style.width=r),i>1?e.setAttribute("aria-colspan",String(i)):e.removeAttribute("aria-colspan")}zs(e,t){this._s(e);let i=t.masterId!=null?this.e.i.F(t.masterId):t,r=p("div","mach-detail");e.appendChild(r);let o=this.e.t.detailRowRenderer;if(o){let s={data:t.data,node:i??t,api:this.e.api},a;try{a=o(s)}catch(l){this.e.reportError(l,"detailRowRenderer",{rowId:t.id}),a=null}typeof a=="string"?r.textContent=a:a instanceof HTMLElement?r.appendChild(a):a&&typeof a=="object"&&a.el instanceof HTMLElement&&(r.appendChild(a.el),Ue(e,a.destroy))}}_s(e){let t=je(e);if(t)try{t()}catch(i){this.e.reportError(i,"detailRowRenderer.destroy")}e.textContent=""}Pd(e,t,i){if(t.loading){L(this.e,e),e.className="mach-cell mach-cell--loading",e.setAttribute("aria-readonly","true"),e.setAttribute("aria-busy","true");let o=p("span","mach-cell-loading-bar");o.style.width=`${34+(i.id.length*13+t.rowIndex*7)%44}%`,e.replaceChildren(o),this.$t(e);return}e.removeAttribute("aria-busy"),e.setAttribute("aria-readonly",this.e.a.oe(t,i)?"false":"true"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-level");let r=this.$f(t,i);if(r!=="standard"){L(this.e,e),this.Kf(r,e,t,i);return}Ye(this.e,e,t,i),this.Gd(e,t,i),this.Uf(e,t,i)}$f(e,t){return e.isGroup?"group":t.isDetailToggle?"detail":t.hasCheckbox?"checkbox":t.colDef.rowDrag?"drag":Ie(t.colDef,"index")?"index":this.e.i.M&&this.Ld()?.id===t.id?"tree":"standard"}Kf(e,t,i,r){if(e==="group")this.jf(t,i,r);else if(e==="detail"){let o=this.e.i.isRowExpanded(i.id),s=p("span",`mach-detail-toggle${o?" mach-detail-toggle--open":""}`);s.textContent="\u25B6",t.replaceChildren(s),t.classList.add("mach-cell--detail-toggle"),this.$t(t)}else if(e==="checkbox"){let o=t.querySelector(".mach-row-checkbox");o&&(o.checked=i.selected,o.indeterminate=this.e.f.cu(i.id),o.disabled=!this.e.f.We(i)),t.className!=="mach-cell mach-cell--selection"&&(t.className="mach-cell mach-cell--selection"),this.$t(t)}else if(e==="drag")this.qf(t,i),t.className!=="mach-cell mach-cell--drag"&&(t.className="mach-cell mach-cell--drag"),this.$t(t);else if(e==="index"){t.textContent=String(this.e.i._a(i)+this.e.t.indexOffset);let o=`mach-cell mach-cell--index ${qe(r)}`;t.className!==o&&(t.className=o),this.Gd(t,i,r)}else this.Yf(t,i,r)}Uf(e,t,i){if(this.e.t.editType!=="cell"||this.e.t.editableIndicator==="none"||!this.e.a.oe(t,i))return;let r=p("button",`mach-cell-edit-trigger mach-cell-edit-trigger--${this.e.t.editableIndicator}`);r.type="button",r.tabIndex=-1,r.title="Edit cell",r.setAttribute("aria-label","Edit cell"),r.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10.8 2.7 2.5 2.5L5.5 13H3v-2.5z"/><path d="m9.5 4 2.5 2.5"/></svg>',r.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation()}),r.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.Ae(t.rowIndex,i.id),this.e.a.start(t.rowIndex,i)}),e.appendChild(r)}Id(e){if(!(e.index<0))for(let t of w)for(let i of e.cells[t]??[])this.e.a.Ho(e.index,i.dataset.colId??"",i)}Ld(){return this.ur!==void 0?this.ur:(this.ur=this.e.r.l().find(e=>!e.hasCheckbox&&!e.isDetailToggle&&!e.colDef.rowDrag&&!Ie(e.colDef,"index"))??null,this.ur)}Yf(e,t,i){let r=this.e.i.isRowExpandable(t),o=this.e.i._r(t),s=j(this.e,t,i,this.e.d(t,i)),a=p("span","mach-tree-indent");a.style.width=`${o*16}px`;let l=p("span","mach-tree-cell");if(o>0&&l.appendChild(a),r){let c=this.e.i.isRowExpanded(t.id);e.setAttribute("aria-expanded",c?"true":"false"),e.setAttribute("aria-level",String(o+1));let u=t.treeLoading?" mach-detail-toggle--loading":t.treeLoadError?" mach-detail-toggle--error":"",h=p("button","mach-tree-toggle");h.type="button",h.tabIndex=-1,h.setAttribute("aria-label",t.treeLoadError?"Retry loading children":c?"Collapse row":"Expand row"),h.setAttribute("aria-expanded",String(c)),t.treeLoadError&&(h.title="Retry loading children");let f=p("span",`mach-detail-toggle${c?" mach-detail-toggle--open":""}${u}`);f.setAttribute("aria-hidden","true"),f.textContent="\u25B6",h.appendChild(f),h.addEventListener("keydown",m=>{(m.key==="Enter"||m.key===" ")&&m.stopPropagation()}),l.appendChild(h)}else{let c=p("span","mach-tree-toggle-spacer");l.appendChild(c)}let d=p("span","mach-tree-text");d.textContent=s,l.appendChild(d),e.replaceChildren(l),s&&!this.e.t.tooltipComponent?e.title=s:e.removeAttribute("title"),Qt(this.e,e,t,i)}$t(e){e.style.height!==""&&(e.style.height=""),e.style.zIndex!==""&&(e.style.zIndex=""),e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-rowspan")}Gd(e,t,i){let r=this.e.i.tu(i.id);if(!r||t.isDetail){this.$t(e);return}let o=this.e.i._a(t)-1;if(o<0||o>=r.length){this.$t(e);return}let s=r[o];if(s===-1){e.style.display="none",e.setAttribute("aria-hidden","true");return}if(e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-hidden"),s>1){let a=Math.min(o+s,this.e.i.G()),l=this.Fe(a)-this.Fe(o);e.style.height=`${l>0?l:s*this.e.t.rowHeight}px`,e.style.zIndex="1",e.setAttribute("aria-rowspan",String(s))}else this.$t(e)}jf(e,t,i){if(i.hasCheckbox){this.Xf(e,t);return}if(i.isDetailToggle){this.Nd(e);return}let r=this.e.r.sa();if(r&&i.id===r.id){this.Jf(e,t);return}this.Zf(e,t,i)||this.Nd(e)}Xf(e,t){let i=e.querySelector(".mach-row-checkbox");if(i){let r=this.e.f.ja(t);i.checked=r.all,i.indeterminate=r.some&&!r.all}e.className!=="mach-cell mach-cell--selection"&&(e.className="mach-cell mach-cell--selection")}Jf(e,t){let i=this.e.i.isGroupExpanded(t.id),r=t.groupLevel??0;e.setAttribute("aria-expanded",i?"true":"false"),e.setAttribute("aria-level",String(r+1));let o=p("span","mach-group-label");o.style.paddingLeft=`${r*16}px`;let s=p("span",`mach-detail-toggle${i?" mach-detail-toggle--open":""}`);s.textContent="\u25B6";let a=p("span","mach-group-text"),l=this.e.r.Je()[r],d=l?.colDef.headerName?`${l.colDef.headerName}: `:"";a.textContent=`${d}${t.groupKey??""}`;let c=p("span","mach-group-count");c.textContent=`(${t.leafNodes?.length??0})`,o.append(s,a,c),e.replaceChildren(o),e.className!=="mach-cell mach-cell--group"&&(e.className="mach-cell mach-cell--group")}Zf(e,t,i){if(!i.colDef.aggFunc||!t.aggValues||!v(t.aggValues,i.id))return!1;let r=t.aggValues[i.id];e.textContent=i.colDef.valueFormatter!=null?j(this.e,t,i,r):Zt(r);let o=`mach-cell ${qe(i)}`;return e.className!==o&&(e.className=o),!0}Nd(e){e.textContent="",e.className!=="mach-cell"&&(e.className="mach-cell")}I(e){if(this.e.o())return;let t=new Set;for(let i of e){if(i<0||t.has(i))continue;t.add(i);let r=this.m[i%this.m.length];if(!r||r.index!==i)continue;let o=this.e.i.h(i);if(o){if(r.kind==="detail"){r.detailRow&&this.zs(r.detailRow,o);continue}for(let s of w){let a=r.rows[s];a&&this.kd(a,o),r.cells[s]&&this._n(r,o,s)}}}this.hr(),this.wd()}refreshCells(e={}){if(this.e.o())return;let t=e.rowIds==null?null:new Set(e.rowIds),i=e.rowIndexes==null?null:new Set(e.rowIndexes),r=e.columns==null?null:new Set(e.columns);for(let o of this.m){let s=this.e.i.h(o.index);!s||!this.Qf(o,s,t,i)||this.em(o,s,r,e.force===!0)}this.hr(),this.wd()}Qf(e,t,i,r){return e.index<0?!1:i==null&&r==null?!0:i?.has(t.id)===!0||r?.has(e.index)===!0}em(e,t,i,r){if(e.kind==="detail"){i==null&&e.detailRow&&this.zs(e.detailRow,t);return}let o=i==null||this.Fs,s=Be(this.e,t);for(let a of w){let l=e.rows[a];l&&Ce(l,s),o?this._n(e,t,a):this.tm(e,t,a,i,r)}}tm(e,t,i,r,o){let s=this.Wt(i),a=e.cells[i];if(a)for(let l=0;l<s.length;l++){let d=s[l];if(!r.has(d.id))continue;let c=a[l];c&&(this.e.a.cl(e.index,t,d,c)||(o&&L(this.e,c),this.Pd(c,t,d),this.Ws(c,e.index,d)))}}im(){this.e.o()||(this.v&&this.v.rowIndex>=this.e.i.G()&&this.Ae(null,null),this.Rd(),this.bn(),this.lr(!0),this.Bs(),this.e.Pe.refresh())}Bs(){let e=this.e.t,t=e.loading?"loading":e.error!=null?"error":this.e.i.G()===0&&!e.suppressNoRowsOverlay?"noRows":null;Gt(this.e,t)}oi(e,t){let i=this.e.r.R(t);if(!i)return null;let r=this.pf(i),o=this.Wt(r).indexOf(i);if(o<0)return null;let s=this.m[e%this.m.length];return!s||s.index!==e||s.kind!=="master"?null:s.cells[r]?.[o]??null}Rd(){this.he.Xt()}Ce(){let e=this.e.i.G(),t=this.e.r.l().length;return this.he.normalize(e,t)}ai(){let e=this.Ce();if(e)return e;let t=this.v;if(t){let i=this.e.r.Q(t.colId);if(i>=0)return{r1:t.rowIndex,c1:i,r2:t.rowIndex,c2:i}}return null}nr(){let e=this.Ce();if(!e)return null;let t=this.e.r.l();return{row1:e.r1,row2:e.r2,colId1:t[e.c1]?.id??"",colId2:t[e.c2]?.id??""}}Fo(){let e=this.he.qp();if(e)return{row:e.row,colIdx:e.colIdx};let t=this.ai();return t?{row:t.r1,colIdx:t.c1}:null}li(){let e=this.Ce();this.he.clear(),e&&(this.zn(),this.wi(),this.e.emit("rangeSelectionChanged",{range:null}))}zn(){for(let e of this.m)if(!(e.index<0||e.kind!=="master"))for(let t of w){let i=this.Wt(t);e.cells[t]?.forEach((r,o)=>{let s=i[o];s&&this.Ws(r,e.index,s)})}}$s(e,t,i){this.he.start({row:e,colIdx:t},i),this.zn(),this.wi(),this.e.emit("rangeSelectionChanged",{range:this.nr()})}Fu(e,t){if(!this.he.Yp()){let a=this.v;if(!a)return;let l=this.e.r.Q(a.colId);if(!this.he.Xp({row:a.rowIndex,colIdx:l}))return}let i=this.e.i.G(),r=this.e.r.l().length;this.he.setEnd({row:Math.max(0,Math.min(e,i-1)),colIdx:Math.max(0,Math.min(t,r-1))}),this.zn(),this.wi();let o=this.e.r.l(),s=this.he.Rs();s&&s.colIdx<o.length&&this.Ae(s.row,o[s.colIdx].id),this.e.emit("rangeSelectionChanged",{range:this.nr()})}Ws(e,t,i){let r=this.Ce();if(!r){e.classList.contains("mach-cell--range")&&e.classList.remove("mach-cell--range","mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right");return}let o=this.e.r.Q(i.id);if(o<0)return;let s=t>=r.r1&&t<=r.r2&&o>=r.c1&&o<=r.c2;e.classList.toggle("mach-cell--range",s),s?(e.classList.toggle("mach-cell--range-top",t===r.r1),e.classList.toggle("mach-cell--range-bottom",t===r.r2),e.classList.toggle("mach-cell--range-left",o===r.c1),e.classList.toggle("mach-cell--range-right",o===r.c2)):e.classList.remove("mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right")}rm(){if(this.Ln)return this.Ln;let e=p("div","mach-fill-handle");return e.style.display="none",e.addEventListener("pointerdown",t=>{this.Ks=!0,this.Fd(t)}),e.addEventListener("mousedown",t=>{this.Ks||this.Fd(t)}),this.e.n.De.center.appendChild(e),this.Ln=e,e}wi(){let e=this.rm(),t=this.Ce();if(!this.e.t.enableRangeSelection||!this.e.t.fillHandle||!t){e.style.display="none";return}let i=this.e.r,r=i.y("left").length,o=i.y("center");if(t.c2<r||t.c2>=r+o.length){e.style.display="none";return}let s=t.c2-r;this.N.update(o);let a=this.N.qe(s+1),l=this.Fe(Math.min(t.r2+1,this.e.i.G()))-this.wt,d=this.e.n.C.center;if(this.E.vt&&(l<d.scrollTop||l>d.scrollTop+d.clientHeight)){e.style.display="none";return}e.style.display="",e.style.left=`${this.E.vt?Math.min(a-4,parseFloat(this.e.n.De.center.style.width)-8):a-4}px`,e.style.top=`${Math.min(l-4,this.E.height-8)}px`}Fd(e){if(this.e.o()||e.button!==0)return;let t=this.Ce();t&&(e.preventDefault(),e.stopPropagation(),this.pr={r1:t.r1,r2:t.r2,c1:t.c1,c2:t.c2,startX:e.clientX,startY:e.clientY,axis:null,active:!1},this.Od(!0))}Hd(e){let i=this.e.n.De.center.getBoundingClientRect(),r=e.clientY-i.top+this.wt,o=this.e.i.G(),s=this.Pn(r,o);return Math.max(this.pr.r2,Math.min(s,o-1))}Vd(e){let i=this.e.n.De.center.getBoundingClientRect(),r=e.clientX-i.left,o=this.e.r,s=o.y("left").length,a=o.y("center");this.N.update(a);let l=this.N.kp(r);if(l<0)return s;let d=this.N.qe(l)+a[l].currentWidth/2;return r<d?s+l:l+1<a.length?s+l+1:s+a.length-1}Od(e){let t=e?"addEventListener":"removeEventListener";for(let i of["pointermove","mousemove"])window[t](i,this.nm);for(let i of["pointerup","mouseup","pointercancel"])window[t](i,this.om)}Gn(){this.pr=null,this.Ks=!1,this.Od(!1),this.e.n.root.classList.remove("mach-root--filling")}Bd(e,t,i){let r=this.he.Rs();!r||t===(e?r.colIdx:r.row)||(this.he.setEnd(e?{row:r.row,colIdx:t}:{row:t,colIdx:r.colIdx}),this.zn(),i&&(e&&this.wi(),this.e.emit("rangeSelectionChanged",{range:this.nr()})))}sm({r1:e,r2:t,c1:i,c2:r},o,s){let a=this.e.r.l(),l=[],d=s?i:e,c=s?r:t,u=s?t:r;for(let h=s?e:i;h<=u;h++){let f=s?this.e.i.h(h):void 0,m=s?void 0:a[h];(s?!f||f.isDetail||f.isGroup:!kn(m))||this.am(a,d,c,o,l,f,m)}this.e.pi(l),this.e.emit("rangeSelectionChanged",{range:this.nr()})}am(e,t,i,r,o,s,a){let l=[];for(let c=t;c<=i;c++){let u=s??this.e.i.h(c),h=a??e[c];l.push(u&&h?this.e.d(u,h):void 0)}if(a&&l.length===1&&l[0]===void 0)return;let d=Js(l);for(let c=i+1;c<=r;c++){let u=s??this.e.i.h(c),h=a??e[c];if(!u||!kn(h)||!this.e.a.oe(u,h))continue;let f=Zs(d,c-t),m=this.e.d(u,h);o.push({node:u,column:h,oldValue:m,newValue:f})}}Ae(e,t){if(this.lm(),e==null||t==null){this.v=null;return}this.v={rowIndex:e,colId:t},this.hr(),this.dm()}hr(){if(!this.v)return;let e=this.oi(this.v.rowIndex,this.v.colId);if(e&&e.style.display!=="none"){let t=Math.max(0,this.e.r.Q(this.v.colId));e.id=`mach-grid-${this.e.gridId}-r${this.v.rowIndex}-c${t}`,e.classList.add("mach-cell--focus"),this.e.n.root.setAttribute("aria-activedescendant",e.id)}else this.e.n.root.removeAttribute("aria-activedescendant")}lm(){if(this.v){let e=this.oi(this.v.rowIndex,this.v.colId);e&&(e.classList.remove("mach-cell--focus"),e.removeAttribute("id"))}this.e.n.root.removeAttribute("aria-activedescendant")}dm(){if(!this.v)return;this.Wr(this.v.rowIndex,"nearest");let e=this.e.r.R(this.v.colId);!e||e.pinned||this.N.Tn(this.e.n.C.center,this.e.r.y("center"),e)}Wr(e,t="top"){let i=this.e.n.C.center,r=this.e.i.G();if(r===0)return;let o=T(e,0,r-1),s=i.clientHeight,a=this.E.read(i.scrollTop),l=this.Fe(o),d=this.Fe(o+1),c=a;t==="top"?c=l:t==="bottom"?c=d-s:t==="middle"?c=l-(s-(d-l))/2:l<a?c=l:d>a+s&&(c=d-s);let u=Math.max(0,this.Fe(r)-s);this.Vn(T(c,0,u)),this.vn()}_d(e){if(this.Mn===e)return;let t=this.Mn;this.Mn=e,this.zd(t,!1),this.zd(e,!0)}zd(e,t){if(e<0)return;let i=this.m[e%this.m.length];if(!(!i||i.index!==e||i.kind!=="master"))for(let r of w)i.rows[r]?.classList.toggle("mach-row--hover",t)}fr(){this.e.n.root.focus({preventScroll:!0})}Kt(e){let t=e.target,i=t.closest(".mach-row");if(!i)return null;let r=Number(i.dataset.index);if(Number.isNaN(r))return null;let o=this.e.i.h(r);if(!o)return null;let s=t.closest(".mach-cell");return{node:o,index:r,cellEl:s}}Wd(e,t,i){let{node:r,index:o,cellEl:s}=i;if(this.cm(t,r,s)||this.um(t,r,s))return;let a=s?.dataset.colId??"",l=a?this.e.r.R(a):void 0;this.hm(r,l)||r.isDetail||this.pm(t,r,o,e)||!s||!l||(this.fr(),this.e.t.suppressCellFocus||this.Ae(o,a),this.e.f.Ya(r,e,!1),this.fm(e,r,o,l),this.mm(r,o,l))}cm(e,t,i){if(!t.isGroup)return!1;if(this.fr(),e.closest(".mach-row-checkbox")){let o=this.e.f.ja(t).all;return this.e.f.hu(t,!o),!0}let r=this.e.r.sa();return(!r||!i||i.dataset.colId===r.id)&&this.e.i.xo(t.id),!0}hm(e,t){return!t?.isDetailToggle||e.isDetail?!1:(this.fr(),this.e.$r(e.id),!0)}pm(e,t,i,r){let o=e.closest(".mach-cell--selection");return o?(this.fr(),this.e.t.suppressCellFocus||this.Ae(i,o.dataset.colId??""),this.li(),this.e.f.Ya(t,r,!0),!0):!1}fm(e,t,i,r){let o=this.e.d(t,r),s=this.e.emit("cellClicked",{event:e,rowNode:t,rowIndex:i,column:r,colDef:r.colDef,value:o});r.colDef.onCellClick?.(s),this.e.emit("rowClicked",{event:e,rowNode:t,rowIndex:i})}mm(e,t,i){(this.e.t.singleClickEdit||i.colDef.singleClickEdit===!0)&&this.e.a.oe(e,i)&&this.e.a.start(t,i)}um(e,t,i){if(!this.e.i.M||!e.closest(".mach-tree-toggle"))return!1;let r=this.Ld();return!r||i?.dataset.colId!==r.id||!this.e.i.isRowExpandable(t)?!1:(this.fr(),t.treeLoadError?this.e.i.loadTreeChildren(t.id,!0).catch(()=>{}):this.e.i.$r(t.id),!0)}gm(e){return!!(e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-tree-toggle, .mach-row-drag-handle")||this.e.a.Yr())}qf(e,t){let i=e.querySelector("button.mach-row-drag-handle"),r=i?.value===t.id?i:p("button","mach-row-drag-handle");r.type="button",r.value=t.id;let o=this._t.ld(t);r.disabled=o!==!0;let s=this.e.c("rowDragHandle");r.setAttribute("aria-label",s),r.title=typeof o=="string"?o:r.disabled?this.e.c("rowDragUnavailable"):s,r.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown"),r!==i&&e.replaceChildren(r)}};var zt=class{constructor(e){this.e=e;this.Oe=null;this.$d={left:void 0,center:void 0,right:void 0};this.js={left:[],center:[],right:[]}}init(){this.Oe=p("div","mach-footer"),this.Oe.style.display="none",this.Oe.setAttribute("role","row"),this.e.n.root.appendChild(this.Oe);for(let e of w){let t=p("div",`mach-footer-row mach-footer-row--${e}`);t.style.height=`${this.e.t.rowHeight}px`,this.Oe.appendChild(t),this.$d[e]=t}}setVisible(e){this.Oe&&(this.Oe.style.display=e?"":"none")}refresh(){if(!this.Oe||this.e.o())return;let e=this.e.t.showSummary;if(this.setVisible(e),!e)return;let t=this.e.t.summaryMethod,i=this.e.i.It().filter(r=>!r.isDetail&&!r.isGroup);for(let r of w){let o=this.e.r.y(r),s=this.$d[r];this.js[r].length!==o.length&&(s.textContent="",this.js[r]=o.map(()=>{let l=p("div","mach-footer-cell");return l.setAttribute("role","cell"),s.appendChild(l),l}));let a=0;o.forEach((l,d)=>{let c=this.js[r][d];if(c.style.left=`${a}px`,c.style.width=`${l.currentWidth}px`,a+=l.currentWidth,l.hasCheckbox||l.isDetailToggle||l.colDef.rowDrag){c.textContent="";return}if(t)try{c.textContent=t({colId:l.id,column:l,values:i.map(u=>this.e.d(u,l))})}catch(u){this.e.reportError(u,"summaryMethod",{colId:l.id}),c.textContent=""}else d===0&&r==="left"?c.textContent=U(this.e.c("totalRowsLabel"),i.length):c.textContent=""})}}destroy(){this.Oe?.remove(),this.Oe=null}};var Wt=class{constructor(e){this.e=e;this.w=null;this.Wn=null;this.qs=null;this.Ci=null;this.Ut=null;this.$n=null;this.Kn=null;this.Un=null;this.jn=null;this.jt=[]}init(){this.w=p("div","mach-pagination"),this.w.style.display="none",this.w.setAttribute("role","navigation");let e=(t,i,r,o)=>{let s=$(`mach-pagination-btn ${t}`,r,o);return s.title=i,s.setAttribute("aria-label",i),s};this.Wn=p("span","mach-pagination-total"),this.$n=e("mach-pagination-first",this.e.c("pageFirst"),"\xAB",()=>this.e.i.setPage(1)),this.Kn=e("mach-pagination-prev",this.e.c("pagePrev"),"\u2039",()=>this.e.i.setPage(this.e.i.Qt()-1)),this.qs=p("span","mach-pagination-page"),this.Un=e("mach-pagination-next",this.e.c("pageNext"),"\u203A",()=>this.e.i.setPage(this.e.i.Qt()+1)),this.jn=e("mach-pagination-last",this.e.c("pageLast"),"\xBB",()=>this.e.i.setPage(this.e.i.getPageCount())),this.w.append(this.Wn,this.$n,this.Kn,this.qs,this.Un,this.jn),this.e.t.paginationShowSizeSelector&&(this.Ut=re({ariaLabel:"page size",options:[],classNames:{root:"mach-pagination-size-control",native:"mach-pagination-size"},themeSource:this.e.n.root,onChange:t=>{let i=Number(t);Number.isNaN(i)||this.e.i.setPageSize(i)}}),this.Ci=this.Ut.native,this.Kd(),this.w.appendChild(this.Ut.el)),this.e.n.root.appendChild(this.w),this.jt.push(this.e.de.on("modelUpdated",()=>this.refresh()),this.e.de.on("paginationChanged",()=>this.refresh())),this.refresh()}Kd(){if(!this.Ci)return;let e=this.e.t.paginationPageSizeOptions,t=this.e.t.paginationPageSize;e.includes(t)||(e.push(t),e.sort((i,r)=>i-r)),this.Ut?.setOptions(e.map(i=>({value:String(i),label:U(this.e.c("perPage"),i)})),String(t))}xe(){this.w&&(this.Ci&&this.e.t.paginationShowSizeSelector&&this.Kd(),this.refresh())}Ud(e,t){e&&e.textContent!==t&&(e.textContent=t)}ym(e,t){let i=e<=1,r=e>=t;this.$n&&(this.$n.disabled=i),this.Kn&&(this.Kn.disabled=i),this.Un&&(this.Un.disabled=r),this.jn&&(this.jn.disabled=r)}refresh(){if(!this.w||this.e.o())return;let e=this.e.i,t=e.we,i=e.getTotalRowCount(),r=t&&i>0;if(this.w.style.display=r?"":"none",!r)return;let o=e.Qt(),s=e.getPageCount();this.Wn&&this.e.t.paginationShowTotal&&this.Ud(this.Wn,U(this.e.c("paginationTotal"),i)),this.Ud(this.qs,ke(this.e.c("paginationPage"),o,s)),this.ym(o,s),this.Ci&&Number(this.Ci.value)!==this.e.t.paginationPageSize&&this.Ut?.setValue(String(this.e.t.paginationPageSize))}destroy(){for(let e of this.jt)e();this.jt=[],this.Ut?.destroy(),this.Ut=null,this.Ci=null,this.w?.remove(),this.w=null}};var $t=class{constructor(e){this.e=e;this.top=null;this.bottom=null}init(){this.top=this.jd(this.e.n.hn),this.bottom=this.jd(this.e.n.pn)}jd(e){let t={root:e,segments:{left:p("div"),center:p("div"),right:p("div")},centerViewport:p("div","mach-pinned-viewport"),rowWrappers:{left:[],center:[],right:[]},cells:[],data:[]};for(let i of w)t.segments[i].className=`mach-pinned-seg mach-pinned-seg--${i}`,i!=="center"&&t.segments[i].classList.add("mach-pane--hidden"),i==="center"&&t.centerViewport.appendChild(t.segments[i]);return e.append(t.segments.left,t.centerViewport,t.segments.right),t}setData(e,t){this.e.o()||!this.top||!this.bottom||(this.top.data=e??[],this.bottom.data=t??[],this.refresh(),this.e.Ie())}setRows(e,t){let i=this[e];this.e.o()||!i||(i.data=t??[],this.Ys(i,e),this.gt(),this.e.Ie())}getRows(e){return this[e]?.data.slice()??[]}xe(){!this.top||!this.bottom||(this.Ys(this.top,"top"),this.Ys(this.bottom,"bottom"))}Ys(e,t){this.mi(e);for(let o of w){for(let s of e.rowWrappers[o])s.remove();e.rowWrappers[o]=[]}if(e.root.style.display=e.data.length>0?"":"none",e.data.length===0)return;let i=this.e.t.rowHeight,r=this.e.r;e.data.forEach((o,s)=>{let a={id:`__pinned_${t}_${s}`,data:o,rowIndex:-1,selected:!1},l={},d=Be(this.e,a,t);for(let c of w){let u=p("div","mach-pinned-row");Ce(u,d),u.style.height=`${i}px`,u.setAttribute("role","row"),l[c]=[];for(let h of r.y(c)){let f=p("div","mach-cell");if(f.dataset.colId=h.id,f.setAttribute("role","gridcell"),h.hasCheckbox&&f.classList.add("mach-cell--selection"),!h.hasCheckbox&&!h.isDetailToggle&&!h.colDef.rowDrag&&h.colDef.type!=="index")try{Ye(this.e,f,a,h)}catch(m){this.e.reportError(m,"pinnedRow.render",{colId:h.id,side:t,rowIndex:s})}u.appendChild(f),l[c].push(f)}e.segments[c].appendChild(u),e.rowWrappers[c].push(u)}e.cells.push(l)})}gt(){if(!this.top||!this.bottom)return;let e=this.e.r,t={left:0,center:0,right:0},i={left:[],center:[],right:[]};for(let r of w){let o=0;for(let s of e.y(r))i[r].push(o),o+=s.currentWidth;t[r]=o}for(let r of[this.top,this.bottom]){let o=r.data.length===0;r.segments.left.classList.toggle("mach-pane--hidden",o||t.left<=0),r.segments.right.classList.toggle("mach-pane--hidden",o||t.right<=0),r.segments.left.style.width=`${t.left}px`,r.segments.right.style.width=`${t.right}px`,r.segments.center.style.width=`${t.center}px`,r.cells.forEach(s=>{let a=0;for(let l of w){let d=e.y(l);s[l].forEach((c,u)=>{c.style.width=`${d[u].currentWidth}px`,c.style.left=`${i[l][u]}px`,c.setAttribute("aria-colindex",String(a+u+1))}),a+=d.length}})}}ff(e){this.top&&(this.top.segments.center.style.transform=`translateX(${-e}px)`),this.bottom&&(this.bottom.segments.center.style.transform=`translateX(${-e}px)`)}refresh(){this.xe(),this.gt()}destroy(){this.top&&this.mi(this.top),this.bottom&&this.mi(this.bottom),this.top=null,this.bottom=null}mi(e){for(let t of e.cells)for(let i of w)for(let r of t[i])L(this.e,r);e.cells=[]}};var Kt=class{constructor(e){this.e=e;this.w=null;this.Ti={};this.jt=[]}init(){this.w=p("div","mach-statusbar"),this.w.style.display="none",this.w.setAttribute("role","status"),this.e.n.root.appendChild(this.w),this.xe(),this.jt.push(this.e.de.on("modelUpdated",()=>this.refresh()),this.e.de.on("selectionChanged",()=>this.refresh()),this.e.de.on("rangeSelectionChanged",()=>this.refresh()),this.e.de.on("cellValueChanged",()=>this.refresh()))}xe(){if(!this.w)return;this.w.textContent="",this.Ti={};let e=this.e.t;if(!e.statusBarEnabled){this.w.style.display="none";return}for(let t of e.statusBarPanels){let i=p("span",`mach-statusbar-item mach-statusbar-item--${t}`);this.w.appendChild(i),this.Ti[t]=i}this.refresh()}Xs(e,t){return U(this.e.c(e),t||0)}Js(e,t){let i=this.Ti[e];i&&i.textContent!==t&&(i.textContent=t)}vm(){let e=this.e.i,t=e.Gi(),i=e.we?e.getTotalRowCount():e.G(),r=U(this.e.c("totalRowsLabel"),i);return e.g&&t>i?`${r} / ${t}`:r}bm(){let e=this.e.s.Ce();if(!e)return"";let t=this.e.r.l(),i=0,r=0;for(let a=e.r1;a<=e.r2;a++){let l=this.e.i.h(a);if(!(!l||l.isDetail||l.isGroup))for(let d=e.c1;d<=e.c2;d++){let c=t[d];if(!c)continue;let u=this.e.d(l,c);typeof u!="number"||Number.isNaN(u)||(i+=u,r++)}}if(r===0)return"";let o=Math.round(i/r*100)/100,s=Number.isInteger(i)?i:Math.round(i*100)/100;return`${this.Xs("statusSum",s)} \xB7 ${this.Xs("statusAvg",o)} \xB7 ${this.Xs("statusCount",r)}`}refresh(){if(!this.w||this.e.o())return;let e=this.e.t;if(this.w.style.display=e.statusBarEnabled?"":"none",!!e.statusBarEnabled){if(this.Ti.rowCount&&this.Js("rowCount",this.vm()),this.Ti.selectedRowCount){let t=this.e.f.ei().length;this.Js("selectedRowCount",U(this.e.c("statusSelected"),t))}this.Ti.rangeAggregate&&this.Js("rangeAggregate",this.bm())}}destroy(){for(let e of this.jt)e();this.jt=[],this.w?.remove(),this.w=null}};function Ui(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Pn(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function Gn(n={}){let e=(n.namespace??"mach-table:grid-state").replace(/:+$/,""),t=Math.max(1024,Math.floor(n.maxBytes??512*1024)),i=o=>`${e}:${o}`,r=(o,s,a)=>{try{n.onError?.(o,s,a)}catch{}};return{storageKey:i,load(o){try{let s=(n.storage??Ui())?.getItem(i(o));if(!s)return null;if(Pn(s)>t)throw new RangeError(`[MachTable] Stored grid state for "${o}" exceeds ${t} bytes.`);let a=JSON.parse(s);if(a?.schemaVersion!==2)throw new TypeError(`[MachTable] Stored grid state for "${o}" uses an unsupported schema.`);let l=X(a.state);if(!l)throw new TypeError(`[MachTable] Stored grid state for "${o}" is invalid.`);return l}catch(s){return r(s,"load",o),null}},save(o,s){try{let a=X(s);if(!a)throw new TypeError(`[MachTable] Invalid grid state for "${o}".`);let l=JSON.stringify({schemaVersion:2,savedAt:Date.now(),state:a});if(Pn(l)>t)throw new RangeError(`[MachTable] Grid state for "${o}" exceeds ${t} bytes.`);(n.storage??Ui())?.setItem(i(o),l)}catch(a){r(a,"save",o)}},clear(o){try{(n.storage??Ui())?.removeItem(i(o))}catch(s){r(s,"clear",o)}}}}var ji=Gn();function qi(n,e){ji.save(n,e)}function Yi(n){return ji.load(n)}function Qs(n){ji.clear(n)}var _e=class{constructor(e){this.onError=e;this.qn=new Set;this.disposed=!1}add(e){let t=!0,i=()=>{if(t){t=!1,this.qn.delete(i);try{e()}catch(r){try{this.onError(r)}catch{}}}};return this.disposed?i():this.qn.add(i),i}A(e){return this.add(()=>e.destroy()),e}dispose(){if(this.disposed)return;this.disposed=!0;let e=[...this.qn].reverse();this.qn.clear();for(let t of e)t()}};function ea(n){return!!(n.field||n.valueGetter||n.cellRenderer||n.checkboxSelection||n.rowDrag||n.type||n.autoRowSpan||n.rowSpan)}function ta(n,e,t){n.width!=null&&n.minWidth!=null&&n.width<n.minWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5C0F\u4E8E minWidth(${n.minWidth})\uFF0C\u5C06\u6309 minWidth \u6E32\u67D3`),n.width!=null&&n.maxWidth!=null&&n.width>n.maxWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5927\u4E8E maxWidth(${n.maxWidth})\uFF0C\u5C06\u6309 maxWidth \u6E32\u67D3`)}function ia(n,e){let t=n.colId??n.field??`col_${e.leafIndex}`;e.seenIds.set(t,(e.seenIds.get(t)??0)+1),n.field&&!ti(n.field)&&e.issues.push(`\u5217 "${t}" \u7684 field \u8DEF\u5F84\u4E0D\u5B89\u5168\u6216\u65E0\u6548\uFF0C\u5DF2\u7981\u6B62\u8BFB\u53D6\u548C\u5199\u5165`),ea(n)||e.issues.push(`\u5217 "${t}" \u65E2\u65E0 field \u4E5F\u65E0 valueGetter\uFF0C\u5C06\u59CB\u7EC8\u663E\u793A\u7A7A\u503C\uFF08\u7EAF\u5DE5\u5177\u5217\u8BF7\u5FFD\u7565\u6B64\u63D0\u793A\uFF09`),ta(n,t,e.issues)}function Ln(n,e){for(let t of n){if(Ae(t)){!Array.isArray(t.children)||t.children.length===0?e.issues.push(`\u5217\u5206\u7EC4 "${t.headerName??t.groupId??"?"}" \u7684 children \u4E3A\u7A7A`):Ln(t.children,e);continue}e.leafIndex++,ia(t,e)}}function Nn(n){if(!n||n.length===0)return[];let e={issues:[],seenIds:new Map,leafIndex:0};Ln(n,e);for(let[t,i]of e.seenIds)i>1&&e.issues.push(`\u5B58\u5728 ${i} \u4E2A\u91CD\u590D\u7684 colId/field "${t}"\uFF0C\u5DF2\u81EA\u52A8\u52A0\u540E\u7F00\u533A\u5206\uFF0C\u5EFA\u8BAE\u663E\u5F0F\u547D\u540D colId`);return e.issues}var Fn=new Set([...Oi,...He]),ra=new Set(["enableColumnResize","pagination","rowKey"]);function na(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:e.length+1},(i,r)=>r);for(let i=1;i<=n.length;i++){let r=t[0];t[0]=i;for(let o=1;o<=e.length;o++){let s=t[o];t[o]=Math.min(t[o-1]+1,s+1,r+(n[i-1]===e[o-1]?0:1)),r=s}}return t[e.length]}function oa(n){let e,t=Math.max(2,Math.floor(n.length*.3))+1,i=n.toLowerCase();for(let r of Fn){if(Math.abs(i.length-r.length)>=t)continue;let o=na(i,r.toLowerCase());o<t&&(t=o,e=r)}return e}function sa(n,e){n.rowKey!=null&&typeof n.rowKey!="string"&&typeof n.rowKey!="function"&&e("INVALID_OPTION_VALUE","rowKey","rowKey \u5FC5\u987B\u662F\u5B57\u6BB5\u8DEF\u5F84\u6216\u8FD4\u56DE\u7A33\u5B9A\u4E1A\u52A1\u4E3B\u952E\u7684\u51FD\u6570"),n.domLayout==="autoHeight"&&n.datasource!=null&&e("OPTION_CONFLICT","domLayout","autoHeight \u4F1A\u6E32\u67D3\u5168\u90E8\u5DF2\u52A0\u8F7D\u884C\uFF0C\u4E0D\u9002\u7528\u4E8E datasource \u65E0\u9650\u6EDA\u52A8\u6A21\u5F0F"),aa(n,e),n.enableColumnResize!=null&&typeof n.enableColumnResize!="boolean"&&e("INVALID_OPTION_VALUE","enableColumnResize","enableColumnResize \u5FC5\u987B\u662F boolean\uFF1B\u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u5173\u95ED")}function aa(n,e){n.datasourceMode==="block"&&(n.datasource==null&&e("OPTION_CONFLICT","datasourceMode","datasourceMode='block' requires a datasource"),typeof n.getRowHeight=="function"&&e("OPTION_CONFLICT","getRowHeight","Random-access block rows require fixed rowHeight so unloaded offsets remain deterministic"),n.masterDetail===!0&&e("OPTION_CONFLICT","masterDetail","masterDetail is not supported by the sparse random-access block row model"),n.treeData===!0&&e("OPTION_CONFLICT","treeData","treeData requires the local/tree row model and cannot use random-access blocks"),n.rowKey==null&&e("MISSING_STABLE_ROW_ID","rowKey","Random-access blocks require rowKey to preserve selection and identity after eviction"))}function la(n,e){for(let t of Oi)if(!(ra.has(t)||!v(n,t))&&!Hi(t,n[t])){let i=t==="maxBodyHeight"?"maxBodyHeight \u5FC5\u987B\u662F\u81F3\u5C11 1px \u7684\u6709\u9650\u6570":`${t} \u503C\u7C7B\u578B\u65E0\u6548\uFF0C\u671F\u671B ${be[t]}`;e("INVALID_OPTION_VALUE",t,i)}}function da(n){let e=[];for(let t of Object.keys(n)){if(Fn.has(t))continue;let i=oa(t);e.push({code:"UNKNOWN_OPTION",option:t,...i?{suggestion:i}:{},message:i?`\u672A\u77E5 GridOption "${t}"\uFF0C\u662F\u5426\u60F3\u4F7F\u7528 "${i}"\uFF1F`:`\u672A\u77E5 GridOption "${t}"\uFF0C\u8BE5\u503C\u4E0D\u4F1A\u751F\u6548`})}return e}function ca(n,e,t){if(e.mode!=="server")return;n.rowKey==null&&t("MISSING_STABLE_ROW_ID","rowKey","\u670D\u52A1\u7AEF\u5206\u9875\u5EFA\u8BAE\u63D0\u4F9B\u7A33\u5B9A rowKey\uFF0C\u5426\u5219\u8DE8\u9875\u9009\u62E9\u4E0E\u589E\u91CF\u66F4\u65B0\u65E0\u6CD5\u53EF\u9760\u4FDD\u6301");let i=e.total;i!==void 0&&(typeof i!="number"||!Number.isFinite(i)||i<0)&&t("INVALID_OPTION_VALUE","pagination.total","\u670D\u52A1\u7AEF\u5206\u9875 total \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u6570")}function ua(n,e){let t=n.pagination;t!=null&&typeof t!="boolean"&&typeof t!="object"&&e("INVALID_OPTION_VALUE","pagination","pagination \u5FC5\u987B\u662F boolean \u6216\u914D\u7F6E\u5BF9\u8C61"),n.datasource!=null&&t!==void 0&&t!==!1&&e("OPTION_CONFLICT","pagination","datasource \u987A\u5E8F\u65E0\u9650\u6A21\u5F0F\u4E0E pagination \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF1B\u666E\u901A\u670D\u52A1\u7AEF\u5206\u9875\u8BF7\u4F7F\u7528 pagination.mode='server'"),t&&typeof t=="object"&&ca(n,t,e)}function Xi(n){let e=n,t=da(e),i=(r,o,s)=>{t.push({code:r,option:o,message:s})};return ua(e,i),e.treeData===!0&&e.masterDetail===!0&&i("OPTION_CONFLICT","masterDetail","treeData \u4E0E masterDetail \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF0C\u4E3B\u4ECE\u660E\u7EC6\u5C06\u88AB\u5FFD\u7565"),la(e,i),sa(e,i),t}function On(n){let e=/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(n.trim());return e?[Number(e[1]),Number(e[2]??0),Number(e[3]??0)]:null}function Ji(n,e){for(let t=0;t<3;t++)if(n[t]!==e[t])return n[t]<e[t]?-1:1;return 0}function ha(n){return n[0]>0?[n[0]+1,0,0]:n[1]>0?[0,n[1]+1,0]:[0,0,n[2]+1]}function pa(n,e){if(e==="*"||e.toLowerCase()==="latest")return!0;let t=/^(\^|~|>=|<=|>|<|=)?\s*(.+)$/.exec(e);if(!t)return!1;let i=On(t[2]);if(!i)return!1;let r=Ji(n,i);switch(t[1]??"="){case">=":return r>=0;case"<=":return r<=0;case">":return r>0;case"<":return r<0;case"^":return r>=0&&Ji(n,ha(i))<0;case"~":return r>=0&&Ji(n,[i[0],i[1]+1,0])<0;default:return r===0}}function Hn(n,e){if(!e?.trim())return!0;let t=n?On(n):null;return t?e.split("||").some(i=>{let r=i.trim().split(/\s+/).filter(Boolean);return r.length>0&&r.every(o=>pa(t,o))}):!1}function fa(n){return[...new Set((n??[]).map(e=>e.trim()).filter(Boolean))]}function Ut(n){let e=new Map;for(let t of n??[]){let i=(typeof t=="string"?t:t?.key??"").trim();if(!i||e.has(i))continue;let r=typeof t=="object"?t.version?.trim():void 0;e.set(i,{key:i,...r?{version:r}:{}})}return[...e.values()]}function Zi(n){let e=[],t=new Map;for(let l of n){let d=typeof l?.key=="string"?l.key.trim():"";if(!d){e.push({code:"INVALID_FEATURE_KEY",message:"GridFeature.key must be a non-empty string"});continue}if(t.has(d)){e.push({code:"DUPLICATE_FEATURE",feature:d,message:`Duplicate GridFeature key: ${d}`});continue}t.set(d,l)}let i=new Set;for(let[l,d]of t){for(let c of Ut(d.requires)){let u=t.get(c.key);u?Hn(u.version,c.version)||(i.add(l),e.push({code:"UNSUPPORTED_FEATURE_VERSION",feature:l,dependency:c.key,message:`GridFeature "${l}" requires "${c.key}" ${c.version}, received ${u.version??"unversioned"}`})):(i.add(l),e.push({code:"MISSING_FEATURE_DEPENDENCY",feature:l,dependency:c.key,message:`GridFeature "${l}" requires missing feature "${c.key}"`}))}for(let c of fa(d.conflicts))if(t.has(c)){i.add(l),e.push({code:"FEATURE_CONFLICT",feature:l,dependency:c,message:`GridFeature "${l}" conflicts with "${c}"`});break}}let r=[],o=new Set,s=new Set,a=l=>{if(s.has(l))return!i.has(l);if(o.has(l))return i.add(l),e.push({code:"FEATURE_CYCLE",feature:l,message:`GridFeature dependency cycle includes "${l}"`}),!1;let d=t.get(l);if(!d||i.has(l))return!1;o.add(l);let c=!0;for(let u of Ut(d.requires))a(u.key)||(c=!1);return o.delete(l),s.add(l),c?(r.push(d),!0):(i.add(l),!1)};for(let l of t.keys())a(l);return{features:r.filter(l=>!i.has(l.key.trim())),issues:e}}var ma=new Set(["valueFormatter","cellStyle","cellClass"]),ga=new Set(["selectionChanged","sortChanged","filterChanged","columnMoved","columnVisibilityChanged","paginationChanged","detailToggled"]),ya=0,jt=class{constructor(e,t){this.D=!1;this.wm=0;this.mr=0;this.qd=!1;this.Zs="";this.x=new _e(e=>console.error("[mach-table] resource cleanup error",e));this.activeFeatures=new Map;this.Qd=0;this.gr=0;this.recentErrors=[];this.Tt=null;this.ec=0;this.yr=null;this.Qs=0;this.vr=null;this.ea=!1;this.ta=null;this.ac=null;this.Yn=new Set;let i;this.Yd=new Promise(r=>{i=r}),this.Xd=i,this.gridId=++ya,this.t=fr(t),this.de=new Ze((r,o)=>{o==="gridError"?console.error("[mach-table] error in gridError listener",r):this.reportError(r,"eventBus.listener",{eventType:o})});try{if(this.Xl(t.dataProcessor),this.r=new nt(this),this.i=this.x.A(new ht(this)),this.f=new pt(this),this.n=this.x.A(new Pt(this)),this.W=this.x.A(new Nt(this)),this.s=this.x.A(new _t(this)),this.dr=this.x.A(new ft(this)),this.xn=this.x.A(new mt(this)),this.qo=this.x.A(new yt(this)),this.a=this.x.A(new bt(this)),this.V=new wt(this),this.O=new St(this),this.be=this.x.A(new At),this.hi=this.x.A(new kt(r=>this.Cm(r))),this.Ts=this.x.A(new Tt(this)),this.columnMenu=this.x.A(new Dt(this)),this.Us=this.x.A(new xt(this)),this.Nn=this.x.A(new Rt(this)),this.wn=this.x.A(new Et(this)),this.fi=this.x.A(new Wt(this)),this.Le=this.x.A(new $t(this)),this.Pe=this.x.A(new zt(this)),this.dt=this.x.A(new Kt(this)),this.api=Mn(this),this.je=new Je(this),this.$=this.x.A(new Mt(this)),this.x.add(()=>this.tc()),this.$.init(),this.n.init(e,this.t),this.wn.init(),this.s.init(),this.qo.init(),this.Nn.init(),this.fi.init(),this.Pe.init(),this.dt.init(),this.Le.init(),this.i.Va(this.t.paginationPage,this.t.paginationPageSize),this.r.Ri(this.t.columnDefs),this.i.nt(this.t.advancedFilterModel),this.i.Mt(this.t.quickFilterText),this.Cn(),this.ic(this.t.columnDefs),this.ms(t),this.W.Dn(),this.t.datasource?this.i.Fr().catch(()=>{}):this.i.rt(this.t.rowData),this.t.initialState&&this.api.state.apply(this.t.initialState,{emitEvents:!1}),this.ys(),this.Ie(),this.Le.setData(this.t.pinnedTopRowData,this.t.pinnedBottomRowData),this.Jl(this.t.features),this.D)return;this.mr=requestAnimationFrame(()=>{this.mr=0,this.D||this.emit("gridReady",{}),this.rc()})}catch(r){throw this.api&&this.reportError(r,"grid.constructor"),this.destroy(),r}}Xl(e){if(e===this.Jd)return!1;let t=++this.Qd,i=typeof e=="function"?e():e;if(this.D||t!==this.Qd)return i?.destroy?.(),!1;let r=this.Zd;return this.Jd=e,i===this.t.dataProcessor&&r?!1:(this.t.dataProcessor=i,this.Zd=i?this.x.add(()=>i.destroy?.()):void 0,r?.(),!0)}whenReady(){return this.Yd}rc(){this.qd||(this.qd=!0,this.Xd(this.api))}lc(e){return this.t.components?.cellRenderers?.[e]??Sr[e]}Uu(e){return this.t.components?.cellEditors?.[e]}Tm(e){return Ut(e.requires).map(t=>t.key).find(t=>!this.activeFeatures.has(t))}Jl(e){let t=this.gr+1;if(this.tc(),this.D||this.gr!==t)return;let i=Zi(e??[]);for(let r of i.issues)this.reportError(new Error(r.message),"feature.manifest",{code:r.code,...r.feature?{key:r.feature}:{},...r.dependency?{dependency:r.dependency}:{}});for(let r of i.features){if(this.D||this.gr!==t)return;let o=r.key.trim(),s=this.Tm(r);if(s){this.reportError(new Error(`GridFeature "${o}" dependency "${s}" did not initialise`),"feature.manifest",{code:"FEATURE_DEPENDENCY_SETUP_FAILED",key:o,dependency:s});continue}let a=new _e(c=>this.reportError(c,"feature.cleanup",{key:o})),l=c=>a.add(c),d={api:this.api,root:this.n.root,getOptions:()=>this.t,addEventListener:(c,u)=>l(this.de.on(c,u)),onCleanup:c=>{l(c)},addManagedDomListener:(c,u,h,f)=>(c.addEventListener(u,h,f),l(()=>c.removeEventListener(u,h,f))),setManagedTimeout:(c,u)=>{let h=setTimeout(()=>{f(),c()},Math.max(0,u)),f=l(()=>clearTimeout(h));return h},createAbortController:()=>{let c=new AbortController;return l(()=>c.abort()),c},reportError:(c,u,h)=>this.reportError(c,`feature.${u}`,h)};try{let c=r.setup(d);if(typeof c=="function"&&l(c),this.D||this.gr!==t){this.nc(o,{feature:r,scope:a});return}this.activeFeatures.set(o,{feature:r,scope:a})}catch(c){a.dispose(),this.reportError(c,"feature.setup",{key:o})}}}tc(){this.gr++;let e=[...this.activeFeatures.entries()].reverse();this.activeFeatures.clear();for(let[t,i]of e)this.nc(t,i)}nc(e,t){t.scope.dispose();try{t.feature.destroy?.()}catch(i){this.reportError(i,"feature.destroy",{key:e})}}o(){return this.D}suspend(){this.ze(),this.api.editing.stop({cancel:!0}),this.Ts.close(),this.columnMenu.close(),this.Us.close(),this.Nn.hide(),this.dr.Gt(),this.xn.destroy(),this.s.suspend(),Jr(this.n.root),Tr(this.n.root);let e=document.activeElement;e instanceof HTMLElement&&this.n.root.contains(e)&&e.blur()}Zt(){return++this.wm}d(e,t){let i=t.colDef;if(i.valueGetter)try{return i.valueGetter({api:this.api,colDef:i,column:t,node:e,data:e.data})}catch(r){this.reportError(r,"valueGetter",{colId:t.id,rowId:e.id});return}if(i.field)return K(e.data,i.field)}c(e){return this.t.locale[e]??_[e]}Qr(e,t,i,r){let o=t.colDef;if(o.valueSetter)try{return o.valueSetter({oldValue:r,newValue:i,data:e.data,node:e,colDef:o,column:t,api:this.api})}catch(s){return this.reportError(s,"valueSetter",{colId:t.id,rowId:e.id}),!1}return o.field?Ee(e.data,o.field,i):!1}Uo(e,t,i,r){this.s.zr(e),this.s.Rl([e.rowIndex],[t.id]),this.O.Qo({nodeId:e.id,columnId:t.id,oldValue:i,newValue:r}),this.emit("cellValueChanged",{oldValue:i,newValue:r,rowNode:e,rowIndex:e.rowIndex,column:t,colDef:t.colDef,data:e.data})}nl(e){let i=this.r.l().slice(e.c1,e.c2+1).filter(o=>!o.isAutoRowNumber),r=[];for(let o=e.r1;o<=e.r2;o++){let s=this.i.h(o);r.push(i.map(a=>!s||s.isDetail||s.isGroup?"":Oe(this,s,a,"clipboard")))}return Ri(r)}wl(){let e=this.s.ai();return e?Ne(this.nl(e)):Promise.resolve(!1)}No(e){this.D||this.pi(this.oc(e,this.r.l()))}async Au(e,t){let{s:i,r,i:o}=this,s=this.V.Zr(),a=o.Li(),l=i.v,d=i.Ce(),c=r.l(),u=this.oc(e,c),h=u.map(({node:m})=>m.data);if(!await Ne(t)||!s()||this.t.suppressClipboard||a!==o.Li()||l!==i.v||d!==i.Ce())return;let f=r.l();c.slice(e.c1,e.c2+1).some((m,g)=>m!==f[e.c1+g])||u.every(({node:m,column:g,oldValue:b},C)=>m.data===h[C]&&Object.is(this.d(m,g),b))&&this.pi(u)}oc(e,t){let i=[];for(let r=e.r1;r<=e.r2;r++){let o=this.i.h(r);if(!(!o||o.isDetail||o.isGroup))for(let s=e.c1;s<=e.c2;s++){let a=t[s];!a||!q(a)||a.colDef.rowDrag||i.push({node:o,column:a,oldValue:this.d(o,a),newValue:null})}}return i}pi(e){this.V.Xu(e)}ze(){this.V?.ju()}ol(e,t,i){if(this.D)return;let r=Ei(e);if(r.length===0)return;let o=this.r.l(),s=this.i.G(),a=[],l=t;for(let d of r){let c=this.Dm(l,s);if(!c)break;this.xm(c.node,d,o,i,a),l=c.index+1}this.pi(a)}Dm(e,t){for(let i=e;i<t;i++){let r=this.i.h(i);if(r&&!r.isDetail&&!r.isGroup)return{index:i,node:r}}return null}Rm(e,t){let i=t;for(;i<e.length;){let r=e[i];if(q(r)&&!r.colDef.rowDrag)break;i++}return i}xm(e,t,i,r,o){let s=r,a=o.length;for(let l of t){if(s=this.Rm(i,s),s>=i.length)return;let d=i[s];if(!this.a.oe(e,d)){s++;continue}let c=this.d(e,d);try{let u=d.colDef.valueParser?de(this,e,d,l,"clipboard",c):gt(l,typeof c=="number"||d.colDef.cellEditor==="number");o.push({node:e,column:d,oldValue:c,newValue:u})}catch(u){o.splice(a),this.reportError(u,"validate",{rowId:e.id,colId:d.id});return}s++}}ch(){let e=this.s.Fo();if(!e)return Promise.resolve();let t=this.V.Zr(),i=this.i.h(e.row),r=this.r.l()[e.colIdx];if(!i||!r)return Promise.resolve();let o=this.d(i,r),s=this.V.Xi([{node:i,column:r,oldValue:o,newValue:o}]);try{if(typeof navigator<"u"&&navigator.clipboard?.readText)return navigator.clipboard.readText().then(a=>{let l=this.s.Fo();a&&t()&&s()&&l?.row===e.row&&l.colIdx===e.colIdx&&this.i.h(e.row)===i&&this.r.l()[e.colIdx]===r&&this.ol(a,e.row,e.colIdx)}).catch(()=>{})}catch{}return Promise.resolve()}emit(e,t,i=!0){let r={type:e,api:this.api,...t};this.de.emit(e,r);let o="on"+e.charAt(0).toUpperCase()+e.slice(1),s=this.t[o];if(typeof s=="function")try{s(r)}catch(l){e==="gridError"?console.error("[mach-table] error in onGridError",l):this.reportError(l,`eventHandler.${String(o)}`,{eventType:e})}let a=e==="columnResized"&&!!r.finished;return i&&(a||ga.has(e))&&this.yn(),r}reportError(e,t,i){let r=e instanceof Error?e.message:String(e),o=this.Em(t,r);this.recentErrors.push({code:o,source:t,message:r,timestamp:Date.now(),...i?{context:i}:{}}),this.recentErrors.length>50&&this.recentErrors.shift(),console.error(`[mach-table] ${o} (${t})`,e),!this.D&&this.emit("gridError",{code:o,error:e,source:t,context:i})}Em(e,t){return/^(datasource|treeData)/.test(e)?"DATA_SOURCE_ERROR":e==="rowKey"||t.includes("Duplicate row id")?"DATA_INTEGRITY_ERROR":e==="validate"?"VALIDATION_ERROR":e.toLowerCase().includes("renderer")||ma.has(e)?"RENDERER_ERROR":e.toLowerCase().includes("editor")||e==="editable"?"EDITOR_ERROR":e.startsWith("feature.")?"FEATURE_ERROR":/^(columnState|gridState)\./.test(e)?"STATE_ERROR":/^(eventBus|eventHandler)\./.test(e)?"EVENT_HANDLER_ERROR":"GRID_ERROR"}jh(){return{gridId:this.gridId,version:We,destroyed:this.D,infinite:this.i.g,loading:this.i.xc()||this.t.loading,rowCount:this.i.Gi(),renderedRowCount:this.n.Ge.querySelectorAll(".mach-row[data-index]").length,columnCount:this.r.ee().length,selectedRowCount:this.f.ei().length,dirtyRowCount:this.$.getDirtyRowIds().length,activeFeatures:[...this.activeFeatures].map(([e,t])=>({key:e,...t.feature.version?{version:t.feature.version}:{}})),performance:this.be.snapshot(),updates:this.hi.snapshot(),recentErrors:this.recentErrors.map(e=>({...e,...e.context?{context:{...e.context}}:{}}))}}Rr(e,t){this.r.Rr(e,t),this.Si()}Si(){this.W.vs(),this.emit("sortChanged",{sortModel:this.r.te()}),this.i.To()}Ju(e,t){let i=this.i._e();t?i[e.id]=t:delete i[e.id],this.i.St(i),this.ar()}ar(){this.W.bs(),this.gs(),this.i.To()}gs(e=!0){this.emit("filterChanged",{filterModel:this.i._e(),advancedFilterModel:this.i.Ni()},e)}Ei(e,t){this.r.Ei(e,t)&&(this.sr(),this.emit("columnMoved",{colId:e,toIndex:t}))}$r(e){return this.i.$r(e)}Za(e,t){this.emit("columnResized",{colId:e.id,width:e.currentWidth,finished:t})}at(e){if(!(this.D||e.length===0))for(let t of e){if(this.D)break;this.Za(t,!0)}}ys(e=!1,t=!1){let i=this.Qs,r=this.yr,o=this.r.no().length>0;if(e){if(r==null||!o)return;if(r!==i){this.yr=null,this.yn();return}}this.yr=null;let s=++this.ec,a=this.t.persistence;if(!a)return;let{key:l,store:d,sections:c}=a;if(!o&&(!c||c.some(f=>f==="columns"||f==="sort"||f==="filter"))){this.yr=i;return}let u;try{u=d?d.load(l):Yi(l)}catch(f){this.reportError(f,"gridState.load");return}let h=(f,m=!1)=>{if(this.D||s!==this.ec||i!==this.Qs||!f)return;let g=this.vr;this.vr=m?"beforeRows":"normal";try{this.api.state.apply(f,{emitEvents:!1,sections:c})}finally{this.vr=g}};k(u)?Promise.resolve(u).then(h).catch(f=>this.reportError(f,"gridState.load")):h(u,t)}Ap(){return this.vr==="beforeRows"}yn(){let e=this.t.persistence;if(!(!e||this.D||this.vr)&&(this.Qs++,this.yr==null)){if(this.Tt&&clearTimeout(this.Tt),e.debounceMs===0){this.Tt=null,this.ia();return}this.Tt=setTimeout(()=>{this.Tt=null,this.ia()},e.debounceMs)}}ia(){let e=this.t.persistence;if(!e||this.D)return;let{key:t,store:i,sections:r}=e,o=this.api.state.get(),s=r?un(o,r):o,a={key:t,...i?{store:i}:{},state:s};if(this.ea){this.ta=a;return}this.sc(a)}sc(e){try{let t=e.store?e.store.save(e.key,e.state):qi(e.key,e.state);if(!k(t))return;this.ea=!0,Promise.resolve(t).catch(i=>this.reportError(i,"gridState.save")).finally(()=>{this.ea=!1;let i=this.ta;this.ta=null,i&&this.sc(i)})}catch(t){this.reportError(t,"gridState.save")}}xh(){let e=p("div","mach-empty mach-empty--error"),t=p("div","mach-empty__title");t.textContent=this.c("requestFailed");let i=p("div","mach-empty__hint");return i.textContent=this.c("requestFailedHint"),e.append(t,i),e}Th(){let e=p("div","mach-loading"),t=p("div","mach-loading__visual");t.setAttribute("aria-hidden","true");for(let s=0;s<4;s+=1){let a=p("span","mach-loading__row");t.appendChild(a)}let i=p("div","mach-loading__status"),r=p("span","mach-spinner mach-loading__spinner");r.setAttribute("aria-hidden","true");let o=p("span","mach-loading__label");return o.textContent=this.c("loading"),i.append(r,o),e.append(t,i),e}Dh(){let e=p("div","mach-empty");e.innerHTML='<svg class="mach-empty__icon" viewBox="0 0 96 84" aria-hidden="true"><rect stroke-opacity=".3" x="8" y="6" width="76" height="66" rx="9"/><path fill="#8b98ff" opacity=".12" stroke="none" d="M17 6H75Q84 6 84 15V26H8V15Q8 6 17 6Z"/><path stroke="var(--mach-body-fg)" opacity=".06" d="M8 26h76M38 26v46M61 26v46M8 42h76M8 57h76"/><path stroke-width="5" opacity=".5" d="M19 15h12m17 0h7m15 0h7"/><path stroke="var(--mach-body-fg)" opacity=".06" stroke-width="4" d="M19 34h12m14 0h8m15 0h8M19 49h12m14 0h8m15 0h8M19 64h12m14 0h8"/><circle stroke-opacity=".3" cx="72" cy="55" r="19"/><circle cx="70" cy="53" r="9"/><path d="m77 60 6 6m-16-16 6 6m0-6-6 6"/></svg>';let{locale:t,manualFiltering:i}=this.t,r=!i&&!this.i.g&&this.i.He().length>0&&this.i.Hi(),o=p("div","mach-empty__title");o.textContent=r?t.noMatchingRows??t.emptyRows??this.c("noMatchingRows"):this.c("emptyRows");let s=p("div","mach-empty__hint");if(s.textContent=this.c("emptyRowsHint"),e.append(o),(!r||t.emptyRowsHint)&&e.append(s),r){let a=p("button","mach-toolbar__select-host");a.type="button",a.textContent=this.c("clearFilters"),a.onclick=()=>{this.i.St({}),this.i.nt(null),this.i.Mt(null),this.t.quickFilterText=null,this.ar(),this.n.root.focus({preventScroll:!0})},e.append(a)}return e}ms(e){if(!(this.t.suppressWarnings||this.D)){if(e)for(let t of Xi(e)){let i=`${t.code}:${t.option??""}:${t.message}`;this.Yn.has(i)||(this.Yn.add(i),console.warn(`[mach-table:${t.code}] ${t.message}`))}this.t.treeData&&this.r.Je().length>0&&console.warn("[mach-table] treeData \u4E0E rowGroup \u4E0D\u652F\u6301\u540C\u65F6\u542F\u7528\uFF0C\u884C\u5206\u7EC4\u5DF2\u88AB\u5FFD\u7565")}}ic(e){if(!(this.t.suppressWarnings||this.D)&&this.ac!==e){this.ac=e;for(let t of Nn(e))this.Yn.has(t)||(this.Yn.add(t),console.warn(`[mach-table] ${t}`))}}sr(){this.je.xi=!0,this.hi.Pl({columns:!0})}K(e){(e.data||e.cells)&&(this.je.xi=!0),this.hi.Pl(e)}Ul(e){return this.hi.batch(e)}Cm(e){this.D||(e.columns?this.Sm():(e.header&&this.W.Dn(),e.pool&&this.s.xd(),(e.pool||e.layout)&&this.Ie()),this.Mm(e),e.data&&!e.pool&&!e.columns?this.s.im():e.cells&&this.s.refreshCells(e.cells===!0?void 0:e.cells),e.pinned&&this.Le.refresh(),e.summary&&this.Pe.refresh(),e.overlays&&this.s.Bs())}Mm(e){if(!(e.data||e.cells)||e.layout||e.columns||e.pool)return;let t=e.data||e.cells===!0?void 0:e.cells;this.je.Zn(t)&&this.ii()}Sm(){this.ms(),this.ic(this.r.no()),this.s.ot(),this.W.Dn(),this.s.xd(),this.Ie(),this.Le.xe(),this.emit("displayedColumnsChanged",{})}Ie(){if(this.D)return;let e=this.be.start();this.Cn(),this.je.Zn(),this.r.aa(this.n.us());let t=this.r.l().map(i=>`${i.id}:${i.currentWidth}`).join("|");this.Zs&&t!==this.Zs&&this.s.ot(),this.Zs=t,this.n.root.setAttribute("aria-colcount",String(this.r.l().length)),this.W.gt(),this.s.Ie(),this.Le.gt(),this.Pe.refresh(),this.be.wh(e)}Cn(){if(!this.n.root)return;let e=this.t.treeData||this.r.Je().length>0;this.n.root.setAttribute("role",e?"treegrid":"grid"),this.t.rowSelection==="multiple"?this.n.root.setAttribute("aria-multiselectable","true"):this.n.root.removeAttribute("aria-multiselectable"),this.r.l().some(i=>!!i.colDef.editable)?this.n.root.removeAttribute("aria-readonly"):this.n.root.setAttribute("aria-readonly","true")}ii(e=!0){this.D||(this.je.Zn(),this.r.aa(this.n.us()),e&&this.s.ot(),this.W.gt(),this.s.bn(),this.s.Bn(),this.s.lr(!0),this.Le.gt(),this.Pe.refresh())}destroy(){if(!this.D){if(this.Tt&&(clearTimeout(this.Tt),this.Tt=null,this.ia()),this.D=!0,this.ze(),this.mr&&cancelAnimationFrame(this.mr),this.mr=0,this.api){this.rc();try{this.emit("gridDestroyed",{})}catch(e){console.error("[mach-table] grid destroy event",e)}}this.x.dispose(),this.de.clear()}}};function va(n,e={}){if(!n)throw new Error("[mach-table] createGrid requires a container element");if(typeof document>"u")throw new Error("[mach-table] createGrid can only be used in a browser environment");return new jt(n,e).api}function ba(n){return n.mode==="allMatching"?{mode:"allMatching",excludedKeys:[...n.excludedKeys]}:{mode:"explicit",selectedKeys:[...n.selectedKeys]}}function wa(n,e){if(e.scope!=="filtered"&&e.scope!=="selected")throw new TypeError("[MachTable] Remote export scope must be filtered or selected.");let t=n.state.get();return{version:1,scope:e.scope,columnIds:t.columns.filter(i=>!i.hide).map(i=>i.colId),sortModel:t.sortModel.map(i=>({...i})),filterModel:oe(t.filterModel),advancedFilterModel:B(t.advancedFilterModel),quickFilterText:t.quickFilterText,...e.scope==="selected"?{selection:ba(e.selection??{mode:"explicit",selectedKeys:t.selectedRowIds})}:{}}}function Ca(n){return n.value===!0?"\u662F":n.value===!1?"\u5426":""}function Ta(n){return e=>{if(e.value==null||e.value==="")return"";let t=e.value instanceof Date?e.value.toISOString():String(e.value);return n==="datetime"?t.slice(0,16).replace("T"," "):t.slice(0,10)}}function Da(n){return e=>{if(e.value==null)return"";let t=n.find(i=>i.value===e.value);return t?t.label:String(e.value)}}function xa(n,e){return n.filterable===!1?!1:e==="number"?"number":e==="date"?"date":e==="select"||e==="boolean"?"set":"text"}function Ra(n,e,t){if(e.editable&&(t==="number"||t==="date")&&(n.cellEditor=t),t==="date"){n.valueFormatter=Ta(e.format);return}if(t==="boolean"){n.valueFormatter=Ca;return}if(t!=="select")return;let i=e.options??[];n.valueFormatter=Da(i),e.editable&&(n.cellEditor="select",n.cellEditorParams={options:i})}function Vn(n){let e=n.type??"string",t={colId:n.field,field:n.field,headerName:n.title??n.field,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth,flex:n.flex,pinned:n.pinned??void 0,hide:n.hidden??!1,editable:n.editable??!1,sortable:n.sortable??!0,resizable:n.resizable??!0,filter:xa(n,e),cellClass:n.cellClass};return Ra(t,n,e),t}function Ea(n){let e=new Map(n.fields.map(s=>[s.field,s])),t=n.groups??[],i=new Set(t.flatMap(s=>s.fields)),r=new Set,o=[];for(let s of n.fields)r.has(s.field)||i.has(s.field)||(o.push(Vn(s)),r.add(s.field));for(let s of t){let a=[];for(let l of s.fields){let d=e.get(l);!d||r.has(l)||(a.push(Vn(d)),r.add(l))}a.length>0&&o.push({groupId:s.groupId,headerName:s.title,children:a})}return o}function N(n){let e=n();return e&&!e.isDestroyed()?e:null}function Sa(n){let e=()=>n.getApi();return{search(t){N(e)?.filtering.setQuickText(t)},async refresh(){if(n.reload){await n.reload();return}let t=N(e);t&&(t.rows.isRemote()?await t.rows.reload():t.view.refreshCells())},openColumns(t){N(e)?.columns.openWorkbench(t)},setDensity(t){N(e)?.updateOptions({size:t})},selectAll(t=!0){N(e)?.selection.selectAll(t)},clearSelection(){let t=N(e);t?.selection.clear(),t?.selection.clearRange()},resetColumns(){N(e)?.columns.resetState()},resetView(){N(e)?.batch(t=>{t.selection.clear(),t.selection.clearRange(),t.filtering.setModel(null),t.filtering.setAdvancedModel(null),t.sorting.setModel(null),t.pagination.setPage(1),t.columns.resetState()})},undo(){return N(e)?.editing.undo()??!1},redo(){return N(e)?.editing.redo()??!1},canUndo(){return N(e)?.editing.canUndo()??!1},canRedo(){return N(e)?.editing.canRedo()??!1},exportCsv(t="mach-table.csv"){let i=N(e);return i?Ni(t,i.io.exportCsv({prependBOM:!0}),"text/csv;charset=utf-8"):!1},async toggleFullscreen(){if(typeof document>"u")return!1;if(document.fullscreenElement)return await document.exitFullscreen?.(),!1;let i=N(e)?.view.getRoot(),r=n.getFullscreenElement?.()??i?.parentElement??i;return r?.requestFullscreen?(await r.requestFullscreen(),!0):!1}}}function Ma(){return{accessor:(n,e={})=>({...e,field:n}),display:n=>({...n}),group:n=>({...n,children:[...n.children]})}}function Ia(n){return[...n]}function Qi(n,e){return e===void 0?n:typeof e!="object"||e===null||typeof n!="object"||n===null?e:{...n,...e}}function Aa(n,e){return typeof n!="function"?e:typeof e!="function"?n:(...t)=>{let i;try{n(...t)}catch(r){i=r}try{e(...t)}catch(r){i??(i=r)}if(i!==void 0)throw i}}function ka(n,e){if(!(!n.components&&!e.components))return{cellRenderers:{...n.components?.cellRenderers,...e.components?.cellRenderers},cellEditors:{...n.components?.cellEditors,...e.components?.cellEditors}}}function Pa(n,e){if(!n.columnTypes&&!e.columnTypes)return;let t={},i=new Set([...Object.keys(n.columnTypes??{}),...Object.keys(e.columnTypes??{})]);for(let r of i)t[r]={...n.columnTypes?.[r],...e.columnTypes?.[r]};return t}function Ga(n,e,t){for(let i of new Set([...Object.keys(e),...Object.keys(t)])){if(!/^on[A-Z]/.test(i))continue;let r=e[i],o=t[i];typeof r!="function"||typeof o!="function"||(n[i]=Aa(r,o))}}function La(n,e){let t={...n,...e,features:e.features??n.features};(n.defaultColDef||e.defaultColDef)&&(t.defaultColDef={...n.defaultColDef,...e.defaultColDef}),(n.locale||e.locale)&&(t.locale={...n.locale,...e.locale});let i=ka(n,e);i&&(t.components=i);let r=Pa(n,e);return r&&(t.columnTypes=r),(n.aggFuncs||e.aggFuncs)&&(t.aggFuncs={...n.aggFuncs,...e.aggFuncs}),t.pagination=Qi(n.pagination,e.pagination),t.statusBar=Qi(n.statusBar,e.statusBar),t.watermark=Qi(n.watermark,e.watermark),Ga(t,n,e),t}function Bn(...n){return n.reduce(La,{})}function Na(n={}){return Bn({defaultColDef:{sortable:!0,resizable:!0,movable:!0,filter:!0},enableColumnResize:!0,rowSelection:"multiple",columnMenu:!0,contextMenu:!0,enableRangeSelection:!0,fillHandle:!0,statusBar:!0,stripedRows:!0},n)}function Fa(n){return n}function Oa(n){return n}function Ha(n){return n}function Yt(n){return n!=null&&n!==""}function Va(n){if(!Yt(n))return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function qt(n,e){try{return new Intl.NumberFormat(n,e)}catch{return new Intl.NumberFormat(void 0,e)}}function _n(n,e){try{return new Intl.DateTimeFormat(n,e)}catch{let t={...e};return delete t.timeZone,new Intl.DateTimeFormat(void 0,t)}}function Ba(n){if(!Yt(n))return null;let e=n instanceof Date?n:new Date(n);return Number.isFinite(e.getTime())?e:null}function _a(n={}){let e=n.emptyText??"",t=n.invalidText??"\u2014",i=qt(n.locale,{maximumFractionDigits:n.maximumFractionDigits??2}),r=qt(n.locale,{maximumFractionDigits:0}),o=qt(n.locale,{style:"currency",currency:n.currency??"CNY",currencyDisplay:n.currencyDisplay??"symbol",maximumFractionDigits:n.maximumFractionDigits??2}),s=qt(n.locale,{style:"percent",maximumFractionDigits:n.maximumFractionDigits??2}),a=_n(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",...n.timeZone?{timeZone:n.timeZone}:{}}),l=_n(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,...n.timeZone?{timeZone:n.timeZone}:{}}),d=(u,h=1)=>({value:f})=>{if(!Yt(f))return e;let m=Va(f);return m==null?t:u.format(m*h)},c=u=>({value:h})=>{if(!Yt(h))return e;let f=Ba(h);return f==null?t:u.format(f)};return Object.freeze({text:{align:"left",filter:"text"},number:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(i)},integer:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(r)},money:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(o)},percent:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s)},percentage:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s,.01)},date:{align:"center",filter:"date",cellEditor:"date",valueFormatter:c(a)},datetime:{align:"center",filter:"date",valueFormatter:c(l)},boolean:{align:"center",filter:"set",valueFormatter:({value:u})=>u===!0?n.trueText??"\u662F":u===!1?n.falseText??"\u5426":e},status:{filter:"set",cellRenderer:"statusTag"},link:{filter:"text",cellRenderer:"link"}})}function zn(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Wn(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function $n(n){if(typeof n!="string")return null;let e=n.trim();return e&&e.length<=256?e:null}function er(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==1)return null;let t=X({version:2,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pagination:{enabled:!0,page:1,pageSize:e.pageSize},selectedRowIds:[],expandedRowIds:[],expandedGroupIds:[]});return t?{version:1,columns:t.columns,sortModel:t.sortModel,filterModel:t.filterModel,advancedFilterModel:t.advancedFilterModel,quickFilterText:t.quickFilterText,pageSize:t.pagination.pageSize}:null}function ze(n){if(n==null||typeof n!="object")return null;let e=n,t=$n(e.id),i=typeof e.name=="string"?e.name.trim().slice(0,120):"",r=er(e.state);if(e.schemaVersion!==1||!t||!i||!r)return null;let o=typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:Date.now(),s=typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)?e.updatedAt:o;return{schemaVersion:1,id:t,name:i,createdAt:o,updatedAt:s,state:r}}function Kn(n){let e=n.state.get();return{version:1,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pageSize:e.pagination.pageSize}}function Un(n,e,t={}){let i=er(e);if(!i||n.isDestroyed())return!1;let r=n.state.get();return n.state.apply({...r,columns:i.columns,sortModel:i.sortModel,filterModel:i.filterModel,advancedFilterModel:i.advancedFilterModel,quickFilterText:i.quickFilterText,pagination:{...r.pagination,page:1,pageSize:i.pageSize}},{sections:["columns","sort","filter","pagination"],emitEvents:t.emitEvents}),!0}function jn(n={}){let e=(n.namespace??"mach-table:views").replace(/:+$/,""),t=Math.max(1,Math.floor(n.maxViews??50)),i=Math.max(4096,Math.floor(n.maxBytes??512*1024)),r=l=>`${e}:${encodeURIComponent(l)}`,o=(l,d,c)=>{try{n.onError?.(l,d,c)}catch{}},s=l=>{let d=(n.storage??zn())?.getItem(r(l));if(!d||Wn(d)>i)return[];let c=JSON.parse(d);return c.schemaVersion!==1||!Array.isArray(c.views)?[]:c.views.flatMap(u=>{let h=ze(u);return h?[h]:[]}).slice(0,t)},a=(l,d)=>{let c=JSON.stringify({schemaVersion:1,savedAt:Date.now(),views:d});if(Wn(c)>i)throw new RangeError(`[MachTable] Saved views for "${l}" exceed ${i} bytes.`);let u=n.storage??zn();if(!u)throw new Error("[MachTable] Saved view storage is unavailable.");u.setItem(r(l),c)};return{list(l){try{return s(l)}catch(d){return o(d,"list",l),[]}},save(l,d){try{let c=ze(d);if(!c)throw new TypeError(`[MachTable] Invalid saved view for "${l}".`);let u=s(l).filter(h=>h.id!==c.id);u.unshift(c),a(l,u.slice(0,t))}catch(c){throw o(c,"save",l),c}},remove(l,d){try{a(l,s(l).filter(c=>c.id!==d))}catch(c){throw o(c,"remove",l),c}}}}function za(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Wa(n,e){let t=e.scope.trim();if(!t||t.length>512)throw new TypeError("[MachTable] Grid view scope must contain between 1 and 512 characters.");let i=e.store??jn(),r=async()=>(await i.list(t)).flatMap(s=>{let a=ze(s);return a?[a]:[]}).sort((s,a)=>a.updatedAt-s.updatedAt);return{list:r,async save(o,s){let a=o.trim().slice(0,120);if(!a)throw new TypeError("[MachTable] Grid view name must be a non-empty string.");let l=$n(s)??za(),d=(await r()).find(h=>h.id===l),c=Date.now(),u={schemaVersion:1,id:l,name:a,createdAt:d?.createdAt??c,updatedAt:c,state:Kn(n)};return await i.save(t,u),u},async apply(o,s){let a=typeof o=="string"?(await r()).find(d=>d.id===o):ze(o),l=typeof o=="string"?o:"provided view";if(!a)throw new Error(`[MachTable] Grid view "${l}" was not found.`);if(!Un(n,a.state,s))throw new Error(`[MachTable] Grid view "${a.id}" could not be applied.`);return a},async remove(o){await i.remove(t,o)}}}var np=We;export{lt as BUILTIN_AGG_FUNCS,_ as DEFAULT_LOCALE,Fi as EVENT_TYPES,Go as LOCALE_EN,Qo as actionsColumn,vo as advancedFilterCondition,bo as advancedFilterGroup,Un as applyGridViewState,Ea as buildColDefsFromSchema,Kn as captureGridViewState,Qs as clearGridState,Pe as createActionButtonsRenderer,Ci as createAggResolver,_a as createBusinessColumnTypes,Ma as createColumnHelper,Na as createEnterprisePreset,va as createGrid,Wa as createGridViewManager,Gn as createLocalGridStateStore,jn as createLocalGridViewStore,Sa as createMachTableCommands,Bn as createMachTablePreset,wr as createProgressBarRenderer,wa as createRemoteExportRequest,fi as createRowActionsRenderer,br as createStatusTagRenderer,Ia as defineColumns,Oa as defineGridOptions,Ha as defineMachTableConfig,Fa as defineMachTablePreset,zi as describeFilter,Ni as downloadFile,Zo as dragColumn,ve as escapeHtml,U as formatText,ke as formatTwo,K as getByPath,mi as indexColumn,Ae as isColDefGroup,ti as isSafePath,Cr as linkRenderer,Yi as loadGridState,ai as matchLocaleKey,B as normalizeAdvancedFilterModel,ii as normalizeColumnFilter,oe as normalizeFilterModel,X as normalizeGridState,er as normalizeGridViewState,ze as normalizeSavedGridView,Si as parseCsv,Mi as parseDelimited,Ei as parseTsv,Zi as resolveGridFeatures,$s as resolveSaveConflict,di as resolveTagVariant,es as rowActionsColumn,ye as sanitizeFormulaCell,qi as saveGridState,Jo as selectionColumn,Ee as setByPath,Ri as toTsv,Xi as validateGridOptions,np as version};