@toolbox-web/grid 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/all.js +576 -483
  2. package/all.js.map +1 -1
  3. package/index.js +1747 -1475
  4. package/index.js.map +1 -1
  5. package/lib/core/grid.d.ts +19 -0
  6. package/lib/core/grid.d.ts.map +1 -1
  7. package/lib/core/internal/aria.d.ts +52 -0
  8. package/lib/core/internal/aria.d.ts.map +1 -0
  9. package/lib/core/internal/config-manager.d.ts.map +1 -1
  10. package/lib/core/internal/idle-scheduler.d.ts +0 -27
  11. package/lib/core/internal/idle-scheduler.d.ts.map +1 -1
  12. package/lib/core/internal/loading.d.ts +0 -38
  13. package/lib/core/internal/loading.d.ts.map +1 -1
  14. package/lib/core/internal/row-animation.d.ts.map +1 -1
  15. package/lib/core/internal/shell.d.ts +6 -0
  16. package/lib/core/internal/shell.d.ts.map +1 -1
  17. package/lib/core/internal/style-injector.d.ts +0 -8
  18. package/lib/core/internal/style-injector.d.ts.map +1 -1
  19. package/lib/core/internal/utils.d.ts +6 -4
  20. package/lib/core/internal/utils.d.ts.map +1 -1
  21. package/lib/core/internal/validate-config.d.ts.map +1 -1
  22. package/lib/core/internal/virtualization.d.ts +177 -23
  23. package/lib/core/internal/virtualization.d.ts.map +1 -1
  24. package/lib/core/plugin/base-plugin.d.ts +50 -0
  25. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  26. package/lib/core/plugin/plugin-manager.d.ts +18 -0
  27. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  28. package/lib/core/plugin/types.d.ts +16 -0
  29. package/lib/core/plugin/types.d.ts.map +1 -1
  30. package/lib/core/types.d.ts +51 -2
  31. package/lib/core/types.d.ts.map +1 -1
  32. package/lib/plugins/clipboard/index.js.map +1 -1
  33. package/lib/plugins/column-virtualization/index.js.map +1 -1
  34. package/lib/plugins/context-menu/index.js.map +1 -1
  35. package/lib/plugins/editing/EditingPlugin.d.ts +7 -5
  36. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  37. package/lib/plugins/editing/index.js +379 -278
  38. package/lib/plugins/editing/index.js.map +1 -1
  39. package/lib/plugins/editing/types.d.ts +14 -1
  40. package/lib/plugins/editing/types.d.ts.map +1 -1
  41. package/lib/plugins/export/index.js.map +1 -1
  42. package/lib/plugins/filtering/index.js.map +1 -1
  43. package/lib/plugins/grouping-columns/index.js.map +1 -1
  44. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -0
  45. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  46. package/lib/plugins/grouping-rows/index.js +88 -69
  47. package/lib/plugins/grouping-rows/index.js.map +1 -1
  48. package/lib/plugins/grouping-rows/types.d.ts +17 -0
  49. package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
  50. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +17 -0
  51. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  52. package/lib/plugins/master-detail/index.js +133 -97
  53. package/lib/plugins/master-detail/index.js.map +1 -1
  54. package/lib/plugins/multi-sort/index.js.map +1 -1
  55. package/lib/plugins/pinned-columns/index.js.map +1 -1
  56. package/lib/plugins/pinned-rows/index.js +2 -2
  57. package/lib/plugins/pinned-rows/index.js.map +1 -1
  58. package/lib/plugins/pivot/index.js +2 -2
  59. package/lib/plugins/pivot/index.js.map +1 -1
  60. package/lib/plugins/print/index.js.map +1 -1
  61. package/lib/plugins/reorder/index.js.map +1 -1
  62. package/lib/plugins/responsive/ResponsivePlugin.d.ts +13 -0
  63. package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
  64. package/lib/plugins/responsive/index.js +65 -49
  65. package/lib/plugins/responsive/index.js.map +1 -1
  66. package/lib/plugins/row-reorder/index.js.map +1 -1
  67. package/lib/plugins/selection/index.js.map +1 -1
  68. package/lib/plugins/server-side/index.js.map +1 -1
  69. package/lib/plugins/tree/index.js.map +1 -1
  70. package/lib/plugins/undo-redo/index.js.map +1 -1
  71. package/lib/plugins/visibility/index.js.map +1 -1
  72. package/package.json +1 -1
  73. package/umd/grid.all.umd.js +25 -23
  74. package/umd/grid.all.umd.js.map +1 -1
  75. package/umd/grid.umd.js +18 -16
  76. package/umd/grid.umd.js.map +1 -1
  77. package/umd/plugins/editing.umd.js +1 -1
  78. package/umd/plugins/editing.umd.js.map +1 -1
  79. package/umd/plugins/grouping-rows.umd.js +2 -2
  80. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  81. package/umd/plugins/master-detail.umd.js +1 -1
  82. package/umd/plugins/master-detail.umd.js.map +1 -1
  83. package/umd/plugins/responsive.umd.js +1 -1
  84. package/umd/plugins/responsive.umd.js.map +1 -1
