@toolbox-web/grid 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/all.js +561 -471
  2. package/all.js.map +1 -1
  3. package/index.js +3 -3
  4. package/index.js.map +1 -1
  5. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +11 -0
  6. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  7. package/lib/plugins/context-menu/index.js +136 -77
  8. package/lib/plugins/context-menu/index.js.map +1 -1
  9. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  10. package/lib/plugins/filtering/index.js +246 -250
  11. package/lib/plugins/filtering/index.js.map +1 -1
  12. package/lib/plugins/multi-sort/index.js +11 -11
  13. package/lib/plugins/pivot/PivotPlugin.d.ts +2 -0
  14. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  15. package/lib/plugins/pivot/index.js +29 -27
  16. package/lib/plugins/pivot/index.js.map +1 -1
  17. package/lib/plugins/print/index.js +1 -1
  18. package/lib/plugins/print/index.js.map +1 -1
  19. package/lib/plugins/row-reorder/RowReorderPlugin.d.ts +18 -0
  20. package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +1 -1
  21. package/lib/plugins/row-reorder/index.js +132 -72
  22. package/lib/plugins/row-reorder/index.js.map +1 -1
  23. package/lib/plugins/selection/index.js +1 -1
  24. package/lib/plugins/visibility/index.js +7 -7
  25. package/package.json +1 -1
  26. package/themes/dg-theme-bootstrap.css +60 -33
  27. package/themes/dg-theme-material.css +83 -52
  28. package/themes/dg-theme-standard.css +80 -12
  29. package/themes/dg-theme-vibrant.css +78 -9
  30. package/umd/grid.all.umd.js +17 -17
  31. package/umd/grid.all.umd.js.map +1 -1
  32. package/umd/grid.umd.js +1 -1
  33. package/umd/grid.umd.js.map +1 -1
  34. package/umd/plugins/context-menu.umd.js +1 -1
  35. package/umd/plugins/context-menu.umd.js.map +1 -1
  36. package/umd/plugins/filtering.umd.js +1 -1
  37. package/umd/plugins/filtering.umd.js.map +1 -1
  38. package/umd/plugins/multi-sort.umd.js +1 -1
  39. package/umd/plugins/multi-sort.umd.js.map +1 -1
  40. package/umd/plugins/pivot.umd.js +1 -1
  41. package/umd/plugins/pivot.umd.js.map +1 -1
  42. package/umd/plugins/print.umd.js +1 -1
  43. package/umd/plugins/print.umd.js.map +1 -1
  44. package/umd/plugins/row-reorder.umd.js +1 -1
  45. package/umd/plugins/row-reorder.umd.js.map +1 -1
  46. package/umd/plugins/selection.umd.js +1 -1
  47. package/umd/plugins/selection.umd.js.map +1 -1
  48. package/umd/plugins/visibility.umd.js +1 -1
  49. package/umd/plugins/visibility.umd.js.map +1 -1
