@toolbox-web/grid 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +8 -0
- package/all.js +1671 -1140
- package/all.js.map +1 -1
- package/index.d.ts +4 -163
- package/index.js +803 -1338
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +48 -50
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +12 -12
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +13 -13
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/custom-elements.json +0 -1934
package/umd/grid.all.umd.js
CHANGED
|
@@ -70,26 +70,26 @@
|
|
|
70
70
|
${n}
|
|
71
71
|
</div>
|
|
72
72
|
</div>
|
|
73
|
-
`}#he(){Qt(this.#t,this.#n?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onToolbarButtonClick:e=>this.#fe(e)}),this.#L?.(),this.#L=eo(this.#t,this.#n?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}#fe(e){const n=(this.#n?.shell?.header?.toolbarButtons??[]).find(r=>r.id===e);if(n?.action){n.action();return}const i=this.#e.toolbarButtons.get(e);i?.action&&i.action()}}customElements.get(Z.tagName)||customElements.define(Z.tagName,Z);class T{version="1.0.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}requestRender(){this.grid?.requestRender?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?.visibleColumns??[]}get shadowRoot(){return this.grid?.shadowRoot??null}get disconnectSignal(){return this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...I,...e}}resolveIcon(e,t){return t!==void 0?t:this.gridIcons[e]}setIcon(e,t){typeof t=="string"?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}function oe(o){return{startRow:Math.min(o.startRow,o.endRow),startCol:Math.min(o.startCol,o.endCol),endRow:Math.max(o.startRow,o.endRow),endCol:Math.max(o.startCol,o.endCol)}}function ro(o){const e=oe(o);return{from:{row:e.startRow,col:e.startCol},to:{row:e.endRow,col:e.endCol}}}function ce(o){return o.map(ro)}function so(o,e,t){const n=oe(t);return o>=n.startRow&&o<=n.endRow&&e>=n.startCol&&e<=n.endCol}function Ke(o,e,t){return t.some(n=>so(o,e,n))}function lo(o){const e=[],t=oe(o);for(let n=t.startRow;n<=t.endRow;n++)for(let i=t.startCol;i<=t.endCol;i++)e.push({row:n,col:i});return e}function ao(o){const e=new Map;for(const t of o)for(const n of lo(t))e.set(`${n.row},${n.col}`,n);return[...e.values()]}function de(o,e){return{startRow:o.row,startCol:o.col,endRow:e.row,endCol:e.col}}const co=':host .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';function uo(o,e,t){if(o==="cell"&&e.selectedCell)return{mode:o,ranges:[{from:{row:e.selectedCell.row,col:e.selectedCell.col},to:{row:e.selectedCell.row,col:e.selectedCell.col}}]};if(o==="row"&&e.selected.size>0){const n=[...e.selected].map(i=>({from:{row:i,col:0},to:{row:i,col:t-1}}));return{mode:o,ranges:n}}return o==="range"&&e.ranges.length>0?{mode:o,ranges:ce(e.ranges)}:{mode:o,ranges:[]}}class ho extends T{name="selection";version="1.0.0";get defaultConfig(){return{mode:"cell"}}selected=new Set;lastSelected=null;anchor=null;ranges=[];activeRange=null;cellAnchor=null;isDragging=!1;selectedCell=null;detach(){this.selected.clear(),this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.isDragging=!1,this.selectedCell=null}onCellClick(e){const{rowIndex:t,colIndex:n,originalEvent:i}=e,{mode:r}=this.config;if(r==="cell")return this.selectedCell={row:t,col:n},this.emit("selection-change",this.#i()),this.requestAfterRender(),!1;if(r==="row")return this.selected.clear(),this.selected.add(t),this.lastSelected=t,this.emit("selection-change",this.#i()),this.requestAfterRender(),!1;if(r==="range"){const s=i.shiftKey,l=i.ctrlKey||i.metaKey;if(s&&this.cellAnchor){const a=de(this.cellAnchor,{row:t,col:n});l?this.ranges.length>0?this.ranges[this.ranges.length-1]=a:this.ranges.push(a):this.ranges=[a],this.activeRange=a}else if(l){const a={startRow:t,startCol:n,endRow:t,endCol:n};this.ranges.push(a),this.activeRange=a,this.cellAnchor={row:t,col:n}}else{const a={startRow:t,startCol:n,endRow:t,endCol:n};this.ranges=[a],this.activeRange=a,this.cellAnchor={row:t,col:n}}return this.emit("selection-change",this.#i()),this.requestAfterRender(),!1}return!1}onKeyDown(e){const{mode:t}=this.config,i=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(e.key);if(e.key==="Escape")return t==="cell"?this.selectedCell=null:t==="row"?(this.selected.clear(),this.anchor=null):t==="range"&&(this.ranges=[],this.activeRange=null,this.cellAnchor=null),this.emit("selection-change",this.#i()),this.requestAfterRender(),!0;if(t==="cell"&&i)return queueMicrotask(()=>{const r=this.grid;this.selectedCell={row:r.focusRow,col:r.focusCol},this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1;if(t==="row"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return queueMicrotask(()=>{const r=this.grid;this.selected.clear(),this.selected.add(r.focusRow),this.lastSelected=r.focusRow,this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1;if(t==="range"&&i){const r=e.shiftKey;return queueMicrotask(()=>{const s=this.grid,l=s.focusRow,a=s.focusCol;if(r){this.cellAnchor||(this.cellAnchor={row:l,col:a});const c=de(this.cellAnchor,{row:l,col:a});this.ranges=[c],this.activeRange=c}else this.ranges=[],this.activeRange=null,this.cellAnchor={row:l,col:a};this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1}if(t==="range"&&e.key==="a"&&(e.ctrlKey||e.metaKey)){const r=this.rows.length,s=this.columns.length;if(r>0&&s>0){const l={startRow:0,startCol:0,endRow:r-1,endCol:s-1};return this.ranges=[l],this.activeRange=l,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}}return!1}onCellMouseDown(e){if(this.config.mode!=="range"||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0||e.originalEvent.shiftKey&&this.cellAnchor)return;this.isDragging=!0;const t=e.rowIndex,n=e.colIndex;this.cellAnchor={row:t,col:n},e.originalEvent.ctrlKey||e.originalEvent.metaKey||(this.ranges=[]);const r={startRow:t,startCol:n,endRow:t,endCol:n};return this.ranges.push(r),this.activeRange=r,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}onCellMouseMove(e){if(this.config.mode!=="range"||!this.isDragging||!this.cellAnchor||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;const t=de(this.cellAnchor,{row:e.rowIndex,col:e.colIndex});return this.ranges.length>0?this.ranges[this.ranges.length-1]=t:this.ranges.push(t),this.activeRange=t,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}onCellMouseUp(e){if(this.config.mode==="range"&&this.isDragging)return this.isDragging=!1,!0}#t(){const e=this.shadowRoot;if(!e)return;const{mode:t}=this.config;e.querySelectorAll(".cell").forEach(r=>{r.classList.remove("selected","top","bottom","first","last")});const i=e.querySelectorAll(".data-grid-row");if(i.forEach(r=>{r.classList.remove("selected","row-focus")}),t==="row"&&(e.querySelectorAll(".cell-focus").forEach(r=>r.classList.remove("cell-focus")),i.forEach(r=>{const s=r.querySelector(".cell[data-row]"),l=parseInt(s?.getAttribute("data-row")??"-1",10);l>=0&&this.selected.has(l)&&r.classList.add("selected","row-focus")})),t==="range"&&this.ranges.length>0){const r=this.activeRange?oe(this.activeRange):null;e.querySelectorAll(".cell[data-row][data-col]").forEach(l=>{const a=parseInt(l.getAttribute("data-row")??"-1",10),c=parseInt(l.getAttribute("data-col")??"-1",10);a>=0&&c>=0&&Ke(a,c,this.ranges)&&(l.classList.add("selected"),l.classList.remove("cell-focus"),r&&(a===r.startRow&&l.classList.add("top"),a===r.endRow&&l.classList.add("bottom"),c===r.startCol&&l.classList.add("first"),c===r.endCol&&l.classList.add("last")))})}t==="cell"&&this.selectedCell&&e.querySelectorAll(".cell-focus").forEach(r=>r.classList.remove("cell-focus"))}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.children[0],{mode:n}=this.config;this.grid.setAttribute("data-selection-mode",n),t&&t.classList.toggle("selecting",this.isDragging),this.#t()}onScrollRender(){this.#t()}getSelectedCell(){return this.selectedCell}getSelectedRows(){return[...this.selected]}getRanges(){return ce(this.ranges)}getSelectedCells(){return ao(this.ranges)}isCellSelected(e,t){return Ke(e,t,this.ranges)}clearSelection(){this.selectedCell=null,this.selected.clear(),this.anchor=null,this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.emit("selection-change",{mode:this.config.mode,ranges:[]}),this.requestAfterRender()}setRanges(e){this.ranges=e.map(t=>({startRow:t.from.row,startCol:t.from.col,endRow:t.to.row,endCol:t.to.col})),this.activeRange=this.ranges.length>0?this.ranges[this.ranges.length-1]:null,this.emit("selection-change",{mode:this.config.mode,ranges:ce(this.ranges)}),this.requestAfterRender()}#i(){return uo(this.config.mode,{selectedCell:this.selectedCell,selected:this.selected,ranges:this.ranges},this.columns.length)}styles=co}function ue(o,e,t){return o.id!==void 0?String(o.id):t?`${t}-${e}`:String(e)}function Ve(o,e,t,n=null,i=0){const r=e.childrenField??"children",s=[];for(let l=0;l<o.length;l++){const a=o[l],c=ue(a,l,n),d=a[r],h=Array.isArray(d)&&d.length>0,f=t.has(c);if(s.push({key:c,data:a,depth:i,hasChildren:h,isExpanded:f,parentKey:n}),h&&f){const u=Ve(d,e,t,c,i+1);s.push(...u)}}return s}function We(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function he(o,e,t=null,n=0){const i=e.childrenField??"children",r=new Set;for(let s=0;s<o.length;s++){const l=o[s],a=ue(l,s,t),c=l[i];if(Array.isArray(c)&&c.length>0){r.add(a);const d=he(c,e,a,n+1);for(const h of d)r.add(h)}}return r}function fo(){return new Set}function je(o,e,t,n=null,i=0){const r=t.childrenField??"children";for(let s=0;s<o.length;s++){const l=o[s],a=ue(l,s,n);if(a===e)return[a];const c=l[r];if(Array.isArray(c)&&c.length>0){const d=je(c,e,t,a,i+1);if(d)return[a,...d]}}return null}function po(o,e,t,n){const i=je(o,e,t);if(!i)return n;const r=new Set(n);for(let s=0;s<i.length-1;s++)r.add(i[s]);return r}function Ue(o,e="children"){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o)if(t&&Array.isArray(t[e])&&t[e].length>0)return!0;return!1}function go(o){if(!Array.isArray(o)||o.length===0)return null;const e=["children","items","nodes","subRows","nested"];for(const t of o)if(!(!t||typeof t!="object")){for(const n of e)if(Array.isArray(t[n])&&t[n].length>0)return n}return null}const bo=".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";class wo extends T{name="tree";version="1.0.0";get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0}}expandedKeys=new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=new Map;detach(){this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear()}detect(e){if(!this.config.autoDetect)return!1;const t=this.config.childrenField??go(e)??"children";return Ue(e,t)}processRows(e){const t=this.config.childrenField??"children";if(!Ue(e,t))return this.flattenedRows=[],this.rowKeyMap.clear(),[...e];this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=he(e,this.config),this.initialExpansionDone=!0),this.flattenedRows=Ve(e,this.config,this.expandedKeys),this.rowKeyMap.clear();for(const n of this.flattenedRows)this.rowKeyMap.set(n.key,n);return this.flattenedRows.map(n=>({...n.data,__treeKey:n.key,__treeDepth:n.depth,__treeHasChildren:n.hasChildren,__treeExpanded:n.isExpanded}))}processColumns(e){if(this.flattenedRows.length===0)return[...e];const t=this.config.indentWidth??20,n=this.config.showExpandIcons??!0,i=[...e];if(i.length>0){const r={...i[0]},s=r.viewRenderer;if(s?.__treeWrapped)return i;const l=a=>{const{value:c,row:d,column:h}=a,f=d.__treeDepth??0,u=d.__treeHasChildren??!1,p=d.__treeExpanded??!1,g=document.createElement("span");if(g.style.display="flex",g.style.alignItems="center",g.style.paddingLeft=`${f*t}px`,u&&n){const w=document.createElement("span");w.className="tree-toggle",this.setIcon(w,this.resolveIcon(p?"collapse":"expand")),w.style.cursor="pointer",w.style.marginRight="4px",w.style.fontSize="10px",w.setAttribute("data-tree-key",d.__treeKey),g.appendChild(w)}else if(n){const w=document.createElement("span");w.style.width="14px",w.style.display="inline-block",g.appendChild(w)}const b=document.createElement("span");if(s){const w=s(a);w instanceof Node?b.appendChild(w):b.textContent=String(w??c??"")}else b.textContent=String(c??"");return g.appendChild(b),g};l.__treeWrapped=!0,r.viewRenderer=l,i[0]=r}return i}onCellClick(e){const t=e.originalEvent?.target;if(!t?.classList.contains("tree-toggle"))return!1;const n=t.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return i?(this.expandedKeys=We(this.expandedKeys,n),this.emit("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth}),this.requestRender(),!0):!1}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=We(this.expandedKeys,e),this.requestRender()}expandAll(){this.expandedKeys=he(this.rows,this.config),this.requestRender()}collapseAll(){this.expandedKeys=fo(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=po(this.rows,e,this.config,this.expandedKeys),this.requestRender()}styles=bo}const M={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},J={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},mo={ROOT:`.${M.ROOT}`,HEADER:`.${M.HEADER}`,HEADER_ROW:`.${M.HEADER_ROW}`,HEADER_CELL:`.${M.HEADER_CELL}`,ROWS_VIEWPORT:`.${M.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${M.ROWS_CONTAINER}`,DATA_ROW:`.${M.DATA_ROW}`,DATA_CELL:`.${M.DATA_CELL}`,GROUP_ROW:`.${M.GROUP_ROW}`,ROW_BY_INDEX:o=>`.${M.DATA_ROW}[${J.ROW_INDEX}="${o}"]`,CELL_BY_FIELD:o=>`.${M.DATA_CELL}[${J.FIELD}="${o}"]`,CELL_AT:(o,e)=>`.${M.DATA_ROW}[${J.ROW_INDEX}="${o}"] .${M.DATA_CELL}[${J.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${M.DATA_ROW}.${M.SELECTED}`,EDITING_CELL:`.${M.DATA_CELL}.${M.EDITING}`},vo={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"},Co={CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},yo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},fe={sum:(o,e)=>o.reduce((t,n)=>t+(Number(n[e])||0),0),avg:(o,e)=>{const t=o.reduce((n,i)=>n+(Number(i[e])||0),0);return o.length?t/o.length:0},count:o=>o.length,min:(o,e)=>Math.min(...o.map(t=>Number(t[e])||1/0)),max:(o,e)=>Math.max(...o.map(t=>Number(t[e])||-1/0)),first:(o,e)=>o[0]?.[e],last:(o,e)=>o[o.length-1]?.[e]},Q=new Map,D={register(o,e){Q.set(o,e)},unregister(o){Q.delete(o)},get(o){if(o!==void 0)return typeof o=="function"?o:Q.get(o)??fe[o]},run(o,e,t,n){const i=this.get(o);return i?i(e,t,n):void 0},has(o){return Q.has(o)||o in fe},list(){return[...Object.keys(fe),...Q.keys()]}},Xe={sum:o=>o.reduce((e,t)=>e+t,0),avg:o=>o.length?o.reduce((e,t)=>e+t,0)/o.length:0,count:o=>o.length,min:o=>o.length?Math.min(...o):0,max:o=>o.length?Math.max(...o):0,first:o=>o[0]??0,last:o=>o[o.length-1]??0};function pe(o){return Xe[o]??Xe.sum}function xo(o,e){return pe(o)(e)}const Eo=D.register.bind(D),Ro=D.unregister.bind(D),Ye=D.get.bind(D),ge=D.run.bind(D),So=D.list.bind(D);function Ao(o,e,t,n){if(n.processCell)return n.processCell(o,e,t);if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const i=String(o),r=n.delimiter??" ",s=n.newline??`
|
|
74
|
-
`;return n.quoteStrings||i.includes(r)||i.includes(s)||i.includes('"')?`"${i.replace(/"/g,'""')}"`:i}function
|
|
75
|
-
`,l=t.filter(h=>!h.hidden&&!h.field.startsWith("__")),a=[];if(i.includeHeaders){const h=l.map(f=>{const u=f.header||f.field;return u.includes(r)||u.includes(s)||u.includes('"')?`"${u.replace(/"/g,'""')}"`:u});a.push(h.join(r))}const d=[...n instanceof Set?[...n]:n].sort((h,f)=>h-f);for(const h of d){const f=e[h];if(!f)continue;const u=l.map(p=>
|
|
73
|
+
`}#he(){Qt(this.#t,this.#n?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onToolbarButtonClick:e=>this.#fe(e)}),this.#L?.(),this.#L=eo(this.#t,this.#n?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}#fe(e){const n=(this.#n?.shell?.header?.toolbarButtons??[]).find(r=>r.id===e);if(n?.action){n.action();return}const i=this.#e.toolbarButtons.get(e);i?.action&&i.action()}}customElements.get(Z.tagName)||customElements.define(Z.tagName,Z);class T{version="1.0.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}requestRender(){this.grid?.requestRender?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?.visibleColumns??[]}get shadowRoot(){return this.grid?.shadowRoot??null}get disconnectSignal(){return this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...I,...e}}resolveIcon(e,t){return t!==void 0?t:this.gridIcons[e]}setIcon(e,t){typeof t=="string"?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const M={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},J={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},ro={ROOT:`.${M.ROOT}`,HEADER:`.${M.HEADER}`,HEADER_ROW:`.${M.HEADER_ROW}`,HEADER_CELL:`.${M.HEADER_CELL}`,ROWS_VIEWPORT:`.${M.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${M.ROWS_CONTAINER}`,DATA_ROW:`.${M.DATA_ROW}`,DATA_CELL:`.${M.DATA_CELL}`,GROUP_ROW:`.${M.GROUP_ROW}`,ROW_BY_INDEX:o=>`.${M.DATA_ROW}[${J.ROW_INDEX}="${o}"]`,CELL_BY_FIELD:o=>`.${M.DATA_CELL}[${J.FIELD}="${o}"]`,CELL_AT:(o,e)=>`.${M.DATA_ROW}[${J.ROW_INDEX}="${o}"] .${M.DATA_CELL}[${J.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${M.DATA_ROW}.${M.SELECTED}`,EDITING_CELL:`.${M.DATA_CELL}.${M.EDITING}`},so={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"},lo={CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},ao={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},ce={sum:(o,e)=>o.reduce((t,n)=>t+(Number(n[e])||0),0),avg:(o,e)=>{const t=o.reduce((n,i)=>n+(Number(i[e])||0),0);return o.length?t/o.length:0},count:o=>o.length,min:(o,e)=>Math.min(...o.map(t=>Number(t[e])||1/0)),max:(o,e)=>Math.max(...o.map(t=>Number(t[e])||-1/0)),first:(o,e)=>o[0]?.[e],last:(o,e)=>o[o.length-1]?.[e]},Q=new Map,D={register(o,e){Q.set(o,e)},unregister(o){Q.delete(o)},get(o){if(o!==void 0)return typeof o=="function"?o:Q.get(o)??ce[o]},run(o,e,t,n){const i=this.get(o);return i?i(e,t,n):void 0},has(o){return Q.has(o)||o in ce},list(){return[...Object.keys(ce),...Q.keys()]}},Ke={sum:o=>o.reduce((e,t)=>e+t,0),avg:o=>o.length?o.reduce((e,t)=>e+t,0)/o.length:0,count:o=>o.length,min:o=>o.length?Math.min(...o):0,max:o=>o.length?Math.max(...o):0,first:o=>o[0]??0,last:o=>o[o.length-1]??0};function de(o){return Ke[o]??Ke.sum}function co(o,e){return de(o)(e)}const uo=D.register.bind(D),ho=D.unregister.bind(D),Ve=D.get.bind(D),ue=D.run.bind(D),fo=D.list.bind(D);function po(o,e,t,n){if(n.processCell)return n.processCell(o,e,t);if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const i=String(o),r=n.delimiter??" ",s=n.newline??`
|
|
74
|
+
`;return n.quoteStrings||i.includes(r)||i.includes(s)||i.includes('"')?`"${i.replace(/"/g,'""')}"`:i}function he(o){const{rows:e,columns:t,selectedIndices:n,config:i}=o,r=i.delimiter??" ",s=i.newline??`
|
|
75
|
+
`,l=t.filter(h=>!h.hidden&&!h.field.startsWith("__")),a=[];if(i.includeHeaders){const h=l.map(f=>{const u=f.header||f.field;return u.includes(r)||u.includes(s)||u.includes('"')?`"${u.replace(/"/g,'""')}"`:u});a.push(h.join(r))}const d=[...n instanceof Set?[...n]:n].sort((h,f)=>h-f);for(const h of d){const f=e[h];if(!f)continue;const u=l.map(p=>po(f[p.field],p.field,f,i));a.push(u.join(r))}return a.join(s)}async function fe(o){try{return await navigator.clipboard.writeText(o),!0}catch{const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}function We(o,e){const t=e.delimiter??" ",n=e.newline??`
|
|
76
76
|
`,i=o.replace(/\r\n/g,`
|
|
77
77
|
`).replace(/\r/g,`
|
|
78
|
-
`),r=[];let s=[],l="",a=!1;for(let c=0;c<i.length;c++){const d=i[c];d==='"'&&!a?a=!0:d==='"'&&a?i[c+1]==='"'?(l+='"',c++):a=!1:d===t&&!a?(s.push(l),l=""):d===n&&!a?(s.push(l),l="",(s.length>1||s.some(h=>h.trim()!==""))&&r.push(s),s=[]):l+=d}return s.push(l),(s.length>1||s.some(c=>c.trim()!==""))&&r.push(s),r}async function
|
|
79
|
-
`,quoteStrings:!1}}lastCopied=null;detach(){this.lastCopied=null}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="c",n=(e.ctrlKey||e.metaKey)&&e.key==="v";return t?(this.#t(e.target),!0):n?(this.#i(),!0):!1}#t(e){const t=this.#g(),n=t?.getSelectedRows()??[],i=n.length>0,r=t?.getRanges()??[],s=r.length>0,l=t?.getSelectedCell()!=null;let a,c,d;if(i&&t)a=
|
|
80
|
-
`,f=[],u=this.columns.slice(a,c+1);if(this.config.includeHeaders){const p=u.map(g=>g.header||g.field);f.push(p.join(d))}for(let p=s;p<=l;p++){const g=this.rows[p];if(!g)continue;const b=u.map(w=>{const A=g[w.field];return A==null?"":A instanceof Date?A.toISOString():String(A)});f.push(b.join(d))}return{text:f.join(h),rowCount:l-s+1,columnCount:c-a+1}}#l(e){const t=e.closest("[data-field-cache]");if(!t)return null;const n=t.dataset.fieldCache;if(!n)return null;const i=t.dataset.row;if(!i)return null;const r=parseInt(i,10);if(isNaN(r))return null;const s=this.rows[r];if(!s)return null;const l=s[n],c=this.columns.find(h=>h.field===n)?.header||n;let d;if(this.config.includeHeaders){const h=l==null?"":String(l);d=`${c}: ${h}`}else d=l==null?"":String(l);return{text:d,field:n,value:l}}async copy(){const t=this.#g()?.getSelectedRows()??[],n=be({rows:this.rows,columns:[...this.columns],selectedIndices:t,config:this.config});return await we(n),this.lastCopied={text:n,timestamp:Date.now()},n}async copyRows(e){const t=be({rows:this.rows,columns:[...this.columns],selectedIndices:e,config:this.config});return await we(t),this.lastCopied={text:t,timestamp:Date.now()},t}async paste(){const e=await Je();return e?Ze(e,this.config):null}getLastCopied(){return this.lastCopied}}const Qe=100;function me(o){if(o==null)return Qe;if(typeof o=="number")return o;const e=parseFloat(o);return isNaN(e)?Qe:e}function et(o){return o.map(e=>me(e.width))}function tt(o){const e=[];let t=0;for(const n of o)e.push(t),t+=me(n.width);return e}function ot(o){return o.reduce((e,t)=>e+me(t.width),0)}function ko(o,e,t,n,i){const r=t.length;if(r===0)return{startCol:0,endCol:0,visibleColumns:[]};let s=To(o,t,n);s=Math.max(0,s-i);const l=o+e;let a=s;for(let d=s;d<r;d++){if(t[d]>=l){a=d-1;break}a=d}a=Math.min(r-1,a+i);const c=[];for(let d=s;d<=a;d++)c.push(d);return{startCol:s,endCol:a,visibleColumns:c}}function To(o,e,t){let n=0,i=e.length-1;for(;n<i;){const r=Math.floor((n+i)/2);e[r]+t[r]<=o?n=r+1:i=r}return n}function Lo(o,e,t){return t?o>e:!1}class Po extends T{name="columnVirtualization";version="1.0.0";get defaultConfig(){return{autoEnable:!0,threshold:30,overscan:3}}isVirtualized=!1;startCol=0;endCol=0;scrollLeft=0;totalWidth=0;columnWidths=[];columnOffsets=[];attach(e){super.attach(e);const t=this.columns;this.columnWidths=et(t),this.columnOffsets=tt(t),this.totalWidth=ot(t),this.endCol=t.length-1}detach(){this.columnWidths=[],this.columnOffsets=[],this.isVirtualized=!1,this.startCol=0,this.endCol=0,this.scrollLeft=0,this.totalWidth=0}processColumns(e){const t=Lo(e.length,this.config.threshold??30,this.config.autoEnable??!0);if(this.isVirtualized=t??!1,this.columnWidths=et(e),this.columnOffsets=tt(e),this.totalWidth=ot(e),!t)return this.startCol=0,this.endCol=e.length-1,[...e];const n=this.grid.clientWidth||800,i=ko(this.scrollLeft,n,this.columnOffsets,this.columnWidths,this.config.overscan??3);return this.startCol=i.startCol,this.endCol=i.endCol,i.visibleColumns.map(r=>e[r])}afterRender(){if(!this.isVirtualized)return;const e=this.shadowRoot;if(!e)return;const t=this.columnOffsets[this.startCol]??0,n=e.querySelector(".header-row"),i=e.querySelectorAll(".data-grid-row");n&&(n.style.paddingLeft=`${t}px`),i.forEach(s=>{s.style.paddingLeft=`${t}px`});const r=e.querySelector(".rows-viewport .rows");r&&(r.style.width=`${this.totalWidth}px`)}onScroll(e){!this.isVirtualized||Math.abs(e.scrollLeft-this.scrollLeft)<1||(this.scrollLeft=e.scrollLeft,this.requestRender())}getIsVirtualized(){return this.isVirtualized}getVisibleColumnRange(){return{start:this.startCol,end:this.endCol}}scrollToColumn(e){const t=this.columnOffsets[e]??0,n=this.grid;n.scrollLeft=t}getColumnOffset(e){return this.columnOffsets[e]??0}getTotalWidth(){return this.totalWidth}}const Mo=".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background:light-dark(#e8e8e8,#3a3a3a)}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";function ve(o,e){return(typeof o=="function"?o(e):o).filter(n=>!(n.hidden===!0||typeof n.hidden=="function"&&n.hidden(e)))}function Io(o,e){return o.disabled===!0?!0:typeof o.disabled=="function"?o.disabled(e):!1}function Ce(o,e,t,n=I.submenuArrow){const i=document.createElement("div");i.className="tbw-context-menu",i.setAttribute("role","menu");for(const r of o){if(r.separator){const c=document.createElement("div");c.className="tbw-context-menu-separator",c.setAttribute("role","separator"),i.appendChild(c);continue}const s=document.createElement("div");s.className="tbw-context-menu-item",r.cssClass&&s.classList.add(r.cssClass),s.setAttribute("role","menuitem"),s.setAttribute("data-id",r.id);const l=Io(r,e);if(l&&(s.classList.add("disabled"),s.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");c.className="tbw-context-menu-icon",c.innerHTML=r.icon,s.appendChild(c)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=r.name,s.appendChild(a),r.shortcut){const c=document.createElement("span");c.className="tbw-context-menu-shortcut",c.textContent=r.shortcut,s.appendChild(c)}if(r.subMenu?.length){const c=document.createElement("span");c.className="tbw-context-menu-arrow",typeof n=="string"?c.innerHTML=n:n instanceof HTMLElement&&c.appendChild(n.cloneNode(!0)),s.appendChild(c),s.addEventListener("mouseenter",()=>{if(s.querySelector(".tbw-context-menu")||!r.subMenu)return;const h=ve(r.subMenu,e),f=Ce(h,e,t,n);f.classList.add("tbw-context-submenu"),f.style.position="absolute",f.style.left="100%",f.style.top="0",s.style.position="relative",s.appendChild(f)}),s.addEventListener("mouseleave",()=>{const d=s.querySelector(".tbw-context-menu");d&&d.remove()})}!l&&r.action&&!r.subMenu&&s.addEventListener("click",c=>{c.stopPropagation(),t(r)}),i.appendChild(s)}return i}function nt(o,e,t){o.style.position="fixed",o.style.left=`${e}px`,o.style.top=`${t}px`,o.style.visibility="hidden",o.style.zIndex="10000";const n=o.getBoundingClientRect(),i=window.innerWidth,r=window.innerHeight;let s=e,l=t;e+n.width>i&&(s=e-n.width),t+n.height>r&&(l=t-n.height),s=Math.max(0,s),l=Math.max(0,l),o.style.left=`${s}px`,o.style.top=`${l}px`,o.style.visibility="visible"}let G=null,K=null,z=null,ye=0;const xe=[{id:"copy",name:"Copy",shortcut:"Ctrl+C",action:o=>{o.grid?.plugins?.clipboard?.copy?.()}},{separator:!0,id:"sep1",name:""},{id:"export-csv",name:"Export CSV",action:o=>{o.grid?.plugins?.export?.exportCsv?.()}}];class No extends T{name="contextMenu";version="1.0.0";get defaultConfig(){return{items:xe}}isOpen=!1;position={x:0,y:0};params=null;menuElement=null;attach(e){super.attach(e),this.installGlobalHandlers(),ye++}detach(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null),this.isOpen=!1,this.params=null,this.uninstallGlobalHandlers()}installGlobalHandlers(){!z&&typeof document<"u"&&(z=document.createElement("style"),z.id="tbw-context-menu-styles",z.textContent=Mo,document.head.appendChild(z)),G||(G=()=>{document.querySelectorAll(".tbw-context-menu").forEach(t=>t.remove())},document.addEventListener("click",G)),K||(K=e=>{e.key==="Escape"&&document.querySelectorAll(".tbw-context-menu").forEach(n=>n.remove())},document.addEventListener("keydown",K))}uninstallGlobalHandlers(){ye--,!(ye>0)&&(G&&(document.removeEventListener("click",G),G=null),K&&(document.removeEventListener("keydown",K),K=null),z&&(z.remove(),z=null))}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.children[0];t&&t.getAttribute("data-context-menu-bound")!=="true"&&(t.setAttribute("data-context-menu-bound","true"),t.addEventListener("contextmenu",n=>{const i=n;i.preventDefault();const r=i.target,s=r.closest("[data-row][data-col]"),l=r.closest(".header-cell");let a;if(s){const d=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),f=this.columns[h],u=this.rows[d];a={row:u,rowIndex:d,column:f,columnIndex:h,field:f?.field??"",value:u?.[f?.field]??null,isHeader:!1,event:i}}else if(l){const d=parseInt(l.getAttribute("data-col")??"-1",10),h=this.columns[d];a={row:null,rowIndex:-1,column:h,columnIndex:d,field:h?.field??"",value:null,isHeader:!0,event:i}}else return;this.params=a,this.position={x:i.clientX,y:i.clientY};const c=ve(this.config.items??xe,a);c.length&&(this.menuElement&&this.menuElement.remove(),this.menuElement=Ce(c,a,d=>{d.action&&d.action(a),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),nt(this.menuElement,i.clientX,i.clientY),this.isOpen=!0,this.emit("context-menu-open",{params:a,items:c}))}))}showMenu(e,t,n){const i={row:n.row??null,rowIndex:n.rowIndex??-1,column:n.column??null,columnIndex:n.columnIndex??-1,field:n.field??"",value:n.value??null,isHeader:n.isHeader??!1,event:n.event??new MouseEvent("contextmenu")},r=ve(this.config.items??xe,i);this.menuElement&&this.menuElement.remove(),this.menuElement=Ce(r,i,s=>{s.action&&s.action(i),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),nt(this.menuElement,e,t),this.isOpen=!0}hideMenu(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null,this.isOpen=!1)}isMenuOpen(){return this.isOpen}}function it(o,e=!0){if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const t=String(o);return e&&(t.includes(",")||t.includes('"')||t.includes(`
|
|
81
|
-
`)||t.includes("\r"))?`"${t.replace(/"/g,'""')}"`:t}function
|
|
82
|
-
`,s=[],l=n.bom?"\uFEFF":"";if(t.includeHeaders!==!1){const a=e.map(c=>{const d=c.header||c.field,h=t.processHeader?t.processHeader(d,c.field):d;return
|
|
78
|
+
`),r=[];let s=[],l="",a=!1;for(let c=0;c<i.length;c++){const d=i[c];d==='"'&&!a?a=!0:d==='"'&&a?i[c+1]==='"'?(l+='"',c++):a=!1:d===t&&!a?(s.push(l),l=""):d===n&&!a?(s.push(l),l="",(s.length>1||s.some(h=>h.trim()!==""))&&r.push(s),s=[]):l+=d}return s.push(l),(s.length>1||s.some(c=>c.trim()!==""))&&r.push(s),r}async function je(){try{return await navigator.clipboard.readText()}catch{return""}}class go extends T{name="clipboard";version="1.0.0";get defaultConfig(){return{includeHeaders:!1,delimiter:" ",newline:`
|
|
79
|
+
`,quoteStrings:!1}}lastCopied=null;detach(){this.lastCopied=null}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="c",n=(e.ctrlKey||e.metaKey)&&e.key==="v";return t?(this.#t(e.target),!0):n?(this.#i(),!0):!1}#t(e){const t=this.#g(),n=t?.getSelectedRows()??[],i=n.length>0,r=t?.getRanges()??[],s=r.length>0,l=t?.getSelectedCell()!=null;let a,c,d;if(i&&t)a=he({rows:this.rows,columns:[...this.columns],selectedIndices:n,config:this.config}),c=n.length,d=this.columns.filter(h=>!h.hidden&&!h.field.startsWith("__")).length;else if(s&&t){const h=r[r.length-1],f=this.#s({startRow:h.from.row,startCol:h.from.col,endRow:h.to.row,endCol:h.to.col});a=f.text,c=f.rowCount,d=f.columnCount}else if(l&&t){const h=t.getSelectedCell(),f=this.#C(h.row,h.col);if(!f)return;a=f.text,c=1,d=1}else{const h=this.#l(e);if(!h)return;a=h.text,c=1,d=1}fe(a).then(()=>{this.lastCopied={text:a,timestamp:Date.now()},this.emit("copy",{text:a,rowCount:c,columnCount:d})})}#i(){je().then(e=>{if(!e)return;const t=We(e,this.config);this.emit("paste",{rows:t,text:e})})}#g(){try{const e=this.grid;if(e?._plugins){for(const t of e._plugins)if(t.name==="selection")return t}}catch{}}#C(e,t){const n=this.rows[e];if(!n)return null;const i=this.columns[t];if(!i)return null;const r=n[i.field],s=i.header||i.field;let l;if(this.config.includeHeaders){const a=r==null?"":String(r);l=`${s}: ${a}`}else l=r==null?"":String(r);return{text:l}}#s(e){const{startRow:t,startCol:n,endRow:i,endCol:r}=e,s=Math.min(t,i),l=Math.max(t,i),a=Math.min(n,r),c=Math.max(n,r),d=this.config.delimiter??" ",h=this.config.newline??`
|
|
80
|
+
`,f=[],u=this.columns.slice(a,c+1);if(this.config.includeHeaders){const p=u.map(g=>g.header||g.field);f.push(p.join(d))}for(let p=s;p<=l;p++){const g=this.rows[p];if(!g)continue;const b=u.map(w=>{const A=g[w.field];return A==null?"":A instanceof Date?A.toISOString():String(A)});f.push(b.join(d))}return{text:f.join(h),rowCount:l-s+1,columnCount:c-a+1}}#l(e){const t=e.closest("[data-field-cache]");if(!t)return null;const n=t.dataset.fieldCache;if(!n)return null;const i=t.dataset.row;if(!i)return null;const r=parseInt(i,10);if(isNaN(r))return null;const s=this.rows[r];if(!s)return null;const l=s[n],c=this.columns.find(h=>h.field===n)?.header||n;let d;if(this.config.includeHeaders){const h=l==null?"":String(l);d=`${c}: ${h}`}else d=l==null?"":String(l);return{text:d,field:n,value:l}}async copy(){const t=this.#g()?.getSelectedRows()??[],n=he({rows:this.rows,columns:[...this.columns],selectedIndices:t,config:this.config});return await fe(n),this.lastCopied={text:n,timestamp:Date.now()},n}async copyRows(e){const t=he({rows:this.rows,columns:[...this.columns],selectedIndices:e,config:this.config});return await fe(t),this.lastCopied={text:t,timestamp:Date.now()},t}async paste(){const e=await je();return e?We(e,this.config):null}getLastCopied(){return this.lastCopied}}const Ue=100;function pe(o){if(o==null)return Ue;if(typeof o=="number")return o;const e=parseFloat(o);return isNaN(e)?Ue:e}function Xe(o){return o.map(e=>pe(e.width))}function Ye(o){const e=[];let t=0;for(const n of o)e.push(t),t+=pe(n.width);return e}function Ze(o){return o.reduce((e,t)=>e+pe(t.width),0)}function bo(o,e,t,n,i){const r=t.length;if(r===0)return{startCol:0,endCol:0,visibleColumns:[]};let s=wo(o,t,n);s=Math.max(0,s-i);const l=o+e;let a=s;for(let d=s;d<r;d++){if(t[d]>=l){a=d-1;break}a=d}a=Math.min(r-1,a+i);const c=[];for(let d=s;d<=a;d++)c.push(d);return{startCol:s,endCol:a,visibleColumns:c}}function wo(o,e,t){let n=0,i=e.length-1;for(;n<i;){const r=Math.floor((n+i)/2);e[r]+t[r]<=o?n=r+1:i=r}return n}function mo(o,e,t){return t?o>e:!1}class vo extends T{name="columnVirtualization";version="1.0.0";get defaultConfig(){return{autoEnable:!0,threshold:30,overscan:3}}isVirtualized=!1;startCol=0;endCol=0;scrollLeft=0;totalWidth=0;columnWidths=[];columnOffsets=[];attach(e){super.attach(e);const t=this.columns;this.columnWidths=Xe(t),this.columnOffsets=Ye(t),this.totalWidth=Ze(t),this.endCol=t.length-1}detach(){this.columnWidths=[],this.columnOffsets=[],this.isVirtualized=!1,this.startCol=0,this.endCol=0,this.scrollLeft=0,this.totalWidth=0}processColumns(e){const t=mo(e.length,this.config.threshold??30,this.config.autoEnable??!0);if(this.isVirtualized=t??!1,this.columnWidths=Xe(e),this.columnOffsets=Ye(e),this.totalWidth=Ze(e),!t)return this.startCol=0,this.endCol=e.length-1,[...e];const n=this.grid.clientWidth||800,i=bo(this.scrollLeft,n,this.columnOffsets,this.columnWidths,this.config.overscan??3);return this.startCol=i.startCol,this.endCol=i.endCol,i.visibleColumns.map(r=>e[r])}afterRender(){if(!this.isVirtualized)return;const e=this.shadowRoot;if(!e)return;const t=this.columnOffsets[this.startCol]??0,n=e.querySelector(".header-row"),i=e.querySelectorAll(".data-grid-row");n&&(n.style.paddingLeft=`${t}px`),i.forEach(s=>{s.style.paddingLeft=`${t}px`});const r=e.querySelector(".rows-viewport .rows");r&&(r.style.width=`${this.totalWidth}px`)}onScroll(e){!this.isVirtualized||Math.abs(e.scrollLeft-this.scrollLeft)<1||(this.scrollLeft=e.scrollLeft,this.requestRender())}getIsVirtualized(){return this.isVirtualized}getVisibleColumnRange(){return{start:this.startCol,end:this.endCol}}scrollToColumn(e){const t=this.columnOffsets[e]??0,n=this.grid;n.scrollLeft=t}getColumnOffset(e){return this.columnOffsets[e]??0}getTotalWidth(){return this.totalWidth}}const Co=".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background:light-dark(#e8e8e8,#3a3a3a)}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";function ge(o,e){return(typeof o=="function"?o(e):o).filter(n=>!(n.hidden===!0||typeof n.hidden=="function"&&n.hidden(e)))}function yo(o,e){return o.disabled===!0?!0:typeof o.disabled=="function"?o.disabled(e):!1}function be(o,e,t,n=I.submenuArrow){const i=document.createElement("div");i.className="tbw-context-menu",i.setAttribute("role","menu");for(const r of o){if(r.separator){const c=document.createElement("div");c.className="tbw-context-menu-separator",c.setAttribute("role","separator"),i.appendChild(c);continue}const s=document.createElement("div");s.className="tbw-context-menu-item",r.cssClass&&s.classList.add(r.cssClass),s.setAttribute("role","menuitem"),s.setAttribute("data-id",r.id);const l=yo(r,e);if(l&&(s.classList.add("disabled"),s.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");c.className="tbw-context-menu-icon",c.innerHTML=r.icon,s.appendChild(c)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=r.name,s.appendChild(a),r.shortcut){const c=document.createElement("span");c.className="tbw-context-menu-shortcut",c.textContent=r.shortcut,s.appendChild(c)}if(r.subMenu?.length){const c=document.createElement("span");c.className="tbw-context-menu-arrow",typeof n=="string"?c.innerHTML=n:n instanceof HTMLElement&&c.appendChild(n.cloneNode(!0)),s.appendChild(c),s.addEventListener("mouseenter",()=>{if(s.querySelector(".tbw-context-menu")||!r.subMenu)return;const h=ge(r.subMenu,e),f=be(h,e,t,n);f.classList.add("tbw-context-submenu"),f.style.position="absolute",f.style.left="100%",f.style.top="0",s.style.position="relative",s.appendChild(f)}),s.addEventListener("mouseleave",()=>{const d=s.querySelector(".tbw-context-menu");d&&d.remove()})}!l&&r.action&&!r.subMenu&&s.addEventListener("click",c=>{c.stopPropagation(),t(r)}),i.appendChild(s)}return i}function Je(o,e,t){o.style.position="fixed",o.style.left=`${e}px`,o.style.top=`${t}px`,o.style.visibility="hidden",o.style.zIndex="10000";const n=o.getBoundingClientRect(),i=window.innerWidth,r=window.innerHeight;let s=e,l=t;e+n.width>i&&(s=e-n.width),t+n.height>r&&(l=t-n.height),s=Math.max(0,s),l=Math.max(0,l),o.style.left=`${s}px`,o.style.top=`${l}px`,o.style.visibility="visible"}let G=null,K=null,z=null,we=0;const me=[{id:"copy",name:"Copy",shortcut:"Ctrl+C",action:o=>{o.grid?.plugins?.clipboard?.copy?.()}},{separator:!0,id:"sep1",name:""},{id:"export-csv",name:"Export CSV",action:o=>{o.grid?.plugins?.export?.exportCsv?.()}}];class xo extends T{name="contextMenu";version="1.0.0";get defaultConfig(){return{items:me}}isOpen=!1;position={x:0,y:0};params=null;menuElement=null;attach(e){super.attach(e),this.installGlobalHandlers(),we++}detach(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null),this.isOpen=!1,this.params=null,this.uninstallGlobalHandlers()}installGlobalHandlers(){!z&&typeof document<"u"&&(z=document.createElement("style"),z.id="tbw-context-menu-styles",z.textContent=Co,document.head.appendChild(z)),G||(G=()=>{document.querySelectorAll(".tbw-context-menu").forEach(t=>t.remove())},document.addEventListener("click",G)),K||(K=e=>{e.key==="Escape"&&document.querySelectorAll(".tbw-context-menu").forEach(n=>n.remove())},document.addEventListener("keydown",K))}uninstallGlobalHandlers(){we--,!(we>0)&&(G&&(document.removeEventListener("click",G),G=null),K&&(document.removeEventListener("keydown",K),K=null),z&&(z.remove(),z=null))}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.children[0];t&&t.getAttribute("data-context-menu-bound")!=="true"&&(t.setAttribute("data-context-menu-bound","true"),t.addEventListener("contextmenu",n=>{const i=n;i.preventDefault();const r=i.target,s=r.closest("[data-row][data-col]"),l=r.closest(".header-cell");let a;if(s){const d=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),f=this.columns[h],u=this.rows[d];a={row:u,rowIndex:d,column:f,columnIndex:h,field:f?.field??"",value:u?.[f?.field]??null,isHeader:!1,event:i}}else if(l){const d=parseInt(l.getAttribute("data-col")??"-1",10),h=this.columns[d];a={row:null,rowIndex:-1,column:h,columnIndex:d,field:h?.field??"",value:null,isHeader:!0,event:i}}else return;this.params=a,this.position={x:i.clientX,y:i.clientY};const c=ge(this.config.items??me,a);c.length&&(this.menuElement&&this.menuElement.remove(),this.menuElement=be(c,a,d=>{d.action&&d.action(a),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Je(this.menuElement,i.clientX,i.clientY),this.isOpen=!0,this.emit("context-menu-open",{params:a,items:c}))}))}showMenu(e,t,n){const i={row:n.row??null,rowIndex:n.rowIndex??-1,column:n.column??null,columnIndex:n.columnIndex??-1,field:n.field??"",value:n.value??null,isHeader:n.isHeader??!1,event:n.event??new MouseEvent("contextmenu")},r=ge(this.config.items??me,i);this.menuElement&&this.menuElement.remove(),this.menuElement=be(r,i,s=>{s.action&&s.action(i),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Je(this.menuElement,e,t),this.isOpen=!0}hideMenu(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null,this.isOpen=!1)}isMenuOpen(){return this.isOpen}}function Qe(o,e=!0){if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const t=String(o);return e&&(t.includes(",")||t.includes('"')||t.includes(`
|
|
81
|
+
`)||t.includes("\r"))?`"${t.replace(/"/g,'""')}"`:t}function Eo(o,e,t,n={}){const i=n.delimiter??",",r=n.newline??`
|
|
82
|
+
`,s=[],l=n.bom?"\uFEFF":"";if(t.includeHeaders!==!1){const a=e.map(c=>{const d=c.header||c.field,h=t.processHeader?t.processHeader(d,c.field):d;return Qe(h)});s.push(a.join(i))}for(const a of o){const c=e.map(d=>{let h=a[d.field];return t.processCell&&(h=t.processCell(h,d.field,a)),Qe(h)});s.push(c.join(i))}return l+s.join(r)}function ve(o,e){const t=URL.createObjectURL(o),n=document.createElement("a");n.href=t,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function Ro(o,e){const t=new Blob([o],{type:"text/csv;charset=utf-8;"});ve(t,e)}function et(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function So(o,e,t){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
83
83
|
<?mso-application progid="Excel.Sheet"?>
|
|
84
84
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
85
85
|
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
|
|
86
86
|
<Worksheet ss:Name="Sheet1">
|
|
87
87
|
<Table>`;if(t.includeHeaders!==!1){n+=`
|
|
88
|
-
<Row>`;for(const i of e){const r=i.header||i.field,s=t.processHeader?t.processHeader(r,i.field):r;n+=`<Cell><Data ss:Type="String">${
|
|
89
|
-
<Row>`;for(const r of e){let s=i[r.field];t.processCell&&(s=t.processCell(s,r.field,i));let l="String",a="";s==null?a="":typeof s=="number"&&!isNaN(s)?(l="Number",a=String(s)):s instanceof Date?(l="DateTime",a=s.toISOString()):a=
|
|
88
|
+
<Row>`;for(const i of e){const r=i.header||i.field,s=t.processHeader?t.processHeader(r,i.field):r;n+=`<Cell><Data ss:Type="String">${et(s)}</Data></Cell>`}n+="</Row>"}for(const i of o){n+=`
|
|
89
|
+
<Row>`;for(const r of e){let s=i[r.field];t.processCell&&(s=t.processCell(s,r.field,i));let l="String",a="";s==null?a="":typeof s=="number"&&!isNaN(s)?(l="Number",a=String(s)):s instanceof Date?(l="DateTime",a=s.toISOString()):a=et(String(s)),n+=`<Cell><Data ss:Type="${l}">${a}</Data></Cell>`}n+="</Row>"}return n+=`
|
|
90
90
|
</Table>
|
|
91
91
|
</Worksheet>
|
|
92
|
-
</Workbook>`,n}function
|
|
92
|
+
</Workbook>`,n}function Ao(o,e){const t=e.endsWith(".xls")?e:`${e}.xls`,n=new Blob([o],{type:"application/vnd.ms-excel;charset=utf-8;"});ve(n,t)}class _o extends T{name="export";version="1.0.0";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;performExport(e,t){const n=this.config,i={format:e,fileName:t?.fileName??n.fileName??"export",includeHeaders:t?.includeHeaders??n.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,columns:t?.columns,rowIndices:t?.rowIndices};let r=[...this.columns];if(n.onlyVisible&&(r=r.filter(a=>!a.hidden&&!a.field.startsWith("__"))),t?.columns){const a=new Set(t.columns);r=r.filter(c=>a.has(c.field))}let s=[...this.rows];if(n.onlySelected){const a=this.getSelectionState();a?.selected?.size&&(s=[...a.selected].sort((d,h)=>d-h).map(d=>this.rows[d]).filter(Boolean))}t?.rowIndices&&(s=t.rowIndices.map(a=>this.rows[a]).filter(Boolean)),this.isExportingFlag=!0;let l=i.fileName;try{switch(e){case"csv":{const a=Eo(s,r,i,{bom:!0});l=l.endsWith(".csv")?l:`${l}.csv`,Ro(a,l);break}case"excel":{const a=So(s,r,i);l=l.endsWith(".xls")?l:`${l}.xls`,Ao(a,l);break}case"json":{const a=s.map(h=>{const f={};for(const u of r){let p=h[u.field];i.processCell&&(p=i.processCell(p,u.field,h)),f[u.field]=p}return f}),c=JSON.stringify(a,null,2);l=l.endsWith(".json")?l:`${l}.json`;const d=new Blob([c],{type:"application/json"});ve(d,l);break}}this.lastExportInfo={format:e,timestamp:new Date},this.emit("export-complete",{format:e,fileName:l,rowCount:s.length,columnCount:r.length})}finally{this.isExportingFlag=!1}}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}}function ko(o){const{totalRows:e,viewportHeight:t,scrollTop:n,rowHeight:i,overscan:r}=o,s=Math.ceil(t/i);let l=Math.floor(n/i)-r;l<0&&(l=0);let a=l+s+r*2;return a>e&&(a=e),a===e&&l>0&&(l=Math.max(0,a-s-r*2)),{start:l,end:a,offsetY:l*i,totalHeight:e*i}}function To(o,e){return o<=e}function Lo(o,e,t=!1){const n=o[e.field];if(e.operator==="blank")return n==null||n==="";if(e.operator==="notBlank")return n!=null&&n!=="";if(n==null)return!1;const i=String(n),r=t?i:i.toLowerCase(),s=t?String(e.value):String(e.value).toLowerCase();switch(e.operator){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"lessThan":return Number(n)<Number(e.value);case"lessThanOrEqual":return Number(n)<=Number(e.value);case"greaterThan":return Number(n)>Number(e.value);case"greaterThanOrEqual":return Number(n)>=Number(e.value);case"between":return Number(n)>=Number(e.value)&&Number(n)<=Number(e.valueTo);case"in":return Array.isArray(e.value)&&e.value.includes(n);case"notIn":return Array.isArray(e.value)&&!e.value.includes(n);default:return!0}}function Po(o,e,t=!1){return e.length?o.filter(n=>e.every(i=>Lo(n,i,t))):o}function Mo(o){return JSON.stringify(o.map(e=>({field:e.field,operator:e.operator,value:e.value,valueTo:e.valueTo})))}function tt(o,e){const t=new Set;for(const n of o){const i=n[e];i!=null&&t.add(i)}return[...t].sort((n,i)=>typeof n=="number"&&typeof i=="number"?n-i:String(n).localeCompare(String(i)))}const Io='.header-cell.filtered:before{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}.tbw-filter-btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:4px;opacity:.4;transition:opacity .15s;color:inherit;vertical-align:middle}.tbw-filter-btn:hover,.tbw-filter-btn.active{opacity:1}.tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}',No=`
|
|
93
93
|
.tbw-filter-panel {
|
|
94
94
|
position: fixed;
|
|
95
95
|
background: var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));
|
|
@@ -230,5 +230,5 @@
|
|
|
230
230
|
.tbw-filter-clear-btn:hover {
|
|
231
231
|
background: var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)));
|
|
232
232
|
}
|
|
233
|
-
`;class F extends T{name="filtering";version="1.0.0";get defaultConfig(){return{debounceMs:300,caseSensitive:!1,trimInput:!0,useWorker:!0}}filters=new Map;cachedResult=null;cacheKey=null;openPanelField=null;panelElement=null;searchText=new Map;excludedValues=new Map;panelAbortController=null;globalStylesInjected=!1;static LIST_ITEM_HEIGHT=28;static LIST_OVERSCAN=3;static LIST_BYPASS_THRESHOLD=50;attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}processRows(e){const t=[...this.filters.values()];if(!t.length)return[...e];const n=Ko(t);if(this.cacheKey===n&&this.cachedResult)return this.cachedResult;const i=Go([...e],t,this.config.caseSensitive);return this.cachedResult=i,this.cacheKey=n,i}afterRender(){const e=this.shadowRoot;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(n=>{const i=n.getAttribute("data-col");if(i===null)return;const r=this.columns[parseInt(i,10)];if(!r||r.filterable===!1||n.querySelector(".tbw-filter-btn"))return;const s=r.field;if(!s)return;const l=document.createElement("button");l.className="tbw-filter-btn",l.setAttribute("aria-label",`Filter ${r.header??s}`),l.innerHTML='<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>',this.filters.has(s)&&(l.classList.add("active"),n.classList.add("filtered")),l.addEventListener("click",a=>{a.stopPropagation(),this.toggleFilterPanel(s,r,l)}),n.appendChild(l)})}setFilter(e,t){t===null?this.filters.delete(e):this.filters.set(e,{...t,field:e}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e){this.filters.clear();for(const t of e)this.filters.set(t.field,t);this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}clearAllFilters(){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[],filteredRowCount:this.rows.length}),this.requestRender()}clearFieldFilter(e){this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){return st(this.sourceRows,e)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles")){this.globalStylesInjected=!0;return}const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent=Wo,document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,n){if(this.openPanelField===e){this.closeFilterPanel();return}this.closeFilterPanel();const i=document.createElement("div");i.className="tbw-filter-panel",this.panelElement=i,this.openPanelField=e;const r=st(this.sourceRows,e);let s=this.excludedValues.get(e);s||(s=new Set,this.excludedValues.set(e,s));const l=this.searchText.get(e)??"",a={field:e,column:t,uniqueValues:r,excludedValues:s,searchText:l,applySetFilter:d=>{this.applySetFilter(e,d),this.closeFilterPanel()},applyTextFilter:(d,h,f)=>{this.applyTextFilter(e,d,h,f),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(e),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let c=!1;this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(i,a),c=i.children.length>0),c||this.renderDefaultFilterPanel(i,a,r,s),document.body.appendChild(i),this.positionPanel(i,n),this.panelAbortController=new AbortController,setTimeout(()=>{document.addEventListener("click",d=>{!i.contains(d.target)&&d.target!==n&&this.closeFilterPanel()},{signal:this.panelAbortController?.signal})},0)}closeFilterPanel(){this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}positionPanel(e,t){const n=t.getBoundingClientRect();e.style.position="fixed",e.style.top=`${n.bottom+4}px`,e.style.left=`${n.left}px`,requestAnimationFrame(()=>{const i=e.getBoundingClientRect();i.right>window.innerWidth-8&&(e.style.left=`${window.innerWidth-i.width-8}px`),i.bottom>window.innerHeight-8&&(e.style.top=`${n.top-i.height-4}px`)})}renderDefaultFilterPanel(e,t,n,i){const{field:r}=t,s=document.createElement("div");s.className="tbw-filter-search";const l=document.createElement("input");l.type="text",l.placeholder="Search...",l.className="tbw-filter-search-input",l.value=this.searchText.get(r)??"",s.appendChild(l),e.appendChild(s);const a=document.createElement("div");a.className="tbw-filter-actions";const c=document.createElement("label");c.className="tbw-filter-value-item",c.style.padding="0",c.style.margin="0";const d=document.createElement("input");d.type="checkbox",d.className="tbw-filter-checkbox";const h=document.createElement("span");h.textContent="Select All",c.appendChild(d),c.appendChild(h),a.appendChild(c);const f=()=>{const v=[...b.values()],x=v.every(S=>S),E=v.every(S=>!S);d.checked=x,d.indeterminate=!x&&!E};d.addEventListener("change",()=>{const v=d.checked;for(const x of b.keys())b.set(x,v);f(),k()}),e.appendChild(a);const u=document.createElement("div");u.className="tbw-filter-values";const p=document.createElement("div");p.className="tbw-filter-values-spacer",u.appendChild(p);const g=document.createElement("div");g.className="tbw-filter-values-content",u.appendChild(g);const b=new Map;n.forEach(v=>{const x=v==null?"__null__":String(v);b.set(x,!i.has(v))}),f();let w=[];const A=(v,x)=>{const E=v==null?"(Blank)":String(v),S=v==null?"__null__":String(v),P=document.createElement("label");P.className="tbw-filter-value-item",P.style.position="absolute",P.style.top=`${x*F.LIST_ITEM_HEIGHT}px`,P.style.left="0",P.style.right="0",P.style.height=`${F.LIST_ITEM_HEIGHT}px`,P.style.boxSizing="border-box";const O=document.createElement("input");O.type="checkbox",O.className="tbw-filter-checkbox",O.checked=b.get(S)??!0,O.dataset.value=S,O.addEventListener("change",()=>{b.set(S,O.checked),f()});const Et=document.createElement("span");return Et.textContent=E,P.appendChild(O),P.appendChild(Et),P},k=()=>{const v=w.length,x=u.clientHeight,E=u.scrollTop;if(p.style.height=`${v*F.LIST_ITEM_HEIGHT}px`,Bo(v,F.LIST_BYPASS_THRESHOLD/3)){g.innerHTML="",g.style.transform="translateY(0px)",w.forEach((P,O)=>{g.appendChild(A(P,O))});return}const S=qo({totalRows:v,viewportHeight:x,scrollTop:E,rowHeight:F.LIST_ITEM_HEIGHT,overscan:F.LIST_OVERSCAN});g.style.transform=`translateY(${S.offsetY}px)`,g.innerHTML="";for(let P=S.start;P<S.end;P++)g.appendChild(A(w[P],P-S.start))},_=v=>{const x=v.toLowerCase();if(w=n.filter(E=>{const S=E==null?"(Blank)":String(E);return!v||S.toLowerCase().includes(x)}),w.length===0){p.style.height="0px",g.innerHTML="";const E=document.createElement("div");E.className="tbw-filter-no-match",E.textContent="No matching values",g.appendChild(E);return}k()};u.addEventListener("scroll",()=>{w.length>0&&k()},{passive:!0}),_(l.value),e.appendChild(u);let L;l.addEventListener("input",()=>{clearTimeout(L),L=setTimeout(()=>{this.searchText.set(r,l.value),_(l.value)},this.config.debounceMs??150)});const m=document.createElement("div");m.className="tbw-filter-buttons";const C=document.createElement("button");C.className="tbw-filter-apply-btn",C.textContent="Apply",C.addEventListener("click",()=>{const v=[];for(const[x,E]of b)if(!E)if(x==="__null__")v.push(null);else{const S=n.find(P=>String(P)===x);v.push(S!==void 0?S:x)}t.applySetFilter(v)}),m.appendChild(C);const R=document.createElement("button");R.className="tbw-filter-clear-btn",R.textContent="Clear Filter",R.addEventListener("click",()=>{t.clearFilter()}),m.appendChild(R),e.appendChild(m)}applySetFilter(e,t){this.excludedValues.set(e,new Set(t)),t.length===0?this.filters.delete(e):this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}applyTextFilter(e,t,n,i){this.filters.set(e,{field:e,type:"text",operator:t,value:n,valueTo:i}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getColumnState(e){const t=this.filters.get(e);if(t)return{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}}applyColumnState(e,t){if(!t.filter){this.filters.delete(e);return}const n={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,n),this.cachedResult=null,this.cacheKey=null}styles=Vo}function jo(o){if(!o.length)return[];const e=new Map,t=[],n=(s,l)=>{if(!l.length)return;const a=t[t.length-1];if(a&&a.implicit&&a.firstIndex+a.columns.length===s){a.columns.push(...l);return}t.push({id:"__implicit__"+s,label:void 0,columns:l,firstIndex:s,implicit:!0})};let i=[],r=0;return o.forEach((s,l)=>{const a=s.group;if(!a){i.length===0&&(r=l),i.push(s);return}i.length&&(n(r,i.slice()),i=[]);const c=typeof a=="string"?a:a.id;let d=e.get(c);d||(d={id:c,label:typeof a=="string"?void 0:a.label,columns:[],firstIndex:l},e.set(c,d),t.push(d)),d.columns.push(s)}),i.length&&n(r,i),t.length===1&&t[0].implicit&&t[0].columns.length===o.length?[]:t}function Uo(o,e,t){if(!e.length||!o)return;const n=new Map;for(const r of e)for(const s of r.columns)s?.field&&n.set(s.field,r.id);const i=Array.from(o.querySelectorAll(".cell[data-field]"));i.forEach(r=>{const s=r.getAttribute("data-field")||"",l=n.get(s);l&&(r.classList.add("grouped"),r.getAttribute("data-group")||r.setAttribute("data-group",l))});for(const r of e){const s=r.columns[r.columns.length-1],l=i.find(a=>a.getAttribute("data-field")===s.field);l&&l.classList.add("group-end")}}function Xo(o,e){if(o.length===0)return null;const t=document.createElement("div");t.className="header-group-row",t.setAttribute("role","row");for(const n of o){const i=n.firstIndex!=null?n.firstIndex:e.findIndex(a=>n.columns.includes(a)),r=String(n.id).startsWith("__implicit__"),s=r?"":n.label||n.id,l=document.createElement("div");l.className="cell header-group-cell",r&&l.classList.add("implicit-group"),l.setAttribute("data-group",String(n.id)),l.style.gridColumn=`${i+1} / span ${n.columns.length}`,l.textContent=s,t.appendChild(l)}return t}function Yo(o){return o.some(e=>e.group!=null)}const Zo=".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong))}";class Jo extends T{name="groupingColumns";version="1.0.0";get defaultConfig(){return{showGroupBorders:!0}}groups=[];isActive=!1;detach(){this.groups=[],this.isActive=!1}static detect(e,t){const n=t?.columns;return Array.isArray(n)?Yo(n):!1}processColumns(e){const t=jo(e);return t.length===0?(this.isActive=!1,this.groups=[],[...e]):(this.isActive=!0,this.groups=t,[...e])}afterRender(){if(!this.isActive||this.groups.length===0){const s=this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");s&&s.remove();return}const e=this.shadowRoot?.querySelector(".header");if(!e)return;const t=e.querySelector(".header-group-row");t&&t.remove();const n=Xo(this.groups,this.columns);if(n){const r=e.querySelector(".header-row");r?e.insertBefore(n,r):e.appendChild(n)}const i=e.querySelector(".header-row");i&&Uo(i,this.groups,this.columns)}isGroupingActive(){return this.isActive}getGroups(){return this.groups}getGroupColumns(e){const t=this.groups.find(n=>n.id===e);return t?t.columns:[]}refresh(){this.requestRender()}styles=Zo}function Qo({rows:o,config:e,expanded:t}){const n=e.groupOn;if(typeof n!="function")return[];const i={key:"__root__",value:null,depth:-1,rows:[],children:new Map};if(o.forEach(l=>{let a=n(l);a==null||a===!1?a=["__ungrouped__"]:Array.isArray(a)||(a=[a]);let c=i;a.forEach((d,h)=>{const f=d==null?"∅":String(d),u=c.key==="__root__"?f:c.key+"||"+f;let p=c.children.get(f);p||(p={key:u,value:d,depth:h,rows:[],children:new Map,parent:c},c.children.set(f,p)),c=p}),c.rows.push(l)}),i.children.size===1&&i.children.has("__ungrouped__")&&i.children.get("__ungrouped__").rows.length===o.length)return[];const r=[],s=l=>{if(l===i){l.children.forEach(c=>s(c));return}const a=t.has(l.key);r.push({kind:"group",key:l.key,value:l.value,depth:l.depth,rows:l.rows,expanded:a}),a&&(l.children.size?l.children.forEach(c=>s(c)):l.rows.forEach(c=>r.push({kind:"data",row:c,rowIndex:o.indexOf(c)})))};return s(i),r}function en(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function tn(o){const e=new Set;for(const t of o)t.kind==="group"&&e.add(t.key);return e}function on(){return new Set}function nn(o){return o.kind!=="group"?0:o.rows.length}const rn='.group-row{background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-right:4px;font-size:10px}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:2px}.group-label{display:inline-flex;align-items:center;gap:8px}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:.85em;font-weight:400}[data-group-depth="0"] .group-label{padding-left:0}[data-group-depth="1"] .group-label{padding-left:20px}[data-group-depth="2"] .group-label{padding-left:40px}[data-group-depth="3"] .group-label{padding-left:60px}[data-group-depth="4"] .group-label{padding-left:80px}';class sn extends T{name="groupingRows";version="1.0.0";get defaultConfig(){return{defaultExpanded:!1,showRowCount:!0,indentWidth:20,aggregators:{}}}expandedKeys=new Set;flattenedRows=[];isActive=!1;detach(){this.expandedKeys.clear(),this.flattenedRows=[],this.isActive=!1}static detect(e,t){return typeof t?.groupOn=="function"||typeof t?.enableRowGrouping=="boolean"}processRows(e){const t=this.config;if(typeof t.groupOn!="function")return this.isActive=!1,this.flattenedRows=[],[...e];const n=Qo({rows:e,config:t,expanded:this.expandedKeys});return n.length===0?(this.isActive=!1,this.flattenedRows=[],[...e]):(this.isActive=!0,this.flattenedRows=n,n.map(i=>i.kind==="group"?{__isGroupRow:!0,__groupKey:i.key,__groupValue:i.value,__groupDepth:i.depth,__groupRows:i.rows,__groupExpanded:i.expanded,__groupRowCount:nn(i)}:i.row))}onCellClick(e){const t=e.row;if(t?.__isGroupRow&&e.originalEvent.target?.closest(".group-toggle"))return this.toggle(t.__groupKey),!0}renderRow(e,t,n){if(!e?.__isGroupRow)return!1;const i=this.config;if(i.groupRowRenderer){const l=()=>{this.toggle(e.__groupKey)},a=i.groupRowRenderer({key:e.__groupKey,value:e.__groupValue,depth:e.__groupDepth,rows:e.__groupRows,expanded:e.__groupExpanded,toggleExpand:l});if(a)return t.className="group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),typeof a=="string"?t.innerHTML=a:(t.innerHTML="",t.appendChild(a)),!0}const r=()=>{this.toggle(e.__groupKey)};return t.className="group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),t.setAttribute("role","row"),t.setAttribute("aria-expanded",String(e.__groupExpanded)),t.style.paddingLeft=`${(e.__groupDepth||0)*(i.indentWidth??20)}px`,t.innerHTML="",i.fullWidth!==!1?this.renderFullWidthGroupRow(e,t,r):this.renderPerColumnGroupRow(e,t,r),!0}afterRender(){}renderFullWidthGroupRow(e,t,n){const i=this.config,r=document.createElement("div");r.className="cell group-full",r.style.gridColumn="1 / -1",r.setAttribute("role","gridcell");const s=document.createElement("button");s.type="button",s.className="group-toggle",s.setAttribute("aria-label",e.__groupExpanded?"Collapse group":"Expand group"),this.setIcon(s,this.resolveIcon(e.__groupExpanded?"collapse":"expand")),s.addEventListener("click",c=>{c.stopPropagation(),n()}),r.appendChild(s);const l=document.createElement("span");l.className="group-label";const a=i.formatLabel?i.formatLabel(e.__groupValue,e.__groupDepth||0,e.__groupKey):String(e.__groupValue);if(l.textContent=a,r.appendChild(l),i.showRowCount!==!1){const c=document.createElement("span");c.className="group-count",c.textContent=`(${e.__groupRowCount??e.__groupRows?.length??0})`,r.appendChild(c)}t.appendChild(r)}renderPerColumnGroupRow(e,t,n){const i=this.config,r=i.aggregators??{},s=this.columns,l=e.__groupRows??[],c=this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns||"";c&&(t.style.display="grid",t.style.gridTemplateColumns=c),s.forEach((d,h)=>{const f=document.createElement("div");if(f.className="cell group-cell",f.setAttribute("data-col",String(h)),f.setAttribute("role","gridcell"),h===0){const u=document.createElement("button");u.type="button",u.className="group-toggle",u.setAttribute("aria-label",e.__groupExpanded?"Collapse group":"Expand group"),this.setIcon(u,this.resolveIcon(e.__groupExpanded?"collapse":"expand")),u.addEventListener("click",b=>{b.stopPropagation(),n()}),f.appendChild(u);const p=document.createElement("span"),g=r[d.field];if(g){const b=ge(g,l,d.field,d);p.textContent=b!=null?String(b):String(e.__groupValue)}else{const b=i.formatLabel?i.formatLabel(e.__groupValue,e.__groupDepth||0,e.__groupKey):String(e.__groupValue);p.textContent=b}if(f.appendChild(p),i.showRowCount!==!1){const b=document.createElement("span");b.className="group-count",b.textContent=` (${l.length})`,f.appendChild(b)}}else{const u=r[d.field];if(u){const p=ge(u,l,d.field,d);f.textContent=p!=null?String(p):""}else f.textContent=""}t.appendChild(f)})}expandAll(){this.expandedKeys=tn(this.flattenedRows),this.requestRender()}collapseAll(){this.expandedKeys=on(),this.requestRender()}toggle(e){this.expandedKeys=en(this.expandedKeys,e);const t=this.flattenedRows.find(n=>n.kind==="group"&&n.key===e);this.emit("group-toggle",{key:e,expanded:this.expandedKeys.has(e),value:t?.value,depth:t?.depth??0}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}expand(e){this.expandedKeys.has(e)||(this.expandedKeys=new Set([...this.expandedKeys,e]),this.requestRender())}collapse(e){if(this.expandedKeys.has(e)){const t=new Set(this.expandedKeys);t.delete(e),this.expandedKeys=t,this.requestRender()}}getGroupState(){const e=this.flattenedRows.filter(t=>t.kind==="group");return{isActive:this.isActive,expandedCount:this.expandedKeys.size,totalGroups:e.length,expandedKeys:[...this.expandedKeys]}}getRowCount(){return this.flattenedRows.length}refreshGroups(){this.requestRender()}getExpandedGroups(){return[...this.expandedKeys]}getFlattenedRows(){return this.flattenedRows}isGroupingActive(){return this.isActive}setGroupOn(e){this.config.groupOn=e,this.requestRender()}styles=rn}function Re(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function ln(o,e){const t=new Set(o);return t.add(e),t}function an(o,e){const t=new Set(o);return t.delete(e),t}function cn(o,e){return o.has(e)}function dn(o,e,t,n){const i=document.createElement("div");i.className="master-detail-row",i.setAttribute("data-detail-for",String(e)),i.setAttribute("role","row");const r=document.createElement("div");r.className="master-detail-cell",r.setAttribute("role","cell"),r.style.gridColumn=`1 / ${n+1}`;const s=t(o,e);return typeof s=="string"?r.innerHTML=s:s instanceof HTMLElement&&r.appendChild(s),i.appendChild(r),i}const un=".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;font-size:10px;opacity:.7;-webkit-user-select:none;user-select:none}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border))}.master-detail-cell{padding:16px;overflow:auto}";class hn extends T{name="masterDetail";version="1.0.0";get defaultConfig(){return{detailHeight:"auto",expandOnRowClick:!1,collapseOnClickOutside:!1,showExpandColumn:!0}}expandedRows=new Set;detailElements=new Map;detach(){this.expandedRows.clear(),this.detailElements.clear()}processColumns(e){if(!this.config.detailRenderer)return[...e];const t=[...e];if(t.length>0){const n={...t[0]},i=n.viewRenderer;if(i?.__masterDetailWrapped)return t;const r=s=>{const{value:l,row:a}=s,c=this.expandedRows.has(a),d=document.createElement("span");d.className="master-detail-cell-wrapper";const h=document.createElement("span");h.className="master-detail-toggle",this.setIcon(h,this.resolveIcon(c?"collapse":"expand")),h.setAttribute("role","button"),h.setAttribute("tabindex","0"),h.setAttribute("aria-expanded",String(c)),h.setAttribute("aria-label",c?"Collapse details":"Expand details"),h.addEventListener("click",u=>{u.stopPropagation();const p=this.rows.indexOf(a);this.expandedRows=Re(this.expandedRows,a),this.emit("detail-expand",{rowIndex:p,row:a,expanded:this.expandedRows.has(a)}),this.requestRender()}),d.appendChild(h);const f=document.createElement("span");if(i){const u=i(s);u instanceof Node?f.appendChild(u):f.textContent=String(u??l??"")}else f.textContent=String(l??"");return d.appendChild(f),d};r.__masterDetailWrapped=!0,n.viewRenderer=r,t[0]=n}return t}onRowClick(e){if(!(!this.config.expandOnRowClick||!this.config.detailRenderer))return this.expandedRows=Re(this.expandedRows,e.row),this.emit("detail-expand",{rowIndex:e.rowIndex,row:e.row,expanded:this.expandedRows.has(e.row)}),this.requestRender(),!1}onCellClick(){this.expandedRows.size>0&&queueMicrotask(()=>this.#t())}afterRender(){this.#t()}onScrollRender(){!this.config.detailRenderer||this.expandedRows.size===0||this.#t()}#t(){if(!this.config.detailRenderer)return;const e=this.shadowRoot?.querySelector(".rows");if(!e)return;const t=new Map,n=e.querySelectorAll(".data-grid-row"),i=this.columns.length;for(const s of n){const l=s.querySelector(".cell[data-row]"),a=l?parseInt(l.getAttribute("data-row")??"-1",10):-1;a>=0&&t.set(a,s)}const r=e.querySelectorAll(".master-detail-row");for(const s of r){const l=parseInt(s.getAttribute("data-detail-for")??"-1",10),a=l>=0?this.rows[l]:void 0,c=a&&this.expandedRows.has(a),d=t.has(l);(!c||!d)&&(s.remove(),a&&this.detailElements.delete(a))}for(const[s,l]of t){const a=this.rows[s];if(!a||!this.expandedRows.has(a))continue;const c=this.detailElements.get(a);if(c){c.previousElementSibling!==l&&l.after(c);continue}const d=dn(a,s,this.config.detailRenderer,i);typeof this.config.detailHeight=="number"&&(d.style.height=`${this.config.detailHeight}px`),l.after(d),this.detailElements.set(a,d)}}getExtraHeight(){let e=0;for(const t of this.expandedRows){const n=this.detailElements.get(t);if(n)e+=n.offsetHeight;else{const i=this.config?.detailHeight;e+=typeof i=="number"?i:150}}return e}getExtraHeightBefore(e){let t=0;for(const n of this.expandedRows){const i=this.rows.indexOf(n);if(i>=0&&i<e){const r=this.detailElements.get(n);if(r)t+=r.offsetHeight;else{const s=this.config?.detailHeight;t+=typeof s=="number"?s:150}}}return t}adjustVirtualStart(e,t,n){if(this.expandedRows.size===0)return e;const i=[];for(const l of this.expandedRows){const a=this.rows.indexOf(l);a>=0&&i.push({index:a,row:l})}i.sort((l,a)=>l.index-a.index);let r=e,s=0;for(const{index:l,row:a}of i){const c=l*n+s,h=this.detailElements.get(a)?.offsetHeight??(typeof this.config?.detailHeight=="number"?this.config.detailHeight:150),f=c+n+h;s+=h,!(l>=e)&&f>t&&l<r&&(r=l)}return r}expand(e){const t=this.rows[e];t&&(this.expandedRows=ln(this.expandedRows,t),this.requestRender())}collapse(e){const t=this.rows[e];t&&(this.expandedRows=an(this.expandedRows,t),this.requestRender())}toggle(e){const t=this.rows[e];t&&(this.expandedRows=Re(this.expandedRows,t),this.requestRender())}isExpanded(e){const t=this.rows[e];return t?cn(this.expandedRows,t):!1}expandAll(){for(const e of this.rows)this.expandedRows.add(e);this.requestRender()}collapseAll(){this.expandedRows.clear(),this.requestRender()}getExpandedRows(){const e=[];for(const t of this.expandedRows){const n=this.rows.indexOf(t);n>=0&&e.push(n)}return e}getDetailElement(e){const t=this.rows[e];return t?this.detailElements.get(t):void 0}styles=un}function fn(o,e,t){return e.length?[...o].sort((n,i)=>{for(const r of e){const l=t.find(h=>h.field===r.field)?.sortComparator??pn,a=n[r.field],c=i[r.field],d=l(a,c,n,i);if(d!==0)return r.direction==="asc"?d:-d}return 0}):[...o]}function pn(o,e){return o==null&&e==null?0:o==null?1:e==null?-1:typeof o=="number"&&typeof e=="number"?o-e:o instanceof Date&&e instanceof Date?o.getTime()-e.getTime():typeof o=="boolean"&&typeof e=="boolean"?o===e?0:o?-1:1:String(o).localeCompare(String(e))}function gn(o,e,t,n){const i=o.find(r=>r.field===e);return t?i?i.direction==="asc"?o.map(r=>r.field===e?{...r,direction:"desc"}:r):o.filter(r=>r.field!==e):o.length<n?[...o,{field:e,direction:"asc"}]:o:i?.direction==="asc"?[{field:e,direction:"desc"}]:i?.direction==="desc"?[]:[{field:e,direction:"asc"}]}function lt(o,e){const t=o.findIndex(n=>n.field===e);return t>=0?t+1:void 0}function at(o,e){return o.find(t=>t.field===e)?.direction}const bn='.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';class wn extends T{name="multiSort";version="1.0.0";get defaultConfig(){return{maxSortColumns:3,showSortIndex:!0}}sortModel=[];detach(){this.sortModel=[]}processRows(e){return this.sortModel.length===0?[...e]:fn([...e],this.sortModel,[...this.columns])}onHeaderClick(e){if(!this.columns.find(r=>r.field===e.field)?.sortable)return!1;const n=e.originalEvent.shiftKey,i=this.config.maxSortColumns??3;return this.sortModel=gn(this.sortModel,e.field,n,i),this.emit("sort-change",{sortModel:[...this.sortModel]}),this.requestRender(),!0}afterRender(){const e=this.shadowRoot;if(!e)return;const t=this.config.showSortIndex!==!1;e.querySelectorAll(".header-row .cell[data-field]").forEach(i=>{const r=i.getAttribute("data-field");if(!r)return;const s=lt(this.sortModel,r),l=at(this.sortModel,r);if(i.querySelector(".sort-index")?.remove(),l){i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(),i.setAttribute("data-sort",l);const d=document.createElement("span");if(d.className="sort-indicator",d.style.marginLeft="4px",d.style.opacity="0.8",this.setIcon(d,this.resolveIcon(l==="asc"?"sortAsc":"sortDesc")),i.appendChild(d),t&&this.sortModel.length>1&&s!==void 0){const h=document.createElement("span");h.className="sort-index",h.textContent=String(s),i.appendChild(h)}}else i.removeAttribute("data-sort")})}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e],this.emit("sort-change",{sortModel:[...e]}),this.requestRender()}clearSort(){this.sortModel=[],this.emit("sort-change",{sortModel:[]}),this.requestRender()}getSortIndex(e){return lt(this.sortModel,e)}getSortDirection(e){return at(this.sortModel,e)}getColumnState(e){const t=this.sortModel.findIndex(i=>i.field===e);return t===-1?void 0:{sort:{direction:this.sortModel[t].direction,priority:t}}}applyColumnState(e,t){if(!t.sort){this.sortModel=this.sortModel.filter(r=>r.field!==e);return}const n=this.sortModel.findIndex(r=>r.field===e),i={field:e,direction:t.sort.direction};n!==-1?this.sortModel[n]=i:this.sortModel.splice(t.sort.priority,0,i)}styles=bn}function mn(o){return o.filter(e=>e.sticky==="left")}function vn(o){return o.filter(e=>e.sticky==="right")}function Se(o){return o.some(e=>e.sticky==="left"||e.sticky==="right")}function ct(o,e){const t=o.shadowRoot;if(!t)return;const n=Array.from(t.querySelectorAll(".header-row .cell"));if(!n.length)return;const i=new Map;e.forEach((l,a)=>{l.field&&i.set(l.field,a)});let r=0;for(const l of e)if(l.sticky==="left"){const a=i.get(l.field),c=n.find(d=>d.getAttribute("data-field")===l.field);c&&(c.classList.add("sticky-left"),c.style.left=r+"px",a!==void 0&&t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach(d=>{d.classList.add("sticky-left"),d.style.left=r+"px"}),r+=c.offsetWidth)}let s=0;for(const l of[...e].reverse())if(l.sticky==="right"){const a=i.get(l.field),c=n.find(d=>d.getAttribute("data-field")===l.field);c&&(c.classList.add("sticky-right"),c.style.right=s+"px",a!==void 0&&t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach(d=>{d.classList.add("sticky-right"),d.style.right=s+"px"}),s+=c.offsetWidth)}}function dt(o){const e=o.shadowRoot;if(!e)return;e.querySelectorAll(".sticky-left, .sticky-right").forEach(n=>{n.classList.remove("sticky-left","sticky-right"),n.style.left="",n.style.right=""})}class Cn extends T{name="pinnedColumns";version="1.0.0";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1}static detect(e,t){const n=t?.columns;return Array.isArray(n)?Se(n):!1}processColumns(e){return this.isApplied=Se([...e]),[...e]}afterRender(){if(!this.isApplied)return;const e=this.grid,t=[...this.columns];if(!Se(t)){dt(e),this.isApplied=!1;return}queueMicrotask(()=>{ct(e,t)})}refreshStickyOffsets(){const e=[...this.columns];ct(this.grid,e)}getLeftPinnedColumns(){const e=[...this.columns];return mn(e)}getRightPinnedColumns(){const e=[...this.columns];return vn(e)}clearStickyPositions(){dt(this.grid)}}function Ae(o,e){const t=document.createElement("div");t.className="tbw-pinned-rows",t.setAttribute("role","presentation"),t.setAttribute("aria-live","polite");const n=document.createElement("div");n.className="tbw-pinned-rows-left";const i=document.createElement("div");i.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",o.showRowCount!==!1){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-row-count",s.textContent=`Total: ${e.totalRows} rows`,n.appendChild(s)}if(o.showFilteredCount&&e.filteredRows!==e.totalRows){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-filtered-count",s.textContent=`Filtered: ${e.filteredRows}`,n.appendChild(s)}if(o.showSelectedCount&&e.selectedRows>0){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-selected-count",s.textContent=`Selected: ${e.selectedRows}`,r.appendChild(s)}if(o.customPanels)for(const s of o.customPanels){const l=yn(s,e);switch(s.position){case"left":n.appendChild(l);break;case"center":i.appendChild(l);break;case"right":r.appendChild(l);break}}return t.appendChild(n),t.appendChild(i),t.appendChild(r),t}function ut(o){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${o}`,e.setAttribute("role","presentation"),e}function ht(o,e,t,n){o.innerHTML="";for(const i of e){const r=document.createElement("div");if(r.className="tbw-aggregation-row",r.setAttribute("role","presentation"),i.id&&r.setAttribute("data-aggregation-id",i.id),i.fullWidth){const s=document.createElement("div");s.className="tbw-aggregation-cell tbw-aggregation-cell-full",s.style.gridColumn="1 / -1",s.textContent=i.label||"",r.appendChild(s)}else for(const s of t){const l=document.createElement("div");l.className="tbw-aggregation-cell",l.setAttribute("data-field",s.field);let a;const c=i.aggregators?.[s.field];if(c){const d=Ye(c);d&&(a=d(n,s.field,s))}else if(i.cells&&Object.prototype.hasOwnProperty.call(i.cells,s.field)){const d=i.cells[s.field];typeof d=="function"?a=d(n,s.field,s):a=d}l.textContent=a!=null?String(a):"",r.appendChild(l)}o.appendChild(r)}}function yn(o,e){const t=document.createElement("div");t.className="tbw-status-panel tbw-status-panel-custom",t.id=`status-panel-${o.id}`;const n=o.render(e);return typeof n=="string"?t.innerHTML=n:t.appendChild(n),t}function ft(o,e,t,n,i){return{totalRows:o.length,filteredRows:i?.cachedResult?.length??o.length,selectedRows:n?.selected?.size??0,columns:e,rows:o,grid:t}}const xn=".tbw-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";class En extends T{name="pinnedRows";version="1.0.0";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;const n=this.getSelectionState(),i=this.getFilterState(),r=ft(this.rows,this.columns,this.grid,n,i),s=this.config.aggregationRows||[],l=s.filter(f=>f.position==="top"),a=s.filter(f=>f.position!=="top");if(l.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=ut("top");const f=e.querySelector(".header");f&&f.nextSibling?t.insertBefore(this.topAggregationContainer,f.nextSibling):t.appendChild(this.topAggregationContainer)}ht(this.topAggregationContainer,l,this.visibleColumns,this.rows)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const c=this.config.showRowCount!==!1||this.config.showSelectedCount&&r.selectedRows>0||this.config.showFilteredCount&&r.filteredRows!==r.totalRows||this.config.customPanels&&this.config.customPanels.length>0,d=c&&this.config.position!=="top",h=a.length>0||d;if(c&&this.config.position==="top")if(!this.infoBarElement)this.infoBarElement=Ae(this.config,r),t.insertBefore(this.infoBarElement,t.firstChild);else{const f=Ae(this.config,r);this.infoBarElement.replaceWith(f),this.infoBarElement=f}else this.config.position==="top"&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);h?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",t.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=ut("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),ht(this.bottomAggregationContainer,a,this.visibleColumns,this.rows)),d&&(this.infoBarElement=Ae(this.config,r),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&this.config.position!=="top"&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const e=this.getSelectionState(),t=this.getFilterState();return ft(this.rows,this.columns,this.grid,e,t)}addPanel(e){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(e),this.requestRender()}removePanel(e){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(t=>t.id!==e),this.requestRender())}addAggregationRow(e){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(e),this.requestRender()}removeAggregationRow(e){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(t=>t.id!==e),this.requestRender())}styles=xn}const Rn=pe;function Sn(o){const e=[];return!o.rowGroupFields?.length&&!o.columnGroupFields?.length&&e.push("At least one row or column group field is required"),o.valueFields?.length||e.push("At least one value field is required"),e}function _e(o,e){return[...o,e].join("|")}function An(o,e){const t=e.rowGroupFields??[],n=e.columnGroupFields??[],i=e.valueFields??[],r=_n(o,n),s=pt(o,t,n,r,i,0,""),l=Tn(s,r,i),a=Object.values(l).reduce((c,d)=>c+d,0);return{rows:s,columnKeys:r,totals:l,grandTotal:a}}function _n(o,e){if(e.length===0)return["value"];const t=new Set;for(const n of o){const i=e.map(r=>String(n[r]??"")).join("|");t.add(i)}return[...t].sort()}function kn(o,e){const t=new Map;for(const n of o){const i=String(n[e]??""),r=t.get(i);r?r.push(n):t.set(i,[n])}return t}function pt(o,e,t,n,i,r,s){const l=[];if(e.length===0){const f=gt(o,t,n,i),u=bt(f);return l.push({rowKey:s||"all",rowLabel:s||"All",depth:r,values:f,total:u,isGroup:!1,rowCount:o.length}),l}const a=e[0],c=e.slice(1),d=c.length>0,h=kn(o,a);for(const[f,u]of h){const p=s?`${s}|${f}`:f,g=gt(u,t,n,i),b=bt(g);let w;d&&(w=pt(u,c,t,n,i,r+1,p)),l.push({rowKey:p,rowLabel:f||"(blank)",depth:r,values:g,total:b,isGroup:d,children:w,rowCount:u.length})}return l}function gt(o,e,t,n){const i={};for(const r of t)for(const s of n){const a=(e.length>0?o.filter(f=>e.map(u=>String(f[u]??"")).join("|")===r):o).map(f=>Number(f[s.field])||0),c=Rn(s.aggFunc),d=a.length>0?c(a):null,h=_e([r],s.field);i[h]=d}return i}function bt(o){let e=0;for(const t of Object.values(o))e+=t??0;return e}function Tn(o,e,t){const n={};function i(r){for(const s of r)if(!s.isGroup||!s.children?.length)for(const l of e)for(const a of t){const c=_e([l],a.field);n[c]=(n[c]??0)+(s.values[c]??0)}else s.children&&i(s.children)}return i(o),n}function Ln(o,e,t=!0){const n=[];function i(r){n.push(r);const s=e?e.has(r.rowKey):t;if(r.children&&s)for(const l of r.children)i(l)}for(const r of o)i(r);return n}function ke(o){const e=[];function t(n){if(n.isGroup&&e.push(n.rowKey),n.children)for(const i of n.children)t(i)}for(const n of o)t(n);return e}const Pn=["sum","avg","count","min","max","first","last"];function Mn(o,e,t,n){const i=new AbortController,r={config:e,callbacks:n,signal:i.signal},s=document.createElement("div");return s.className="tbw-pivot-panel",s.appendChild(ee("Options",()=>On(t,r))),s.appendChild(ee("Row Groups",()=>wt("rowGroups",r))),s.appendChild(ee("Column Groups",()=>wt("columnGroups",r))),s.appendChild(ee("Values",()=>Nn(r))),s.appendChild(ee("Available Fields",()=>Hn(r))),o.appendChild(s),()=>{i.abort(),s.remove()}}function ee(o,e){const t=document.createElement("div");t.className="tbw-pivot-section";const n=document.createElement("div");n.className="tbw-pivot-section-header",n.textContent=o;const i=document.createElement("div");return i.className="tbw-pivot-section-content",i.appendChild(e()),t.appendChild(n),t.appendChild(i),t}function wt(o,e){const{config:t,callbacks:n,signal:i}=e,r=document.createElement("div");r.className="tbw-pivot-drop-zone",r.setAttribute("data-zone",o);const s=o==="rowGroups"?t.rowGroupFields??[]:t.columnGroupFields??[];if(s.length===0){const l=document.createElement("div");l.className="tbw-pivot-placeholder",l.textContent="Drag fields here or click to add",r.appendChild(l)}else for(const l of s)r.appendChild(In(l,o,e));return r.addEventListener("dragover",l=>{l.preventDefault(),r.classList.add("drag-over")},{signal:i}),r.addEventListener("dragleave",()=>{r.classList.remove("drag-over")},{signal:i}),r.addEventListener("drop",l=>{l.preventDefault(),r.classList.remove("drag-over");const a=l.dataTransfer?.getData("text/plain");a&&n.onAddFieldToZone(a,o)},{signal:i}),r}function In(o,e,t){const{callbacks:n,signal:i}=t,r=document.createElement("div");r.className="tbw-pivot-field-chip",r.draggable=!0;const s=n.getAvailableFields().find(c=>c.field===o),l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=s?.header??o;const a=document.createElement("button");return a.className="tbw-pivot-chip-remove",a.innerHTML="×",a.title="Remove field",a.addEventListener("click",c=>{c.stopPropagation(),n.onRemoveFieldFromZone(o,e)},{signal:i}),r.appendChild(l),r.appendChild(a),r.addEventListener("dragstart",c=>{c.dataTransfer?.setData("text/plain",o),c.dataTransfer?.setData("source-zone",e),r.classList.add("dragging")},{signal:i}),r.addEventListener("dragend",()=>{r.classList.remove("dragging")},{signal:i}),r}function Nn(o){const{config:e,callbacks:t,signal:n}=o,i=document.createElement("div");i.className="tbw-pivot-drop-zone tbw-pivot-values-zone",i.setAttribute("data-zone","values");const r=e.valueFields??[];if(r.length===0){const s=document.createElement("div");s.className="tbw-pivot-placeholder",s.textContent="Drag numeric fields here for aggregation",i.appendChild(s)}else for(const s of r)i.appendChild(Dn(s,o));return i.addEventListener("dragover",s=>{s.preventDefault(),i.classList.add("drag-over")},{signal:n}),i.addEventListener("dragleave",()=>{i.classList.remove("drag-over")},{signal:n}),i.addEventListener("drop",s=>{s.preventDefault(),i.classList.remove("drag-over");const l=s.dataTransfer?.getData("text/plain");l&&t.onAddValueField(l,"sum")},{signal:n}),i}function Dn(o,e){const{callbacks:t,signal:n}=e,i=document.createElement("div");i.className="tbw-pivot-field-chip tbw-pivot-value-chip";const r=t.getAvailableFields().find(d=>d.field===o.field),s=document.createElement("div");s.className="tbw-pivot-value-label-wrapper";const l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=r?.header??o.field;const a=document.createElement("select");a.className="tbw-pivot-agg-select",a.title="Aggregation function";for(const d of Pn){const h=document.createElement("option");h.value=d,h.textContent=d.toUpperCase(),h.selected=d===o.aggFunc,a.appendChild(h)}a.addEventListener("change",()=>{t.onUpdateValueAggFunc(o.field,a.value)},{signal:n});const c=document.createElement("button");return c.className="tbw-pivot-chip-remove",c.innerHTML="×",c.title="Remove value field",c.addEventListener("click",d=>{d.stopPropagation(),t.onRemoveValueField(o.field)},{signal:n}),s.appendChild(l),s.appendChild(a),i.appendChild(s),i.appendChild(c),i}function Hn(o){const{config:e,callbacks:t,signal:n}=o,i=document.createElement("div");i.className="tbw-pivot-available-fields";const r=t.getAvailableFields(),s=new Set([...e.rowGroupFields??[],...e.columnGroupFields??[],...e.valueFields?.map(a=>a.field)??[]]),l=r.filter(a=>!s.has(a.field));if(l.length===0){const a=document.createElement("div");a.className="tbw-pivot-placeholder",a.textContent="All fields are in use",i.appendChild(a)}else for(const a of l){const c=document.createElement("div");c.className="tbw-pivot-field-chip available",c.textContent=a.header,c.draggable=!0,c.title=`Drag to add "${a.field}" to a zone`,c.addEventListener("dragstart",d=>{d.dataTransfer?.setData("text/plain",a.field),c.classList.add("dragging")},{signal:n}),c.addEventListener("dragend",()=>{c.classList.remove("dragging")},{signal:n}),i.appendChild(c)}return i}function On(o,e){const{config:t,callbacks:n,signal:i}=e,r=document.createElement("div");return r.className="tbw-pivot-options",r.appendChild(Te("Enable Pivot View",o,s=>{n.onTogglePivot(s)},i)),r.appendChild(Te("Show Row Totals",t.showTotals??!0,s=>{n.onOptionChange("showTotals",s)},i)),r.appendChild(Te("Show Grand Total",t.showGrandTotal??!0,s=>{n.onOptionChange("showGrandTotal",s)},i)),r}function Te(o,e,t,n){const i=document.createElement("label");i.className="tbw-pivot-checkbox";const r=document.createElement("input");r.type="checkbox",r.checked=e,r.addEventListener("change",()=>t(r.checked),{signal:n});const s=document.createElement("span");return s.textContent=o,i.appendChild(r),i.appendChild(s),i}function zn(o,e,t){return e.className="pivot-group-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("role","row"),e.innerHTML="",t.columns.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),r.setAttribute("role","gridcell"),i===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s}px`;const l=String(o.__pivotRowKey),a=document.createElement("button");a.type="button",a.className="pivot-toggle",a.setAttribute("aria-label",o.__pivotExpanded?"Collapse group":"Expand group"),t.setIcon(a,t.resolveIcon(o.__pivotExpanded?"collapse":"expand")),a.addEventListener("click",h=>{h.stopPropagation(),t.onToggle(l)}),r.appendChild(a);const c=document.createElement("span");c.className="pivot-label",c.textContent=String(o.__pivotLabel??""),r.appendChild(c);const d=document.createElement("span");d.className="pivot-count",d.textContent=` (${Number(o.__pivotRowCount)||0})`,r.appendChild(d)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function Fn(o,e,t){return e.className="pivot-leaf-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.innerHTML="",t.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),r.setAttribute("role","gridcell"),i===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s+20}px`;const l=document.createElement("span");l.className="pivot-label",l.textContent=String(o.__pivotLabel??""),r.appendChild(l)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function qn(o,e,t){return e.className="pivot-grand-total-row",e.setAttribute("role","presentation"),e.innerHTML="",t.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),i===0){const s=document.createElement("span");s.className="pivot-label",s.textContent="Grand Total",r.appendChild(s)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}const Bn='.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;font-size:10px;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}';class V extends T{name="pivot";version="1.0.0";static PANEL_ID="pivot";get defaultConfig(){return{active:!0,showTotals:!0,showGrandTotal:!0}}isActive=!1;hasInitialized=!1;pivotResult=null;fieldHeaderMap=new Map;expandedKeys=new Set;defaultExpanded=!0;originalColumns=[];panelContainer=null;grandTotalFooter=null;hasValidPivotConfig(){return(this.config.valueFields?.length??0)>0}detach(){this.isActive=!1,this.hasInitialized=!1,this.pivotResult=null,this.fieldHeaderMap.clear(),this.originalColumns=[],this.panelContainer=null,this.cleanupGrandTotalFooter()}getToolPanel(){return{id:V.PANEL_ID,title:"Pivot",icon:"⊞",tooltip:"Configure pivot table",order:90,render:e=>this.renderPanel(e)}}processRows(e){if(!this.hasInitialized&&this.config.active!==!1&&this.hasValidPivotConfig()&&(this.hasInitialized=!0,this.isActive=!0),!this.isActive)return[...e];const t=Sn(this.config);if(t.length>0)return this.warn(`Config errors: ${t.join(", ")}`),[...e];if(this.buildFieldHeaderMap(),this.defaultExpanded=this.config.defaultExpanded??!0,this.expandedKeys.size===0&&this.defaultExpanded&&this.pivotResult){const r=ke(this.pivotResult.rows);for(const s of r)this.expandedKeys.add(s)}if(this.pivotResult=An(e,this.config),this.expandedKeys.size===0&&this.defaultExpanded){const r=ke(this.pivotResult.rows);for(const s of r)this.expandedKeys.add(s)}const n=this.config.indentWidth??20;return Ln(this.pivotResult.rows,this.expandedKeys,this.defaultExpanded).map(r=>({__pivotRowKey:r.rowKey,__pivotLabel:r.rowLabel,__pivotDepth:r.depth,__pivotIsGroup:r.isGroup,__pivotHasChildren:!!r.children?.length,__pivotExpanded:this.expandedKeys.has(r.rowKey),__pivotRowCount:r.rowCount??0,__pivotIndent:r.depth*n,__pivotTotal:r.total,...r.values}))}processColumns(e){if(!this.isActive||!this.pivotResult)return[...e];const t=[],n=(this.config.rowGroupFields??[]).map(i=>this.fieldHeaderMap.get(i)??i).join(" / ");t.push({field:"__pivotLabel",header:n||"Group",width:200});for(const i of this.pivotResult.columnKeys)for(const r of this.config.valueFields??[]){const s=_e([i],r.field),l=r.header||this.fieldHeaderMap.get(r.field)||r.field;t.push({field:s,header:`${i} - ${l} (${r.aggFunc})`,width:120,type:"number"})}return this.config.showTotals&&t.push({field:"__pivotTotal",header:"Total",width:100,type:"number"}),t}renderRow(e,t){const n=e;return n.__pivotRowKey&&n.__pivotHasChildren?zn(n,t,{columns:this.gridColumns,onToggle:i=>this.toggle(i),resolveIcon:i=>this.resolveIcon(i),setIcon:(i,r)=>this.setIcon(i,r)}):n.__pivotRowKey!==void 0&&this.isActive?Fn(n,t,this.gridColumns):(this.cleanupPivotStyling(t),!1)}cleanupPivotStyling(e){(e.classList.contains("pivot-group-row")||e.classList.contains("pivot-leaf-row")||e.classList.contains("pivot-grand-total-row"))&&(e.classList.remove("pivot-group-row","pivot-leaf-row","pivot-grand-total-row"),e.classList.add("data-grid-row"),e.removeAttribute("data-pivot-depth"),e.innerHTML="")}afterRender(){this.isActive&&this.config.showGrandTotal&&this.pivotResult?this.renderGrandTotalFooter():this.cleanupGrandTotalFooter()}renderGrandTotalFooter(){if(!this.pivotResult)return;const e=this.shadowRoot;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.grandTotalFooter||(this.grandTotalFooter=document.createElement("div"),this.grandTotalFooter.className="pivot-grand-total-footer",t.appendChild(this.grandTotalFooter));const n={__pivotRowKey:"__grandTotal",__pivotLabel:"Grand Total",__pivotIsGrandTotal:!0,__pivotTotal:this.pivotResult.grandTotal,...this.pivotResult.totals};qn(n,this.grandTotalFooter,this.gridColumns)}cleanupGrandTotalFooter(){this.grandTotalFooter&&(this.grandTotalFooter.remove(),this.grandTotalFooter=null)}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e),this.requestRender()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}expandAll(){if(this.pivotResult){const e=ke(this.pivotResult.rows);for(const t of e)this.expandedKeys.add(t);this.requestRender()}}collapseAll(){this.expandedKeys.clear(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}enablePivot(){this.originalColumns.length===0&&this.captureOriginalColumns(),this.isActive=!0,this.requestRender()}disablePivot(){this.isActive=!1,this.pivotResult=null,this.requestRender()}isPivotActive(){return this.isActive}getPivotResult(){return this.pivotResult}setRowGroupFields(e){this.config.rowGroupFields=e,this.requestRender()}setColumnGroupFields(e){this.config.columnGroupFields=e,this.requestRender()}setValueFields(e){this.config.valueFields=e,this.requestRender()}refresh(){this.pivotResult=null,this.requestRender()}showPanel(){this.grid.openToolPanel(V.PANEL_ID)}hidePanel(){this.grid.closeToolPanel()}togglePanel(){this.grid.toggleToolPanel(V.PANEL_ID)}isPanelVisible(){return this.grid.activeToolPanel===V.PANEL_ID}get gridColumns(){return this.grid.columns??[]}buildFieldHeaderMap(){const e=this.getAvailableFields();this.fieldHeaderMap.clear();for(const t of e)this.fieldHeaderMap.set(t.field,t.header)}getAvailableFields(){return this.originalColumns.length>0?this.originalColumns:this.captureOriginalColumns()}captureOriginalColumns(){const e=this.grid;try{const t=e.getAllColumns?.()??e.columns??[];return this.originalColumns=t.filter(n=>!n.field.startsWith("__pivot")).map(n=>({field:n.field,header:n.header??n.field})),this.originalColumns}catch{return[]}}renderPanel(e){this.panelContainer=e,this.originalColumns.length===0&&this.captureOriginalColumns();const t={onTogglePivot:n=>{n?this.enablePivot():this.disablePivot(),this.refreshPanel()},onAddFieldToZone:(n,i)=>this.addFieldToZone(n,i),onRemoveFieldFromZone:(n,i)=>this.removeFieldFromZone(n,i),onAddValueField:(n,i)=>this.addValueField(n,i),onRemoveValueField:n=>this.removeValueField(n),onUpdateValueAggFunc:(n,i)=>this.updateValueAggFunc(n,i),onOptionChange:(n,i)=>{this.config[n]=i,this.isActive&&this.refresh()},getAvailableFields:()=>this.getAvailableFields()};return Mn(e,this.config,this.isActive,t)}refreshPanel(){this.panelContainer&&(this.panelContainer.innerHTML="",this.renderPanel(this.panelContainer))}addFieldToZone(e,t){if(t==="rowGroups"){const n=this.config.rowGroupFields??[];n.includes(e)||(this.config.rowGroupFields=[...n,e])}else{const n=this.config.columnGroupFields??[];n.includes(e)||(this.config.columnGroupFields=[...n,e])}this.removeFromOtherZones(e,t),this.isActive&&this.refresh(),this.refreshPanel()}removeFieldFromZone(e,t){t==="rowGroups"?this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(n=>n!==e):this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(n=>n!==e),this.isActive&&this.refresh(),this.refreshPanel()}removeFromOtherZones(e,t){t!=="rowGroups"&&(this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(n=>n!==e)),t!=="columnGroups"&&(this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(n=>n!==e)),t!=="values"&&(this.config.valueFields=(this.config.valueFields??[]).filter(n=>n.field!==e))}addValueField(e,t){const n=this.config.valueFields??[];n.some(i=>i.field===e)||(this.config.valueFields=[...n,{field:e,aggFunc:t}]),this.removeFromOtherZones(e,"values"),this.isActive&&this.refresh(),this.refreshPanel()}removeValueField(e){this.config.valueFields=(this.config.valueFields??[]).filter(t=>t.field!==e),this.isActive&&this.refresh(),this.refreshPanel()}updateValueAggFunc(e,t){const n=this.config.valueFields??[],i=n.findIndex(r=>r.field===e);i>=0&&(n[i]={...n[i],aggFunc:t},this.config.valueFields=[...n]),this.isActive&&this.refresh()}styles=Bn}function $n(o){const e=o.sticky;if(e==="left"||e==="right")return!1;const t=o.meta??{},n=t.sticky;return n==="left"||n==="right"?!1:t.lockPosition!==!0&&t.suppressMovable!==!0}function mt(o,e,t){if(e===t||e<0||e>=o.length||t<0||t>o.length)return o;const n=[...o],[i]=n.splice(e,1);return n.splice(t,0,i),n}const Gn='.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';class Kn extends T{name="reorder";version="1.0.0";get defaultConfig(){return{animation:!0,animationDuration:200}}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;attach(e){super.attach(e),e.addEventListener("column-reorder-request",t=>{const n=t.detail;n?.field&&typeof n.toIndex=="number"&&this.moveColumn(n.field,n.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}afterRender(){const e=this.shadowRoot;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(n=>{const i=n,r=i.getAttribute("data-field");if(!r)return;const s=this.columns.find(l=>l.field===r);if(!s||!$n(s)){i.draggable=!1;return}i.draggable=!0,!i.getAttribute("data-dragstart-bound")&&(i.setAttribute("data-dragstart-bound","true"),i.addEventListener("dragstart",l=>{const c=this.getColumnOrder().indexOf(r);this.isDragging=!0,this.draggedField=r,this.draggedIndex=c,l.dataTransfer&&(l.dataTransfer.effectAllowed="move",l.dataTransfer.setData("text/plain",r)),i.classList.add("dragging")}),i.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,e.querySelectorAll(".header-row > .cell").forEach(l=>{l.classList.remove("dragging","drop-target","drop-before","drop-after")})}),i.addEventListener("dragover",l=>{if(l.preventDefault(),!this.isDragging||this.draggedField===r)return;const a=i.getBoundingClientRect(),c=a.left+a.width/2,h=this.getColumnOrder().indexOf(r);this.dropIndex=l.clientX<c?h:h+1,i.classList.add("drop-target"),i.classList.toggle("drop-before",l.clientX<c),i.classList.toggle("drop-after",l.clientX>=c)}),i.addEventListener("dragleave",()=>{i.classList.remove("drop-target","drop-before","drop-after")}),i.addEventListener("drop",l=>{l.preventDefault();const a=this.draggedField,c=this.draggedIndex,d=this.dropIndex;if(!this.isDragging||a===null||c===null||d===null)return;const h=d>c?d-1:d,f=this.getColumnOrder(),u=mt(f,c,h),p={field:a,fromIndex:c,toIndex:h,columnOrder:u};this.grid.setColumnOrder(u),this.emit("column-move",p),this.grid.requestStateChange?.()}))})}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const n=this.getColumnOrder(),i=n.indexOf(e);if(i===-1)return;const r=mt(n,i,t);this.grid.setColumnOrder(r),this.emit("column-move",{field:e,fromIndex:i,toIndex:t,columnOrder:r}),this.grid.requestStateChange?.()}setColumnOrder(e){this.grid.setColumnOrder(e),this.grid.requestStateChange?.()}resetColumnOrder(){const e=this.columns.map(t=>t.field);this.grid.setColumnOrder(e),this.grid.requestStateChange?.()}styles=Gn}function ne(o,e){return Math.floor(o/e)}function Vn(o,e){return{start:o*e,end:(o+1)*e}}function Wn(o,e,t){const n=ne(o,t),i=ne(e-1,t),r=[];for(let s=n;s<=i;s++)r.push(s);return r}async function vt(o,e,t,n){const i=Vn(e,t);return o.getRows({startRow:i.start,endRow:i.end,sortModel:n.sortModel,filterModel:n.filterModel})}function jn(o,e,t){const n=ne(o,e),i=t.get(n);if(!i)return;const r=o%e;return i[r]}const Un=100;class Xn extends T{name="serverSide";version="1.0.0";get defaultConfig(){return{pageSize:100,cacheBlockSize:100,maxConcurrentRequests:2}}dataSource=null;totalRowCount=0;loadedBlocks=new Map;loadingBlocks=new Set;lastRequestId=0;scrollDebounceTimer;detach(){this.dataSource=null,this.totalRowCount=0,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}loadRequiredBlocks(){if(!this.dataSource)return;const e=this.grid,t=this.config.cacheBlockSize??100,n={startRow:e.virtualization.start,endRow:e.virtualization.end},i=Wn(n.startRow,n.endRow,t);for(const r of i)if(!(this.loadedBlocks.has(r)||this.loadingBlocks.has(r))){if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2))break;this.loadingBlocks.add(r),vt(this.dataSource,r,t,{}).then(s=>{this.loadedBlocks.set(r,s.rows),this.totalRowCount=s.totalRowCount,this.loadingBlocks.delete(r),this.requestRender(),this.loadRequiredBlocks()}).catch(()=>{this.loadingBlocks.delete(r)})}}processRows(e){if(!this.dataSource)return[...e];const t=[];for(let n=0;n<this.totalRowCount;n++){const i=jn(n,this.config.cacheBlockSize??100,this.loadedBlocks);t.push(i??{__loading:!0,__index:n})}return t}onScroll(e){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},Un))}setDataSource(e){this.dataSource=e,this.loadedBlocks.clear(),this.loadingBlocks.clear();const t=this.config.cacheBlockSize??100;vt(e,0,t,{}).then(n=>{this.loadedBlocks.set(0,n.rows),this.totalRowCount=n.totalRowCount,this.requestRender()})}refresh(){this.dataSource&&(this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.requestRender())}purgeCache(){this.loadedBlocks.clear()}getTotalRowCount(){return this.totalRowCount}isRowLoaded(e){const t=this.config.cacheBlockSize??100,n=ne(e,t);return this.loadedBlocks.has(n)}getLoadedBlockCount(){return this.loadedBlocks.size}}function Yn(o,e,t){const n=[...o.undoStack,e];for(;n.length>t;)n.shift();return{undoStack:n,redoStack:[]}}function Ct(o){if(o.undoStack.length===0)return{newState:o,action:null};const e=[...o.undoStack],t=e.pop();return t?{newState:{undoStack:e,redoStack:[...o.redoStack,t]},action:t}:{newState:o,action:null}}function yt(o){if(o.redoStack.length===0)return{newState:o,action:null};const e=[...o.redoStack],t=e.pop();return t?{newState:{undoStack:[...o.undoStack,t],redoStack:e},action:t}:{newState:o,action:null}}function Zn(o){return o.undoStack.length>0}function Jn(o){return o.redoStack.length>0}function Qn(){return{undoStack:[],redoStack:[]}}function ei(o,e,t,n){return{type:"cell-edit",rowIndex:o,field:e,oldValue:t,newValue:n,timestamp:Date.now()}}class ti extends T{name="undoRedo";version="1.0.0";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];detach(){this.undoStack=[],this.redoStack=[]}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey,n=(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey);if(t){const i=Ct({undoStack:this.undoStack,redoStack:this.redoStack});if(i.action){const r=this.rows;r[i.action.rowIndex]&&(r[i.action.rowIndex][i.action.field]=i.action.oldValue),this.undoStack=i.newState.undoStack,this.redoStack=i.newState.redoStack,this.emit("undo",{action:i.action,type:"undo"}),this.requestRender()}return!0}if(n){const i=yt({undoStack:this.undoStack,redoStack:this.redoStack});if(i.action){const r=this.rows;r[i.action.rowIndex]&&(r[i.action.rowIndex][i.action.field]=i.action.newValue),this.undoStack=i.newState.undoStack,this.redoStack=i.newState.redoStack,this.emit("redo",{action:i.action,type:"redo"}),this.requestRender()}return!0}return!1}recordEdit(e,t,n,i){const r=ei(e,t,n,i),s=Yn({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=s.undoStack,this.redoStack=s.redoStack}undo(){const e=Ct({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.oldValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}redo(){const e=yt({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.newValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}canUndo(){return Zn({undoStack:this.undoStack,redoStack:this.redoStack})}canRedo(){return Jn({undoStack:this.undoStack,redoStack:this.redoStack})}clearHistory(){const e=Qn();this.undoStack=e.undoStack,this.redoStack=e.redoStack}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}}const oi='.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';function xt(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class W extends T{name="visibility";version="1.0.0";static PANEL_ID="columns";get defaultConfig(){return{allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){return{id:W.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(W.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.toggleToolPanel(W.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(t=>t.visible).map(t=>t.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(t=>!t.visible).map(t=>t.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.grid.setColumnVisible(e,!0)}hideColumn(e){this.grid.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.activeToolPanel===W.PANEL_ID}renderPanelContent(e){const t=this.grid,n=document.createElement("div");n.className="tbw-visibility-content";const i=document.createElement("div");i.className="tbw-visibility-list",n.appendChild(i);const r=document.createElement("button");return r.className="tbw-visibility-show-all",r.textContent="Show All",r.addEventListener("click",()=>{t.showAllColumns(),this.rebuildToggles(i)}),n.appendChild(r),this.columnListElement=i,this.rebuildToggles(i),e.appendChild(n),()=>{this.columnListElement=null,n.remove()}}hasReorderPlugin(){const e=this.grid?.getPluginByName?.("reorder");return!!(e&&typeof e.moveColumn=="function")}rebuildToggles(e){const t=this.grid,n=this.hasReorderPlugin();e.innerHTML="";const i=t.getAllColumns();for(let r=0;r<i.length;r++){const s=i[r],l=s.header||s.field,a=document.createElement("div");a.className=s.lockVisible?"tbw-visibility-row locked":"tbw-visibility-row",a.setAttribute("data-field",s.field),a.setAttribute("data-index",String(r)),n&&xt(s)&&(a.draggable=!0,a.classList.add("reorderable"),this.setupDragListeners(a,s.field,r,e));const c=document.createElement("label");c.className="tbw-visibility-label";const d=document.createElement("input");d.type="checkbox",d.checked=s.visible,d.disabled=s.lockVisible??!1,d.addEventListener("change",()=>{t.toggleColumnVisibility(s.field),setTimeout(()=>this.rebuildToggles(e),0)});const h=document.createElement("span");if(h.textContent=l,c.appendChild(d),c.appendChild(h),n&&xt(s)){const f=document.createElement("span");f.className="tbw-visibility-handle",this.setIcon(f,this.resolveIcon("dragHandle")),f.title="Drag to reorder",a.appendChild(f)}a.appendChild(c),e.appendChild(a)}}setupDragListeners(e,t,n,i){e.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=t,this.draggedIndex=n,r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",t)),e.classList.add("dragging")}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,i.querySelectorAll(".tbw-visibility-row").forEach(r=>{r.classList.remove("dragging","drop-target","drop-before","drop-after")})}),e.addEventListener("dragover",r=>{if(r.preventDefault(),!this.isDragging||this.draggedField===t)return;const s=e.getBoundingClientRect(),l=s.top+s.height/2;this.dropIndex=r.clientY<l?n:n+1,i.querySelectorAll(".tbw-visibility-row").forEach(a=>{a!==e&&a.classList.remove("drop-target","drop-before","drop-after")}),e.classList.add("drop-target"),e.classList.toggle("drop-before",r.clientY<l),e.classList.toggle("drop-after",r.clientY>=l)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",r=>{r.preventDefault();const s=this.draggedField,l=this.draggedIndex,a=this.dropIndex;if(!this.isDragging||s===null||l===null||a===null)return;const c=a>l?a-1:a;if(c!==l){const d={field:s,fromIndex:l,toIndex:c};this.emit("column-reorder-request",d),setTimeout(()=>{this.rebuildToggles(i)},0)}})}styles=oi}y.BaseGridPlugin=T,y.ClipboardPlugin=_o,y.ColumnVirtualizationPlugin=Po,y.ContextMenuPlugin=No,y.DEFAULT_GRID_ICONS=I,y.DGEvents=Co,y.DataGridElement=Z,y.ExportPlugin=Fo,y.FilteringPlugin=F,y.FitModeEnum=q,y.GridCSSVars=vo,y.GridClasses=M,y.GridDataAttrs=J,y.GridElement=Z,y.GridSelectors=mo,y.GroupingColumnsPlugin=Jo,y.GroupingRowsPlugin=sn,y.MasterDetailPlugin=hn,y.MultiSortPlugin=wn,y.PinnedColumnsPlugin=Cn,y.PinnedRowsPlugin=En,y.PivotPlugin=V,y.PluginEvents=yo,y.PluginManager=Ge,y.ReorderPlugin=Kn,y.SelectionPlugin=ho,y.ServerSidePlugin=Xn,y.TreePlugin=wo,y.UndoRedoPlugin=ti,y.VisibilityPlugin=W,y.aggregatorRegistry=D,y.getAggregator=Ye,y.getValueAggregator=pe,y.listAggregators=So,y.registerAggregator=Eo,y.runAggregator=ge,y.runValueAggregator=xo,y.unregisterAggregator=Ro,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
233
|
+
`;class F extends T{name="filtering";version="1.0.0";get defaultConfig(){return{debounceMs:300,caseSensitive:!1,trimInput:!0,useWorker:!0}}filters=new Map;cachedResult=null;cacheKey=null;openPanelField=null;panelElement=null;searchText=new Map;excludedValues=new Map;panelAbortController=null;globalStylesInjected=!1;static LIST_ITEM_HEIGHT=28;static LIST_OVERSCAN=3;static LIST_BYPASS_THRESHOLD=50;attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}processRows(e){const t=[...this.filters.values()];if(!t.length)return[...e];const n=Mo(t);if(this.cacheKey===n&&this.cachedResult)return this.cachedResult;const i=Po([...e],t,this.config.caseSensitive);return this.cachedResult=i,this.cacheKey=n,i}afterRender(){const e=this.shadowRoot;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(n=>{const i=n.getAttribute("data-col");if(i===null)return;const r=this.columns[parseInt(i,10)];if(!r||r.filterable===!1||n.querySelector(".tbw-filter-btn"))return;const s=r.field;if(!s)return;const l=document.createElement("button");l.className="tbw-filter-btn",l.setAttribute("aria-label",`Filter ${r.header??s}`),l.innerHTML='<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>',this.filters.has(s)&&(l.classList.add("active"),n.classList.add("filtered")),l.addEventListener("click",a=>{a.stopPropagation(),this.toggleFilterPanel(s,r,l)}),n.appendChild(l)})}setFilter(e,t){t===null?this.filters.delete(e):this.filters.set(e,{...t,field:e}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e){this.filters.clear();for(const t of e)this.filters.set(t.field,t);this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}clearAllFilters(){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[],filteredRowCount:this.rows.length}),this.requestRender()}clearFieldFilter(e){this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){return tt(this.sourceRows,e)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles")){this.globalStylesInjected=!0;return}const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent=No,document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,n){if(this.openPanelField===e){this.closeFilterPanel();return}this.closeFilterPanel();const i=document.createElement("div");i.className="tbw-filter-panel",this.panelElement=i,this.openPanelField=e;const r=tt(this.sourceRows,e);let s=this.excludedValues.get(e);s||(s=new Set,this.excludedValues.set(e,s));const l=this.searchText.get(e)??"",a={field:e,column:t,uniqueValues:r,excludedValues:s,searchText:l,applySetFilter:d=>{this.applySetFilter(e,d),this.closeFilterPanel()},applyTextFilter:(d,h,f)=>{this.applyTextFilter(e,d,h,f),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(e),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let c=!1;this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(i,a),c=i.children.length>0),c||this.renderDefaultFilterPanel(i,a,r,s),document.body.appendChild(i),this.positionPanel(i,n),this.panelAbortController=new AbortController,setTimeout(()=>{document.addEventListener("click",d=>{!i.contains(d.target)&&d.target!==n&&this.closeFilterPanel()},{signal:this.panelAbortController?.signal})},0)}closeFilterPanel(){this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}positionPanel(e,t){const n=t.getBoundingClientRect();e.style.position="fixed",e.style.top=`${n.bottom+4}px`,e.style.left=`${n.left}px`,requestAnimationFrame(()=>{const i=e.getBoundingClientRect();i.right>window.innerWidth-8&&(e.style.left=`${window.innerWidth-i.width-8}px`),i.bottom>window.innerHeight-8&&(e.style.top=`${n.top-i.height-4}px`)})}renderDefaultFilterPanel(e,t,n,i){const{field:r}=t,s=document.createElement("div");s.className="tbw-filter-search";const l=document.createElement("input");l.type="text",l.placeholder="Search...",l.className="tbw-filter-search-input",l.value=this.searchText.get(r)??"",s.appendChild(l),e.appendChild(s);const a=document.createElement("div");a.className="tbw-filter-actions";const c=document.createElement("label");c.className="tbw-filter-value-item",c.style.padding="0",c.style.margin="0";const d=document.createElement("input");d.type="checkbox",d.className="tbw-filter-checkbox";const h=document.createElement("span");h.textContent="Select All",c.appendChild(d),c.appendChild(h),a.appendChild(c);const f=()=>{const v=[...b.values()],x=v.every(S=>S),E=v.every(S=>!S);d.checked=x,d.indeterminate=!x&&!E};d.addEventListener("change",()=>{const v=d.checked;for(const x of b.keys())b.set(x,v);f(),k()}),e.appendChild(a);const u=document.createElement("div");u.className="tbw-filter-values";const p=document.createElement("div");p.className="tbw-filter-values-spacer",u.appendChild(p);const g=document.createElement("div");g.className="tbw-filter-values-content",u.appendChild(g);const b=new Map;n.forEach(v=>{const x=v==null?"__null__":String(v);b.set(x,!i.has(v))}),f();let w=[];const A=(v,x)=>{const E=v==null?"(Blank)":String(v),S=v==null?"__null__":String(v),P=document.createElement("label");P.className="tbw-filter-value-item",P.style.position="absolute",P.style.top=`${x*F.LIST_ITEM_HEIGHT}px`,P.style.left="0",P.style.right="0",P.style.height=`${F.LIST_ITEM_HEIGHT}px`,P.style.boxSizing="border-box";const O=document.createElement("input");O.type="checkbox",O.className="tbw-filter-checkbox",O.checked=b.get(S)??!0,O.dataset.value=S,O.addEventListener("change",()=>{b.set(S,O.checked),f()});const Et=document.createElement("span");return Et.textContent=E,P.appendChild(O),P.appendChild(Et),P},k=()=>{const v=w.length,x=u.clientHeight,E=u.scrollTop;if(p.style.height=`${v*F.LIST_ITEM_HEIGHT}px`,To(v,F.LIST_BYPASS_THRESHOLD/3)){g.innerHTML="",g.style.transform="translateY(0px)",w.forEach((P,O)=>{g.appendChild(A(P,O))});return}const S=ko({totalRows:v,viewportHeight:x,scrollTop:E,rowHeight:F.LIST_ITEM_HEIGHT,overscan:F.LIST_OVERSCAN});g.style.transform=`translateY(${S.offsetY}px)`,g.innerHTML="";for(let P=S.start;P<S.end;P++)g.appendChild(A(w[P],P-S.start))},_=v=>{const x=v.toLowerCase();if(w=n.filter(E=>{const S=E==null?"(Blank)":String(E);return!v||S.toLowerCase().includes(x)}),w.length===0){p.style.height="0px",g.innerHTML="";const E=document.createElement("div");E.className="tbw-filter-no-match",E.textContent="No matching values",g.appendChild(E);return}k()};u.addEventListener("scroll",()=>{w.length>0&&k()},{passive:!0}),_(l.value),e.appendChild(u);let L;l.addEventListener("input",()=>{clearTimeout(L),L=setTimeout(()=>{this.searchText.set(r,l.value),_(l.value)},this.config.debounceMs??150)});const m=document.createElement("div");m.className="tbw-filter-buttons";const C=document.createElement("button");C.className="tbw-filter-apply-btn",C.textContent="Apply",C.addEventListener("click",()=>{const v=[];for(const[x,E]of b)if(!E)if(x==="__null__")v.push(null);else{const S=n.find(P=>String(P)===x);v.push(S!==void 0?S:x)}t.applySetFilter(v)}),m.appendChild(C);const R=document.createElement("button");R.className="tbw-filter-clear-btn",R.textContent="Clear Filter",R.addEventListener("click",()=>{t.clearFilter()}),m.appendChild(R),e.appendChild(m)}applySetFilter(e,t){this.excludedValues.set(e,new Set(t)),t.length===0?this.filters.delete(e):this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}applyTextFilter(e,t,n,i){this.filters.set(e,{field:e,type:"text",operator:t,value:n,valueTo:i}),this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getColumnState(e){const t=this.filters.get(e);if(t)return{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}}applyColumnState(e,t){if(!t.filter){this.filters.delete(e);return}const n={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,n),this.cachedResult=null,this.cacheKey=null}styles=Io}function Do(o){if(!o.length)return[];const e=new Map,t=[],n=(s,l)=>{if(!l.length)return;const a=t[t.length-1];if(a&&a.implicit&&a.firstIndex+a.columns.length===s){a.columns.push(...l);return}t.push({id:"__implicit__"+s,label:void 0,columns:l,firstIndex:s,implicit:!0})};let i=[],r=0;return o.forEach((s,l)=>{const a=s.group;if(!a){i.length===0&&(r=l),i.push(s);return}i.length&&(n(r,i.slice()),i=[]);const c=typeof a=="string"?a:a.id;let d=e.get(c);d||(d={id:c,label:typeof a=="string"?void 0:a.label,columns:[],firstIndex:l},e.set(c,d),t.push(d)),d.columns.push(s)}),i.length&&n(r,i),t.length===1&&t[0].implicit&&t[0].columns.length===o.length?[]:t}function Ho(o,e,t){if(!e.length||!o)return;const n=new Map;for(const r of e)for(const s of r.columns)s?.field&&n.set(s.field,r.id);const i=Array.from(o.querySelectorAll(".cell[data-field]"));i.forEach(r=>{const s=r.getAttribute("data-field")||"",l=n.get(s);l&&(r.classList.add("grouped"),r.getAttribute("data-group")||r.setAttribute("data-group",l))});for(const r of e){const s=r.columns[r.columns.length-1],l=i.find(a=>a.getAttribute("data-field")===s.field);l&&l.classList.add("group-end")}}function Oo(o,e){if(o.length===0)return null;const t=document.createElement("div");t.className="header-group-row",t.setAttribute("role","row");for(const n of o){const i=n.firstIndex!=null?n.firstIndex:e.findIndex(a=>n.columns.includes(a)),r=String(n.id).startsWith("__implicit__"),s=r?"":n.label||n.id,l=document.createElement("div");l.className="cell header-group-cell",r&&l.classList.add("implicit-group"),l.setAttribute("data-group",String(n.id)),l.style.gridColumn=`${i+1} / span ${n.columns.length}`,l.textContent=s,t.appendChild(l)}return t}function zo(o){return o.some(e=>e.group!=null)}const Fo=".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong))}";class qo extends T{name="groupingColumns";version="1.0.0";get defaultConfig(){return{showGroupBorders:!0}}groups=[];isActive=!1;detach(){this.groups=[],this.isActive=!1}static detect(e,t){const n=t?.columns;return Array.isArray(n)?zo(n):!1}processColumns(e){const t=Do(e);return t.length===0?(this.isActive=!1,this.groups=[],[...e]):(this.isActive=!0,this.groups=t,[...e])}afterRender(){if(!this.isActive||this.groups.length===0){const s=this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");s&&s.remove();return}const e=this.shadowRoot?.querySelector(".header");if(!e)return;const t=e.querySelector(".header-group-row");t&&t.remove();const n=Oo(this.groups,this.columns);if(n){const r=e.querySelector(".header-row");r?e.insertBefore(n,r):e.appendChild(n)}const i=e.querySelector(".header-row");i&&Ho(i,this.groups,this.columns)}isGroupingActive(){return this.isActive}getGroups(){return this.groups}getGroupColumns(e){const t=this.groups.find(n=>n.id===e);return t?t.columns:[]}refresh(){this.requestRender()}styles=Fo}function Bo({rows:o,config:e,expanded:t}){const n=e.groupOn;if(typeof n!="function")return[];const i={key:"__root__",value:null,depth:-1,rows:[],children:new Map};if(o.forEach(l=>{let a=n(l);a==null||a===!1?a=["__ungrouped__"]:Array.isArray(a)||(a=[a]);let c=i;a.forEach((d,h)=>{const f=d==null?"∅":String(d),u=c.key==="__root__"?f:c.key+"||"+f;let p=c.children.get(f);p||(p={key:u,value:d,depth:h,rows:[],children:new Map,parent:c},c.children.set(f,p)),c=p}),c.rows.push(l)}),i.children.size===1&&i.children.has("__ungrouped__")&&i.children.get("__ungrouped__").rows.length===o.length)return[];const r=[],s=l=>{if(l===i){l.children.forEach(c=>s(c));return}const a=t.has(l.key);r.push({kind:"group",key:l.key,value:l.value,depth:l.depth,rows:l.rows,expanded:a}),a&&(l.children.size?l.children.forEach(c=>s(c)):l.rows.forEach(c=>r.push({kind:"data",row:c,rowIndex:o.indexOf(c)})))};return s(i),r}function $o(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function Go(o){const e=new Set;for(const t of o)t.kind==="group"&&e.add(t.key);return e}function Ko(){return new Set}function Vo(o){return o.kind!=="group"?0:o.rows.length}const Wo='.group-row{background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-right:4px;font-size:10px}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:2px}.group-label{display:inline-flex;align-items:center;gap:8px}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:.85em;font-weight:400}[data-group-depth="0"] .group-label{padding-left:0}[data-group-depth="1"] .group-label{padding-left:20px}[data-group-depth="2"] .group-label{padding-left:40px}[data-group-depth="3"] .group-label{padding-left:60px}[data-group-depth="4"] .group-label{padding-left:80px}';class jo extends T{name="groupingRows";version="1.0.0";get defaultConfig(){return{defaultExpanded:!1,showRowCount:!0,indentWidth:20,aggregators:{}}}expandedKeys=new Set;flattenedRows=[];isActive=!1;detach(){this.expandedKeys.clear(),this.flattenedRows=[],this.isActive=!1}static detect(e,t){return typeof t?.groupOn=="function"||typeof t?.enableRowGrouping=="boolean"}processRows(e){const t=this.config;if(typeof t.groupOn!="function")return this.isActive=!1,this.flattenedRows=[],[...e];const n=Bo({rows:e,config:t,expanded:this.expandedKeys});return n.length===0?(this.isActive=!1,this.flattenedRows=[],[...e]):(this.isActive=!0,this.flattenedRows=n,n.map(i=>i.kind==="group"?{__isGroupRow:!0,__groupKey:i.key,__groupValue:i.value,__groupDepth:i.depth,__groupRows:i.rows,__groupExpanded:i.expanded,__groupRowCount:Vo(i)}:i.row))}onCellClick(e){const t=e.row;if(t?.__isGroupRow&&e.originalEvent.target?.closest(".group-toggle"))return this.toggle(t.__groupKey),!0}renderRow(e,t,n){if(!e?.__isGroupRow)return!1;const i=this.config;if(i.groupRowRenderer){const l=()=>{this.toggle(e.__groupKey)},a=i.groupRowRenderer({key:e.__groupKey,value:e.__groupValue,depth:e.__groupDepth,rows:e.__groupRows,expanded:e.__groupExpanded,toggleExpand:l});if(a)return t.className="group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),typeof a=="string"?t.innerHTML=a:(t.innerHTML="",t.appendChild(a)),!0}const r=()=>{this.toggle(e.__groupKey)};return t.className="group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),t.setAttribute("role","row"),t.setAttribute("aria-expanded",String(e.__groupExpanded)),t.style.paddingLeft=`${(e.__groupDepth||0)*(i.indentWidth??20)}px`,t.innerHTML="",i.fullWidth!==!1?this.renderFullWidthGroupRow(e,t,r):this.renderPerColumnGroupRow(e,t,r),!0}afterRender(){}renderFullWidthGroupRow(e,t,n){const i=this.config,r=document.createElement("div");r.className="cell group-full",r.style.gridColumn="1 / -1",r.setAttribute("role","gridcell");const s=document.createElement("button");s.type="button",s.className="group-toggle",s.setAttribute("aria-label",e.__groupExpanded?"Collapse group":"Expand group"),this.setIcon(s,this.resolveIcon(e.__groupExpanded?"collapse":"expand")),s.addEventListener("click",c=>{c.stopPropagation(),n()}),r.appendChild(s);const l=document.createElement("span");l.className="group-label";const a=i.formatLabel?i.formatLabel(e.__groupValue,e.__groupDepth||0,e.__groupKey):String(e.__groupValue);if(l.textContent=a,r.appendChild(l),i.showRowCount!==!1){const c=document.createElement("span");c.className="group-count",c.textContent=`(${e.__groupRowCount??e.__groupRows?.length??0})`,r.appendChild(c)}t.appendChild(r)}renderPerColumnGroupRow(e,t,n){const i=this.config,r=i.aggregators??{},s=this.columns,l=e.__groupRows??[],c=this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns||"";c&&(t.style.display="grid",t.style.gridTemplateColumns=c),s.forEach((d,h)=>{const f=document.createElement("div");if(f.className="cell group-cell",f.setAttribute("data-col",String(h)),f.setAttribute("role","gridcell"),h===0){const u=document.createElement("button");u.type="button",u.className="group-toggle",u.setAttribute("aria-label",e.__groupExpanded?"Collapse group":"Expand group"),this.setIcon(u,this.resolveIcon(e.__groupExpanded?"collapse":"expand")),u.addEventListener("click",b=>{b.stopPropagation(),n()}),f.appendChild(u);const p=document.createElement("span"),g=r[d.field];if(g){const b=ue(g,l,d.field,d);p.textContent=b!=null?String(b):String(e.__groupValue)}else{const b=i.formatLabel?i.formatLabel(e.__groupValue,e.__groupDepth||0,e.__groupKey):String(e.__groupValue);p.textContent=b}if(f.appendChild(p),i.showRowCount!==!1){const b=document.createElement("span");b.className="group-count",b.textContent=` (${l.length})`,f.appendChild(b)}}else{const u=r[d.field];if(u){const p=ue(u,l,d.field,d);f.textContent=p!=null?String(p):""}else f.textContent=""}t.appendChild(f)})}expandAll(){this.expandedKeys=Go(this.flattenedRows),this.requestRender()}collapseAll(){this.expandedKeys=Ko(),this.requestRender()}toggle(e){this.expandedKeys=$o(this.expandedKeys,e);const t=this.flattenedRows.find(n=>n.kind==="group"&&n.key===e);this.emit("group-toggle",{key:e,expanded:this.expandedKeys.has(e),value:t?.value,depth:t?.depth??0}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}expand(e){this.expandedKeys.has(e)||(this.expandedKeys=new Set([...this.expandedKeys,e]),this.requestRender())}collapse(e){if(this.expandedKeys.has(e)){const t=new Set(this.expandedKeys);t.delete(e),this.expandedKeys=t,this.requestRender()}}getGroupState(){const e=this.flattenedRows.filter(t=>t.kind==="group");return{isActive:this.isActive,expandedCount:this.expandedKeys.size,totalGroups:e.length,expandedKeys:[...this.expandedKeys]}}getRowCount(){return this.flattenedRows.length}refreshGroups(){this.requestRender()}getExpandedGroups(){return[...this.expandedKeys]}getFlattenedRows(){return this.flattenedRows}isGroupingActive(){return this.isActive}setGroupOn(e){this.config.groupOn=e,this.requestRender()}styles=Wo}function Ce(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function Uo(o,e){const t=new Set(o);return t.add(e),t}function Xo(o,e){const t=new Set(o);return t.delete(e),t}function Yo(o,e){return o.has(e)}function Zo(o,e,t,n){const i=document.createElement("div");i.className="master-detail-row",i.setAttribute("data-detail-for",String(e)),i.setAttribute("role","row");const r=document.createElement("div");r.className="master-detail-cell",r.setAttribute("role","cell"),r.style.gridColumn=`1 / ${n+1}`;const s=t(o,e);return typeof s=="string"?r.innerHTML=s:s instanceof HTMLElement&&r.appendChild(s),i.appendChild(r),i}const Jo=".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;font-size:10px;opacity:.7;-webkit-user-select:none;user-select:none}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border))}.master-detail-cell{padding:16px;overflow:auto}";class Qo extends T{name="masterDetail";version="1.0.0";get defaultConfig(){return{detailHeight:"auto",expandOnRowClick:!1,collapseOnClickOutside:!1,showExpandColumn:!0}}expandedRows=new Set;detailElements=new Map;detach(){this.expandedRows.clear(),this.detailElements.clear()}processColumns(e){if(!this.config.detailRenderer)return[...e];const t=[...e];if(t.length>0){const n={...t[0]},i=n.viewRenderer;if(i?.__masterDetailWrapped)return t;const r=s=>{const{value:l,row:a}=s,c=this.expandedRows.has(a),d=document.createElement("span");d.className="master-detail-cell-wrapper";const h=document.createElement("span");h.className="master-detail-toggle",this.setIcon(h,this.resolveIcon(c?"collapse":"expand")),h.setAttribute("role","button"),h.setAttribute("tabindex","0"),h.setAttribute("aria-expanded",String(c)),h.setAttribute("aria-label",c?"Collapse details":"Expand details"),h.addEventListener("click",u=>{u.stopPropagation();const p=this.rows.indexOf(a);this.expandedRows=Ce(this.expandedRows,a),this.emit("detail-expand",{rowIndex:p,row:a,expanded:this.expandedRows.has(a)}),this.requestRender()}),d.appendChild(h);const f=document.createElement("span");if(i){const u=i(s);u instanceof Node?f.appendChild(u):f.textContent=String(u??l??"")}else f.textContent=String(l??"");return d.appendChild(f),d};r.__masterDetailWrapped=!0,n.viewRenderer=r,t[0]=n}return t}onRowClick(e){if(!(!this.config.expandOnRowClick||!this.config.detailRenderer))return this.expandedRows=Ce(this.expandedRows,e.row),this.emit("detail-expand",{rowIndex:e.rowIndex,row:e.row,expanded:this.expandedRows.has(e.row)}),this.requestRender(),!1}onCellClick(){this.expandedRows.size>0&&queueMicrotask(()=>this.#t())}afterRender(){this.#t()}onScrollRender(){!this.config.detailRenderer||this.expandedRows.size===0||this.#t()}#t(){if(!this.config.detailRenderer)return;const e=this.shadowRoot?.querySelector(".rows");if(!e)return;const t=new Map,n=e.querySelectorAll(".data-grid-row"),i=this.columns.length;for(const s of n){const l=s.querySelector(".cell[data-row]"),a=l?parseInt(l.getAttribute("data-row")??"-1",10):-1;a>=0&&t.set(a,s)}const r=e.querySelectorAll(".master-detail-row");for(const s of r){const l=parseInt(s.getAttribute("data-detail-for")??"-1",10),a=l>=0?this.rows[l]:void 0,c=a&&this.expandedRows.has(a),d=t.has(l);(!c||!d)&&(s.remove(),a&&this.detailElements.delete(a))}for(const[s,l]of t){const a=this.rows[s];if(!a||!this.expandedRows.has(a))continue;const c=this.detailElements.get(a);if(c){c.previousElementSibling!==l&&l.after(c);continue}const d=Zo(a,s,this.config.detailRenderer,i);typeof this.config.detailHeight=="number"&&(d.style.height=`${this.config.detailHeight}px`),l.after(d),this.detailElements.set(a,d)}}getExtraHeight(){let e=0;for(const t of this.expandedRows){const n=this.detailElements.get(t);if(n)e+=n.offsetHeight;else{const i=this.config?.detailHeight;e+=typeof i=="number"?i:150}}return e}getExtraHeightBefore(e){let t=0;for(const n of this.expandedRows){const i=this.rows.indexOf(n);if(i>=0&&i<e){const r=this.detailElements.get(n);if(r)t+=r.offsetHeight;else{const s=this.config?.detailHeight;t+=typeof s=="number"?s:150}}}return t}adjustVirtualStart(e,t,n){if(this.expandedRows.size===0)return e;const i=[];for(const l of this.expandedRows){const a=this.rows.indexOf(l);a>=0&&i.push({index:a,row:l})}i.sort((l,a)=>l.index-a.index);let r=e,s=0;for(const{index:l,row:a}of i){const c=l*n+s,h=this.detailElements.get(a)?.offsetHeight??(typeof this.config?.detailHeight=="number"?this.config.detailHeight:150),f=c+n+h;s+=h,!(l>=e)&&f>t&&l<r&&(r=l)}return r}expand(e){const t=this.rows[e];t&&(this.expandedRows=Uo(this.expandedRows,t),this.requestRender())}collapse(e){const t=this.rows[e];t&&(this.expandedRows=Xo(this.expandedRows,t),this.requestRender())}toggle(e){const t=this.rows[e];t&&(this.expandedRows=Ce(this.expandedRows,t),this.requestRender())}isExpanded(e){const t=this.rows[e];return t?Yo(this.expandedRows,t):!1}expandAll(){for(const e of this.rows)this.expandedRows.add(e);this.requestRender()}collapseAll(){this.expandedRows.clear(),this.requestRender()}getExpandedRows(){const e=[];for(const t of this.expandedRows){const n=this.rows.indexOf(t);n>=0&&e.push(n)}return e}getDetailElement(e){const t=this.rows[e];return t?this.detailElements.get(t):void 0}styles=Jo}function en(o,e,t){return e.length?[...o].sort((n,i)=>{for(const r of e){const l=t.find(h=>h.field===r.field)?.sortComparator??tn,a=n[r.field],c=i[r.field],d=l(a,c,n,i);if(d!==0)return r.direction==="asc"?d:-d}return 0}):[...o]}function tn(o,e){return o==null&&e==null?0:o==null?1:e==null?-1:typeof o=="number"&&typeof e=="number"?o-e:o instanceof Date&&e instanceof Date?o.getTime()-e.getTime():typeof o=="boolean"&&typeof e=="boolean"?o===e?0:o?-1:1:String(o).localeCompare(String(e))}function on(o,e,t,n){const i=o.find(r=>r.field===e);return t?i?i.direction==="asc"?o.map(r=>r.field===e?{...r,direction:"desc"}:r):o.filter(r=>r.field!==e):o.length<n?[...o,{field:e,direction:"asc"}]:o:i?.direction==="asc"?[{field:e,direction:"desc"}]:i?.direction==="desc"?[]:[{field:e,direction:"asc"}]}function ot(o,e){const t=o.findIndex(n=>n.field===e);return t>=0?t+1:void 0}function nt(o,e){return o.find(t=>t.field===e)?.direction}const nn='.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';class rn extends T{name="multiSort";version="1.0.0";get defaultConfig(){return{maxSortColumns:3,showSortIndex:!0}}sortModel=[];detach(){this.sortModel=[]}processRows(e){return this.sortModel.length===0?[...e]:en([...e],this.sortModel,[...this.columns])}onHeaderClick(e){if(!this.columns.find(r=>r.field===e.field)?.sortable)return!1;const n=e.originalEvent.shiftKey,i=this.config.maxSortColumns??3;return this.sortModel=on(this.sortModel,e.field,n,i),this.emit("sort-change",{sortModel:[...this.sortModel]}),this.requestRender(),!0}afterRender(){const e=this.shadowRoot;if(!e)return;const t=this.config.showSortIndex!==!1;e.querySelectorAll(".header-row .cell[data-field]").forEach(i=>{const r=i.getAttribute("data-field");if(!r)return;const s=ot(this.sortModel,r),l=nt(this.sortModel,r);if(i.querySelector(".sort-index")?.remove(),l){i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(),i.setAttribute("data-sort",l);const d=document.createElement("span");if(d.className="sort-indicator",d.style.marginLeft="4px",d.style.opacity="0.8",this.setIcon(d,this.resolveIcon(l==="asc"?"sortAsc":"sortDesc")),i.appendChild(d),t&&this.sortModel.length>1&&s!==void 0){const h=document.createElement("span");h.className="sort-index",h.textContent=String(s),i.appendChild(h)}}else i.removeAttribute("data-sort")})}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e],this.emit("sort-change",{sortModel:[...e]}),this.requestRender()}clearSort(){this.sortModel=[],this.emit("sort-change",{sortModel:[]}),this.requestRender()}getSortIndex(e){return ot(this.sortModel,e)}getSortDirection(e){return nt(this.sortModel,e)}getColumnState(e){const t=this.sortModel.findIndex(i=>i.field===e);return t===-1?void 0:{sort:{direction:this.sortModel[t].direction,priority:t}}}applyColumnState(e,t){if(!t.sort){this.sortModel=this.sortModel.filter(r=>r.field!==e);return}const n=this.sortModel.findIndex(r=>r.field===e),i={field:e,direction:t.sort.direction};n!==-1?this.sortModel[n]=i:this.sortModel.splice(t.sort.priority,0,i)}styles=nn}function sn(o){return o.filter(e=>e.sticky==="left")}function ln(o){return o.filter(e=>e.sticky==="right")}function ye(o){return o.some(e=>e.sticky==="left"||e.sticky==="right")}function it(o,e){const t=o.shadowRoot;if(!t)return;const n=Array.from(t.querySelectorAll(".header-row .cell"));if(!n.length)return;const i=new Map;e.forEach((l,a)=>{l.field&&i.set(l.field,a)});let r=0;for(const l of e)if(l.sticky==="left"){const a=i.get(l.field),c=n.find(d=>d.getAttribute("data-field")===l.field);c&&(c.classList.add("sticky-left"),c.style.left=r+"px",a!==void 0&&t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach(d=>{d.classList.add("sticky-left"),d.style.left=r+"px"}),r+=c.offsetWidth)}let s=0;for(const l of[...e].reverse())if(l.sticky==="right"){const a=i.get(l.field),c=n.find(d=>d.getAttribute("data-field")===l.field);c&&(c.classList.add("sticky-right"),c.style.right=s+"px",a!==void 0&&t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach(d=>{d.classList.add("sticky-right"),d.style.right=s+"px"}),s+=c.offsetWidth)}}function rt(o){const e=o.shadowRoot;if(!e)return;e.querySelectorAll(".sticky-left, .sticky-right").forEach(n=>{n.classList.remove("sticky-left","sticky-right"),n.style.left="",n.style.right=""})}class an extends T{name="pinnedColumns";version="1.0.0";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1}static detect(e,t){const n=t?.columns;return Array.isArray(n)?ye(n):!1}processColumns(e){return this.isApplied=ye([...e]),[...e]}afterRender(){if(!this.isApplied)return;const e=this.grid,t=[...this.columns];if(!ye(t)){rt(e),this.isApplied=!1;return}queueMicrotask(()=>{it(e,t)})}refreshStickyOffsets(){const e=[...this.columns];it(this.grid,e)}getLeftPinnedColumns(){const e=[...this.columns];return sn(e)}getRightPinnedColumns(){const e=[...this.columns];return ln(e)}clearStickyPositions(){rt(this.grid)}}function xe(o,e){const t=document.createElement("div");t.className="tbw-pinned-rows",t.setAttribute("role","presentation"),t.setAttribute("aria-live","polite");const n=document.createElement("div");n.className="tbw-pinned-rows-left";const i=document.createElement("div");i.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",o.showRowCount!==!1){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-row-count",s.textContent=`Total: ${e.totalRows} rows`,n.appendChild(s)}if(o.showFilteredCount&&e.filteredRows!==e.totalRows){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-filtered-count",s.textContent=`Filtered: ${e.filteredRows}`,n.appendChild(s)}if(o.showSelectedCount&&e.selectedRows>0){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-selected-count",s.textContent=`Selected: ${e.selectedRows}`,r.appendChild(s)}if(o.customPanels)for(const s of o.customPanels){const l=cn(s,e);switch(s.position){case"left":n.appendChild(l);break;case"center":i.appendChild(l);break;case"right":r.appendChild(l);break}}return t.appendChild(n),t.appendChild(i),t.appendChild(r),t}function st(o){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${o}`,e.setAttribute("role","presentation"),e}function lt(o,e,t,n){o.innerHTML="";for(const i of e){const r=document.createElement("div");if(r.className="tbw-aggregation-row",r.setAttribute("role","presentation"),i.id&&r.setAttribute("data-aggregation-id",i.id),i.fullWidth){const s=document.createElement("div");s.className="tbw-aggregation-cell tbw-aggregation-cell-full",s.style.gridColumn="1 / -1",s.textContent=i.label||"",r.appendChild(s)}else for(const s of t){const l=document.createElement("div");l.className="tbw-aggregation-cell",l.setAttribute("data-field",s.field);let a;const c=i.aggregators?.[s.field];if(c){const d=Ve(c);d&&(a=d(n,s.field,s))}else if(i.cells&&Object.prototype.hasOwnProperty.call(i.cells,s.field)){const d=i.cells[s.field];typeof d=="function"?a=d(n,s.field,s):a=d}l.textContent=a!=null?String(a):"",r.appendChild(l)}o.appendChild(r)}}function cn(o,e){const t=document.createElement("div");t.className="tbw-status-panel tbw-status-panel-custom",t.id=`status-panel-${o.id}`;const n=o.render(e);return typeof n=="string"?t.innerHTML=n:t.appendChild(n),t}function at(o,e,t,n,i){return{totalRows:o.length,filteredRows:i?.cachedResult?.length??o.length,selectedRows:n?.selected?.size??0,columns:e,rows:o,grid:t}}const dn=".tbw-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";class un extends T{name="pinnedRows";version="1.0.0";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;const n=this.getSelectionState(),i=this.getFilterState(),r=at(this.rows,this.columns,this.grid,n,i),s=this.config.aggregationRows||[],l=s.filter(f=>f.position==="top"),a=s.filter(f=>f.position!=="top");if(l.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=st("top");const f=e.querySelector(".header");f&&f.nextSibling?t.insertBefore(this.topAggregationContainer,f.nextSibling):t.appendChild(this.topAggregationContainer)}lt(this.topAggregationContainer,l,this.visibleColumns,this.rows)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const c=this.config.showRowCount!==!1||this.config.showSelectedCount&&r.selectedRows>0||this.config.showFilteredCount&&r.filteredRows!==r.totalRows||this.config.customPanels&&this.config.customPanels.length>0,d=c&&this.config.position!=="top",h=a.length>0||d;if(c&&this.config.position==="top")if(!this.infoBarElement)this.infoBarElement=xe(this.config,r),t.insertBefore(this.infoBarElement,t.firstChild);else{const f=xe(this.config,r);this.infoBarElement.replaceWith(f),this.infoBarElement=f}else this.config.position==="top"&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);h?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",t.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=st("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),lt(this.bottomAggregationContainer,a,this.visibleColumns,this.rows)),d&&(this.infoBarElement=xe(this.config,r),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&this.config.position!=="top"&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const e=this.getSelectionState(),t=this.getFilterState();return at(this.rows,this.columns,this.grid,e,t)}addPanel(e){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(e),this.requestRender()}removePanel(e){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(t=>t.id!==e),this.requestRender())}addAggregationRow(e){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(e),this.requestRender()}removeAggregationRow(e){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(t=>t.id!==e),this.requestRender())}styles=dn}const hn=de;function fn(o){const e=[];return!o.rowGroupFields?.length&&!o.columnGroupFields?.length&&e.push("At least one row or column group field is required"),o.valueFields?.length||e.push("At least one value field is required"),e}function Ee(o,e){return[...o,e].join("|")}function pn(o,e){const t=e.rowGroupFields??[],n=e.columnGroupFields??[],i=e.valueFields??[],r=gn(o,n),s=ct(o,t,n,r,i,0,""),l=wn(s,r,i),a=Object.values(l).reduce((c,d)=>c+d,0);return{rows:s,columnKeys:r,totals:l,grandTotal:a}}function gn(o,e){if(e.length===0)return["value"];const t=new Set;for(const n of o){const i=e.map(r=>String(n[r]??"")).join("|");t.add(i)}return[...t].sort()}function bn(o,e){const t=new Map;for(const n of o){const i=String(n[e]??""),r=t.get(i);r?r.push(n):t.set(i,[n])}return t}function ct(o,e,t,n,i,r,s){const l=[];if(e.length===0){const f=dt(o,t,n,i),u=ut(f);return l.push({rowKey:s||"all",rowLabel:s||"All",depth:r,values:f,total:u,isGroup:!1,rowCount:o.length}),l}const a=e[0],c=e.slice(1),d=c.length>0,h=bn(o,a);for(const[f,u]of h){const p=s?`${s}|${f}`:f,g=dt(u,t,n,i),b=ut(g);let w;d&&(w=ct(u,c,t,n,i,r+1,p)),l.push({rowKey:p,rowLabel:f||"(blank)",depth:r,values:g,total:b,isGroup:d,children:w,rowCount:u.length})}return l}function dt(o,e,t,n){const i={};for(const r of t)for(const s of n){const a=(e.length>0?o.filter(f=>e.map(u=>String(f[u]??"")).join("|")===r):o).map(f=>Number(f[s.field])||0),c=hn(s.aggFunc),d=a.length>0?c(a):null,h=Ee([r],s.field);i[h]=d}return i}function ut(o){let e=0;for(const t of Object.values(o))e+=t??0;return e}function wn(o,e,t){const n={};function i(r){for(const s of r)if(!s.isGroup||!s.children?.length)for(const l of e)for(const a of t){const c=Ee([l],a.field);n[c]=(n[c]??0)+(s.values[c]??0)}else s.children&&i(s.children)}return i(o),n}function mn(o,e,t=!0){const n=[];function i(r){n.push(r);const s=e?e.has(r.rowKey):t;if(r.children&&s)for(const l of r.children)i(l)}for(const r of o)i(r);return n}function Re(o){const e=[];function t(n){if(n.isGroup&&e.push(n.rowKey),n.children)for(const i of n.children)t(i)}for(const n of o)t(n);return e}const vn=["sum","avg","count","min","max","first","last"];function Cn(o,e,t,n){const i=new AbortController,r={config:e,callbacks:n,signal:i.signal},s=document.createElement("div");return s.className="tbw-pivot-panel",s.appendChild(ee("Options",()=>Sn(t,r))),s.appendChild(ee("Row Groups",()=>ht("rowGroups",r))),s.appendChild(ee("Column Groups",()=>ht("columnGroups",r))),s.appendChild(ee("Values",()=>xn(r))),s.appendChild(ee("Available Fields",()=>Rn(r))),o.appendChild(s),()=>{i.abort(),s.remove()}}function ee(o,e){const t=document.createElement("div");t.className="tbw-pivot-section";const n=document.createElement("div");n.className="tbw-pivot-section-header",n.textContent=o;const i=document.createElement("div");return i.className="tbw-pivot-section-content",i.appendChild(e()),t.appendChild(n),t.appendChild(i),t}function ht(o,e){const{config:t,callbacks:n,signal:i}=e,r=document.createElement("div");r.className="tbw-pivot-drop-zone",r.setAttribute("data-zone",o);const s=o==="rowGroups"?t.rowGroupFields??[]:t.columnGroupFields??[];if(s.length===0){const l=document.createElement("div");l.className="tbw-pivot-placeholder",l.textContent="Drag fields here or click to add",r.appendChild(l)}else for(const l of s)r.appendChild(yn(l,o,e));return r.addEventListener("dragover",l=>{l.preventDefault(),r.classList.add("drag-over")},{signal:i}),r.addEventListener("dragleave",()=>{r.classList.remove("drag-over")},{signal:i}),r.addEventListener("drop",l=>{l.preventDefault(),r.classList.remove("drag-over");const a=l.dataTransfer?.getData("text/plain");a&&n.onAddFieldToZone(a,o)},{signal:i}),r}function yn(o,e,t){const{callbacks:n,signal:i}=t,r=document.createElement("div");r.className="tbw-pivot-field-chip",r.draggable=!0;const s=n.getAvailableFields().find(c=>c.field===o),l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=s?.header??o;const a=document.createElement("button");return a.className="tbw-pivot-chip-remove",a.innerHTML="×",a.title="Remove field",a.addEventListener("click",c=>{c.stopPropagation(),n.onRemoveFieldFromZone(o,e)},{signal:i}),r.appendChild(l),r.appendChild(a),r.addEventListener("dragstart",c=>{c.dataTransfer?.setData("text/plain",o),c.dataTransfer?.setData("source-zone",e),r.classList.add("dragging")},{signal:i}),r.addEventListener("dragend",()=>{r.classList.remove("dragging")},{signal:i}),r}function xn(o){const{config:e,callbacks:t,signal:n}=o,i=document.createElement("div");i.className="tbw-pivot-drop-zone tbw-pivot-values-zone",i.setAttribute("data-zone","values");const r=e.valueFields??[];if(r.length===0){const s=document.createElement("div");s.className="tbw-pivot-placeholder",s.textContent="Drag numeric fields here for aggregation",i.appendChild(s)}else for(const s of r)i.appendChild(En(s,o));return i.addEventListener("dragover",s=>{s.preventDefault(),i.classList.add("drag-over")},{signal:n}),i.addEventListener("dragleave",()=>{i.classList.remove("drag-over")},{signal:n}),i.addEventListener("drop",s=>{s.preventDefault(),i.classList.remove("drag-over");const l=s.dataTransfer?.getData("text/plain");l&&t.onAddValueField(l,"sum")},{signal:n}),i}function En(o,e){const{callbacks:t,signal:n}=e,i=document.createElement("div");i.className="tbw-pivot-field-chip tbw-pivot-value-chip";const r=t.getAvailableFields().find(d=>d.field===o.field),s=document.createElement("div");s.className="tbw-pivot-value-label-wrapper";const l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=r?.header??o.field;const a=document.createElement("select");a.className="tbw-pivot-agg-select",a.title="Aggregation function";for(const d of vn){const h=document.createElement("option");h.value=d,h.textContent=d.toUpperCase(),h.selected=d===o.aggFunc,a.appendChild(h)}a.addEventListener("change",()=>{t.onUpdateValueAggFunc(o.field,a.value)},{signal:n});const c=document.createElement("button");return c.className="tbw-pivot-chip-remove",c.innerHTML="×",c.title="Remove value field",c.addEventListener("click",d=>{d.stopPropagation(),t.onRemoveValueField(o.field)},{signal:n}),s.appendChild(l),s.appendChild(a),i.appendChild(s),i.appendChild(c),i}function Rn(o){const{config:e,callbacks:t,signal:n}=o,i=document.createElement("div");i.className="tbw-pivot-available-fields";const r=t.getAvailableFields(),s=new Set([...e.rowGroupFields??[],...e.columnGroupFields??[],...e.valueFields?.map(a=>a.field)??[]]),l=r.filter(a=>!s.has(a.field));if(l.length===0){const a=document.createElement("div");a.className="tbw-pivot-placeholder",a.textContent="All fields are in use",i.appendChild(a)}else for(const a of l){const c=document.createElement("div");c.className="tbw-pivot-field-chip available",c.textContent=a.header,c.draggable=!0,c.title=`Drag to add "${a.field}" to a zone`,c.addEventListener("dragstart",d=>{d.dataTransfer?.setData("text/plain",a.field),c.classList.add("dragging")},{signal:n}),c.addEventListener("dragend",()=>{c.classList.remove("dragging")},{signal:n}),i.appendChild(c)}return i}function Sn(o,e){const{config:t,callbacks:n,signal:i}=e,r=document.createElement("div");return r.className="tbw-pivot-options",r.appendChild(Se("Enable Pivot View",o,s=>{n.onTogglePivot(s)},i)),r.appendChild(Se("Show Row Totals",t.showTotals??!0,s=>{n.onOptionChange("showTotals",s)},i)),r.appendChild(Se("Show Grand Total",t.showGrandTotal??!0,s=>{n.onOptionChange("showGrandTotal",s)},i)),r}function Se(o,e,t,n){const i=document.createElement("label");i.className="tbw-pivot-checkbox";const r=document.createElement("input");r.type="checkbox",r.checked=e,r.addEventListener("change",()=>t(r.checked),{signal:n});const s=document.createElement("span");return s.textContent=o,i.appendChild(r),i.appendChild(s),i}function An(o,e,t){return e.className="pivot-group-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("role","row"),e.innerHTML="",t.columns.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),r.setAttribute("role","gridcell"),i===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s}px`;const l=String(o.__pivotRowKey),a=document.createElement("button");a.type="button",a.className="pivot-toggle",a.setAttribute("aria-label",o.__pivotExpanded?"Collapse group":"Expand group"),t.setIcon(a,t.resolveIcon(o.__pivotExpanded?"collapse":"expand")),a.addEventListener("click",h=>{h.stopPropagation(),t.onToggle(l)}),r.appendChild(a);const c=document.createElement("span");c.className="pivot-label",c.textContent=String(o.__pivotLabel??""),r.appendChild(c);const d=document.createElement("span");d.className="pivot-count",d.textContent=` (${Number(o.__pivotRowCount)||0})`,r.appendChild(d)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function _n(o,e,t){return e.className="pivot-leaf-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.innerHTML="",t.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),r.setAttribute("role","gridcell"),i===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s+20}px`;const l=document.createElement("span");l.className="pivot-label",l.textContent=String(o.__pivotLabel??""),r.appendChild(l)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function kn(o,e,t){return e.className="pivot-grand-total-row",e.setAttribute("role","presentation"),e.innerHTML="",t.forEach((n,i)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(i)),i===0){const s=document.createElement("span");s.className="pivot-label",s.textContent="Grand Total",r.appendChild(s)}else{const s=o[n.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}const Tn='.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;font-size:10px;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}';class V extends T{name="pivot";version="1.0.0";static PANEL_ID="pivot";get defaultConfig(){return{active:!0,showTotals:!0,showGrandTotal:!0}}isActive=!1;hasInitialized=!1;pivotResult=null;fieldHeaderMap=new Map;expandedKeys=new Set;defaultExpanded=!0;originalColumns=[];panelContainer=null;grandTotalFooter=null;hasValidPivotConfig(){return(this.config.valueFields?.length??0)>0}detach(){this.isActive=!1,this.hasInitialized=!1,this.pivotResult=null,this.fieldHeaderMap.clear(),this.originalColumns=[],this.panelContainer=null,this.cleanupGrandTotalFooter()}getToolPanel(){return{id:V.PANEL_ID,title:"Pivot",icon:"⊞",tooltip:"Configure pivot table",order:90,render:e=>this.renderPanel(e)}}processRows(e){if(!this.hasInitialized&&this.config.active!==!1&&this.hasValidPivotConfig()&&(this.hasInitialized=!0,this.isActive=!0),!this.isActive)return[...e];const t=fn(this.config);if(t.length>0)return this.warn(`Config errors: ${t.join(", ")}`),[...e];if(this.buildFieldHeaderMap(),this.defaultExpanded=this.config.defaultExpanded??!0,this.expandedKeys.size===0&&this.defaultExpanded&&this.pivotResult){const r=Re(this.pivotResult.rows);for(const s of r)this.expandedKeys.add(s)}if(this.pivotResult=pn(e,this.config),this.expandedKeys.size===0&&this.defaultExpanded){const r=Re(this.pivotResult.rows);for(const s of r)this.expandedKeys.add(s)}const n=this.config.indentWidth??20;return mn(this.pivotResult.rows,this.expandedKeys,this.defaultExpanded).map(r=>({__pivotRowKey:r.rowKey,__pivotLabel:r.rowLabel,__pivotDepth:r.depth,__pivotIsGroup:r.isGroup,__pivotHasChildren:!!r.children?.length,__pivotExpanded:this.expandedKeys.has(r.rowKey),__pivotRowCount:r.rowCount??0,__pivotIndent:r.depth*n,__pivotTotal:r.total,...r.values}))}processColumns(e){if(!this.isActive||!this.pivotResult)return[...e];const t=[],n=(this.config.rowGroupFields??[]).map(i=>this.fieldHeaderMap.get(i)??i).join(" / ");t.push({field:"__pivotLabel",header:n||"Group",width:200});for(const i of this.pivotResult.columnKeys)for(const r of this.config.valueFields??[]){const s=Ee([i],r.field),l=r.header||this.fieldHeaderMap.get(r.field)||r.field;t.push({field:s,header:`${i} - ${l} (${r.aggFunc})`,width:120,type:"number"})}return this.config.showTotals&&t.push({field:"__pivotTotal",header:"Total",width:100,type:"number"}),t}renderRow(e,t){const n=e;return n.__pivotRowKey&&n.__pivotHasChildren?An(n,t,{columns:this.gridColumns,onToggle:i=>this.toggle(i),resolveIcon:i=>this.resolveIcon(i),setIcon:(i,r)=>this.setIcon(i,r)}):n.__pivotRowKey!==void 0&&this.isActive?_n(n,t,this.gridColumns):(this.cleanupPivotStyling(t),!1)}cleanupPivotStyling(e){(e.classList.contains("pivot-group-row")||e.classList.contains("pivot-leaf-row")||e.classList.contains("pivot-grand-total-row"))&&(e.classList.remove("pivot-group-row","pivot-leaf-row","pivot-grand-total-row"),e.classList.add("data-grid-row"),e.removeAttribute("data-pivot-depth"),e.innerHTML="")}afterRender(){this.isActive&&this.config.showGrandTotal&&this.pivotResult?this.renderGrandTotalFooter():this.cleanupGrandTotalFooter()}renderGrandTotalFooter(){if(!this.pivotResult)return;const e=this.shadowRoot;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.grandTotalFooter||(this.grandTotalFooter=document.createElement("div"),this.grandTotalFooter.className="pivot-grand-total-footer",t.appendChild(this.grandTotalFooter));const n={__pivotRowKey:"__grandTotal",__pivotLabel:"Grand Total",__pivotIsGrandTotal:!0,__pivotTotal:this.pivotResult.grandTotal,...this.pivotResult.totals};kn(n,this.grandTotalFooter,this.gridColumns)}cleanupGrandTotalFooter(){this.grandTotalFooter&&(this.grandTotalFooter.remove(),this.grandTotalFooter=null)}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e),this.requestRender()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}expandAll(){if(this.pivotResult){const e=Re(this.pivotResult.rows);for(const t of e)this.expandedKeys.add(t);this.requestRender()}}collapseAll(){this.expandedKeys.clear(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}enablePivot(){this.originalColumns.length===0&&this.captureOriginalColumns(),this.isActive=!0,this.requestRender()}disablePivot(){this.isActive=!1,this.pivotResult=null,this.requestRender()}isPivotActive(){return this.isActive}getPivotResult(){return this.pivotResult}setRowGroupFields(e){this.config.rowGroupFields=e,this.requestRender()}setColumnGroupFields(e){this.config.columnGroupFields=e,this.requestRender()}setValueFields(e){this.config.valueFields=e,this.requestRender()}refresh(){this.pivotResult=null,this.requestRender()}showPanel(){this.grid.openToolPanel(V.PANEL_ID)}hidePanel(){this.grid.closeToolPanel()}togglePanel(){this.grid.toggleToolPanel(V.PANEL_ID)}isPanelVisible(){return this.grid.activeToolPanel===V.PANEL_ID}get gridColumns(){return this.grid.columns??[]}buildFieldHeaderMap(){const e=this.getAvailableFields();this.fieldHeaderMap.clear();for(const t of e)this.fieldHeaderMap.set(t.field,t.header)}getAvailableFields(){return this.originalColumns.length>0?this.originalColumns:this.captureOriginalColumns()}captureOriginalColumns(){const e=this.grid;try{const t=e.getAllColumns?.()??e.columns??[];return this.originalColumns=t.filter(n=>!n.field.startsWith("__pivot")).map(n=>({field:n.field,header:n.header??n.field})),this.originalColumns}catch{return[]}}renderPanel(e){this.panelContainer=e,this.originalColumns.length===0&&this.captureOriginalColumns();const t={onTogglePivot:n=>{n?this.enablePivot():this.disablePivot(),this.refreshPanel()},onAddFieldToZone:(n,i)=>this.addFieldToZone(n,i),onRemoveFieldFromZone:(n,i)=>this.removeFieldFromZone(n,i),onAddValueField:(n,i)=>this.addValueField(n,i),onRemoveValueField:n=>this.removeValueField(n),onUpdateValueAggFunc:(n,i)=>this.updateValueAggFunc(n,i),onOptionChange:(n,i)=>{this.config[n]=i,this.isActive&&this.refresh()},getAvailableFields:()=>this.getAvailableFields()};return Cn(e,this.config,this.isActive,t)}refreshPanel(){this.panelContainer&&(this.panelContainer.innerHTML="",this.renderPanel(this.panelContainer))}addFieldToZone(e,t){if(t==="rowGroups"){const n=this.config.rowGroupFields??[];n.includes(e)||(this.config.rowGroupFields=[...n,e])}else{const n=this.config.columnGroupFields??[];n.includes(e)||(this.config.columnGroupFields=[...n,e])}this.removeFromOtherZones(e,t),this.isActive&&this.refresh(),this.refreshPanel()}removeFieldFromZone(e,t){t==="rowGroups"?this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(n=>n!==e):this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(n=>n!==e),this.isActive&&this.refresh(),this.refreshPanel()}removeFromOtherZones(e,t){t!=="rowGroups"&&(this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(n=>n!==e)),t!=="columnGroups"&&(this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(n=>n!==e)),t!=="values"&&(this.config.valueFields=(this.config.valueFields??[]).filter(n=>n.field!==e))}addValueField(e,t){const n=this.config.valueFields??[];n.some(i=>i.field===e)||(this.config.valueFields=[...n,{field:e,aggFunc:t}]),this.removeFromOtherZones(e,"values"),this.isActive&&this.refresh(),this.refreshPanel()}removeValueField(e){this.config.valueFields=(this.config.valueFields??[]).filter(t=>t.field!==e),this.isActive&&this.refresh(),this.refreshPanel()}updateValueAggFunc(e,t){const n=this.config.valueFields??[],i=n.findIndex(r=>r.field===e);i>=0&&(n[i]={...n[i],aggFunc:t},this.config.valueFields=[...n]),this.isActive&&this.refresh()}styles=Tn}function Ln(o){const e=o.sticky;if(e==="left"||e==="right")return!1;const t=o.meta??{},n=t.sticky;return n==="left"||n==="right"?!1:t.lockPosition!==!0&&t.suppressMovable!==!0}function ft(o,e,t){if(e===t||e<0||e>=o.length||t<0||t>o.length)return o;const n=[...o],[i]=n.splice(e,1);return n.splice(t,0,i),n}const Pn='.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';class Mn extends T{name="reorder";version="1.0.0";get defaultConfig(){return{animation:!0,animationDuration:200}}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;attach(e){super.attach(e),e.addEventListener("column-reorder-request",t=>{const n=t.detail;n?.field&&typeof n.toIndex=="number"&&this.moveColumn(n.field,n.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}afterRender(){const e=this.shadowRoot;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(n=>{const i=n,r=i.getAttribute("data-field");if(!r)return;const s=this.columns.find(l=>l.field===r);if(!s||!Ln(s)){i.draggable=!1;return}i.draggable=!0,!i.getAttribute("data-dragstart-bound")&&(i.setAttribute("data-dragstart-bound","true"),i.addEventListener("dragstart",l=>{const c=this.getColumnOrder().indexOf(r);this.isDragging=!0,this.draggedField=r,this.draggedIndex=c,l.dataTransfer&&(l.dataTransfer.effectAllowed="move",l.dataTransfer.setData("text/plain",r)),i.classList.add("dragging")}),i.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,e.querySelectorAll(".header-row > .cell").forEach(l=>{l.classList.remove("dragging","drop-target","drop-before","drop-after")})}),i.addEventListener("dragover",l=>{if(l.preventDefault(),!this.isDragging||this.draggedField===r)return;const a=i.getBoundingClientRect(),c=a.left+a.width/2,h=this.getColumnOrder().indexOf(r);this.dropIndex=l.clientX<c?h:h+1,i.classList.add("drop-target"),i.classList.toggle("drop-before",l.clientX<c),i.classList.toggle("drop-after",l.clientX>=c)}),i.addEventListener("dragleave",()=>{i.classList.remove("drop-target","drop-before","drop-after")}),i.addEventListener("drop",l=>{l.preventDefault();const a=this.draggedField,c=this.draggedIndex,d=this.dropIndex;if(!this.isDragging||a===null||c===null||d===null)return;const h=d>c?d-1:d,f=this.getColumnOrder(),u=ft(f,c,h),p={field:a,fromIndex:c,toIndex:h,columnOrder:u};this.grid.setColumnOrder(u),this.emit("column-move",p),this.grid.requestStateChange?.()}))})}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const n=this.getColumnOrder(),i=n.indexOf(e);if(i===-1)return;const r=ft(n,i,t);this.grid.setColumnOrder(r),this.emit("column-move",{field:e,fromIndex:i,toIndex:t,columnOrder:r}),this.grid.requestStateChange?.()}setColumnOrder(e){this.grid.setColumnOrder(e),this.grid.requestStateChange?.()}resetColumnOrder(){const e=this.columns.map(t=>t.field);this.grid.setColumnOrder(e),this.grid.requestStateChange?.()}styles=Pn}function oe(o){return{startRow:Math.min(o.startRow,o.endRow),startCol:Math.min(o.startCol,o.endCol),endRow:Math.max(o.startRow,o.endRow),endCol:Math.max(o.startCol,o.endCol)}}function In(o){const e=oe(o);return{from:{row:e.startRow,col:e.startCol},to:{row:e.endRow,col:e.endCol}}}function Ae(o){return o.map(In)}function Nn(o,e,t){const n=oe(t);return o>=n.startRow&&o<=n.endRow&&e>=n.startCol&&e<=n.endCol}function pt(o,e,t){return t.some(n=>Nn(o,e,n))}function Dn(o){const e=[],t=oe(o);for(let n=t.startRow;n<=t.endRow;n++)for(let i=t.startCol;i<=t.endCol;i++)e.push({row:n,col:i});return e}function Hn(o){const e=new Map;for(const t of o)for(const n of Dn(t))e.set(`${n.row},${n.col}`,n);return[...e.values()]}function _e(o,e){return{startRow:o.row,startCol:o.col,endRow:e.row,endCol:e.col}}const On=':host .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';function zn(o,e,t){if(o==="cell"&&e.selectedCell)return{mode:o,ranges:[{from:{row:e.selectedCell.row,col:e.selectedCell.col},to:{row:e.selectedCell.row,col:e.selectedCell.col}}]};if(o==="row"&&e.selected.size>0){const n=[...e.selected].map(i=>({from:{row:i,col:0},to:{row:i,col:t-1}}));return{mode:o,ranges:n}}return o==="range"&&e.ranges.length>0?{mode:o,ranges:Ae(e.ranges)}:{mode:o,ranges:[]}}class Fn extends T{name="selection";version="1.0.0";get defaultConfig(){return{mode:"cell"}}selected=new Set;lastSelected=null;anchor=null;ranges=[];activeRange=null;cellAnchor=null;isDragging=!1;selectedCell=null;detach(){this.selected.clear(),this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.isDragging=!1,this.selectedCell=null}onCellClick(e){const{rowIndex:t,colIndex:n,originalEvent:i}=e,{mode:r}=this.config;if(r==="cell")return this.selectedCell={row:t,col:n},this.emit("selection-change",this.#i()),this.requestAfterRender(),!1;if(r==="row")return this.selected.clear(),this.selected.add(t),this.lastSelected=t,this.emit("selection-change",this.#i()),this.requestAfterRender(),!1;if(r==="range"){const s=i.shiftKey,l=i.ctrlKey||i.metaKey;if(s&&this.cellAnchor){const a=_e(this.cellAnchor,{row:t,col:n});l?this.ranges.length>0?this.ranges[this.ranges.length-1]=a:this.ranges.push(a):this.ranges=[a],this.activeRange=a}else if(l){const a={startRow:t,startCol:n,endRow:t,endCol:n};this.ranges.push(a),this.activeRange=a,this.cellAnchor={row:t,col:n}}else{const a={startRow:t,startCol:n,endRow:t,endCol:n};this.ranges=[a],this.activeRange=a,this.cellAnchor={row:t,col:n}}return this.emit("selection-change",this.#i()),this.requestAfterRender(),!1}return!1}onKeyDown(e){const{mode:t}=this.config,i=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(e.key);if(e.key==="Escape")return t==="cell"?this.selectedCell=null:t==="row"?(this.selected.clear(),this.anchor=null):t==="range"&&(this.ranges=[],this.activeRange=null,this.cellAnchor=null),this.emit("selection-change",this.#i()),this.requestAfterRender(),!0;if(t==="cell"&&i)return queueMicrotask(()=>{this.selectedCell={row:this.grid.focusRow,col:this.grid.focusCol},this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1;if(t==="row"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return queueMicrotask(()=>{this.selected.clear(),this.selected.add(this.grid.focusRow),this.lastSelected=this.grid.focusRow,this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1;if(t==="range"&&i){const r=e.shiftKey;return queueMicrotask(()=>{const s=this.grid.focusRow,l=this.grid.focusCol;if(r){this.cellAnchor||(this.cellAnchor={row:s,col:l});const a=_e(this.cellAnchor,{row:s,col:l});this.ranges=[a],this.activeRange=a}else this.ranges=[],this.activeRange=null,this.cellAnchor={row:s,col:l};this.emit("selection-change",this.#i()),this.requestAfterRender()}),!1}if(t==="range"&&e.key==="a"&&(e.ctrlKey||e.metaKey)){const r=this.rows.length,s=this.columns.length;if(r>0&&s>0){const l={startRow:0,startCol:0,endRow:r-1,endCol:s-1};return this.ranges=[l],this.activeRange=l,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}}return!1}onCellMouseDown(e){if(this.config.mode!=="range"||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0||e.originalEvent.shiftKey&&this.cellAnchor)return;this.isDragging=!0;const t=e.rowIndex,n=e.colIndex;this.cellAnchor={row:t,col:n},e.originalEvent.ctrlKey||e.originalEvent.metaKey||(this.ranges=[]);const r={startRow:t,startCol:n,endRow:t,endCol:n};return this.ranges.push(r),this.activeRange=r,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}onCellMouseMove(e){if(this.config.mode!=="range"||!this.isDragging||!this.cellAnchor||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;const t=_e(this.cellAnchor,{row:e.rowIndex,col:e.colIndex});return this.ranges.length>0?this.ranges[this.ranges.length-1]=t:this.ranges.push(t),this.activeRange=t,this.emit("selection-change",this.#i()),this.requestAfterRender(),!0}onCellMouseUp(e){if(this.config.mode==="range"&&this.isDragging)return this.isDragging=!1,!0}#t(){const e=this.shadowRoot;if(!e)return;const{mode:t}=this.config;e.querySelectorAll(".cell").forEach(r=>{r.classList.remove("selected","top","bottom","first","last")});const i=e.querySelectorAll(".data-grid-row");if(i.forEach(r=>{r.classList.remove("selected","row-focus")}),t==="row"&&(e.querySelectorAll(".cell-focus").forEach(r=>r.classList.remove("cell-focus")),i.forEach(r=>{const s=r.querySelector(".cell[data-row]"),l=parseInt(s?.getAttribute("data-row")??"-1",10);l>=0&&this.selected.has(l)&&r.classList.add("selected","row-focus")})),t==="range"&&this.ranges.length>0){const r=this.activeRange?oe(this.activeRange):null;e.querySelectorAll(".cell[data-row][data-col]").forEach(l=>{const a=parseInt(l.getAttribute("data-row")??"-1",10),c=parseInt(l.getAttribute("data-col")??"-1",10);a>=0&&c>=0&&pt(a,c,this.ranges)&&(l.classList.add("selected"),l.classList.remove("cell-focus"),r&&(a===r.startRow&&l.classList.add("top"),a===r.endRow&&l.classList.add("bottom"),c===r.startCol&&l.classList.add("first"),c===r.endCol&&l.classList.add("last")))})}t==="cell"&&this.selectedCell&&e.querySelectorAll(".cell-focus").forEach(r=>r.classList.remove("cell-focus"))}afterRender(){const e=this.shadowRoot;if(!e)return;const t=e.children[0],{mode:n}=this.config;this.grid.setAttribute("data-selection-mode",n),t&&t.classList.toggle("selecting",this.isDragging),this.#t()}onScrollRender(){this.#t()}getSelectedCell(){return this.selectedCell}getSelectedRows(){return[...this.selected]}getRanges(){return Ae(this.ranges)}getSelectedCells(){return Hn(this.ranges)}isCellSelected(e,t){return pt(e,t,this.ranges)}clearSelection(){this.selectedCell=null,this.selected.clear(),this.anchor=null,this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.emit("selection-change",{mode:this.config.mode,ranges:[]}),this.requestAfterRender()}setRanges(e){this.ranges=e.map(t=>({startRow:t.from.row,startCol:t.from.col,endRow:t.to.row,endCol:t.to.col})),this.activeRange=this.ranges.length>0?this.ranges[this.ranges.length-1]:null,this.emit("selection-change",{mode:this.config.mode,ranges:Ae(this.ranges)}),this.requestAfterRender()}#i(){return zn(this.config.mode,{selectedCell:this.selectedCell,selected:this.selected,ranges:this.ranges},this.columns.length)}styles=On}function ne(o,e){return Math.floor(o/e)}function qn(o,e){return{start:o*e,end:(o+1)*e}}function Bn(o,e,t){const n=ne(o,t),i=ne(e-1,t),r=[];for(let s=n;s<=i;s++)r.push(s);return r}async function gt(o,e,t,n){const i=qn(e,t);return o.getRows({startRow:i.start,endRow:i.end,sortModel:n.sortModel,filterModel:n.filterModel})}function $n(o,e,t){const n=ne(o,e),i=t.get(n);if(!i)return;const r=o%e;return i[r]}const Gn=100;class Kn extends T{name="serverSide";version="1.0.0";get defaultConfig(){return{pageSize:100,cacheBlockSize:100,maxConcurrentRequests:2}}dataSource=null;totalRowCount=0;loadedBlocks=new Map;loadingBlocks=new Set;lastRequestId=0;scrollDebounceTimer;detach(){this.dataSource=null,this.totalRowCount=0,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}loadRequiredBlocks(){if(!this.dataSource)return;const e=this.grid,t=this.config.cacheBlockSize??100,n={startRow:e.virtualization.start,endRow:e.virtualization.end},i=Bn(n.startRow,n.endRow,t);for(const r of i)if(!(this.loadedBlocks.has(r)||this.loadingBlocks.has(r))){if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2))break;this.loadingBlocks.add(r),gt(this.dataSource,r,t,{}).then(s=>{this.loadedBlocks.set(r,s.rows),this.totalRowCount=s.totalRowCount,this.loadingBlocks.delete(r),this.requestRender(),this.loadRequiredBlocks()}).catch(()=>{this.loadingBlocks.delete(r)})}}processRows(e){if(!this.dataSource)return[...e];const t=[];for(let n=0;n<this.totalRowCount;n++){const i=$n(n,this.config.cacheBlockSize??100,this.loadedBlocks);t.push(i??{__loading:!0,__index:n})}return t}onScroll(e){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},Gn))}setDataSource(e){this.dataSource=e,this.loadedBlocks.clear(),this.loadingBlocks.clear();const t=this.config.cacheBlockSize??100;gt(e,0,t,{}).then(n=>{this.loadedBlocks.set(0,n.rows),this.totalRowCount=n.totalRowCount,this.requestRender()})}refresh(){this.dataSource&&(this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.requestRender())}purgeCache(){this.loadedBlocks.clear()}getTotalRowCount(){return this.totalRowCount}isRowLoaded(e){const t=this.config.cacheBlockSize??100,n=ne(e,t);return this.loadedBlocks.has(n)}getLoadedBlockCount(){return this.loadedBlocks.size}}function ke(o,e,t){return o.id!==void 0?String(o.id):t?`${t}-${e}`:String(e)}function bt(o,e,t,n=null,i=0){const r=e.childrenField??"children",s=[];for(let l=0;l<o.length;l++){const a=o[l],c=ke(a,l,n),d=a[r],h=Array.isArray(d)&&d.length>0,f=t.has(c);if(s.push({key:c,data:a,depth:i,hasChildren:h,isExpanded:f,parentKey:n}),h&&f){const u=bt(d,e,t,c,i+1);s.push(...u)}}return s}function wt(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function Te(o,e,t=null,n=0){const i=e.childrenField??"children",r=new Set;for(let s=0;s<o.length;s++){const l=o[s],a=ke(l,s,t),c=l[i];if(Array.isArray(c)&&c.length>0){r.add(a);const d=Te(c,e,a,n+1);for(const h of d)r.add(h)}}return r}function Vn(){return new Set}function mt(o,e,t,n=null,i=0){const r=t.childrenField??"children";for(let s=0;s<o.length;s++){const l=o[s],a=ke(l,s,n);if(a===e)return[a];const c=l[r];if(Array.isArray(c)&&c.length>0){const d=mt(c,e,t,a,i+1);if(d)return[a,...d]}}return null}function Wn(o,e,t,n){const i=mt(o,e,t);if(!i)return n;const r=new Set(n);for(let s=0;s<i.length-1;s++)r.add(i[s]);return r}function vt(o,e="children"){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o)if(t&&Array.isArray(t[e])&&t[e].length>0)return!0;return!1}function jn(o){if(!Array.isArray(o)||o.length===0)return null;const e=["children","items","nodes","subRows","nested"];for(const t of o)if(!(!t||typeof t!="object")){for(const n of e)if(Array.isArray(t[n])&&t[n].length>0)return n}return null}const Un=".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";class Xn extends T{name="tree";version="1.0.0";get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0}}expandedKeys=new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=new Map;detach(){this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear()}detect(e){if(!this.config.autoDetect)return!1;const t=this.config.childrenField??jn(e)??"children";return vt(e,t)}processRows(e){const t=this.config.childrenField??"children";if(!vt(e,t))return this.flattenedRows=[],this.rowKeyMap.clear(),[...e];this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=Te(e,this.config),this.initialExpansionDone=!0),this.flattenedRows=bt(e,this.config,this.expandedKeys),this.rowKeyMap.clear();for(const n of this.flattenedRows)this.rowKeyMap.set(n.key,n);return this.flattenedRows.map(n=>({...n.data,__treeKey:n.key,__treeDepth:n.depth,__treeHasChildren:n.hasChildren,__treeExpanded:n.isExpanded}))}processColumns(e){if(this.flattenedRows.length===0)return[...e];const t=this.config.indentWidth??20,n=this.config.showExpandIcons??!0,i=[...e];if(i.length>0){const r={...i[0]},s=r.viewRenderer;if(s?.__treeWrapped)return i;const l=a=>{const{value:c,row:d,column:h}=a,f=d.__treeDepth??0,u=d.__treeHasChildren??!1,p=d.__treeExpanded??!1,g=document.createElement("span");if(g.style.display="flex",g.style.alignItems="center",g.style.paddingLeft=`${f*t}px`,u&&n){const w=document.createElement("span");w.className="tree-toggle",this.setIcon(w,this.resolveIcon(p?"collapse":"expand")),w.style.cursor="pointer",w.style.marginRight="4px",w.style.fontSize="10px",w.setAttribute("data-tree-key",d.__treeKey),g.appendChild(w)}else if(n){const w=document.createElement("span");w.style.width="14px",w.style.display="inline-block",g.appendChild(w)}const b=document.createElement("span");if(s){const w=s(a);w instanceof Node?b.appendChild(w):b.textContent=String(w??c??"")}else b.textContent=String(c??"");return g.appendChild(b),g};l.__treeWrapped=!0,r.viewRenderer=l,i[0]=r}return i}onCellClick(e){const t=e.originalEvent?.target;if(!t?.classList.contains("tree-toggle"))return!1;const n=t.getAttribute("data-tree-key");if(!n)return!1;const i=this.rowKeyMap.get(n);return i?(this.expandedKeys=wt(this.expandedKeys,n),this.emit("tree-expand",{key:n,row:i.data,expanded:this.expandedKeys.has(n),depth:i.depth}),this.requestRender(),!0):!1}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=wt(this.expandedKeys,e),this.requestRender()}expandAll(){this.expandedKeys=Te(this.rows,this.config),this.requestRender()}collapseAll(){this.expandedKeys=Vn(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=Wn(this.rows,e,this.config,this.expandedKeys),this.requestRender()}styles=Un}function Yn(o,e,t){const n=[...o.undoStack,e];for(;n.length>t;)n.shift();return{undoStack:n,redoStack:[]}}function Ct(o){if(o.undoStack.length===0)return{newState:o,action:null};const e=[...o.undoStack],t=e.pop();return t?{newState:{undoStack:e,redoStack:[...o.redoStack,t]},action:t}:{newState:o,action:null}}function yt(o){if(o.redoStack.length===0)return{newState:o,action:null};const e=[...o.redoStack],t=e.pop();return t?{newState:{undoStack:[...o.undoStack,t],redoStack:e},action:t}:{newState:o,action:null}}function Zn(o){return o.undoStack.length>0}function Jn(o){return o.redoStack.length>0}function Qn(){return{undoStack:[],redoStack:[]}}function ei(o,e,t,n){return{type:"cell-edit",rowIndex:o,field:e,oldValue:t,newValue:n,timestamp:Date.now()}}class ti extends T{name="undoRedo";version="1.0.0";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];detach(){this.undoStack=[],this.redoStack=[]}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey,n=(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey);if(t){const i=Ct({undoStack:this.undoStack,redoStack:this.redoStack});if(i.action){const r=this.rows;r[i.action.rowIndex]&&(r[i.action.rowIndex][i.action.field]=i.action.oldValue),this.undoStack=i.newState.undoStack,this.redoStack=i.newState.redoStack,this.emit("undo",{action:i.action,type:"undo"}),this.requestRender()}return!0}if(n){const i=yt({undoStack:this.undoStack,redoStack:this.redoStack});if(i.action){const r=this.rows;r[i.action.rowIndex]&&(r[i.action.rowIndex][i.action.field]=i.action.newValue),this.undoStack=i.newState.undoStack,this.redoStack=i.newState.redoStack,this.emit("redo",{action:i.action,type:"redo"}),this.requestRender()}return!0}return!1}recordEdit(e,t,n,i){const r=ei(e,t,n,i),s=Yn({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=s.undoStack,this.redoStack=s.redoStack}undo(){const e=Ct({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.oldValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}redo(){const e=yt({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.newValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}canUndo(){return Zn({undoStack:this.undoStack,redoStack:this.redoStack})}canRedo(){return Jn({undoStack:this.undoStack,redoStack:this.redoStack})}clearHistory(){const e=Qn();this.undoStack=e.undoStack,this.redoStack=e.redoStack}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}}const oi='.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';function xt(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class W extends T{name="visibility";version="1.0.0";static PANEL_ID="columns";get defaultConfig(){return{allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){return{id:W.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(W.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.toggleToolPanel(W.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(t=>t.visible).map(t=>t.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(t=>!t.visible).map(t=>t.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.grid.setColumnVisible(e,!0)}hideColumn(e){this.grid.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.activeToolPanel===W.PANEL_ID}renderPanelContent(e){const t=this.grid,n=document.createElement("div");n.className="tbw-visibility-content";const i=document.createElement("div");i.className="tbw-visibility-list",n.appendChild(i);const r=document.createElement("button");return r.className="tbw-visibility-show-all",r.textContent="Show All",r.addEventListener("click",()=>{t.showAllColumns(),this.rebuildToggles(i)}),n.appendChild(r),this.columnListElement=i,this.rebuildToggles(i),e.appendChild(n),()=>{this.columnListElement=null,n.remove()}}hasReorderPlugin(){const e=this.grid?.getPluginByName?.("reorder");return!!(e&&typeof e.moveColumn=="function")}rebuildToggles(e){const t=this.grid,n=this.hasReorderPlugin();e.innerHTML="";const i=t.getAllColumns();for(let r=0;r<i.length;r++){const s=i[r],l=s.header||s.field,a=document.createElement("div");a.className=s.lockVisible?"tbw-visibility-row locked":"tbw-visibility-row",a.setAttribute("data-field",s.field),a.setAttribute("data-index",String(r)),n&&xt(s)&&(a.draggable=!0,a.classList.add("reorderable"),this.setupDragListeners(a,s.field,r,e));const c=document.createElement("label");c.className="tbw-visibility-label";const d=document.createElement("input");d.type="checkbox",d.checked=s.visible,d.disabled=s.lockVisible??!1,d.addEventListener("change",()=>{t.toggleColumnVisibility(s.field),setTimeout(()=>this.rebuildToggles(e),0)});const h=document.createElement("span");if(h.textContent=l,c.appendChild(d),c.appendChild(h),n&&xt(s)){const f=document.createElement("span");f.className="tbw-visibility-handle",this.setIcon(f,this.resolveIcon("dragHandle")),f.title="Drag to reorder",a.appendChild(f)}a.appendChild(c),e.appendChild(a)}}setupDragListeners(e,t,n,i){e.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=t,this.draggedIndex=n,r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",t)),e.classList.add("dragging")}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,i.querySelectorAll(".tbw-visibility-row").forEach(r=>{r.classList.remove("dragging","drop-target","drop-before","drop-after")})}),e.addEventListener("dragover",r=>{if(r.preventDefault(),!this.isDragging||this.draggedField===t)return;const s=e.getBoundingClientRect(),l=s.top+s.height/2;this.dropIndex=r.clientY<l?n:n+1,i.querySelectorAll(".tbw-visibility-row").forEach(a=>{a!==e&&a.classList.remove("drop-target","drop-before","drop-after")}),e.classList.add("drop-target"),e.classList.toggle("drop-before",r.clientY<l),e.classList.toggle("drop-after",r.clientY>=l)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",r=>{r.preventDefault();const s=this.draggedField,l=this.draggedIndex,a=this.dropIndex;if(!this.isDragging||s===null||l===null||a===null)return;const c=a>l?a-1:a;if(c!==l){const d={field:s,fromIndex:l,toIndex:c};this.emit("column-reorder-request",d),setTimeout(()=>{this.rebuildToggles(i)},0)}})}styles=oi}y.BaseGridPlugin=T,y.ClipboardPlugin=go,y.ColumnVirtualizationPlugin=vo,y.ContextMenuPlugin=xo,y.DEFAULT_GRID_ICONS=I,y.DGEvents=lo,y.DataGridElement=Z,y.ExportPlugin=_o,y.FilteringPlugin=F,y.FitModeEnum=q,y.GridCSSVars=so,y.GridClasses=M,y.GridDataAttrs=J,y.GridElement=Z,y.GridSelectors=ro,y.GroupingColumnsPlugin=qo,y.GroupingRowsPlugin=jo,y.MasterDetailPlugin=Qo,y.MultiSortPlugin=rn,y.PinnedColumnsPlugin=an,y.PinnedRowsPlugin=un,y.PivotPlugin=V,y.PluginEvents=ao,y.PluginManager=Ge,y.ReorderPlugin=Mn,y.SelectionPlugin=Fn,y.ServerSidePlugin=Kn,y.TreePlugin=Xn,y.UndoRedoPlugin=ti,y.VisibilityPlugin=W,y.aggregatorRegistry=D,y.getAggregator=Ve,y.getValueAggregator=de,y.listAggregators=fo,y.registerAggregator=uo,y.runAggregator=ue,y.runValueAggregator=co,y.unregisterAggregator=ho,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
234
234
|
//# sourceMappingURL=grid.all.umd.js.map
|