package/umd/grid.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(v,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(v=typeof globalThis<"u"?globalThis:v||self,z(v.TbwGrid={}))})(this,(function(v){"use strict";const z={STRETCH:"stretch",FIXED:"fixed"},Ce={mode:"reduced-motion",duration:200,easing:"ease-out"},ye='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',M={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:ye,filterActive:ye,print:"🖨️"};function at(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const i=o.getAttribute("field")||"";if(!i)return null;const n=o.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),c=o.hasAttribute("editable"),d={field:i,type:s,header:l,sortable:a,editable:c},u=o.getAttribute("width");if(u){const b=parseFloat(u);!isNaN(b)&&/^\d+(\.\d+)?$/.test(u.trim())?d.width=b:d.width=u}const g=o.getAttribute("minWidth")||o.getAttribute("min-width");if(g){const b=parseFloat(g);isNaN(b)||(d.minWidth=b)}o.hasAttribute("resizable")&&(d.resizable=!0),o.hasAttribute("sizable")&&(d.resizable=!0);const f=o.getAttribute("editor"),p=o.getAttribute("renderer");f&&(d.__editorName=f),p&&(d.__rendererName=p);const h=o.getAttribute("options");h&&(d.options=h.split(",").map(b=>{const[I,A]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:I.trim(),label:A?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),C=o.querySelector("tbw-grid-column-editor"),R=o.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),C&&(d.__editorTemplate=C),R&&(d.__headerTemplate=R);const E=globalThis.DataGridElement?.getAdapters?.()??[],P=w??o,m=E.find(b=>b.canHandle(P));if(m){const b=m.createRenderer(P);b&&(d.viewRenderer=b)}const S=C??o,_=E.find(b=>b.canHandle(S));if(_){const b=_.createEditor(S);b&&(d.editor=b)}return d}).filter(o=>!!o)}function _e(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(n=>{const r=o[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else o[n.field]={...n}});const i=t.map(n=>{const r=o[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete o[n.field],s});return Object.keys(o).forEach(n=>i.push(o[n])),i}function Ee(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function Se(t){const e=t.effectiveConfig?.fitMode||t.fitMode||z.STRETCH;if(e!==z.STRETCH&&e!==z.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let i=!1;t._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=o[r];let l=s?s.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&V(t),t.__didInitialAutoSize=!0}function V(t){(t.effectiveConfig?.fitMode||t.fitMode||z.STRETCH)===z.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const i=o.minWidth;return i!=null?`minmax(${i}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function ct(t){return t==null?"string":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date||typeof t=="string"&&/\d{4}-\d{2}-\d{2}/.test(t)&&!isNaN(Date.parse(t))?"date":"string"}function dt(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=ct(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return i.forEach(r=>{n[r.field]=r.type||"string"}),{columns:i,typeMap:n}}const ht=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",ut=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,ft=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;function gt(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const pt=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),Re=/^on\w+$/i,wt=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),bt=/^\s*(javascript|vbscript|data|blob):/i;function $(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,mt(e.content),e.innerHTML}function mt(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(pt.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>Re.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(i);continue}const r=[];for(const s of i.attributes){const l=s.name.toLowerCase();if(Re.test(l)){r.push(s.name);continue}if(wt.has(l)&&bt.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>i.removeAttribute(s))}e.forEach(i=>i.remove())}function Ae(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(ht,(l,a)=>{const c=vt(a,e);return o.push({expr:a.trim(),result:c}),c}),n=Ct(i),r=o.length&&o.every(l=>l.result===""||l.result===D);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function vt(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return D;if(t==="value")return e.value==null?D:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(4),n=e.row?e.row[i]:void 0;return n==null?D:String(n)}if(t.length>80||!ut.test(t)||ft.test(t))return D;const o=t.match(/\./g);if(o&&o.length>1)return D;try{const n=new Function("value","row",`return (${t});`)(e.value,e.row),r=n==null?"":String(n);return/Reflect|Proxy|ownKeys/.test(r)?D:r||D}catch{return D}}function Ct(t){return t&&t.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function yt(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function Te(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":Ae(t,i));return o.__blocked=e,o}const _t=100;class Et{#l;#n;#u;#d;#h;#a={};#i={};#f=!0;#g=[];#b;#s;#m;#r;#p;constructor(e){this.#r=e}get original(){return this.#a}get effective(){return this.#i}get columns(){return this.#i.columns??[]}set columns(e){this.#i.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#h}set originalColumnNodes(e){this.#h=e}get lightDomTitle(){return this.#p}set lightDomTitle(e){this.#p=e}get initialColumnState(){return this.#m}set initialColumnState(e){this.#m=e}get sourcesChanged(){return this.#f}markSourcesChanged(){this.#f=!0}setGridConfig(e){this.#l=e,this.#f=!0,this.#d=void 0}getGridConfig(){return this.#l}setColumns(e){this.#n=e,this.#f=!0}getColumns(){return this.#n}setFitMode(e){this.#u=e,this.#f=!0}getFitMode(){return this.#u}merge(){const e=(this.#i.columns?.length??0)>0;if(!this.#f&&e)return;const o=this.#C();this.#f=!1,this.#a=o,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#i=this.#A(this.#a),this.#D()}#A(e){const o={...e};return e.columns&&(o.columns=e.columns.map(i=>({...i}))),e.shell&&(o.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(i=>({...i})),headerContents:e.shell.headerContents?.map(i=>({...i}))}),o}#D(){const e=this.#i;this.#w(),e.rowHeight&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#r.applyAnimationConfig(e)}#w(){const e=this.#i.typeDefaults;if(!e)return;const o=this.columns;for(const i of o){if(!i.type)continue;const n=e[i.type];n&&(!i.renderer&&!i.viewRenderer&&n.renderer&&(i.renderer=n.renderer),!i.format&&n.format&&(i.format=n.format),!i.editor&&n.editor&&(i.editor=n.editor),!i.editorParams&&n.editorParams&&(i.editorParams=n.editorParams))}}#C(){const e=this.#l?{...this.#l}:{},o=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#d??[]).map(s=>({...s}));let n=_e(o,i);this.#n&&this.#n.length&&(n=_e(this.#n,i));const r=this.#r.getRows();return n.length===0&&r.length&&(n=dt(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=Te(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Te(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#y(e),e.columnState&&!this.#m&&(this.#m=e.columnState),e}#y(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#p=o),this.#p&&!e.shell.header.title&&(e.shell.header.title=this.#p);const i=this.#r.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#r.getShellToolPanels();if(n.size>0){const u=Array.from(n.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.toolPanels=u}const r=this.#r.getShellHeaderContents();if(r.size>0){const u=Array.from(r.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.headerContents=u}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),a=this.#l?.shell?.header?.toolbarContents??[],c=new Set(a.map(u=>u.id)),d=[...a];for(const u of l)c.has(u.id)||d.push(u);d.sort((u,g)=>(u.order??0)-(g.order??0)),e.shell.header.toolbarContents=d}collectState(e){const o=this.columns,i=this.#v();return{columns:o.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=i.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,o){if(!e.columns||e.columns.length===0)return;const i=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=i.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of o)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#m=void 0,this.#r.setSortState(null),this.#i=this.#A(this.#a),this.#D();for(const o of e)if(o.applyColumnState)for(const i of this.columns)o.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange(e)}#v(){const e=new Map,o=this.#r.getSortState();return o&&e.set(o.field,{direction:o.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0;const o=this.collectState(e);this.#r.emit("column-state-change",o)},_t)}setColumnVisible(e,o){const i=this.columns,n=i.find(s=>s.field===e);return!n||!o&&n.lockVisible||!o&&i.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!o?!1:(n.hidden=!o,this.#r.emit("column-visibility",{field:e,visible:o,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const o=this.columns.find(i=>i.field===e);return o?this.setColumnVisible(e,!!o.hidden):!1}isColumnVisible(e){const o=this.columns.find(i=>i.field===e);return o?!o.hidden:!1}showAllColumns(){const e=this.columns;e.some(o=>o.hidden)&&(e.forEach(o=>o.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(o=>o.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const o=new Map(this.columns.map(n=>[n.field,n])),i=[];for(const n of e){const r=o.get(n);r&&(i.push(r),o.delete(n))}for(const n of o.values())i.push(n);this.columns=i,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#h=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#h.length?at(e):[])}clearLightDomCache(){this.#d=void 0}#_=new Map;registerLightDomHandler(e,o){this.#_.set(e.toLowerCase(),o)}unregisterLightDomHandler(e){this.#_.delete(e.toLowerCase())}observeLightDOM(e){this.#b&&this.#b.disconnect();const o=new Set;let i=null;const n=()=>{i=null;for(const r of o)this.#_.get(r)?.();o.clear()};this.#b=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#_.has(c)&&o.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#_.has(a)&&o.add(a)}}o.size>0&&!i&&(i=setTimeout(n,0))}),this.#b.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#g.push(e)}notifyChange(){for(const e of this.#g)e()}dispose(){this.#b?.disconnect(),this.#g=[],this.#s&&clearTimeout(this.#s)}}function xe(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"&#x1F5F9;":"&#9744;"}</span>`}function Pe(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function Le(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const o=t.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function St(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function se(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Rt(t){try{if(getComputedStyle(t).direction==="rtl")return"rtl"}catch{}try{if(t.closest?.("[dir]")?.getAttribute("dir")==="rtl")return"rtl"}catch{}return"ltr"}function He(t){return Rt(t)==="rtl"}function De(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const n=i.getTypeDefault(e.type);if(n?.renderer)return n.renderer}}function Oe(t,e){if(e.format)return e.format;if(!e.type)return;const o=t.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(e.type);if(i?.format)return i.format}}const ze='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function le(t){return(t.__editingCellCount??0)>0}function ae(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const Me=document.createElement("template");Me.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ne=document.createElement("template");Ne.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function At(){return Me.content.firstElementChild.cloneNode(!0)}function Tt(){return Ne.content.firstElementChild.cloneNode(!0)}function K(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function xt(t,e,o,i,n){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,a=l.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const g=Tt();t._rowPool.push(g)}if(t._rowPool.length>r){for(let g=r;g<t._rowPool.length;g++){const f=t._rowPool[g];f.parentNode===s&&f.remove()}t._rowPool.length=r}const d=n&&t.__hasRenderRowPlugins!==!1,u=t._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const f=e+g,p=t._rows[f],h=t._rowPool[g];if(h.setAttribute("aria-rowindex",String(f+c+1)),d&&n(p,h,f)){h.__epoch=i,h.__rowDataRef=p,h.parentNode!==s&&s.appendChild(h);continue}const w=h.__epoch,C=h.__rowDataRef,R=h.children.length,E=w===i&&R===a,P=C!==p;let m=!1;if(E&&P){for(let A=0;A<a;A++)if(l[A].externalView&&!h.querySelector(`.cell[data-col="${A}"] [data-external-view]`)){m=!0;break}}if(!E||m){const A=le(h),T=t._activeEditRows===f;A&&!T?(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),ae(h),B(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):A&&T?(ce(t,h,p,f),h.__rowDataRef=p):(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),B(t,h,p,f),h.__epoch=i,h.__rowDataRef=p)}else if(P){const A=le(h),T=t._activeEditRows===f;A&&!T?(ae(h),B(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):(ce(t,h,p,f),h.__rowDataRef=p)}else{const A=le(h),T=t._activeEditRows===f;A&&!T?(ae(h),B(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):ce(t,h,p,f)}let S=!1;const _=t.changedRowIds;if(_&&_.length>0)try{const A=t.getRowId?.(p);A&&(S=_.includes(A))}catch{}const b=h.classList.contains("changed");S!==b&&h.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const A=h.getAttribute("data-dynamic-classes");A&&A.split(" ").forEach(T=>T&&h.classList.remove(T));try{const T=I(p);if(T&&T.length>0){const ve=T.filter(re=>re&&typeof re=="string");ve.forEach(re=>h.classList.add(re)),h.setAttribute("data-dynamic-classes",ve.join(" "))}else h.removeAttribute("data-dynamic-classes")}catch(T){console.warn("[tbw-grid] rowClass callback error:",T),h.removeAttribute("data-dynamic-classes")}}u&&t._afterRowRender?.({row:p,rowIndex:f,rowElement:h}),h.parentNode!==s&&s.appendChild(h)}}function ce(t,e,o,i){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=t._focusRow,d=t._focusCol,u=t._hasAfterCellRenderHook?.()??!1;let g=t.__hasSpecialColumns;if(g===void 0){g=!1;const p=t.__frameworkAdapter;for(let h=0;h<s;h++){const w=r[h];if(w.__viewTemplate||w.__compiledView||w.renderer||w.viewRenderer||w.externalView||w.format||w.type==="date"||w.type==="boolean"||w.type&&p?.getTypeDefault?.(w.type)?.renderer||w.type&&p?.getTypeDefault?.(w.type)?.format){g=!0;break}}t.__hasSpecialColumns=g}const f=String(i);if(!g){for(let p=0;p<a;p++){const h=n[p];if(h.classList.contains("editing"))continue;const w=r[p],C=o[w.field];h.textContent=C==null?"":String(C),h.getAttribute("data-row")!==f&&h.setAttribute("data-row",f);const R=c===i&&d===p,y=h.classList.contains("cell-focus");R!==y&&(h.classList.toggle("cell-focus",R),h.setAttribute("aria-selected",String(R))),u&&t._afterCellRender?.({row:o,rowIndex:i,column:w,colIndex:p,value:C,cellElement:h,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){B(t,e,o,i);return}for(let p=0;p<a;p++){const h=r[p],w=n[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const C=c===i&&d===p,R=w.classList.contains("cell-focus");C!==R&&(w.classList.toggle("cell-focus",C),w.setAttribute("aria-selected",String(C)));const y=h.cellClass;if(y){const _=w.getAttribute("data-dynamic-classes");_&&_.split(" ").forEach(b=>b&&w.classList.remove(b));try{const b=o[h.field],I=y(b,o,h);if(I&&I.length>0){const A=I.filter(T=>T&&typeof T=="string");A.forEach(T=>w.classList.add(T)),w.setAttribute("data-dynamic-classes",A.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(b){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,b),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const E=De(t,h);if(E){const _=o[h.field],b=E({row:o,value:_,field:h.field,column:h,cellEl:w});typeof b=="string"?w.innerHTML=$(b):b instanceof Node?b.parentElement!==w&&(w.innerHTML="",w.appendChild(b)):b==null&&(w.textContent=_==null?"":String(_)),u&&t._afterCellRender?.({row:o,rowIndex:i,column:h,colIndex:p,value:_,cellElement:w,rowElement:e});continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const P=o[h.field];let m;const S=Oe(t,h);if(S){try{const _=S(P,o);m=_==null?"":String(_)}catch(_){console.warn(`[tbw-grid] Format error in column '${h.field}':`,_),m=P==null?"":String(P)}w.textContent=m}else h.type==="date"?(m=Pe(P),w.textContent=m):h.type==="boolean"?w.innerHTML=xe(!!P):(m=P==null?"":String(P),w.textContent=m);u&&t._afterCellRender?.({row:o,rowIndex:i,column:h,colIndex:p,value:P,cellElement:w,rowElement:e})}}function B(t,e,o,i){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,a=t,c=t._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let u=0;u<r;u++){const g=n[u],f=At();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(i)),f.setAttribute("data-field",g.field),f.setAttribute("data-header",g.header??g.field),g.type&&f.setAttribute("data-type",g.type);let p=o[g.field];const h=Oe(t,g);if(h)try{p=h(p,o)}catch(m){console.warn(`[tbw-grid] Format error in column '${g.field}':`,m)}const w=g.__compiledView,C=g.__viewTemplate,R=De(t,g),y=g.externalView;let E=!1;if(R){const m=R({row:o,value:p,field:g.field,column:g,cellEl:f});typeof m=="string"?(f.innerHTML=$(m),E=!0):m instanceof Node?m.parentElement!==f&&(f.textContent="",f.appendChild(m)):m==null&&(f.textContent=p==null?"":String(p))}else if(y){const m=y,S=document.createElement("div");S.setAttribute("data-external-view",""),S.setAttribute("data-field",g.field),f.appendChild(S);const _={row:o,value:p,field:g.field,column:g};if(m.mount)try{m.mount({placeholder:S,context:_,spec:m})}catch(b){console.warn(`[tbw-grid] External view mount error for column '${g.field}':`,b)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:m,context:_}}))}catch(b){console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`,b)}});S.setAttribute("data-mounted","")}else if(w){const m=w({row:o,value:p,field:g.field,column:g}),S=w.__blocked;f.innerHTML=S?"":$(m),E=!0,S&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(C){const m=C.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(m)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=$(Ae(m,{row:o,value:p})),E=!0)}else h?f.textContent=p==null?"":String(p):g.type==="date"?f.textContent=Pe(p):g.type==="boolean"?f.innerHTML=xe(!!p):f.textContent=p==null?"":String(p);if(E){yt(f);const m=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(m)&&(f.textContent=m.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(f.textContent||"")&&(f.textContent=""))}f.hasAttribute("data-blocked-template")&&(f.textContent||"").trim().length&&(f.textContent=""),g.editable?f.tabIndex=0:g.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===i&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false");const P=g.cellClass;if(P)try{const m=o[g.field],S=P(m,o,g);if(S&&S.length>0){const _=S.filter(b=>b&&typeof b=="string");_.forEach(b=>f.classList.add(b)),f.setAttribute("data-dynamic-classes",_.join(" "))}}catch(m){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,m)}c&&t._afterCellRender?.({row:o,rowIndex:i,column:g,colIndex:u,value:p,cellElement:f,rowElement:e}),d.appendChild(f)}e.appendChild(d)}function ke(t,e,o){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]"),n=Le(i);if(n<0)return;const r=t._rows[n];if(!r||t._dispatchRowClick?.(e,n,r,o))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,n,l,s))return;const a=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){a&&(se(t._bodyEl??t),s.classList.add("cell-focus"));const c=s.querySelector(ze);try{c?.focus({preventScroll:!0})}catch{}return}W(t)}}}function Pt(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,i=t._visibleColumns.length-1,n=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const u=d.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<i?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<o&&(t._focusRow+=1,t._focusCol=0)):t._focusCol>0?t._focusCol-=1:t._focusRow>0&&(typeof t.commitActiveRowEdit=="function"&&t._activeEditRows===t._focusRow&&t.commitActiveRowEdit(),t._focusRow-=1,t._focusCol=i),W(t);return}case"ArrowDown":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":{He(t)?t._focusCol=Math.max(0,t._focusCol-1):t._focusCol=Math.min(i,t._focusCol+1),e.preventDefault();break}case"ArrowLeft":{He(t)?t._focusCol=Math.min(i,t._focusCol+1):t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break}case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),W(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=i,e.preventDefault(),W(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":{const d=t._focusRow,u=t._focusCol,g=t._visibleColumns[u],f=t._rows[d],p=g?.field??"",h=p&&f?f[p]:void 0,w=t.querySelector(`[data-row="${d}"][data-col="${u}"]`),C={rowIndex:d,colIndex:u,field:p,value:h,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},R=new CustomEvent("cell-activate",{cancelable:!0,detail:C});t.dispatchEvent(R);const y=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:u}});if(t.dispatchEvent(y),R.defaultPrevented||y.defaultPrevented){e.preventDefault();return}break}default:return}W(t)}}function W(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=t._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const u=t._focusRow*s;u<c.scrollTop?c.scrollTop=u:u+s>c.scrollTop+d&&(c.scrollTop=u-d+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),se(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const i=t._focusRow,n=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(i>=n&&i<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[i-n];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.querySelector(".tbw-scroll-area");if(a&&l&&(!o||e?.forceHorizontalScroll))if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),u=a.getBoundingClientRect(),g=d.left-u.left+a.scrollLeft,f=g+d.width,p=a.scrollLeft+c.left,h=a.scrollLeft+a.clientWidth-c.right;g<p?a.scrollLeft=g-c.left:f>h&&(a.scrollLeft=f-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(ze);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Q=new WeakMap;function Lt(t,e){const o=Le(e),i=St(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,se(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function de(t,e,o,i){let n=null;const r=o.composedPath?.();if(r&&r.length>0?n=r[0]:n=o.target,n&&!e.contains(n)){const h=document.elementFromPoint(o.clientX,o.clientY);h&&(n=h)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,u,g,f,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=t._rows[c],p=t._columns[d],g=p?.field,f=u&&g?u[g]:void 0)),{type:i,row:u,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:g,value:f,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Ht(t,e,o){const i=de(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(i)??!1)&&Q.set(t,!0)}function Dt(t,e,o){if(!Q.get(t))return;const i=de(t,e,o,"mousemove");t._dispatchCellMouseMove?.(i)}function Ot(t,e,o){if(!Q.get(t))return;const i=de(t,e,o,"mouseup");t._dispatchCellMouseUp?.(i),Q.set(t,!1)}function zt(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||Lt(t,n))},{signal:o}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&&ke(t,i,n)},{signal:o}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&&ke(t,i,n)},{signal:o})}function Mt(t,e,o,i){e.addEventListener("keydown",n=>Pt(t,n),{signal:i}),o.addEventListener("mousedown",n=>Ht(t,o,n),{signal:i}),document.addEventListener("mousemove",n=>Dt(t,o,n),{signal:i}),document.addEventListener("mouseup",n=>Ot(t,o,n),{signal:i})}function Ie(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function qe(t,e,o){const n=o.find(l=>l.field===e.field)?.sortComparator??Ie,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function $e(t,e,o,i){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),oe(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:i}})),t.requestStateChange?.()}function We(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Fe(t,e,1)):t._sortState.direction===1?Fe(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),t._rows=t.__originalOrder.slice(),oe(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(i=>{i.getAttribute("aria-sort")?(i.getAttribute("aria-sort")==="ascending"||i.getAttribute("aria-sort")==="descending")&&(t._sortState||i.setAttribute("aria-sort","none")):i.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Fe(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??qe)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{$e(t,l,e,o)}):$e(t,s,e,o)}function X(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Z(t,e){return t.effectiveConfig?.resizable!==!1&&e.resizable!==!1}function Nt(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function J(t,e){const o=document.createElement("span");Ee(o,"sort-indicator");const i=t._sortState?.field===e.field?t._sortState.direction:0,n={...M,...t.icons},r=i===1?n.sortAsc:i===-1?n.sortDesc:n.sortNone;return Nt(o,r),o}function ee(t,e,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.start(n,e,o)}),i.addEventListener("dblclick",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.resetColumn(e)}),i}function te(t,e,o,i){i.classList.add("sortable"),i.tabIndex=0;const n=t._sortState?.field===e.field?t._sortState.direction:0;i.setAttribute("aria-sort",n===0?"none":n===1?"ascending":"descending"),i.addEventListener("click",r=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(r,o,i)||We(t,e)}),i.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,o,i))return;We(t,e)}})}function kt(t,e){if(e!=null)if(typeof e=="string"){const o=document.createElement("span");for(o.innerHTML=$(e);o.firstChild;)t.appendChild(o.firstChild)}else e instanceof Node&&t.appendChild(e)}function oe(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",Ee(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i));const r=o.header??o.field,s=t._sortState?.field===o.field?t._sortState.direction:0,l=s===1?"asc":s===-1?"desc":null;if(o.headerRenderer){const a={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>X(t,o)?J(t,o):null,renderFilterButton:()=>null},c=o.headerRenderer(a);kt(n,c),X(t,o)&&te(t,o,i,n),Z(t,o)&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)))}else if(o.headerLabelRenderer){const a={column:o,value:r},c=o.headerLabelRenderer(a),d=document.createElement("span");c==null?d.textContent=r:typeof c=="string"?d.innerHTML=$(c):c instanceof Node&&d.appendChild(c),n.appendChild(d),X(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),Z(t,o)&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(a=>n.appendChild(a.cloneNode(!0))),X(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),Z(t,o)&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)));else{const a=document.createElement("span");a.textContent=r,n.appendChild(a),X(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),Z(t,o)&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)))}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const Ue=typeof requestIdleCallback=="function";function It(t,e){return Ue?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function Ge(t){Ue?cancelIdleCallback(t):clearTimeout(t)}function qt(t){const e=document.createElement("div");return e.className=`tbw-spinner tbw-spinner--${t}`,e.setAttribute("role","progressbar"),e.setAttribute("aria-label","Loading"),e}function $t(t,e){if(e){const i=e({size:t});if(typeof i=="string"){const n=document.createElement("div");return n.innerHTML=i,n}return i}return qt(t)}function Wt(t){const e=document.createElement("div");return e.className="tbw-loading-overlay",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.appendChild($t("large",t)),e}function Ft(t,e){t.appendChild(e)}function Ut(t){t?.remove()}function Gt(t,e){e?(t.classList.add("tbw-row-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy"))}function Vt(t,e){e?(t.classList.add("tbw-cell-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-cell-loading"),t.removeAttribute("aria-busy"))}var x=(t=>(t[t.STYLE=1]="STYLE",t[t.VIRTUALIZATION=2]="VIRTUALIZATION",t[t.HEADER=3]="HEADER",t[t.ROWS=4]="ROWS",t[t.COLUMNS=5]="COLUMNS",t[t.FULL=6]="FULL",t))(x||{});class Bt{#l;#n=0;#u=0;#d=null;#h=null;#a=null;#i=!1;constructor(e){this.#l=e}requestPhase(e,o){e>this.#n&&(this.#n=e),this.#u===0&&(this.#f(),this.#u=requestAnimationFrame(()=>this.#g()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){this.#u!==0&&(cancelAnimationFrame(this.#u),this.#u=0),this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null)}get isPending(){return this.#n!==0}get pendingPhase(){return this.#n}#f(){this.#d||(this.#d=new Promise(e=>{this.#h=e}))}#g(){if(this.#u=0,!this.#l.isConnected()){this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null);return}const e=this.#n;this.#n=0,e>=5&&this.#l.mergeConfig(),e>=4&&this.#l.processRows(),e>=5&&(this.#l.processColumns(),this.#l.updateTemplate()),e>=3&&this.#l.renderHeader(),e>=2&&this.#l.renderVirtualWindow(),e>=1&&this.#l.afterRender(),!this.#i&&this.#a&&(this.#i=!0,this.#a()),this.#h&&(this.#h(),this.#h=null,this.#d=null)}}function Ve(t){let e=null,o=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),u=t._visibleColumns[e.colIndex];u.width=d,u.__userResized=!0,u.__renderedWidth=d,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),i!==null&&(document.documentElement.style.cursor=i,i=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const u=t._visibleColumns[c],g=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??g??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:f},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),i===null&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}const he="data-animating",Xt={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Yt={change:500,insert:300,remove:200};function jt(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function Kt(t,e){const o=Xt[e],i=getComputedStyle(t).getPropertyValue(o);if(i){const n=jt(i);if(!isNaN(n)&&n>0)return n}return Yt[e]}function Qt(t,e,o){t.removeAttribute(he),t.offsetWidth,t.setAttribute(he,e);const i=Kt(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(he)},i)}function ue(t,e,o){if(e<0)return!1;const i=t.findRenderedRowElement?.(e);return i?(Qt(i,o),!0):!1}function Zt(t,e,o){let i=0;for(const n of e)ue(t,n,o)&&i++;return i}function Jt(t,e,o){const i=t._rows??[],n=t.getRowId;if(!n)return!1;const r=i.findIndex(s=>n(s)===e);return r<0?!1:ue(t,r,o)}function ie(t,e,o){const i=document.createElement(t);if(e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function H(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const i in e){const n=e[i];n!=null&&o.setAttribute(i,n)}return o}function Be(t,e,o){const i=document.createElement("button");if(t&&(i.className=t),e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}const Xe=document.createElement("template");Xe.innerHTML=`
1
+ (function(y,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(y=typeof globalThis<"u"?globalThis:y||self,F(y.TbwGrid={}))})(this,(function(y){"use strict";function F(){return{rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0}}function ht(t,e,o,i,n){if(i===t.rowCount&&n===t.colCount)return!1;const r=t.rowCount;return t.rowCount=i,t.colCount=n,e&&(e.setAttribute("aria-rowcount",String(i)),e.setAttribute("aria-colcount",String(n))),i!==r&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role")),!0}function ut(t,e){const o=t?.gridAriaLabel;return o||(t?.shell?.header?.title??e?.lightDomTitle??void 0)}function ft(t,e,o,i){if(!e)return!1;let n=!1;const r=ut(o,i);r!==t.ariaLabel&&(t.ariaLabel=r,r?e.setAttribute("aria-label",r):e.removeAttribute("aria-label"),n=!0);const s=o?.gridAriaDescribedBy;return s!==t.ariaDescribedBy&&(t.ariaDescribedBy=s,s?e.setAttribute("aria-describedby",s):e.removeAttribute("aria-describedby"),n=!0),n}const q={STRETCH:"stretch",FIXED:"fixed"},Ee={mode:"reduced-motion",duration:200,easing:"ease-out"},Se='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',O={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:Se,filterActive:Se,print:"🖨️"};function gt(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const i=o.getAttribute("field")||"";if(!i)return null;const n=o.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),c=o.hasAttribute("editable"),d={field:i,type:s,header:l,sortable:a,editable:c},f=o.getAttribute("width");if(f){const b=parseFloat(f);!isNaN(b)&&/^\d+(\.\d+)?$/.test(f.trim())?d.width=b:d.width=f}const u=o.getAttribute("minWidth")||o.getAttribute("min-width");if(u){const b=parseFloat(u);isNaN(b)||(d.minWidth=b)}o.hasAttribute("resizable")&&(d.resizable=!0),o.hasAttribute("sizable")&&(d.resizable=!0);const g=o.getAttribute("editor"),p=o.getAttribute("renderer");g&&(d.__editorName=g),p&&(d.__rendererName=p);const h=o.getAttribute("options");h&&(d.options=h.split(",").map(b=>{const[I,R]=b.includes(":")?b.split(":"):[b.trim(),b.trim()];return{value:I.trim(),label:R?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),m=o.querySelector("tbw-grid-column-editor"),C=o.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),m&&(d.__editorTemplate=m),C&&(d.__headerTemplate=C);const P=globalThis.DataGridElement?.getAdapters?.()??[],H=w??o,v=P.find(b=>b.canHandle(H));if(v){const b=v.createRenderer(H);b&&(d.viewRenderer=b)}const S=m??o,E=P.find(b=>b.canHandle(S));if(E){const b=E.createEditor(S);b&&(d.editor=b)}return d}).filter(o=>!!o)}function Re(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(n=>{const r=o[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else o[n.field]={...n}});const i=t.map(n=>{const r=o[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete o[n.field],s});return Object.keys(o).forEach(n=>i.push(o[n])),i}function Ae(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function Te(t){const e=t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH;if(e!==q.STRETCH&&e!==q.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let i=!1;t._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=o[r];let l=s?s.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&U(t),t.__didInitialAutoSize=!0}function U(t){(t.effectiveConfig?.fitMode||t.fitMode||q.STRETCH)===q.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const i=o.minWidth;return i!=null?`minmax(${i}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function pt(t){return t==null?"string":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date||typeof t=="string"&&/\d{4}-\d{2}-\d{2}/.test(t)&&!isNaN(Date.parse(t))?"date":"string"}function wt(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=pt(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return i.forEach(r=>{n[r.field]=r.type||"string"}),{columns:i,typeMap:n}}const bt=/{{\s*([^}]+)\s*}}/g,z="__DG_EMPTY__",mt=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,vt=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;function Ct(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const yt=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),xe=/^on\w+$/i,_t=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Et=/^\s*(javascript|vbscript|data|blob):/i;function $(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,St(e.content),e.innerHTML}function St(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(yt.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>xe.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(i);continue}const r=[];for(const s of i.attributes){const l=s.name.toLowerCase();if(xe.test(l)){r.push(s.name);continue}if(_t.has(l)&&Et.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>i.removeAttribute(s))}e.forEach(i=>i.remove())}function Pe(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(bt,(l,a)=>{const c=Rt(a,e);return o.push({expr:a.trim(),result:c}),c}),n=At(i),r=o.length&&o.every(l=>l.result===""||l.result===z);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function Rt(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return z;if(t==="value")return e.value==null?z:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(4),n=e.row?e.row[i]:void 0;return n==null?z:String(n)}if(t.length>80||!mt.test(t)||vt.test(t))return z;const o=t.match(/\./g);if(o&&o.length>1)return z;try{const n=new Function("value","row",`return (${t});`)(e.value,e.row),r=n==null?"":String(n);return/Reflect|Proxy|ownKeys/.test(r)?z:r||z}catch{return z}}function At(t){return t&&t.replace(new RegExp(z,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Tt(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function He(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":Pe(t,i));return o.__blocked=e,o}const xt=100;class Pt{#l;#n;#u;#d;#h;#a={};#i={};#f=!0;#p=[];#v;#s;#C;#r;#w;constructor(e){this.#r=e}get original(){return this.#a}get effective(){return this.#i}get columns(){return this.#i.columns??[]}set columns(e){this.#i.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#h}set originalColumnNodes(e){this.#h=e}get lightDomTitle(){return this.#w}set lightDomTitle(e){this.#w=e}get initialColumnState(){return this.#C}set initialColumnState(e){this.#C=e}get sourcesChanged(){return this.#f}markSourcesChanged(){this.#f=!0}setGridConfig(e){this.#l=e,this.#f=!0,this.#d=void 0}getGridConfig(){return this.#l}setColumns(e){this.#n=e,this.#f=!0}getColumns(){return this.#n}setFitMode(e){this.#u=e,this.#f=!0}getFitMode(){return this.#u}merge(){const e=(this.#i.columns?.length??0)>0;if(!this.#f&&e)return;const o=this.#k();this.#f=!1,this.#a=o,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#i=this.#A(this.#a),this.#m()}#A(e){const o={...e};return e.columns&&(o.columns=e.columns.map(i=>({...i}))),e.shell&&(o.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(i=>({...i})),headerContents:e.shell.headerContents?.map(i=>({...i}))}),o}#m(){const e=this.#i;this.#z(),typeof e.rowHeight=="number"&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#r.applyAnimationConfig(e)}#z(){const e=this.#i.typeDefaults;if(!e)return;const o=this.columns;for(const i of o){if(!i.type)continue;const n=e[i.type];n&&(!i.renderer&&!i.viewRenderer&&n.renderer&&(i.renderer=n.renderer),!i.format&&n.format&&(i.format=n.format),!i.editor&&n.editor&&(i.editor=n.editor),!i.editorParams&&n.editorParams&&(i.editorParams=n.editorParams))}}#k(){const e=this.#l?{...this.#l}:{},o=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#d??[]).map(s=>({...s}));let n=Re(o,i);this.#n&&this.#n.length&&(n=Re(this.#n,i));const r=this.#r.getRows();return n.length===0&&r.length&&(n=wt(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=He(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=He(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#b(e),e.columnState&&!this.#C&&(this.#C=e.columnState),e}#b(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#w=o),this.#w&&!e.shell.header.title&&(e.shell.header.title=this.#w);const i=this.#r.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#r.getShellToolPanels();if(n.size>0){const f=Array.from(n.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.toolPanels=f}const r=this.#r.getShellHeaderContents();if(r.size>0){const f=Array.from(r.values());f.sort((u,g)=>(u.order??100)-(g.order??100)),e.shell.headerContents=f}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),a=this.#l?.shell?.header?.toolbarContents??[],c=new Set(a.map(f=>f.id)),d=[...a];for(const f of l)c.has(f.id)||d.push(f);d.sort((f,u)=>(f.order??0)-(u.order??0)),e.shell.header.toolbarContents=d}collectState(e){const o=this.columns,i=this.#y();return{columns:o.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=i.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,o){if(!e.columns||e.columns.length===0)return;const i=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=i.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of o)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#C=void 0,this.#r.setSortState(null),this.#i=this.#A(this.#a),this.#m();for(const o of e)if(o.applyColumnState)for(const i of this.columns)o.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange(e)}#y(){const e=new Map,o=this.#r.getSortState();return o&&e.set(o.field,{direction:o.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#s&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0;const o=this.collectState(e);this.#r.emit("column-state-change",o)},xt)}setColumnVisible(e,o){const i=this.columns,n=i.find(s=>s.field===e);return!n||!o&&n.lockVisible||!o&&i.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!o?!1:(n.hidden=!o,this.#r.emit("column-visibility",{field:e,visible:o,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const o=this.columns.find(i=>i.field===e);return o?this.setColumnVisible(e,!!o.hidden):!1}isColumnVisible(e){const o=this.columns.find(i=>i.field===e);return o?!o.hidden:!1}showAllColumns(){const e=this.columns;e.some(o=>o.hidden)&&(e.forEach(o=>o.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(o=>o.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const o=new Map(this.columns.map(n=>[n.field,n])),i=[];for(const n of e){const r=o.get(n);r&&(i.push(r),o.delete(n))}for(const n of o.values())i.push(n);this.columns=i,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#h=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#h.length?gt(e):[])}clearLightDomCache(){this.#d=void 0}#g=new Map;registerLightDomHandler(e,o){this.#g.set(e.toLowerCase(),o)}unregisterLightDomHandler(e){this.#g.delete(e.toLowerCase())}observeLightDOM(e){this.#v&&this.#v.disconnect();const o=new Set;let i=null;const n=()=>{i=null;for(const r of o)this.#g.get(r)?.();o.clear()};this.#v=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#g.has(c)&&o.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#g.has(a)&&o.add(a)}}o.size>0&&!i&&(i=setTimeout(n,0))}),this.#v.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#p.push(e)}notifyChange(){for(const e of this.#p)e()}dispose(){this.#v?.disconnect(),this.#p=[],this.#s&&clearTimeout(this.#s)}}function re(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function Le(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"&#x1F5F9;":"&#9744;"}</span>`}function ze(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function De(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const o=t.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function Ht(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function se(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Lt(t){try{if(getComputedStyle(t).direction==="rtl")return"rtl"}catch{}try{if(t.closest?.("[dir]")?.getAttribute("dir")==="rtl")return"rtl"}catch{}return"ltr"}function Oe(t){return Lt(t)==="rtl"}function Me(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const n=i.getTypeDefault(e.type);if(n?.renderer)return n.renderer}}function ke(t,e){if(e.format)return e.format;if(!e.type)return;const o=t.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(e.type);if(i?.format)return i.format}}const Ie='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function le(t){return(t.__editingCellCount??0)>0}function ae(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const Ne=document.createElement("template");Ne.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const qe=document.createElement("template");qe.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function zt(){return Ne.content.firstElementChild.cloneNode(!0)}function Dt(){return qe.content.firstElementChild.cloneNode(!0)}function j(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function Ot(t,e,o,i,n){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,a=l.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const u=Dt();t._rowPool.push(u)}if(t._rowPool.length>r){for(let u=r;u<t._rowPool.length;u++){const g=t._rowPool[u];g.parentNode===s&&g.remove()}t._rowPool.length=r}const d=n&&t.__hasRenderRowPlugins!==!1,f=t._hasAfterRowRenderHook?.()??!1;for(let u=0;u<r;u++){const g=e+u,p=t._rows[g],h=t._rowPool[u];if(h.setAttribute("aria-rowindex",String(g+c+1)),d&&n(p,h,g)){h.__epoch=i,h.__rowDataRef=p,h.parentNode!==s&&s.appendChild(h);continue}const w=h.__epoch,m=h.__rowDataRef,C=h.children.length,P=w===i&&C===a,H=m!==p;let v=!1;if(P&&H){for(let R=0;R<a;R++)if(l[R].externalView&&!h.querySelector(`.cell[data-col="${R}"] [data-external-view]`)){v=!0;break}}if(!P||v){const R=le(h),A=t._activeEditRows===g;R&&!A?(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),ae(h),G(t,h,p,g),h.__epoch=i,h.__rowDataRef=p):R&&A?(ce(t,h,p,g),h.__rowDataRef=p):(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),G(t,h,p,g),h.__epoch=i,h.__rowDataRef=p)}else if(H){const R=le(h),A=t._activeEditRows===g;R&&!A?(ae(h),G(t,h,p,g),h.__epoch=i,h.__rowDataRef=p):(ce(t,h,p,g),h.__rowDataRef=p)}else{const R=le(h),A=t._activeEditRows===g;R&&!A?(ae(h),G(t,h,p,g),h.__epoch=i,h.__rowDataRef=p):ce(t,h,p,g)}let S=!1;const E=t.changedRowIds;if(E&&E.length>0)try{const R=t.getRowId?.(p);R&&(S=E.includes(R))}catch{}const b=h.classList.contains("changed");S!==b&&h.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const R=h.getAttribute("data-dynamic-classes");R&&R.split(" ").forEach(A=>A&&h.classList.remove(A));try{const A=I(p);if(A&&A.length>0){const _e=A.filter(ne=>ne&&typeof ne=="string");_e.forEach(ne=>h.classList.add(ne)),h.setAttribute("data-dynamic-classes",_e.join(" "))}else h.removeAttribute("data-dynamic-classes")}catch(A){console.warn("[tbw-grid] rowClass callback error:",A),h.removeAttribute("data-dynamic-classes")}}f&&t._afterRowRender?.({row:p,rowIndex:g,rowElement:h}),h.parentNode!==s&&s.appendChild(h)}}function ce(t,e,o,i){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=t._focusRow,d=t._focusCol,f=t._hasAfterCellRenderHook?.()??!1;let u=t.__hasSpecialColumns;if(u===void 0){u=!1;const p=t.__frameworkAdapter;for(let h=0;h<s;h++){const w=r[h];if(w.__viewTemplate||w.__compiledView||w.renderer||w.viewRenderer||w.externalView||w.format||w.type==="date"||w.type==="boolean"||w.type&&p?.getTypeDefault?.(w.type)?.renderer||w.type&&p?.getTypeDefault?.(w.type)?.format){u=!0;break}}t.__hasSpecialColumns=u}const g=String(i);if(!u){for(let p=0;p<a;p++){const h=n[p];if(h.classList.contains("editing"))continue;const w=r[p],m=o[w.field];h.textContent=m==null?"":String(m),h.getAttribute("data-row")!==g&&h.setAttribute("data-row",g);const C=c===i&&d===p,_=h.classList.contains("cell-focus");C!==_&&(h.classList.toggle("cell-focus",C),h.setAttribute("aria-selected",String(C))),f&&t._afterCellRender?.({row:o,rowIndex:i,column:w,colIndex:p,value:m,cellElement:h,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){G(t,e,o,i);return}for(let p=0;p<a;p++){const h=r[p],w=n[p];w.getAttribute("data-row")!==g&&w.setAttribute("data-row",g);const m=c===i&&d===p,C=w.classList.contains("cell-focus");m!==C&&(w.classList.toggle("cell-focus",m),w.setAttribute("aria-selected",String(m)));const _=h.cellClass;if(_){const E=w.getAttribute("data-dynamic-classes");E&&E.split(" ").forEach(b=>b&&w.classList.remove(b));try{const b=o[h.field],I=_(b,o,h);if(I&&I.length>0){const R=I.filter(A=>A&&typeof A=="string");R.forEach(A=>w.classList.add(A)),w.setAttribute("data-dynamic-classes",R.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(b){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,b),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const P=Me(t,h);if(P){const E=o[h.field],b=P({row:o,value:E,field:h.field,column:h,cellEl:w});typeof b=="string"?w.innerHTML=$(b):b instanceof Node?b.parentElement!==w&&(w.innerHTML="",w.appendChild(b)):b==null&&(w.textContent=E==null?"":String(E)),f&&t._afterCellRender?.({row:o,rowIndex:i,column:h,colIndex:p,value:E,cellElement:w,rowElement:e});continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const H=o[h.field];let v;const S=ke(t,h);if(S){try{const E=S(H,o);v=E==null?"":String(E)}catch(E){console.warn(`[tbw-grid] Format error in column '${h.field}':`,E),v=H==null?"":String(H)}w.textContent=v}else h.type==="date"?(v=ze(H),w.textContent=v):h.type==="boolean"?w.innerHTML=Le(!!H):(v=H==null?"":String(H),w.textContent=v);f&&t._afterCellRender?.({row:o,rowIndex:i,column:h,colIndex:p,value:H,cellElement:w,rowElement:e})}}function G(t,e,o,i){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,a=t,c=t._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let f=0;f<r;f++){const u=n[f],g=zt();g.setAttribute("aria-colindex",String(f+1)),g.setAttribute("data-col",String(f)),g.setAttribute("data-row",String(i)),g.setAttribute("data-field",u.field),g.setAttribute("data-header",u.header??u.field),u.type&&g.setAttribute("data-type",u.type);let p=o[u.field];const h=ke(t,u);if(h)try{p=h(p,o)}catch(v){console.warn(`[tbw-grid] Format error in column '${u.field}':`,v)}const w=u.__compiledView,m=u.__viewTemplate,C=Me(t,u),_=u.externalView;let P=!1;if(C){const v=C({row:o,value:p,field:u.field,column:u,cellEl:g});typeof v=="string"?(g.innerHTML=$(v),P=!0):v instanceof Node?v.parentElement!==g&&(g.textContent="",g.appendChild(v)):v==null&&(g.textContent=p==null?"":String(p))}else if(_){const v=_,S=document.createElement("div");S.setAttribute("data-external-view",""),S.setAttribute("data-field",u.field),g.appendChild(S);const E={row:o,value:p,field:u.field,column:u};if(v.mount)try{v.mount({placeholder:S,context:E,spec:v})}catch(b){console.warn(`[tbw-grid] External view mount error for column '${u.field}':`,b)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:v,context:E}}))}catch(b){console.warn(`[tbw-grid] External view event dispatch error for column '${u.field}':`,b)}});S.setAttribute("data-mounted","")}else if(w){const v=w({row:o,value:p,field:u.field,column:u}),S=w.__blocked;g.innerHTML=S?"":$(v),P=!0,S&&(g.textContent="",g.setAttribute("data-blocked-template",""))}else if(m){const v=m.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(v)?(g.textContent="",g.setAttribute("data-blocked-template","")):(g.innerHTML=$(Pe(v,{row:o,value:p})),P=!0)}else h?g.textContent=p==null?"":String(p):u.type==="date"?g.textContent=ze(p):u.type==="boolean"?g.innerHTML=Le(!!p):g.textContent=p==null?"":String(p);if(P){Tt(g);const v=g.textContent||"";/Proxy|Reflect\.ownKeys/.test(v)&&(g.textContent=v.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(g.textContent||"")&&(g.textContent=""))}g.hasAttribute("data-blocked-template")&&(g.textContent||"").trim().length&&(g.textContent=""),u.editable?g.tabIndex=0:u.type==="boolean"&&(g.hasAttribute("tabindex")||(g.tabIndex=0)),s===i&&l===f?(g.classList.add("cell-focus"),g.setAttribute("aria-selected","true")):g.setAttribute("aria-selected","false");const H=u.cellClass;if(H)try{const v=o[u.field],S=H(v,o,u);if(S&&S.length>0){const E=S.filter(b=>b&&typeof b=="string");E.forEach(b=>g.classList.add(b)),g.setAttribute("data-dynamic-classes",E.join(" "))}}catch(v){console.warn(`[tbw-grid] cellClass callback error for column '${u.field}':`,v)}c&&t._afterCellRender?.({row:o,rowIndex:i,column:u,colIndex:f,value:p,cellElement:g,rowElement:e}),d.appendChild(g)}e.appendChild(d)}function $e(t,e,o){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]"),n=De(i);if(n<0)return;const r=t._rows[n];if(!r||t._dispatchRowClick?.(e,n,r,o))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,n,l,s))return;const a=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){a&&(se(t._bodyEl??t),s.classList.add("cell-focus"));const c=s.querySelector(Ie);try{c?.focus({preventScroll:!0})}catch{}return}W(t)}}}function Mt(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,i=t._visibleColumns.length-1,n=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const f=d.tagName;return!!(f==="INPUT"||f==="SELECT"||f==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<i?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<o&&(t._focusRow+=1,t._focusCol=0)):t._focusCol>0?t._focusCol-=1:t._focusRow>0&&(typeof t.commitActiveRowEdit=="function"&&t._activeEditRows===t._focusRow&&t.commitActiveRowEdit(),t._focusRow-=1,t._focusCol=i),W(t);return}case"ArrowDown":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":{Oe(t)?t._focusCol=Math.max(0,t._focusCol-1):t._focusCol=Math.min(i,t._focusCol+1),e.preventDefault();break}case"ArrowLeft":{Oe(t)?t._focusCol=Math.min(i,t._focusCol+1):t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break}case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),W(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=i,e.preventDefault(),W(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":{const d=t._focusRow,f=t._focusCol,u=t._visibleColumns[f],g=t._rows[d],p=u?.field??"",h=p&&g?g[p]:void 0,w=t.querySelector(`[data-row="${d}"][data-col="${f}"]`),m={rowIndex:d,colIndex:f,field:p,value:h,row:g,cellEl:w,trigger:"keyboard",originalEvent:e},C=new CustomEvent("cell-activate",{cancelable:!0,detail:m});t.dispatchEvent(C);const _=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:f}});if(t.dispatchEvent(_),C.defaultPrevented||_.defaultPrevented){e.preventDefault();return}break}default:return}W(t)}}function W(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=t._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const f=t._focusRow*s;f<c.scrollTop?c.scrollTop=f:f+s>c.scrollTop+d&&(c.scrollTop=f-d+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),se(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const i=t._focusRow,n=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(i>=n&&i<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[i-n];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.querySelector(".tbw-scroll-area");if(a&&l&&(!o||e?.forceHorizontalScroll))if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),f=a.getBoundingClientRect(),u=d.left-f.left+a.scrollLeft,g=u+d.width,p=a.scrollLeft+c.left,h=a.scrollLeft+a.clientWidth-c.right;u<p?a.scrollLeft=u-c.left:g>h&&(a.scrollLeft=g-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(Ie);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const K=new WeakMap;function kt(t,e){const o=De(e),i=Ht(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,se(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function de(t,e,o,i){let n=null;const r=o.composedPath?.();if(r&&r.length>0?n=r[0]:n=o.target,n&&!e.contains(n)){const h=document.elementFromPoint(o.clientX,o.clientY);h&&(n=h)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,f,u,g,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(f=t._rows[c],p=t._columns[d],u=p?.field,g=f&&u?f[u]:void 0)),{type:i,row:f,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:u,value:g,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function It(t,e,o){const i=de(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(i)??!1)&&K.set(t,!0)}function Nt(t,e,o){if(!K.get(t))return;const i=de(t,e,o,"mousemove");t._dispatchCellMouseMove?.(i)}function qt(t,e,o){if(!K.get(t))return;const i=de(t,e,o,"mouseup");t._dispatchCellMouseUp?.(i),K.set(t,!1)}function $t(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||kt(t,n))},{signal:o}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&&$e(t,i,n)},{signal:o}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&&$e(t,i,n)},{signal:o})}function Wt(t,e,o,i){e.addEventListener("keydown",n=>Mt(t,n),{signal:i}),o.addEventListener("mousedown",n=>It(t,o,n),{signal:i}),document.addEventListener("mousemove",n=>Nt(t,o,n),{signal:i}),document.addEventListener("mouseup",n=>qt(t,o,n),{signal:i})}function We(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Fe(t,e,o){const n=o.find(l=>l.field===e.field)?.sortComparator??We,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function Ue(t,e,o,i){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),te(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:i}})),t.requestStateChange?.()}function Ge(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Ve(t,e,1)):t._sortState.direction===1?Ve(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),t._rows=t.__originalOrder.slice(),te(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(i=>{i.getAttribute("aria-sort")?(i.getAttribute("aria-sort")==="ascending"||i.getAttribute("aria-sort")==="descending")&&(t._sortState||i.setAttribute("aria-sort","none")):i.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Ve(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??Fe)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{Ue(t,l,e,o)}):Ue(t,s,e,o)}function V(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Q(t,e){return t.effectiveConfig?.resizable!==!1&&e.resizable!==!1}function Ft(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function Z(t,e){const o=document.createElement("span");Ae(o,"sort-indicator");const i=t._sortState?.field===e.field?t._sortState.direction:0,n={...O,...t.icons},r=i===1?n.sortAsc:i===-1?n.sortDesc:n.sortNone;return Ft(o,r),o}function J(t,e,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.start(n,e,o)}),i.addEventListener("dblclick",n=>{n.stopPropagation(),n.preventDefault(),t._resizeController.resetColumn(e)}),i}function ee(t,e,o,i){i.classList.add("sortable"),i.tabIndex=0;const n=t._sortState?.field===e.field?t._sortState.direction:0;i.setAttribute("aria-sort",n===0?"none":n===1?"ascending":"descending"),i.addEventListener("click",r=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(r,o,i)||Ge(t,e)}),i.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,o,i))return;Ge(t,e)}})}function Ut(t,e){if(e!=null)if(typeof e=="string"){const o=document.createElement("span");for(o.innerHTML=$(e);o.firstChild;)t.appendChild(o.firstChild)}else e instanceof Node&&t.appendChild(e)}function te(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",Ae(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i));const r=o.header??o.field,s=t._sortState?.field===o.field?t._sortState.direction:0,l=s===1?"asc":s===-1?"desc":null;if(o.headerRenderer){const a={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>V(t,o)?Z(t,o):null,renderFilterButton:()=>null},c=o.headerRenderer(a);Ut(n,c),V(t,o)&&ee(t,o,i,n),Q(t,o)&&(n.classList.add("resizable"),n.appendChild(J(t,i,n)))}else if(o.headerLabelRenderer){const a={column:o,value:r},c=o.headerLabelRenderer(a),d=document.createElement("span");c==null?d.textContent=r:typeof c=="string"?d.innerHTML=$(c):c instanceof Node&&d.appendChild(c),n.appendChild(d),V(t,o)&&(ee(t,o,i,n),n.appendChild(Z(t,o))),Q(t,o)&&(n.classList.add("resizable"),n.appendChild(J(t,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(a=>n.appendChild(a.cloneNode(!0))),V(t,o)&&(ee(t,o,i,n),n.appendChild(Z(t,o))),Q(t,o)&&(n.classList.add("resizable"),n.appendChild(J(t,i,n)));else{const a=document.createElement("span");a.textContent=r,n.appendChild(a),V(t,o)&&(ee(t,o,i,n),n.appendChild(Z(t,o))),Q(t,o)&&(n.classList.add("resizable"),n.appendChild(J(t,i,n)))}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const Be=typeof requestIdleCallback=="function";function Gt(t,e){return Be?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function Xe(t){Be?cancelIdleCallback(t):clearTimeout(t)}function Vt(t){const e=document.createElement("div");return e.className=`tbw-spinner tbw-spinner--${t}`,e.setAttribute("role","progressbar"),e.setAttribute("aria-label","Loading"),e}function Bt(t,e){if(e){const i=e({size:t});if(typeof i=="string"){const n=document.createElement("div");return n.innerHTML=i,n}return i}return Vt(t)}function Xt(t){const e=document.createElement("div");return e.className="tbw-loading-overlay",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.appendChild(Bt("large",t)),e}function Yt(t,e){t.appendChild(e)}function jt(t){t?.remove()}function Kt(t,e){e?(t.classList.add("tbw-row-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy"))}function Qt(t,e){e?(t.classList.add("tbw-cell-loading"),t.setAttribute("aria-busy","true")):(t.classList.remove("tbw-cell-loading"),t.removeAttribute("aria-busy"))}var T=(t=>(t[t.STYLE=1]="STYLE",t[t.VIRTUALIZATION=2]="VIRTUALIZATION",t[t.HEADER=3]="HEADER",t[t.ROWS=4]="ROWS",t[t.COLUMNS=5]="COLUMNS",t[t.FULL=6]="FULL",t))(T||{});class Zt{#l;#n=0;#u=0;#d=null;#h=null;#a=null;#i=!1;constructor(e){this.#l=e}requestPhase(e,o){e>this.#n&&(this.#n=e),this.#u===0&&(this.#f(),this.#u=requestAnimationFrame(()=>this.#p()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){this.#u!==0&&(cancelAnimationFrame(this.#u),this.#u=0),this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null)}get isPending(){return this.#n!==0}get pendingPhase(){return this.#n}#f(){this.#d||(this.#d=new Promise(e=>{this.#h=e}))}#p(){if(this.#u=0,!this.#l.isConnected()){this.#n=0,this.#h&&(this.#h(),this.#h=null,this.#d=null);return}const e=this.#n;this.#n=0,e>=5&&this.#l.mergeConfig(),e>=4&&this.#l.processRows(),e>=5&&(this.#l.processColumns(),this.#l.updateTemplate()),e>=3&&this.#l.renderHeader(),e>=2&&this.#l.renderVirtualWindow(),e>=1&&this.#l.afterRender(),!this.#i&&this.#a&&(this.#i=!0,this.#a()),this.#h&&(this.#h(),this.#h=null,this.#d=null)}}function Ye(t){let e=null,o=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),f=t._visibleColumns[e.colIndex];f.width=d,f.__userResized=!0,f.__renderedWidth=d,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:f.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),i!==null&&(document.documentElement.style.cursor=i,i=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const f=t._visibleColumns[c],u=typeof f?.width=="number"?f.width:void 0,g=f?.__renderedWidth??u??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:g},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),i===null&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}const he="data-animating",Jt={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},eo={change:500,insert:300,remove:200};function to(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function oo(t,e){const o=Jt[e],i=getComputedStyle(t).getPropertyValue(o);if(i){const n=to(i);if(!isNaN(n)&&n>0)return n}return eo[e]}function io(t,e,o){t.removeAttribute(he),t.offsetWidth,t.setAttribute(he,e);const i=oo(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(he)},i)}function ue(t,e,o){if(e<0)return!1;const i=t.findRenderedRowElement?.(e);return i?(io(i,o),!0):!1}function no(t,e,o){let i=0;for(const n of e)ue(t,n,o)&&i++;return i}function ro(t,e,o){const i=t._rows??[],n=t.getRowId;if(!n)return!1;const r=i.findIndex(s=>n(s)===e);return r<0?!1:ue(t,r,o)}function oe(t,e,o){const i=document.createElement(t);if(e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function L(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const i in e){const n=e[i];n!=null&&o.setAttribute(i,n)}return o}function je(t,e,o){const i=document.createElement("button");if(t&&(i.className=t),e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}const Ke=document.createElement("template");Ke.innerHTML=`
2
2
  <div class="tbw-scroll-area">
3
3
  <div class="rows-body-wrapper">
4
4
  <div class="rows-body" role="grid">
@@ -16,23 +16,23 @@
16
16
  <div class="faux-vscroll">
17
17
  <div class="faux-vscroll-spacer"></div>
18
18
  </div>
19
- `;function Ye(){return Xe.content.cloneNode(!0)}function je(t){const e=document.createDocumentFragment(),o=H(t.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(t.hasShell&&t.shellHeader&&t.shellBody)o.appendChild(t.shellHeader),o.appendChild(t.shellBody);else{const i=H("tbw-grid-content");i.appendChild(Ye()),o.appendChild(i)}return e.appendChild(o),e}function eo(t){const e=H("tbw-shell-header",{part:"shell-header",role:"presentation"});if(t.title){const r=H("tbw-shell-title");r.textContent=t.title,e.appendChild(r)}const o=H("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});e.appendChild(o);const i=H("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of t.configButtons)r.hasRender&&i.appendChild(H("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of t.apiButtons)r.hasRender&&i.appendChild(H("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((t.configButtons.some(r=>r.hasRender)||t.apiButtons.some(r=>r.hasRender))&&t.hasPanels&&i.appendChild(H("tbw-toolbar-separator")),t.hasPanels){const r=Be(t.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(t.isPanelOpen),"aria-controls":"tbw-tool-panel"});r.innerHTML=t.toolPanelIcon,i.appendChild(r)}return e.appendChild(i),e}function to(t){const e=H("tbw-shell-body"),o=t.panels.length>0,i=t.panels.length===1,n=H("tbw-grid-content");n.appendChild(Ye());let r=null;if(o){r=ie("aside",{class:t.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":t.position,role:"presentation",id:"tbw-tool-panel"});const s=t.position==="left"?"right":"left";r.appendChild(H("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=H("tbw-tool-panel-content",{role:"presentation"}),a=H("tbw-accordion");for(const c of t.panels){const d=`tbw-accordion-section${c.isExpanded?" expanded":""}${i?" single":""}`,u=H(d,{"data-section":c.id}),g=Be("tbw-accordion-header",{"aria-expanded":String(c.isExpanded),"aria-controls":`tbw-section-${c.id}`});if(i&&g.setAttribute("aria-disabled","true"),c.icon){const p=ie("span",{class:"tbw-accordion-icon"});p.innerHTML=c.icon,g.appendChild(p)}const f=ie("span",{class:"tbw-accordion-title"});if(f.textContent=c.title,g.appendChild(f),!i){const p=ie("span",{class:"tbw-accordion-chevron"});p.innerHTML=c.isExpanded?t.collapseIcon:t.expandIcon,g.appendChild(p)}u.appendChild(g),u.appendChild(H("tbw-accordion-content",{id:`tbw-section-${c.id}`,role:"presentation"})),a.appendChild(u)}l.appendChild(a),r.appendChild(l)}return t.position==="left"&&r?(e.appendChild(r),e.appendChild(n)):(e.appendChild(n),r&&e.appendChild(r)),e}function q(t){return t?typeof t=="string"?t:t.outerHTML:""}function oo(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}function Ke(t){return!!(t?.header?.title||t?.header?.toolbarContents?.length||t?.toolPanels?.length||t?.headerContents?.length||t?.header?.lightDomContent?.length||t?.header?.hasToolButtonsContainer)}function Qe(t,e,o="☰"){const i=t?.header?.title??e.lightDomTitle??"",n=!!i,r=q(o),s=t?.header?.toolbarContents??[],l=[...e.toolbarContents.values()],a=new Set(s.map(h=>h.id)),c=[...s];for(const h of l)a.has(h.id)||c.push(h);const d=c.length>0,u=e.toolPanels.size>0,g=d&&u,f=[...c].sort((h,w)=>(h.order??0)-(w.order??0));let p="";for(const h of f)p+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${h.id}"></div>`;if(g&&(p+='<div class="tbw-toolbar-separator"></div>'),u){const h=e.isPanelOpen;p+=`<button class="${h?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${h}" aria-controls="tbw-tool-panel">${r}</button>`}return`
19
+ `;function Qe(){return Ke.content.cloneNode(!0)}function Ze(t){const e=document.createDocumentFragment(),o=L(t.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(t.hasShell&&t.shellHeader&&t.shellBody)o.appendChild(t.shellHeader),o.appendChild(t.shellBody);else{const i=L("tbw-grid-content");i.appendChild(Qe()),o.appendChild(i)}return e.appendChild(o),e}function so(t){const e=L("tbw-shell-header",{part:"shell-header",role:"presentation"});if(t.title){const r=L("tbw-shell-title");r.textContent=t.title,e.appendChild(r)}const o=L("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});e.appendChild(o);const i=L("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of t.configButtons)r.hasRender&&i.appendChild(L("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of t.apiButtons)r.hasRender&&i.appendChild(L("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((t.configButtons.some(r=>r.hasRender)||t.apiButtons.some(r=>r.hasRender))&&t.hasPanels&&i.appendChild(L("tbw-toolbar-separator")),t.hasPanels){const r=je(t.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(t.isPanelOpen),"aria-controls":"tbw-tool-panel"});r.innerHTML=t.toolPanelIcon,i.appendChild(r)}return e.appendChild(i),e}function lo(t){const e=L("tbw-shell-body"),o=t.panels.length>0,i=t.panels.length===1,n=L("tbw-grid-content");n.appendChild(Qe());let r=null;if(o){r=oe("aside",{class:t.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":t.position,role:"presentation",id:"tbw-tool-panel"});const s=t.position==="left"?"right":"left";r.appendChild(L("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=L("tbw-tool-panel-content",{role:"presentation"}),a=L("tbw-accordion");for(const c of t.panels){const d=`tbw-accordion-section${c.isExpanded?" expanded":""}${i?" single":""}`,f=L(d,{"data-section":c.id}),u=je("tbw-accordion-header",{"aria-expanded":String(c.isExpanded),"aria-controls":`tbw-section-${c.id}`});if(i&&u.setAttribute("aria-disabled","true"),c.icon){const p=oe("span",{class:"tbw-accordion-icon"});p.innerHTML=c.icon,u.appendChild(p)}const g=oe("span",{class:"tbw-accordion-title"});if(g.textContent=c.title,u.appendChild(g),!i){const p=oe("span",{class:"tbw-accordion-chevron"});p.innerHTML=c.isExpanded?t.collapseIcon:t.expandIcon,u.appendChild(p)}f.appendChild(u),f.appendChild(L("tbw-accordion-content",{id:`tbw-section-${c.id}`,role:"presentation"})),a.appendChild(f)}l.appendChild(a),r.appendChild(l)}return t.position==="left"&&r?(e.appendChild(r),e.appendChild(n)):(e.appendChild(n),r&&e.appendChild(r)),e}function N(t){return t?typeof t=="string"?t:t.outerHTML:""}function ao(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}function Je(t){return!!(t?.header?.title||t?.header?.toolbarContents?.length||t?.toolPanels?.length||t?.headerContents?.length||t?.header?.lightDomContent?.length||t?.header?.hasToolButtonsContainer)}function co(t,e,o="☰"){const i=t?.header?.title??e.lightDomTitle??"",n=!!i,r=N(o),s=t?.header?.toolbarContents??[],l=[...e.toolbarContents.values()],a=new Set(s.map(h=>h.id)),c=[...s];for(const h of l)a.has(h.id)||c.push(h);const d=c.length>0,f=e.toolPanels.size>0,u=d&&f,g=[...c].sort((h,w)=>(h.order??0)-(w.order??0));let p="";for(const h of g)p+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${h.id}"></div>`;if(u&&(p+='<div class="tbw-toolbar-separator"></div>'),f){const h=e.isPanelOpen;p+=`<button class="${h?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${h}" aria-controls="tbw-tool-panel">${r}</button>`}return`
20
20
  <div class="tbw-shell-header" part="shell-header" role="presentation">
21
- ${n?`<div class="tbw-shell-title">${gt(i)}</div>`:""}
21
+ ${n?`<div class="tbw-shell-title">${Ct(i)}</div>`:""}
22
22
  <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>
23
23
  <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
24
24
  ${p}
25
25
  </div>
26
26
  </div>
27
- `}function F(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const n=o.getAttribute("title");n&&(e.lightDomTitle=n)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function U(t,e,o){const i=t.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;e.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:(s=>{for(;i.firstChild;)s.appendChild(i.firstChild)})};e.toolbarContents.set(n,r),e.lightDomToolbarContentIds.add(n),i.style.display="none"}function G(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(n=>{const r=n,s=r.getAttribute("id"),l=r.getAttribute("title");if(!s||!l){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s??""}", title="${l??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,d=parseInt(r.getAttribute("order")??"100",10);let u;const g=o?.(r);if(g)u=g;else{const h=r.innerHTML.trim();u=w=>{const C=document.createElement("div");return C.innerHTML=h,w.appendChild(C),()=>C.remove()}}const f=e.toolPanels.get(s);if(f){if(g){f.render=u,f.order=d,f.icon=a,f.tooltip=c;const h=e.panelCleanups.get(s);h&&(h(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:a,tooltip:c,order:d,render:u};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function io(t,e,o,i){const n=t.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){i.onPanelToggle();return}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const d=a.closest("[data-section]")?.getAttribute("data-section");d&&i.onSectionToggle(d)}})}function no(t,e,o){const i=t.querySelector(".tbw-tool-panel"),n=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let a=0,c=0,d=0,u=!1;const g=h=>{if(!u)return;h.preventDefault();const w=s==="left"?h.clientX-a:a-h.clientX,C=Math.min(d,Math.max(l,c+w));i.style.width=`${C}px`},f=()=>{if(!u)return;u=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const h=i.getBoundingClientRect().width;o(h),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)},p=h=>{h.preventDefault(),u=!0,a=h.clientX,c=i.getBoundingClientRect().width,d=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)};return n.addEventListener("mousedown",p),()=>{n.removeEventListener("mousedown",p),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)}}function Ze(t,e,o){const i=e?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(l=>l.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id)||!l.render)continue;const a=t.querySelector(`[data-toolbar-content="${l.id}"]`);if(!a)continue;const c=l.render(a);c&&o.toolbarContentCleanups.set(l.id,c)}}function fe(t,e){const o=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,i=e.headerContents.size>0;if(!o&&!i)return;const n=t.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const s of e.lightDomHeaderContent)s.style.display="",n.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let a=n.querySelector(`[data-header-content="${s.id}"]`);a||(a=document.createElement("div"),a.setAttribute("data-header-content",s.id),n.appendChild(a));const c=s.render(a);c&&e.headerContentCleanups.set(s.id,c)}}function ro(t,e,o){if(!e.isPanelOpen)return;const i=q(o?.expand??M.expand),n=q(o?.collapse??M.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),a=t.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",l);const d=a.querySelector(".tbw-accordion-header");d&&d.setAttribute("aria-expanded",String(l));const u=a.querySelector(".tbw-accordion-chevron");if(u&&(u.innerHTML=l?n:i),l){if(c.children.length===0){const g=s.render(c);g&&e.panelCleanups.set(r,g)}}else{const g=e.panelCleanups.get(r);g&&(g(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function Je(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function et(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function so(t){for(const e of t.headerContentCleanups.values())e();t.headerContentCleanups.clear();for(const e of t.panelCleanups.values())e();t.panelCleanups.clear();for(const e of t.toolbarContentCleanups.values())e();t.toolbarContentCleanups.clear();for(const e of t.toolbarContents.values())e.onDestroy?.();if(t.isPanelOpen)for(const e of t.expandedSections)t.toolPanels.get(e)?.onClose?.();t.isPanelOpen=!1,t.expandedSections.clear(),t.toolPanels.clear(),t.headerContents.clear(),t.toolbarContents.clear(),t.lightDomHeaderContent=[],t.lightDomToolPanelIds.clear(),t.lightDomToolbarContentIds.clear(),t.lightDomContentMoved=!1}function lo(t,e){let o=!1;const i={get isInitialized(){return o},setInitialized(n){o=n},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const s=[...t.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];s&&t.expandedSections.add(s.id)}const n=e.getShadow();Je(n,t),et(n,t),ro(n,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const n=e.getShadow();Je(n,t),et(n,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(n){const r=t.toolPanels.get(n);if(!r){console.warn(`[tbw-grid] Tool panel section "${n}" not found`);return}if(t.toolPanels.size===1)return;const s=e.getShadow(),l=t.expandedSections.has(n);if(l){const a=t.panelCleanups.get(n);a&&(a(),t.panelCleanups.delete(n)),r.onClose?.(),t.expandedSections.delete(n),ge(s,n,!1)}else{for(const[a,c]of t.toolPanels)if(a!==n&&t.expandedSections.has(a)){const d=t.panelCleanups.get(a);d&&(d(),t.panelCleanups.delete(a)),c.onClose?.(),t.expandedSections.delete(a),ge(s,a,!1);const u=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);u&&(u.innerHTML="")}t.expandedSections.add(n),ge(s,n,!0),ao(s,t,n)}e.emit("tool-panel-section-toggle",{id:n,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(n){if(t.toolPanels.has(n.id)){console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);return}t.toolPanels.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolPanel(n){if(t.expandedSections.has(n)){const r=t.panelCleanups.get(n);r&&(r(),t.panelCleanups.delete(n)),t.expandedSections.delete(n)}t.toolPanels.delete(n),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(n){if(t.headerContents.has(n.id)){console.warn(`[tbw-grid] Header content "${n.id}" already registered`);return}t.headerContents.set(n.id,n),o&&fe(e.getShadow(),t)},unregisterHeaderContent(n){const r=t.headerContentCleanups.get(n);r&&(r(),t.headerContentCleanups.delete(n)),t.headerContents.get(n)?.onDestroy?.(),t.headerContents.delete(n),e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove()},getToolbarContents(){return[...t.toolbarContents.values()].sort((n,r)=>(n.order??0)-(r.order??0))},registerToolbarContent(n){if(t.toolbarContents.has(n.id)){console.warn(`[tbw-grid] Toolbar content "${n.id}" already registered`);return}t.toolbarContents.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolbarContent(n){const r=t.toolbarContentCleanups.get(n);r&&(r(),t.toolbarContentCleanups.delete(n));const s=t.toolbarContents.get(n);s?.onDestroy&&s.onDestroy(),t.toolbarContents.delete(n),o&&e.refreshShellHeader()}};return i}function ge(t,e,o){const i=t.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",o)}function ao(t,e,o){const i=e.toolPanels.get(o);if(!i?.render)return;const n=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&e.panelCleanups.set(o,r)}function co(t,e,o,i){const n=Ke(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)t.querySelectorAll(`:scope > ${l}`).forEach(c=>r.push(c));t.replaceChildren();for(const l of r)t.appendChild(l);if(n){const l=q(i?.toolPanel??M.toolPanel),a=q(i?.expand??M.expand),c=q(i?.collapse??M.collapse),u=[...e?.header?.toolbarContents??[]].sort((y,E)=>(y.order??0)-(E.order??0)),f=[...e?.toolPanels??[]].sort((y,E)=>(y.order??100)-(E.order??100)),p={title:e?.header?.title??void 0,hasPanels:f.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:l,configButtons:u.map(y=>({id:y.id,hasElement:!1,hasRender:!!y.render})),apiButtons:[]},h={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:a,collapseIcon:c,panels:f.map(y=>({id:y.id,title:y.title,icon:q(y.icon),isExpanded:o.expandedSections.has(y.id)}))},w=eo(p),C=to(h),R=je({hasShell:!0,shellHeader:w,shellBody:C});t.appendChild(R)}else{const l=je({hasShell:!1});t.appendChild(l)}return n}const tt="tbw-grid-styles";let ne="";const pe=new Map;function ho(){let t=document.getElementById(tt);return t||(t=document.createElement("style"),t.id=tt,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function we(){const t=ho(),e=Array.from(pe.values()).join(`
28
- `);t.textContent=`${ne}
27
+ `}function et(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const n=o.getAttribute("title");n&&(e.lightDomTitle=n)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function tt(t,e,o){const i=t.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;e.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:(s=>{for(;i.firstChild;)s.appendChild(i.firstChild);return()=>{for(;s.firstChild;)i.appendChild(s.firstChild)}})};e.toolbarContents.set(n,r),e.lightDomToolbarContentIds.add(n),i.style.display="none"}function ot(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(n=>{const r=n,s=r.getAttribute("id"),l=r.getAttribute("title");if(!s||!l){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s??""}", title="${l??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,d=parseInt(r.getAttribute("order")??"100",10);let f;const u=o?.(r);if(u)f=u;else{const h=r.innerHTML.trim();f=w=>{const m=document.createElement("div");return m.innerHTML=h,w.appendChild(m),()=>m.remove()}}const g=e.toolPanels.get(s);if(g){if(u){g.render=f,g.order=d,g.icon=a,g.tooltip=c;const h=e.panelCleanups.get(s);h&&(h(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:a,tooltip:c,order:d,render:f};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function ho(t,e,o,i){const n=t.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){i.onPanelToggle();return}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const d=a.closest("[data-section]")?.getAttribute("data-section");d&&i.onSectionToggle(d)}})}function uo(t,e,o){const i=t.querySelector(".tbw-tool-panel"),n=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let a=0,c=0,d=0,f=!1;const u=h=>{if(!f)return;h.preventDefault();const w=s==="left"?h.clientX-a:a-h.clientX,m=Math.min(d,Math.max(l,c+w));i.style.width=`${m}px`},g=()=>{if(!f)return;f=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const h=i.getBoundingClientRect().width;o(h),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",g)},p=h=>{h.preventDefault(),f=!0,a=h.clientX,c=i.getBoundingClientRect().width,d=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",u),document.addEventListener("mouseup",g)};return n.addEventListener("mousedown",p),()=>{n.removeEventListener("mousedown",p),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",g)}}function fe(t,e,o){const i=e?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(l=>l.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id)||!l.render)continue;const a=t.querySelector(`[data-toolbar-content="${l.id}"]`);if(!a)continue;const c=l.render(a);c&&o.toolbarContentCleanups.set(l.id,c)}}function ge(t,e){const o=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,i=e.headerContents.size>0;if(!o&&!i)return;const n=t.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const s of e.lightDomHeaderContent)s.style.display="",n.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let a=n.querySelector(`[data-header-content="${s.id}"]`);a||(a=document.createElement("div"),a.setAttribute("data-header-content",s.id),n.appendChild(a));const c=s.render(a);c&&e.headerContentCleanups.set(s.id,c)}}function fo(t,e,o){if(!e.isPanelOpen)return;const i=N(o?.expand??O.expand),n=N(o?.collapse??O.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),a=t.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",l);const d=a.querySelector(".tbw-accordion-header");d&&d.setAttribute("aria-expanded",String(l));const f=a.querySelector(".tbw-accordion-chevron");if(f&&(f.innerHTML=l?n:i),l){if(c.children.length===0){const u=s.render(c);u&&e.panelCleanups.set(r,u)}}else{const u=e.panelCleanups.get(r);u&&(u(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function it(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function nt(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function pe(t){for(const e of t.toolbarContentCleanups.values())e();t.toolbarContentCleanups.clear()}function go(t){for(const e of t.headerContentCleanups.values())e();t.headerContentCleanups.clear();for(const e of t.panelCleanups.values())e();t.panelCleanups.clear();for(const e of t.toolbarContentCleanups.values())e();t.toolbarContentCleanups.clear();for(const e of t.toolbarContents.values())e.onDestroy?.();if(t.isPanelOpen)for(const e of t.expandedSections)t.toolPanels.get(e)?.onClose?.();t.isPanelOpen=!1,t.expandedSections.clear(),t.toolPanels.clear(),t.headerContents.clear(),t.toolbarContents.clear(),t.lightDomHeaderContent=[],t.lightDomToolPanelIds.clear(),t.lightDomToolbarContentIds.clear(),t.lightDomContentMoved=!1}function po(t,e){let o=!1;const i={get isInitialized(){return o},setInitialized(n){o=n},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const s=[...t.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];s&&t.expandedSections.add(s.id)}const n=e.getShadow();it(n,t),nt(n,t),fo(n,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const n=e.getShadow();it(n,t),nt(n,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(n){const r=t.toolPanels.get(n);if(!r){console.warn(`[tbw-grid] Tool panel section "${n}" not found`);return}if(t.toolPanels.size===1)return;const s=e.getShadow(),l=t.expandedSections.has(n);if(l){const a=t.panelCleanups.get(n);a&&(a(),t.panelCleanups.delete(n)),r.onClose?.(),t.expandedSections.delete(n),we(s,n,!1)}else{for(const[a,c]of t.toolPanels)if(a!==n&&t.expandedSections.has(a)){const d=t.panelCleanups.get(a);d&&(d(),t.panelCleanups.delete(a)),c.onClose?.(),t.expandedSections.delete(a),we(s,a,!1);const f=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);f&&(f.innerHTML="")}t.expandedSections.add(n),we(s,n,!0),wo(s,t,n)}e.emit("tool-panel-section-toggle",{id:n,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(n){if(t.toolPanels.has(n.id)){console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);return}t.toolPanels.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolPanel(n){if(t.expandedSections.has(n)){const r=t.panelCleanups.get(n);r&&(r(),t.panelCleanups.delete(n)),t.expandedSections.delete(n)}t.toolPanels.delete(n),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(n){if(t.headerContents.has(n.id)){console.warn(`[tbw-grid] Header content "${n.id}" already registered`);return}t.headerContents.set(n.id,n),o&&ge(e.getShadow(),t)},unregisterHeaderContent(n){const r=t.headerContentCleanups.get(n);r&&(r(),t.headerContentCleanups.delete(n)),t.headerContents.get(n)?.onDestroy?.(),t.headerContents.delete(n),e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove()},getToolbarContents(){return[...t.toolbarContents.values()].sort((n,r)=>(n.order??0)-(r.order??0))},registerToolbarContent(n){if(t.toolbarContents.has(n.id)){console.warn(`[tbw-grid] Toolbar content "${n.id}" already registered`);return}t.toolbarContents.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolbarContent(n){const r=t.toolbarContentCleanups.get(n);r&&(r(),t.toolbarContentCleanups.delete(n));const s=t.toolbarContents.get(n);s?.onDestroy&&s.onDestroy(),t.toolbarContents.delete(n),o&&e.refreshShellHeader()}};return i}function we(t,e,o){const i=t.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",o)}function wo(t,e,o){const i=e.toolPanels.get(o);if(!i?.render)return;const n=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&e.panelCleanups.set(o,r)}function bo(t,e,o,i){const n=Je(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)t.querySelectorAll(`:scope > ${l}`).forEach(c=>r.push(c));t.replaceChildren();for(const l of r)t.appendChild(l);if(n){const l=N(i?.toolPanel??O.toolPanel),a=N(i?.expand??O.expand),c=N(i?.collapse??O.collapse),f=[...e?.header?.toolbarContents??[]].sort((_,P)=>(_.order??0)-(P.order??0)),g=[...e?.toolPanels??[]].sort((_,P)=>(_.order??100)-(P.order??100)),p={title:e?.header?.title??void 0,hasPanels:g.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:l,configButtons:f.map(_=>({id:_.id,hasElement:!1,hasRender:!!_.render})),apiButtons:[]},h={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:a,collapseIcon:c,panels:g.map(_=>({id:_.id,title:_.title,icon:N(_.icon),isExpanded:o.expandedSections.has(_.id)}))},w=so(p),m=lo(h),C=Ze({hasShell:!0,shellHeader:w,shellBody:m});t.appendChild(C)}else{const l=Ze({hasShell:!1});t.appendChild(l)}return n}const rt="tbw-grid-styles";let ie="";const be=new Map;function mo(){let t=document.getElementById(rt);return t||(t=document.createElement("style"),t.id=rt,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function me(){const t=mo(),e=Array.from(be.values()).join(`
28
+ `);t.textContent=`${ie}
29
29
 
30
30
  /* Plugin Styles */
31
- ${e}`}function uo(t){let e=!1;for(const{name:o,styles:i}of t)pe.has(o)||(pe.set(o,i),e=!0);return e&&we(),e}function fo(){try{for(const t of Array.from(document.styleSheets))try{const o=Array.from(t.cssRules||[]).map(i=>i.cssText).join(`
32
- `);if(o.includes(".tbw-grid-root")&&o.includes("tbw-grid"))return o}catch{continue}}catch(t){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",t)}return null}async function go(t){if(ne)return;if(typeof t=="string"&&t.length>0){ne=t,we();return}await new Promise(o=>setTimeout(o,50));const e=fo();e?(ne=e,we()):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(o=>o.href||"(inline)"))}function po(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function wo(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function ot(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function bo(t,e,o){if(t.touches.length!==1)return;ot(e);const i=t.touches[0];e.startY=i.clientY,e.startX=i.clientX,e.lastY=i.clientY,e.lastX=i.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function mo(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const i=t.touches[0],n=i.clientY,r=i.clientX,s=performance.now(),l=e.startY-n,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const h=s-e.lastTime;h>0&&(e.velocityY=(e.lastY-n)/h,e.velocityX=(e.lastX-r)/h)}e.lastY=n,e.lastX=r,e.lastTime=s;const{scrollTop:c,scrollHeight:d,clientHeight:u}=o.fauxScrollbar,g=d-u,f=l>0&&c<g||l<0&&c>0;let p=!1;if(o.scrollArea){const{scrollLeft:h,scrollWidth:w,clientWidth:C}=o.scrollArea,R=w-C;p=a>0&&h<R||a<0&&h>0}return f&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),p&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+a),f||p}function vo(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&Co(t,e),wo(t)}function Co(t,e){const n=()=>{t.velocityY*=.95,t.velocityX*=.95;const r=t.velocityY*16,s=t.velocityX*16;Math.abs(t.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(t.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=s),Math.abs(t.velocityY)>.01||Math.abs(t.velocityX)>.01?t.momentumRaf=requestAnimationFrame(n):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(n)}function yo(t,e,o,i){t.addEventListener("touchstart",n=>bo(n,e,o),{passive:!0,signal:i}),t.addEventListener("touchmove",n=>{mo(n,e,o)&&n.preventDefault()},{passive:!1,signal:i}),t.addEventListener("touchend",()=>vo(e,o),{passive:!0,signal:i})}const _o=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:t=>t===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:t=>t==="left"||t==="right"||t==="start"||t==="end"}],Eo=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:t=>Array.isArray(t)&&t.length>0}],So={editing:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",selection:"import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';",reorder:"import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';",clipboard:"import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';",filtering:"import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';",multiSort:"import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';",groupingRows:"import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';",groupingColumns:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",tree:"import { TreePlugin } from '@toolbox-web/grid/plugins/tree';",masterDetail:"import { MasterDetailPlugin } from '@toolbox-web/grid/plugins/master-detail';",pinnedColumns:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",pinnedRows:"import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';",visibility:"import { VisibilityPlugin } from '@toolbox-web/grid/plugins/visibility';",undoRedo:"import { UndoRedoPlugin } from '@toolbox-web/grid/plugins/undo-redo';",export:"import { ExportPlugin } from '@toolbox-web/grid/plugins/export';",contextMenu:"import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';",pivot:"import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';",serverSide:"import { ServerSidePlugin } from '@toolbox-web/grid/plugins/server-side';",columnVirtualization:"import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';"};function be(t){return So[t]??`import { ${N(t)}Plugin } from '@toolbox-web/grid/plugins/${t}';`}function it(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function N(t){return t.charAt(0).toUpperCase()+t.slice(1)}function nt(t,e){return t.some(o=>o.name===e)}function Ro(t,e){const o=_o,i=Eo,n=new Map;function r(l,a,c,d,u=!1){n.has(l)||n.set(l,{description:a,importHint:c,fields:[],isConfigProperty:u});const g=n.get(l);g.fields.includes(d)||g.fields.push(d)}for(const l of i){const a=t[l.property];(l.isUsed?l.isUsed(a):a!==void 0)&&!nt(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??be(l.pluginName),l.property,!0)}const s=t.columns;if(s&&s.length>0)for(const l of s)for(const a of o){const c=l[a.property];if((a.isUsed?a.isUsed(c):c!==void 0)&&!nt(e,a.pluginName)){const u=l.field||"<unknown>";r(a.pluginName,a.description,a.importHint??be(a.pluginName),u)}}if(n.size>0){const l=[];for(const[a,{description:c,importHint:d,fields:u,isConfigProperty:g}]of n)if(g)l.push(`Config uses ${c}, but the required plugin is not loaded.
31
+ ${e}`}function vo(t){let e=!1;for(const{name:o,styles:i}of t)be.has(o)||(be.set(o,i),e=!0);return e&&me(),e}function Co(){try{for(const t of Array.from(document.styleSheets))try{const o=Array.from(t.cssRules||[]).map(i=>i.cssText).join(`
32
+ `);if(o.includes(".tbw-grid-root")&&o.includes("tbw-grid"))return o}catch{continue}}catch(t){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",t)}return null}async function yo(t){if(ie)return;if(typeof t=="string"&&t.length>0){ie=t,me();return}await new Promise(o=>setTimeout(o,50));const e=Co();e?(ie=e,me()):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(o=>o.href||"(inline)"))}function _o(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Eo(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function st(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function So(t,e,o){if(t.touches.length!==1)return;st(e);const i=t.touches[0];e.startY=i.clientY,e.startX=i.clientX,e.lastY=i.clientY,e.lastX=i.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function Ro(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const i=t.touches[0],n=i.clientY,r=i.clientX,s=performance.now(),l=e.startY-n,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const h=s-e.lastTime;h>0&&(e.velocityY=(e.lastY-n)/h,e.velocityX=(e.lastX-r)/h)}e.lastY=n,e.lastX=r,e.lastTime=s;const{scrollTop:c,scrollHeight:d,clientHeight:f}=o.fauxScrollbar,u=d-f,g=l>0&&c<u||l<0&&c>0;let p=!1;if(o.scrollArea){const{scrollLeft:h,scrollWidth:w,clientWidth:m}=o.scrollArea,C=w-m;p=a>0&&h<C||a<0&&h>0}return g&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),p&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+a),g||p}function Ao(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&To(t,e),Eo(t)}function To(t,e){const n=()=>{t.velocityY*=.95,t.velocityX*=.95;const r=t.velocityY*16,s=t.velocityX*16;Math.abs(t.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(t.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=s),Math.abs(t.velocityY)>.01||Math.abs(t.velocityX)>.01?t.momentumRaf=requestAnimationFrame(n):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(n)}function xo(t,e,o,i){t.addEventListener("touchstart",n=>So(n,e,o),{passive:!0,signal:i}),t.addEventListener("touchmove",n=>{Ro(n,e,o)&&n.preventDefault()},{passive:!1,signal:i}),t.addEventListener("touchend",()=>Ao(e,o),{passive:!0,signal:i})}const Po=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:t=>t===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:t=>t==="left"||t==="right"||t==="start"||t==="end"}],Ho=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:t=>Array.isArray(t)&&t.length>0}],Lo={editing:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",selection:"import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';",reorder:"import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';",clipboard:"import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';",filtering:"import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';",multiSort:"import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';",groupingRows:"import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';",groupingColumns:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",tree:"import { TreePlugin } from '@toolbox-web/grid/plugins/tree';",masterDetail:"import { MasterDetailPlugin } from '@toolbox-web/grid/plugins/master-detail';",pinnedColumns:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",pinnedRows:"import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';",visibility:"import { VisibilityPlugin } from '@toolbox-web/grid/plugins/visibility';",undoRedo:"import { UndoRedoPlugin } from '@toolbox-web/grid/plugins/undo-redo';",export:"import { ExportPlugin } from '@toolbox-web/grid/plugins/export';",contextMenu:"import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';",pivot:"import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';",serverSide:"import { ServerSidePlugin } from '@toolbox-web/grid/plugins/server-side';",columnVirtualization:"import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';"};function ve(t){return Lo[t]??`import { ${M(t)}Plugin } from '@toolbox-web/grid/plugins/${t}';`}function M(t){return t.charAt(0).toUpperCase()+t.slice(1)}function lt(t,e){return t.some(o=>o.name===e)}function zo(t,e){const o=Po,i=Ho,n=new Map;function r(l,a,c,d,f=!1){n.has(l)||n.set(l,{description:a,importHint:c,fields:[],isConfigProperty:f});const u=n.get(l);u.fields.includes(d)||u.fields.push(d)}for(const l of i){const a=t[l.property];(l.isUsed?l.isUsed(a):a!==void 0)&&!lt(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??ve(l.pluginName),l.property,!0)}const s=t.columns;if(s&&s.length>0)for(const l of s)for(const a of o){const c=l[a.property];if((a.isUsed?a.isUsed(c):c!==void 0)&&!lt(e,a.pluginName)){const f=l.field||"<unknown>";r(a.pluginName,a.description,a.importHint??ve(a.pluginName),f)}}if(n.size>0){const l=[];for(const[a,{description:c,importHint:d,fields:f,isConfigProperty:u}]of n)if(u)l.push(`Config uses ${c}, but the required plugin is not loaded.
33
33
  → Add the plugin to your gridConfig.plugins array:
34
34
  ${d}
35
- plugins: [new ${a.charAt(0).toUpperCase()+a.slice(1)}Plugin(), ...]`);else{const f=u.slice(0,3).join(", ")+(u.length>3?`, ... (${u.length} total)`:"");l.push(`Column(s) [${f}] use ${c}, but the required plugin is not loaded.
35
+ plugins: [new ${a.charAt(0).toUpperCase()+a.slice(1)}Plugin(), ...]`);else{const g=f.slice(0,3).join(", ")+(f.length>3?`, ... (${f.length} total)`:"");l.push(`Column(s) [${g}] use ${c}, but the required plugin is not loaded.
36
36
  → Add the plugin to your gridConfig.plugins array:
37
37
  ${d}
38
38
  plugins: [new ${a.charAt(0).toUpperCase()+a.slice(1)}Plugin(), ...]`)}throw new Error(`[tbw-grid] Configuration error:
@@ -41,23 +41,25 @@ ${l.join(`
41
41
 
42
42
  `)}
43
43
 
44
- This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function Ao(t){const e=[],o=[];for(const i of t){const r=i.constructor.manifest;if(r?.configRules)for(const s of r.configRules){const l=i.config;if(s.check(l)){const c=`${`[tbw-grid:${N(i.name)}Plugin]`} Configuration warning: ${s.message}`;s.severity==="error"?e.push(c):o.push(c)}}}if(o.length>0&&it())for(const i of o)console.warn(i);if(e.length>0)throw new Error(`[tbw-grid] Configuration error:
44
+ This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function Do(t){const e=[],o=[];for(const i of t){const r=i.constructor.manifest;if(r?.configRules)for(const s of r.configRules){const l=i.config;if(s.check(l)){const c=`${`[tbw-grid:${M(i.name)}Plugin]`} Configuration warning: ${s.message}`;s.severity==="error"?e.push(c):o.push(c)}}}if(o.length>0&&re())for(const i of o)console.warn(i);if(e.length>0)throw new Error(`[tbw-grid] Configuration error:
45
45
 
46
46
  ${e.join(`
47
47
 
48
- `)}`)}function To(t,e){const o=t.name,n=t.constructor.dependencies??[];for(const r of n){const s=r.name,l=r.required??!0,a=r.reason;if(!e.some(d=>d.name===s)){const d=a??`${N(o)}Plugin requires ${N(s)}Plugin`,u=be(s);if(l)throw new Error(`[tbw-grid] Plugin dependency error:
48
+ `)}`)}function Oo(t,e){const o=t.name,n=t.constructor.dependencies??[];for(const r of n){const s=r.name,l=r.required??!0,a=r.reason;if(!e.some(d=>d.name===s)){const d=a??`${M(o)}Plugin requires ${M(s)}Plugin`,f=ve(s);if(l)throw new Error(`[tbw-grid] Plugin dependency error:
49
49
 
50
50
  ${d}.
51
51
 
52
- → Add the plugin to your gridConfig.plugins array BEFORE ${N(o)}Plugin:
53
- ${u}
54
- plugins: [new ${N(s)}Plugin(), new ${N(o)}Plugin()]`);console.info(`[tbw-grid] ${N(o)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function xo(t){if(!it())return;const e=new Set(t.map(i=>i.name)),o=new Set;for(const i of t){const r=i.constructor.manifest;if(r?.incompatibleWith){for(const s of r.incompatibleWith)if(e.has(s.name)){const l=[i.name,s.name].sort().join("↔");if(o.has(l))continue;o.add(l),console.warn(`[tbw-grid] Plugin incompatibility warning:
52
+ → Add the plugin to your gridConfig.plugins array BEFORE ${M(o)}Plugin:
53
+ ${f}
54
+ plugins: [new ${M(s)}Plugin(), new ${M(o)}Plugin()]`);console.info(`[tbw-grid] ${M(o)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function Mo(t){if(!re())return;const e=new Set(t.map(i=>i.name)),o=new Set;for(const i of t){const r=i.constructor.manifest;if(r?.incompatibleWith){for(const s of r.incompatibleWith)if(e.has(s.name)){const l=[i.name,s.name].sort().join("↔");if(o.has(l))continue;o.add(l),console.warn(`[tbw-grid] Plugin incompatibility warning:
55
55
 
56
- ${N(i.name)}Plugin and ${N(s.name)}Plugin are both loaded, but they are currently incompatible.
56
+ ${M(i.name)}Plugin and ${M(s.name)}Plugin are both loaded, but they are currently incompatible.
57
57
 
58
58
  → ${s.reason}
59
59
 
60
- Consider removing one of these plugins to avoid unexpected behavior.`)}}}}class rt{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;eventListeners=new Map;queryHandlers=new Map;attachAll(e){for(const o of e)this.attach(o)}attach(e){if(To(e,this.plugins),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,i);if(e.headerRenderers)for(const[o,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,i);if(e.cellEditors)for(const[o,i]of Object.entries(e.cellEditors))this.cellEditors.set(o,i);this.registerQueryHandlers(e),e.attach(this.grid);for(const o of this.plugins)o!==e&&o.onPluginAttached&&o.onPluginAttached(e.name,e)}registerQueryHandlers(e){const i=e.constructor.manifest;if(i?.queries)for(const n of i.queries){let r=this.queryHandlers.get(n.type);r||(r=new Set,this.queryHandlers.set(n.type,r)),r.add(e)}}unregisterQueryHandlers(e){for(const[o,i]of this.queryHandlers)i.delete(e),i.size===0&&this.queryHandlers.delete(o)}detachAll(){for(const e of this.plugins)for(const o of this.plugins)o!==e&&o.onPluginDetached&&o.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const o=this.plugins[e];this.unsubscribeAll(o),this.unregisterQueryHandlers(o),o.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(o=>o.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let o=[...e];for(const i of this.plugins)i.processRows&&(o=i.processRows(o));return o}processColumns(e){let o=[...e];for(const i of this.plugins)i.processColumns&&(o=i.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const o of this.plugins)o.afterCellRender?.(e)}hasAfterCellRenderHook(){return this.plugins.some(e=>typeof e.afterCellRender=="function")}afterRowRender(e){for(const o of this.plugins)o.afterRowRender?.(e)}hasAfterRowRenderHook(){return this.plugins.some(e=>typeof e.afterRowRender=="function")}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const o of this.plugins)typeof o.getExtraHeight=="function"&&(e+=o.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if(typeof e.getExtraHeight=="function"&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let o=0;for(const i of this.plugins)typeof i.getExtraHeightBefore=="function"&&(o+=i.getExtraHeightBefore(e));return o}adjustVirtualStart(e,o,i){let n=e;for(const r of this.plugins)if(typeof r.adjustVirtualStart=="function"){const s=r.adjustVirtualStart(e,o,i);s<n&&(n=s)}return n}renderRow(e,o,i){for(const n of this.plugins)if(n.renderRow?.(e,o,i))return!0;return!1}queryPlugins(e){const o=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const n of i){const r=n.handleQuery?.(e)??n.onPluginQuery?.(e);r!==void 0&&o.push(r)}return o}for(const n of this.plugins){const r=n.handleQuery?.(e)??n.onPluginQuery?.(e);r!==void 0&&o.push(r)}return o}subscribe(e,o,i){let n=this.eventListeners.get(o);n||(n=new Map,this.eventListeners.set(o,n)),n.set(e,i)}unsubscribe(e,o){const i=this.eventListeners.get(o);i&&(i.delete(e),i.size===0&&this.eventListeners.delete(o))}unsubscribeAll(e){for(const[o,i]of this.eventListeners)i.delete(e),i.size===0&&this.eventListeners.delete(o)}emitPluginEvent(e,o){const i=this.eventListeners.get(e);if(i)for(const n of i.values())try{n(o)}catch(r){console.error(`[tbw-grid] Error in plugin event handler for "${e}":`,r)}}onKeyDown(e){for(const o of this.plugins)if(o.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const o of this.plugins)if(o.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const o of this.plugins)if(o.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const o of this.plugins)if(o.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const o of this.plugins)o.onScroll?.(e)}onCellMouseDown(e){for(const o of this.plugins)if(o.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const o of this.plugins)if(o.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const o of this.plugins)if(o.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,o){let i=0,n=0,r=!1;for(const s of this.plugins){const l=s.getHorizontalScrollOffsets?.(e,o);l&&(i+=l.left,n+=l.right,l.skipScroll&&(r=!0))}return{left:i,right:n,skipScroll:r}}getToolPanels(){const e=[];for(const o of this.plugins){const i=o.getToolPanel?.();i&&e.push({plugin:o,panel:i})}return e.sort((o,i)=>(o.panel.order??0)-(i.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const i=o.getHeaderContent?.();i&&e.push({plugin:o,content:i})}return e.sort((o,i)=>(o.content.order??0)-(i.content.order??0))}}const Po=`/**
60
+ Consider removing one of these plugins to avoid unexpected behavior.`)}}}}function at(t,e){return!t||typeof t!="object"?t:"__rowCacheKey"in t?t.__rowCacheKey:"rowId"in t&&t.rowId!=null?`id:${t.rowId}`:e?`id:${e(t)}`:t}function ko(t,e,o){const i=at(e,o);if(typeof i=="string")return t.byKey.get(i);if(i&&typeof i=="object")return t.byRef.get(i)}function Io(t,e,o,i){const n=at(e,i);typeof n=="string"?t.byKey.set(n,o):n&&typeof n=="object"&&t.byRef.set(n,o)}function No(t,e,o,i,n){const r=new Array(t.length);let s=0;for(let l=0;l<t.length;l++){const a=t[l];let c=n?.(a,l),d=c!==void 0;c===void 0&&(c=ko(e,a,i.rowId),d=c!==void 0),c===void 0&&(c=o,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}function Ce(t,e,o){if(e<0||e>=t.length)return;const i=t[e],n=o-i.height;if(n!==0){i.height=o,i.measured=!0;for(let r=e+1;r<t.length;r++)t[r].offset+=n}}function qo(t){if(t.length===0)return 0;const e=t[t.length-1];return e.offset+e.height}function $o(t,e){if(t.length===0)return-1;if(e<=0)return 0;let o=0,i=t.length-1;for(;o<=i;){const n=Math.floor((o+i)/2),r=t[n],s=r.offset+r.height;if(e<r.offset)i=n-1;else if(e>=s)o=n+1;else return n}return Math.max(0,Math.min(o,t.length-1))}function Wo(t,e){let o=0,i=0;for(const n of t)n.measured&&(o+=n.height,i++);return i>0?o/i:e}function Fo(t){let e=0;for(const o of t)o.measured&&e++;return e}function Uo(t,e){const{positionCache:o,heightCache:i,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=t;let c=!1;e.forEach(u=>{const g=u.dataset.rowIndex;if(!g)return;const p=parseInt(g,10);if(p<r||p>=s||p>=n.length)return;const h=n[p],w=l?.(h,p);if(w!==void 0){const C=o[p];(!C.measured||Math.abs(C.height-w)>1)&&(Ce(o,p,w),c=!0);return}const m=u.offsetHeight;if(m>0){const C=o[p];(!C.measured||Math.abs(C.height-m)>1)&&(Ce(o,p,m),Io(i,h,m,a),c=!0)}});const d=c?Fo(o):0,f=c?Wo(o,t.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:f}}function Go(t,e,o,i){let n=0,r=0;for(let s=0;s<t.length;s++){const l=t[s];l.measured&&i?.(e[s],s)===void 0&&(r+=l.height,n++)}return{measuredCount:n,averageHeight:n>0?r/n:o}}class B{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;eventListeners=new Map;queryHandlers=new Map;static deprecationWarned=new WeakSet;attachAll(e){for(const o of e)this.attach(o)}attach(e){if(Oo(e,this.plugins),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,i);if(e.headerRenderers)for(const[o,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,i);if(e.cellEditors)for(const[o,i]of Object.entries(e.cellEditors))this.cellEditors.set(o,i);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid);for(const o of this.plugins)o!==e&&o.onPluginAttached&&o.onPluginAttached(e.name,e)}registerQueryHandlers(e){const i=e.constructor.manifest;if(i?.queries)for(const n of i.queries){let r=this.queryHandlers.get(n.type);r||(r=new Set,this.queryHandlers.set(n.type,r)),r.add(e)}}warnDeprecatedHooks(e){const o=e.constructor;if(B.deprecationWarned.has(o)||!re())return;const i=typeof e.getExtraHeight=="function"||typeof e.getExtraHeightBefore=="function",n=typeof e.getRowHeight=="function";i&&!n&&(B.deprecationWarned.add(o),console.warn(`[tbw-grid] Deprecation warning: "${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v3.0.
61
+ → Migrate to getRowHeight(row, index) for better variable row height support.
62
+ → See: https://toolbox-web.dev/docs/grid/plugins/migration#row-height-hooks`))}unregisterQueryHandlers(e){for(const[o,i]of this.queryHandlers)i.delete(e),i.size===0&&this.queryHandlers.delete(o)}detachAll(){for(const e of this.plugins)for(const o of this.plugins)o!==e&&o.onPluginDetached&&o.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const o=this.plugins[e];this.unsubscribeAll(o),this.unregisterQueryHandlers(o),o.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(o=>o.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let o=[...e];for(const i of this.plugins)i.processRows&&(o=i.processRows(o));return o}processColumns(e){let o=[...e];for(const i of this.plugins)i.processColumns&&(o=i.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const o of this.plugins)o.afterCellRender?.(e)}hasAfterCellRenderHook(){return this.plugins.some(e=>typeof e.afterCellRender=="function")}afterRowRender(e){for(const o of this.plugins)o.afterRowRender?.(e)}hasAfterRowRenderHook(){return this.plugins.some(e=>typeof e.afterRowRender=="function")}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const o of this.plugins)typeof o.getExtraHeight=="function"&&(e+=o.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if(typeof e.getExtraHeight=="function"&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let o=0;for(const i of this.plugins)typeof i.getExtraHeightBefore=="function"&&(o+=i.getExtraHeightBefore(e));return o}getRowHeight(e,o){for(const i of this.plugins)if(typeof i.getRowHeight=="function"){const n=i.getRowHeight(e,o);if(n!==void 0)return n}}hasRowHeightPlugin(){for(const e of this.plugins)if(typeof e.getRowHeight=="function")return!0;return!1}adjustVirtualStart(e,o,i){let n=e;for(const r of this.plugins)if(typeof r.adjustVirtualStart=="function"){const s=r.adjustVirtualStart(e,o,i);s<n&&(n=s)}return n}renderRow(e,o,i){for(const n of this.plugins)if(n.renderRow?.(e,o,i))return!0;return!1}queryPlugins(e){const o=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const n of i){const r=n.handleQuery?.(e)??n.onPluginQuery?.(e);r!==void 0&&o.push(r)}return o}for(const n of this.plugins){const r=n.handleQuery?.(e)??n.onPluginQuery?.(e);r!==void 0&&o.push(r)}return o}subscribe(e,o,i){let n=this.eventListeners.get(o);n||(n=new Map,this.eventListeners.set(o,n)),n.set(e,i)}unsubscribe(e,o){const i=this.eventListeners.get(o);i&&(i.delete(e),i.size===0&&this.eventListeners.delete(o))}unsubscribeAll(e){for(const[o,i]of this.eventListeners)i.delete(e),i.size===0&&this.eventListeners.delete(o)}emitPluginEvent(e,o){const i=this.eventListeners.get(e);if(i)for(const n of i.values())try{n(o)}catch(r){console.error(`[tbw-grid] Error in plugin event handler for "${e}":`,r)}}onKeyDown(e){for(const o of this.plugins)if(o.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const o of this.plugins)if(o.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const o of this.plugins)if(o.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const o of this.plugins)if(o.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const o of this.plugins)o.onScroll?.(e)}onCellMouseDown(e){for(const o of this.plugins)if(o.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const o of this.plugins)if(o.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const o of this.plugins)if(o.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,o){let i=0,n=0,r=!1;for(const s of this.plugins){const l=s.getHorizontalScrollOffsets?.(e,o);l&&(i+=l.left,n+=l.right,l.skipScroll&&(r=!0))}return{left:i,right:n,skipScroll:r}}getToolPanels(){const e=[];for(const o of this.plugins){const i=o.getToolPanel?.();i&&e.push({plugin:o,panel:i})}return e.sort((o,i)=>(o.panel.order??0)-(i.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const i=o.getHeaderContent?.();i&&e.push({plugin:o,content:i})}return e.sort((o,i)=>(o.content.order??0)-(i.content.order??0))}}const Vo=`/**
61
63
  * tbw-grid Light DOM Styles
62
64
  *
63
65
  * This stylesheet uses CSS nesting to scope all styles to the tbw-grid element.
@@ -85,5 +87,5 @@ ${N(i.name)}Plugin and ${N(s.name)}Plugin are both loaded, but they are currentl
85
87
  @layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.data-grid-row.tbw-row-loading:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:10;animation:tbw-fade-in .15s ease-out}.data-grid-row.tbw-row-loading:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);content:"";position:absolute;left:var(--tbw-spacing-md);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:11}.cell.tbw-cell-loading{position:relative;pointer-events:none}.cell.tbw-cell-loading:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:10;animation:tbw-fade-in .15s ease-out}.cell.tbw-cell-loading:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:11}}
86
88
  @layer tbw-base{tbw-grid .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=off] .data-grid-row[data-animating]{animation:none}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}
87
89
  @layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}tbw-grid .cell:focus,tbw-grid .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}tbw-grid .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=reduced-motion] .data-grid-row[data-animating]{animation:none}}}
88
- `;class k extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static#l=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#n(){return this}#u=!1;#d;#h;#a=[];get#i(){return this.#t?.effective??{}}#f=!1;#g=!1;#b={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#s;#m=0;#r=null;#p=!1;#A;#D=po();#w;#C;#y;#v;#_={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#o;#E;#M=!1;#O;#F;#z;#t;#e=oo();#c;#N;#k=!1;#T=new Set;#x=new Map;#I;#S=new Map;_rows=[];#U=[];get _columns(){return this.#i.columns??[]}set _columns(e){this.#i.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null};_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#t?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#t&&(this.#t.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#t?.originalColumnNodes}set __originalColumnNodes(e){this.#t&&(this.#t.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const o=this.#a;this.#a=e,o!==e&&this.#W("rows")}get sourceRows(){return this.#a}get columns(){return[...this._columns]}set columns(e){const o=this.#t?.getColumns();this.#t?.setColumns(e),o!==e&&this.#W("columns")}get gridConfig(){return this.#i}set gridConfig(e){const o=this.#t?.getGridConfig();this.#t?.setGridConfig(e),o!==e&&(this.#t.clearLightDomCache(),this.#W("gridConfig"))}get fitMode(){return this.#i.fitMode??"stretch"}set fitMode(e){const o=this.#t?.getFitMode();this.#t?.setFitMode(e),o!==e&&this.#W("fitMode")}get loading(){return this.#k}set loading(e){const o=this.#k;this.#k=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),o!==e&&this.#Ae()}setRowLoading(e,o){const i=this.#T.has(e);o?this.#T.add(e):this.#T.delete(e),i!==o&&this.#ce(e,o)}setCellLoading(e,o,i){let n=this.#x.get(e);const r=n?.has(o)??!1;i?(n||(n=new Set,this.#x.set(e,n)),n.add(o)):(n?.delete(o),n?.size===0&&this.#x.delete(e)),r!==i&&this.#de(e,o,i)}isRowLoading(e){return this.#T.has(e)}isCellLoading(e,o){return this.#x.get(e)?.has(o)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#T)this.#ce(e,!1);this.#T.clear();for(const[e,o]of this.#x)for(const i of o)this.#de(e,i,!1);this.#x.clear()}get effectiveConfig(){return this.#i}get disconnectSignal(){return this.#w||(this.#w=new AbortController),this.#w.signal}constructor(){super(),this.#ue(),this.#d=new Promise(e=>this.#h=e),this.#s=new Bt({mergeConfig:()=>{this.#t.parseLightDomColumns(this),this.#t.merge(),this.#Z(),Ro(this.#i,this.#o?.getPlugins()??[]),Ao(this.#o?.getPlugins()??[]),xo(this.#o?.getPlugins()??[]),this.#Re(),this.#U=[...this._columns]},processColumns:()=>this.#_e(),processRows:()=>this.#Ee(),renderHeader:()=>oe(this),updateTemplate:()=>V(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0,!0),afterRender:()=>{this.#o?.afterRender(),this.#i.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,Se(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,W(this)),this._virtualization.enabled&&!this.#$&&this.#ge()},isConnected:()=>this.isConnected&&this.#f}),this.#s.setInitialReadyResolver(()=>this.#h?.()),this.#c=lo(this.#e,{getShadow:()=>this.#n,getShellConfig:()=>this.#i?.shell,getAccordionIcons:()=>({expand:this.#i?.icons?.expand??M.expand,collapse:this.#i?.icons?.collapse??M.collapse}),emit:(e,o)=>this.#L(e,o),refreshShellHeader:()=>this.refreshShellHeader()}),this.#t=new Et({getRows:()=>this.#a,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#s.requestPhase(x.FULL,"configChange")},emit:(e,o)=>this.#L(e,o),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#H(),renderHeader:()=>oe(this),updateTemplate:()=>V(this),refreshVirtualWindow:()=>this.#s.requestPhase(x.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#Se(e),getShellLightDomTitle:()=>this.#e.lightDomTitle,getShellToolPanels:()=>this.#e.toolPanels,getShellHeaderContents:()=>this.#e.headerContents,getShellToolbarContents:()=>this.#e.toolbarContents,getShellLightDomHeaderContent:()=>this.#e.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#e.hasToolButtonsContainer})}async#ue(){await go(Po)}getPlugin(e){return this.#o?.getPlugin(e)}getPluginByName(e){return this.#o?.getPluginByName(e)}requestRender(){this.#s.requestPhase(x.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#s.requestPhase(x.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#s.requestPhase(x.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){V(this)}requestAfterRender(){this.#s.requestPhase(x.STYLE,"plugin:requestAfterRender")}#Q(){this.#o=new rt(this);const e=this.#i?.plugins,o=Array.isArray(e)?e:[];this.#o.attachAll(o)}#q(){const e=this.#o?.getPluginStyles()??[];uo(e)}#Z(){const e=this.#i?.plugins,o=Array.isArray(e)?e:[];if(this.#E!==o){if(this.#E&&this.#E.length===o.length&&this.#E.every((i,n)=>i===o[n])){this.#E=o;return}this.#o&&this.#o.detachAll();for(const i of this.#e.toolPanels.keys()){const n=this.#e.lightDomToolPanelIds.has(i),r=this.#e.apiToolPanelIds.has(i);if(!n&&!r){const s=this.#e.panelCleanups.get(i);s&&(s(),this.#e.panelCleanups.delete(i)),this.#e.toolPanels.delete(i)}}for(const i of this.#e.headerContents.keys()){const n=this.#e.headerContentCleanups.get(i);n&&(n(),this.#e.headerContentCleanups.delete(i)),this.#e.headerContents.delete(i)}this.#Q(),this.#q(),this.#E=o,this.#J(),this.#p=this.#o?.getAll().some(i=>i.onScroll)??!1}}#fe(){this.#o?.detachAll()}#J(){if(!this.#o)return;const e=this.#o.getToolPanels();for(const{panel:i}of e)this.#e.toolPanels.has(i.id)||this.#e.toolPanels.set(i.id,i);const o=this.#o.getHeaderContents();for(const{content:i}of o)this.#e.headerContents.has(i.id)||this.#e.headerContents.set(i.id,i)}#P(){const e=k.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return i=>{if(o?.createToolPanelRenderer){const n=o.createToolPanelRenderer(i);if(n)return n}for(const n of e)if(n.createToolPanelRenderer){const r=n.createToolPanelRenderer(i);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",k.version),this.id||(this.id=`tbw-grid-${++k.#l}`),this._rows=Array.isArray(this.#a)?[...this.#a]:[],this.#w&&(this.#w.abort(),this.#M=!1),this.#w=new AbortController,this.#v&&(Ge(this.#v),this.#v=void 0),F(this,this.#e),U(this,this.#e),G(this,this.#e,this.#P()),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#Q();const e=this.#i?.plugins;this.#E=Array.isArray(e)?e:[],this.#J(),this.#u||(this.#j(),this.#q(),this.#u=!0),this.#ee(),this.#v=It(()=>{this.#Le()},{timeout:100})}disconnectedCallback(){this.#v&&(Ge(this.#v),this.#v=void 0),this.#fe(),so(this.#e),this.#c.setInitialized(!1),this.#N?.(),this.#N=void 0,ot(this.#D),this.#w&&(this.#w.abort(),this.#w=void 0),this.#O?.abort(),this.#O=void 0,this.#M=!1,this._resizeController&&this._resizeController.dispose(),this.#C&&(this.#C.disconnect(),this.#C=void 0),this.#y&&(this.#y.disconnect(),this.#y=void 0,this.#$=!1),K(this),this.#R.clear(),this.#E=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#f=!1}attributeChangedCallback(e,o,i){if(e==="loading"){const n=i!==null&&i!=="false";this.loading!==n&&(this.loading=n);return}if(!(o===i||!i||i==="null"||i==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const n=JSON.parse(i);e==="rows"?this.rows=n:e==="columns"?this.columns=n:e==="grid-config"&&(this.gridConfig=n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else e==="fit-mode"&&(this.fitMode=i)}#ee(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#c.isInitialized){fe(this.#n,this.#e),Ze(this.#n,this.#i?.shell,this.#e);const r=this.#i?.shell?.toolPanel?.defaultOpen;r&&this.#e.toolPanels.has(r)&&(this.openToolPanel(),this.#e.expandedSections.add(r))}if(this.setAttribute("data-upgraded",""),this.#f=!0,this._resizeController=Ve(this),this.#H(),this.#oe(o),this.#M)return;this.#M=!0;const i=this.disconnectSignal;Mt(this,this,this.#n,i);const n=this.#i.rowHeight;n&&n>0?this._virtualization.rowHeight=n:requestAnimationFrame(()=>this.#te()),queueMicrotask(()=>this.#pe()),this.#s.requestPhase(x.FULL,"afterConnect")}#te(){if(this.#o.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let i=0;o.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#s.requestPhase(x.VIRTUALIZATION,"measureRowHeight"))}#oe(e){this.#O?.abort(),this.#O=new AbortController;const o=this.#O.signal,i=e?.querySelector(".faux-vscroll"),n=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#p=this.#o?.getAll().some(r=>r.onScroll)??!1,i&&n){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#p)return;const a=i.scrollTop,c=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)n.style.transform=`translateY(${-a}px)`;else{const d=Math.floor(a/c),u=d-d%2,g=-(a-u*c);n.style.transform=`translateY(${g}px)`}this.#r=a,this.#m||(this.#m=requestAnimationFrame(()=>{this.#m=0,this.#r!==null&&(this.#Te(this.#r),this.#r=null)}))},{passive:!0,signal:o});const r=this.#n.querySelector(".tbw-scroll-area");this.#F=r,r&&this.#p&&r.addEventListener("scroll",()=>{const a=this.#_;a.scrollTop=i.scrollTop,a.scrollLeft=r.scrollLeft,a.scrollHeight=i.scrollHeight,a.scrollWidth=r.scrollWidth,a.clientHeight=i.clientHeight,a.clientWidth=r.clientWidth,this.#o?.onScroll(a)},{passive:!0,signal:o});const s=this.#n.querySelector(".tbw-grid-content"),l=this.#F;s&&(s.addEventListener("wheel",a=>{const c=a.shiftKey||Math.abs(a.deltaX)>Math.abs(a.deltaY);if(c&&l){const d=a.shiftKey?a.deltaY:a.deltaX,{scrollLeft:u,scrollWidth:g,clientWidth:f}=l;(d>0&&u<g-f||d<0&&u>0)&&(a.preventDefault(),l.scrollLeft+=d)}else if(!c){const{scrollTop:d,scrollHeight:u,clientHeight:g}=i;(a.deltaY>0&&d<u-g||a.deltaY<0&&d>0)&&(a.preventDefault(),i.scrollTop+=a.deltaY)}},{passive:!1,signal:o}),yo(s,this.#D,{fauxScrollbar:i,scrollArea:l},o))}this._bodyEl&&zt(this,this._bodyEl,o),this.#C?.disconnect(),this._virtualization.viewportEl&&(this.#C=new ResizeObserver(()=>{this.#s.requestPhase(x.VIRTUALIZATION,"resize-observer")}),this.#C.observe(this._virtualization.viewportEl)),this.#n.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:o}),this.#n.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#n.contains(s))&&delete this.dataset.hasFocus},{signal:o})}#$=!1;#ge(){if(this.#$)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#$=!0,this.#y?.disconnect(),this.#y=new ResizeObserver(()=>{this.#te()}),this.#y.observe(e))}addEventListener(e,o,i){super.addEventListener(e,o,i)}removeEventListener(e,o,i){super.removeEventListener(e,o,i)}#L(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#pe(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,i)=>{const n=i===this._focusRow;o.setAttribute("aria-selected",String(n)),o.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(n&&s===this._focusCol))})})}#W(e){this.#b[e]=!0,!this.#g&&(this.#g=!0,queueMicrotask(()=>this.#we()))}#we(){if(!this.#g||!this.#f){this.#g=!1;return}const e=this.#b;if(this.#g=!1,this.#b={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#Ce(),e.rows&&this.#ie();return}e.columns&&this.#me(),e.rows&&this.#ie(),e.fitMode&&this.#ve()}#ie(){this._rows=Array.isArray(this.#a)?[...this.#a]:[],this.#G(),this.#s.requestPhase(x.ROWS,"applyRowsUpdate")}#G(){this.#S.clear();const e=this.#i.getRowId;this._rows.forEach((o,i)=>{const n=this.#ne(o,e);n!==void 0&&this.#S.set(n,{row:o,index:i})})}#ne(e,o){if(o)return o(e);const i=e;if("id"in i&&i.id!=null)return String(i.id);if("_id"in i&&i._id!=null)return String(i._id)}#be(e,o){const i=this.#ne(e,o);if(i===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return i}#me(){K(this),this.#t.merge(),this.#H()}#ve(){this.#t.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,Se(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),V(this))}#Ce(){F(this,this.#e),U(this,this.#e);const e=!!this.#n.querySelector(".has-shell"),o=!!this.#n.querySelector(".tbw-tool-panel"),i=this.#n.querySelectorAll(".tbw-accordion-section").length;this.#t.parseLightDomColumns(this),this.#t.merge(),this.#Z(),G(this,this.#e,this.#P()),this.#t.markSourcesChanged(),this.#t.merge();const n=Ke(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=(this.#i?.shell?.toolPanels?.length??0)!==i;if(e!==n||!e&&n||!o&&r||o&&s){this.#j(),this.#q(),this.#ee(),this.#G();return}e&&this.#ye(),this.#G(),this.#s.requestPhase(x.COLUMNS,"applyGridConfigUpdate")}#ye(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;const o=this.#i.shell?.header?.title??this.#e.lightDomTitle;let i=e.querySelector(".tbw-shell-title");o?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=o):i&&i.remove()}#_e(){if(this.#o){const e=this.#U.length>0?this.#U:this._columns,o=e.filter(r=>!r.hidden),i=e.filter(r=>r.hidden),n=this.#o.processColumns([...o]);if(n!==o){new Set(o.map(l=>l.field));const r=new Set(n.map(l=>l.field));!o.some(l=>r.has(l.field))&&n.length>0?this._columns=[...n,...i]:this._columns=[...n,...i]}else this._columns=[...e]}}#Ee(){K(this);const e=Array.isArray(this.#a)?[...this.#a]:[],o=this.#o?.processRows(e)??e;this._rows=o}#Se(e){const o={...Ce,...e.animation},i=o.mode??"reduced-motion";let n=1;i===!1||i==="off"?n=0:(i===!0||i==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${o.duration}ms`),this.style.setProperty("--tbw-animation-easing",o.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof i=="boolean"?i?"on":"off":i}#V(e,o,i=this.__rowRenderEpoch){this.#A||(this.#A=(n,r,s)=>this.#o?.renderRow(n,r,s)??!1),xt(this,e,o,i,this.#A)}#B=-1;#re=-1;#se(e,o){if(e===this.#B&&o===this.#re)return;const i=this.#B;this.#B=e,this.#re=o,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(o))),e!==i&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#le;#ae;#Re(){if(!this.__rowsBodyEl)return;const e=this.#i.gridAriaLabel,o=this.#i.shell?.header?.title??this.#e?.lightDomTitle??void 0,i=e??o;i!==this.#le&&(this.#le=i,i?this.__rowsBodyEl.setAttribute("aria-label",i):this.__rowsBodyEl.removeAttribute("aria-label"));const n=this.#i.gridAriaDescribedBy;n!==this.#ae&&(this.#ae=n,n?this.__rowsBodyEl.setAttribute("aria-describedby",n):this.__rowsBodyEl.removeAttribute("aria-describedby"))}#Ae(){const e=this.querySelector(".tbw-grid-root");e&&(this.#k?(this.#I||(this.#I=Wt(this.#i?.loadingRenderer)),Ft(e,this.#I)):Ut(this.#I))}#ce(e,o){const i=this.#S.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);n&&Gt(n,o)}#de(e,o,i){const n=this.#S.get(e);if(!n)return;const r=this.findRenderedRowElement?.(n.index);if(!r)return;const s=this._visibleColumns.findIndex(a=>a.field===o);if(s<0)return;const l=r.children[s];l&&Vt(l,i)}#H(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#t.parseLightDomColumns(this),this.#z){const e=this.#z;this.#z=void 0,this.#t.merge();const o=this.#o?.getAll()??[];this.#t.applyState(e,o)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#s.requestPhase(x.FULL,"setup")}}#Te(e){if(this.refreshVirtualWindow(!1),this.#o?.onScrollRender(),this.#p){const o=this._virtualization.container,i=this.#F,n=this.#_;n.scrollTop=e,n.scrollLeft=i?.scrollLeft??0,n.scrollHeight=o?.scrollHeight??0,n.scrollWidth=i?.scrollWidth??0,n.clientHeight=o?.clientHeight??0,n.clientWidth=i?.clientWidth??0,this.#o?.onScroll(n)}}findHeaderRow(){return this.#n.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const i=o.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,i,n){const r=this._rows[o],s=this._columns[i];if(!r||!s)return!1;const l=s.field,a=r[l],c=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:o,colIndex:i,field:l,value:a,row:r,cellEl:n,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(c),c.defaultPrevented)return!0;const d={row:r,rowIndex:o,colIndex:i,field:l,value:a,cellEl:n,originalEvent:e},u=this.#o?.onCellClick(d)??!1;return this.#L("cell-click",d),u}_dispatchRowClick(e,o,i,n){if(!i)return!1;const r={rowIndex:o,row:i,rowEl:n,originalEvent:e},s=this.#o?.onRowClick(r)??!1;return this.#L("row-click",r),s}_dispatchHeaderClick(e,o,i){const n=this._columns[o];if(!n)return!1;const r={colIndex:o,field:n.field,column:n,headerEl:i,originalEvent:e};return this.#o?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#o?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#o?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#o?.queryPlugins(e)??[]}query(e,o){return this.#o?.queryPlugins({type:e,context:o})??[]}_dispatchCellMouseDown(e){return this.#o?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#o?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#o?.onCellMouseUp(e)}_afterCellRender(e){this.#o?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#o?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#o?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#o?.hasAfterRowRenderHook()??!1}async ready(){return this.#d}async forceLayout(){return this.#s.requestPhase(x.FULL,"forceLayout"),this.#s.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#be(e,this.#i.getRowId)}getRow(e){return this.#S.get(e)?.row}updateRow(e,o,i="api"){const n=this.#S.get(e);if(!n)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=n,l=[];for(const[a,c]of Object.entries(o)){const d=r[a];d!==c&&(l.push({field:a,oldValue:d,newValue:c}),r[a]=c)}for(const{field:a,oldValue:c,newValue:d}of l)this.#L("cell-change",{row:r,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:o,source:i});l.length>0&&this.#s.requestPhase(x.ROWS,"updateRow")}updateRows(e,o="api"){let i=!1;for(const{id:n,changes:r}of e){const s=this.#S.get(n);if(!s)throw new Error(`[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:a}=s;for(const[c,d]of Object.entries(r)){const u=l[c];u!==d&&(i=!0,l[c]=d,this.#L("cell-change",{row:l,rowId:n,rowIndex:a,field:c,oldValue:u,newValue:d,changes:r,source:o}))}}i&&this.#s.requestPhase(x.ROWS,"updateRows")}animateRow(e,o){ue(this,e,o)}animateRows(e,o){Zt(this,e,o)}animateRowById(e,o){return Jt(this,e,o)}setColumnVisible(e,o){const i=this.#t.setColumnVisible(e,o);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const o=this.#t.toggleColumnVisibility(e);return o&&this.requestStateChange(),o}isColumnVisible(e){return this.#t.isColumnVisible(e)}showAllColumns(){this.#t.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#t.getAllColumns()}setColumnOrder(e){this.#t.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#t.getColumnOrder()}getColumnState(){const e=this.#o?.getAll()??[];return this.#t.collectState(e)}set columnState(e){e&&(this.#z=e,this.#t.initialColumnState=e,this.#u&&this.#xe(e))}get columnState(){return this.getColumnState()}#xe(e){const o=this.#o?.getAll()??[];this.#t.applyState(e,o),this.#H()}requestStateChange(){const e=this.#o?.getAll()??[];this.#t.requestStateChange(e)}resetColumnState(){this.#z=void 0,this.__originalOrder=[];const e=this.#o?.getAll()??[];this.#t.resetState(e),this.#t.merge(),this.#H()}get isToolPanelOpen(){return this.#c.isPanelOpen}get expandedToolPanelSections(){return this.#c.expandedSections}openToolPanel(){this.#c.openToolPanel()}closeToolPanel(){this.#c.closeToolPanel()}toggleToolPanel(){this.#c.toggleToolPanel()}toggleToolPanelSection(e){this.#c.toggleToolPanelSection(e)}getToolPanels(){return this.#c.getToolPanels()}registerToolPanel(e){this.#e.apiToolPanelIds.add(e.id),this.#c.registerToolPanel(e)}unregisterToolPanel(e){this.#e.apiToolPanelIds.delete(e),this.#c.unregisterToolPanel(e)}getHeaderContents(){return this.#c.getHeaderContents()}registerHeaderContent(e){this.#c.registerHeaderContent(e)}unregisterHeaderContent(e){this.#c.unregisterHeaderContent(e)}getToolbarContents(){return this.#c.getToolbarContents()}registerToolbarContent(e){this.#c.registerToolbarContent(e)}unregisterToolbarContent(e){this.#c.unregisterToolbarContent(e)}#X=!1;refreshShellHeader(){this.#X||(this.#X=!0,queueMicrotask(()=>{this.#X=!1,this.isConnected&&(F(this,this.#e),U(this,this.#e),G(this,this.#e,this.#P()),this.#t.markSourcesChanged(),this.#t.merge(),this.#j(),this.#q(),this.#Pe())}))}#Pe(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#c.isInitialized){fe(this.#n,this.#e),Ze(this.#n,this.#i?.shell,this.#e);const i=this.#i?.shell?.toolPanel?.defaultOpen;i&&this.#e.toolPanels.has(i)&&(this.openToolPanel(),this.#e.expandedSections.add(i))}this._resizeController=Ve(this),this.#oe(o),this.#s.requestPhase(x.COLUMNS,"shellRefresh")}#R=new Map;registerStyles(e,o){let i=this.#R.get(e);i||(i=new CSSStyleSheet,this.#R.set(e,i)),i.replaceSync(o),this.#he()}unregisterStyles(e){this.#R.delete(e)&&this.#he()}getRegisteredStyles(){return Array.from(this.#R.keys())}#he(){const e=Array.from(this.#R.values()),o=document.adoptedStyleSheets.filter(i=>!Array.from(this.#R.values()).includes(i));document.adoptedStyleSheets=[...o,...e]}#Le(){const e=()=>{const i=this.#e.lightDomTitle,n=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),G(this,this.#e,this.#P());const r=this.#e.lightDomTitle,s=this.#e.hasToolButtonsContainer;if(r&&!i||s&&!n){this.#t.markSourcesChanged(),this.#t.merge();const l=this.#n.querySelector(".tbw-shell-header");if(l){const a=Qe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),c=document.createElement("div");c.innerHTML=a;const d=c.firstElementChild;d&&(l.replaceWith(d),this.#K())}}},o=()=>{this.__lightDomColumnsCache=void 0,this.#H()};this.#t.registerLightDomHandler("tbw-grid-header",e),this.#t.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#t.registerLightDomHandler("tbw-grid-tool-panel",e),this.#t.registerLightDomHandler("tbw-grid-column",o),this.#t.registerLightDomHandler("tbw-grid-detail",o),this.#t.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,K(this),this.#t.parseLightDomColumns(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),G(this,this.#e,this.#P());const i=this.#e.lightDomTitle,n=this.#e.hasToolButtonsContainer;if(i&&!e||n&&!o){this.#t.markSourcesChanged(),this.#t.merge();const s=this.#n.querySelector(".tbw-shell-header");if(s){const l=Qe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),a=document.createElement("div");a.innerHTML=l;const c=a.firstElementChild;c&&(s.replaceWith(c),this.#K())}}this.#s.requestPhase(x.COLUMNS,"refreshColumns")}#Y(e){const o=this._virtualization.rowHeight,i=this._virtualization.container??this,n=this._virtualization.viewportEl??i,r=i.clientHeight,s=n.clientHeight,a=this.shadowRoot?.querySelector(".tbw-scroll-area"),c=a?a.clientHeight:r,u=c-s,g=this.#o?.getExtraHeight()??0,f=Math.max(0,r-c);return e*o+u+g+f}refreshVirtualWindow(e=!1,o=!1){if(!this._bodyEl)return;const i=this._rows.length;if(!this._virtualization.enabled){this.#V(0,i),o||this.#o?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=i,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#V(0,i,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#Y(i)}px`),this.#se(i,this._visibleColumns.length),o||this.#o?.afterRender();return}const n=this._virtualization.container??this,r=this._virtualization.viewportEl??n,s=r.clientHeight,l=this._virtualization.rowHeight,a=n.scrollTop;let c=Math.floor(a/l),d=0;const u=10;for(;d<u;){const y=this.#o?.getExtraHeightBefore?.(c)??0,E=Math.floor((a-y)/l);if(E>=c||E<0)break;c=E,d++}c=c-c%2,c<0&&(c=0);const g=this.#o?.adjustVirtualStart(c,a,l);g!==void 0&&g<c&&(c=g,c=c-c%2,c<0&&(c=0));const f=Math.ceil(s/l)+3;let p=c+f;if(p>i&&(p=i),this._virtualization.start=c,this._virtualization.end=p,n.clientHeight===0&&s>0){this.#s.requestPhase(x.VIRTUALIZATION,"stale-refs-retry");return}const w=this.#Y(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${w}px`);const C=this.#o?.getExtraHeightBefore?.(c)??0,R=-(a-c*l-C);this._bodyEl.style.transform=`translateY(${R}px)`,this.#V(c,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#se(i,this._visibleColumns.length),e&&!o&&(this.#o?.afterRender(),queueMicrotask(()=>{const y=n.clientHeight,E=r.clientHeight;if(y===0&&E>0)return;const P=this.#Y(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${P}px`)}))}#j(){F(this,this.#e),U(this,this.#e),G(this,this.#e,this.#P()),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#i?.shell;co(this.#n,e,{isPanelOpen:this.#e.isPanelOpen,expandedSections:this.#e.expandedSections},this.#i?.icons)&&(this.#K(),this.#c.setInitialized(!0))}#K(){io(this.#n,this.#i?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#N?.(),this.#N=no(this.#n,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(k.tagName)||customElements.define(k.tagName,k),globalThis.DataGridElement=k;const Lo={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class Ho{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#l;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#l?.abort(),this.#l=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#l?.abort(),this.#l=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}emitCancelable(e,o){const i=new CustomEvent(e,{detail:o,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(e,o){this.grid?._pluginManager?.subscribe(this,e,o)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,o){this.grid?._pluginManager?.emitPluginEvent(e,o)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#l?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...M,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const o=this.gridElement;return o?getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const o=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(o,10);if(!isNaN(i))return i}return 200}resolveIcon(e,o){return o!==void 0?o:this.gridIcons[e]}setIcon(e,o){typeof o=="string"?e.innerHTML=o:o instanceof HTMLElement&&(e.innerHTML="",e.appendChild(o.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const L={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},Y={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Do={ROOT:`.${L.ROOT}`,HEADER:`.${L.HEADER}`,HEADER_ROW:`.${L.HEADER_ROW}`,HEADER_CELL:`.${L.HEADER_CELL}`,ROWS_VIEWPORT:`.${L.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${L.ROWS_CONTAINER}`,DATA_ROW:`.${L.DATA_ROW}`,DATA_CELL:`.${L.DATA_CELL}`,GROUP_ROW:`.${L.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${L.DATA_ROW}[${Y.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${L.DATA_CELL}[${Y.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${L.DATA_ROW}[${Y.ROW_INDEX}="${t}"] .${L.DATA_CELL}[${Y.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${L.DATA_ROW}.${L.SELECTED}`,EDITING_CELL:`.${L.DATA_CELL}.${L.EDITING}`},Oo={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function zo(t){const e=document.createElement("tbw-grid");return t&&(e.gridConfig=t),e}function Mo(t,e=document){return e.querySelector(t)}const No={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},ko={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},me={sum:(t,e)=>t.reduce((o,i)=>o+(Number(i[e])||0),0),avg:(t,e)=>{const o=t.reduce((i,n)=>i+(Number(n[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>Math.min(...t.map(o=>Number(o[e])||1/0)),max:(t,e)=>Math.max(...t.map(o=>Number(o[e])||-1/0)),first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},j=new Map,O={register(t,e){j.set(t,e)},unregister(t){j.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:j.get(t)??me[t]},run(t,e,o,i){const n=this.get(t);return n?n(e,o,i):void 0},has(t){return j.has(t)||t in me},list(){return[...Object.keys(me),...j.keys()]}},st={sum:t=>t.reduce((e,o)=>e+o,0),avg:t=>t.length?t.reduce((e,o)=>e+o,0)/t.length:0,count:t=>t.length,min:t=>t.length?Math.min(...t):0,max:t=>t.length?Math.max(...t):0,first:t=>t[0]??0,last:t=>t[t.length-1]??0};function lt(t){return st[t]??st.sum}function Io(t,e){return lt(t)(e)}const qo=O.register.bind(O),$o=O.unregister.bind(O),Wo=O.get.bind(O),Fo=O.run.bind(O),Uo=O.list.bind(O);v.BaseGridPlugin=Ho,v.DEFAULT_ANIMATION_CONFIG=Ce,v.DEFAULT_GRID_ICONS=M,v.DGEvents=No,v.DataGridElement=k,v.FitModeEnum=z,v.GridCSSVars=Oo,v.GridClasses=L,v.GridDataAttrs=Y,v.GridElement=k,v.GridSelectors=Do,v.PLUGIN_QUERIES=Lo,v.PluginEvents=ko,v.PluginManager=rt,v.RenderPhase=x,v.aggregatorRegistry=O,v.builtInSort=qe,v.createGrid=zo,v.defaultComparator=Ie,v.getAggregator=Wo,v.getValueAggregator=lt,v.listAggregators=Uo,v.queryGrid=Mo,v.registerAggregator=qo,v.runAggregator=Fo,v.runValueAggregator=Io,v.unregisterAggregator=$o,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
90
+ `;class k extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static#l=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#n(){return this}#u=!1;#d;#h;#a=[];get#i(){return this.#t?.effective??{}}#f=!1;#p=!1;#v={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#s;#C=0;#r=null;#w=!1;#A=!1;#m=0;#z;#k=_o();#b;#y;#g;#E;#Q={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#e;#_;#I=!1;#D;#G;#O;#t;#o=ao();#c;#N;#q=!1;#T=new Set;#x=new Map;#$;#S=new Map;_rows=[];#V=[];get _columns(){return this.#i.columns??[]}set _columns(e){this.#i.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:new Map,byRef:new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1};_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#t?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#t&&(this.#t.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#t?.originalColumnNodes}set __originalColumnNodes(e){this.#t&&(this.#t.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const o=this.#a;this.#a=e,o!==e&&this.#U("rows")}get sourceRows(){return this.#a}get columns(){return[...this._columns]}set columns(e){const o=this.#t?.getColumns();this.#t?.setColumns(e),o!==e&&this.#U("columns")}get gridConfig(){return this.#i}set gridConfig(e){const o=this.#t?.getGridConfig();this.#t?.setGridConfig(e),o!==e&&(this.#t.clearLightDomCache(),this.#U("gridConfig"))}get fitMode(){return this.#i.fitMode??"stretch"}set fitMode(e){const o=this.#t?.getFitMode();this.#t?.setFitMode(e),o!==e&&this.#U("fitMode")}get loading(){return this.#q}set loading(e){const o=this.#q;this.#q=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),o!==e&&this.#He()}setRowLoading(e,o){const i=this.#T.has(e);o?this.#T.add(e):this.#T.delete(e),i!==o&&this.#ce(e,o)}setCellLoading(e,o,i){let n=this.#x.get(e);const r=n?.has(o)??!1;i?(n||(n=new Set,this.#x.set(e,n)),n.add(o)):(n?.delete(o),n?.size===0&&this.#x.delete(e)),r!==i&&this.#de(e,o,i)}isRowLoading(e){return this.#T.has(e)}isCellLoading(e,o){return this.#x.get(e)?.has(o)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#T)this.#ce(e,!1);this.#T.clear();for(const[e,o]of this.#x)for(const i of o)this.#de(e,i,!1);this.#x.clear()}get effectiveConfig(){return this.#i}get disconnectSignal(){return this.#b||(this.#b=new AbortController),this.#b.signal}constructor(){super(),this.#pe(),this.#d=new Promise(e=>this.#h=e),this.#s=new Zt({mergeConfig:()=>{this.#t.parseLightDomColumns(this),this.#t.merge(),this.#J(),zo(this.#i,this.#e?.getPlugins()??[]),Do(this.#e?.getPlugins()??[]),Mo(this.#e?.getPlugins()??[]),this.#Pe(),this.#V=[...this._columns]},processColumns:()=>this.#Ae(),processRows:()=>this.#Te(),renderHeader:()=>te(this),updateTemplate:()=>U(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0,!0),afterRender:()=>{this.#e?.afterRender(),this.#i.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,Te(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,W(this)),this._virtualization.enabled&&!this.#F&&this.#me(),this.#A&&(this.#A=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#be()})}))},isConnected:()=>this.isConnected&&this.#f}),this.#s.setInitialReadyResolver(()=>this.#h?.()),this.#c=po(this.#o,{getShadow:()=>this.#n,getShellConfig:()=>this.#i?.shell,getAccordionIcons:()=>({expand:this.#i?.icons?.expand??O.expand,collapse:this.#i?.icons?.collapse??O.collapse}),emit:(e,o)=>this.#P(e,o),refreshShellHeader:()=>this.refreshShellHeader()}),this.#t=new Pt({getRows:()=>this.#a,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#s.requestPhase(T.FULL,"configChange")},emit:(e,o)=>this.#P(e,o),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#H(),renderHeader:()=>te(this),updateTemplate:()=>U(this),refreshVirtualWindow:()=>this.#s.requestPhase(T.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#xe(e),getShellLightDomTitle:()=>this.#o.lightDomTitle,getShellToolPanels:()=>this.#o.toolPanels,getShellHeaderContents:()=>this.#o.headerContents,getShellToolbarContents:()=>this.#o.toolbarContents,getShellLightDomHeaderContent:()=>this.#o.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#o.hasToolButtonsContainer})}async#pe(){await yo(Vo)}getPlugin(e){return this.#e?.getPlugin(e)}getPluginByName(e){return this.#e?.getPluginByName(e)}requestRender(){this.#s.requestPhase(T.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#s.requestPhase(T.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#s.requestPhase(T.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){U(this)}requestAfterRender(){this.#s.requestPhase(T.STYLE,"plugin:requestAfterRender")}#Z(){this.#e=new B(this);const e=this.#i?.plugins,o=Array.isArray(e)?e:[];this.#e.attachAll(o)}#W(){const e=this.#e?.getPluginStyles()??[];vo(e)}#J(){const e=this.#i?.plugins,o=Array.isArray(e)?e:[];if(this.#_!==o){if(this.#_&&this.#_.length===o.length&&this.#_.every((i,n)=>i===o[n])){this.#_=o;return}this.#e&&this.#e.detachAll();for(const i of this.#o.toolPanels.keys()){const n=this.#o.lightDomToolPanelIds.has(i),r=this.#o.apiToolPanelIds.has(i);if(!n&&!r){const s=this.#o.panelCleanups.get(i);s&&(s(),this.#o.panelCleanups.delete(i)),this.#o.toolPanels.delete(i)}}for(const i of this.#o.headerContents.keys()){const n=this.#o.headerContentCleanups.get(i);n&&(n(),this.#o.headerContentCleanups.delete(i)),this.#o.headerContents.delete(i)}this.#Z(),this.#W(),this.#_=o,this.#ee(),this.#w=this.#e?.getAll().some(i=>i.onScroll)??!1}}#we(){this.#e?.detachAll()}#ee(){if(!this.#e)return;const e=this.#e.getToolPanels();for(const{panel:i}of e)this.#o.toolPanels.has(i.id)||this.#o.toolPanels.set(i.id,i);const o=this.#e.getHeaderContents();for(const{content:i}of o)this.#o.headerContents.has(i.id)||this.#o.headerContents.set(i.id,i)}#te(){const e=k.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return i=>{if(o?.createToolPanelRenderer){const n=o.createToolPanelRenderer(i);if(n)return n}for(const n of e)if(n.createToolPanelRenderer){const r=n.createToolPanelRenderer(i);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",k.version),this.id||(this.id=`tbw-grid-${++k.#l}`),this._rows=Array.isArray(this.#a)?[...this.#a]:[],this.#b&&(this.#b.abort(),this.#I=!1),this.#b=new AbortController,this.#E&&(Xe(this.#E),this.#E=void 0),this.#M(),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#Z();const e=this.#i?.plugins;this.#_=Array.isArray(e)?e:[],this.#ee(),this.#u||(this.#K(),this.#W(),this.#u=!0),this.#oe(),this.#E=Gt(()=>{this.#Oe()},{timeout:100})}disconnectedCallback(){this.#E&&(Xe(this.#E),this.#E=void 0),this.#m&&(clearTimeout(this.#m),this.#m=0),this.#we(),go(this.#o),this.#c.setInitialized(!1),this.#N?.(),this.#N=void 0,st(this.#k),this.#b&&(this.#b.abort(),this.#b=void 0),this.#D?.abort(),this.#D=void 0,this.#I=!1,this._resizeController&&this._resizeController.dispose(),this.#y&&(this.#y.disconnect(),this.#y=void 0),this.#g&&(this.#g.disconnect(),this.#g=void 0,this.#F=!1),j(this),this.#R.clear(),this.#_=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#f=!1}attributeChangedCallback(e,o,i){if(e==="loading"){const n=i!==null&&i!=="false";this.loading!==n&&(this.loading=n);return}if(!(o===i||!i||i==="null"||i==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const n=JSON.parse(i);e==="rows"?this.rows=n:e==="columns"?this.columns=n:e==="grid-config"&&(this.gridConfig=n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else e==="fit-mode"&&(this.fitMode=i)}#oe(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#c.isInitialized){ge(this.#n,this.#o),fe(this.#n,this.#i?.shell,this.#o);const s=this.#i?.shell?.toolPanel?.defaultOpen;s&&this.#o.toolPanels.has(s)&&(this.openToolPanel(),this.#o.expandedSections.add(s))}if(this.setAttribute("data-upgraded",""),this.#f=!0,this._resizeController=Ye(this),this.#H(),this.#ne(o),this.#I)return;this.#I=!0;const i=this.disconnectSignal;Wt(this,this,this.#n,i);const n=this.#i.rowHeight,r=this.#e.hasRowHeightPlugin();typeof n=="function"||r?(this._virtualization.variableHeights=!0,this._virtualization.rowHeight=typeof n=="number"&&n>0?n:28,this.#j(),typeof n!="function"&&(this.#A=!0)):typeof n=="number"&&n>0?(this._virtualization.rowHeight=n,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#ie()),queueMicrotask(()=>this.#ve()),this.#s.requestPhase(T.FULL,"afterConnect")}#ie(){if(this.#e.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let i=0;o.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#s.requestPhase(T.VIRTUALIZATION,"measureRowHeight"))}#be(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let i=0;o.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);if(r>0&&(Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r),this.#j(),this._virtualization.totalHeightEl)){const l=this.#L(this._rows.length);this._virtualization.totalHeightEl.style.height=`${l}px`}}#ne(e){this.#D?.abort(),this.#D=new AbortController;const o=this.#D.signal,i=e?.querySelector(".faux-vscroll"),n=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#w=this.#e?.getAll().some(r=>r.onScroll)??!1,i&&n){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#w)return;const a=i.scrollTop,c=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)n.style.transform=`translateY(${-a}px)`;else{const d=Math.floor(a/c),f=d-d%2,u=-(a-f*c);n.style.transform=`translateY(${u}px)`}this.#r=a,this.#C||(this.#C=requestAnimationFrame(()=>{this.#C=0,this.#r!==null&&(this.#Le(this.#r),this.#r=null)}))},{passive:!0,signal:o});const r=this.#n.querySelector(".tbw-scroll-area");this.#G=r,r&&this.#w&&r.addEventListener("scroll",()=>{const a=this.#Q;a.scrollTop=i.scrollTop,a.scrollLeft=r.scrollLeft,a.scrollHeight=i.scrollHeight,a.scrollWidth=r.scrollWidth,a.clientHeight=i.clientHeight,a.clientWidth=r.clientWidth,this.#e?.onScroll(a)},{passive:!0,signal:o});const s=this.#n.querySelector(".tbw-grid-content"),l=this.#G;s&&(s.addEventListener("wheel",a=>{const c=a.shiftKey||Math.abs(a.deltaX)>Math.abs(a.deltaY);if(c&&l){const d=a.shiftKey?a.deltaY:a.deltaX,{scrollLeft:f,scrollWidth:u,clientWidth:g}=l;(d>0&&f<u-g||d<0&&f>0)&&(a.preventDefault(),l.scrollLeft+=d)}else if(!c){const{scrollTop:d,scrollHeight:f,clientHeight:u}=i;(a.deltaY>0&&d<f-u||a.deltaY<0&&d>0)&&(a.preventDefault(),i.scrollTop+=a.deltaY)}},{passive:!1,signal:o}),xo(s,this.#k,{fauxScrollbar:i,scrollArea:l},o))}this._bodyEl&&$t(this,this._bodyEl,o),this.#y?.disconnect(),this._virtualization.viewportEl&&(this.#y=new ResizeObserver(()=>{this.#s.requestPhase(T.VIRTUALIZATION,"resize-observer")}),this.#y.observe(this._virtualization.viewportEl)),this.#n.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:o}),this.#n.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#n.contains(s))&&delete this.dataset.hasFocus},{signal:o})}#F=!1;#me(){if(this.#F)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#F=!0,this.#g?.disconnect(),this.#g=new ResizeObserver(()=>{this.#ie()}),this.#g.observe(e))}addEventListener(e,o,i){super.addEventListener(e,o,i)}removeEventListener(e,o,i){super.removeEventListener(e,o,i)}#P(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#ve(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,i)=>{const n=i===this._focusRow;o.setAttribute("aria-selected",String(n)),o.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(n&&s===this._focusCol))})})}#U(e){this.#v[e]=!0,!this.#p&&(this.#p=!0,queueMicrotask(()=>this.#Ce()))}#Ce(){if(!this.#p||!this.#f){this.#p=!1;return}const e=this.#v;if(this.#p=!1,this.#v={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#Se(),e.rows&&this.#re();return}e.columns&&this.#_e(),e.rows&&this.#re(),e.fitMode&&this.#Ee()}#re(){this._rows=Array.isArray(this.#a)?[...this.#a]:[],this.#B(),this.#s.requestPhase(T.ROWS,"applyRowsUpdate")}#B(){this.#S.clear();const e=this.#i.getRowId;this._rows.forEach((o,i)=>{const n=this.#se(o,e);n!==void 0&&this.#S.set(n,{row:o,index:i})})}#se(e,o){if(o)return o(e);const i=e;if("id"in i&&i.id!=null)return String(i.id);if("_id"in i&&i._id!=null)return String(i._id)}#ye(e,o){const i=this.#se(e,o);if(i===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return i}#_e(){j(this),this.#t.merge(),this.#H()}#Ee(){this.#t.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,Te(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),U(this))}#Se(){et(this,this.#o),tt(this,this.#o);const e=!!this.#n.querySelector(".has-shell"),o=!!this.#n.querySelector(".tbw-tool-panel"),i=this.#n.querySelectorAll(".tbw-accordion-section").length;this.#t.parseLightDomColumns(this),this.#t.merge(),this.#J(),ot(this,this.#o,this.#te()),this.#t.markSourcesChanged(),this.#t.merge();const n=Je(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=this.#i?.shell?.toolPanels?.length??0;if(e!==n||!o&&r||o&&s!==i){pe(this.#o),this.#K(),this.#W(),this.#oe(),this.#B();return}e&&this.#Re(),this.#B(),this.#s.requestPhase(T.COLUMNS,"applyGridConfigUpdate")}#Re(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;const o=this.#i.shell?.header?.title??this.#o.lightDomTitle;let i=e.querySelector(".tbw-shell-title");o?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=o):i&&i.remove()}#Ae(){if(this.#e){const e=this.#V.length>0?this.#V:this._columns,o=e.filter(r=>!r.hidden),i=e.filter(r=>r.hidden),n=this.#e.processColumns([...o]);if(n!==o){const r=new Set(n.map(l=>l.field));!o.some(l=>r.has(l.field))&&n.length>0?this._columns=[...n,...i]:this._columns=[...n,...i]}else this._columns=[...e]}}#Te(){j(this);const e=Array.isArray(this.#a)?[...this.#a]:[],o=this.#e?.processRows(e)??e;this._rows=o,this._virtualization.variableHeights&&this.#j()}#xe(e){const o={...Ee,...e.animation},i=o.mode??"reduced-motion";let n=1;i===!1||i==="off"?n=0:(i===!0||i==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${o.duration}ms`),this.style.setProperty("--tbw-animation-easing",o.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof i=="boolean"?i?"on":"off":i}#X(e,o,i=this.__rowRenderEpoch){this.#z||(this.#z=(n,r,s)=>this.#e?.renderRow(n,r,s)??!1),Ot(this,e,o,i,this.#z)}#le=F();#ae(e,o){ht(this.#le,this.__rowsBodyEl,this._bodyEl,e,o)}#Pe(){ft(this.#le,this.__rowsBodyEl,this.#i,this.#o)}#He(){const e=this.querySelector(".tbw-grid-root");e&&(this.#q?(this.#$||(this.#$=Xt(this.#i?.loadingRenderer)),Yt(e,this.#$)):jt(this.#$))}#ce(e,o){const i=this.#S.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);n&&Kt(n,o)}#de(e,o,i){const n=this.#S.get(e);if(!n)return;const r=this.findRenderedRowElement?.(n.index);if(!r)return;const s=this._visibleColumns.findIndex(a=>a.field===o);if(s<0)return;const l=r.children[s];l&&Qt(l,i)}#H(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#t.parseLightDomColumns(this),this.#O){const e=this.#O;this.#O=void 0,this.#t.merge();const o=this.#e?.getAll()??[];this.#t.applyState(e,o)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#s.requestPhase(T.FULL,"setup")}}#Le(e){if(this.refreshVirtualWindow(!1),this.#e?.onScrollRender(),this._virtualization.variableHeights&&(this.#m&&clearTimeout(this.#m),this.#m=window.setTimeout(()=>{this.#m=0,this.#fe(this._virtualization.start,this._virtualization.end)},100)),this.#w){const o=this._virtualization.container,i=this.#G,n=this.#Q;n.scrollTop=e,n.scrollLeft=i?.scrollLeft??0,n.scrollHeight=o?.scrollHeight??0,n.scrollWidth=i?.scrollWidth??0,n.clientHeight=o?.clientHeight??0,n.clientWidth=i?.clientWidth??0,this.#e?.onScroll(n)}}findHeaderRow(){return this.#n.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const i=o.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,i,n){const r=this._rows[o],s=this._columns[i];if(!r||!s)return!1;const l=s.field,a=r[l],c=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:o,colIndex:i,field:l,value:a,row:r,cellEl:n,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(c),c.defaultPrevented)return!0;const d={row:r,rowIndex:o,colIndex:i,field:l,value:a,cellEl:n,originalEvent:e},f=this.#e?.onCellClick(d)??!1;return this.#P("cell-click",d),f}_dispatchRowClick(e,o,i,n){if(!i)return!1;const r={rowIndex:o,row:i,rowEl:n,originalEvent:e},s=this.#e?.onRowClick(r)??!1;return this.#P("row-click",r),s}_dispatchHeaderClick(e,o,i){const n=this._columns[o];if(!n)return!1;const r={colIndex:o,field:n.field,column:n,headerEl:i,originalEvent:e};return this.#e?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#e?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#e?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#e?.queryPlugins(e)??[]}query(e,o){return this.#e?.queryPlugins({type:e,context:o})??[]}_dispatchCellMouseDown(e){return this.#e?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#e?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#e?.onCellMouseUp(e)}_afterCellRender(e){this.#e?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#e?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#e?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#e?.hasAfterRowRenderHook()??!1}async ready(){return this.#d}async forceLayout(){return this.#s.requestPhase(T.FULL,"forceLayout"),this.#s.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#ye(e,this.#i.getRowId)}getRow(e){return this.#S.get(e)?.row}updateRow(e,o,i="api"){const n=this.#S.get(e);if(!n)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=n,l=[];for(const[a,c]of Object.entries(o)){const d=r[a];d!==c&&(l.push({field:a,oldValue:d,newValue:c}),r[a]=c)}for(const{field:a,oldValue:c,newValue:d}of l)this.#P("cell-change",{row:r,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:o,source:i});l.length>0&&this.#s.requestPhase(T.ROWS,"updateRow")}updateRows(e,o="api"){let i=!1;for(const{id:n,changes:r}of e){const s=this.#S.get(n);if(!s)throw new Error(`[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:a}=s;for(const[c,d]of Object.entries(r)){const f=l[c];f!==d&&(i=!0,l[c]=d,this.#P("cell-change",{row:l,rowId:n,rowIndex:a,field:c,oldValue:f,newValue:d,changes:r,source:o}))}}i&&this.#s.requestPhase(T.ROWS,"updateRows")}animateRow(e,o){ue(this,e,o)}animateRows(e,o){no(this,e,o)}animateRowById(e,o){return ro(this,e,o)}setColumnVisible(e,o){const i=this.#t.setColumnVisible(e,o);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const o=this.#t.toggleColumnVisibility(e);return o&&this.requestStateChange(),o}isColumnVisible(e){return this.#t.isColumnVisible(e)}showAllColumns(){this.#t.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#t.getAllColumns()}setColumnOrder(e){this.#t.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#t.getColumnOrder()}getColumnState(){const e=this.#e?.getAll()??[];return this.#t.collectState(e)}set columnState(e){e&&(this.#O=e,this.#t.initialColumnState=e,this.#u&&this.#ze(e))}get columnState(){return this.getColumnState()}#ze(e){const o=this.#e?.getAll()??[];this.#t.applyState(e,o),this.#H()}requestStateChange(){const e=this.#e?.getAll()??[];this.#t.requestStateChange(e)}resetColumnState(){this.#O=void 0,this.__originalOrder=[];const e=this.#e?.getAll()??[];this.#t.resetState(e),this.#t.merge(),this.#H()}get isToolPanelOpen(){return this.#c.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#c.expandedSections}openToolPanel(){this.#c.openToolPanel()}closeToolPanel(){this.#c.closeToolPanel()}toggleToolPanel(){this.#c.toggleToolPanel()}toggleToolPanelSection(e){this.#c.toggleToolPanelSection(e)}getToolPanels(){return this.#c.getToolPanels()}registerToolPanel(e){this.#o.apiToolPanelIds.add(e.id),this.#c.registerToolPanel(e)}unregisterToolPanel(e){this.#o.apiToolPanelIds.delete(e),this.#c.unregisterToolPanel(e)}getHeaderContents(){return this.#c.getHeaderContents()}registerHeaderContent(e){this.#c.registerHeaderContent(e)}unregisterHeaderContent(e){this.#c.unregisterHeaderContent(e)}getToolbarContents(){return this.#c.getToolbarContents()}registerToolbarContent(e){this.#c.registerToolbarContent(e)}unregisterToolbarContent(e){this.#c.unregisterToolbarContent(e)}#Y=!1;refreshShellHeader(){this.#Y||(this.#Y=!0,queueMicrotask(()=>{this.#Y=!1,this.isConnected&&(this.#M(),this.#t.markSourcesChanged(),this.#t.merge(),pe(this.#o),this.#K(),this.#W(),this.#De())}))}#De(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#c.isInitialized){ge(this.#n,this.#o),fe(this.#n,this.#i?.shell,this.#o);const i=this.#i?.shell?.toolPanel?.defaultOpen;i&&this.#o.toolPanels.has(i)&&(this.openToolPanel(),this.#o.expandedSections.add(i))}this._resizeController=Ye(this),this.#ne(o),this.#s.requestPhase(T.COLUMNS,"shellRefresh")}#R=new Map;registerStyles(e,o){let i=this.#R.get(e);i||(i=new CSSStyleSheet,this.#R.set(e,i)),i.replaceSync(o),this.#he()}unregisterStyles(e){this.#R.delete(e)&&this.#he()}getRegisteredStyles(){return Array.from(this.#R.keys())}#he(){const e=Array.from(this.#R.values()),o=document.adoptedStyleSheets.filter(i=>!Array.from(this.#R.values()).includes(i));document.adoptedStyleSheets=[...o,...e]}#M(){et(this,this.#o),tt(this,this.#o),ot(this,this.#o,this.#te())}#ue(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;pe(this.#o);const o=co(this.#i.shell,this.#o,this.#i.icons?.toolPanel),i=document.createElement("div");i.innerHTML=o;const n=i.firstElementChild;n&&(e.replaceWith(n),this.#ge(),fe(this.#n,this.#i?.shell,this.#o))}#Oe(){const e=()=>{const i=this.#o.lightDomTitle,n=this.#o.hasToolButtonsContainer;this.#M();const r=this.#o.lightDomTitle,s=this.#o.hasToolButtonsContainer;(r&&!i||s&&!n)&&(this.#t.markSourcesChanged(),this.#t.merge(),this.#ue())},o=()=>{this.__lightDomColumnsCache=void 0,this.#H()};this.#t.registerLightDomHandler("tbw-grid-header",e),this.#t.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#t.registerLightDomHandler("tbw-grid-tool-panel",e),this.#t.registerLightDomHandler("tbw-grid-column",o),this.#t.registerLightDomHandler("tbw-grid-detail",o),this.#t.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,j(this),this.#t.parseLightDomColumns(this);const e=this.#o.lightDomTitle,o=this.#o.hasToolButtonsContainer;this.#M();const i=this.#o.lightDomTitle,n=this.#o.hasToolButtonsContainer;(i&&!e||n&&!o)&&(this.#t.markSourcesChanged(),this.#t.merge(),this.#ue()),this.#s.requestPhase(T.COLUMNS,"refreshColumns")}#L(e){const o=this._virtualization.container??this,i=this._virtualization.viewportEl??o,n=o.clientHeight,r=i.clientHeight,l=this.shadowRoot?.querySelector(".tbw-scroll-area"),a=l?l.clientHeight:n,d=a-r,f=Math.max(0,n-a);let u,g=0;return this._virtualization.variableHeights&&this._virtualization.positionCache?u=qo(this._virtualization.positionCache):(u=e*this._virtualization.rowHeight,g=this.#e?.getExtraHeight()??0),u+d+g+f}#j(){if(!this._virtualization.variableHeights)return;const e=this._rows,o=this._virtualization.rowHeight||28,i=this.#i.rowHeight,n=this.#i.getRowId,r=n?l=>n(l):void 0;this._virtualization.positionCache=No(e,this._virtualization.heightCache,o,{rowId:r},(l,a)=>{const c=this.#e?.getRowHeight?.(l,a);if(c!==void 0)return c;if(i){const d=i(l,a);if(d!==void 0&&d>0)return d}});const s=Go(this._virtualization.positionCache,e,o,(l,a)=>this.#e?.getRowHeight?.(l,a));this._virtualization.measuredCount=s.measuredCount,s.measuredCount>0&&(this._virtualization.averageHeight=s.averageHeight)}invalidateRowHeight(e,o){if(!this._virtualization.variableHeights||!this._virtualization.positionCache||e<0||e>=this._rows.length)return;const i=this._virtualization.positionCache,n=this._rows[e];let r=o;r===void 0&&(r=this.#e?.getRowHeight?.(n,e)),r===void 0&&(r=this._virtualization.rowHeight);const s=i[e];if(!(!s||Math.abs(s.height-r)<1)&&(Ce(i,e,r),this._virtualization.totalHeightEl)){const l=this.#L(this._rows.length);this._virtualization.totalHeightEl.style.height=`${l}px`}}#fe(e,o){if(!this._virtualization.variableHeights||!this._virtualization.positionCache||!this._bodyEl)return;const i=this._bodyEl.querySelectorAll(".data-grid-row"),n=this.#i.getRowId,r=Uo({positionCache:this._virtualization.positionCache,heightCache:this._virtualization.heightCache,rows:this._rows,defaultHeight:this._virtualization.rowHeight,start:e,end:o,getPluginHeight:(s,l)=>this.#e?.getRowHeight?.(s,l),getRowId:n?s=>n(s):void 0},i);if(r.hasChanges&&(this._virtualization.measuredCount=r.measuredCount,this._virtualization.averageHeight=r.averageHeight,this._virtualization.totalHeightEl)){const s=this.#L(this._rows.length);this._virtualization.totalHeightEl.style.height=`${s}px`}}refreshVirtualWindow(e=!1,o=!1){if(!this._bodyEl)return;const i=this._rows.length;if(!this._virtualization.enabled){this.#X(0,i),o||this.#e?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=i,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#X(0,i,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),e&&this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#L(i)}px`),this.#ae(i,this._visibleColumns.length),o||this.#e?.afterRender();return}const n=this._virtualization.container??this,r=this._virtualization.viewportEl??n,s=r.clientHeight,l=this._virtualization.rowHeight,a=n.scrollTop;let c;const d=this._virtualization.positionCache;if(this._virtualization.variableHeights&&d&&d.length>0)c=$o(d,a),c===-1&&(c=0);else{c=Math.floor(a/l);let w=0;const m=10;for(;w<m;){const C=this.#e?.getExtraHeightBefore?.(c)??0,_=Math.floor((a-C)/l);if(_>=c||_<0)break;c=_,w++}}c=c-c%2,c<0&&(c=0);const f=this.#e?.adjustVirtualStart(c,a,l);f!==void 0&&f<c&&(c=f,c=c-c%2,c<0&&(c=0));let u;if(this._virtualization.variableHeights&&d&&d.length>0){const w=s+l*3;let m=0;for(u=c;u<i&&m<w;)m+=d[u].height,u++;const C=Math.ceil(s/l)+3;u-c<C&&(u=Math.min(c+C,i))}else{const w=Math.ceil(s/l)+3;u=c+w}if(u>i&&(u=i),this._virtualization.start=c,this._virtualization.end=u,n.clientHeight===0&&s>0){this.#s.requestPhase(T.VIRTUALIZATION,"stale-refs-retry");return}if(e&&this._virtualization.totalHeightEl){const w=this.#L(i);this._virtualization.totalHeightEl.style.height=`${w}px`}let p;if(this._virtualization.variableHeights&&d&&d[c])p=d[c].offset;else{const w=this.#e?.getExtraHeightBefore?.(c)??0;p=c*l+w}const h=-(a-p);this._bodyEl.style.transform=`translateY(${h}px)`,this.#X(c,u,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),e&&this._virtualization.variableHeights&&this.#fe(c,u),this.#ae(i,this._visibleColumns.length),e&&!o&&(this.#e?.afterRender(),queueMicrotask(()=>{const w=n.clientHeight,m=r.clientHeight;if(w===0&&m>0)return;const C=this.#L(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${C}px`)}))}#K(){this.#M(),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#i?.shell;bo(this.#n,e,{isPanelOpen:this.#o.isPanelOpen,expandedSections:this.#o.expandedSections},this.#i?.icons)&&(this.#ge(),this.#c.setInitialized(!0))}#ge(){ho(this.#n,this.#i?.shell,this.#o,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#N?.(),this.#N=uo(this.#n,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(k.tagName)||customElements.define(k.tagName,k),globalThis.DataGridElement=k;const Bo={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class Xo{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#l;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#l?.abort(),this.#l=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#l?.abort(),this.#l=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}emitCancelable(e,o){const i=new CustomEvent(e,{detail:o,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(e,o){this.grid?._pluginManager?.subscribe(this,e,o)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,o){this.grid?._pluginManager?.emitPluginEvent(e,o)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#l?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...O,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const o=this.gridElement;return o?getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const o=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(o,10);if(!isNaN(i))return i}return 200}resolveIcon(e,o){return o!==void 0?o:this.gridIcons[e]}setIcon(e,o){typeof o=="string"?e.innerHTML=o:o instanceof HTMLElement&&(e.innerHTML="",e.appendChild(o.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const x={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},X={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Yo={ROOT:`.${x.ROOT}`,HEADER:`.${x.HEADER}`,HEADER_ROW:`.${x.HEADER_ROW}`,HEADER_CELL:`.${x.HEADER_CELL}`,ROWS_VIEWPORT:`.${x.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${x.ROWS_CONTAINER}`,DATA_ROW:`.${x.DATA_ROW}`,DATA_CELL:`.${x.DATA_CELL}`,GROUP_ROW:`.${x.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${x.DATA_ROW}[${X.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${x.DATA_CELL}[${X.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${x.DATA_ROW}[${X.ROW_INDEX}="${t}"] .${x.DATA_CELL}[${X.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${x.DATA_ROW}.${x.SELECTED}`,EDITING_CELL:`.${x.DATA_CELL}.${x.EDITING}`},jo={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function Ko(t){const e=document.createElement("tbw-grid");return t&&(e.gridConfig=t),e}function Qo(t,e=document){return e.querySelector(t)}const Zo={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},Jo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},ye={sum:(t,e)=>t.reduce((o,i)=>o+(Number(i[e])||0),0),avg:(t,e)=>{const o=t.reduce((i,n)=>i+(Number(n[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>t.length?Math.min(...t.map(o=>Number(o[e])||1/0)):0,max:(t,e)=>t.length?Math.max(...t.map(o=>Number(o[e])||-1/0)):0,first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},Y=new Map,D={register(t,e){Y.set(t,e)},unregister(t){Y.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:Y.get(t)??ye[t]},run(t,e,o,i){const n=this.get(t);return n?n(e,o,i):void 0},has(t){return Y.has(t)||t in ye},list(){return[...Object.keys(ye),...Y.keys()]}},ct={sum:t=>t.reduce((e,o)=>e+o,0),avg:t=>t.length?t.reduce((e,o)=>e+o,0)/t.length:0,count:t=>t.length,min:t=>t.length?Math.min(...t):0,max:t=>t.length?Math.max(...t):0,first:t=>t[0]??0,last:t=>t[t.length-1]??0};function dt(t){return ct[t]??ct.sum}function ei(t,e){return dt(t)(e)}const ti=D.register.bind(D),oi=D.unregister.bind(D),ii=D.get.bind(D),ni=D.run.bind(D),ri=D.list.bind(D);y.BaseGridPlugin=Xo,y.DEFAULT_ANIMATION_CONFIG=Ee,y.DEFAULT_GRID_ICONS=O,y.DGEvents=Zo,y.DataGridElement=k,y.FitModeEnum=q,y.GridCSSVars=jo,y.GridClasses=x,y.GridDataAttrs=X,y.GridElement=k,y.GridSelectors=Yo,y.PLUGIN_QUERIES=Bo,y.PluginEvents=Jo,y.PluginManager=B,y.RenderPhase=T,y.aggregatorRegistry=D,y.builtInSort=Fe,y.createGrid=Ko,y.defaultComparator=We,y.getAggregator=ii,y.getValueAggregator=dt,y.listAggregators=ri,y.queryGrid=Qo,y.registerAggregator=ti,y.runAggregator=ni,y.runValueAggregator=ei,y.unregisterAggregator=oi,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
89
91
  //# sourceMappingURL=grid.umd.js.map