package/umd/grid.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(C,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(C=typeof globalThis<"u"?globalThis:C||self,q(C.TbwGrid={}))})(this,(function(C){"use strict";const q='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}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}@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}}@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)}}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}}',W={STRETCH:"stretch",FIXED:"fixed"},be={mode:"reduced-motion",duration:200,easing:"ease-out"},me='<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>',z={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:me,filterActive:me,print:"🖨️"};function it(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,c=o.hasAttribute("sortable"),a=o.hasAttribute("editable"),h={field:i,type:s,header:l,sortable:c,editable:a},u=o.getAttribute("width");if(u){const m=parseFloat(u);!isNaN(m)&&/^\d+(\.\d+)?$/.test(u.trim())?h.width=m:h.width=u}const g=o.getAttribute("minWidth")||o.getAttribute("min-width");if(g){const m=parseFloat(g);isNaN(m)||(h.minWidth=m)}o.hasAttribute("resizable")&&(h.resizable=!0),o.hasAttribute("sizable")&&(h.resizable=!0);const f=o.getAttribute("editor"),p=o.getAttribute("renderer");f&&(h.__editorName=f),p&&(h.__rendererName=p);const d=o.getAttribute("options");d&&(h.options=d.split(",").map(m=>{const[I,T]=m.includes(":")?m.split(":"):[m.trim(),m.trim()];return{value:I.trim(),label:T?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),R=o.querySelector("tbw-grid-column-header");w&&(h.__viewTemplate=w),b&&(h.__editorTemplate=b),R&&(h.__headerTemplate=R);const E=globalThis.DataGridElement?.getAdapters?.()??[],P=w??o,v=E.find(m=>m.canHandle(P));if(v){const m=v.createRenderer(P);m&&(h.viewRenderer=m)}const S=b??o,_=E.find(m=>m.canHandle(S));if(_){const m=_.createEditor(S);m&&(h.editor=m)}return h}).filter(o=>!!o)}function ve(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,c=s.renderer||s.viewRenderer;return l&&!c&&(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 Ce(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 ye(t){const e=t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH;if(e!==W.STRETCH&&e!==W.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 c of t._rowPool){const a=c.children[r];if(a){const h=a.scrollWidth;h>l&&(l=h)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&B(t),t.__didInitialAutoSize=!0}function B(t){(t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH)===W.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 nt(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 rt(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=nt(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 st=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",lt=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,at=/__(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 dt=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"]),_e=/^on\w+$/i,ht=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),ut=/^\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,ft(e.content),e.innerHTML}function ft(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(dt.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>_e.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(_e.test(l)){r.push(s.name);continue}if(ht.has(l)&&ut.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 Ee(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(st,(l,c)=>{const a=gt(c,e);return o.push({expr:c.trim(),result:a}),a}),n=pt(i),r=o.length&&o.every(l=>l.result===""||l.result===D);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function gt(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||!lt.test(t)||at.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 pt(t){return t&&t.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function wt(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 Se(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":Ee(t,i));return o.__blocked=e,o}const bt=100;class mt{#l;#n;#u;#d;#h;#a={};#i={};#f=!0;#p=[];#m;#s;#v;#r;#b;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.#b}set lightDomTitle(e){this.#b=e}get initialColumnState(){return this.#v}set initialColumnState(e){this.#v=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.#w();this.#f=!1,this.#a=o,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#i=this.#S(this.#a),this.#x()}#S(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}#x(){const e=this.#i;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.#l?{...this.#l}:{},o=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#d??[]).map(s=>({...s}));let n=ve(o,i);this.#n&&this.#n.length&&(n=ve(this.#n,i));const r=this.#r.getRows();return n.length===0&&r.length&&(n=rt(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=Se(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Se(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#C(e),e.columnState&&!this.#v&&(this.#v=e.columnState),e}#C(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#b=o),this.#b&&!e.shell.header.title&&(e.shell.header.title=this.#b);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()),c=this.#l?.shell?.header?.toolbarContents??[],a=new Set(c.map(u=>u.id)),h=[...c];for(const u of l)a.has(u.id)||h.push(u);h.sort((u,g)=>(u.order??0)-(g.order??0)),e.shell.header.toolbarContents=h}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 c=i.get(n.field);c&&(s.sort=c);for(const a of e)if(a.getColumnState){const h=a.getColumnState(n.field);h&&Object.assign(s,h)}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 c=n.get(l.field);if(!c)return l;const a={...l};return c.width!==void 0&&(a.width=c.width,a.__renderedWidth=c.width),c.visible!==void 0&&(a.hidden=!c.visible),a});r.sort((l,c)=>{const a=n.get(l.field)?.order??1/0,h=n.get(c.field)?.order??1/0;return a-h}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,c)=>(l.sort?.priority??0)-(c.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 c of e.columns)l.applyColumnState(c.field,c)}resetState(e){this.#v=void 0,this.#r.setSortState(null),this.#i=this.#S(this.#a),this.#x();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)},bt)}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?it(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.#m&&this.#m.disconnect();const o=new Set;let i=null;const n=()=>{i=null;for(const r of o)this.#g.get(r)?.();o.clear()};this.#m=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const a=l.tagName.toLowerCase();this.#g.has(a)&&o.add(a)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const c=s.target.tagName.toLowerCase();this.#g.has(c)&&o.add(c)}}o.size>0&&!i&&(i=setTimeout(n,0))}),this.#m.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.#m?.disconnect(),this.#p=[],this.#s&&clearTimeout(this.#s)}}function Re(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"&#x1F5F9;":"&#9744;"}</span>`}function Te(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 Ae(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 vt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function re(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function xe(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const i=t.effectiveConfig?.typeDefaults;if(i?.[e.type]?.renderer)return i[e.type].renderer;const n=t.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}function Pe(t,e){if(e.format)return e.format;if(!e.type)return;const o=t.effectiveConfig?.typeDefaults;if(o?.[e.type]?.format)return o[e.type].format;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const n=i.getTypeDefault(e.type);if(n?.format)return n.format}}const Le='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function se(t){return(t.__editingCellCount??0)>0}function le(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const He=document.createElement("template");He.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Oe=document.createElement("template");Oe.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function Ct(){return He.content.firstElementChild.cloneNode(!0)}function yt(){return Oe.content.firstElementChild.cloneNode(!0)}function Z(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function _t(t,e,o,i,n){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,c=l.length;let a=t.__cachedHeaderRowCount;for(a===void 0&&(a=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=a);t._rowPool.length<r;){const g=yt();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 h=n&&t.__hasRenderRowPlugins!==!1,u=t._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const f=e+g,p=t._rows[f],d=t._rowPool[g];if(d.setAttribute("aria-rowindex",String(f+a+1)),h&&n(p,d,f)){d.__epoch=i,d.__rowDataRef=p,d.parentNode!==s&&s.appendChild(d);continue}const w=d.__epoch,b=d.__rowDataRef,R=d.children.length,E=w===i&&R===c,P=b!==p;let v=!1;if(E&&P){for(let T=0;T<c;T++)if(l[T].externalView&&!d.querySelector(`.cell[data-col="${T}"] [data-external-view]`)){v=!0;break}}if(!E||v){const T=se(d),A=t._activeEditRows===f;T&&!A?(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):T&&A?(ae(t,d,p,f),d.__rowDataRef=p):(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p)}else if(P){const T=se(d),A=t._activeEditRows===f;T&&!A?(le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):(ae(t,d,p,f),d.__rowDataRef=p)}else{const T=se(d),A=t._activeEditRows===f;T&&!A?(le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):ae(t,d,p,f)}let S=!1;const _=t.changedRowIds;if(_&&_.length>0)try{const T=t.getRowId?.(p);T&&(S=_.includes(T))}catch{}const m=d.classList.contains("changed");S!==m&&d.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const T=d.getAttribute("data-dynamic-classes");T&&T.split(" ").forEach(A=>A&&d.classList.remove(A));try{const A=I(p);if(A&&A.length>0){const we=A.filter(ne=>ne&&typeof ne=="string");we.forEach(ne=>d.classList.add(ne)),d.setAttribute("data-dynamic-classes",we.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(A){console.warn("[tbw-grid] rowClass callback error:",A),d.removeAttribute("data-dynamic-classes")}}u&&t._afterRowRender?.({row:p,rowIndex:f,rowElement:d}),d.parentNode!==s&&s.appendChild(d)}}function ae(t,e,o,i){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,c=s<l?s:l,a=t._focusRow,h=t._focusCol,u=t._hasAfterCellRenderHook?.()??!1;let g=t.__hasSpecialColumns;if(g===void 0){g=!1;const p=t.effectiveConfig?.typeDefaults,d=t.__frameworkAdapter;for(let w=0;w<s;w++){const b=r[w];if(b.__viewTemplate||b.__compiledView||b.renderer||b.viewRenderer||b.externalView||b.format||b.type==="date"||b.type==="boolean"||b.type&&p?.[b.type]?.renderer||b.type&&p?.[b.type]?.format||b.type&&d?.getTypeDefault?.(b.type)?.renderer||b.type&&d?.getTypeDefault?.(b.type)?.format){g=!0;break}}t.__hasSpecialColumns=g}const f=String(i);if(!g){for(let p=0;p<c;p++){const d=n[p];if(d.classList.contains("editing"))continue;const w=r[p],b=o[w.field];d.textContent=b==null?"":String(b),d.getAttribute("data-row")!==f&&d.setAttribute("data-row",f);const R=a===i&&h===p,y=d.classList.contains("cell-focus");R!==y&&(d.classList.toggle("cell-focus",R),d.setAttribute("aria-selected",String(R))),u&&t._afterCellRender?.({row:o,rowIndex:i,column:w,colIndex:p,value:b,cellElement:d,rowElement:e})}return}for(let p=0;p<c;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){X(t,e,o,i);return}for(let p=0;p<c;p++){const d=r[p],w=n[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const b=a===i&&h===p,R=w.classList.contains("cell-focus");b!==R&&(w.classList.toggle("cell-focus",b),w.setAttribute("aria-selected",String(b)));const y=d.cellClass;if(y){const _=w.getAttribute("data-dynamic-classes");_&&_.split(" ").forEach(m=>m&&w.classList.remove(m));try{const m=o[d.field],I=y(m,o,d);if(I&&I.length>0){const T=I.filter(A=>A&&typeof A=="string");T.forEach(A=>w.classList.add(A)),w.setAttribute("data-dynamic-classes",T.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(m){console.warn(`[tbw-grid] cellClass callback error for column '${d.field}':`,m),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const E=xe(t,d);if(E){const _=o[d.field],m=E({row:o,value:_,field:d.field,column:d,cellEl:w});typeof m=="string"?w.innerHTML=$(m):m instanceof Node?m.parentElement!==w&&(w.innerHTML="",w.appendChild(m)):m==null&&(w.textContent=_==null?"":String(_)),u&&t._afterCellRender?.({row:o,rowIndex:i,column:d,colIndex:p,value:_,cellElement:w,rowElement:e});continue}if(d.__viewTemplate||d.__compiledView||d.externalView)continue;const P=o[d.field];let v;const S=Pe(t,d);if(S)try{const _=S(P,o);v=_==null?"":String(_)}catch(_){console.warn(`[tbw-grid] Format error in column '${d.field}':`,_),v=P==null?"":String(P)}else d.type==="date"?(v=Te(P),w.textContent=v):d.type==="boolean"?w.innerHTML=Re(!!P):(v=P==null?"":String(P),w.textContent=v);u&&t._afterCellRender?.({row:o,rowIndex:i,column:d,colIndex:p,value:P,cellElement:w,rowElement:e})}}function X(t,e,o,i){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,c=t,a=t._hasAfterCellRenderHook?.()??!1,h=document.createDocumentFragment();for(let u=0;u<r;u++){const g=n[u],f=Ct();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 d=Pe(t,g);if(d)try{p=d(p,o)}catch(v){console.warn(`[tbw-grid] Format error in column '${g.field}':`,v)}const w=g.__compiledView,b=g.__viewTemplate,R=xe(t,g),y=g.externalView;let E=!1;if(R){const v=R({row:o,value:p,field:g.field,column:g,cellEl:f});typeof v=="string"?(f.innerHTML=$(v),E=!0):v instanceof Node?v.parentElement!==f&&(f.textContent="",f.appendChild(v)):v==null&&(f.textContent=p==null?"":String(p))}else if(y){const v=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(v.mount)try{v.mount({placeholder:S,context:_,spec:v})}catch(m){console.warn(`[tbw-grid] External view mount error for column '${g.field}':`,m)}else queueMicrotask(()=>{try{c.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:v,context:_}}))}catch(m){console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`,m)}});S.setAttribute("data-mounted","")}else if(w){const v=w({row:o,value:p,field:g.field,column:g}),S=w.__blocked;f.innerHTML=S?"":$(v),E=!0,S&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(b){const v=b.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(v)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=$(Ee(v,{row:o,value:p})),E=!0)}else g.type==="date"?f.textContent=Te(p):g.type==="boolean"?f.innerHTML=Re(!!p):f.textContent=p==null?"":String(p);if(E){wt(f);const v=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(v)&&(f.textContent=v.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 v=o[g.field],S=P(v,o,g);if(S&&S.length>0){const _=S.filter(m=>m&&typeof m=="string");_.forEach(m=>f.classList.add(m)),f.setAttribute("data-dynamic-classes",_.join(" "))}}catch(v){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,v)}a&&t._afterCellRender?.({row:o,rowIndex:i,column:g,colIndex:u,value:p,cellElement:f,rowElement:e}),h.appendChild(f)}e.appendChild(h)}function De(t,e,o){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]"),n=Ae(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 c=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){c&&(re(t._bodyEl??t),s.classList.add("cell-focus"));const a=s.querySelector(Le);try{a?.focus({preventScroll:!0})}catch{}return}F(t)}}}function Et(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?.()??[],c=l.length?l[0]:e.target,a=h=>{if(!h)return!1;const u=h.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||h.isContentEditable)};if(!(a(c)&&(e.key==="Home"||e.key==="End"))&&!(a(c)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&c.tagName==="INPUT"&&c.type==="number")&&!(a(c)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(a(c)&&(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),F(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":t._focusCol=Math.min(i,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":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(),F(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(),F(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 h=t._focusRow,u=t._focusCol,g=t._visibleColumns[u],f=t._rows[h],p=g?.field??"",d=p&&f?f[p]:void 0,w=t.querySelector(`[data-row="${h}"][data-col="${u}"]`),b={rowIndex:h,colIndex:u,field:p,value:d,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},R=new CustomEvent("cell-activate",{cancelable:!0,detail:b});t.dispatchEvent(R);const y=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:h,col:u}});if(t.dispatchEvent(y),R.defaultPrevented||y.defaultPrevented){e.preventDefault();return}break}default:return}F(t)}}function F(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:c}=t._virtualization,a=l,h=c?.clientHeight??a?.clientHeight??0;if(a&&h>0){const u=t._focusRow*s;u<a.scrollTop?a.scrollTop=u:u+s>a.scrollTop+h&&(a.scrollTop=u-h+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),re(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 c=t.querySelector(".tbw-scroll-area");if(c&&l&&!o)if(e?.forceScrollLeft)c.scrollLeft=0;else if(e?.forceScrollRight)c.scrollLeft=c.scrollWidth-c.clientWidth;else{const a=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!a.skipScroll){const h=l.getBoundingClientRect(),u=c.getBoundingClientRect(),g=h.left-u.left+c.scrollLeft,f=g+h.width,p=c.scrollLeft+a.left,d=c.scrollLeft+c.clientWidth-a.right;g<p?c.scrollLeft=g-a.left:f>d&&(c.scrollLeft=f-c.clientWidth+a.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const a=l.querySelector(Le);if(a&&document.activeElement!==a)try{a.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 St(t,e){const o=Ae(e),i=vt(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,re(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function ce(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 d=document.elementFromPoint(o.clientX,o.clientY);d&&(n=d)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),c=n?.closest?.(".header-row");let a,h,u,g,f,p;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&h>=0&&(u=t._rows[a],p=t._columns[h],g=p?.field,f=u&&g?u[g]:void 0)),{type:i,row:u,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:h!==void 0&&h>=0?h:void 0,field:g,value:f,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!c,cell:a!==void 0&&h!==void 0&&a>=0&&h>=0?{row:a,col:h}:void 0}}function Rt(t,e,o){const i=ce(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(i)??!1)&&Q.set(t,!0)}function Tt(t,e,o){if(!Q.get(t))return;const i=ce(t,e,o,"mousemove");t._dispatchCellMouseMove?.(i)}function At(t,e,o){if(!Q.get(t))return;const i=ce(t,e,o,"mouseup");t._dispatchCellMouseUp?.(i),Q.set(t,!1)}function xt(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||St(t,n))},{signal:o}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&&De(t,i,n)},{signal:o}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&&De(t,i,n)},{signal:o})}function Pt(t,e,o,i){e.addEventListener("keydown",n=>Et(t,n),{signal:i}),o.addEventListener("mousedown",n=>Rt(t,o,n),{signal:i}),document.addEventListener("mousemove",n=>Tt(t,o,n),{signal:i}),document.addEventListener("mouseup",n=>At(t,o,n),{signal:i})}function Me(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function ze(t,e,o){const n=o.find(l=>l.field===e.field)?.sortComparator??Me,{field:r,direction:s}=e;return[...t].sort((l,c)=>n(l[r],c[r],l,c)*s)}function Ne(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 Ie(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),ke(t,e,1)):t._sortState.direction===1?ke(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 ke(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??ze)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{Ne(t,l,e,o)}):Ne(t,s,e,o)}function Y(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Lt(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");Ce(o,"sort-indicator");const i=t._sortState?.field===e.field?t._sortState.direction:0,n={...z,...t.icons},r=i===1?n.sortAsc:i===-1?n.sortDesc:n.sortNone;return Lt(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)||Ie(t,e)}),i.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,o,i))return;Ie(t,e)}})}function Ht(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",Ce(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 c={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>Y(t,o)?J(t,o):null,renderFilterButton:()=>null,renderResizeHandle:()=>ee(t,i,n)},a=o.headerRenderer(c);Ht(n,a),Y(t,o)&&te(t,o,i,n),o.resizable&&n.classList.add("resizable")}else if(o.headerLabelRenderer){const c={column:o,value:r},a=o.headerLabelRenderer(c),h=document.createElement("span");a==null?h.textContent=r:typeof a=="string"?h.innerHTML=$(a):a instanceof Node&&h.appendChild(a),n.appendChild(h),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(c=>n.appendChild(c.cloneNode(!0))),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)));else{const c=document.createElement("span");c.textContent=r,n.appendChild(c),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(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 qe=typeof requestIdleCallback=="function";function Ot(t,e){return qe?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function We(t){qe?cancelIdleCallback(t):clearTimeout(t)}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 Dt{#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 $e(t){let e=null,o=null,i=null,n=null;const r=c=>{if(!e)return;const a=c.clientX-e.startX,h=Math.max(40,e.startWidth+a),u=t._visibleColumns[e.colIndex];u.width=h,u.__userResized=!0,u.__renderedWidth=h,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:h}}))};let s=!1;const l=()=>{const c=e!==null;c&&(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,c&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(c,a,h){c.preventDefault();const u=t._visibleColumns[a],g=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??g??h.getBoundingClientRect().width;e={startX:c.clientX,colIndex:a,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(c){const a=t._visibleColumns[c];a&&(a.__userResized=!1,a.__renderedWidth=void 0,a.width=a.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:a.field,width:a.width}})))},dispose(){l()}}}const de="data-animating",Mt={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},zt={change:500,insert:300,remove:200};function Nt(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function It(t,e){const o=Mt[e],i=getComputedStyle(t).getPropertyValue(o);if(i){const n=Nt(i);if(!isNaN(n)&&n>0)return n}return zt[e]}function kt(t,e,o){t.removeAttribute(de),t.offsetWidth,t.setAttribute(de,e);const i=It(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(de)},i)}function he(t,e,o){if(e<0)return!1;const i=t.findRenderedRowElement?.(e);return i?(kt(i,o),!0):!1}function qt(t,e,o){let i=0;for(const n of e)he(t,n,o)&&i++;return i}function Wt(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:he(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 O(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 Fe(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 Ue=document.createElement("template");Ue.innerHTML=`
1
+ (function(C,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(C=typeof globalThis<"u"?globalThis:C||self,q(C.TbwGrid={}))})(this,(function(C){"use strict";const q='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}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}@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}}@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)}}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}}',W={STRETCH:"stretch",FIXED:"fixed"},be={mode:"reduced-motion",duration:200,easing:"ease-out"},me='<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>',z={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:me,filterActive:me,print:"🖨️"};function it(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,c=o.hasAttribute("sortable"),a=o.hasAttribute("editable"),h={field:i,type:s,header:l,sortable:c,editable:a},u=o.getAttribute("width");if(u){const m=parseFloat(u);!isNaN(m)&&/^\d+(\.\d+)?$/.test(u.trim())?h.width=m:h.width=u}const g=o.getAttribute("minWidth")||o.getAttribute("min-width");if(g){const m=parseFloat(g);isNaN(m)||(h.minWidth=m)}o.hasAttribute("resizable")&&(h.resizable=!0),o.hasAttribute("sizable")&&(h.resizable=!0);const f=o.getAttribute("editor"),p=o.getAttribute("renderer");f&&(h.__editorName=f),p&&(h.__rendererName=p);const d=o.getAttribute("options");d&&(h.options=d.split(",").map(m=>{const[I,T]=m.includes(":")?m.split(":"):[m.trim(),m.trim()];return{value:I.trim(),label:T?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),R=o.querySelector("tbw-grid-column-header");w&&(h.__viewTemplate=w),b&&(h.__editorTemplate=b),R&&(h.__headerTemplate=R);const E=globalThis.DataGridElement?.getAdapters?.()??[],P=w??o,v=E.find(m=>m.canHandle(P));if(v){const m=v.createRenderer(P);m&&(h.viewRenderer=m)}const S=b??o,_=E.find(m=>m.canHandle(S));if(_){const m=_.createEditor(S);m&&(h.editor=m)}return h}).filter(o=>!!o)}function ve(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,c=s.renderer||s.viewRenderer;return l&&!c&&(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 Ce(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 ye(t){const e=t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH;if(e!==W.STRETCH&&e!==W.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 c of t._rowPool){const a=c.children[r];if(a){const h=a.scrollWidth;h>l&&(l=h)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&B(t),t.__didInitialAutoSize=!0}function B(t){(t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH)===W.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 nt(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 rt(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=nt(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 st=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",lt=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,at=/__(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 dt=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"]),_e=/^on\w+$/i,ht=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),ut=/^\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,ft(e.content),e.innerHTML}function ft(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(dt.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>_e.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(_e.test(l)){r.push(s.name);continue}if(ht.has(l)&&ut.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 Ee(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(st,(l,c)=>{const a=gt(c,e);return o.push({expr:c.trim(),result:a}),a}),n=pt(i),r=o.length&&o.every(l=>l.result===""||l.result===D);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function gt(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||!lt.test(t)||at.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 pt(t){return t&&t.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function wt(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 Se(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":Ee(t,i));return o.__blocked=e,o}const bt=100;class mt{#l;#n;#u;#d;#h;#a={};#i={};#f=!0;#p=[];#m;#s;#v;#r;#b;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.#b}set lightDomTitle(e){this.#b=e}get initialColumnState(){return this.#v}set initialColumnState(e){this.#v=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.#w();this.#f=!1,this.#a=o,Object.freeze(this.#a),this.#a.columns&&Object.freeze(this.#a.columns),this.#i=this.#S(this.#a),this.#x()}#S(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}#x(){const e=this.#i;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.#l?{...this.#l}:{},o=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#d??[]).map(s=>({...s}));let n=ve(o,i);this.#n&&this.#n.length&&(n=ve(this.#n,i));const r=this.#r.getRows();return n.length===0&&r.length&&(n=rt(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=Se(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Se(s.__editorTemplate.innerHTML))}),e.columns=n),this.#u&&(e.fitMode=this.#u),e.fitMode||(e.fitMode="stretch"),this.#C(e),e.columnState&&!this.#v&&(this.#v=e.columnState),e}#C(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#b=o),this.#b&&!e.shell.header.title&&(e.shell.header.title=this.#b);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()),c=this.#l?.shell?.header?.toolbarContents??[],a=new Set(c.map(u=>u.id)),h=[...c];for(const u of l)a.has(u.id)||h.push(u);h.sort((u,g)=>(u.order??0)-(g.order??0)),e.shell.header.toolbarContents=h}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 c=i.get(n.field);c&&(s.sort=c);for(const a of e)if(a.getColumnState){const h=a.getColumnState(n.field);h&&Object.assign(s,h)}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 c=n.get(l.field);if(!c)return l;const a={...l};return c.width!==void 0&&(a.width=c.width,a.__renderedWidth=c.width),c.visible!==void 0&&(a.hidden=!c.visible),a});r.sort((l,c)=>{const a=n.get(l.field)?.order??1/0,h=n.get(c.field)?.order??1/0;return a-h}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,c)=>(l.sort?.priority??0)-(c.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 c of e.columns)l.applyColumnState(c.field,c)}resetState(e){this.#v=void 0,this.#r.setSortState(null),this.#i=this.#S(this.#a),this.#x();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)},bt)}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?it(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.#m&&this.#m.disconnect();const o=new Set;let i=null;const n=()=>{i=null;for(const r of o)this.#g.get(r)?.();o.clear()};this.#m=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const a=l.tagName.toLowerCase();this.#g.has(a)&&o.add(a)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const c=s.target.tagName.toLowerCase();this.#g.has(c)&&o.add(c)}}o.size>0&&!i&&(i=setTimeout(n,0))}),this.#m.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.#m?.disconnect(),this.#p=[],this.#s&&clearTimeout(this.#s)}}function Re(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"&#x1F5F9;":"&#9744;"}</span>`}function Te(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 Ae(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 vt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function re(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function xe(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const i=t.effectiveConfig?.typeDefaults;if(i?.[e.type]?.renderer)return i[e.type].renderer;const n=t.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}function Pe(t,e){if(e.format)return e.format;if(!e.type)return;const o=t.effectiveConfig?.typeDefaults;if(o?.[e.type]?.format)return o[e.type].format;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const n=i.getTypeDefault(e.type);if(n?.format)return n.format}}const Le='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function se(t){return(t.__editingCellCount??0)>0}function le(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const He=document.createElement("template");He.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Oe=document.createElement("template");Oe.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function Ct(){return He.content.firstElementChild.cloneNode(!0)}function yt(){return Oe.content.firstElementChild.cloneNode(!0)}function Z(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function _t(t,e,o,i,n){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,c=l.length;let a=t.__cachedHeaderRowCount;for(a===void 0&&(a=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=a);t._rowPool.length<r;){const g=yt();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 h=n&&t.__hasRenderRowPlugins!==!1,u=t._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const f=e+g,p=t._rows[f],d=t._rowPool[g];if(d.setAttribute("aria-rowindex",String(f+a+1)),h&&n(p,d,f)){d.__epoch=i,d.__rowDataRef=p,d.parentNode!==s&&s.appendChild(d);continue}const w=d.__epoch,b=d.__rowDataRef,R=d.children.length,E=w===i&&R===c,P=b!==p;let v=!1;if(E&&P){for(let T=0;T<c;T++)if(l[T].externalView&&!d.querySelector(`.cell[data-col="${T}"] [data-external-view]`)){v=!0;break}}if(!E||v){const T=se(d),A=t._activeEditRows===f;T&&!A?(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):T&&A?(ae(t,d,p,f),d.__rowDataRef=p):(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p)}else if(P){const T=se(d),A=t._activeEditRows===f;T&&!A?(le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):(ae(t,d,p,f),d.__rowDataRef=p)}else{const T=se(d),A=t._activeEditRows===f;T&&!A?(le(d),X(t,d,p,f),d.__epoch=i,d.__rowDataRef=p):ae(t,d,p,f)}let S=!1;const _=t.changedRowIds;if(_&&_.length>0)try{const T=t.getRowId?.(p);T&&(S=_.includes(T))}catch{}const m=d.classList.contains("changed");S!==m&&d.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const T=d.getAttribute("data-dynamic-classes");T&&T.split(" ").forEach(A=>A&&d.classList.remove(A));try{const A=I(p);if(A&&A.length>0){const we=A.filter(ne=>ne&&typeof ne=="string");we.forEach(ne=>d.classList.add(ne)),d.setAttribute("data-dynamic-classes",we.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(A){console.warn("[tbw-grid] rowClass callback error:",A),d.removeAttribute("data-dynamic-classes")}}u&&t._afterRowRender?.({row:p,rowIndex:f,rowElement:d}),d.parentNode!==s&&s.appendChild(d)}}function ae(t,e,o,i){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,c=s<l?s:l,a=t._focusRow,h=t._focusCol,u=t._hasAfterCellRenderHook?.()??!1;let g=t.__hasSpecialColumns;if(g===void 0){g=!1;const p=t.effectiveConfig?.typeDefaults,d=t.__frameworkAdapter;for(let w=0;w<s;w++){const b=r[w];if(b.__viewTemplate||b.__compiledView||b.renderer||b.viewRenderer||b.externalView||b.format||b.type==="date"||b.type==="boolean"||b.type&&p?.[b.type]?.renderer||b.type&&p?.[b.type]?.format||b.type&&d?.getTypeDefault?.(b.type)?.renderer||b.type&&d?.getTypeDefault?.(b.type)?.format){g=!0;break}}t.__hasSpecialColumns=g}const f=String(i);if(!g){for(let p=0;p<c;p++){const d=n[p];if(d.classList.contains("editing"))continue;const w=r[p],b=o[w.field];d.textContent=b==null?"":String(b),d.getAttribute("data-row")!==f&&d.setAttribute("data-row",f);const R=a===i&&h===p,y=d.classList.contains("cell-focus");R!==y&&(d.classList.toggle("cell-focus",R),d.setAttribute("aria-selected",String(R))),u&&t._afterCellRender?.({row:o,rowIndex:i,column:w,colIndex:p,value:b,cellElement:d,rowElement:e})}return}for(let p=0;p<c;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){X(t,e,o,i);return}for(let p=0;p<c;p++){const d=r[p],w=n[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const b=a===i&&h===p,R=w.classList.contains("cell-focus");b!==R&&(w.classList.toggle("cell-focus",b),w.setAttribute("aria-selected",String(b)));const y=d.cellClass;if(y){const _=w.getAttribute("data-dynamic-classes");_&&_.split(" ").forEach(m=>m&&w.classList.remove(m));try{const m=o[d.field],I=y(m,o,d);if(I&&I.length>0){const T=I.filter(A=>A&&typeof A=="string");T.forEach(A=>w.classList.add(A)),w.setAttribute("data-dynamic-classes",T.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(m){console.warn(`[tbw-grid] cellClass callback error for column '${d.field}':`,m),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const E=xe(t,d);if(E){const _=o[d.field],m=E({row:o,value:_,field:d.field,column:d,cellEl:w});typeof m=="string"?w.innerHTML=$(m):m instanceof Node?m.parentElement!==w&&(w.innerHTML="",w.appendChild(m)):m==null&&(w.textContent=_==null?"":String(_)),u&&t._afterCellRender?.({row:o,rowIndex:i,column:d,colIndex:p,value:_,cellElement:w,rowElement:e});continue}if(d.__viewTemplate||d.__compiledView||d.externalView)continue;const P=o[d.field];let v;const S=Pe(t,d);if(S)try{const _=S(P,o);v=_==null?"":String(_)}catch(_){console.warn(`[tbw-grid] Format error in column '${d.field}':`,_),v=P==null?"":String(P)}else d.type==="date"?(v=Te(P),w.textContent=v):d.type==="boolean"?w.innerHTML=Re(!!P):(v=P==null?"":String(P),w.textContent=v);u&&t._afterCellRender?.({row:o,rowIndex:i,column:d,colIndex:p,value:P,cellElement:w,rowElement:e})}}function X(t,e,o,i){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,c=t,a=t._hasAfterCellRenderHook?.()??!1,h=document.createDocumentFragment();for(let u=0;u<r;u++){const g=n[u],f=Ct();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 d=Pe(t,g);if(d)try{p=d(p,o)}catch(v){console.warn(`[tbw-grid] Format error in column '${g.field}':`,v)}const w=g.__compiledView,b=g.__viewTemplate,R=xe(t,g),y=g.externalView;let E=!1;if(R){const v=R({row:o,value:p,field:g.field,column:g,cellEl:f});typeof v=="string"?(f.innerHTML=$(v),E=!0):v instanceof Node?v.parentElement!==f&&(f.textContent="",f.appendChild(v)):v==null&&(f.textContent=p==null?"":String(p))}else if(y){const v=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(v.mount)try{v.mount({placeholder:S,context:_,spec:v})}catch(m){console.warn(`[tbw-grid] External view mount error for column '${g.field}':`,m)}else queueMicrotask(()=>{try{c.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:S,spec:v,context:_}}))}catch(m){console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`,m)}});S.setAttribute("data-mounted","")}else if(w){const v=w({row:o,value:p,field:g.field,column:g}),S=w.__blocked;f.innerHTML=S?"":$(v),E=!0,S&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(b){const v=b.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(v)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=$(Ee(v,{row:o,value:p})),E=!0)}else g.type==="date"?f.textContent=Te(p):g.type==="boolean"?f.innerHTML=Re(!!p):f.textContent=p==null?"":String(p);if(E){wt(f);const v=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(v)&&(f.textContent=v.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 v=o[g.field],S=P(v,o,g);if(S&&S.length>0){const _=S.filter(m=>m&&typeof m=="string");_.forEach(m=>f.classList.add(m)),f.setAttribute("data-dynamic-classes",_.join(" "))}}catch(v){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,v)}a&&t._afterCellRender?.({row:o,rowIndex:i,column:g,colIndex:u,value:p,cellElement:f,rowElement:e}),h.appendChild(f)}e.appendChild(h)}function De(t,e,o){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]"),n=Ae(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 c=t._focusRow!==n||t._focusCol!==l;if(t._focusRow=n,t._focusCol=l,s.classList.contains("editing")){c&&(re(t._bodyEl??t),s.classList.add("cell-focus"));const a=s.querySelector(Le);try{a?.focus({preventScroll:!0})}catch{}return}F(t)}}}function Et(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?.()??[],c=l.length?l[0]:e.target,a=h=>{if(!h)return!1;const u=h.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||h.isContentEditable)};if(!(a(c)&&(e.key==="Home"||e.key==="End"))&&!(a(c)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&c.tagName==="INPUT"&&c.type==="number")&&!(a(c)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(a(c)&&(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),F(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":t._focusCol=Math.min(i,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":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(),F(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(),F(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 h=t._focusRow,u=t._focusCol,g=t._visibleColumns[u],f=t._rows[h],p=g?.field??"",d=p&&f?f[p]:void 0,w=t.querySelector(`[data-row="${h}"][data-col="${u}"]`),b={rowIndex:h,colIndex:u,field:p,value:d,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},R=new CustomEvent("cell-activate",{cancelable:!0,detail:b});t.dispatchEvent(R);const y=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:h,col:u}});if(t.dispatchEvent(y),R.defaultPrevented||y.defaultPrevented){e.preventDefault();return}break}default:return}F(t)}}function F(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:c}=t._virtualization,a=l,h=c?.clientHeight??a?.clientHeight??0;if(a&&h>0){const u=t._focusRow*s;u<a.scrollTop?a.scrollTop=u:u+s>a.scrollTop+h&&(a.scrollTop=u-h+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),re(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 c=t.querySelector(".tbw-scroll-area");if(c&&l&&!o)if(e?.forceScrollLeft)c.scrollLeft=0;else if(e?.forceScrollRight)c.scrollLeft=c.scrollWidth-c.clientWidth;else{const a=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!a.skipScroll){const h=l.getBoundingClientRect(),u=c.getBoundingClientRect(),g=h.left-u.left+c.scrollLeft,f=g+h.width,p=c.scrollLeft+a.left,d=c.scrollLeft+c.clientWidth-a.right;g<p?c.scrollLeft=g-a.left:f>d&&(c.scrollLeft=f-c.clientWidth+a.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const a=l.querySelector(Le);if(a&&document.activeElement!==a)try{a.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 St(t,e){const o=Ae(e),i=vt(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,re(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function ce(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 d=document.elementFromPoint(o.clientX,o.clientY);d&&(n=d)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),c=n?.closest?.(".header-row");let a,h,u,g,f,p;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&h>=0&&(u=t._rows[a],p=t._columns[h],g=p?.field,f=u&&g?u[g]:void 0)),{type:i,row:u,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:h!==void 0&&h>=0?h:void 0,field:g,value:f,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!c,cell:a!==void 0&&h!==void 0&&a>=0&&h>=0?{row:a,col:h}:void 0}}function Rt(t,e,o){const i=ce(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(i)??!1)&&Q.set(t,!0)}function Tt(t,e,o){if(!Q.get(t))return;const i=ce(t,e,o,"mousemove");t._dispatchCellMouseMove?.(i)}function At(t,e,o){if(!Q.get(t))return;const i=ce(t,e,o,"mouseup");t._dispatchCellMouseUp?.(i),Q.set(t,!1)}function xt(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||St(t,n))},{signal:o}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&&De(t,i,n)},{signal:o}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&&De(t,i,n)},{signal:o})}function Pt(t,e,o,i){e.addEventListener("keydown",n=>Et(t,n),{signal:i}),o.addEventListener("mousedown",n=>Rt(t,o,n),{signal:i}),document.addEventListener("mousemove",n=>Tt(t,o,n),{signal:i}),document.addEventListener("mouseup",n=>At(t,o,n),{signal:i})}function Me(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function ze(t,e,o){const n=o.find(l=>l.field===e.field)?.sortComparator??Me,{field:r,direction:s}=e;return[...t].sort((l,c)=>n(l[r],c[r],l,c)*s)}function Ne(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 Ie(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),ke(t,e,1)):t._sortState.direction===1?ke(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 ke(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??ze)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{Ne(t,l,e,o)}):Ne(t,s,e,o)}function Y(t,e){return t.effectiveConfig?.sortable!==!1&&e.sortable===!0}function Lt(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");Ce(o,"sort-indicator");const i=t._sortState?.field===e.field?t._sortState.direction:0,n={...z,...t.icons},r=i===1?n.sortAsc:i===-1?n.sortDesc:n.sortNone;return Lt(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)||Ie(t,e)}),i.addEventListener("keydown",r=>{if(r.key==="Enter"||r.key===" "){if(r.preventDefault(),t._dispatchHeaderClick?.(r,o,i))return;Ie(t,e)}})}function Ht(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",Ce(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 c={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>Y(t,o)?J(t,o):null,renderFilterButton:()=>null,renderResizeHandle:()=>ee(t,i,n)},a=o.headerRenderer(c);Ht(n,a),Y(t,o)&&te(t,o,i,n),o.resizable&&n.classList.add("resizable")}else if(o.headerLabelRenderer){const c={column:o,value:r},a=o.headerLabelRenderer(c),h=document.createElement("span");a==null?h.textContent=r:typeof a=="string"?h.innerHTML=$(a):a instanceof Node&&h.appendChild(a),n.appendChild(h),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(c=>n.appendChild(c.cloneNode(!0))),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(n.classList.add("resizable"),n.appendChild(ee(t,i,n)));else{const c=document.createElement("span");c.textContent=r,n.appendChild(c),Y(t,o)&&(te(t,o,i,n),n.appendChild(J(t,o))),o.resizable&&(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 qe=typeof requestIdleCallback=="function";function Ot(t,e){return qe?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function We(t){qe?cancelIdleCallback(t):clearTimeout(t)}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 Dt{#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 $e(t){let e=null,o=null,i=null,n=null;const r=c=>{if(!e)return;const a=c.clientX-e.startX,h=Math.max(40,e.startWidth+a),u=t._visibleColumns[e.colIndex];u.width=h,u.__userResized=!0,u.__renderedWidth=h,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:h}}))};let s=!1;const l=()=>{const c=e!==null;c&&(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,c&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(c,a,h){c.preventDefault();const u=t._visibleColumns[a],g=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??g??h.getBoundingClientRect().width;e={startX:c.clientX,colIndex:a,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(c){const a=t._visibleColumns[c];a&&(a.__userResized=!1,a.__renderedWidth=void 0,a.width=a.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:a.field,width:a.width}})))},dispose(){l()}}}const de="data-animating",Mt={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},zt={change:500,insert:300,remove:200};function Nt(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function It(t,e){const o=Mt[e],i=getComputedStyle(t).getPropertyValue(o);if(i){const n=Nt(i);if(!isNaN(n)&&n>0)return n}return zt[e]}function kt(t,e,o){t.removeAttribute(de),t.offsetWidth,t.setAttribute(de,e);const i=It(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(de)},i)}function he(t,e,o){if(e<0)return!1;const i=t.findRenderedRowElement?.(e);return i?(kt(i,o),!0):!1}function qt(t,e,o){let i=0;for(const n of e)he(t,n,o)&&i++;return i}function Wt(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:he(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 O(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 Fe(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 Ue=document.createElement("template");Ue.innerHTML=`
2
2
  <div class="tbw-scroll-area">
3
3
  <div class="rows-body-wrapper">
4
4
  <div class="rows-body" role="grid">