@toolbox-web/grid 3.0.0-beta.2 → 3.0.0-beta.3
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.js +2 -2
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/clipboard-payload.d.ts +47 -0
- package/lib/plugins/clipboard/copy.d.ts +9 -2
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +18 -0
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/sticky-rows/index.js +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={STRETCH:"stretch",FIXED:"fixed"},t={AUTO:"auto",MERGE:"merge"},i={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},r={mode:"reduced-motion",duration:200,easing:"ease-out"},n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function o(e,t){if(!e)return;const i="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===i?.a11y?.announcements)return;const r=e.querySelector?.(".tbw-sr-only");r&&(r.textContent="",requestAnimationFrame(()=>{r.textContent=t}))}function s(e,t,...r){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,o=n?.a11y?.messages?.[t];return o?o(...r):i[t](...r)}function a(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e){if("id"===e.toLowerCase())return"ID";return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").split(" ").filter(Boolean).map(a).join(" ")}const c=/* @__PURE__ */new Set(["string","number","boolean","date","datetime","currency"]);function d(e){const t=e.lastIndexOf(":");if(t>0){const i=e.slice(t+1).toLowerCase();if(c.has(i)){const r=e.slice(0,t);return{field:r,header:l(r),type:i}}}return{field:e,header:l(e)}}function u(e){return e.map(e=>"string"==typeof e?d(e):e)}function h(e,t){return t?e.map(e=>({...t,...e})):e}function g(e){return e.some(e=>"string"==typeof e)}function f(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const p="TBW021",m="TBW041",w="TBW061",b="TBW062",v="TBW080",y="TBW090",_="TBW091",C="TBW092",R="TBW093",E="TBW100",S="TBW110",A="TBW112",M="TBW113",x="TBW114",H="TBW140",T="TBW141",k="TBW142",L="TBW143";function P(e,t,i,r){return`${f(i,r)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function D(e,t,i,r){throw new Error(P(e,t,i,r))}function I(e,t,i,r){console.warn(P(e,t,i,r))}function O(e,t,i,r){console.debug(P(e,t,i,r))}function z(e,t,i,r){console.error(P(e,t,i,r))}function N(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const i={},r=t;for(let s=0;s<r.length;s++){const e=r[s],t=i[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate),e.__element&&!t.__element&&(t.__element=e.__element);const i=e.renderer||e.viewRenderer,r=t.renderer||t.viewRenderer;i&&!r&&(t.viewRenderer=i,e.renderer&&(t.renderer=i)),e.editor&&!t.editor&&(t.editor=e.editor),e.headerRenderer&&!t.headerRenderer&&(t.headerRenderer=e.headerRenderer),e.headerLabelRenderer&&!t.headerLabelRenderer&&(t.headerLabelRenderer=e.headerLabelRenderer)}else i[e.field]={...e}}const n=e.map(e=>{const t=i[e.field];if(!t)return e;const r={...e};t.header&&!r.header&&(r.header=t.header),t.type&&!r.type&&(r.type=t.type),r.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(r.resizable=!0),null!=t.width&&null==r.width&&(r.width=t.width),null!=t.minWidth&&null==r.minWidth&&(r.minWidth=t.minWidth),t.__viewTemplate&&(r.__viewTemplate=t.__viewTemplate),t.__headerTemplate&&(r.__headerTemplate=t.__headerTemplate),t.__element&&!r.__element&&(r.__element=t.__element);const n=t.renderer||t.viewRenderer,o=r.renderer||r.viewRenderer;return n&&!o&&(r.viewRenderer=n,t.renderer&&(r.renderer=n)),t.editor&&!r.editor&&(r.editor=t.editor),r.headerRenderer||r.headerLabelRenderer||(t.headerRenderer?r.headerRenderer=t.headerRenderer:t.headerLabelRenderer&&(r.headerLabelRenderer=t.headerLabelRenderer)),delete i[e.field],r}),o=Object.keys(i);for(let s=0;s<o.length;s++)n.push(i[o[s]]);return n}function q(e,t){try{e.part?.add?.(t)}catch{}const i=e.getAttribute("part");i?i.split(/\s+/).includes(t)||e.setAttribute("part",i+" "+t):e.setAttribute("part",t)}function F(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;if(i!==e.STRETCH&&i!==e.FIXED)return;if(t.__didInitialAutoSize)return;if(!t.isConnected)return;const r=Array.from(t._headerRowEl?.children||[]);if(!r.length)return;let n=!1;const o=t._visibleColumns;for(let e=0;e<o.length;e++){const i=o[e];if(i.width)continue;const s=r[e];let a=s?s.scrollWidth:0;for(let r=0;r<t._rowPool.length;r++){const i=t._rowPool[r].children[e];if(i){const e=i.scrollWidth;e>a&&(a=e)}}a>0&&(i.width=a+2,i.__autoSized=!0,n=!0)}n&&B(t),t.__didInitialAutoSize=!0}const W=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function $(e,t){return"number"==typeof e?`${e}px`:(W.test(e)||I("TBW050",`Column '${t??"?"}' has an invalid CSS width value: '${e}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`),e)}function B(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;t._gridTemplate=i===e.STRETCH?t._visibleColumns.map(e=>{if(null!=e.width)return $(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():t._visibleColumns.map(e=>null!=e.width?$(e.width,e.field):"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}const V={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-grid-row",GROUP_ROW:"group-row",DATA_CELL:"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"},U={FIELD:"data-field",GROUP_KEY:"data-group-key"},G={ROOT:`.${V.ROOT}`,HEADER:`.${V.HEADER}`,HEADER_ROW:`.${V.HEADER_ROW}`,HEADER_CELL:`.${V.HEADER_CELL}`,ROWS_VIEWPORT:`.${V.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${V.ROWS_CONTAINER}`,DATA_ROW:`.${V.DATA_ROW}`,DATA_CELL:`.${V.DATA_CELL}`,GROUP_ROW:`.${V.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${V.DATA_CELL}[${U.FIELD}="${e}"]`,SELECTED_ROWS:`.${V.DATA_ROW}.${V.SELECTED}`,EDITING_CELL:`.${V.DATA_CELL}.${V.EDITING}`},j={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"},Y=/{{\s*([^}]+)\s*}}/g,X="__DG_EMPTY__",K=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,Z="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),Q=new RegExp(`__(proto|defineGetter|defineSetter)|${Z.slice(3).join("|")}|this\\b`),J=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),ee=/^on\w+$/i,te=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),ie=/^\s*(javascript|vbscript|data|blob):/i;function re(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],i=e.querySelectorAll("*");for(const r of i){const e=r.tagName.toLowerCase();if(J.has(e)){t.push(r);continue}if("svg"===e||"http://www.w3.org/2000/svg"===r.namespaceURI){if(Array.from(r.attributes).some(e=>ee.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(r);continue}}const i=[];for(const t of r.attributes){const e=t.name.toLowerCase();ee.test(e)?i.push(t.name):(te.has(e)&&ie.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&i.push(t.name)}i.forEach(e=>r.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function ne(e,t){const i=function(e){const t=[];let i=0;for(;i<e.length;){const r=e[i];if(" "!==r){if(r>="0"&&r<="9"||"."===r&&i+1<e.length&&e[i+1]>="0"&&e[i+1]<="9"){const r=i;for(;i<e.length&&(e[i]>="0"&&e[i]<="9"||"."===e[i]);)i++;t.push({type:"num",v:Number(e.slice(r,i))});continue}if("'"===r){let r="";for(i++;i<e.length&&"'"!==e[i];)r+=e[i++];if(i>=e.length)return null;i++,t.push({type:"str",v:r});continue}if(r>="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r||"$"===r){const r=i;for(;i<e.length&&/[\w$.]/.test(e[i]);)i++;t.push({type:"id",v:e.slice(r,i)});continue}if(i+2<e.length){const r=e.slice(i,i+3);if("==="===r||"!=="===r){t.push({type:"op",v:r}),i+=3;continue}}if(i+1<e.length){const r=e.slice(i,i+2);if("=="===r||"!="===r||"<="===r||">="===r||"&&"===r||"||"===r){t.push({type:"op",v:r}),i+=2;continue}}if(!"+-*/%<>!?:(),".includes(r))return null;t.push({type:"op",v:r}),i++}else i++}return t}(e);if(!i)return;const r=i;let n=0;function o(){return r[n]}function s(){return r[n++]}function a(e,t){const i=o();return!!i&&(i.type===e&&(void 0===t||i.v===t))}function l(){const e=function(){let e=c();for(;a("op","||");)s(),e=e||c();return e}();if(a("op","?")){s();const t=l();if(!a("op",":"))return;s();const i=l();return e?t:i}return e}function c(){let e=d();for(;a("op","&&");)s(),e=e&&d();return e}function d(){let e=u();for(;;){const t=o();if(!t||"op"!==t.type)break;if("==="===t.v)s(),e=e===u();else if("!=="===t.v)s(),e=e!==u();else if("=="===t.v)s(),e=e==u();else{if("!="!==t.v)break;s(),e=e!=u()}}return e}function u(){let e=h();for(;;){const t=o();if(!t||"op"!==t.type)break;if("<"===t.v)s(),e=e<h();else if(">"===t.v)s(),e=e>h();else if("<="===t.v)s(),e=e<=h();else{if(">="!==t.v)break;s(),e=e>=h()}}return e}function h(){let e=g();for(;;){const t=o();if(!t||"op"!==t.type)break;if("+"===t.v)s(),e+=g();else{if("-"!==t.v)break;s(),e-=g()}}return e}function g(){let e=f();for(;;){const t=o();if(!t||"op"!==t.type)break;if("*"===t.v)s(),e*=f();else if("/"===t.v)s(),e/=f();else{if("%"!==t.v)break;s(),e%=f()}}return e}function f(){return a("op","!")?(s(),!f()):p()}function p(){const e=o();if(e){if("num"===e.type)return s(),e.v;if("str"===e.type)return s(),e.v;if("id"===e.type)return s(),function(e){if("value"===e)return t.value;if(e.startsWith("row.")){const i=e.slice(4);return t.row?t.row[i]:void 0}if(e.startsWith("typeDefault.")){const i=e.slice(12);return t.typeDefault?t.typeDefault[i]:void 0}return"row"===e?t.row:"typeDefault"===e?t.typeDefault:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=l();return a("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const m=l();return n<r.length?void 0:m}function oe(e,t){if(!e||-1===e.indexOf("{{"))return e;const i=[],r=e.replace(Y,(e,r)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return X;if(se.test(e))return X;if("value"===e)return null==t.value?X:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(4),r=t.row?t.row[i]:void 0;return null==r?X:String(r)}if(e.startsWith("typeDefault.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(12),r=t.typeDefault?t.typeDefault[i]:void 0;return null==r?X:String(r)}if(e.length>80)return X;if(!K.test(e)||Q.test(e))return X;const i=e.match(/\./g);if(i&&i.length>1)return X;try{const i=ne(e,t),r=null==i?"":String(i);return se.test(r)?X:r||X}catch{return X}}(r,t);return i.push({expr:r.trim(),result:n}),n}),n=(o=r)?o.replace(new RegExp(X,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):o;var o;const s=i.length&&i.every(e=>""===e.result||e.result===X);return se.test(e)||s?"":n}const se=/Reflect|Proxy|ownKeys/;function ae(e){if(se.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&se.test(t.textContent||"")&&(t.textContent="");se.test(e.textContent||"")&&(e.textContent="")}}function le(e){if(se.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>oe(e,t);return t.__blocked=!1,t}function ce(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}class de{static dependencies;static manifest;aliases;version="3.0.0-beta.2";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},i={};for(const r of Object.keys(t))i[r]=this;for(const r of e){const e=r.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in t)){t[n]=o,i[n]=r;continue}if(t[n]===o)continue;const e=i[n]?.constructor.name??this.constructor.name,s=r.constructor.name,a=P("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,i={...e.userConfig};for(const r of Object.keys(t))delete t[r];Object.assign(t,i)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(t,10);if(!isNaN(i))return i}return 200}setIcon(e,t,i){e.dataset.icon=ce(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const r=this.#t(t,i);void 0!==r?"string"==typeof r?e.innerHTML=re(r):r instanceof HTMLElement&&(e.innerHTML="",e.appendChild(r.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(i,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const r=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return r?e.insertBefore(i,r):e.appendChild(i),i}warn(e,t){void 0!==t?console.warn(P(e,t,this.gridElement.id,this.name)):console.warn(`${f(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(P(e,t,this.gridElement.id,this.name))}}const ue=/* @__PURE__ */new WeakMap;function he(e,t,i=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:i});const r=e,n=t.field;let o=ue.get(r);if(o){const e=o.get(n);if(void 0!==e)return e.v}else o=/* @__PURE__ */new Map,ue.set(r,o);const s=t.valueAccessor({row:e,column:t,rowIndex:i});return o.set(n,{v:s}),s}function ge(e,t){e&&(t?ue.get(e)?.delete(t):ue.delete(e))}function fe(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function pe(e,t,i){const r=i.find(e=>e.field===t.field),n=r?.sortComparator,{field:o,direction:s}=t,a=[...e];return n?r?.valueAccessor?a.sort((e,t)=>n(he(e,r),he(t,r),e,t)*s):a.sort((e,t)=>n(e[o],t[o],e,t)*s):r?.valueAccessor?we(a,r,s):me(a,o,s),a}function me(e,t,i){e.sort((e,r)=>{const n=be(e,r);if(0!==n)return n;const o=e[t],s=r[t];return null==o&&null==s?0:null==o?-i:null==s||o>s?i:o<s?-i:0})}function we(e,t,i){e.sort((e,r)=>{const n=be(e,r);if(0!==n)return n;const o=he(e,t),s=he(r,t);return null==o&&null==s?0:null==o?-i:null==s||o>s?i:o<s?-i:0})}function be(e,t){const i=!0===e?.__loading;return i===(!0===t?.__loading)?0:i?1:-1}function ve(e,t,i,r){const n=r.find(e=>e.field===t),o=n?.sortComparator;o?n?.valueAccessor?e.sort((e,t)=>o(he(e,n),he(t,n),e,t)*i):e.sort((e,r)=>o(e[t],r[t],e,r)*i):n?.valueAccessor?we(e,n,i):me(e,t,i)}function ye(e,t,i,r){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;Te(e),e.refreshVirtualWindow(!0),_e(e,i,r)}function _e(e,t,i){const r={field:t.field,direction:i};e.dispatchEvent(new CustomEvent("sort-change",{detail:r})),e._pluginManager?.emitPluginEvent?.("sort-change",r),o(e,s(e,0===i?"sortCleared":"sortApplied",t.header??t.field,1===i?"ascending":"descending")),e.requestStateChange?.()}function Ce(e){return e._pluginManager?._hasRowStructurePlugins??!1}function Re(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)Ee(e,t,-1);else{if(e._sortState=null,Ce(e))return e._requestSchedulerPhase(4,"sort-clear"),void _e(e,t,0);e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e._rows=e.__originalOrder.slice(),e.__originalOrder=[],Te(e);const i=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(i)for(let t=0;t<i.length;t++){const r=i[t];r.getAttribute("aria-sort")&&("ascending"!==r.getAttribute("aria-sort")&&"descending"!==r.getAttribute("aria-sort")||e._sortState)||r.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),_e(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),Ee(e,t,1)}function Ee(e,t,i){if(e._sortState={field:t.field,direction:i},Ce(e))return e._requestSchedulerPhase(4,"sort-apply"),void _e(e,t,i);const r={field:t.field,direction:i},n=e._columns,o=e.effectiveConfig?.sortHandler??pe;if(o===pe)return ve(e._rows,r.field,i,n),void ye(e,e._rows,t,i);const s=o(e._rows,r,n);s&&"function"==typeof s.then?s.then(r=>{ye(e,r,t,i)}):ye(e,s,t,i)}function Se(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function Ae(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Me(e,t){const i=document.createElement("span");q(i,"sort-indicator");const r=e._sortState?.field===t.field?e._sortState.direction:0,n=1===r?"sortAsc":-1===r?"sortDesc":"sortNone";i.dataset.icon=ce(n);const o=e.icons?.[n];return void 0!==o&&function(e,t){"string"==typeof t?e.innerHTML=re(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(i,o),i}function xe(e,t,i){const r=document.createElement("div");return r.className="resize-handle",r.setAttribute("aria-hidden","true"),r.addEventListener("mousedown",r=>{r.stopPropagation(),r.preventDefault(),e._resizeController.start(r,t,i)}),r.addEventListener("dblclick",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.resetColumn(t)}),r}function He(e,t,i,r){r.classList.add(V.SORTABLE),r.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;r.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),r.addEventListener("click",i=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(i,t,r)||Re(e,t)}),r.addEventListener("keydown",i=>{if("Enter"===i.key||" "===i.key){if(i.preventDefault(),e._dispatchHeaderClick?.(i,t,r))return;Re(e,t)}})}function Te(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((i,r)=>{const n=document.createElement("div");n.className="cell",q(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(r+1)),n.setAttribute("data-field",i.field),n.setAttribute("data-col",String(r)),i.type&&n.setAttribute("data-type",i.type);const o=i.header??i.field,s=e._sortState?.field===i.field?e._sortState.direction:0,a=1===s?"asc":-1===s?"desc":null;if(i.headerRenderer){const t={column:i,value:o,sortState:a,filterActive:!1,cellEl:n,renderSortIcon:()=>Se(e,i)?Me(e,i):null,renderFilterButton:()=>null},s=i.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const i=document.createElement("span");for(i.innerHTML=re(t);i.firstChild;)e.appendChild(i.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),Se(e,i)&&He(e,i,0,n),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}else if(i.headerLabelRenderer){const t={column:i,value:o},s=i.headerLabelRenderer(t),a=document.createElement("span");null==s?a.textContent=o:"string"==typeof s?a.innerHTML=re(s):s instanceof Node&&a.appendChild(s),n.appendChild(a),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)));else{const t=document.createElement("span");t.textContent=o,n.appendChild(t),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${V.SORTABLE}`).forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function ke(e,t){const i=e[0]||{},r=Object.keys(i).map(e=>{const t=i[e],r=null==(n=t)?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":n instanceof Date||"string"==typeof n&&/\d{4}-\d{2}-\d{2}/.test(n)&&!isNaN(Date.parse(n))?"date":"string";var n;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:r}}),n={};return r.forEach(e=>{n[e.field]=e.type||"string"}),{columns:r,typeMap:n}}const Le={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class Pe{#i;#r=0;#n=0;#o=null;#s=null;#a=null;#l=!1;constructor(e){this.#i=e}requestPhase(e,t){e>this.#r&&(this.#r=e),0===this.#n&&(this.#c(),this.#n=requestAnimationFrame(()=>this.#d()))}whenReady(){return this.#o?this.#o:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){0!==this.#n&&(cancelAnimationFrame(this.#n),this.#n=0),this.#r=0,this.#s&&(this.#s(),this.#s=null,this.#o=null)}get isPending(){return 0!==this.#r}get pendingPhase(){return this.#r}#c(){this.#o||(this.#o=new Promise(e=>{this.#s=e}))}#d(){if(this.#n=0,!this.#i._schedulerIsConnected)return this.#r=0,void(this.#s&&(this.#s(),this.#s=null,this.#o=null));const e=this.#r;this.#r=0,e>=Le.COLUMNS&&this.#i._schedulerMergeConfig(),e>=Le.ROWS&&this.#i._schedulerProcessRows(),e>=Le.COLUMNS&&(this.#i._schedulerProcessColumns(),this.#i._schedulerUpdateTemplate()),e>=Le.HEADER&&this.#i._schedulerRenderHeader(),e>=Le.VIRTUALIZATION&&this.#i.refreshVirtualWindow(!0,!0),e>=Le.STYLE&&this.#i._schedulerAfterRender();const t=!this.#l;t&&(this.#l=!0,this.#a?.()),this.#s&&(this.#s(),this.#s=null,this.#o=null),0!==e&&this.#u(e,t)}#u(e,t){const i=this.#i._virtualization,r=i?.enabled?{start:i.start,end:i.end}:null,n={phase:e,initial:t,rowCount:this.#i._rows?.length??0,visibleRange:r};this.#i._hostElement.dispatchEvent(new CustomEvent("render",{detail:n,bubbles:!0,composed:!0}))}}class De{#h;#g;#f;#p;#m;#w;#b;#v={};#y={};#_=!0;#C=[];#R;#E;#S;#A;#i;constructor(e){this.#i=e}get original(){return this.#v}get effective(){return this.#y}get columns(){return this.#y.columns??[]}set columns(e){this.#y.columns=e}get lightDomColumnsCache(){return this.#m}set lightDomColumnsCache(e){this.#m=e}get originalColumnNodes(){return this.#b}set originalColumnNodes(e){this.#b=e}get initialColumnState(){return this.#A}set initialColumnState(e){this.#A=e}get sourcesChanged(){return this.#_}markSourcesChanged(){this.#_=!0}setGridConfig(e){this.#h!==e&&(this.#h=e,this.#_=!0,this.#m=void 0)}getGridConfig(){return this.#h}setColumns(e){this.#g=e,this.#_=!0}getColumns(){return this.#g}setFitMode(e){this.#f=e,this.#_=!0}getFitMode(){return this.#f}setColumnInference(e){this.#p!==e&&(this.#p=e,this.#_=!0)}getColumnInference(){return this.#p}merge(){const e=(this.#y.columns?.length??0)>0;if(!this.#_&&e)return;const t=this.#M();this.#_=!1,this.#v=t,Object.freeze(this.#v),this.#v.columns&&Object.freeze(this.#v.columns),this.#y=this.#x(this.#v),this.#H()}#x(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#H(){const e=this.#y;if(this.#T(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#i._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width="number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:80)})}this.#i._applyAnimationConfig(e)}#T(){const e=this.#y.typeDefaults;if(!e)return;const t=this.columns;for(const i of t){if(!i.type)continue;const t=e[i.type];t&&(i.renderer||i.viewRenderer||!t.renderer||(i.renderer=t.renderer),!i.format&&t.format&&(i.format=t.format),!i.editor&&t.editor&&(i.editor=t.editor),!i.editorParams&&t.editorParams&&(i.editorParams=t.editorParams))}}#M(){const e=this.#h?{...this.#h}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#m??[]).map(e=>({...e}));let r=N(t,i);this.#g&&this.#g.length&&(r=N(this.#g,i));const n=this.#i.sourceRows;if("merge"===(this.#p??e.columnInference??"auto")&&n.length){r=function(e,t){if(!t.length)return e;const i=/* @__PURE__ */new Map;for(const o of t)i.set(o.field,o);const r=new Set(e.map(e=>e.field)),n=e.map(e=>{const t=i.get(e.field);if(!t)return e;const r={...e};for(const[i,n]of Object.entries(t))void 0!==n&&Object.assign(r,{[i]:n});return r});for(const o of t)r.has(o.field)||n.push(o);return n}(ke(n).columns,r)}else if(0===r.length&&n.length){r=ke(n).columns}if(r.length&&(!function(e){const t=[],i=[];for(const o of e)"number"==typeof o.order&&Number.isFinite(o.order)&&o.order>=0?t.push({col:o,order:Math.floor(o.order)}):i.push(o);if(0===t.length)return e;t.sort((e,t)=>e.order-t.order);const r=[];let n=0;for(const{col:o,order:s}of t){for(;r.length<s&&n<i.length;)r.push(i[n++]);const e=Math.min(s,r.length);r.splice(e,0,o)}for(;n<i.length;)r.push(i[n++]);e.length=0,e.push(...r)}(r),r.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),r.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=le(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=le(e.__editorTemplate.innerHTML))}),e.columns=r),this.#w&&Object.keys(this.#w).length>0){const t={...this.#w},i=e.typeDefaults??{};for(const e of Object.keys(i)){const r=i[e],n=t[e];t[e]=n?{...n,...r}:r}e.typeDefaults=t}return this.#f&&(e.fitMode=this.#f),e.fitMode||(e.fitMode="stretch"),this.#p&&(e.columnInference=this.#p),this.#i._pluginManager?.processConfig?.(e),e.columnState&&!this.#A&&(this.#A=e.columnState),e}collectState(e){const t=this.columns,i=this.#k();return{columns:t.map((t,r)=>{const n={field:t.field,order:r,visible:!t.hidden},o=t;void 0!==o.__renderedWidth?n.width=o.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=i.get(t.field);s&&(n.sort=s);for(const i of e)if(i.getColumnState){const e=i.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const i=this.columns,r=new Map(e.columns.map(e=>[e.field,e])),n=i.map(e=>{const t=r.get(e.field);if(!t)return e;const i={...e};return void 0!==t.width&&(i.width=t.width,i.__renderedWidth=t.width),void 0!==t.visible&&(i.hidden=!t.visible),i});n.sort((e,t)=>(r.get(e.field)?.order??1/0)-(r.get(t.field)?.order??1/0)),this.columns=n;const o=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(o.length>0){const e=o[0];e.sort&&(this.#i._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#i._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#A=void 0,this.#i._sortState=null,this.#y=this.#x(this.#v),this.#H();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#k(){const e=/* @__PURE__ */new Map,t=this.#i._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#E&&clearTimeout(this.#E),this.#E=setTimeout(()=>{this.#E=void 0;const t=this.collectState(e);this.#i._emit("column-state-change",t)},100)}setColumnVisible(e,t){const i=this.columns,r=i.find(t=>t.field===e);if(!r)return!1;if(!t&&r.lockVisible)return!1;if(!t){if(0===i.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!r.hidden!=!t&&(r.hidden=!t,this.#i._emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(e=>!e.hidden).map(e=>e.field)}),this.#i._clearRowPool(),this.#i._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#i._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#i._clearRowPool(),this.#i._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),i=[];for(const r of e){const e=t.get(r);e&&(i.push(e),t.delete(r))}for(const r of t.values())i.push(r);this.columns=i,this.#i._invalidateVisibleColumnsCache(),Te(this.#i),B(this.#i),this.#i._requestSchedulerPhase(Le.COLUMNS,"configManager")}parseLightDomColumns(e){if(this.#m||(this.#b=Array.from(e.querySelectorAll("tbw-grid-column")),this.#m=this.#b.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const i=t.includes(":")?d(t):void 0,r={field:i?.field??t,type:e.getAttribute("type")||i?.type||void 0,header:e.getAttribute("header")||i?.header||void 0,sortable:e.hasAttribute("sortable")&&"false"!==e.getAttribute("sortable"),__element:e},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?r.width=e:r.width=n}const o=e.getAttribute("minWidth")||e.getAttribute("min-width");if(o){const e=parseFloat(o);isNaN(e)||(r.minWidth=e)}const s=e.getAttribute("order");if(s){const e=parseInt(s,10);Number.isFinite(e)&&e>=0&&(r.order=e)}e.hasAttribute("resizable")&&(r.resizable="false"!==e.getAttribute("resizable"));const a=e.getAttribute("options");a&&(r.options=a.split(",").map(e=>{const[t,i]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:i?.trim()||t.trim()}}));const l=e.querySelector("tbw-grid-column-view"),c=e.querySelector("tbw-grid-column-editor"),u=e.querySelector("tbw-grid-column-header");l&&(r.__viewTemplate=l),u&&(r.__headerTemplate=u);const h=globalThis.DataGridElement,g=h?.getAdapters?.()??[],f=l??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(r.viewRenderer=e)}const m=c??e,w=g.find(e=>e.canHandle(m));if(w){const e=w.createEditor(m);e&&(r.editor=e)}const b=g.find(t=>t.canHandle(e)&&(t.createHeaderRenderer||t.createHeaderLabelRenderer));if(b){const t=b.createHeaderRenderer?.(e);t&&(r.headerRenderer=t);const i=b.createHeaderLabelRenderer?.(e);i&&(r.headerLabelRenderer=i)}return r}).filter(e=>!!e)}(e):[]),!this.#w){const t=function(e){const t=globalThis.DataGridElement,i=t?.getAdapters?.()??[];return Array.from(e.children).filter(e=>"tbw-grid-type"===e.tagName.toLowerCase()).map(e=>{const t=e.getAttribute("name")?.trim();if(!t)return null;const r=Array.from(e.children).find(e=>"tbw-grid-column-view"===e.tagName.toLowerCase()),n=r??e,o=i.find(e=>e.canHandle(n)),s=o?.createRenderer(n),a={};for(const i of Array.from(e.attributes)){if(!i.name.startsWith("data-"))continue;const e=i.name.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()).trim();e&&(a[e]=i.value)}return{name:t,params:a,viewTemplate:r,viewRenderer:s}}).filter(e=>null!==e)}(e),i={};for(const e of t){const t={};let r=!1;if(e.viewRenderer)t.renderer=e.viewRenderer,r=!0;else if(e.viewTemplate){const i=le(e.viewTemplate.innerHTML);t.renderer=t=>i({row:t.row,value:t.value,field:t.field,column:t.column,typeDefault:e.params}),r=!0}r&&(i[e.name]=t)}this.#w=i}}clearLightDomCache(){this.#m=void 0,this.#w=void 0}#L=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#L.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#L.delete(e.toLowerCase())}observeLightDOM(e){this.#R&&this.#R.disconnect();const t=/* @__PURE__ */new Set,i=()=>{this.#S=void 0;for(const e of t){const t=this.#L.get(e);t?.()}t.clear()};this.#R=new MutationObserver(e=>{for(const i of e){for(const e of i.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#L.has(i)&&t.add(i)}for(const e of i.removedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#L.has(i)&&t.add(i)}if("attributes"===i.type&&i.target.nodeType===Node.ELEMENT_NODE){const e=i.target.tagName.toLowerCase();this.#L.has(e)&&t.add(e)}}t.size>0&&!this.#S&&(this.#S=setTimeout(i,0))}),this.#R.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order","name","type"]})}onChange(e){this.#C.push(e)}notifyChange(){for(const e of this.#C)e()}dispose(){this.#R?.disconnect(),this.#C=[],this.#E&&clearTimeout(this.#E),this.#S&&(clearTimeout(this.#S),this.#S=void 0)}}function Ie(e,t){const i=document.createElement("div");return e&&(i.className=e),i}const Oe=document.createElement("template");function ze(e){const t=document.createDocumentFragment(),i=Ie(V.ROOT);{const e=Ie("tbw-grid-content");e.appendChild(Oe.content.cloneNode(!0)),i.appendChild(e)}return t.appendChild(i),t}Oe.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';function Ne(e){const t=document.createElement("div");return t.className="tbw-empty-message",t.textContent=e.filteredOut?"No matching rows":"No data to display",t}function qe(e,t,i="rows"){const r=document.createElement("div");return r.className="tbw-empty-overlay",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("data-overlay-target",i),r.appendChild(function(e,t){const i=(t??Ne)(e);if("string"==typeof i){const e=document.createElement("div");return e.className="tbw-empty-message",e.innerHTML=re(i),e}return i}(e,t)),r}function Fe(e){e?.remove()}function We(){if("undefined"!=typeof window&&window.location){const e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e||"::1"===e)return!0}return"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV}function $e(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function Be(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}function Ve(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const i=e.closest(".data-grid-row");if(!i)return-1;const r=i.parentElement;if(!r)return-1;const n=r.querySelectorAll(":scope > .data-grid-row");for(let o=0;o<n.length;o++)if(n[o]===i)return o;return-1}function Ue(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Ge(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}function je(e){return"rtl"===Ge(e)}function Ye(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function Xe(e,t){const i=t.renderer||t.viewRenderer;if(i)return i;if(!t.type)return;const r=e.__frameworkAdapter;if(r?.getTypeDefault){const i=r.getTypeDefault(t.type,e._hostElement);if(i?.renderer)return i.renderer}}function Ke(e,t){if(t.format)return t.format;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(t.type,e._hostElement);if(r?.format)return r.format}}const Ze='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function Qe(e){return(e.__editingCellCount??0)>0}function Je(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${V.EDITING}`).forEach(e=>e.classList.remove(V.EDITING))}const et=document.createElement("template");et.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const tt=document.createElement("template");function it(){return et.content.firstElementChild.cloneNode(!0)}function rt(){return tt.content.firstElementChild.cloneNode(!0)}function nt(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function ot(e,t,i,r){const n=t.children,o=e._visibleColumns,s=o.length,a=n.length,l=s<a?s:a,c=e._focusRow,d=e._focusCol,u=e._hasAfterCellRenderHook?.()??!1;let h=e.__hasSpecialColumns;if(void 0===h){h=!1;const t=e.__frameworkAdapter;for(let i=0;i<s;i++){const r=o[i];if(r.__viewTemplate||r.__compiledView||r.renderer||r.viewRenderer||r.externalView||r.format||r.cellClass||"date"===r.type||"boolean"===r.type||r.type&&t?.getTypeDefault?.(r.type,e._hostElement)?.renderer||r.type&&t?.getTypeDefault?.(r.type,e._hostElement)?.format){h=!0;break}}e.__hasSpecialColumns=h}const g=String(r);if(h){for(let s=0;s<l;s++){if(o[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void st(e,t,i,r)}}for(let s=0;s<l;s++){const a=o[s],l=n[s];l.getAttribute("data-row")!==g&&l.setAttribute("data-row",g);const h=l.classList.contains(V.EDITING);if(!h){const e=c===r&&d===s;e!==l.classList.contains("cell-focus")&&(l.classList.toggle("cell-focus",e),l.setAttribute("aria-selected",String(e)))}const p=a.cellClass;if(p){const t=l.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&l.classList.remove(e[t])}try{const e=p(he(i,a,r),i,a),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let i=0;i<t.length;i++){const r=t[i];r&&"string"==typeof r&&(l.classList.add(r),e+=(e?" ":"")+r)}l.setAttribute("data-dynamic-classes",e)}else l.removeAttribute("data-dynamic-classes")}catch(f){I(w,`cellClass callback error for column '${a.field}': ${f}`,e.id),l.removeAttribute("data-dynamic-classes")}}if(h)continue;const m=Xe(e,a);if(m){const n=he(i,a,r),o=m({row:i,value:n,field:a.field,column:a,grid:e,cellEl:l});"string"==typeof o?(e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(o)):o instanceof Node?o.parentElement!==l&&(e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML="",l.appendChild(o)):null==o&&(e.__frameworkAdapter?.releaseCell?.(l),l.textContent=null==n?"":String(n)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.__compiledView){const n=he(i,a,r),o=a.__compiledView({row:i,value:n,field:a.field,column:a});a.__compiledView.__blocked?l.textContent="":(l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(o),ae(l)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.__viewTemplate){const n=he(i,a,r),o=a.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(o)?l.textContent="":(l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(oe(o,{row:i,value:n})),ae(l)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.externalView)continue;const v=he(i,a,r);let y;l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l);const _=Ke(e,a);if(_){try{const e=_(v,i);y=null==e?"":String(e)}catch(f){I(b,`Format error in column '${a.field}': ${f}`,e.id),y=null==v?"":String(v)}l.textContent=y}else"date"===a.type?(y=Be(v),l.textContent=y):"boolean"===a.type?l.innerHTML=$e(!!v):(y=null==v?"":String(v),l.textContent=y);u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:v,cellElement:l,rowElement:t})}}else for(let p=0;p<l;p++){const s=n[p];if(s.classList.contains(V.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const a=o[p],l=he(i,a,r);s.textContent=null==l?"":String(l),s.getAttribute("data-row")!==g&&s.setAttribute("data-row",g);const h=c===r&&d===p;h!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",h),s.setAttribute("aria-selected",String(h))),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:p,value:l,cellElement:s,rowElement:t})}}function st(e,t,i,r){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const n=e.__frameworkAdapter;if(n?.releaseCell){n.beginBatch?.(e);try{const e=t.children;for(let t=e.length-1;t>=0;t--)n.releaseCell(e[t]);t.innerHTML=""}finally{n.endBatch?.(e)}}else t.innerHTML="";const o=e._visibleColumns,s=o.length,a=e._focusRow,l=e._focusCol,c=e._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let h=0;h<s;h++){const n=o[h],s=it();s.setAttribute("aria-colindex",String(h+1)),s.setAttribute("data-col",String(h)),s.setAttribute("data-row",String(r)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let g=he(i,n,r);const f=Ke(e,n);if(f)try{g=f(g,i)}catch(u){I(b,`Format error in column '${n.field}': ${u}`,e.id)}const p=n.__compiledView,m=n.__viewTemplate,v=Xe(e,n),y=n.externalView;let _=!1;if(v){const t=v({row:i,value:g,field:n.field,column:n,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=re(t),_=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==g?"":String(g))}else if(y){const t=y,r=document.createElement("div");r.setAttribute("data-external-view",""),r.setAttribute("data-field",n.field),s.appendChild(r);const o={row:i,value:g,field:n.field,column:n,grid:e};if(t.mount)try{t.mount({placeholder:r,context:o,spec:t})}catch(u){I("TBW063",`External view mount error for column '${n.field}': ${u}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:r,spec:t,context:o}}))}catch(u){I("TBW064",`External view event dispatch error for column '${n.field}': ${u}`,e.id)}});r.setAttribute("data-mounted","")}else if(p){const e=p({row:i,value:g,field:n.field,column:n}),t=p.__blocked;s.innerHTML=t?"":re(e),_=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(m){const e=m.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=re(oe(e,{row:i,value:g})),_=!0)}else f?s.textContent=null==g?"":String(g):"date"===n.type?s.textContent=Be(g):"boolean"===n.type?s.innerHTML=$e(!!g):s.textContent=null==g?"":String(g);if(_){ae(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof n.editable?n.editable(i):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),a===r&&l===h?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const C=n.cellClass;if(C)try{const e=C(he(i,n,r),i,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(s.classList.add(i),e+=(e?" ":"")+i);s.setAttribute("data-dynamic-classes",e)}}catch(u){I(w,`cellClass callback error for column '${n.field}': ${u}`,e.id)}c&&e._afterCellRender?.({row:i,rowIndex:r,column:n,colIndex:h,value:g,cellElement:s,rowElement:t}),d.appendChild(s)}t.appendChild(d)}function at(e,t,i){if(t.target?.closest(".resize-handle"))return;const r=Ve(i.querySelector(".cell[data-row]"));if(r<0)return;const n=e._rows[r];if(!n)return;if(e._dispatchRowClick?.(t,r,n,i))return;const o=t.target?.closest(".cell[data-col]");if(o){const i=Number(o.getAttribute("data-col"));if(!isNaN(i)){if(e._dispatchCellClick?.(t,r,i,o))return;const n=e._focusRow!==r||e._focusCol!==i;if(e._focusRow=r,e._focusCol=i,o.classList.contains(V.EDITING)){n&&(Ue(e._bodyEl??e),o.classList.add("cell-focus"));const i=t.target,r=o.contains(i)&&i.matches(Ze)?i:o.querySelector(Ze);try{r?.focus({preventScroll:!0})}catch{}return}_t(e)}}}function lt(e,t){return e&&"object"==typeof e?"__rowCacheKey"in e?e.__rowCacheKey:"rowId"in e&&null!=e.rowId?`id:${e.rowId}`:t?`id:${t(e)}`:e:e}function ct(e,t,i){const r=lt(t,i);return"string"==typeof r?e.byKey.get(r):r&&"object"==typeof r?e.byRef.get(r):void 0}function dt(e,t,i){if(t<0||t>=e.length)return;const r=e[t],n=i-r.height;if(0!==n){r.height=i,r.measured=!0;for(let i=t+1;i<e.length;i++)e[i].offset+=n}}function ut(e,t){if(0===e.length)return-1;if(t<=0)return 0;let i=0,r=e.length-1;for(;i<=r;){const n=Math.floor((i+r)/2),o=e[n],s=o.offset+o.height;if(t<o.offset)r=n-1;else{if(!(t>=s))return n;i=n+1}}return Math.max(0,Math.min(i,e.length-1))}function ht(e,t){const{positionCache:i,heightCache:r,rows:n,start:o,end:s,getPluginHeight:a,getRowId:l}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<o||d>=s||d>=n.length)return;const u=n[d],h=a?.(u,d);if(void 0!==h){const e=i[d];return void((!e.measured||Math.abs(e.height-h)>1)&&(dt(i,d,h),c=!0))}const g=e.offsetHeight;if(g>0){const e=i[d];(!e.measured||Math.abs(e.height-g)>1)&&(dt(i,d,g),function(e,t,i,r){const n=lt(t,r);"string"==typeof n?e.byKey.set(n,i):n&&"object"==typeof n&&e.byRef.set(n,i)}(r,u,g,l),c=!0)}});const d=c?function(e){let t=0;for(const i of e)i.measured&&t++;return t}(i):0,u=c?function(e,t){let i=0,r=0;for(const n of e)n.measured&&(i+=n.height,r++);return r>0?i/r:t}(i,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:u}}tt.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const gt=335e5;function ft(e,t,i=gt){return{rawContentHeight:e,spacerHeight:Math.min(e,i),viewportHeight:t,capped:e>i}}function pt(e,t){if(!t.capped)return e;const i=t.spacerHeight-t.viewportHeight,r=t.rawContentHeight-t.viewportHeight;if(i<=0||r<=0)return e;const n=e*r/i;return n<0?0:n>r?r:n}function mt(e,t){if(!t.capped)return e;const i=t.spacerHeight-t.viewportHeight,r=t.rawContentHeight-t.viewportHeight;return i<=0||r<=0?e:e*i/r}function wt(e){const{totalRows:t,viewportHeight:i,scrollTop:r,rowHeight:n,overscan:o,maxSpacerHeight:s=gt}=e,a=Math.ceil(i/n),l=t*n,c=ft(l,i,s),d=pt(r,c);let u=Math.floor(d/n)-o;u<0&&(u=0);let h=u+a+2*o;return h>t&&(h=t),h===t&&u>0&&(u=Math.max(0,h-a-2*o)),{start:u,end:h,offsetY:u*n,totalHeight:c.spacerHeight,rawContentHeight:l}}function bt(e,t){return e<=t}function vt(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function yt(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function _t(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:i,viewportEl:r,scrollMapping:n}=e._virtualization,o=i,s=r?.clientHeight??o?.clientHeight??0;if(o&&s>0){const i=e._focusRow*t,r=n?pt(o.scrollTop,n):o.scrollTop;if(i<r)o.scrollTop=n?mt(i,n):i;else if(i+t>r+s){const e=i-s+t;o.scrollTop=n?mt(e,n):e}}}const i=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;i||e.refreshVirtualWindow(!1),Ue(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const r=e._focusRow,n=e._virtualization.start??0,o=e._virtualization.end??e._rows.length;if(r>=n&&r<o){const o=e._bodyEl.querySelectorAll(".data-grid-row")[r-n];let s=o?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=o?.querySelector(`.cell[data-col="${e._focusCol}"]`)??o?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const r=e.querySelector(".tbw-scroll-area");if(r&&s&&(!i||t?.forceHorizontalScroll))if(t?.forceScrollLeft)r.scrollLeft=0;else if(t?.forceScrollRight)r.scrollLeft=r.scrollWidth-r.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(o??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),i=r.getBoundingClientRect(),n=e.left-i.left+r.scrollLeft,o=n+e.width,a=r.scrollLeft+t.left,l=r.scrollLeft+r.clientWidth-t.right;n<a?r.scrollLeft=n-t.left:o>l&&(r.scrollLeft=o-r.clientWidth+t.right)}}if(i&&s.classList.contains(V.EDITING)){const e=s.querySelector(Ze);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(i&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!i){const t=document.activeElement;t instanceof HTMLElement&&t!==e&&"function"==typeof e.contains&&e.contains(t)&&!t.classList.contains("cell")&&!t.closest(".cell")||t===e||e.focus({preventScroll:!0})}}}}const Ct=/* @__PURE__ */new WeakMap;function Rt(e,t){const i=Ve(t),r=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(i<0||r<0)return;e._focusRow=i,e._focusCol=r,Ue(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid, [data-tbw-grid]");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Et(e,t,i,r){let n=null;const o=i.composedPath?.();if(n=o&&o.length>0?o[0]:i.target,n&&!t.contains(n)){const e=document.elementFromPoint(i.clientX,i.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),a=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let c,d,u,h,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=e._rows[c],f=e._visibleColumns[d],h=f?.field,g=u&&h?u[h]:void 0)),{type:r,row:u,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:h,value:g,column:f,originalEvent:i,cellElement:s??void 0,rowElement:a??void 0,isHeader:!!l,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function St(e,t,i,r){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const i=e._rows.length-1,r=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,o=e._visibleColumns[e._focusCol],s=o?.type,a=t.composedPath?.()??[],l=a.length?a[0]:t.target;if((!l||l===e||l.closest?.(".rows-body"))&&(!yt(l)||"Home"!==t.key&&"End"!==t.key)&&!(yt(l)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===l.tagName&&"number"===l.type||yt(l)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||yt(l)&&("Enter"===t.key||"Escape"===t.key)||n&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&(e._activeEditRows===e._focusRow&&vt(e),e._focusRow-=1,e._focusCol=r):e._focusCol<r?e._focusCol+=1:(vt(e),e._focusRow<i&&(e._focusRow+=1,e._focusCol=0)),void _t(e);case"ArrowDown":n&&vt(e),e._focusRow=Math.min(i,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&vt(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const i=je(e);e._focusCol=i?Math.max(0,e._focusCol-1):Math.min(r,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const i=je(e);e._focusCol=i?Math.min(r,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&vt(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void _t(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&vt(e),e._focusRow=i,e._focusCol=r):e._focusCol=r,t.preventDefault(),void _t(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(i,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const i=e._focusRow,r=e._focusCol,n=e._visibleColumns[r],o=e._rows[i],s=n?.field??"",a=s&&o?o[s]:void 0,l=e.querySelector(`[data-row="${i}"][data-col="${r}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:i,colIndex:r,column:n,field:s,value:a,row:o,cellEl:l,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}_t(e)}}(e,t),{signal:r}),i.addEventListener("mousedown",t=>function(e,t,i){const r=Et(e,t,i,"mousedown");e._dispatchCellMouseDown?.(r)&&Ct.set(e,!0)}(e,i,t),{signal:r}),document.addEventListener("mousemove",t=>function(e,t,i){if(!Ct.get(e))return;const r=Et(e,t,i,"mousemove");e._dispatchCellMouseMove?.(r)}(e,i,t),{signal:r}),document.addEventListener("mouseup",t=>function(e,t,i){if(!Ct.get(e))return;const r=Et(e,t,i,"mouseup");e._dispatchCellMouseUp?.(r),Ct.set(e,!1)}(e,i,t),{signal:r})}let At;function Mt(e){At=e}class xt{#i;#P=/* @__PURE__ */new Set;#D=/* @__PURE__ */new Map;#I=null;#O=null;constructor(e){this.#i=e,this.#z()}focusCell(e,t){const i=this.#i,r=i._rows.length-1;if(r<0)return;let n;if("string"==typeof t){if(n=i._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const o=i._visibleColumns.length-1;o<0||(i._focusRow=Math.max(0,Math.min(e,r)),i._focusCol=Math.max(0,Math.min(n,o)),_t(i))}get focusedCell(){const e=this.#i;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const i=this.#i._virtualization;if(!i.enabled)return;const r=i.container;if(!r)return;const n=this.#i._rows.length;if(0===n)return;const o=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",a=t?.behavior??"instant";let l,c;const d=i.positionCache;i.variableHeights&&d&&d.length>o?(l=d[o].offset,c=d[o].height):(l=o*i.rowHeight,c=i.rowHeight);const u=i.viewportEl?.clientHeight??r.clientHeight??0;if(u<=0)return;const h=r.scrollTop,g=l+c,f=h+u;let p;switch(s){case"start":p=l;break;case"center":p=l-u/2+c/2;break;case"end":p=g-u;break;default:if(l>=h&&g<=f)return;p=l<h?l:g-u}p=Math.max(0,p);const m=mt(p,i.scrollMapping);"smooth"===a?r.scrollTo({top:m,behavior:"smooth"}):r.scrollTop=m}scrollToRowById(e,t){const i=this.#i._getRowEntry(e);i&&this.scrollToRow(i.index,t)}registerExternalFocusContainer(e){if(this.#P.has(e))return;this.#P.add(e);const t=new AbortController,i=t.signal,r=this.#i;e.addEventListener("focusin",e=>{r.dataset.hasFocus="",this.#N(e.target)},{signal:i}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete r.dataset.hasFocus,null===t&&this.#q()},{signal:i}),this.#D.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#P.delete(e);const t=this.#D.get(e);t&&(t(),this.#D.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#i.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#P)if(t.contains(e))return!0;return!1}#z(){const e=this.#i,t=new AbortController,i=t.signal;e.addEventListener("focusin",e=>this.#N(e.target),{signal:i,capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#q()},{signal:i}),this.#O=()=>t.abort()}#N(e){if(!(e instanceof HTMLElement))return;if(e===this.#i)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#I=e)}#q(){queueMicrotask(()=>{if(!this.#i.isConnected)return;document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#I;if(!e)return!1;if(!e.isConnected)return this.#I=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#I?.isConnected?this.#I:null}destroy(){for(const e of this.#D.values())e();this.#D.clear(),this.#P.clear(),this.#O?.(),this.#O=null,this.#I=null}}const Ht="function"==typeof requestIdleCallback;function Tt(e){Ht?cancelIdleCallback(e):clearTimeout(e)}function kt(e,t){if(t){const i=t({size:e});if("string"==typeof i){const e=document.createElement("div");return e.innerHTML=i,e}return i}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Lt(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="tbw-row-loading-spinner",t.appendChild(i),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}function Pt(e){let t=null,i=null,r=null,n=null;const o=r=>{if(!t)return;const n=r.clientX-t.startX,o=e._visibleColumns[t.colIndex],s="number"==typeof o?.minWidth&&Number.isFinite(o.minWidth)&&o.minWidth>0?o.minWidth:40,a=Math.max(s,t.startWidth+n);o.width=a,o.__userResized=!0,o.__renderedWidth=a,null==i&&(i=requestAnimationFrame(()=>{i=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:o.field,width:a}}))};let s=!1;const a=()=>{const i=null!==t;i&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),null!==r&&(document.documentElement.style.cursor=r,r=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,i&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(i,s,l){i.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,i){const r=i.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const i=e._visibleColumns[n];if(null==i.width&&!i.__userResized){const e=r[n],t=e?.getBoundingClientRect().width;t&&(i.width=Math.round(t),i.__userResized=!0,i.__renderedWidth=i.width)}}}(s,c);const d=e._visibleColumns[s],u="number"==typeof d?.width?d.width:void 0,h=d?.__renderedWidth??u??l.getBoundingClientRect().width;t={startX:i.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),null===r&&(r=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===n&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const i=e._visibleColumns[t];i&&(i.__userResized=!1,i.__renderedWidth=void 0,i.width=i.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:i.field,width:i.width}})))},dispose(){a()}}}const Dt="data-animating",It={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ot={change:500,insert:300,remove:200};function zt(e,t){const i=It[t],r=getComputedStyle(e).getPropertyValue(i);if(r){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(r);if(!isNaN(e)&&e>0)return e}return Ot[t]}function Nt(e,t,i){if(t<0)return Promise.resolve(!1);const r=e.findRenderedRowElement?.(t);return r?new Promise(e=>{!function(e,t,i){e.removeAttribute(Dt),e.offsetWidth,e.setAttribute(Dt,t);const r=zt(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Dt),i?.()},r)}(r,i,()=>e(!0))}):Promise.resolve(!1)}function qt(e,t){if(t)return t(e);const i=e;return"id"in i&&null!=i.id?String(i.id):"_id"in i&&null!=i._id?String(i._id):void 0}function Ft(e,t,i){const r=qt(e,i);return void 0===r&&D("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),r}class Wt{#i;constructor(e){this.#i=e}resolveRowId(e){return Ft(e,this.#i.id,this.#i.effectiveConfig?.getRowId)}getRow(e){return this.#i._getRowEntry(e)?.row}getRowEntry(e){return this.#i._getRowEntry(e)}#F(e,t,i,r,n){const o=this.#i,s=[];for(const[a,l]of Object.entries(r)){if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=t[a];if(c===l)continue;const d=o.query?.("commitCellValue",{rowIndex:i,rowId:e,field:a,oldValue:c,newValue:l,source:n});d?.includes(!1)||(d?.includes(!0)||(t[a]=l,ge(t,a)),s.push({field:a,oldValue:c,newValue:l}),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:e,rowIndex:i,field:a,oldValue:c,newValue:l,changes:r,source:n},bubbles:!0,composed:!0})))}return s}updateRow(e,t,i="api"){const r=this.#i,n=r._getRowEntry(e);n||D(m,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,r.id);const{row:o,index:s}=n;this.#F(e,o,s,t,i).length>0&&(nt(r),r._requestSchedulerPhase(Le.VIRTUALIZATION,"updateRow"),r._emitDataChange())}updateRows(e,t="api"){const i=this.#i;let r=!1;for(const{id:n,changes:o}of e){const e=i._getRowEntry(n);e||D(m,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:s,index:a}=e;this.#F(n,s,a,o,t).length>0&&(r=!0)}r&&(nt(i),i._requestSchedulerPhase(Le.VIRTUALIZATION,"updateRows"),i._emitDataChange())}async insertRow(e,t,i=!0){const r=this.#i,n=Math.max(0,Math.min(e,r._rows.length));r.sourceRows=[...r.sourceRows,t];const o=[...r._rows];o.splice(n,0,t),r._rows=o,r._sortState&&(r.__originalOrder=[...r.__originalOrder,t]),nt(r),r._rebuildRowIdMap(),r.__rowRenderEpoch++;for(let s=0;s<r._rowPool.length;s++)r._rowPool[s].__epoch=-1;r.refreshVirtualWindow(!0),r._emitPluginEvent("row-inserted",{row:t,index:n}),r._emitDataChange(),i&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Nt(r,n,"insert"))}async removeRow(e,t=!0){const i=this.#i,r=i._rows[e];if(!r)return;t&&await Nt(i,e,"remove");const n=i._rows.indexOf(r);if(n<0)return r;const o=[...i._rows];o.splice(n,1),i._rows=o;const s=i.sourceRows.indexOf(r);if(s>=0){const e=[...i.sourceRows];e.splice(s,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(r);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}nt(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let a=0;a<i._rowPool.length;a++)i._rowPool[a].__epoch=-1;return i.refreshVirtualWindow(!0),i._emitDataChange(),t&&requestAnimationFrame(()=>{const e=i.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),r}async applyTransaction(e,t=!0){const i=this.#i,r={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:a}of e.remove){const e=i._getRowEntry(a);if(!e)continue;const{row:n}=e;if(t){const e=i._rows.indexOf(n);e>=0&&await Nt(i,e,"remove")}const o=i._rows.indexOf(n);if(o<0){r.removed.push(n);continue}const s=[...i._rows];s.splice(o,1),i._rows=s;const l=i.sourceRows.indexOf(n);if(l>=0){const e=[...i.sourceRows];e.splice(l,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(n);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}r.removed.push(n)}const n=new Set(e.remove?.map(e=>e.id));if(e.update?.length)for(const{id:a,changes:l}of e.update){if(n.has(a))continue;const e=i._getRowEntry(a);if(!e)continue;const{row:t,index:o}=e;let s=!1;for(const[r,n]of Object.entries(l)){const e=t[r];e!==n&&(s=!0,t[r]=n,ge(t,r),i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:a,rowIndex:o,field:r,oldValue:e,newValue:n,changes:l,source:"api"},bubbles:!0,composed:!0})))}s&&r.updated.push(t)}if(e.add?.length)for(const a of e.add){i.sourceRows=[...i.sourceRows,a];const e=[...i._rows];e.push(a),i._rows=e,i._sortState&&(i.__originalOrder=[...i.__originalOrder,a]),r.added.push(a)}const o=r.added.length>0||r.removed.length>0,s=r.updated.length>0;if(o){nt(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let e=0;e<i._rowPool.length;e++)i._rowPool[e].__epoch=-1;i.refreshVirtualWindow(!0)}else s&&(nt(i),i._requestSchedulerPhase(Le.VIRTUALIZATION,"applyTransaction"));if((o||s)&&i._emitDataChange(),t&&r.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of r.added){const t=i._rows.indexOf(e);t>=0&&await Nt(i,t,"insert")}}if(t&&r.updated.length>0)for(const a of r.updated){const e=i._rows.indexOf(a);e>=0&&await Nt(i,e,"change")}return t&&r.removed.length>0&&requestAnimationFrame(()=>{const e=i.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),r}#W=null;#$=[];#B=null;applyTransactionAsync(e){return this.#W||(this.#W={add:[],update:[],remove:[]}),e.add&&this.#W.add.push(...e.add),e.update&&this.#W.update.push(...e.update),e.remove&&this.#W.remove.push(...e.remove),new Promise(e=>{this.#$.push(e),null===this.#B&&(this.#B=requestAnimationFrame(()=>{this.#B=null;const e=this.#W,t=this.#$;this.#W=null,this.#$=[],this.applyTransaction(e,!1).then(e=>{for(const i of t)i(e)})}))})}}const $t="tbw-grid-styles";let Bt="";const Vt=/* @__PURE__ */new Map;function Ut(){const e=function(){const e=si.activeTag;return e===si.tagName?$t:`${$t}-${e}`}();let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function Gt(e){const t=si.activeTag;return t===si.tagName?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function jt(){const e=Ut(),t=Array.from(Vt.values()).join("\n");e.textContent=`${Bt}\n\n/* Plugin Styles */\n${t}`}async function Yt(e){if(Bt)return;if("string"==typeof e&&e.length>0)return Bt=Gt(e),void jt();await new Promise(e=>setTimeout(e,50));const t=function(){try{for(const e of Array.from(document.styleSheets))try{const t=Array.from(e.cssRules||[]).map(e=>e.cssText).join("\n");if(t.includes(".tbw-grid-root")&&t.includes("tbw-grid"))return t}catch{continue}}catch(e){I("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(Bt=Gt(t),jt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||I("TBW121",`Could not find grid.css in document.styleSheets. Grid styling will not work. Available stylesheets: ${Array.from(document.styleSheets).map(e=>e.href||"(inline)").join(", ")}`)}function Xt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function Kt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Zt(e,t){if(null!==e.lastTime){performance.now()-e.lastTime>60&&(e.velocityY=0,e.velocityX=0)}(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const i=.95,r=1;let n=performance.now();const o=()=>{const s=performance.now(),a=s-n;n=s;const l=a/16,c=Math.pow(i,l);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,u=16*e.velocityX,h=Math.abs(d)>=r,g=Math.abs(u)>=r;h&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=u),e.momentumRaf=h||g?requestAnimationFrame(o):0};e.momentumRaf=requestAnimationFrame(o)}(e,t),Xt(e)}function Qt(e,t,i,r){e.addEventListener("pointerdown",i=>{"touch"===i.pointerType&&null===t.activePointerId&&(t.activePointerId=i.pointerId,e.setPointerCapture(i.pointerId),function(e,t,i){Kt(i),i.startY=t,i.startX=e,i.lastY=t,i.lastX=e,i.lastTime=performance.now(),i.velocityY=0,i.velocityX=0,i.locked=!1}(i.clientX,i.clientY,t))},{passive:!0,signal:r}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const r=function(e,t,i,r){if(null===i.lastY||null===i.lastX)return!1;const n=performance.now(),o=i.lastY-t,s=i.lastX-e;if(null!==i.lastTime){const e=n-i.lastTime;e>0&&(i.velocityY=o/e,i.velocityX=s/e)}if(i.lastY=t,i.lastX=e,i.lastTime=n,i.locked){const{scrollTop:e,scrollHeight:t,clientHeight:i}=r.fauxScrollbar;if(o>0&&e<t-i||o<0&&e>0?r.fauxScrollbar.scrollTop+=o:0!==o&&window.scrollBy(0,o),r.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:i}=r.scrollArea;s>0&&e<t-i||s<0&&e>0?r.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const a=null!==i.startY?Math.abs(i.startY-t):0,l=null!==i.startX?Math.abs(i.startX-e):0;if(a<3&&l<3)return!1;const c=a>=l,{scrollHeight:d,clientHeight:u}=r.fauxScrollbar,h=d-u>0;let g=!1;if(r.scrollArea){const{scrollWidth:e,clientWidth:t}=r.scrollArea;g=e-t>0}return!!(c&&h||!c&&g)&&(i.locked=!0,r.fauxScrollbar.scrollTop+=o,r.scrollArea&&(r.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,i);r&&e.preventDefault()},{passive:!1,signal:r}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Zt(t,i))},{passive:!0,signal:r}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Xt(t))},{passive:!0,signal:r}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Xt(t))},{passive:!0,signal:r})}const Jt=[{property:"editable",pluginName:"editing",level:"column",description:"",isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:""},{property:"editorParams",pluginName:"editing",level:"column",description:""},{property:"group",pluginName:"groupingColumns",level:"column",description:""},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:"",isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],ei=[{property:"rowEditable",pluginName:"editing",level:"config",description:"",isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:"",isUsed:e=>Array.isArray(e)&&e.length>0}];function ti(e){return`import { ${ii(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function ii(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ri(e,t){return e.some(e=>e.name===t)}class ni{#i;state;constructor(e,t){this.#i=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:/* @__PURE__ */new Map,byRef:/* @__PURE__ */new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,scrollMapping:{rawContentHeight:0,spacerHeight:0,viewportHeight:0,capped:!1},...t}}updateCachedGeometry(){const e=this.state,t=e.container,i=e.viewportEl??t;i&&(e.cachedViewportHeight=i.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const r=e.scrollAreaEl;r&&(e.cachedScrollAreaHeight=r.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const i=this.state;let r,n,o;if(t){const e=i.container??this.#i._hostElement,t=i.viewportEl??e,s=i.scrollAreaEl;r=e?.clientHeight??0,n=t?.clientHeight??0,o=s?s.clientHeight:r,i.cachedFauxHeight=r,i.cachedViewportHeight=n,i.cachedScrollAreaHeight=o}else r=i.cachedFauxHeight,n=i.cachedViewportHeight,o=i.cachedScrollAreaHeight||r;const s=o-n,a=Math.max(0,r-o);let l;return l=i.variableHeights&&i.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(i.positionCache):e*i.rowHeight,i.scrollMapping=ft(l,n),i.scrollMapping.spacerHeight+s+a}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#i,i=t._rows,r=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,o=t.effectiveConfig?.getRowId,s=o?e=>o(e):void 0;e.positionCache=function(e,t,i,r,n){const o=new Array(e.length);let s=0;for(let a=0;a<e.length;a++){const l=e[a];let c=n?.(l,a),d=void 0!==c;void 0===c&&(c=ct(t,l,r.rowId),d=void 0!==c),void 0===c&&(c=i,d=!1),o[a]={offset:s,height:c,measured:d},s+=c}return o}(i,e.heightCache,r,{rowId:s},(e,i)=>{const r=t._getPluginRowHeight(e,i);if(void 0!==r)return r;if(n){const t=n(e,i);if(void 0!==t&&t>0)return t}});const a=function(e,t,i,r){let n=0,o=0;for(let s=0;s<e.length;s++){const i=e[s];if(i.measured){const e=r?.(t[s],s);void 0===e&&(o+=i.height,n++)}}return{measuredCount:n,averageHeight:n>0?o/n:i}}(e.positionCache,i,r,(e,i)=>t._getPluginRowHeight(e,i));e.measuredCount=a.measuredCount,a.measuredCount>0&&(e.averageHeight=a.averageHeight)}invalidateRowHeight(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const r=this.#i._rows;if(e<0||e>=r.length)return;const n=r[e];let o=t;void 0===o&&(o=this.#i._getPluginRowHeight(n,e)),void 0===o&&(o=i.rowHeight);const s=i.positionCache[e];if(s&&!(Math.abs(s.height-o)<1)&&(dt(i.positionCache,e,o),i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(r.length);i.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const r=this.#i,n=r._bodyEl;if(!n)return;const o=n.querySelectorAll(".data-grid-row"),s=r.effectiveConfig?.getRowId,a=r._rows,l=ht({positionCache:i.positionCache,heightCache:i.heightCache,rows:a,defaultHeight:i.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>r._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},o);if(l.hasChanges&&(i.measuredCount=l.measuredCount,i.averageHeight=l.averageHeight,i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(a.length);i.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const i=this.state,r=this.#i,n=r._bodyEl;if(!n)return!1;const o=r._rows.length;if(!i.enabled)return r._renderVisibleRows(0,o),t||r._afterPluginRender(),!0;if(o<=i.bypassThreshold)return i.start=0,i.end=o,e&&(n.style.transform="translateY(0px)"),r._renderVisibleRows(0,o,r.__rowRenderEpoch),e&&i.variableHeights&&this.initializePositionCache(),e&&i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(o,!0)}px`),r._updateAriaCounts(o,r._visibleColumns.length),t||r._afterPluginRender(),!0;const s=i.container,a=i.viewportEl??s,l=e?i.cachedViewportHeight=a.clientHeight:i.cachedViewportHeight||(i.cachedViewportHeight=a.clientHeight),c=i.rowHeight,d=pt(s.scrollTop,i.scrollMapping);let u;e&&i.variableHeights&&this.initializePositionCache();const h=i.positionCache;i.variableHeights&&h&&h.length>0?(u=ut(h,d),-1===u&&(u=0)):u=Math.floor(d/c),u-=u%2,u<0&&(u=0),o>0&&u>o-1&&(u=o-1);const g=r._adjustPluginVirtualStart(u,d,c);let f;if(void 0!==g&&g<u&&(u=g,u-=u%2,u<0&&(u=0)),i.variableHeights&&h&&h.length>0){const e=l+3*c;let t=0;for(f=u;f<o&&t<e;)t+=h[f].height,f++;const i=Math.ceil(l/c)+3;f-u<i&&(f=Math.min(u+i,o))}else{f=u+(Math.ceil(l/c)+3)}f>o&&(f=o);const p=i.start,m=i.end;if(!e&&u===p&&f===m)return!1;i.start=u,i.end=f;const w=e?i.cachedFauxHeight=s.clientHeight:i.cachedFauxHeight||(i.cachedFauxHeight=s.clientHeight);if(e){const e=i.scrollAreaEl;e&&(i.cachedScrollAreaHeight=e.clientHeight)}if(0===w&&l>0)return r._requestSchedulerPhase(Le.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&i.totalHeightEl){const e=this.calculateTotalSpacerHeight(o);i.totalHeightEl.style.height=`${e}px`}let b;b=i.variableHeights&&h&&h[u]?h[u].offset:u*c;const v=-(d-b);return n.style.transform=`translateY(${v}px)`,r._renderVisibleRows(u,f,r.__rowRenderEpoch),e&&i.variableHeights&&this.measureRenderedRowHeights(u,f),r._updateAriaCounts(o,r._visibleColumns.length),e&&!t&&(r._afterPluginRender(),queueMicrotask(()=>{if(!i.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(o);0===i.cachedFauxHeight&&i.cachedViewportHeight>0||(i.totalHeightEl.style.height=`${e}px`)})),!0}}class oi{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=/* @__PURE__ */new Map;cellRenderers=/* @__PURE__ */new Map;headerRenderers=/* @__PURE__ */new Map;cellEditors=/* @__PURE__ */new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;_hasProcessRows=!1;_hasRowStructurePlugins=!1;#V=/* @__PURE__ */new Map;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;attachAll(e){const t=this.#U(e);for(const i of t)this.attach(i)}#U(e){if(e.length<2)return e;const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,r=[];for(const n of e){const e=n.constructor,o=t.get(e);if(!o){t.set(e,n),r.push(n);continue}const s=i.get(o)??[];s.push(n),i.set(o,s)}if(0===i.size)return r;for(const[n,o]of i)n.mergeConfigsFrom(o);return r}attach(e){if(function(e,t,i){const r=e.name,n=e.constructor.dependencies??[];for(const o of n){if(o.when&&!o.when(e.resolvedConfig))continue;const n=o.name,s=o.required??!0,a=o.reason;if(t.some(e=>e.name===n))continue;const l=o.severity??(s?"error":void 0);if(!l)continue;const c="error"===l?"requires":"recommends",d=a??`${ii(r)}Plugin ${c} ${ii(n)}Plugin`;if("error"===l){const e=ti(n);D("TBW020",`Plugin dependency error:\n\n${d}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${ii(r)}Plugin:\n ${e}\n plugins: [new ${ii(n)}Plugin(), new ${ii(r)}Plugin()]`,i)}else We()&&("warn"===l?I(p,`${d}.`,i):O(p,`${d}.`,i))}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,i);if(e.headerRenderers)for(const[t,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,i);if(e.cellEditors)for(const[t,i]of Object.entries(e.cellEditors))this.cellEditors.set(t,i);this.registerQueryHandlers(e),e.attach(this.grid),this.#G();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const i of t.queries){let t=this.queryHandlers.get(i.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(i.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,i]of this.queryHandlers)i.delete(e),0===i.size&&this.queryHandlers.delete(t)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1,this._hasProcessRows=!1,this.#V.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(e))}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){if(!this._hasProcessRows)return e;let t=e;for(const i of this.#j("processRows")){const e=i.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const i of this.#j("processColumns"))t=i.processColumns(t);return t}processConfig(e){for(const t of this.#j("processConfig"))t.processConfig(e)}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterStructuralRender(){for(const e of this.#j("afterStructuralRender"))e.afterStructuralRender()}beforeStructuralRender(){for(const e of this.plugins)e.beforeStructuralRender?.()}parseLightDom(){for(const e of this.plugins)e.parseLightDom?.()}syncLightDom(){for(const e of this.plugins)e.syncLightDom?.()}needsStructuralRerender(){let e=!1;for(const t of this.plugins)t.needsStructuralRerender?.()&&(e=!0);return e}afterRender(){for(const e of this.#j("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#j("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#j("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#G(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender),this._hasProcessRows=this.plugins.some(e=>"function"==typeof e.processRows),this._hasRowStructurePlugins=this.plugins.some(e=>!0===e.constructor.manifest?.modifiesRowStructure),this.#V.clear()}#j(e){let t=this.#V.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const i=t=>{const i=t.constructor.manifest?.hookPriority;if(!i)return 0;return i[e]??0};return t.some(e=>0!==i(e))&&t.sort((e,t)=>i(e)-i(t)),this.#V.set(e,t),t}onScrollRender(){for(const e of this.#j("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const i of this.plugins)if("function"==typeof i.getRowHeight){const r=i.getRowHeight(e,t);if(void 0!==r)return r}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,i){let r=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const o=n.adjustVirtualStart(e,t,i);o<r&&(r=o)}return r}renderRow(e,t,i){for(const r of this.plugins)if(r.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const r of i){const i=r.handleQuery?.(e);void 0!==i&&t.push(i)}return t}for(const r of this.plugins){const i=r.handleQuery?.(e);void 0!==i&&t.push(i)}return t}subscribe(e,t,i){let r=this.eventListeners.get(t);r||(r=/* @__PURE__ */new Map,this.eventListeners.set(t,r)),r.set(e,i)}unsubscribe(e,t){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,i]of this.eventListeners)i.delete(e),0===i.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const i=this.eventListeners.get(e);if(i)for(const n of i.values())try{n(t)}catch(r){z("TBW024",`Error in plugin event handler for "${e}": ${r}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#j("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#j("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#j("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#j("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#j("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#j("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#j("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#j("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let i=0,r=0,n=!1;for(const o of this.plugins){const s=o.getHorizontalScrollOffsets?.(e,t);s&&(i+=s.left,r+=s.right,s.skipScroll&&(n=!0))}return{left:i,right:r,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const i=t.getToolPanel?.();i&&e.push({plugin:t,panel:i})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const i=t.getHeaderContent?.();i&&e.push({plugin:t,content:i})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class si extends HTMLElement{static tagName="tbw-grid";static version="3.0.0-beta.2";static activeTag="tbw-grid";static#Y=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","column-inference","loading"]}get#X(){return this}#K=!1;#o;#s;#Z=[];get#y(){return this.#Q?.effective??{}}#J=!1;#ee=!1;#te={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1};#ie;#re=0;#ne=null;#oe=!1;#se=!1;#ae=0;#le;#ce={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#de;#ue;#he;#ge;#fe={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#pe;#me;#we;#be;#ve;#ye;get _pluginManager(){return this.#pe}#_e=!1;#Ce;#Re;#A;#Q;#Ee=/* @__PURE__ */new Map;#Se=!1;#Ae=/* @__PURE__ */new Set;#Me=/* @__PURE__ */new Map;#xe;#He={};#Te=/* @__PURE__ */new Map;#ke=!1;_rows=[];#Le=[];get _columns(){return this.#y.columns??[]}set _columns(e){this.#y.columns=e,this.#Pe=void 0}#Pe;get _visibleColumns(){return this.#Pe??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Pe=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#be.state}set _virtualization(e){Object.assign(this.#be.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#Q?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#Q&&(this.#Q.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#Q?.originalColumnNodes}set __originalColumnNodes(e){this.#Q&&(this.#Q.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],i=this.#Z;this.#Z=t,i!==t&&this.#De("rows")}get sourceRows(){return this.#Z}set sourceRows(e){this.#Z=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=Array.isArray(e)?u(e):e,i=this.#Q?.getColumns();this.#Q?.setColumns(t),i!==t&&this.#De("columns")}get gridConfig(){return this.#y}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#Q?.getGridConfig();this.#Q?.setGridConfig(e),t!==e&&(this.#Q.clearLightDomCache(),this.#De("gridConfig"))}get _sourceConfig(){return this.#Q?.getGridConfig()}get fitMode(){return this.#y.fitMode??"stretch"}set fitMode(e){const t=this.#Q?.getFitMode();this.#Q?.setFitMode(e),t!==e&&this.#De("fitMode")}get columnInference(){return this.#y.columnInference??"auto"}set columnInference(e){const t=this.#Q?.getColumnInference();this.#Q?.setColumnInference(e),t!==e&&this.#De("columnInference")}get loading(){return this.#Se}set loading(e){const t=this.#Se;this.#Se=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Ie(),this.#Oe())}setRowLoading(e,t){const i=this.#Ae.has(e);t?this.#Ae.add(e):this.#Ae.delete(e),i!==t&&this.#ze(e,t)}setCellLoading(e,t,i){let r=this.#Me.get(e);const n=r?.has(t)??!1;i?(r||(r=/* @__PURE__ */new Set,this.#Me.set(e,r)),r.add(t)):(r?.delete(t),0===r?.size&&this.#Me.delete(e)),n!==i&&this.#Ne(e,t,i)}isRowLoading(e){return this.#Ae.has(e)}isCellLoading(e,t){return this.#Me.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ae)this.#ze(e,!1);this.#Ae.clear();for(const[e,t]of this.#Me)for(const i of t)this.#Ne(e,i,!1);this.#Me.clear()}get effectiveConfig(){return this.#y}get disconnectSignal(){return this.#de||(this.#de=new AbortController),this.#de.signal}constructor(){super(),this.#qe(),this.#o=new Promise(e=>this.#s=e),this.#be=new ni(this),this.#ve=new xt(this),this.#ye=new Wt(this),this.#ie=new Pe(this),this.#ie.setInitialReadyResolver(()=>this.#s?.()),this.#Q=new De(this)}async#qe(){await Yt('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-column-selection-bg: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-resize-handle-width: 2px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);--tbw-icon-expand: "▶";--tbw-icon-collapse: "▼";--tbw-icon-sort-asc: "▲";--tbw-icon-sort-desc: "▼";--tbw-icon-sort-none: "⇅";--tbw-icon-submenu-arrow: "▶";--tbw-icon-drag-handle: "⋮⋮";--tbw-icon-tool-panel: "☰";--tbw-icon-filter: "";--tbw-icon-filter-active: "";--tbw-icon-print: "🖨️";--tbw-icon-expand-mask: none;--tbw-icon-collapse-mask: none;--tbw-icon-sort-asc-mask: none;--tbw-icon-sort-desc-mask: none;--tbw-icon-sort-none-mask: none;--tbw-icon-submenu-arrow-mask: none;--tbw-icon-drag-handle-mask: none;--tbw-icon-tool-panel-mask: none;--tbw-icon-filter-mask: url("data:image/svg+xml,%3Csvg viewBox=\'0 0 16 16\' width=\'12\' height=\'12\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath 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\'/%3E%3C/svg%3E");--tbw-icon-filter-active-mask: var(--tbw-icon-filter-mask);--tbw-icon-print-mask: none}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}>tbw-grid-column,>tbw-grid-type{display:none}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible;position:relative}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;touch-action:none;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30);touch-action:none}.faux-vscroll-spacer{width:1px}.tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}\n@layer tbw-base{tbw-grid{[data-icon=expand]:empty:before{content:var(--tbw-icon-expand)}[data-icon=collapse]:empty:before{content:var(--tbw-icon-collapse)}[data-icon=sort-asc]:empty:before{content:var(--tbw-icon-sort-asc)}[data-icon=sort-desc]:empty:before{content:var(--tbw-icon-sort-desc)}[data-icon=sort-none]:empty:before{content:var(--tbw-icon-sort-none)}[data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow)}[data-icon=drag-handle]:empty:before{content:var(--tbw-icon-drag-handle)}[data-icon=tool-panel]:empty:before{content:var(--tbw-icon-tool-panel)}[data-icon=print]:empty:before{content:var(--tbw-icon-print)}[data-icon=filter]:empty:before{content:var(--tbw-icon-filter)}[data-icon=filter-active]:empty:before{content:var(--tbw-icon-filter-active)}[data-icon]:empty:before{display:inline-block;vertical-align:middle;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center}[data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);mask-image:var(--tbw-icon-expand-mask)}[data-icon=collapse]:empty:before{-webkit-mask-image:var(--tbw-icon-collapse-mask);mask-image:var(--tbw-icon-collapse-mask)}[data-icon=sort-asc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-asc-mask);mask-image:var(--tbw-icon-sort-asc-mask)}[data-icon=sort-desc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-desc-mask);mask-image:var(--tbw-icon-sort-desc-mask)}[data-icon=sort-none]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-none-mask);mask-image:var(--tbw-icon-sort-none-mask)}[data-icon=submenu-arrow]:empty:before{-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);mask-image:var(--tbw-icon-submenu-arrow-mask)}[data-icon=drag-handle]:empty:before{-webkit-mask-image:var(--tbw-icon-drag-handle-mask);mask-image:var(--tbw-icon-drag-handle-mask)}[data-icon=tool-panel]:empty:before{-webkit-mask-image:var(--tbw-icon-tool-panel-mask);mask-image:var(--tbw-icon-tool-panel-mask)}[data-icon=print]:empty:before{-webkit-mask-image:var(--tbw-icon-print-mask);mask-image:var(--tbw-icon-print-mask)}[data-icon=filter]:empty:before,[data-icon=filter-active]:empty:before{width:var(--tbw-icon-size, 1em);height:var(--tbw-icon-size, 1em);background:currentColor}[data-icon=filter]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-mask);mask-image:var(--tbw-icon-filter-mask)}[data-icon=filter-active]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}}.tbw-context-menu [data-icon]:empty:before{display:inline-block;width:1em;height:1em;vertical-align:middle}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow, "▶")}}\n@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-hit-area, 18px) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.header-group-row>.header-group-cell{&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-hit-area, 18px) / -2);width:var(--tbw-resize-hit-area, 18px);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:transparent;&:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);height:100%;background:var(--tbw-resize-handle-color);border-radius:var(--tbw-resize-handle-border-radius);transition:background .12s ease}&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{&:before{background:var(--tbw-resize-handle-color-hover)}&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}\n@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}@media(hover:hover){&:hover{background:var(--tbw-color-row-hover)}}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}\n@layer tbw-base{.tbw-empty-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--tbw-spacing-md, 12px);text-align:center;background:light-dark(rgba(255,255,255,.6),rgba(0,0,0,.4));color:var(--tbw-color-text-secondary, var(--tbw-color-text));z-index:999;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-empty-message{font-family:var(--tbw-font-family, inherit);font-size:var(--tbw-font-size-md, 14px);line-height:1.4;max-width:480px;user-select:text}}\n@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}\n')}getPlugin(e){return this.#pe?.getPlugin(e)}getPluginByName(e){return this.#pe?.getPluginByName(e)}requestRender(){this.#ie.requestPhase(Le.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#ie.requestPhase(Le.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#ie.requestPhase(Le.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){B(this)}requestAfterRender(){this.#ie.requestPhase(Le.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Fe(){this.#pe=new oi(this);const e=this.#y?.plugins,t=Array.isArray(e)?e:[],i=this.#y?.features;let r,n=[];if(i&&At){n=At(i).map(e=>this.#We(e))}if(0===n.length)r=t;else if(0===t.length)r=n;else{const e=new Set(t.map(e=>e.name));r=[...n.filter(t=>!e.has(t.name)),...t]}this.#pe.attachAll(r)}#We(e){const t=this.#Ee.get(e.name);return t&&t!==e?(t.refreshUserConfigFrom(e),t):(this.#Ee.set(e.name,e),e)}#$e(){!function(e){let t=!1;for(const{name:i,styles:r}of e)Vt.has(i)||(Vt.set(i,Gt(r)),t=!0);t&&jt()}(this.#pe?.getPluginStyles()??[])}#Be(){const e=this.#y?.plugins,t=Array.isArray(e)?e:[],i=this.#y?.features??void 0,r=i!==this.#we;if((this.#me===t||void 0!==this.#me&&this.#me.length===t.length&&this.#me.every((e,i)=>e===t[i]))&&!r)return void(this.#me=t);this.#pe&&this.#pe.detachAll(),this.#Fe(),this.#$e(),this.#me=t,this.#we=i,this.#Ve(),this.#Q.markSourcesChanged(),this.#Q.merge();const n=this.#oe;if(this.#oe=this.#pe?.getAll().some(e=>e.onScroll)??!1,!n&&this.#oe){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");this.#Ue(e)}}#Ge(){this.#pe?.detachAll()}#je(){const e=si.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}}}_registerLightDomHandler(e,t){this.#Q.registerLightDomHandler(e,t)}_unregisterLightDomHandler(e){this.#Q.unregisterLightDomHandler(e)}_requestConfigMerge(){this.#Q.markSourcesChanged(),this.#Q.merge()}_getToolPanelRendererFactory(){return this.#je()}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",si.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++si.#Y),this._rows=Array.isArray(this.#Z)?[...this.#Z]:[],this.#de&&(this.#de.abort(),this.#_e=!1),this.#de=new AbortController,this.#ge&&(Tt(this.#ge),this.#ge=void 0),this.#Ye(),this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Fe();const e=this.#y?.plugins;var t,i;this.#me=Array.isArray(e)?e:[],this.#we=this.#y?.features??void 0,this.#K||(this.#Xe(),this.#$e(),this.#K=!0),this.#Ke(),this.#ge=(t=()=>{this.#Ze()},i={timeout:100},Ht?requestIdleCallback(t,i):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#ge&&(Tt(this.#ge),this.#ge=void 0),this.#ae&&(clearTimeout(this.#ae),this.#ae=0),this.#Ge();const e=this.#pe?.getPluginByName("shell");e?.disposeShellState?.(),Kt(this.#ce),this.#de&&(this.#de.abort(),this.#de=void 0),this.#Ce?.abort(),this.#Ce=void 0,this.#_e=!1,this._resizeController&&this._resizeController.dispose(),this.#ue&&(this.#ue.disconnect(),this.#ue=void 0),this.#he&&(this.#he.disconnect(),this.#he=void 0,this.#Qe=!1,this.#Je=0),nt(this),this.#et.clear(),this._virtualization.heightCache?.byKey.clear(),this.#me=void 0,this.#we=void 0;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#J=!1}attributeChangedCallback(e,t,i){if("loading"===e){const e=null!==i&&"false"!==i;return void(this.loading!==e&&(this.loading=e))}if(t!==i&&i&&"null"!==i&&"undefined"!==i)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(i);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{I("TBW130",`Invalid JSON for '${e}' attribute: ${i}`,this.id)}else"fit-mode"===e?this.fitMode=i:"column-inference"===e&&(this.columnInference=i)}#Ke(){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.setAttribute("data-upgraded",""),this.#J=!0,this._resizeController=Pt(this),this.#tt(),this.#Ue(e),this.#_e)return;this.#_e=!0;const t=this.disconnectSignal;St(this,this,this.#X,t),this.#Ve(),queueMicrotask(()=>this.#it()),this.#ie.requestPhase(Le.FULL,"afterConnect")}#Ve(){const e=this.#y.rowHeight,t=this.#pe.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#be.initializePositionCache(),"function"!=typeof e&&(this.#se=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#rt())}#rt(){if(this.#pe.hasRowHeightPlugin())return;const e=this.#y.rowHeight;if("number"==typeof e&&e>0)return;const t=this._bodyEl?.querySelector(".data-grid-row");if(!t)return;const i=this.#nt(),r=[],n=this._bodyEl?.querySelectorAll(".data-grid-row");for(const h of n??[]){if(h.style.getPropertyValue("--tbw-row-height"))continue;let e=0;h.querySelectorAll(".cell").forEach(t=>{const i=t.offsetHeight;i>e&&(e=i)});const t=Math.max(h.getBoundingClientRect().height,e);t>0&&r.push(t)}if(0===r.length)return;r.sort((e,t)=>e-t);const o=r.length>>1,s=r.length%2==1?r[o]:(r[o-1]+r[o])/2,a=this._virtualization.rowHeight,l=this.#Je,c=i>0&&l>0&&Math.abs(i-l)>1,d=i>0&&0===l,u=s>0&&s-a>1;if(i>0&&(this.#Je=i),c||d||u){const e=c||d?Math.max(i,s):s;Math.abs(e-a)>1&&(this._virtualization.rowHeight=e,this.#ie.requestPhase(Le.VIRTUALIZATION,"measureRowHeight"))}}#nt(){const e=getComputedStyle(this).getPropertyValue("--tbw-row-height").trim();if(!e)return 0;if(e.endsWith("px"))return parseFloat(e)||0;const t=this._bodyEl?.querySelector('.data-grid-row:not([style*="--tbw-row-height"]) > .cell');if(!t)return 0;const i=parseFloat(getComputedStyle(t).minHeight);return i>0?i:0}#ot(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const r=e.getBoundingClientRect(),n=Math.max(r.height,i);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#be.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#be.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Ue(e){this.#Ce?.abort(),this.#Ce=new AbortController;const t=this.#Ce.signal,i=e?.querySelector(".faux-vscroll"),r=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#oe=this.#pe?.getAll().some(e=>e.onScroll)??!1,i&&r){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#oe)return;const e=i.scrollTop,t=pt(e,this._virtualization.scrollMapping),n=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)r.style.transform=`translateY(${-e}px)`;else{const e=this._virtualization.positionCache;let i,o;if(this._virtualization.variableHeights&&e&&e.length>0){i=ut(e,t),-1===i&&(i=0);const r=i-i%2;o=e[r]?.offset??r*n}else{i=Math.floor(t/n);o=(i-i%2)*n}const s=-(t-o);r.style.transform=`translateY(${s}px)`}this.#ne=e,this.#re||(this.#re=requestAnimationFrame(()=>{this.#re=0,null!==this.#ne&&(this.#st(this.#ne),this.#ne=null)}))},{passive:!0,signal:t});const e=this.#X.querySelector(".tbw-scroll-area");this.#Re=e,this._virtualization.scrollAreaEl=e,e&&this.#oe&&e.addEventListener("scroll",()=>{const t=this.#fe;t.scrollTop=i.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=i.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=i.clientHeight,t.clientWidth=e.clientWidth,this.#pe?.onScroll(t)},{passive:!0,signal:t});const n=this.#X.querySelector(".tbw-grid-content"),o=this.#Re;n&&(n.addEventListener("wheel",e=>{try{if(n.querySelector("select:open"))return}catch{}const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&o){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:i,scrollWidth:r,clientWidth:n}=o;(t>0&&i<r-n||t<0&&i>0)&&(e.preventDefault(),o.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:r,clientHeight:n}=i;(e.deltaY>0&&t<r-n||e.deltaY<0&&t>0)&&(e.preventDefault(),i.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),Qt(n,this.#ce,{fauxScrollbar:i,scrollArea:o},t))}var n,o,s;this._bodyEl&&(n=this,o=this._bodyEl,s=t,o.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(V.EDITING))return;const i=e.target;i.draggable||i.closest('[draggable="true"]')||e.preventDefault(),Rt(n,t)},{signal:s}),o.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&at(n,e,t),!document.activeElement?.closest(`.cell.${V.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),o.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&at(n,e,t)},{signal:s})),this.#ue?.disconnect(),this._virtualization.viewportEl&&(this.#ue=new ResizeObserver(()=>{this.#at(),this.#ie.requestPhase(Le.VIRTUALIZATION,"resize-observer")}),this.#ue.observe(this._virtualization.viewportEl)),this.#X.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#X.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#X.contains(t)||this.#ve.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Qe=!1;#Je=0;#lt(){if(this.#Qe)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Qe=!0,this.#he?.disconnect(),this.#he=new ResizeObserver(()=>{this.#rt()}),this.#he.observe(e))}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}on(e,t){const i=e=>{t(e.detail,e)};return this.addEventListener(e,i),()=>this.removeEventListener(e,i)}#ct(e,t){this.#J&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#ct("data-change",{rowCount:this._rows.length,sourceRowCount:this.#Z.length}),function(e,t,i){if(i===t.lastAnnouncedSourceCount)return;const r=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=i,0===i&&r<0||o(e,s(e,"dataLoaded",i))}(this,this.#dt,this.#Z.length)}#it(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const i=t===this._focusRow;e.setAttribute("aria-selected",String(i)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(i&&t===this._focusCol))})})}#De(e){this.#te[e]=!0,this.#ee||(this.#ee=!0,queueMicrotask(()=>this.#ut()))}#ut(){if(!this.#ee||!this.#J)return void(this.#ee=!1);const e=this.#te;if(this.#ee=!1,this.#te={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1},e.gridConfig)return this.#ht(),void(e.rows&&this.#gt());(e.columns||e.columnInference)&&this.#ft(),e.rows&&this.#gt(),e.fitMode&&this.#pt()}#gt(){this._rows=Array.isArray(this.#Z)?[...this.#Z]:[],this.#ke=!0,this.#ie.requestPhase(Le.ROWS,"applyRowsUpdate")}#mt(){this.#ke&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#ke=!1,this.#Te.clear();const e=this.#y.getRowId;for(let t=0;t<this._rows.length;t++){const i=qt(this._rows[t],e);void 0!==i&&this.#Te.set(i,{row:this._rows[t],index:t})}}#ft(){nt(this),this.#Q.merge(),this.#tt()}#pt(){this.#Q.merge();if("fixed"===this.#y.fitMode)this.__didInitialAutoSize=!1,F(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}B(this)}}#ht(){this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Be(),this.#Ve(),this.#Q.markSourcesChanged(),this.#Q.merge();const e=this.#Q.initialColumnState;if(e){this.#Q.initialColumnState=void 0,this.#A=void 0;const t=this.#pe?.getAll()??[];this.#Q.applyState(e,t)}if(this.#pe?.needsStructuralRerender()??!1)return this.#pe?.beforeStructuralRender(),this.#Xe(),this.#$e(),this.#Ke(),void this._rebuildRowIdMap();this._rebuildRowIdMap(),this.#ie.requestPhase(Le.COLUMNS,"applyGridConfigUpdate")}#wt(){if(this.__rowRenderEpoch++,this.#pe){const e=this.#Le.length>0?this.#Le:this._columns,t=e.filter(e=>!e.hidden),i=e.filter(e=>e.hidden),r=this.#pe.processColumns([...t]);if(r!==t){const n=new Set(r.map(e=>e.field));!t.some(e=>n.has(e.field))&&r.length>0?this._columns=[...r,...i]:this._columns=this.#bt(e,r,i)}else this._columns=[...e]}}#bt(e,t,i){if(0===i.length)return t;const r=/* @__PURE__ */new Map;for(const a of t)r.set(a.field,a);const n=new Set(e.map(e=>e.field)),o=[];for(const a of t)n.has(a.field)||o.push(a);const s=[];for(const a of e){const e=r.get(a.field);e?s.push(e):a.hidden&&s.push(a)}return s.push(...o),s}#vt(){nt(this);const e=this.#Z;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#be.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#y.initialSort){const{field:e,direction:t}=this.#y.initialSort;this._columns.find(t=>t.field===e)&&(this._sortState={field:e,direction:"desc"===t?-1:1})}this._sortState&&(this.__originalOrder=this._rows);const t=function(e,t,i=!1){if(!e._sortState)return t;const r=e.effectiveConfig?.sortHandler??pe;if(r===pe)return i||(e.__originalOrder=t.slice()),ve(t,e._sortState.field,e._sortState.direction,e._columns),t;i||(e.__originalOrder=t);const n=r(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),i=this.#pe?.processRows(t)??t;this._rows=i,this.#ke=!0,this._emitDataChange()}_renderVisibleRows(e,t,i=this.__rowRenderEpoch){if(this.#le||(this.#le=(e,t,i)=>this.#pe?.renderRow(e,t,i)??!1),function(e,t,i,r,n){const o=Math.max(0,i-t),s=e._bodyEl,a=e._visibleColumns,l=a.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<o;){const t=rt();e._rowPool.push(t)}if(e._rowPool.length>o){const t=e.__frameworkAdapter,i=t?.releaseCell;t?.beginBatch?.(e);try{for(let r=o;r<e._rowPool.length;r++){const n=e._rowPool[r];if(i){const e=n.children;for(let r=0;r<e.length;r++){const n=e[r];n.firstElementChild&&i.call(t,n)}}n.parentNode===s&&n.remove()}e._rowPool.length=o}finally{t?.endBatch?.(e)}}const d=n&&!1!==e.__hasRenderRowPlugins,u=e._hasAfterRowRenderHook?.()??!1,h=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<o;f++){const i=t+f,o=e._rows[i],p=e._rowPool[f];if(p.setAttribute("aria-rowindex",String(i+c+1)),d&&n(o,p,i)){p.__epoch=r,p.__rowDataRef=o,p.parentNode!==s&&s.appendChild(p);continue}const m=p.__epoch,w=p.__rowDataRef;let b=p.children.length;b>l&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const v=m===r&&b===l,y=w!==o,_=!!e._isGridEditMode;let C=!1;if(v&&y)for(let e=0;e<l;e++)if(a[e].externalView&&!p.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){C=!0;break}if(!v||C){const t=Qe(p),n=_&&!y||e._activeEditRows===i;t&&!n?(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):t&&n?(ot(e,p,o,i),p.__rowDataRef=o):(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o)}else if(y){const t=Qe(p),n=e._activeEditRows===i;t&&!n?(Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):(ot(e,p,o,i),p.__rowDataRef=o)}else{const t=Qe(p),n=_||e._activeEditRows===i;t&&!n?(Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):ot(e,p,o,i)}let R=!1;const E=e._changedRowIdSet;if(E&&E.size>0)try{const t=e.getRowId?.(o);t&&(R=E.has(t))}catch{}R!==p.classList.contains("changed")&&p.classList.toggle("changed",R);const S=e.effectiveConfig?.rowClass;if(S){const t=p.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&p.classList.remove(e[t])}try{const e=S(o),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let i=0;i<t.length;i++){const r=t[i];r&&"string"==typeof r&&(p.classList.add(r),e+=(e?" ":"")+r)}p.setAttribute("data-dynamic-classes",e)}else p.removeAttribute("data-dynamic-classes")}catch(g){I("TBW060",`rowClass callback error: ${g}`,e.id),p.removeAttribute("data-dynamic-classes")}}if(h){const e=h(o,i);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}u&&e._afterRowRender?.({row:o,rowIndex:i,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,i,this.#le),this.#Ae.size>0)for(const r of this.#Ae)this.#ze(r,!0)}#dt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,i,r,n){if(r===e.rowCount&&n===e.colCount)return!1;const o=e.rowCount;e.rowCount=r,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(r)),t.setAttribute("aria-colcount",String(n))),r!==o&&i&&(r>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role"))}(this.#dt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#ie.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#pe?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,i){return this.#pe?.adjustVirtualStart(e,t,i)}_afterPluginRender(){this.#pe?.afterRender()}_emitPluginEvent(e,t){this.#pe?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Be(),function(e,t,i){const r=Jt,n=ei,o=/* @__PURE__ */new Map;function s(e,t,i,r,n=!1){o.has(e)||o.set(e,{description:t,importHint:i,fields:[],isConfigProperty:n});const s=o.get(e);s.fields.includes(r)||s.fields.push(r)}const a=e.features;function l(e){return!!a&&!1===a[e]}for(const d of n){const i=e[d.property];if((d.isUsed?d.isUsed(i):void 0!==i)&&!ri(t,d.pluginName)&&!l(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,ti(d.pluginName),d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of r){const i=d[e.property];if((e.isUsed?e.isUsed(i):void 0!==i)&&!ri(t,e.pluginName)&&!l(e.pluginName)){const t=d.field||"<unknown>",i=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,i,ti(e.pluginName),t)}}if(o.size>0){const e=[];for(const[t,{description:i,importHint:r,fields:n,isConfigProperty:s}]of o)if(s)e.push(`Config uses ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${r}\n plugins: [new ${ii(t)}Plugin(), ...]`);else{const o=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${o}] use ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${r}\n plugins: [new ${ii(t)}Plugin(), ...]`)}D([...o.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,i)}}(this.#y,this.#pe?.getPlugins()??[],this.id),function(e,t){const i=[],r=[];for(const n of e){const e=n.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=n.config;if(t.check(e)){const e=`[${ii(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?i.push(e):r.push(e)}}}if(r.length>0&&We())for(const n of r)I("TBW004",n,t);i.length>0&&D("TBW003",`Configuration error:\n\n${i.join("\n\n")}`,t)}(this.#pe?.getPlugins()??[],this.id),function(e,t){if(!We())return;const i=new Set(e.map(e=>e.name)),r=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const o of e.incompatibleWith)if(i.has(o.name)){const e=[n.name,o.name].sort().join("↔");if(r.has(e))continue;r.add(e),I("TBW022",`${ii(n.name)}Plugin and ${ii(o.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${o.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#pe?.getPlugins()??[],this.id),this.#yt(),this.#Le=[...this._columns]}_schedulerProcessColumns(){this.#wt()}_schedulerProcessRows(){this.#vt()}_schedulerRenderHeader(){Te(this)}_schedulerUpdateTemplate(){B(this)}_schedulerAfterRender(){this.#pe?.afterRender(),this.#Oe(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#be.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#y.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,F(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,_t(this)),this._virtualization.enabled&&!this.#Qe&&this.#lt(),this.#se&&(this.#se=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#ot()})})),this.#Se&&this.#Ie()}get _schedulerIsConnected(){return this.isConnected&&this.#J}get _hostElement(){return this}get _renderRoot(){return this.#X}_emit(e,t){this.#ct(e,t)}get _accordionIcons(){return{expand:this.#y?.icons?.expand??n.expand,collapse:this.#y?.icons?.collapse??n.collapse}}_pluginShellContributions(){return{toolPanels:(this.#pe?.getToolPanels()??[]).map(e=>e.panel),headerContents:(this.#pe?.getHeaderContents()??[]).map(e=>e.content)}}_clearRowPool(){const e=this.__frameworkAdapter,t=e?.releaseCell;if(t){e?.beginBatch?.(this);try{for(let i=0;i<this._rowPool.length;i++){const r=this._rowPool[i].children;for(let i=0;i<r.length;i++){const n=r[i];n.firstElementChild&&t.call(e,n)}}this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="")}finally{e?.endBatch?.(this)}}else this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="");this.__rowRenderEpoch++}_setup(){this.#tt()}_applyAnimationConfig(e){const t={...r,...e.animation},i=t.mode??"reduced-motion";let n=1;!1===i||"off"===i?n=0:!0!==i&&"on"!==i||(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}#yt(){!function(e,t,i){if(!t)return!1;let r=!1;const n=i?.gridAriaLabelledBy,o=n?void 0:function(e){const t=e?.gridAriaLabel;return t||(e?.shell?.header?.title??void 0)}(i);n!==e.ariaLabelledBy&&(e.ariaLabelledBy=n,n?t.setAttribute("aria-labelledby",n):t.removeAttribute("aria-labelledby"),r=!0),o!==e.ariaLabel&&(e.ariaLabel=o,o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),r=!0);const s=i?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0);const a=i?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),r=!0)}(this.#dt,this.__rowsBodyEl,this.#y)}#Ie(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#Se?(this.#xe||(this.#xe=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(kt("large",e)),t}(this.#y?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#xe)):(t=this.#xe,t?.remove()))}#Oe(){!function(e,t,i,r,n,o,s){if(!e)return;if(!function(e,t,i){return!(e||t>0||null===i)}(t,i,n))return Fe(s.el),s.el=void 0,s.renderer=void 0,s.target=void 0,s.sourceRows=void 0,void(s.filteredOut=void 0);const a=r.length,l=a>0&&0===i;if(s.el&&s.renderer===n&&s.target===o&&s.sourceRows===r&&s.filteredOut===l)return;const c="grid"===o?e:e.querySelector(".rows-container")??e;Fe(s.el),s.el=qe({sourceRowCount:a,filteredOut:l},n??void 0,o),function(e,t){e.appendChild(t)}(c,s.el),s.renderer=n,s.target=o,s.sourceRows=r,s.filteredOut=l}(this.querySelector(".tbw-grid-root"),this.#Se,this._rows.length,this.#Z,this.#y?.emptyRenderer,this.#y?.emptyOverlay??"rows",this.#He)}#ze(e,t){this.#mt();const i=this.#Te.get(e);if(!i)return;const r=this.findRenderedRowElement?.(i.index);r&&Lt(r,t)}#Ne(e,t,i){this.#mt();const r=this.#Te.get(e);if(!r)return;const n=this.findRenderedRowElement?.(r.index);if(!n)return;const o=this._visibleColumns.findIndex(e=>e.field===t);if(o<0)return;const s=n.children[o];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,i)}#tt(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#Q.parseLightDomColumns(this),this.#A){const e=this.#A;this.#A=void 0,this.#Q.merge();const t=this.#pe?.getAll()??[];this.#Q.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#ie.requestPhase(Le.FULL,"setup")}}#st(e){const t=this._virtualization.container,i=this.#Re,r=i?.scrollLeft??0,n=t?.scrollHeight??0,o=i?.scrollWidth??0,s=t?.clientHeight??0,a=i?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#pe?.onScrollRender(),this._virtualization.variableHeights&&(this.#ae&&clearTimeout(this.#ae),this.#ae=window.setTimeout(()=>{this.#ae=0,this.#be.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#oe){const t=this.#fe;t.scrollTop=e,t.scrollLeft=r,t.scrollHeight=n,t.scrollWidth=o,t.clientHeight=s,t.clientWidth=a,this.#pe?.onScroll(t)}this.#ct("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#X.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,i=e-t.start;return i>=0&&i<this._rowPool.length&&i<t.end-t.start?this._rowPool[i]:null}_dispatchCellClick(e,t,i,r){const n=this._rows[t],o=this._visibleColumns[i];if(!n||!o)return!1;const s=o.field,a=n[s],l=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,column:o,field:s,value:a,row:n,cellEl:r,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(l),l.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:i,column:o,field:s,value:a,cellEl:r,originalEvent:e},d=this.#pe?.onCellClick(c)??!1;return this.#ct("cell-click",c),d}_dispatchRowClick(e,t,i,r){if(!i)return!1;const n={rowIndex:t,row:i,rowEl:r,originalEvent:e},o=this.#pe?.onRowClick(n)??!1;return this.#ct("row-click",n),o}_dispatchHeaderClick(e,t,i){if(!t)return!1;const r={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:i,originalEvent:e};return this.#pe?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#pe?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#pe?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#pe?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#pe?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#pe?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#pe?.onCellMouseUp(e)}_afterCellRender(e){this.#pe?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#pe?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#pe?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#pe?.hasAfterRowRenderHook()??!1}async ready(){return this.#o}async forceLayout(){return 0===this.#ie.pendingPhase&&this.#ie.requestPhase(Le.FULL,"forceLayout"),this.#ie.whenReady()}async getConfig(){return Object.freeze({...this.#y||{}})}getRowId(e){return Ft(e,this.id,this.#y.getRowId)}getRow(e){return this.#ye.getRow(e)}_getRowEntry(e){return this.#mt(),this.#Te.get(e)}updateRow(e,t,i="api"){this.#ye.updateRow(e,t,i)}updateRows(e,t="api"){this.#ye.updateRows(e,t)}animateRow(e,t){return Nt(this,e,t)}animateRows(e,t){return function(e,t,i){return Promise.all(t.map(t=>Nt(e,t,i))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,i){const r=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const o=r.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return o<0?Promise.resolve(!1):Nt(e,o,i)}(this,e,t)}async insertRow(e,t,i=!0){return this.#ye.insertRow(e,t,i)}async removeRow(e,t=!0){return this.#ye.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#ye.applyTransaction(e,t)}applyTransactionAsync(e){return this.#ye.applyTransactionAsync(e)}focusCell(e,t){this.#ve.focusCell(e,t)}get focusedCell(){return this.#ve.focusedCell}scrollToRow(e,t){this.#ve.scrollToRow(e,t)}scrollToRowById(e,t){this.#ve.scrollToRowById(e,t)}setColumnVisible(e,t){const i=this.#Q.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#Q.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#Q.isColumnVisible(e)}showAllColumns(){this.#Q.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#Q.getAllColumns()}setColumnOrder(e){this.#Q.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#Q.getColumnOrder()}getColumnState(){const e=this.#pe?.getAll()??[];return this.#Q.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#K?this.#_t(e):(this.#A=e,this.#Q.initialColumnState=e))}#_t(e){const t=this._columns,i=this._sortState,r=this.#pe?.getAll()??[];this.#Q.applyState(e,r);if(!e.columns.some(e=>void 0!==e.sort)&&this.#Ct(t,i))return this.#Pe=void 0,B(this),void this.#ie.requestPhase(Le.STYLE,"column-width");this.#tt()}#Ct(e,t){const i=this._columns,r=this._sortState;if(t?.field!==r?.field||t?.direction!==r?.direction)return!1;if(e.length!==i.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],r=i[n];if(t.field!==r.field)return!1;if(!!t.hidden!=!!r.hidden)return!1}return!0}get sortModel(){return this._sortState?{field:this._sortState.field,direction:1===this._sortState.direction?"asc":"desc"}:null}sort(e,t){if(null===e){if(!this._sortState)return;const e=this._sortState.field;this._sortState=null,this.__rowRenderEpoch++;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].__epoch=-1;return this._rows=this.__originalOrder.slice(),this.__originalOrder=[],Te(this),this.refreshVirtualWindow(!0),this.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e,direction:0}})),this._pluginManager?.emitPluginEvent?.("sort-change",{field:e,direction:0}),void this.requestStateChange?.()}const i=this._columns.find(t=>t.field===e);i&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),Ee(this,i,"desc"===t?-1:1)):Re(this,i))}requestStateChange(){const e=this.#pe?.getAll()??[];this.#Q.requestStateChange(e)}resetColumnState(){this.#A=void 0,this.__originalOrder=[];const e=this.#pe?.getAll()??[];this.#Q.resetState(e),this.#Q.merge(),this.#tt()}get defaultRowHeight(){return this._virtualization.rowHeight}#Rt=!1;refreshShellHeader(){this.#Rt||(this.#Rt=!0,queueMicrotask(()=>{this.#Rt=!1,this.isConnected&&(this.#Ye(),this.#Q.markSourcesChanged(),this.#Q.merge(),this.#pe?.beforeStructuralRender(),this.#pe?.afterStructuralRender(),this.#Et())}))}#Et(){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this._resizeController=Pt(this),this.#Ue(e),this.#ie.requestPhase(Le.COLUMNS,"shellRefresh")}#et=/* @__PURE__ */new Map;registerStyles(e,t){let i=this.#et.get(e);i||(i=new CSSStyleSheet,this.#et.set(e,i)),i.replaceSync(t),this.#St()}unregisterStyles(e){this.#et.delete(e)&&this.#St()}getRegisteredStyles(){return Array.from(this.#et.keys())}#St(){const e=Array.from(this.#et.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#et.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#ve.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#ve.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#ve.containsFocus(e)}get lastFocusedElement(){return this.#ve.lastFocusedElement}restoreLastFocus(){return this.#ve.restoreLastFocus()}#Ye(){this.#pe?.parseLightDom()}#Ze(){const e=()=>{this.#Q.clearLightDomCache(),this.#tt()};this.#Q.registerLightDomHandler("tbw-grid-column",e),this.#Q.registerLightDomHandler("tbw-grid-detail",e),this.#Q.registerLightDomHandler("tbw-grid-type",e),this.#Q.observeLightDOM(this)}refreshColumns(){this.#Q.clearLightDomCache(),nt(this),this.#Q.parseLightDomColumns(this),this.#pe?.syncLightDom(),this.#ie.requestPhase(Le.COLUMNS,"refreshColumns")}#at(){this.#be.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#be.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#be.invalidateRowHeight(e,t)}#Xe(){this.#Ye(),this.#Q.markSourcesChanged(),this.#Q.merge(),function(e){const t=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(V.ROOT)||t.push(i);e.replaceChildren();for(const i of t)e.appendChild(i);e.appendChild(ze())}(this.#X),this.#pe?.afterStructuralRender()}}!function(){const e=si.tagName,t=customElements.get(e);if(!t)return customElements.define(e,si),void(si.activeTag=e);if(t.version===si.version)return void(si.activeTag=e);const i=`${e}-v${si.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(i)||customElements.define(i,si),si.activeTag=i}(),globalThis.DataGridElement||(globalThis.DataGridElement=si);const ai=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"];function li(e){const t=document.createElement(si.activeTag);return e&&(t.gridConfig=e),t}function ci(e,t,i){let r=document,n=!1;return"boolean"==typeof t?n=t:t&&(r=t,n=!!i),n?customElements.whenDefined(si.activeTag).then(()=>r.querySelector(e)):r.querySelector(e)}function di(e,t,i){return i?.valueAccessor?he(e,i):e?.[t]}function ui(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const hi={sum:(e,t,i)=>{let r=0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||(r+=s)}return r},avg:(e,t,i)=>{if(!e.length)return 0;let r=0,n=0;for(let o=0;o<e.length;o++){const s=di(e[o],t,i);if(ui(s))continue;const a=Number(s);isNaN(a)||(r+=a,n++)}return n>0?r/n:0},count:e=>e.length,min:(e,t,i)=>{if(!e.length)return 0;let r=1/0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||s<r&&(r=s)}return r===1/0?0:r},max:(e,t,i)=>{if(!e.length)return 0;let r=-1/0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||s>r&&(r=s)}return r===-1/0?0:r},first:(e,t,i)=>e[0]?di(e[0],t,i):void 0,last:(e,t,i)=>e.length?di(e[e.length-1],t,i):void 0},gi=/* @__PURE__ */new Map,fi={register(e,t){gi.set(e,t)},unregister(e){gi.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:gi.get(e)??hi[e]},run(e,t,i,r){const n=this.get(e);return n?n(t,i,r):void 0},has:e=>gi.has(e)||e in hi,list:()=>[...Object.keys(hi),...gi.keys()]},pi={sum:e=>{let t=0;for(let i=0;i<e.length;i++)t+=e[i];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let i=0;i<e.length;i++)t+=e[i];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let i=1;i<e.length;i++)e[i]<t&&(t=e[i]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let i=1;i<e.length;i++)e[i]>t&&(t=e[i]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function mi(e){return pi[e]??pi.sum}function wi(e,t){return mi(e)(t)}export{L as A,de as BaseGridPlugin,E as C,ai as CORE_CONSUMED_ADAPTER_METHODS,t as ColumnInferenceModeEnum,H as D,i as DEFAULT_A11Y_MESSAGES,r as DEFAULT_ANIMATION_CONFIG,n as DEFAULT_GRID_ICONS,si as DataGridElement,v as E,Ze as F,e as FitModeEnum,j as GridCSSVars,V as GridClasses,U as GridDataAttrs,si as GridElement,G as GridSelectors,S as M,gt as MAX_ELEMENT_HEIGHT_PX,A as N,R as P,oi as PluginManager,Le as RenderPhase,o as a,fi as aggregatorRegistry,h as applyColumnDefaults,bt as b,pe as builtInSort,le as c,ft as computeScrollMapping,li as createGrid,wt as d,fe as defaultComparator,_t as e,Be as f,mt as fromVirtualScrollTop,s as g,mi as getValueAggregator,D as h,g as hasColumnShorthands,M as i,ge as invalidateAccessorCache,x as j,Lt as k,oe as l,Ge as m,y as n,u as normalizeColumns,_ as o,z as p,d as parseColumnShorthand,C as q,ci as queryGrid,Ye as r,he as resolveCellValue,wi as runValueAggregator,re as s,Mt as setFeatureResolver,ce as t,pt as toVirtualScrollTop,Ve as u,Ue as v,I as w,O as x,k as y,T as z};//# sourceMappingURL=index.js.map
|
|
1
|
+
const e={STRETCH:"stretch",FIXED:"fixed"},t={AUTO:"auto",MERGE:"merge"},i={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},r={mode:"reduced-motion",duration:200,easing:"ease-out"},n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function o(e,t){if(!e)return;const i="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===i?.a11y?.announcements)return;const r=e.querySelector?.(".tbw-sr-only");r&&(r.textContent="",requestAnimationFrame(()=>{r.textContent=t}))}function s(e,t,...r){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,o=n?.a11y?.messages?.[t];return o?o(...r):i[t](...r)}function a(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e){if("id"===e.toLowerCase())return"ID";return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").split(" ").filter(Boolean).map(a).join(" ")}const c=/* @__PURE__ */new Set(["string","number","boolean","date","datetime","currency"]);function d(e){const t=e.lastIndexOf(":");if(t>0){const i=e.slice(t+1).toLowerCase();if(c.has(i)){const r=e.slice(0,t);return{field:r,header:l(r),type:i}}}return{field:e,header:l(e)}}function u(e){return e.map(e=>"string"==typeof e?d(e):e)}function h(e,t){return t?e.map(e=>({...t,...e})):e}function g(e){return e.some(e=>"string"==typeof e)}function f(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const p="TBW021",m="TBW041",w="TBW061",b="TBW062",v="TBW080",y="TBW090",_="TBW091",C="TBW092",R="TBW093",E="TBW100",S="TBW110",A="TBW112",M="TBW113",x="TBW114",H="TBW140",T="TBW141",k="TBW142",L="TBW143";function P(e,t,i,r){return`${f(i,r)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function D(e,t,i,r){throw new Error(P(e,t,i,r))}function I(e,t,i,r){console.warn(P(e,t,i,r))}function O(e,t,i,r){console.debug(P(e,t,i,r))}function z(e,t,i,r){console.error(P(e,t,i,r))}function N(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const i={},r=t;for(let s=0;s<r.length;s++){const e=r[s],t=i[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate),e.__element&&!t.__element&&(t.__element=e.__element);const i=e.renderer||e.viewRenderer,r=t.renderer||t.viewRenderer;i&&!r&&(t.viewRenderer=i,e.renderer&&(t.renderer=i)),e.editor&&!t.editor&&(t.editor=e.editor),e.headerRenderer&&!t.headerRenderer&&(t.headerRenderer=e.headerRenderer),e.headerLabelRenderer&&!t.headerLabelRenderer&&(t.headerLabelRenderer=e.headerLabelRenderer)}else i[e.field]={...e}}const n=e.map(e=>{const t=i[e.field];if(!t)return e;const r={...e};t.header&&!r.header&&(r.header=t.header),t.type&&!r.type&&(r.type=t.type),r.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(r.resizable=!0),null!=t.width&&null==r.width&&(r.width=t.width),null!=t.minWidth&&null==r.minWidth&&(r.minWidth=t.minWidth),t.__viewTemplate&&(r.__viewTemplate=t.__viewTemplate),t.__headerTemplate&&(r.__headerTemplate=t.__headerTemplate),t.__element&&!r.__element&&(r.__element=t.__element);const n=t.renderer||t.viewRenderer,o=r.renderer||r.viewRenderer;return n&&!o&&(r.viewRenderer=n,t.renderer&&(r.renderer=n)),t.editor&&!r.editor&&(r.editor=t.editor),r.headerRenderer||r.headerLabelRenderer||(t.headerRenderer?r.headerRenderer=t.headerRenderer:t.headerLabelRenderer&&(r.headerLabelRenderer=t.headerLabelRenderer)),delete i[e.field],r}),o=Object.keys(i);for(let s=0;s<o.length;s++)n.push(i[o[s]]);return n}function q(e,t){try{e.part?.add?.(t)}catch{}const i=e.getAttribute("part");i?i.split(/\s+/).includes(t)||e.setAttribute("part",i+" "+t):e.setAttribute("part",t)}function F(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;if(i!==e.STRETCH&&i!==e.FIXED)return;if(t.__didInitialAutoSize)return;if(!t.isConnected)return;const r=Array.from(t._headerRowEl?.children||[]);if(!r.length)return;let n=!1;const o=t._visibleColumns;for(let e=0;e<o.length;e++){const i=o[e];if(i.width)continue;const s=r[e];let a=s?s.scrollWidth:0;for(let r=0;r<t._rowPool.length;r++){const i=t._rowPool[r].children[e];if(i){const e=i.scrollWidth;e>a&&(a=e)}}a>0&&(i.width=a+2,i.__autoSized=!0,n=!0)}n&&B(t),t.__didInitialAutoSize=!0}const W=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function $(e,t){return"number"==typeof e?`${e}px`:(W.test(e)||I("TBW050",`Column '${t??"?"}' has an invalid CSS width value: '${e}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`),e)}function B(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;t._gridTemplate=i===e.STRETCH?t._visibleColumns.map(e=>{if(null!=e.width)return $(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():t._visibleColumns.map(e=>null!=e.width?$(e.width,e.field):"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}const V={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-grid-row",GROUP_ROW:"group-row",DATA_CELL:"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"},U={FIELD:"data-field",GROUP_KEY:"data-group-key"},G={ROOT:`.${V.ROOT}`,HEADER:`.${V.HEADER}`,HEADER_ROW:`.${V.HEADER_ROW}`,HEADER_CELL:`.${V.HEADER_CELL}`,ROWS_VIEWPORT:`.${V.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${V.ROWS_CONTAINER}`,DATA_ROW:`.${V.DATA_ROW}`,DATA_CELL:`.${V.DATA_CELL}`,GROUP_ROW:`.${V.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${V.DATA_CELL}[${U.FIELD}="${e}"]`,SELECTED_ROWS:`.${V.DATA_ROW}.${V.SELECTED}`,EDITING_CELL:`.${V.DATA_CELL}.${V.EDITING}`},j={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"},Y=/{{\s*([^}]+)\s*}}/g,X="__DG_EMPTY__",K=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,Z="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),Q=new RegExp(`__(proto|defineGetter|defineSetter)|${Z.slice(3).join("|")}|this\\b`),J=new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing".split("|")),ee=/^on\w+$/i,te=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),ie=/^\s*(javascript|vbscript|data|blob):/i;function re(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],i=e.querySelectorAll("*");for(const r of i){const e=r.tagName.toLowerCase();if(J.has(e)){t.push(r);continue}if("svg"===e||"http://www.w3.org/2000/svg"===r.namespaceURI){if(Array.from(r.attributes).some(e=>ee.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(r);continue}}const i=[];for(const t of r.attributes){const e=t.name.toLowerCase();ee.test(e)?i.push(t.name):(te.has(e)&&ie.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&i.push(t.name)}i.forEach(e=>r.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function ne(e,t){const i=function(e){const t=[];let i=0;for(;i<e.length;){const r=e[i];if(" "!==r){if(r>="0"&&r<="9"||"."===r&&i+1<e.length&&e[i+1]>="0"&&e[i+1]<="9"){const r=i;for(;i<e.length&&(e[i]>="0"&&e[i]<="9"||"."===e[i]);)i++;t.push({type:"num",v:Number(e.slice(r,i))});continue}if("'"===r){let r="";for(i++;i<e.length&&"'"!==e[i];)r+=e[i++];if(i>=e.length)return null;i++,t.push({type:"str",v:r});continue}if(r>="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r||"$"===r){const r=i;for(;i<e.length&&/[\w$.]/.test(e[i]);)i++;t.push({type:"id",v:e.slice(r,i)});continue}if(i+2<e.length){const r=e.slice(i,i+3);if("==="===r||"!=="===r){t.push({type:"op",v:r}),i+=3;continue}}if(i+1<e.length){const r=e.slice(i,i+2);if("=="===r||"!="===r||"<="===r||">="===r||"&&"===r||"||"===r){t.push({type:"op",v:r}),i+=2;continue}}if(!"+-*/%<>!?:(),".includes(r))return null;t.push({type:"op",v:r}),i++}else i++}return t}(e);if(!i)return;const r=i;let n=0;function o(){return r[n]}function s(){return r[n++]}function a(e,t){const i=o();return!!i&&(i.type===e&&(void 0===t||i.v===t))}function l(){const e=function(){let e=c();for(;a("op","||");)s(),e=e||c();return e}();if(a("op","?")){s();const t=l();if(!a("op",":"))return;s();const i=l();return e?t:i}return e}function c(){let e=d();for(;a("op","&&");)s(),e=e&&d();return e}function d(){let e=u();for(;;){const t=o();if(!t||"op"!==t.type)break;if("==="===t.v)s(),e=e===u();else if("!=="===t.v)s(),e=e!==u();else if("=="===t.v)s(),e=e==u();else{if("!="!==t.v)break;s(),e=e!=u()}}return e}function u(){let e=h();for(;;){const t=o();if(!t||"op"!==t.type)break;if("<"===t.v)s(),e=e<h();else if(">"===t.v)s(),e=e>h();else if("<="===t.v)s(),e=e<=h();else{if(">="!==t.v)break;s(),e=e>=h()}}return e}function h(){let e=g();for(;;){const t=o();if(!t||"op"!==t.type)break;if("+"===t.v)s(),e+=g();else{if("-"!==t.v)break;s(),e-=g()}}return e}function g(){let e=f();for(;;){const t=o();if(!t||"op"!==t.type)break;if("*"===t.v)s(),e*=f();else if("/"===t.v)s(),e/=f();else{if("%"!==t.v)break;s(),e%=f()}}return e}function f(){return a("op","!")?(s(),!f()):p()}function p(){const e=o();if(e){if("num"===e.type)return s(),e.v;if("str"===e.type)return s(),e.v;if("id"===e.type)return s(),function(e){if("value"===e)return t.value;if(e.startsWith("row.")){const i=e.slice(4);return t.row?t.row[i]:void 0}if(e.startsWith("typeDefault.")){const i=e.slice(12);return t.typeDefault?t.typeDefault[i]:void 0}return"row"===e?t.row:"typeDefault"===e?t.typeDefault:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=l();return a("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const m=l();return n<r.length?void 0:m}function oe(e,t){if(!e||-1===e.indexOf("{{"))return e;const i=[],r=e.replace(Y,(e,r)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return X;if(se.test(e))return X;if("value"===e)return null==t.value?X:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(4),r=t.row?t.row[i]:void 0;return null==r?X:String(r)}if(e.startsWith("typeDefault.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(12),r=t.typeDefault?t.typeDefault[i]:void 0;return null==r?X:String(r)}if(e.length>80)return X;if(!K.test(e)||Q.test(e))return X;const i=e.match(/\./g);if(i&&i.length>1)return X;try{const i=ne(e,t),r=null==i?"":String(i);return se.test(r)?X:r||X}catch{return X}}(r,t);return i.push({expr:r.trim(),result:n}),n}),n=(o=r)?o.replace(new RegExp(X,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):o;var o;const s=i.length&&i.every(e=>""===e.result||e.result===X);return se.test(e)||s?"":n}const se=/Reflect|Proxy|ownKeys/;function ae(e){if(se.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&se.test(t.textContent||"")&&(t.textContent="");se.test(e.textContent||"")&&(e.textContent="")}}function le(e){if(se.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>oe(e,t);return t.__blocked=!1,t}function ce(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}class de{static dependencies;static manifest;aliases;version="3.0.0-beta.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},i={};for(const r of Object.keys(t))i[r]=this;for(const r of e){const e=r.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in t)){t[n]=o,i[n]=r;continue}if(t[n]===o)continue;const e=i[n]?.constructor.name??this.constructor.name,s=r.constructor.name,a=P("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,i={...e.userConfig};for(const r of Object.keys(t))delete t[r];Object.assign(t,i)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(t,10);if(!isNaN(i))return i}return 200}setIcon(e,t,i){e.dataset.icon=ce(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const r=this.#t(t,i);void 0!==r?"string"==typeof r?e.innerHTML=re(r):r instanceof HTMLElement&&(e.innerHTML="",e.appendChild(r.cloneNode(!0))):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(i,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const r=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return r?e.insertBefore(i,r):e.appendChild(i),i}warn(e,t){void 0!==t?console.warn(P(e,t,this.gridElement.id,this.name)):console.warn(`${f(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(P(e,t,this.gridElement.id,this.name))}}const ue=/* @__PURE__ */new WeakMap;function he(e,t,i=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:i});const r=e,n=t.field;let o=ue.get(r);if(o){const e=o.get(n);if(void 0!==e)return e.v}else o=/* @__PURE__ */new Map,ue.set(r,o);const s=t.valueAccessor({row:e,column:t,rowIndex:i});return o.set(n,{v:s}),s}function ge(e,t){e&&(t?ue.get(e)?.delete(t):ue.delete(e))}function fe(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function pe(e,t,i){const r=i.find(e=>e.field===t.field),n=r?.sortComparator,{field:o,direction:s}=t,a=[...e];return n?r?.valueAccessor?a.sort((e,t)=>n(he(e,r),he(t,r),e,t)*s):a.sort((e,t)=>n(e[o],t[o],e,t)*s):r?.valueAccessor?we(a,r,s):me(a,o,s),a}function me(e,t,i){e.sort((e,r)=>{const n=be(e,r);if(0!==n)return n;const o=e[t],s=r[t];return null==o&&null==s?0:null==o?-i:null==s||o>s?i:o<s?-i:0})}function we(e,t,i){e.sort((e,r)=>{const n=be(e,r);if(0!==n)return n;const o=he(e,t),s=he(r,t);return null==o&&null==s?0:null==o?-i:null==s||o>s?i:o<s?-i:0})}function be(e,t){const i=!0===e?.__loading;return i===(!0===t?.__loading)?0:i?1:-1}function ve(e,t,i,r){const n=r.find(e=>e.field===t),o=n?.sortComparator;o?n?.valueAccessor?e.sort((e,t)=>o(he(e,n),he(t,n),e,t)*i):e.sort((e,r)=>o(e[t],r[t],e,r)*i):n?.valueAccessor?we(e,n,i):me(e,t,i)}function ye(e,t,i,r){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;Te(e),e.refreshVirtualWindow(!0),_e(e,i,r)}function _e(e,t,i){const r={field:t.field,direction:i};e.dispatchEvent(new CustomEvent("sort-change",{detail:r})),e._pluginManager?.emitPluginEvent?.("sort-change",r),o(e,s(e,0===i?"sortCleared":"sortApplied",t.header??t.field,1===i?"ascending":"descending")),e.requestStateChange?.()}function Ce(e){return e._pluginManager?._hasRowStructurePlugins??!1}function Re(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)Ee(e,t,-1);else{if(e._sortState=null,Ce(e))return e._requestSchedulerPhase(4,"sort-clear"),void _e(e,t,0);e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e._rows=e.__originalOrder.slice(),e.__originalOrder=[],Te(e);const i=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(i)for(let t=0;t<i.length;t++){const r=i[t];r.getAttribute("aria-sort")&&("ascending"!==r.getAttribute("aria-sort")&&"descending"!==r.getAttribute("aria-sort")||e._sortState)||r.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),_e(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),Ee(e,t,1)}function Ee(e,t,i){if(e._sortState={field:t.field,direction:i},Ce(e))return e._requestSchedulerPhase(4,"sort-apply"),void _e(e,t,i);const r={field:t.field,direction:i},n=e._columns,o=e.effectiveConfig?.sortHandler??pe;if(o===pe)return ve(e._rows,r.field,i,n),void ye(e,e._rows,t,i);const s=o(e._rows,r,n);s&&"function"==typeof s.then?s.then(r=>{ye(e,r,t,i)}):ye(e,s,t,i)}function Se(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function Ae(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Me(e,t){const i=document.createElement("span");q(i,"sort-indicator");const r=e._sortState?.field===t.field?e._sortState.direction:0,n=1===r?"sortAsc":-1===r?"sortDesc":"sortNone";i.dataset.icon=ce(n);const o=e.icons?.[n];return void 0!==o&&function(e,t){"string"==typeof t?e.innerHTML=re(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(i,o),i}function xe(e,t,i){const r=document.createElement("div");return r.className="resize-handle",r.setAttribute("aria-hidden","true"),r.addEventListener("mousedown",r=>{r.stopPropagation(),r.preventDefault(),e._resizeController.start(r,t,i)}),r.addEventListener("dblclick",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.resetColumn(t)}),r}function He(e,t,i,r){r.classList.add(V.SORTABLE),r.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;r.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),r.addEventListener("click",i=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(i,t,r)||Re(e,t)}),r.addEventListener("keydown",i=>{if("Enter"===i.key||" "===i.key){if(i.preventDefault(),e._dispatchHeaderClick?.(i,t,r))return;Re(e,t)}})}function Te(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((i,r)=>{const n=document.createElement("div");n.className="cell",q(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(r+1)),n.setAttribute("data-field",i.field),n.setAttribute("data-col",String(r)),i.type&&n.setAttribute("data-type",i.type);const o=i.header??i.field,s=e._sortState?.field===i.field?e._sortState.direction:0,a=1===s?"asc":-1===s?"desc":null;if(i.headerRenderer){const t={column:i,value:o,sortState:a,filterActive:!1,cellEl:n,renderSortIcon:()=>Se(e,i)?Me(e,i):null,renderFilterButton:()=>null},s=i.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const i=document.createElement("span");for(i.innerHTML=re(t);i.firstChild;)e.appendChild(i.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),Se(e,i)&&He(e,i,0,n),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}else if(i.headerLabelRenderer){const t={column:i,value:o},s=i.headerLabelRenderer(t),a=document.createElement("span");null==s?a.textContent=o:"string"==typeof s?a.innerHTML=re(s):s instanceof Node&&a.appendChild(s),n.appendChild(a),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)));else{const t=document.createElement("span");t.textContent=o,n.appendChild(t),Se(e,i)&&(He(e,i,0,n),n.appendChild(Me(e,i))),Ae(e,i)&&(n.classList.add("resizable"),n.appendChild(xe(e,r,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${V.SORTABLE}`).forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function ke(e,t){const i=e[0]||{},r=Object.keys(i).map(e=>{const t=i[e],r=null==(n=t)?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":n instanceof Date||"string"==typeof n&&/\d{4}-\d{2}-\d{2}/.test(n)&&!isNaN(Date.parse(n))?"date":"string";var n;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:r}}),n={};return r.forEach(e=>{n[e.field]=e.type||"string"}),{columns:r,typeMap:n}}const Le={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class Pe{#i;#r=0;#n=0;#o=null;#s=null;#a=null;#l=!1;constructor(e){this.#i=e}requestPhase(e,t){e>this.#r&&(this.#r=e),0===this.#n&&(this.#c(),this.#n=requestAnimationFrame(()=>this.#d()))}whenReady(){return this.#o?this.#o:Promise.resolve()}setInitialReadyResolver(e){this.#a=e}cancel(){0!==this.#n&&(cancelAnimationFrame(this.#n),this.#n=0),this.#r=0,this.#s&&(this.#s(),this.#s=null,this.#o=null)}get isPending(){return 0!==this.#r}get pendingPhase(){return this.#r}#c(){this.#o||(this.#o=new Promise(e=>{this.#s=e}))}#d(){if(this.#n=0,!this.#i._schedulerIsConnected)return this.#r=0,void(this.#s&&(this.#s(),this.#s=null,this.#o=null));const e=this.#r;this.#r=0,e>=Le.COLUMNS&&this.#i._schedulerMergeConfig(),e>=Le.ROWS&&this.#i._schedulerProcessRows(),e>=Le.COLUMNS&&(this.#i._schedulerProcessColumns(),this.#i._schedulerUpdateTemplate()),e>=Le.HEADER&&this.#i._schedulerRenderHeader(),e>=Le.VIRTUALIZATION&&this.#i.refreshVirtualWindow(!0,!0),e>=Le.STYLE&&this.#i._schedulerAfterRender();const t=!this.#l;t&&(this.#l=!0,this.#a?.()),this.#s&&(this.#s(),this.#s=null,this.#o=null),0!==e&&this.#u(e,t)}#u(e,t){const i=this.#i._virtualization,r=i?.enabled?{start:i.start,end:i.end}:null,n={phase:e,initial:t,rowCount:this.#i._rows?.length??0,visibleRange:r};this.#i._hostElement.dispatchEvent(new CustomEvent("render",{detail:n,bubbles:!0,composed:!0}))}}class De{#h;#g;#f;#p;#m;#w;#b;#v={};#y={};#_=!0;#C=[];#R;#E;#S;#A;#i;constructor(e){this.#i=e}get original(){return this.#v}get effective(){return this.#y}get columns(){return this.#y.columns??[]}set columns(e){this.#y.columns=e}get lightDomColumnsCache(){return this.#m}set lightDomColumnsCache(e){this.#m=e}get originalColumnNodes(){return this.#b}set originalColumnNodes(e){this.#b=e}get initialColumnState(){return this.#A}set initialColumnState(e){this.#A=e}get sourcesChanged(){return this.#_}markSourcesChanged(){this.#_=!0}setGridConfig(e){this.#h!==e&&(this.#h=e,this.#_=!0,this.#m=void 0)}getGridConfig(){return this.#h}setColumns(e){this.#g=e,this.#_=!0}getColumns(){return this.#g}setFitMode(e){this.#f=e,this.#_=!0}getFitMode(){return this.#f}setColumnInference(e){this.#p!==e&&(this.#p=e,this.#_=!0)}getColumnInference(){return this.#p}merge(){const e=(this.#y.columns?.length??0)>0;if(!this.#_&&e)return;const t=this.#M();this.#_=!1,this.#v=t,Object.freeze(this.#v),this.#v.columns&&Object.freeze(this.#v.columns),this.#y=this.#x(this.#v),this.#H()}#x(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#H(){const e=this.#y;if(this.#T(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#i._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width="number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:80)})}this.#i._applyAnimationConfig(e)}#T(){const e=this.#y.typeDefaults;if(!e)return;const t=this.columns;for(const i of t){if(!i.type)continue;const t=e[i.type];t&&(i.renderer||i.viewRenderer||!t.renderer||(i.renderer=t.renderer),!i.format&&t.format&&(i.format=t.format),!i.editor&&t.editor&&(i.editor=t.editor),!i.editorParams&&t.editorParams&&(i.editorParams=t.editorParams))}}#M(){const e=this.#h?{...this.#h}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#m??[]).map(e=>({...e}));let r=N(t,i);this.#g&&this.#g.length&&(r=N(this.#g,i));const n=this.#i.sourceRows;if("merge"===(this.#p??e.columnInference??"auto")&&n.length){r=function(e,t){if(!t.length)return e;const i=/* @__PURE__ */new Map;for(const o of t)i.set(o.field,o);const r=new Set(e.map(e=>e.field)),n=e.map(e=>{const t=i.get(e.field);if(!t)return e;const r={...e};for(const[i,n]of Object.entries(t))void 0!==n&&Object.assign(r,{[i]:n});return r});for(const o of t)r.has(o.field)||n.push(o);return n}(ke(n).columns,r)}else if(0===r.length&&n.length){r=ke(n).columns}if(r.length&&(!function(e){const t=[],i=[];for(const o of e)"number"==typeof o.order&&Number.isFinite(o.order)&&o.order>=0?t.push({col:o,order:Math.floor(o.order)}):i.push(o);if(0===t.length)return e;t.sort((e,t)=>e.order-t.order);const r=[];let n=0;for(const{col:o,order:s}of t){for(;r.length<s&&n<i.length;)r.push(i[n++]);const e=Math.min(s,r.length);r.splice(e,0,o)}for(;n<i.length;)r.push(i[n++]);e.length=0,e.push(...r)}(r),r.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),r.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=le(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=le(e.__editorTemplate.innerHTML))}),e.columns=r),this.#w&&Object.keys(this.#w).length>0){const t={...this.#w},i=e.typeDefaults??{};for(const e of Object.keys(i)){const r=i[e],n=t[e];t[e]=n?{...n,...r}:r}e.typeDefaults=t}return this.#f&&(e.fitMode=this.#f),e.fitMode||(e.fitMode="stretch"),this.#p&&(e.columnInference=this.#p),this.#i._pluginManager?.processConfig?.(e),e.columnState&&!this.#A&&(this.#A=e.columnState),e}collectState(e){const t=this.columns,i=this.#k();return{columns:t.map((t,r)=>{const n={field:t.field,order:r,visible:!t.hidden},o=t;void 0!==o.__renderedWidth?n.width=o.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=i.get(t.field);s&&(n.sort=s);for(const i of e)if(i.getColumnState){const e=i.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const i=this.columns,r=new Map(e.columns.map(e=>[e.field,e])),n=i.map(e=>{const t=r.get(e.field);if(!t)return e;const i={...e};return void 0!==t.width&&(i.width=t.width,i.__renderedWidth=t.width),void 0!==t.visible&&(i.hidden=!t.visible),i});n.sort((e,t)=>(r.get(e.field)?.order??1/0)-(r.get(t.field)?.order??1/0)),this.columns=n;const o=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(o.length>0){const e=o[0];e.sort&&(this.#i._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#i._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#A=void 0,this.#i._sortState=null,this.#y=this.#x(this.#v),this.#H();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#k(){const e=/* @__PURE__ */new Map,t=this.#i._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#E&&clearTimeout(this.#E),this.#E=setTimeout(()=>{this.#E=void 0;const t=this.collectState(e);this.#i._emit("column-state-change",t)},100)}setColumnVisible(e,t){const i=this.columns,r=i.find(t=>t.field===e);if(!r)return!1;if(!t&&r.lockVisible)return!1;if(!t){if(0===i.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!r.hidden!=!t&&(r.hidden=!t,this.#i._emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(e=>!e.hidden).map(e=>e.field)}),this.#i._clearRowPool(),this.#i._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#i._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#i._clearRowPool(),this.#i._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),i=[];for(const r of e){const e=t.get(r);e&&(i.push(e),t.delete(r))}for(const r of t.values())i.push(r);this.columns=i,this.#i._invalidateVisibleColumnsCache(),Te(this.#i),B(this.#i),this.#i._requestSchedulerPhase(Le.COLUMNS,"configManager")}parseLightDomColumns(e){if(this.#m||(this.#b=Array.from(e.querySelectorAll("tbw-grid-column")),this.#m=this.#b.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const i=t.includes(":")?d(t):void 0,r={field:i?.field??t,type:e.getAttribute("type")||i?.type||void 0,header:e.getAttribute("header")||i?.header||void 0,sortable:e.hasAttribute("sortable")&&"false"!==e.getAttribute("sortable"),__element:e},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?r.width=e:r.width=n}const o=e.getAttribute("minWidth")||e.getAttribute("min-width");if(o){const e=parseFloat(o);isNaN(e)||(r.minWidth=e)}const s=e.getAttribute("order");if(s){const e=parseInt(s,10);Number.isFinite(e)&&e>=0&&(r.order=e)}e.hasAttribute("resizable")&&(r.resizable="false"!==e.getAttribute("resizable"));const a=e.getAttribute("options");a&&(r.options=a.split(",").map(e=>{const[t,i]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:i?.trim()||t.trim()}}));const l=e.querySelector("tbw-grid-column-view"),c=e.querySelector("tbw-grid-column-editor"),u=e.querySelector("tbw-grid-column-header");l&&(r.__viewTemplate=l),u&&(r.__headerTemplate=u);const h=globalThis.DataGridElement,g=h?.getAdapters?.()??[],f=l??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(r.viewRenderer=e)}const m=c??e,w=g.find(e=>e.canHandle(m));if(w){const e=w.createEditor(m);e&&(r.editor=e)}const b=g.find(t=>t.canHandle(e)&&(t.createHeaderRenderer||t.createHeaderLabelRenderer));if(b){const t=b.createHeaderRenderer?.(e);t&&(r.headerRenderer=t);const i=b.createHeaderLabelRenderer?.(e);i&&(r.headerLabelRenderer=i)}return r}).filter(e=>!!e)}(e):[]),!this.#w){const t=function(e){const t=globalThis.DataGridElement,i=t?.getAdapters?.()??[];return Array.from(e.children).filter(e=>"tbw-grid-type"===e.tagName.toLowerCase()).map(e=>{const t=e.getAttribute("name")?.trim();if(!t)return null;const r=Array.from(e.children).find(e=>"tbw-grid-column-view"===e.tagName.toLowerCase()),n=r??e,o=i.find(e=>e.canHandle(n)),s=o?.createRenderer(n),a={};for(const i of Array.from(e.attributes)){if(!i.name.startsWith("data-"))continue;const e=i.name.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()).trim();e&&(a[e]=i.value)}return{name:t,params:a,viewTemplate:r,viewRenderer:s}}).filter(e=>null!==e)}(e),i={};for(const e of t){const t={};let r=!1;if(e.viewRenderer)t.renderer=e.viewRenderer,r=!0;else if(e.viewTemplate){const i=le(e.viewTemplate.innerHTML);t.renderer=t=>i({row:t.row,value:t.value,field:t.field,column:t.column,typeDefault:e.params}),r=!0}r&&(i[e.name]=t)}this.#w=i}}clearLightDomCache(){this.#m=void 0,this.#w=void 0}#L=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#L.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#L.delete(e.toLowerCase())}observeLightDOM(e){this.#R&&this.#R.disconnect();const t=/* @__PURE__ */new Set,i=()=>{this.#S=void 0;for(const e of t){const t=this.#L.get(e);t?.()}t.clear()};this.#R=new MutationObserver(e=>{for(const i of e){for(const e of i.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#L.has(i)&&t.add(i)}for(const e of i.removedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#L.has(i)&&t.add(i)}if("attributes"===i.type&&i.target.nodeType===Node.ELEMENT_NODE){const e=i.target.tagName.toLowerCase();this.#L.has(e)&&t.add(e)}}t.size>0&&!this.#S&&(this.#S=setTimeout(i,0))}),this.#R.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order","name","type"]})}onChange(e){this.#C.push(e)}notifyChange(){for(const e of this.#C)e()}dispose(){this.#R?.disconnect(),this.#C=[],this.#E&&clearTimeout(this.#E),this.#S&&(clearTimeout(this.#S),this.#S=void 0)}}function Ie(e,t){const i=document.createElement("div");return e&&(i.className=e),i}const Oe=document.createElement("template");function ze(e){const t=document.createDocumentFragment(),i=Ie(V.ROOT);{const e=Ie("tbw-grid-content");e.appendChild(Oe.content.cloneNode(!0)),i.appendChild(e)}return t.appendChild(i),t}Oe.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';function Ne(e){const t=document.createElement("div");return t.className="tbw-empty-message",t.textContent=e.filteredOut?"No matching rows":"No data to display",t}function qe(e,t,i="rows"){const r=document.createElement("div");return r.className="tbw-empty-overlay",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("data-overlay-target",i),r.appendChild(function(e,t){const i=(t??Ne)(e);if("string"==typeof i){const e=document.createElement("div");return e.className="tbw-empty-message",e.innerHTML=re(i),e}return i}(e,t)),r}function Fe(e){e?.remove()}function We(){if("undefined"!=typeof window&&window.location){const e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e||"::1"===e)return!0}return"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV}function $e(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function Be(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}function Ve(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const i=e.closest(".data-grid-row");if(!i)return-1;const r=i.parentElement;if(!r)return-1;const n=r.querySelectorAll(":scope > .data-grid-row");for(let o=0;o<n.length;o++)if(n[o]===i)return o;return-1}function Ue(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Ge(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}function je(e){return"rtl"===Ge(e)}function Ye(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function Xe(e,t){const i=t.renderer||t.viewRenderer;if(i)return i;if(!t.type)return;const r=e.__frameworkAdapter;if(r?.getTypeDefault){const i=r.getTypeDefault(t.type,e._hostElement);if(i?.renderer)return i.renderer}}function Ke(e,t){if(t.format)return t.format;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(t.type,e._hostElement);if(r?.format)return r.format}}const Ze='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function Qe(e){return(e.__editingCellCount??0)>0}function Je(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${V.EDITING}`).forEach(e=>e.classList.remove(V.EDITING))}const et=document.createElement("template");et.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const tt=document.createElement("template");function it(){return et.content.firstElementChild.cloneNode(!0)}function rt(){return tt.content.firstElementChild.cloneNode(!0)}function nt(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function ot(e,t,i,r){const n=t.children,o=e._visibleColumns,s=o.length,a=n.length,l=s<a?s:a,c=e._focusRow,d=e._focusCol,u=e._hasAfterCellRenderHook?.()??!1;let h=e.__hasSpecialColumns;if(void 0===h){h=!1;const t=e.__frameworkAdapter;for(let i=0;i<s;i++){const r=o[i];if(r.__viewTemplate||r.__compiledView||r.renderer||r.viewRenderer||r.externalView||r.format||r.cellClass||"date"===r.type||"boolean"===r.type||r.type&&t?.getTypeDefault?.(r.type,e._hostElement)?.renderer||r.type&&t?.getTypeDefault?.(r.type,e._hostElement)?.format){h=!0;break}}e.__hasSpecialColumns=h}const g=String(r);if(h){for(let s=0;s<l;s++){if(o[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void st(e,t,i,r)}}for(let s=0;s<l;s++){const a=o[s],l=n[s];l.getAttribute("data-row")!==g&&l.setAttribute("data-row",g);const h=l.classList.contains(V.EDITING);if(!h){const e=c===r&&d===s;e!==l.classList.contains("cell-focus")&&(l.classList.toggle("cell-focus",e),l.setAttribute("aria-selected",String(e)))}const p=a.cellClass;if(p){const t=l.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&l.classList.remove(e[t])}try{const e=p(he(i,a,r),i,a),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let i=0;i<t.length;i++){const r=t[i];r&&"string"==typeof r&&(l.classList.add(r),e+=(e?" ":"")+r)}l.setAttribute("data-dynamic-classes",e)}else l.removeAttribute("data-dynamic-classes")}catch(f){I(w,`cellClass callback error for column '${a.field}': ${f}`,e.id),l.removeAttribute("data-dynamic-classes")}}if(h)continue;const m=Xe(e,a);if(m){const n=he(i,a,r),o=m({row:i,value:n,field:a.field,column:a,grid:e,cellEl:l});"string"==typeof o?(e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(o)):o instanceof Node?o.parentElement!==l&&(e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML="",l.appendChild(o)):null==o&&(e.__frameworkAdapter?.releaseCell?.(l),l.textContent=null==n?"":String(n)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.__compiledView){const n=he(i,a,r),o=a.__compiledView({row:i,value:n,field:a.field,column:a});a.__compiledView.__blocked?l.textContent="":(l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(o),ae(l)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.__viewTemplate){const n=he(i,a,r),o=a.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(o)?l.textContent="":(l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l),l.innerHTML=re(oe(o,{row:i,value:n})),ae(l)),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:n,cellElement:l,rowElement:t});continue}if(a.externalView)continue;const v=he(i,a,r);let y;l.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(l);const _=Ke(e,a);if(_){try{const e=_(v,i);y=null==e?"":String(e)}catch(f){I(b,`Format error in column '${a.field}': ${f}`,e.id),y=null==v?"":String(v)}l.textContent=y}else"date"===a.type?(y=Be(v),l.textContent=y):"boolean"===a.type?l.innerHTML=$e(!!v):(y=null==v?"":String(v),l.textContent=y);u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:s,value:v,cellElement:l,rowElement:t})}}else for(let p=0;p<l;p++){const s=n[p];if(s.classList.contains(V.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const a=o[p],l=he(i,a,r);s.textContent=null==l?"":String(l),s.getAttribute("data-row")!==g&&s.setAttribute("data-row",g);const h=c===r&&d===p;h!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",h),s.setAttribute("aria-selected",String(h))),u&&e._afterCellRender?.({row:i,rowIndex:r,column:a,colIndex:p,value:l,cellElement:s,rowElement:t})}}function st(e,t,i,r){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const n=e.__frameworkAdapter;if(n?.releaseCell){n.beginBatch?.(e);try{const e=t.children;for(let t=e.length-1;t>=0;t--)n.releaseCell(e[t]);t.innerHTML=""}finally{n.endBatch?.(e)}}else t.innerHTML="";const o=e._visibleColumns,s=o.length,a=e._focusRow,l=e._focusCol,c=e._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let h=0;h<s;h++){const n=o[h],s=it();s.setAttribute("aria-colindex",String(h+1)),s.setAttribute("data-col",String(h)),s.setAttribute("data-row",String(r)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let g=he(i,n,r);const f=Ke(e,n);if(f)try{g=f(g,i)}catch(u){I(b,`Format error in column '${n.field}': ${u}`,e.id)}const p=n.__compiledView,m=n.__viewTemplate,v=Xe(e,n),y=n.externalView;let _=!1;if(v){const t=v({row:i,value:g,field:n.field,column:n,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=re(t),_=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==g?"":String(g))}else if(y){const t=y,r=document.createElement("div");r.setAttribute("data-external-view",""),r.setAttribute("data-field",n.field),s.appendChild(r);const o={row:i,value:g,field:n.field,column:n,grid:e};if(t.mount)try{t.mount({placeholder:r,context:o,spec:t})}catch(u){I("TBW063",`External view mount error for column '${n.field}': ${u}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:r,spec:t,context:o}}))}catch(u){I("TBW064",`External view event dispatch error for column '${n.field}': ${u}`,e.id)}});r.setAttribute("data-mounted","")}else if(p){const e=p({row:i,value:g,field:n.field,column:n}),t=p.__blocked;s.innerHTML=t?"":re(e),_=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(m){const e=m.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=re(oe(e,{row:i,value:g})),_=!0)}else f?s.textContent=null==g?"":String(g):"date"===n.type?s.textContent=Be(g):"boolean"===n.type?s.innerHTML=$e(!!g):s.textContent=null==g?"":String(g);if(_){ae(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof n.editable?n.editable(i):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),a===r&&l===h?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const C=n.cellClass;if(C)try{const e=C(he(i,n,r),i,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(s.classList.add(i),e+=(e?" ":"")+i);s.setAttribute("data-dynamic-classes",e)}}catch(u){I(w,`cellClass callback error for column '${n.field}': ${u}`,e.id)}c&&e._afterCellRender?.({row:i,rowIndex:r,column:n,colIndex:h,value:g,cellElement:s,rowElement:t}),d.appendChild(s)}t.appendChild(d)}function at(e,t,i){if(t.target?.closest(".resize-handle"))return;const r=Ve(i.querySelector(".cell[data-row]"));if(r<0)return;const n=e._rows[r];if(!n)return;if(e._dispatchRowClick?.(t,r,n,i))return;const o=t.target?.closest(".cell[data-col]");if(o){const i=Number(o.getAttribute("data-col"));if(!isNaN(i)){if(e._dispatchCellClick?.(t,r,i,o))return;const n=e._focusRow!==r||e._focusCol!==i;if(e._focusRow=r,e._focusCol=i,o.classList.contains(V.EDITING)){n&&(Ue(e._bodyEl??e),o.classList.add("cell-focus"));const i=t.target,r=o.contains(i)&&i.matches(Ze)?i:o.querySelector(Ze);try{r?.focus({preventScroll:!0})}catch{}return}_t(e)}}}function lt(e,t){return e&&"object"==typeof e?"__rowCacheKey"in e?e.__rowCacheKey:"rowId"in e&&null!=e.rowId?`id:${e.rowId}`:t?`id:${t(e)}`:e:e}function ct(e,t,i){const r=lt(t,i);return"string"==typeof r?e.byKey.get(r):r&&"object"==typeof r?e.byRef.get(r):void 0}function dt(e,t,i){if(t<0||t>=e.length)return;const r=e[t],n=i-r.height;if(0!==n){r.height=i,r.measured=!0;for(let i=t+1;i<e.length;i++)e[i].offset+=n}}function ut(e,t){if(0===e.length)return-1;if(t<=0)return 0;let i=0,r=e.length-1;for(;i<=r;){const n=Math.floor((i+r)/2),o=e[n],s=o.offset+o.height;if(t<o.offset)r=n-1;else{if(!(t>=s))return n;i=n+1}}return Math.max(0,Math.min(i,e.length-1))}function ht(e,t){const{positionCache:i,heightCache:r,rows:n,start:o,end:s,getPluginHeight:a,getRowId:l}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<o||d>=s||d>=n.length)return;const u=n[d],h=a?.(u,d);if(void 0!==h){const e=i[d];return void((!e.measured||Math.abs(e.height-h)>1)&&(dt(i,d,h),c=!0))}const g=e.offsetHeight;if(g>0){const e=i[d];(!e.measured||Math.abs(e.height-g)>1)&&(dt(i,d,g),function(e,t,i,r){const n=lt(t,r);"string"==typeof n?e.byKey.set(n,i):n&&"object"==typeof n&&e.byRef.set(n,i)}(r,u,g,l),c=!0)}});const d=c?function(e){let t=0;for(const i of e)i.measured&&t++;return t}(i):0,u=c?function(e,t){let i=0,r=0;for(const n of e)n.measured&&(i+=n.height,r++);return r>0?i/r:t}(i,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:u}}tt.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const gt=335e5;function ft(e,t,i=gt){return{rawContentHeight:e,spacerHeight:Math.min(e,i),viewportHeight:t,capped:e>i}}function pt(e,t){if(!t.capped)return e;const i=t.spacerHeight-t.viewportHeight,r=t.rawContentHeight-t.viewportHeight;if(i<=0||r<=0)return e;const n=e*r/i;return n<0?0:n>r?r:n}function mt(e,t){if(!t.capped)return e;const i=t.spacerHeight-t.viewportHeight,r=t.rawContentHeight-t.viewportHeight;return i<=0||r<=0?e:e*i/r}function wt(e){const{totalRows:t,viewportHeight:i,scrollTop:r,rowHeight:n,overscan:o,maxSpacerHeight:s=gt}=e,a=Math.ceil(i/n),l=t*n,c=ft(l,i,s),d=pt(r,c);let u=Math.floor(d/n)-o;u<0&&(u=0);let h=u+a+2*o;return h>t&&(h=t),h===t&&u>0&&(u=Math.max(0,h-a-2*o)),{start:u,end:h,offsetY:u*n,totalHeight:c.spacerHeight,rawContentHeight:l}}function bt(e,t){return e<=t}function vt(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function yt(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function _t(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:i,viewportEl:r,scrollMapping:n}=e._virtualization,o=i,s=r?.clientHeight??o?.clientHeight??0;if(o&&s>0){const i=e._focusRow*t,r=n?pt(o.scrollTop,n):o.scrollTop;if(i<r)o.scrollTop=n?mt(i,n):i;else if(i+t>r+s){const e=i-s+t;o.scrollTop=n?mt(e,n):e}}}const i=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;i||e.refreshVirtualWindow(!1),Ue(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const r=e._focusRow,n=e._virtualization.start??0,o=e._virtualization.end??e._rows.length;if(r>=n&&r<o){const o=e._bodyEl.querySelectorAll(".data-grid-row")[r-n];let s=o?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=o?.querySelector(`.cell[data-col="${e._focusCol}"]`)??o?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const r=e.querySelector(".tbw-scroll-area");if(r&&s&&(!i||t?.forceHorizontalScroll))if(t?.forceScrollLeft)r.scrollLeft=0;else if(t?.forceScrollRight)r.scrollLeft=r.scrollWidth-r.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(o??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),i=r.getBoundingClientRect(),n=e.left-i.left+r.scrollLeft,o=n+e.width,a=r.scrollLeft+t.left,l=r.scrollLeft+r.clientWidth-t.right;n<a?r.scrollLeft=n-t.left:o>l&&(r.scrollLeft=o-r.clientWidth+t.right)}}if(i&&s.classList.contains(V.EDITING)){const e=s.querySelector(Ze);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(i&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!i){const t=document.activeElement;t instanceof HTMLElement&&t!==e&&"function"==typeof e.contains&&e.contains(t)&&!t.classList.contains("cell")&&!t.closest(".cell")||t===e||e.focus({preventScroll:!0})}}}}const Ct=/* @__PURE__ */new WeakMap;function Rt(e,t){const i=Ve(t),r=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(i<0||r<0)return;e._focusRow=i,e._focusCol=r,Ue(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid, [data-tbw-grid]");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Et(e,t,i,r){let n=null;const o=i.composedPath?.();if(n=o&&o.length>0?o[0]:i.target,n&&!t.contains(n)){const e=document.elementFromPoint(i.clientX,i.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),a=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let c,d,u,h,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=e._rows[c],f=e._visibleColumns[d],h=f?.field,g=u&&h?u[h]:void 0)),{type:r,row:u,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:h,value:g,column:f,originalEvent:i,cellElement:s??void 0,rowElement:a??void 0,isHeader:!!l,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function St(e,t,i,r){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const i=e._rows.length-1,r=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,o=e._visibleColumns[e._focusCol],s=o?.type,a=t.composedPath?.()??[],l=a.length?a[0]:t.target;if((!l||l===e||l.closest?.(".rows-body"))&&(!yt(l)||"Home"!==t.key&&"End"!==t.key)&&!(yt(l)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===l.tagName&&"number"===l.type||yt(l)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||yt(l)&&("Enter"===t.key||"Escape"===t.key)||n&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&(e._activeEditRows===e._focusRow&&vt(e),e._focusRow-=1,e._focusCol=r):e._focusCol<r?e._focusCol+=1:(vt(e),e._focusRow<i&&(e._focusRow+=1,e._focusCol=0)),void _t(e);case"ArrowDown":n&&vt(e),e._focusRow=Math.min(i,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&vt(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const i=je(e);e._focusCol=i?Math.max(0,e._focusCol-1):Math.min(r,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const i=je(e);e._focusCol=i?Math.min(r,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&vt(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void _t(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&vt(e),e._focusRow=i,e._focusCol=r):e._focusCol=r,t.preventDefault(),void _t(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(i,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const i=e._focusRow,r=e._focusCol,n=e._visibleColumns[r],o=e._rows[i],s=n?.field??"",a=s&&o?o[s]:void 0,l=e.querySelector(`[data-row="${i}"][data-col="${r}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:i,colIndex:r,column:n,field:s,value:a,row:o,cellEl:l,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}_t(e)}}(e,t),{signal:r}),i.addEventListener("mousedown",t=>function(e,t,i){const r=Et(e,t,i,"mousedown");e._dispatchCellMouseDown?.(r)&&Ct.set(e,!0)}(e,i,t),{signal:r}),document.addEventListener("mousemove",t=>function(e,t,i){if(!Ct.get(e))return;const r=Et(e,t,i,"mousemove");e._dispatchCellMouseMove?.(r)}(e,i,t),{signal:r}),document.addEventListener("mouseup",t=>function(e,t,i){if(!Ct.get(e))return;const r=Et(e,t,i,"mouseup");e._dispatchCellMouseUp?.(r),Ct.set(e,!1)}(e,i,t),{signal:r})}let At;function Mt(e){At=e}class xt{#i;#P=/* @__PURE__ */new Set;#D=/* @__PURE__ */new Map;#I=null;#O=null;constructor(e){this.#i=e,this.#z()}focusCell(e,t){const i=this.#i,r=i._rows.length-1;if(r<0)return;let n;if("string"==typeof t){if(n=i._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const o=i._visibleColumns.length-1;o<0||(i._focusRow=Math.max(0,Math.min(e,r)),i._focusCol=Math.max(0,Math.min(n,o)),_t(i))}get focusedCell(){const e=this.#i;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const i=this.#i._virtualization;if(!i.enabled)return;const r=i.container;if(!r)return;const n=this.#i._rows.length;if(0===n)return;const o=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",a=t?.behavior??"instant";let l,c;const d=i.positionCache;i.variableHeights&&d&&d.length>o?(l=d[o].offset,c=d[o].height):(l=o*i.rowHeight,c=i.rowHeight);const u=i.viewportEl?.clientHeight??r.clientHeight??0;if(u<=0)return;const h=r.scrollTop,g=l+c,f=h+u;let p;switch(s){case"start":p=l;break;case"center":p=l-u/2+c/2;break;case"end":p=g-u;break;default:if(l>=h&&g<=f)return;p=l<h?l:g-u}p=Math.max(0,p);const m=mt(p,i.scrollMapping);"smooth"===a?r.scrollTo({top:m,behavior:"smooth"}):r.scrollTop=m}scrollToRowById(e,t){const i=this.#i._getRowEntry(e);i&&this.scrollToRow(i.index,t)}registerExternalFocusContainer(e){if(this.#P.has(e))return;this.#P.add(e);const t=new AbortController,i=t.signal,r=this.#i;e.addEventListener("focusin",e=>{r.dataset.hasFocus="",this.#N(e.target)},{signal:i}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete r.dataset.hasFocus,null===t&&this.#q()},{signal:i}),this.#D.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#P.delete(e);const t=this.#D.get(e);t&&(t(),this.#D.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#i.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#P)if(t.contains(e))return!0;return!1}#z(){const e=this.#i,t=new AbortController,i=t.signal;e.addEventListener("focusin",e=>this.#N(e.target),{signal:i,capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#q()},{signal:i}),this.#O=()=>t.abort()}#N(e){if(!(e instanceof HTMLElement))return;if(e===this.#i)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#I=e)}#q(){queueMicrotask(()=>{if(!this.#i.isConnected)return;document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#I;if(!e)return!1;if(!e.isConnected)return this.#I=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#I?.isConnected?this.#I:null}destroy(){for(const e of this.#D.values())e();this.#D.clear(),this.#P.clear(),this.#O?.(),this.#O=null,this.#I=null}}const Ht="function"==typeof requestIdleCallback;function Tt(e){Ht?cancelIdleCallback(e):clearTimeout(e)}function kt(e,t){if(t){const i=t({size:e});if("string"==typeof i){const e=document.createElement("div");return e.innerHTML=i,e}return i}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Lt(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="tbw-row-loading-spinner",t.appendChild(i),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}function Pt(e){let t=null,i=null,r=null,n=null;const o=r=>{if(!t)return;const n=r.clientX-t.startX,o=e._visibleColumns[t.colIndex],s="number"==typeof o?.minWidth&&Number.isFinite(o.minWidth)&&o.minWidth>0?o.minWidth:40,a=Math.max(s,t.startWidth+n);o.width=a,o.__userResized=!0,o.__renderedWidth=a,null==i&&(i=requestAnimationFrame(()=>{i=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:o.field,width:a}}))};let s=!1;const a=()=>{const i=null!==t;i&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),null!==r&&(document.documentElement.style.cursor=r,r=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,i&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(i,s,l){i.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,i){const r=i.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const i=e._visibleColumns[n];if(null==i.width&&!i.__userResized){const e=r[n],t=e?.getBoundingClientRect().width;t&&(i.width=Math.round(t),i.__userResized=!0,i.__renderedWidth=i.width)}}}(s,c);const d=e._visibleColumns[s],u="number"==typeof d?.width?d.width:void 0,h=d?.__renderedWidth??u??l.getBoundingClientRect().width;t={startX:i.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),null===r&&(r=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===n&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const i=e._visibleColumns[t];i&&(i.__userResized=!1,i.__renderedWidth=void 0,i.width=i.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:i.field,width:i.width}})))},dispose(){a()}}}const Dt="data-animating",It={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ot={change:500,insert:300,remove:200};function zt(e,t){const i=It[t],r=getComputedStyle(e).getPropertyValue(i);if(r){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(r);if(!isNaN(e)&&e>0)return e}return Ot[t]}function Nt(e,t,i){if(t<0)return Promise.resolve(!1);const r=e.findRenderedRowElement?.(t);return r?new Promise(e=>{!function(e,t,i){e.removeAttribute(Dt),e.offsetWidth,e.setAttribute(Dt,t);const r=zt(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Dt),i?.()},r)}(r,i,()=>e(!0))}):Promise.resolve(!1)}function qt(e,t){if(t)return t(e);const i=e;return"id"in i&&null!=i.id?String(i.id):"_id"in i&&null!=i._id?String(i._id):void 0}function Ft(e,t,i){const r=qt(e,i);return void 0===r&&D("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),r}class Wt{#i;constructor(e){this.#i=e}resolveRowId(e){return Ft(e,this.#i.id,this.#i.effectiveConfig?.getRowId)}getRow(e){return this.#i._getRowEntry(e)?.row}getRowEntry(e){return this.#i._getRowEntry(e)}#F(e,t,i,r,n){const o=this.#i,s=[];for(const[a,l]of Object.entries(r)){if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=t[a];if(c===l)continue;const d=o.query?.("commitCellValue",{rowIndex:i,rowId:e,field:a,oldValue:c,newValue:l,source:n});d?.includes(!1)||(d?.includes(!0)||(t[a]=l,ge(t,a)),s.push({field:a,oldValue:c,newValue:l}),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:e,rowIndex:i,field:a,oldValue:c,newValue:l,changes:r,source:n},bubbles:!0,composed:!0})))}return s}updateRow(e,t,i="api"){const r=this.#i,n=r._getRowEntry(e);n||D(m,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,r.id);const{row:o,index:s}=n;this.#F(e,o,s,t,i).length>0&&(nt(r),r._requestSchedulerPhase(Le.VIRTUALIZATION,"updateRow"),r._emitDataChange())}updateRows(e,t="api"){const i=this.#i;let r=!1;for(const{id:n,changes:o}of e){const e=i._getRowEntry(n);e||D(m,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:s,index:a}=e;this.#F(n,s,a,o,t).length>0&&(r=!0)}r&&(nt(i),i._requestSchedulerPhase(Le.VIRTUALIZATION,"updateRows"),i._emitDataChange())}async insertRow(e,t,i=!0){const r=this.#i,n=Math.max(0,Math.min(e,r._rows.length));r.sourceRows=[...r.sourceRows,t];const o=[...r._rows];o.splice(n,0,t),r._rows=o,r._sortState&&(r.__originalOrder=[...r.__originalOrder,t]),nt(r),r._rebuildRowIdMap(),r.__rowRenderEpoch++;for(let s=0;s<r._rowPool.length;s++)r._rowPool[s].__epoch=-1;r.refreshVirtualWindow(!0),r._emitPluginEvent("row-inserted",{row:t,index:n}),r._emitDataChange(),i&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Nt(r,n,"insert"))}async removeRow(e,t=!0){const i=this.#i,r=i._rows[e];if(!r)return;t&&await Nt(i,e,"remove");const n=i._rows.indexOf(r);if(n<0)return r;const o=[...i._rows];o.splice(n,1),i._rows=o;const s=i.sourceRows.indexOf(r);if(s>=0){const e=[...i.sourceRows];e.splice(s,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(r);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}nt(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let a=0;a<i._rowPool.length;a++)i._rowPool[a].__epoch=-1;return i.refreshVirtualWindow(!0),i._emitDataChange(),t&&requestAnimationFrame(()=>{const e=i.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),r}async applyTransaction(e,t=!0){const i=this.#i,r={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:a}of e.remove){const e=i._getRowEntry(a);if(!e)continue;const{row:n}=e;if(t){const e=i._rows.indexOf(n);e>=0&&await Nt(i,e,"remove")}const o=i._rows.indexOf(n);if(o<0){r.removed.push(n);continue}const s=[...i._rows];s.splice(o,1),i._rows=s;const l=i.sourceRows.indexOf(n);if(l>=0){const e=[...i.sourceRows];e.splice(l,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(n);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}r.removed.push(n)}const n=new Set(e.remove?.map(e=>e.id));if(e.update?.length)for(const{id:a,changes:l}of e.update){if(n.has(a))continue;const e=i._getRowEntry(a);if(!e)continue;const{row:t,index:o}=e;let s=!1;for(const[r,n]of Object.entries(l)){const e=t[r];e!==n&&(s=!0,t[r]=n,ge(t,r),i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:a,rowIndex:o,field:r,oldValue:e,newValue:n,changes:l,source:"api"},bubbles:!0,composed:!0})))}s&&r.updated.push(t)}if(e.add?.length)for(const a of e.add){i.sourceRows=[...i.sourceRows,a];const e=[...i._rows];e.push(a),i._rows=e,i._sortState&&(i.__originalOrder=[...i.__originalOrder,a]),r.added.push(a)}const o=r.added.length>0||r.removed.length>0,s=r.updated.length>0;if(o){nt(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let e=0;e<i._rowPool.length;e++)i._rowPool[e].__epoch=-1;i.refreshVirtualWindow(!0)}else s&&(nt(i),i._requestSchedulerPhase(Le.VIRTUALIZATION,"applyTransaction"));if((o||s)&&i._emitDataChange(),t&&r.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of r.added){const t=i._rows.indexOf(e);t>=0&&await Nt(i,t,"insert")}}if(t&&r.updated.length>0)for(const a of r.updated){const e=i._rows.indexOf(a);e>=0&&await Nt(i,e,"change")}return t&&r.removed.length>0&&requestAnimationFrame(()=>{const e=i.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),r}#W=null;#$=[];#B=null;applyTransactionAsync(e){return this.#W||(this.#W={add:[],update:[],remove:[]}),e.add&&this.#W.add.push(...e.add),e.update&&this.#W.update.push(...e.update),e.remove&&this.#W.remove.push(...e.remove),new Promise(e=>{this.#$.push(e),null===this.#B&&(this.#B=requestAnimationFrame(()=>{this.#B=null;const e=this.#W,t=this.#$;this.#W=null,this.#$=[],this.applyTransaction(e,!1).then(e=>{for(const i of t)i(e)})}))})}}const $t="tbw-grid-styles";let Bt="";const Vt=/* @__PURE__ */new Map;function Ut(){const e=function(){const e=si.activeTag;return e===si.tagName?$t:`${$t}-${e}`}();let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function Gt(e){const t=si.activeTag;return t===si.tagName?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function jt(){const e=Ut(),t=Array.from(Vt.values()).join("\n");e.textContent=`${Bt}\n\n/* Plugin Styles */\n${t}`}async function Yt(e){if(Bt)return;if("string"==typeof e&&e.length>0)return Bt=Gt(e),void jt();await new Promise(e=>setTimeout(e,50));const t=function(){try{for(const e of Array.from(document.styleSheets))try{const t=Array.from(e.cssRules||[]).map(e=>e.cssText).join("\n");if(t.includes(".tbw-grid-root")&&t.includes("tbw-grid"))return t}catch{continue}}catch(e){I("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(Bt=Gt(t),jt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||I("TBW121",`Could not find grid.css in document.styleSheets. Grid styling will not work. Available stylesheets: ${Array.from(document.styleSheets).map(e=>e.href||"(inline)").join(", ")}`)}function Xt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function Kt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Zt(e,t){if(null!==e.lastTime){performance.now()-e.lastTime>60&&(e.velocityY=0,e.velocityX=0)}(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const i=.95,r=1;let n=performance.now();const o=()=>{const s=performance.now(),a=s-n;n=s;const l=a/16,c=Math.pow(i,l);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,u=16*e.velocityX,h=Math.abs(d)>=r,g=Math.abs(u)>=r;h&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=u),e.momentumRaf=h||g?requestAnimationFrame(o):0};e.momentumRaf=requestAnimationFrame(o)}(e,t),Xt(e)}function Qt(e,t,i,r){e.addEventListener("pointerdown",i=>{"touch"===i.pointerType&&null===t.activePointerId&&(t.activePointerId=i.pointerId,e.setPointerCapture(i.pointerId),function(e,t,i){Kt(i),i.startY=t,i.startX=e,i.lastY=t,i.lastX=e,i.lastTime=performance.now(),i.velocityY=0,i.velocityX=0,i.locked=!1}(i.clientX,i.clientY,t))},{passive:!0,signal:r}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const r=function(e,t,i,r){if(null===i.lastY||null===i.lastX)return!1;const n=performance.now(),o=i.lastY-t,s=i.lastX-e;if(null!==i.lastTime){const e=n-i.lastTime;e>0&&(i.velocityY=o/e,i.velocityX=s/e)}if(i.lastY=t,i.lastX=e,i.lastTime=n,i.locked){const{scrollTop:e,scrollHeight:t,clientHeight:i}=r.fauxScrollbar;if(o>0&&e<t-i||o<0&&e>0?r.fauxScrollbar.scrollTop+=o:0!==o&&window.scrollBy(0,o),r.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:i}=r.scrollArea;s>0&&e<t-i||s<0&&e>0?r.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const a=null!==i.startY?Math.abs(i.startY-t):0,l=null!==i.startX?Math.abs(i.startX-e):0;if(a<3&&l<3)return!1;const c=a>=l,{scrollHeight:d,clientHeight:u}=r.fauxScrollbar,h=d-u>0;let g=!1;if(r.scrollArea){const{scrollWidth:e,clientWidth:t}=r.scrollArea;g=e-t>0}return!!(c&&h||!c&&g)&&(i.locked=!0,r.fauxScrollbar.scrollTop+=o,r.scrollArea&&(r.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,i);r&&e.preventDefault()},{passive:!1,signal:r}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Zt(t,i))},{passive:!0,signal:r}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Xt(t))},{passive:!0,signal:r}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Xt(t))},{passive:!0,signal:r})}const Jt=[{property:"editable",pluginName:"editing",level:"column",description:"",isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:""},{property:"editorParams",pluginName:"editing",level:"column",description:""},{property:"group",pluginName:"groupingColumns",level:"column",description:""},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:"",isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],ei=[{property:"rowEditable",pluginName:"editing",level:"config",description:"",isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:"",isUsed:e=>Array.isArray(e)&&e.length>0}];function ti(e){return`import { ${ii(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function ii(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ri(e,t){return e.some(e=>e.name===t)}class ni{#i;state;constructor(e,t){this.#i=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:/* @__PURE__ */new Map,byRef:/* @__PURE__ */new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,scrollMapping:{rawContentHeight:0,spacerHeight:0,viewportHeight:0,capped:!1},...t}}updateCachedGeometry(){const e=this.state,t=e.container,i=e.viewportEl??t;i&&(e.cachedViewportHeight=i.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const r=e.scrollAreaEl;r&&(e.cachedScrollAreaHeight=r.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const i=this.state;let r,n,o;if(t){const e=i.container??this.#i._hostElement,t=i.viewportEl??e,s=i.scrollAreaEl;r=e?.clientHeight??0,n=t?.clientHeight??0,o=s?s.clientHeight:r,i.cachedFauxHeight=r,i.cachedViewportHeight=n,i.cachedScrollAreaHeight=o}else r=i.cachedFauxHeight,n=i.cachedViewportHeight,o=i.cachedScrollAreaHeight||r;const s=o-n,a=Math.max(0,r-o);let l;return l=i.variableHeights&&i.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(i.positionCache):e*i.rowHeight,i.scrollMapping=ft(l,n),i.scrollMapping.spacerHeight+s+a}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#i,i=t._rows,r=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,o=t.effectiveConfig?.getRowId,s=o?e=>o(e):void 0;e.positionCache=function(e,t,i,r,n){const o=new Array(e.length);let s=0;for(let a=0;a<e.length;a++){const l=e[a];let c=n?.(l,a),d=void 0!==c;void 0===c&&(c=ct(t,l,r.rowId),d=void 0!==c),void 0===c&&(c=i,d=!1),o[a]={offset:s,height:c,measured:d},s+=c}return o}(i,e.heightCache,r,{rowId:s},(e,i)=>{const r=t._getPluginRowHeight(e,i);if(void 0!==r)return r;if(n){const t=n(e,i);if(void 0!==t&&t>0)return t}});const a=function(e,t,i,r){let n=0,o=0;for(let s=0;s<e.length;s++){const i=e[s];if(i.measured){const e=r?.(t[s],s);void 0===e&&(o+=i.height,n++)}}return{measuredCount:n,averageHeight:n>0?o/n:i}}(e.positionCache,i,r,(e,i)=>t._getPluginRowHeight(e,i));e.measuredCount=a.measuredCount,a.measuredCount>0&&(e.averageHeight=a.averageHeight)}invalidateRowHeight(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const r=this.#i._rows;if(e<0||e>=r.length)return;const n=r[e];let o=t;void 0===o&&(o=this.#i._getPluginRowHeight(n,e)),void 0===o&&(o=i.rowHeight);const s=i.positionCache[e];if(s&&!(Math.abs(s.height-o)<1)&&(dt(i.positionCache,e,o),i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(r.length);i.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const r=this.#i,n=r._bodyEl;if(!n)return;const o=n.querySelectorAll(".data-grid-row"),s=r.effectiveConfig?.getRowId,a=r._rows,l=ht({positionCache:i.positionCache,heightCache:i.heightCache,rows:a,defaultHeight:i.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>r._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},o);if(l.hasChanges&&(i.measuredCount=l.measuredCount,i.averageHeight=l.averageHeight,i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(a.length);i.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const i=this.state,r=this.#i,n=r._bodyEl;if(!n)return!1;const o=r._rows.length;if(!i.enabled)return r._renderVisibleRows(0,o),t||r._afterPluginRender(),!0;if(o<=i.bypassThreshold)return i.start=0,i.end=o,e&&(n.style.transform="translateY(0px)"),r._renderVisibleRows(0,o,r.__rowRenderEpoch),e&&i.variableHeights&&this.initializePositionCache(),e&&i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(o,!0)}px`),r._updateAriaCounts(o,r._visibleColumns.length),t||r._afterPluginRender(),!0;const s=i.container,a=i.viewportEl??s,l=e?i.cachedViewportHeight=a.clientHeight:i.cachedViewportHeight||(i.cachedViewportHeight=a.clientHeight),c=i.rowHeight,d=pt(s.scrollTop,i.scrollMapping);let u;e&&i.variableHeights&&this.initializePositionCache();const h=i.positionCache;i.variableHeights&&h&&h.length>0?(u=ut(h,d),-1===u&&(u=0)):u=Math.floor(d/c),u-=u%2,u<0&&(u=0),o>0&&u>o-1&&(u=o-1);const g=r._adjustPluginVirtualStart(u,d,c);let f;if(void 0!==g&&g<u&&(u=g,u-=u%2,u<0&&(u=0)),i.variableHeights&&h&&h.length>0){const e=l+3*c;let t=0;for(f=u;f<o&&t<e;)t+=h[f].height,f++;const i=Math.ceil(l/c)+3;f-u<i&&(f=Math.min(u+i,o))}else{f=u+(Math.ceil(l/c)+3)}f>o&&(f=o);const p=i.start,m=i.end;if(!e&&u===p&&f===m)return!1;i.start=u,i.end=f;const w=e?i.cachedFauxHeight=s.clientHeight:i.cachedFauxHeight||(i.cachedFauxHeight=s.clientHeight);if(e){const e=i.scrollAreaEl;e&&(i.cachedScrollAreaHeight=e.clientHeight)}if(0===w&&l>0)return r._requestSchedulerPhase(Le.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&i.totalHeightEl){const e=this.calculateTotalSpacerHeight(o);i.totalHeightEl.style.height=`${e}px`}let b;b=i.variableHeights&&h&&h[u]?h[u].offset:u*c;const v=-(d-b);return n.style.transform=`translateY(${v}px)`,r._renderVisibleRows(u,f,r.__rowRenderEpoch),e&&i.variableHeights&&this.measureRenderedRowHeights(u,f),r._updateAriaCounts(o,r._visibleColumns.length),e&&!t&&(r._afterPluginRender(),queueMicrotask(()=>{if(!i.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(o);0===i.cachedFauxHeight&&i.cachedViewportHeight>0||(i.totalHeightEl.style.height=`${e}px`)})),!0}}class oi{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=/* @__PURE__ */new Map;cellRenderers=/* @__PURE__ */new Map;headerRenderers=/* @__PURE__ */new Map;cellEditors=/* @__PURE__ */new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;_hasProcessRows=!1;_hasRowStructurePlugins=!1;#V=/* @__PURE__ */new Map;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;attachAll(e){const t=this.#U(e);for(const i of t)this.attach(i)}#U(e){if(e.length<2)return e;const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,r=[];for(const n of e){const e=n.constructor,o=t.get(e);if(!o){t.set(e,n),r.push(n);continue}const s=i.get(o)??[];s.push(n),i.set(o,s)}if(0===i.size)return r;for(const[n,o]of i)n.mergeConfigsFrom(o);return r}attach(e){if(function(e,t,i){const r=e.name,n=e.constructor.dependencies??[];for(const o of n){if(o.when&&!o.when(e.resolvedConfig))continue;const n=o.name,s=o.required??!0,a=o.reason;if(t.some(e=>e.name===n))continue;const l=o.severity??(s?"error":void 0);if(!l)continue;const c="error"===l?"requires":"recommends",d=a??`${ii(r)}Plugin ${c} ${ii(n)}Plugin`;if("error"===l){const e=ti(n);D("TBW020",`Plugin dependency error:\n\n${d}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${ii(r)}Plugin:\n ${e}\n plugins: [new ${ii(n)}Plugin(), new ${ii(r)}Plugin()]`,i)}else We()&&("warn"===l?I(p,`${d}.`,i):O(p,`${d}.`,i))}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,i);if(e.headerRenderers)for(const[t,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,i);if(e.cellEditors)for(const[t,i]of Object.entries(e.cellEditors))this.cellEditors.set(t,i);this.registerQueryHandlers(e),e.attach(this.grid),this.#G();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const i of t.queries){let t=this.queryHandlers.get(i.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(i.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,i]of this.queryHandlers)i.delete(e),0===i.size&&this.queryHandlers.delete(t)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1,this._hasProcessRows=!1,this.#V.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(e))}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){if(!this._hasProcessRows)return e;let t=e;for(const i of this.#j("processRows")){const e=i.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const i of this.#j("processColumns"))t=i.processColumns(t);return t}processConfig(e){for(const t of this.#j("processConfig"))t.processConfig(e)}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterStructuralRender(){for(const e of this.#j("afterStructuralRender"))e.afterStructuralRender()}beforeStructuralRender(){for(const e of this.plugins)e.beforeStructuralRender?.()}parseLightDom(){for(const e of this.plugins)e.parseLightDom?.()}syncLightDom(){for(const e of this.plugins)e.syncLightDom?.()}needsStructuralRerender(){let e=!1;for(const t of this.plugins)t.needsStructuralRerender?.()&&(e=!0);return e}afterRender(){for(const e of this.#j("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#j("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#j("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#G(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender),this._hasProcessRows=this.plugins.some(e=>"function"==typeof e.processRows),this._hasRowStructurePlugins=this.plugins.some(e=>!0===e.constructor.manifest?.modifiesRowStructure),this.#V.clear()}#j(e){let t=this.#V.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const i=t=>{const i=t.constructor.manifest?.hookPriority;if(!i)return 0;return i[e]??0};return t.some(e=>0!==i(e))&&t.sort((e,t)=>i(e)-i(t)),this.#V.set(e,t),t}onScrollRender(){for(const e of this.#j("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const i of this.plugins)if("function"==typeof i.getRowHeight){const r=i.getRowHeight(e,t);if(void 0!==r)return r}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,i){let r=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const o=n.adjustVirtualStart(e,t,i);o<r&&(r=o)}return r}renderRow(e,t,i){for(const r of this.plugins)if(r.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const r of i){const i=r.handleQuery?.(e);void 0!==i&&t.push(i)}return t}for(const r of this.plugins){const i=r.handleQuery?.(e);void 0!==i&&t.push(i)}return t}subscribe(e,t,i){let r=this.eventListeners.get(t);r||(r=/* @__PURE__ */new Map,this.eventListeners.set(t,r)),r.set(e,i)}unsubscribe(e,t){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,i]of this.eventListeners)i.delete(e),0===i.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const i=this.eventListeners.get(e);if(i)for(const n of i.values())try{n(t)}catch(r){z("TBW024",`Error in plugin event handler for "${e}": ${r}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#j("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#j("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#j("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#j("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#j("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#j("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#j("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#j("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let i=0,r=0,n=!1;for(const o of this.plugins){const s=o.getHorizontalScrollOffsets?.(e,t);s&&(i+=s.left,r+=s.right,s.skipScroll&&(n=!0))}return{left:i,right:r,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const i=t.getToolPanel?.();i&&e.push({plugin:t,panel:i})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const i=t.getHeaderContent?.();i&&e.push({plugin:t,content:i})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class si extends HTMLElement{static tagName="tbw-grid";static version="3.0.0-beta.3";static activeTag="tbw-grid";static#Y=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","column-inference","loading"]}get#X(){return this}#K=!1;#o;#s;#Z=[];get#y(){return this.#Q?.effective??{}}#J=!1;#ee=!1;#te={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1};#ie;#re=0;#ne=null;#oe=!1;#se=!1;#ae=0;#le;#ce={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#de;#ue;#he;#ge;#fe={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#pe;#me;#we;#be;#ve;#ye;get _pluginManager(){return this.#pe}#_e=!1;#Ce;#Re;#A;#Q;#Ee=/* @__PURE__ */new Map;#Se=!1;#Ae=/* @__PURE__ */new Set;#Me=/* @__PURE__ */new Map;#xe;#He={};#Te=/* @__PURE__ */new Map;#ke=!1;_rows=[];#Le=[];get _columns(){return this.#y.columns??[]}set _columns(e){this.#y.columns=e,this.#Pe=void 0}#Pe;get _visibleColumns(){return this.#Pe??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Pe=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#be.state}set _virtualization(e){Object.assign(this.#be.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#Q?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#Q&&(this.#Q.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#Q?.originalColumnNodes}set __originalColumnNodes(e){this.#Q&&(this.#Q.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],i=this.#Z;this.#Z=t,i!==t&&this.#De("rows")}get sourceRows(){return this.#Z}set sourceRows(e){this.#Z=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=Array.isArray(e)?u(e):e,i=this.#Q?.getColumns();this.#Q?.setColumns(t),i!==t&&this.#De("columns")}get gridConfig(){return this.#y}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#Q?.getGridConfig();this.#Q?.setGridConfig(e),t!==e&&(this.#Q.clearLightDomCache(),this.#De("gridConfig"))}get _sourceConfig(){return this.#Q?.getGridConfig()}get fitMode(){return this.#y.fitMode??"stretch"}set fitMode(e){const t=this.#Q?.getFitMode();this.#Q?.setFitMode(e),t!==e&&this.#De("fitMode")}get columnInference(){return this.#y.columnInference??"auto"}set columnInference(e){const t=this.#Q?.getColumnInference();this.#Q?.setColumnInference(e),t!==e&&this.#De("columnInference")}get loading(){return this.#Se}set loading(e){const t=this.#Se;this.#Se=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Ie(),this.#Oe())}setRowLoading(e,t){const i=this.#Ae.has(e);t?this.#Ae.add(e):this.#Ae.delete(e),i!==t&&this.#ze(e,t)}setCellLoading(e,t,i){let r=this.#Me.get(e);const n=r?.has(t)??!1;i?(r||(r=/* @__PURE__ */new Set,this.#Me.set(e,r)),r.add(t)):(r?.delete(t),0===r?.size&&this.#Me.delete(e)),n!==i&&this.#Ne(e,t,i)}isRowLoading(e){return this.#Ae.has(e)}isCellLoading(e,t){return this.#Me.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ae)this.#ze(e,!1);this.#Ae.clear();for(const[e,t]of this.#Me)for(const i of t)this.#Ne(e,i,!1);this.#Me.clear()}get effectiveConfig(){return this.#y}get disconnectSignal(){return this.#de||(this.#de=new AbortController),this.#de.signal}constructor(){super(),this.#qe(),this.#o=new Promise(e=>this.#s=e),this.#be=new ni(this),this.#ve=new xt(this),this.#ye=new Wt(this),this.#ie=new Pe(this),this.#ie.setInitialReadyResolver(()=>this.#s?.()),this.#Q=new De(this)}async#qe(){await Yt('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-column-selection-bg: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-resize-handle-width: 2px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);--tbw-icon-expand: "▶";--tbw-icon-collapse: "▼";--tbw-icon-sort-asc: "▲";--tbw-icon-sort-desc: "▼";--tbw-icon-sort-none: "⇅";--tbw-icon-submenu-arrow: "▶";--tbw-icon-drag-handle: "⋮⋮";--tbw-icon-tool-panel: "☰";--tbw-icon-filter: "";--tbw-icon-filter-active: "";--tbw-icon-print: "🖨️";--tbw-icon-expand-mask: none;--tbw-icon-collapse-mask: none;--tbw-icon-sort-asc-mask: none;--tbw-icon-sort-desc-mask: none;--tbw-icon-sort-none-mask: none;--tbw-icon-submenu-arrow-mask: none;--tbw-icon-drag-handle-mask: none;--tbw-icon-tool-panel-mask: none;--tbw-icon-filter-mask: url("data:image/svg+xml,%3Csvg viewBox=\'0 0 16 16\' width=\'12\' height=\'12\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath 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\'/%3E%3C/svg%3E");--tbw-icon-filter-active-mask: var(--tbw-icon-filter-mask);--tbw-icon-print-mask: none}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}>tbw-grid-column,>tbw-grid-type{display:none}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible;position:relative}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;touch-action:none;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30);touch-action:none}.faux-vscroll-spacer{width:1px}.tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}\n@layer tbw-base{tbw-grid{[data-icon=expand]:empty:before{content:var(--tbw-icon-expand)}[data-icon=collapse]:empty:before{content:var(--tbw-icon-collapse)}[data-icon=sort-asc]:empty:before{content:var(--tbw-icon-sort-asc)}[data-icon=sort-desc]:empty:before{content:var(--tbw-icon-sort-desc)}[data-icon=sort-none]:empty:before{content:var(--tbw-icon-sort-none)}[data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow)}[data-icon=drag-handle]:empty:before{content:var(--tbw-icon-drag-handle)}[data-icon=tool-panel]:empty:before{content:var(--tbw-icon-tool-panel)}[data-icon=print]:empty:before{content:var(--tbw-icon-print)}[data-icon=filter]:empty:before{content:var(--tbw-icon-filter)}[data-icon=filter-active]:empty:before{content:var(--tbw-icon-filter-active)}[data-icon]:empty:before{display:inline-block;vertical-align:middle;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center}[data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);mask-image:var(--tbw-icon-expand-mask)}[data-icon=collapse]:empty:before{-webkit-mask-image:var(--tbw-icon-collapse-mask);mask-image:var(--tbw-icon-collapse-mask)}[data-icon=sort-asc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-asc-mask);mask-image:var(--tbw-icon-sort-asc-mask)}[data-icon=sort-desc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-desc-mask);mask-image:var(--tbw-icon-sort-desc-mask)}[data-icon=sort-none]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-none-mask);mask-image:var(--tbw-icon-sort-none-mask)}[data-icon=submenu-arrow]:empty:before{-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);mask-image:var(--tbw-icon-submenu-arrow-mask)}[data-icon=drag-handle]:empty:before{-webkit-mask-image:var(--tbw-icon-drag-handle-mask);mask-image:var(--tbw-icon-drag-handle-mask)}[data-icon=tool-panel]:empty:before{-webkit-mask-image:var(--tbw-icon-tool-panel-mask);mask-image:var(--tbw-icon-tool-panel-mask)}[data-icon=print]:empty:before{-webkit-mask-image:var(--tbw-icon-print-mask);mask-image:var(--tbw-icon-print-mask)}[data-icon=filter]:empty:before,[data-icon=filter-active]:empty:before{width:var(--tbw-icon-size, 1em);height:var(--tbw-icon-size, 1em);background:currentColor}[data-icon=filter]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-mask);mask-image:var(--tbw-icon-filter-mask)}[data-icon=filter-active]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}}.tbw-context-menu [data-icon]:empty:before{display:inline-block;width:1em;height:1em;vertical-align:middle}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow, "▶")}}\n@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-hit-area, 18px) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.header-group-row>.header-group-cell{&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-hit-area, 18px) / -2);width:var(--tbw-resize-hit-area, 18px);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:transparent;&:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);height:100%;background:var(--tbw-resize-handle-color);border-radius:var(--tbw-resize-handle-border-radius);transition:background .12s ease}&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{&:before{background:var(--tbw-resize-handle-color-hover)}&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}\n@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}@media(hover:hover){&:hover{background:var(--tbw-color-row-hover)}}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}\n@layer tbw-base{.tbw-empty-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--tbw-spacing-md, 12px);text-align:center;background:light-dark(rgba(255,255,255,.6),rgba(0,0,0,.4));color:var(--tbw-color-text-secondary, var(--tbw-color-text));z-index:999;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-empty-message{font-family:var(--tbw-font-family, inherit);font-size:var(--tbw-font-size-md, 14px);line-height:1.4;max-width:480px;user-select:text}}\n@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}\n')}getPlugin(e){return this.#pe?.getPlugin(e)}getPluginByName(e){return this.#pe?.getPluginByName(e)}requestRender(){this.#ie.requestPhase(Le.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#ie.requestPhase(Le.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#ie.requestPhase(Le.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){B(this)}requestAfterRender(){this.#ie.requestPhase(Le.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Fe(){this.#pe=new oi(this);const e=this.#y?.plugins,t=Array.isArray(e)?e:[],i=this.#y?.features;let r,n=[];if(i&&At){n=At(i).map(e=>this.#We(e))}if(0===n.length)r=t;else if(0===t.length)r=n;else{const e=new Set(t.map(e=>e.name));r=[...n.filter(t=>!e.has(t.name)),...t]}this.#pe.attachAll(r)}#We(e){const t=this.#Ee.get(e.name);return t&&t!==e?(t.refreshUserConfigFrom(e),t):(this.#Ee.set(e.name,e),e)}#$e(){!function(e){let t=!1;for(const{name:i,styles:r}of e)Vt.has(i)||(Vt.set(i,Gt(r)),t=!0);t&&jt()}(this.#pe?.getPluginStyles()??[])}#Be(){const e=this.#y?.plugins,t=Array.isArray(e)?e:[],i=this.#y?.features??void 0,r=i!==this.#we;if((this.#me===t||void 0!==this.#me&&this.#me.length===t.length&&this.#me.every((e,i)=>e===t[i]))&&!r)return void(this.#me=t);this.#pe&&this.#pe.detachAll(),this.#Fe(),this.#$e(),this.#me=t,this.#we=i,this.#Ve(),this.#Q.markSourcesChanged(),this.#Q.merge();const n=this.#oe;if(this.#oe=this.#pe?.getAll().some(e=>e.onScroll)??!1,!n&&this.#oe){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");this.#Ue(e)}}#Ge(){this.#pe?.detachAll()}#je(){const e=si.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}}}_registerLightDomHandler(e,t){this.#Q.registerLightDomHandler(e,t)}_unregisterLightDomHandler(e){this.#Q.unregisterLightDomHandler(e)}_requestConfigMerge(){this.#Q.markSourcesChanged(),this.#Q.merge()}_getToolPanelRendererFactory(){return this.#je()}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",si.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++si.#Y),this._rows=Array.isArray(this.#Z)?[...this.#Z]:[],this.#de&&(this.#de.abort(),this.#_e=!1),this.#de=new AbortController,this.#ge&&(Tt(this.#ge),this.#ge=void 0),this.#Ye(),this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Fe();const e=this.#y?.plugins;var t,i;this.#me=Array.isArray(e)?e:[],this.#we=this.#y?.features??void 0,this.#K||(this.#Xe(),this.#$e(),this.#K=!0),this.#Ke(),this.#ge=(t=()=>{this.#Ze()},i={timeout:100},Ht?requestIdleCallback(t,i):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#ge&&(Tt(this.#ge),this.#ge=void 0),this.#ae&&(clearTimeout(this.#ae),this.#ae=0),this.#Ge();const e=this.#pe?.getPluginByName("shell");e?.disposeShellState?.(),Kt(this.#ce),this.#de&&(this.#de.abort(),this.#de=void 0),this.#Ce?.abort(),this.#Ce=void 0,this.#_e=!1,this._resizeController&&this._resizeController.dispose(),this.#ue&&(this.#ue.disconnect(),this.#ue=void 0),this.#he&&(this.#he.disconnect(),this.#he=void 0,this.#Qe=!1,this.#Je=0),nt(this),this.#et.clear(),this._virtualization.heightCache?.byKey.clear(),this.#me=void 0,this.#we=void 0;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#J=!1}attributeChangedCallback(e,t,i){if("loading"===e){const e=null!==i&&"false"!==i;return void(this.loading!==e&&(this.loading=e))}if(t!==i&&i&&"null"!==i&&"undefined"!==i)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(i);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{I("TBW130",`Invalid JSON for '${e}' attribute: ${i}`,this.id)}else"fit-mode"===e?this.fitMode=i:"column-inference"===e&&(this.columnInference=i)}#Ke(){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.setAttribute("data-upgraded",""),this.#J=!0,this._resizeController=Pt(this),this.#tt(),this.#Ue(e),this.#_e)return;this.#_e=!0;const t=this.disconnectSignal;St(this,this,this.#X,t),this.#Ve(),queueMicrotask(()=>this.#it()),this.#ie.requestPhase(Le.FULL,"afterConnect")}#Ve(){const e=this.#y.rowHeight,t=this.#pe.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#be.initializePositionCache(),"function"!=typeof e&&(this.#se=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#rt())}#rt(){if(this.#pe.hasRowHeightPlugin())return;const e=this.#y.rowHeight;if("number"==typeof e&&e>0)return;const t=this._bodyEl?.querySelector(".data-grid-row");if(!t)return;const i=this.#nt(),r=[],n=this._bodyEl?.querySelectorAll(".data-grid-row");for(const h of n??[]){if(h.style.getPropertyValue("--tbw-row-height"))continue;let e=0;h.querySelectorAll(".cell").forEach(t=>{const i=t.offsetHeight;i>e&&(e=i)});const t=Math.max(h.getBoundingClientRect().height,e);t>0&&r.push(t)}if(0===r.length)return;r.sort((e,t)=>e-t);const o=r.length>>1,s=r.length%2==1?r[o]:(r[o-1]+r[o])/2,a=this._virtualization.rowHeight,l=this.#Je,c=i>0&&l>0&&Math.abs(i-l)>1,d=i>0&&0===l,u=s>0&&s-a>1;if(i>0&&(this.#Je=i),c||d||u){const e=c||d?Math.max(i,s):s;Math.abs(e-a)>1&&(this._virtualization.rowHeight=e,this.#ie.requestPhase(Le.VIRTUALIZATION,"measureRowHeight"))}}#nt(){const e=getComputedStyle(this).getPropertyValue("--tbw-row-height").trim();if(!e)return 0;if(e.endsWith("px"))return parseFloat(e)||0;const t=this._bodyEl?.querySelector('.data-grid-row:not([style*="--tbw-row-height"]) > .cell');if(!t)return 0;const i=parseFloat(getComputedStyle(t).minHeight);return i>0?i:0}#ot(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const r=e.getBoundingClientRect(),n=Math.max(r.height,i);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#be.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#be.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Ue(e){this.#Ce?.abort(),this.#Ce=new AbortController;const t=this.#Ce.signal,i=e?.querySelector(".faux-vscroll"),r=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#oe=this.#pe?.getAll().some(e=>e.onScroll)??!1,i&&r){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#oe)return;const e=i.scrollTop,t=pt(e,this._virtualization.scrollMapping),n=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)r.style.transform=`translateY(${-e}px)`;else{const e=this._virtualization.positionCache;let i,o;if(this._virtualization.variableHeights&&e&&e.length>0){i=ut(e,t),-1===i&&(i=0);const r=i-i%2;o=e[r]?.offset??r*n}else{i=Math.floor(t/n);o=(i-i%2)*n}const s=-(t-o);r.style.transform=`translateY(${s}px)`}this.#ne=e,this.#re||(this.#re=requestAnimationFrame(()=>{this.#re=0,null!==this.#ne&&(this.#st(this.#ne),this.#ne=null)}))},{passive:!0,signal:t});const e=this.#X.querySelector(".tbw-scroll-area");this.#Re=e,this._virtualization.scrollAreaEl=e,e&&this.#oe&&e.addEventListener("scroll",()=>{const t=this.#fe;t.scrollTop=i.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=i.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=i.clientHeight,t.clientWidth=e.clientWidth,this.#pe?.onScroll(t)},{passive:!0,signal:t});const n=this.#X.querySelector(".tbw-grid-content"),o=this.#Re;n&&(n.addEventListener("wheel",e=>{try{if(n.querySelector("select:open"))return}catch{}const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&o){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:i,scrollWidth:r,clientWidth:n}=o;(t>0&&i<r-n||t<0&&i>0)&&(e.preventDefault(),o.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:r,clientHeight:n}=i;(e.deltaY>0&&t<r-n||e.deltaY<0&&t>0)&&(e.preventDefault(),i.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),Qt(n,this.#ce,{fauxScrollbar:i,scrollArea:o},t))}var n,o,s;this._bodyEl&&(n=this,o=this._bodyEl,s=t,o.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(V.EDITING))return;const i=e.target;i.draggable||i.closest('[draggable="true"]')||e.preventDefault(),Rt(n,t)},{signal:s}),o.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&at(n,e,t),!document.activeElement?.closest(`.cell.${V.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),o.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&at(n,e,t)},{signal:s})),this.#ue?.disconnect(),this._virtualization.viewportEl&&(this.#ue=new ResizeObserver(()=>{this.#at(),this.#ie.requestPhase(Le.VIRTUALIZATION,"resize-observer")}),this.#ue.observe(this._virtualization.viewportEl)),this.#X.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#X.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#X.contains(t)||this.#ve.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Qe=!1;#Je=0;#lt(){if(this.#Qe)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Qe=!0,this.#he?.disconnect(),this.#he=new ResizeObserver(()=>{this.#rt()}),this.#he.observe(e))}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}on(e,t){const i=e=>{t(e.detail,e)};return this.addEventListener(e,i),()=>this.removeEventListener(e,i)}#ct(e,t){this.#J&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#ct("data-change",{rowCount:this._rows.length,sourceRowCount:this.#Z.length}),function(e,t,i){if(i===t.lastAnnouncedSourceCount)return;const r=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=i,0===i&&r<0||o(e,s(e,"dataLoaded",i))}(this,this.#dt,this.#Z.length)}#it(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const i=t===this._focusRow;e.setAttribute("aria-selected",String(i)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(i&&t===this._focusCol))})})}#De(e){this.#te[e]=!0,this.#ee||(this.#ee=!0,queueMicrotask(()=>this.#ut()))}#ut(){if(!this.#ee||!this.#J)return void(this.#ee=!1);const e=this.#te;if(this.#ee=!1,this.#te={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1},e.gridConfig)return this.#ht(),void(e.rows&&this.#gt());(e.columns||e.columnInference)&&this.#ft(),e.rows&&this.#gt(),e.fitMode&&this.#pt()}#gt(){this._rows=Array.isArray(this.#Z)?[...this.#Z]:[],this.#ke=!0,this.#ie.requestPhase(Le.ROWS,"applyRowsUpdate")}#mt(){this.#ke&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#ke=!1,this.#Te.clear();const e=this.#y.getRowId;for(let t=0;t<this._rows.length;t++){const i=qt(this._rows[t],e);void 0!==i&&this.#Te.set(i,{row:this._rows[t],index:t})}}#ft(){nt(this),this.#Q.merge(),this.#tt()}#pt(){this.#Q.merge();if("fixed"===this.#y.fitMode)this.__didInitialAutoSize=!1,F(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}B(this)}}#ht(){this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Be(),this.#Ve(),this.#Q.markSourcesChanged(),this.#Q.merge();const e=this.#Q.initialColumnState;if(e){this.#Q.initialColumnState=void 0,this.#A=void 0;const t=this.#pe?.getAll()??[];this.#Q.applyState(e,t)}if(this.#pe?.needsStructuralRerender()??!1)return this.#pe?.beforeStructuralRender(),this.#Xe(),this.#$e(),this.#Ke(),void this._rebuildRowIdMap();this._rebuildRowIdMap(),this.#ie.requestPhase(Le.COLUMNS,"applyGridConfigUpdate")}#wt(){if(this.__rowRenderEpoch++,this.#pe){const e=this.#Le.length>0?this.#Le:this._columns,t=e.filter(e=>!e.hidden),i=e.filter(e=>e.hidden),r=this.#pe.processColumns([...t]);if(r!==t){const n=new Set(r.map(e=>e.field));!t.some(e=>n.has(e.field))&&r.length>0?this._columns=[...r,...i]:this._columns=this.#bt(e,r,i)}else this._columns=[...e]}}#bt(e,t,i){if(0===i.length)return t;const r=/* @__PURE__ */new Map;for(const a of t)r.set(a.field,a);const n=new Set(e.map(e=>e.field)),o=[];for(const a of t)n.has(a.field)||o.push(a);const s=[];for(const a of e){const e=r.get(a.field);e?s.push(e):a.hidden&&s.push(a)}return s.push(...o),s}#vt(){nt(this);const e=this.#Z;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#be.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#y.initialSort){const{field:e,direction:t}=this.#y.initialSort;this._columns.find(t=>t.field===e)&&(this._sortState={field:e,direction:"desc"===t?-1:1})}this._sortState&&(this.__originalOrder=this._rows);const t=function(e,t,i=!1){if(!e._sortState)return t;const r=e.effectiveConfig?.sortHandler??pe;if(r===pe)return i||(e.__originalOrder=t.slice()),ve(t,e._sortState.field,e._sortState.direction,e._columns),t;i||(e.__originalOrder=t);const n=r(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),i=this.#pe?.processRows(t)??t;this._rows=i,this.#ke=!0,this._emitDataChange()}_renderVisibleRows(e,t,i=this.__rowRenderEpoch){if(this.#le||(this.#le=(e,t,i)=>this.#pe?.renderRow(e,t,i)??!1),function(e,t,i,r,n){const o=Math.max(0,i-t),s=e._bodyEl,a=e._visibleColumns,l=a.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<o;){const t=rt();e._rowPool.push(t)}if(e._rowPool.length>o){const t=e.__frameworkAdapter,i=t?.releaseCell;t?.beginBatch?.(e);try{for(let r=o;r<e._rowPool.length;r++){const n=e._rowPool[r];if(i){const e=n.children;for(let r=0;r<e.length;r++){const n=e[r];n.firstElementChild&&i.call(t,n)}}n.parentNode===s&&n.remove()}e._rowPool.length=o}finally{t?.endBatch?.(e)}}const d=n&&!1!==e.__hasRenderRowPlugins,u=e._hasAfterRowRenderHook?.()??!1,h=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<o;f++){const i=t+f,o=e._rows[i],p=e._rowPool[f];if(p.setAttribute("aria-rowindex",String(i+c+1)),d&&n(o,p,i)){p.__epoch=r,p.__rowDataRef=o,p.parentNode!==s&&s.appendChild(p);continue}const m=p.__epoch,w=p.__rowDataRef;let b=p.children.length;b>l&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const v=m===r&&b===l,y=w!==o,_=!!e._isGridEditMode;let C=!1;if(v&&y)for(let e=0;e<l;e++)if(a[e].externalView&&!p.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){C=!0;break}if(!v||C){const t=Qe(p),n=_&&!y||e._activeEditRows===i;t&&!n?(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):t&&n?(ot(e,p,o,i),p.__rowDataRef=o):(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o)}else if(y){const t=Qe(p),n=e._activeEditRows===i;t&&!n?(Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):(ot(e,p,o,i),p.__rowDataRef=o)}else{const t=Qe(p),n=_||e._activeEditRows===i;t&&!n?(Je(p),st(e,p,o,i),p.__epoch=r,p.__rowDataRef=o):ot(e,p,o,i)}let R=!1;const E=e._changedRowIdSet;if(E&&E.size>0)try{const t=e.getRowId?.(o);t&&(R=E.has(t))}catch{}R!==p.classList.contains("changed")&&p.classList.toggle("changed",R);const S=e.effectiveConfig?.rowClass;if(S){const t=p.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&p.classList.remove(e[t])}try{const e=S(o),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let i=0;i<t.length;i++){const r=t[i];r&&"string"==typeof r&&(p.classList.add(r),e+=(e?" ":"")+r)}p.setAttribute("data-dynamic-classes",e)}else p.removeAttribute("data-dynamic-classes")}catch(g){I("TBW060",`rowClass callback error: ${g}`,e.id),p.removeAttribute("data-dynamic-classes")}}if(h){const e=h(o,i);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}u&&e._afterRowRender?.({row:o,rowIndex:i,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,i,this.#le),this.#Ae.size>0)for(const r of this.#Ae)this.#ze(r,!0)}#dt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,i,r,n){if(r===e.rowCount&&n===e.colCount)return!1;const o=e.rowCount;e.rowCount=r,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(r)),t.setAttribute("aria-colcount",String(n))),r!==o&&i&&(r>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role"))}(this.#dt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#ie.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#pe?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,i){return this.#pe?.adjustVirtualStart(e,t,i)}_afterPluginRender(){this.#pe?.afterRender()}_emitPluginEvent(e,t){this.#pe?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#Q.parseLightDomColumns(this),this.#Q.merge(),this.#Be(),function(e,t,i){const r=Jt,n=ei,o=/* @__PURE__ */new Map;function s(e,t,i,r,n=!1){o.has(e)||o.set(e,{description:t,importHint:i,fields:[],isConfigProperty:n});const s=o.get(e);s.fields.includes(r)||s.fields.push(r)}const a=e.features;function l(e){return!!a&&!1===a[e]}for(const d of n){const i=e[d.property];if((d.isUsed?d.isUsed(i):void 0!==i)&&!ri(t,d.pluginName)&&!l(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,ti(d.pluginName),d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of r){const i=d[e.property];if((e.isUsed?e.isUsed(i):void 0!==i)&&!ri(t,e.pluginName)&&!l(e.pluginName)){const t=d.field||"<unknown>",i=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,i,ti(e.pluginName),t)}}if(o.size>0){const e=[];for(const[t,{description:i,importHint:r,fields:n,isConfigProperty:s}]of o)if(s)e.push(`Config uses ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${r}\n plugins: [new ${ii(t)}Plugin(), ...]`);else{const o=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${o}] use ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${r}\n plugins: [new ${ii(t)}Plugin(), ...]`)}D([...o.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,i)}}(this.#y,this.#pe?.getPlugins()??[],this.id),function(e,t){const i=[],r=[];for(const n of e){const e=n.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=n.config;if(t.check(e)){const e=`[${ii(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?i.push(e):r.push(e)}}}if(r.length>0&&We())for(const n of r)I("TBW004",n,t);i.length>0&&D("TBW003",`Configuration error:\n\n${i.join("\n\n")}`,t)}(this.#pe?.getPlugins()??[],this.id),function(e,t){if(!We())return;const i=new Set(e.map(e=>e.name)),r=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const o of e.incompatibleWith)if(i.has(o.name)){const e=[n.name,o.name].sort().join("↔");if(r.has(e))continue;r.add(e),I("TBW022",`${ii(n.name)}Plugin and ${ii(o.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${o.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#pe?.getPlugins()??[],this.id),this.#yt(),this.#Le=[...this._columns]}_schedulerProcessColumns(){this.#wt()}_schedulerProcessRows(){this.#vt()}_schedulerRenderHeader(){Te(this)}_schedulerUpdateTemplate(){B(this)}_schedulerAfterRender(){this.#pe?.afterRender(),this.#Oe(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#be.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#y.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,F(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,_t(this)),this._virtualization.enabled&&!this.#Qe&&this.#lt(),this.#se&&(this.#se=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#ot()})})),this.#Se&&this.#Ie()}get _schedulerIsConnected(){return this.isConnected&&this.#J}get _hostElement(){return this}get _renderRoot(){return this.#X}_emit(e,t){this.#ct(e,t)}get _accordionIcons(){return{expand:this.#y?.icons?.expand??n.expand,collapse:this.#y?.icons?.collapse??n.collapse}}_pluginShellContributions(){return{toolPanels:(this.#pe?.getToolPanels()??[]).map(e=>e.panel),headerContents:(this.#pe?.getHeaderContents()??[]).map(e=>e.content)}}_clearRowPool(){const e=this.__frameworkAdapter,t=e?.releaseCell;if(t){e?.beginBatch?.(this);try{for(let i=0;i<this._rowPool.length;i++){const r=this._rowPool[i].children;for(let i=0;i<r.length;i++){const n=r[i];n.firstElementChild&&t.call(e,n)}}this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="")}finally{e?.endBatch?.(this)}}else this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="");this.__rowRenderEpoch++}_setup(){this.#tt()}_applyAnimationConfig(e){const t={...r,...e.animation},i=t.mode??"reduced-motion";let n=1;!1===i||"off"===i?n=0:!0!==i&&"on"!==i||(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}#yt(){!function(e,t,i){if(!t)return!1;let r=!1;const n=i?.gridAriaLabelledBy,o=n?void 0:function(e){const t=e?.gridAriaLabel;return t||(e?.shell?.header?.title??void 0)}(i);n!==e.ariaLabelledBy&&(e.ariaLabelledBy=n,n?t.setAttribute("aria-labelledby",n):t.removeAttribute("aria-labelledby"),r=!0),o!==e.ariaLabel&&(e.ariaLabel=o,o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),r=!0);const s=i?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0);const a=i?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),r=!0)}(this.#dt,this.__rowsBodyEl,this.#y)}#Ie(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#Se?(this.#xe||(this.#xe=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(kt("large",e)),t}(this.#y?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#xe)):(t=this.#xe,t?.remove()))}#Oe(){!function(e,t,i,r,n,o,s){if(!e)return;if(!function(e,t,i){return!(e||t>0||null===i)}(t,i,n))return Fe(s.el),s.el=void 0,s.renderer=void 0,s.target=void 0,s.sourceRows=void 0,void(s.filteredOut=void 0);const a=r.length,l=a>0&&0===i;if(s.el&&s.renderer===n&&s.target===o&&s.sourceRows===r&&s.filteredOut===l)return;const c="grid"===o?e:e.querySelector(".rows-container")??e;Fe(s.el),s.el=qe({sourceRowCount:a,filteredOut:l},n??void 0,o),function(e,t){e.appendChild(t)}(c,s.el),s.renderer=n,s.target=o,s.sourceRows=r,s.filteredOut=l}(this.querySelector(".tbw-grid-root"),this.#Se,this._rows.length,this.#Z,this.#y?.emptyRenderer,this.#y?.emptyOverlay??"rows",this.#He)}#ze(e,t){this.#mt();const i=this.#Te.get(e);if(!i)return;const r=this.findRenderedRowElement?.(i.index);r&&Lt(r,t)}#Ne(e,t,i){this.#mt();const r=this.#Te.get(e);if(!r)return;const n=this.findRenderedRowElement?.(r.index);if(!n)return;const o=this._visibleColumns.findIndex(e=>e.field===t);if(o<0)return;const s=n.children[o];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,i)}#tt(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#Q.parseLightDomColumns(this),this.#A){const e=this.#A;this.#A=void 0,this.#Q.merge();const t=this.#pe?.getAll()??[];this.#Q.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#ie.requestPhase(Le.FULL,"setup")}}#st(e){const t=this._virtualization.container,i=this.#Re,r=i?.scrollLeft??0,n=t?.scrollHeight??0,o=i?.scrollWidth??0,s=t?.clientHeight??0,a=i?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#pe?.onScrollRender(),this._virtualization.variableHeights&&(this.#ae&&clearTimeout(this.#ae),this.#ae=window.setTimeout(()=>{this.#ae=0,this.#be.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#oe){const t=this.#fe;t.scrollTop=e,t.scrollLeft=r,t.scrollHeight=n,t.scrollWidth=o,t.clientHeight=s,t.clientWidth=a,this.#pe?.onScroll(t)}this.#ct("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#X.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,i=e-t.start;return i>=0&&i<this._rowPool.length&&i<t.end-t.start?this._rowPool[i]:null}_dispatchCellClick(e,t,i,r){const n=this._rows[t],o=this._visibleColumns[i];if(!n||!o)return!1;const s=o.field,a=n[s],l=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,column:o,field:s,value:a,row:n,cellEl:r,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(l),l.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:i,column:o,field:s,value:a,cellEl:r,originalEvent:e},d=this.#pe?.onCellClick(c)??!1;return this.#ct("cell-click",c),d}_dispatchRowClick(e,t,i,r){if(!i)return!1;const n={rowIndex:t,row:i,rowEl:r,originalEvent:e},o=this.#pe?.onRowClick(n)??!1;return this.#ct("row-click",n),o}_dispatchHeaderClick(e,t,i){if(!t)return!1;const r={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:i,originalEvent:e};return this.#pe?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#pe?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#pe?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#pe?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#pe?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#pe?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#pe?.onCellMouseUp(e)}_afterCellRender(e){this.#pe?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#pe?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#pe?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#pe?.hasAfterRowRenderHook()??!1}async ready(){return this.#o}async forceLayout(){return 0===this.#ie.pendingPhase&&this.#ie.requestPhase(Le.FULL,"forceLayout"),this.#ie.whenReady()}async getConfig(){return Object.freeze({...this.#y||{}})}getRowId(e){return Ft(e,this.id,this.#y.getRowId)}getRow(e){return this.#ye.getRow(e)}_getRowEntry(e){return this.#mt(),this.#Te.get(e)}updateRow(e,t,i="api"){this.#ye.updateRow(e,t,i)}updateRows(e,t="api"){this.#ye.updateRows(e,t)}animateRow(e,t){return Nt(this,e,t)}animateRows(e,t){return function(e,t,i){return Promise.all(t.map(t=>Nt(e,t,i))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,i){const r=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const o=r.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return o<0?Promise.resolve(!1):Nt(e,o,i)}(this,e,t)}async insertRow(e,t,i=!0){return this.#ye.insertRow(e,t,i)}async removeRow(e,t=!0){return this.#ye.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#ye.applyTransaction(e,t)}applyTransactionAsync(e){return this.#ye.applyTransactionAsync(e)}focusCell(e,t){this.#ve.focusCell(e,t)}get focusedCell(){return this.#ve.focusedCell}scrollToRow(e,t){this.#ve.scrollToRow(e,t)}scrollToRowById(e,t){this.#ve.scrollToRowById(e,t)}setColumnVisible(e,t){const i=this.#Q.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#Q.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#Q.isColumnVisible(e)}showAllColumns(){this.#Q.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#Q.getAllColumns()}setColumnOrder(e){this.#Q.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#Q.getColumnOrder()}getColumnState(){const e=this.#pe?.getAll()??[];return this.#Q.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#K?this.#_t(e):(this.#A=e,this.#Q.initialColumnState=e))}#_t(e){const t=this._columns,i=this._sortState,r=this.#pe?.getAll()??[];this.#Q.applyState(e,r);if(!e.columns.some(e=>void 0!==e.sort)&&this.#Ct(t,i))return this.#Pe=void 0,B(this),void this.#ie.requestPhase(Le.STYLE,"column-width");this.#tt()}#Ct(e,t){const i=this._columns,r=this._sortState;if(t?.field!==r?.field||t?.direction!==r?.direction)return!1;if(e.length!==i.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],r=i[n];if(t.field!==r.field)return!1;if(!!t.hidden!=!!r.hidden)return!1}return!0}get sortModel(){return this._sortState?{field:this._sortState.field,direction:1===this._sortState.direction?"asc":"desc"}:null}sort(e,t){if(null===e){if(!this._sortState)return;const e=this._sortState.field;this._sortState=null,this.__rowRenderEpoch++;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].__epoch=-1;return this._rows=this.__originalOrder.slice(),this.__originalOrder=[],Te(this),this.refreshVirtualWindow(!0),this.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e,direction:0}})),this._pluginManager?.emitPluginEvent?.("sort-change",{field:e,direction:0}),void this.requestStateChange?.()}const i=this._columns.find(t=>t.field===e);i&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),Ee(this,i,"desc"===t?-1:1)):Re(this,i))}requestStateChange(){const e=this.#pe?.getAll()??[];this.#Q.requestStateChange(e)}resetColumnState(){this.#A=void 0,this.__originalOrder=[];const e=this.#pe?.getAll()??[];this.#Q.resetState(e),this.#Q.merge(),this.#tt()}get defaultRowHeight(){return this._virtualization.rowHeight}#Rt=!1;refreshShellHeader(){this.#Rt||(this.#Rt=!0,queueMicrotask(()=>{this.#Rt=!1,this.isConnected&&(this.#Ye(),this.#Q.markSourcesChanged(),this.#Q.merge(),this.#pe?.beforeStructuralRender(),this.#pe?.afterStructuralRender(),this.#Et())}))}#Et(){const e=this.#X.querySelector(".tbw-grid-content")??this.#X.querySelector(".tbw-grid-root");this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this._resizeController=Pt(this),this.#Ue(e),this.#ie.requestPhase(Le.COLUMNS,"shellRefresh")}#et=/* @__PURE__ */new Map;registerStyles(e,t){let i=this.#et.get(e);i||(i=new CSSStyleSheet,this.#et.set(e,i)),i.replaceSync(t),this.#St()}unregisterStyles(e){this.#et.delete(e)&&this.#St()}getRegisteredStyles(){return Array.from(this.#et.keys())}#St(){const e=Array.from(this.#et.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#et.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#ve.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#ve.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#ve.containsFocus(e)}get lastFocusedElement(){return this.#ve.lastFocusedElement}restoreLastFocus(){return this.#ve.restoreLastFocus()}#Ye(){this.#pe?.parseLightDom()}#Ze(){const e=()=>{this.#Q.clearLightDomCache(),this.#tt()};this.#Q.registerLightDomHandler("tbw-grid-column",e),this.#Q.registerLightDomHandler("tbw-grid-detail",e),this.#Q.registerLightDomHandler("tbw-grid-type",e),this.#Q.observeLightDOM(this)}refreshColumns(){this.#Q.clearLightDomCache(),nt(this),this.#Q.parseLightDomColumns(this),this.#pe?.syncLightDom(),this.#ie.requestPhase(Le.COLUMNS,"refreshColumns")}#at(){this.#be.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#be.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#be.invalidateRowHeight(e,t)}#Xe(){this.#Ye(),this.#Q.markSourcesChanged(),this.#Q.merge(),function(e){const t=[];for(let i=e.firstChild;i;i=i.nextSibling)1===i.nodeType&&i.classList.contains(V.ROOT)||t.push(i);e.replaceChildren();for(const i of t)e.appendChild(i);e.appendChild(ze())}(this.#X),this.#pe?.afterStructuralRender()}}!function(){const e=si.tagName,t=customElements.get(e);if(!t)return customElements.define(e,si),void(si.activeTag=e);if(t.version===si.version)return void(si.activeTag=e);const i=`${e}-v${si.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(i)||customElements.define(i,si),si.activeTag=i}(),globalThis.DataGridElement||(globalThis.DataGridElement=si);const ai=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"];function li(e){const t=document.createElement(si.activeTag);return e&&(t.gridConfig=e),t}function ci(e,t,i){let r=document,n=!1;return"boolean"==typeof t?n=t:t&&(r=t,n=!!i),n?customElements.whenDefined(si.activeTag).then(()=>r.querySelector(e)):r.querySelector(e)}function di(e,t,i){return i?.valueAccessor?he(e,i):e?.[t]}function ui(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const hi={sum:(e,t,i)=>{let r=0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||(r+=s)}return r},avg:(e,t,i)=>{if(!e.length)return 0;let r=0,n=0;for(let o=0;o<e.length;o++){const s=di(e[o],t,i);if(ui(s))continue;const a=Number(s);isNaN(a)||(r+=a,n++)}return n>0?r/n:0},count:e=>e.length,min:(e,t,i)=>{if(!e.length)return 0;let r=1/0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||s<r&&(r=s)}return r===1/0?0:r},max:(e,t,i)=>{if(!e.length)return 0;let r=-1/0;for(let n=0;n<e.length;n++){const o=di(e[n],t,i);if(ui(o))continue;const s=Number(o);isNaN(s)||s>r&&(r=s)}return r===-1/0?0:r},first:(e,t,i)=>e[0]?di(e[0],t,i):void 0,last:(e,t,i)=>e.length?di(e[e.length-1],t,i):void 0},gi=/* @__PURE__ */new Map,fi={register(e,t){gi.set(e,t)},unregister(e){gi.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:gi.get(e)??hi[e]},run(e,t,i,r){const n=this.get(e);return n?n(t,i,r):void 0},has:e=>gi.has(e)||e in hi,list:()=>[...Object.keys(hi),...gi.keys()]},pi={sum:e=>{let t=0;for(let i=0;i<e.length;i++)t+=e[i];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let i=0;i<e.length;i++)t+=e[i];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let i=1;i<e.length;i++)e[i]<t&&(t=e[i]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let i=1;i<e.length;i++)e[i]>t&&(t=e[i]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function mi(e){return pi[e]??pi.sum}function wi(e,t){return mi(e)(t)}export{L as A,de as BaseGridPlugin,E as C,ai as CORE_CONSUMED_ADAPTER_METHODS,t as ColumnInferenceModeEnum,H as D,i as DEFAULT_A11Y_MESSAGES,r as DEFAULT_ANIMATION_CONFIG,n as DEFAULT_GRID_ICONS,si as DataGridElement,v as E,Ze as F,e as FitModeEnum,j as GridCSSVars,V as GridClasses,U as GridDataAttrs,si as GridElement,G as GridSelectors,S as M,gt as MAX_ELEMENT_HEIGHT_PX,A as N,R as P,oi as PluginManager,Le as RenderPhase,o as a,fi as aggregatorRegistry,h as applyColumnDefaults,bt as b,pe as builtInSort,le as c,ft as computeScrollMapping,li as createGrid,wt as d,fe as defaultComparator,_t as e,Be as f,mt as fromVirtualScrollTop,s as g,mi as getValueAggregator,D as h,g as hasColumnShorthands,M as i,ge as invalidateAccessorCache,x as j,Lt as k,oe as l,Ge as m,y as n,u as normalizeColumns,_ as o,z as p,d as parseColumnShorthand,C as q,ci as queryGrid,Ye as r,he as resolveCellValue,wi as runValueAggregator,re as s,Mt as setFeatureResolver,ce as t,pt as toVirtualScrollTop,Ve as u,Ue as v,I as w,O as x,k as y,T as z};//# sourceMappingURL=index.js.map
|