@toolbox-web/grid 2.14.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1 +1 @@
1
- const e={STRETCH:"stretch",FIXED:"fixed"},t={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`},o={mode:"reduced-motion",duration:200,easing:"ease-out"},i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;const o="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===o?.a11y?.announcements)return;const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}function r(e,o,...i){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,r=n?.a11y?.messages?.[o];return r?r(...i):t[o](...i)}function s(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const l="TBW041",a="TBW061",c="TBW062",d="TBW072",h="TBW080",u="TBW090",g="TBW091",f="TBW092",p="TBW093",w="TBW100",m="TBW110",b="TBW111",v="TBW112",C="TBW113",y="TBW114",_="TBW140",R="TBW141",S="TBW142",E="TBW143";function x(e,t,o,i){return`${s(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function T(e,t,o,i){throw new Error(x(e,t,o,i))}function A(e,t,o,i){console.warn(x(e,t,o,i))}function P(e,t,o,i){console.debug(x(e,t,o,i))}function H(e,t,o,i){console.error(x(e,t,o,i))}function M(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const o={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=o[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.editable&&(t.editable=!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.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}}const n=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const n=t.renderer||t.viewRenderer,r=i.renderer||i.viewRenderer;return n&&!r&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i}),r=Object.keys(o);for(let s=0;s<r.length;s++)n.push(o[r[s]]);return n}function k(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function L(t){const o=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;if(o!==e.STRETCH&&o!==e.FIXED)return;if(t.__didInitialAutoSize)return;if(!t.isConnected)return;const i=Array.from(t._headerRowEl?.children||[]);if(!i.length)return;let n=!1;const r=t._visibleColumns;for(let e=0;e<r.length;e++){const o=r[e];if(o.width)continue;const s=i[e];let l=s?s.scrollWidth:0;for(let i=0;i<t._rowPool.length;i++){const o=t._rowPool[i].children[e];if(o){const e=o.scrollWidth;e>l&&(l=e)}}l>0&&(o.width=l+2,o.__autoSized=!0,n=!0)}n&&I(t),t.__didInitialAutoSize=!0}const O=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function D(e,t){return"number"==typeof e?`${e}px`:(O.test(e)||A("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 I(t){const o=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;t._gridTemplate=o===e.STRETCH?t._visibleColumns.map(e=>{if(null!=e.width)return D(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?D(e.width,e.field):"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}const z={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},N={FIELD:"data-field",GROUP_KEY:"data-group-key"},q={ROOT:`.${z.ROOT}`,HEADER:`.${z.HEADER}`,HEADER_ROW:`.${z.HEADER_ROW}`,HEADER_CELL:`.${z.HEADER_CELL}`,ROWS_VIEWPORT:`.${z.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${z.ROWS_CONTAINER}`,DATA_ROW:`.${z.DATA_ROW}`,DATA_CELL:`.${z.DATA_CELL}`,GROUP_ROW:`.${z.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${z.DATA_CELL}[${N.FIELD}="${e}"]`,SELECTED_ROWS:`.${z.DATA_ROW}.${z.SELECTED}`,EDITING_CELL:`.${z.DATA_CELL}.${z.EDITING}`},$={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"},F=/{{\s*([^}]+)\s*}}/g,W="__DG_EMPTY__",B=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,V="__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("")),U=new RegExp(`__(proto|defineGetter|defineSetter)|${V.slice(3).join("|")}|this\\b`);const G=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("|")),j=/^on\w+$/i,Y=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),X=/^\s*(javascript|vbscript|data|blob):/i;function K(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=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(G.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>j.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();j.test(e)?o.push(t.name):(Y.has(e)&&X.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function Z(e,t){const o=function(e){const t=[];let o=0;for(;o<e.length;){const i=e[o];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&o+1<e.length&&e[o+1]>="0"&&e[o+1]<="9"){const i=o;for(;o<e.length&&(e[o]>="0"&&e[o]<="9"||"."===e[o]);)o++;t.push({type:"num",v:Number(e.slice(i,o))});continue}if("'"===i){let i="";for(o++;o<e.length&&"'"!==e[o];)i+=e[o++];if(o>=e.length)return null;o++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=o;for(;o<e.length&&/[\w$.]/.test(e[o]);)o++;t.push({type:"id",v:e.slice(i,o)});continue}if(o+2<e.length){const i=e.slice(o,o+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),o+=3;continue}}if(o+1<e.length){const i=e.slice(o,o+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),o+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),o++}else o++}return t}(e);if(!o)return;const i=o;let n=0;function r(){return i[n]}function s(){return i[n++]}function l(e,t){const o=r();return!!o&&(o.type===e&&(void 0===t||o.v===t))}function a(){const e=function(){let e=c();for(;l("op","||");)s(),e=e||c();return e}();if(l("op","?")){s();const t=a();if(!l("op",":"))return;s();const o=a();return e?t:o}return e}function c(){let e=d();for(;l("op","&&");)s(),e=e&&d();return e}function d(){let e=h();for(;;){const t=r();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=u();for(;;){const t=r();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=g();for(;;){const t=r();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=r();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 l("op","!")?(s(),!f()):p()}function p(){const e=r();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 o=e.slice(4);return t.row?t.row[o]:void 0}return"row"===e?t.row:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=a();return l("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=a();return n<i.length?void 0:w}function Q(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(F,(e,i)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return W;if(J.test(e))return W;if("value"===e)return null==t.value?W:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?W:String(i)}if(e.length>80)return W;if(!B.test(e)||U.test(e))return W;const o=e.match(/\./g);if(o&&o.length>1)return W;try{const o=Z(e,t),i=null==o?"":String(o);return J.test(i)?W:i||W}catch{return W}}(i,t);return o.push({expr:i.trim(),result:n}),n}),n=(r=i)?r.replace(new RegExp(W,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):r;var r;const s=o.length&&o.every(e=>""===e.result||e.result===W);return J.test(e)||s?"":n}const J=/Reflect|Proxy|ownKeys/;function ee(e){if(J.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&J.test(t.textContent||"")&&(t.textContent="");J.test(e.textContent||"")&&(e.textContent="")}}function te(e){if(J.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>Q(e,t);return t.__blocked=!1,t}function oe(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}class ie{static dependencies;static manifest;aliases;version="2.14.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const i of Object.keys(t))o[i]=this;for(const i of e){const e=i.userConfig;for(const[n,r]of Object.entries(e)){if(void 0===r)continue;if(!(n in t)){t[n]=r,o[n]=i;continue}if(t[n]===r)continue;const e=o[n]?.constructor.name??this.constructor.name,s=i.constructor.name,l=x("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(l)}}Object.assign(this.userConfig,t)}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 o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.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{...i,...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(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=oe(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#t(t,o);void 0!==i?"string"==typeof i?e.innerHTML=K(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.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 o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(o,i):e.appendChild(o),o}warn(e,t){void 0!==t?console.warn(x(e,t,this.gridElement.id,this.name)):console.warn(`${s(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(x(e,t,this.gridElement.id,this.name))}}const ne=/* @__PURE__ */new WeakMap;function re(e,t,o=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:o});const i=e,n=t.field;let r=ne.get(i);if(r){const e=r.get(n);if(void 0!==e)return e.v}else r=/* @__PURE__ */new Map,ne.set(i,r);const s=t.valueAccessor({row:e,column:t,rowIndex:o});return r.set(n,{v:s}),s}function se(e,t){e&&(t?ne.get(e)?.delete(t):ne.delete(e))}function le(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function ae(e,t,o){const i=o.find(e=>e.field===t.field),n=i?.sortComparator,{field:r,direction:s}=t,l=[...e];return n?i?.valueAccessor?l.sort((e,t)=>n(re(e,i),re(t,i),e,t)*s):l.sort((e,t)=>n(e[r],t[r],e,t)*s):i?.valueAccessor?de(l,i,s):ce(l,r,s),l}function ce(e,t,o){e.sort((e,i)=>{const n=he(e,i);if(0!==n)return n;const r=e[t],s=i[t];return null==r&&null==s?0:null==r?-o:null==s||r>s?o:r<s?-o:0})}function de(e,t,o){e.sort((e,i)=>{const n=he(e,i);if(0!==n)return n;const r=re(e,t),s=re(i,t);return null==r&&null==s?0:null==r?-o:null==s||r>s?o:r<s?-o:0})}function he(e,t){const o=!0===e?.__loading;return o===(!0===t?.__loading)?0:o?1:-1}function ue(e,t,o,i){const n=i.find(e=>e.field===t),r=n?.sortComparator;r?n?.valueAccessor?e.sort((e,t)=>r(re(e,n),re(t,n),e,t)*o):e.sort((e,i)=>r(e[t],i[t],e,i)*o):n?.valueAccessor?de(e,n,o):ce(e,t,o)}function ge(e,t,o,i){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;Re(e),e.refreshVirtualWindow(!0),fe(e,o,i)}function fe(e,t,o){const i={field:t.field,direction:o};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,r(e,0===o?"sortCleared":"sortApplied",t.header??t.field,1===o?"ascending":"descending")),e.requestStateChange?.()}function pe(e){return e._pluginManager?._hasRowStructurePlugins??!1}function we(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)me(e,t,-1);else{if(e._sortState=null,pe(e))return e._requestSchedulerPhase(4,"sort-clear"),void fe(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=[],Re(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(o)for(let t=0;t<o.length;t++){const i=o[t];i.getAttribute("aria-sort")&&("ascending"!==i.getAttribute("aria-sort")&&"descending"!==i.getAttribute("aria-sort")||e._sortState)||i.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),fe(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),me(e,t,1)}function me(e,t,o){if(e._sortState={field:t.field,direction:o},pe(e))return e._requestSchedulerPhase(4,"sort-apply"),void fe(e,t,o);const i={field:t.field,direction:o},n=e._columns,r=e.effectiveConfig?.sortHandler??ae;if(r===ae)return ue(e._rows,i.field,o,n),void ge(e,e._rows,t,o);const s=r(e._rows,i,n);s&&"function"==typeof s.then?s.then(i=>{ge(e,i,t,o)}):ge(e,s,t,o)}function be(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function ve(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Ce(e,t){const o=document.createElement("span");k(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,n=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";o.dataset.icon=oe(n);const r=e.icons?.[n];return void 0!==r&&function(e,t){"string"==typeof t?e.innerHTML=K(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,r),o}function ye(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function _e(e,t,o,i){i.classList.add(z.SORTABLE),i.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),i.addEventListener("click",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||we(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;we(e,t)}})}function Re(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",k(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i)),o.type&&n.setAttribute("data-type",o.type);const r=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>be(e,o)?Ce(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=K(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),be(e,o)&&_e(e,o,0,n),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}else if(o.headerLabelRenderer){const t={column:o,value:r},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=r:"string"==typeof s?l.innerHTML=K(s):s instanceof Node&&l.appendChild(s),n.appendChild(l),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)));else{const t=document.createElement("span");t.textContent=r,n.appendChild(t),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${z.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 Se(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[e],i=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:i}}),n={};return i.forEach(e=>{n[e.field]=e.type||"string"}),{columns:i,typeMap:n}}const Ee={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class xe{#o;#i=0;#n=0;#r=null;#s=null;#l=null;#a=!1;constructor(e){this.#o=e}requestPhase(e,t){e>this.#i&&(this.#i=e),0===this.#n&&(this.#c(),this.#n=requestAnimationFrame(()=>this.#d()))}whenReady(){return this.#r?this.#r:Promise.resolve()}setInitialReadyResolver(e){this.#l=e}cancel(){0!==this.#n&&(cancelAnimationFrame(this.#n),this.#n=0),this.#i=0,this.#s&&(this.#s(),this.#s=null,this.#r=null)}get isPending(){return 0!==this.#i}get pendingPhase(){return this.#i}#c(){this.#r||(this.#r=new Promise(e=>{this.#s=e}))}#d(){if(this.#n=0,!this.#o._schedulerIsConnected)return this.#i=0,void(this.#s&&(this.#s(),this.#s=null,this.#r=null));const e=this.#i;this.#i=0,e>=Ee.COLUMNS&&this.#o._schedulerMergeConfig(),e>=Ee.ROWS&&this.#o._schedulerProcessRows(),e>=Ee.COLUMNS&&(this.#o._schedulerProcessColumns(),this.#o._schedulerUpdateTemplate()),e>=Ee.HEADER&&this.#o._schedulerRenderHeader(),e>=Ee.VIRTUALIZATION&&this.#o.refreshVirtualWindow(!0,!0),e>=Ee.STYLE&&this.#o._schedulerAfterRender(),!this.#a&&this.#l&&(this.#a=!0,this.#l()),this.#s&&(this.#s(),this.#s=null,this.#r=null)}}class Te{#h;#u;#g;#f;#p;#w={};#m={};#b=!0;#v=[];#C;#y;#_;#R;#o;#S;constructor(e){this.#o=e}get original(){return this.#w}get effective(){return this.#m}get columns(){return this.#m.columns??[]}set columns(e){this.#m.columns=e}get lightDomColumnsCache(){return this.#f}set lightDomColumnsCache(e){this.#f=e}get originalColumnNodes(){return this.#p}set originalColumnNodes(e){this.#p=e}get lightDomTitle(){return this.#S}set lightDomTitle(e){this.#S=e}get initialColumnState(){return this.#R}set initialColumnState(e){this.#R=e}get sourcesChanged(){return this.#b}markSourcesChanged(){this.#b=!0}setGridConfig(e){this.#h!==e&&(this.#h=e,this.#b=!0,this.#f=void 0)}getGridConfig(){return this.#h}setColumns(e){this.#u=e,this.#b=!0}getColumns(){return this.#u}setFitMode(e){this.#g=e,this.#b=!0}getFitMode(){return this.#g}merge(){const e=(this.#m.columns?.length??0)>0;if(!this.#b&&e)return;const t=this.#E();this.#b=!1,this.#w=t,Object.freeze(this.#w),this.#w.columns&&Object.freeze(this.#w.columns),this.#m=this.#x(this.#w),this.#T()}#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}#T(){const e=this.#m;if(this.#A(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#o._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#o._applyAnimationConfig(e)}#A(){const e=this.#m.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#E(){const e=this.#h?{...this.#h}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#f??[]).map(e=>({...e}));let i=M(t,o);this.#u&&this.#u.length&&(i=M(this.#u,o));const n=this.#o.sourceRows;if(0===i.length&&n.length){i=Se(n).columns}return i.length&&(i.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)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=te(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=te(e.__editorTemplate.innerHTML))}),e.columns=i),this.#g&&(e.fitMode=this.#g),e.fitMode||(e.fitMode="stretch"),this.#P(e),e.columnState&&!this.#R&&(this.#R=e.columnState),e}#P(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#o._shellState.lightDomTitle;t&&(this.#S=t),this.#S&&!e.shell.header.title&&(e.shell.header.title=this.#S);const o=this.#o._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#o._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#o._shellState.toolPanels;if(i.size>0){const t=Array.from(i.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const n=this.#o._shellState.headerContents;if(n.size>0){const t=Array.from(n.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const r=this.#o._shellState.toolbarContents,s=Array.from(r.values()),l=this.#h?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#H();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},r=t;void 0!==r.__renderedWidth?n.width=r.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=o.get(t.field);s&&(n.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const r=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(r.length>0){const e=r[0];e.sort&&(this.#o._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#o._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#R=void 0,this.#o._sortState=null,this.#m=this.#x(this.#w),this.#T();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)}#H(){const e=/* @__PURE__ */new Map,t=this.#o._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=void 0;const t=this.collectState(e);this.#o._emit("column-state-change",t)},100)}setColumnVisible(e,t){const o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#o._emit("column-visibility",{field:e,visible:t,visibleColumns:o.filter(e=>!e.hidden).map(e=>e.field)}),this.#o._clearRowPool(),this.#o._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.#o._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#o._clearRowPool(),this.#o._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])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,this.#o._invalidateVisibleColumnsCache(),Re(this.#o),I(this.#o),this.#o._requestSchedulerPhase(Ee.COLUMNS,"configManager")}parseLightDomColumns(e){this.#f||(this.#p=Array.from(e.querySelectorAll("tbw-grid-column")),this.#f=this.#p.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const o=e.getAttribute("type")||void 0,i={field:t,type:o&&/* @__PURE__ */new Set(["number","string","date","boolean","select"]).has(o)?o:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const r=e.getAttribute("minWidth")||e.getAttribute("min-width");if(r){const e=parseFloat(r);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,m=g.find(e=>e.canHandle(w));if(m){const e=m.createEditor(w);e&&(i.editor=e)}return i}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#f=void 0}#M=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#M.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#M.delete(e.toLowerCase())}observeLightDOM(e){this.#C&&this.#C.disconnect();const t=/* @__PURE__ */new Set,o=()=>{this.#_=void 0;for(const e of t){const t=this.#M.get(e);t?.()}t.clear()};this.#C=new MutationObserver(e=>{for(const o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#M.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#M.has(e)&&t.add(e)}}t.size>0&&!this.#_&&(this.#_=setTimeout(o,0))}),this.#C.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#v.push(e)}notifyChange(){for(const e of this.#v)e()}dispose(){this.#C?.disconnect(),this.#v=[],this.#y&&clearTimeout(this.#y),this.#_&&(clearTimeout(this.#_),this.#_=void 0)}}function Ae(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 Pe(e,t,o="rows"){const i=document.createElement("div");return i.className="tbw-empty-overlay",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("data-overlay-target",o),i.appendChild(function(e,t){const o=(t??Ae)(e);if("string"==typeof o){const e=document.createElement("div");return e.className="tbw-empty-message",e.innerHTML=K(o),e}return o}(e,t)),i}function He(e){e?.remove()}function Me(){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 ke(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"&#x1F5F9;":"&#9744;"}</span>`}function Le(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 Oe(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function De(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Ie(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 ze(e){return"rtl"===Ie(e)}function Ne(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function qe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(t.type,e._hostElement);if(o?.renderer)return o.renderer}}function $e(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}const Fe='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function We(e){return(e.__editingCellCount??0)>0}function Be(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${z.EDITING}`).forEach(e=>e.classList.remove(z.EDITING))}const Ve=document.createElement("template");Ve.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ue=document.createElement("template");function Ge(){return Ve.content.firstElementChild.cloneNode(!0)}function je(){return Ue.content.firstElementChild.cloneNode(!0)}function Ye(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Xe(e,t,o,i){const n=t.children,r=e._visibleColumns,s=r.length,l=n.length,d=s<l?s:l,h=e._focusRow,u=e._focusCol,g=e._hasAfterCellRenderHook?.()??!1;let f=e.__hasSpecialColumns;if(void 0===f){f=!1;const t=e.__frameworkAdapter;for(let o=0;o<s;o++){const i=r[o];if(i.__viewTemplate||i.__compiledView||i.renderer||i.viewRenderer||i.externalView||i.format||i.cellClass||"date"===i.type||"boolean"===i.type||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.renderer||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.format){f=!0;break}}e.__hasSpecialColumns=f}const p=String(i);if(f){for(let s=0;s<d;s++){if(r[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void Ke(e,t,o,i)}}for(let s=0;s<d;s++){const l=r[s],d=n[s];d.getAttribute("data-row")!==p&&d.setAttribute("data-row",p);const f=d.classList.contains(z.EDITING);if(!f){const e=h===i&&u===s;e!==d.classList.contains("cell-focus")&&(d.classList.toggle("cell-focus",e),d.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=d.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&d.classList.remove(e[t])}try{const e=m(re(o,l,i),o,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(d.classList.add(i),e+=(e?" ":"")+i)}d.setAttribute("data-dynamic-classes",e)}else d.removeAttribute("data-dynamic-classes")}catch(w){A(a,`cellClass callback error for column '${l.field}': ${w}`,e.id),d.removeAttribute("data-dynamic-classes")}}if(f)continue;const b=qe(e,l);if(b){const n=re(o,l,i),r=b({row:o,value:n,field:l.field,column:l,grid:e,cellEl:d});"string"==typeof r?(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(r)):r instanceof Node?r.parentElement!==d&&(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML="",d.appendChild(r)):null==r&&(e.__frameworkAdapter?.releaseCell?.(d),d.textContent=null==n?"":String(n)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.__compiledView){const n=re(o,l,i),r=l.__compiledView({row:o,value:n,field:l.field,column:l});l.__compiledView.__blocked?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(r),ee(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.__viewTemplate){const n=re(o,l,i),r=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(r)?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(Q(r,{row:o,value:n})),ee(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.externalView)continue;const v=re(o,l,i);let C;d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d);const y=$e(e,l);if(y){try{const e=y(v,o);C=null==e?"":String(e)}catch(w){A(c,`Format error in column '${l.field}': ${w}`,e.id),C=null==v?"":String(v)}d.textContent=C}else"date"===l.type?(C=Le(v),d.textContent=C):"boolean"===l.type?d.innerHTML=ke(!!v):(C=null==v?"":String(v),d.textContent=C);g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:v,cellElement:d,rowElement:t})}}else for(let a=0;a<d;a++){const s=n[a];if(s.classList.contains(z.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=r[a],c=re(o,l,i);s.textContent=null==c?"":String(c),s.getAttribute("data-row")!==p&&s.setAttribute("data-row",p);const d=h===i&&u===a;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:a,value:c,cellElement:s,rowElement:t})}}function Ke(e,t,o,i){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 r=e._visibleColumns,s=r.length,l=e._focusRow,d=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let f=0;f<s;f++){const n=r[f],s=Ge();s.setAttribute("aria-colindex",String(f+1)),s.setAttribute("data-col",String(f)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let p=re(o,n,i);const w=$e(e,n);if(w)try{p=w(p,o)}catch(g){A(c,`Format error in column '${n.field}': ${g}`,e.id)}const m=n.__compiledView,b=n.__viewTemplate,v=qe(e,n),C=n.externalView;let y=!1;if(v){const t=v({row:o,value:p,field:n.field,column:n,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=K(t),y=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==p?"":String(p))}else if(C){const t=C,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",n.field),s.appendChild(i);const r={row:o,value:p,field:n.field,column:n,grid:e};if(t.mount)try{t.mount({placeholder:i,context:r,spec:t})}catch(g){A("TBW063",`External view mount error for column '${n.field}': ${g}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:i,spec:t,context:r}}))}catch(g){A("TBW064",`External view event dispatch error for column '${n.field}': ${g}`,e.id)}});i.setAttribute("data-mounted","")}else if(m){const e=m({row:o,value:p,field:n.field,column:n}),t=m.__blocked;s.innerHTML=t?"":K(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(b){const e=b.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=K(Q(e,{row:o,value:p})),y=!0)}else w?s.textContent=null==p?"":String(p):"date"===n.type?s.textContent=Le(p):"boolean"===n.type?s.innerHTML=ke(!!p):s.textContent=null==p?"":String(p);if(y){ee(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(o):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===i&&d===f?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const _=n.cellClass;if(_)try{const e=_(re(o,n,i),o,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(g){A(a,`cellClass callback error for column '${n.field}': ${g}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:n,colIndex:f,value:p,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function Ze(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=Oe(o.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,o))return;const r=t.target?.closest(".cell[data-col]");if(r){const o=Number(r.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,r))return;const n=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,r.classList.contains(z.EDITING)){n&&(De(e._bodyEl??e),r.classList.add("cell-focus"));const o=t.target,i=r.contains(o)&&o.matches(Fe)?o:r.querySelector(Fe);try{i?.focus({preventScroll:!0})}catch{}return}ht(e)}}}function Qe(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 Je(e,t,o){const i=Qe(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function et(e,t,o){if(t<0||t>=e.length)return;const i=e[t],n=o-i.height;if(0!==n){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=n}}function tt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const n=Math.floor((o+i)/2),r=e[n],s=r.offset+r.height;if(t<r.offset)i=n-1;else{if(!(t>=s))return n;o=n+1}}return Math.max(0,Math.min(o,e.length-1))}function ot(e,t){const{positionCache:o,heightCache:i,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<r||d>=s||d>=n.length)return;const h=n[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(et(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(et(o,d,g),function(e,t,o,i){const n=Qe(t,i);"string"==typeof n?e.byKey.set(n,o):n&&"object"==typeof n&&e.byRef.set(n,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const n of e)n.measured&&(o+=n.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}Ue.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const it=335e5;function nt(e,t,o=it){return{rawContentHeight:e,spacerHeight:Math.min(e,o),viewportHeight:t,capped:e>o}}function rt(e,t){if(!t.capped)return e;const o=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;if(o<=0||i<=0)return e;const n=e*i/o;return n<0?0:n>i?i:n}function st(e,t){if(!t.capped)return e;const o=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;return o<=0||i<=0?e:e*o/i}function lt(e){const{totalRows:t,viewportHeight:o,scrollTop:i,rowHeight:n,overscan:r,maxSpacerHeight:s=it}=e,l=Math.ceil(o/n),a=t*n,c=nt(a,o,s),d=rt(i,c);let h=Math.floor(d/n)-r;h<0&&(h=0);let u=h+l+2*r;return u>t&&(u=t),u===t&&h>0&&(h=Math.max(0,u-l-2*r)),{start:h,end:u,offsetY:h*n,totalHeight:c.spacerHeight,rawContentHeight:a}}function at(e,t){return e<=t}function ct(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function dt(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function ht(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i,scrollMapping:n}=e._virtualization,r=o,s=i?.clientHeight??r?.clientHeight??0;if(r&&s>0){const o=e._focusRow*t,i=n?rt(r.scrollTop,n):r.scrollTop;if(o<i)r.scrollTop=n?st(o,n):o;else if(o+t>i+s){const e=o-s+t;r.scrollTop=n?st(e,n):e}}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),De(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,n=e._virtualization.start??0,r=e._virtualization.end??e._rows.length;if(i>=n&&i<r){const r=e._bodyEl.querySelectorAll(".data-grid-row")[i-n];let s=r?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=r?.querySelector(`.cell[data-col="${e._focusCol}"]`)??r?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(r??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),n=e.left-o.left+i.scrollLeft,r=n+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;n<l?i.scrollLeft=n-t.left:r>a&&(i.scrollLeft=r-i.clientWidth+t.right)}}if(o&&s.classList.contains(z.EDITING)){const e=s.querySelector(Fe);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!o){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 ut=/* @__PURE__ */new WeakMap;function gt(e,t){const o=Oe(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,De(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 ft(e,t,o,i){let n=null;const r=o.composedPath?.();if(n=r&&r.length>0?r[0]:o.target,n&&!t.contains(n)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function pt(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,r=e._visibleColumns[e._focusCol],s=r?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target;if((!a||a===e||a.closest?.(".rows-body"))&&(!dt(a)||"Home"!==t.key&&"End"!==t.key)&&!(dt(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||dt(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||dt(a)&&("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&&ct(e),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:(ct(e),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void ht(e);case"ArrowDown":n&&ct(e),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&ct(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=ze(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=ze(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&ct(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void ht(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&ct(e),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void ht(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],r=e._rows[o],s=n?.field??"",l=s&&r?r[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:n,field:s,value:l,row:r,cellEl:a,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}ht(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=ft(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&ut.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!ut.get(e))return;const i=ft(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!ut.get(e))return;const i=ft(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),ut.set(e,!1)}(e,o,t),{signal:i})}let wt;function mt(e){wt=e}class bt{#o;#k=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#O=null;#D=null;constructor(e){this.#o=e,this.#I()}focusCell(e,t){const o=this.#o,i=o._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=o._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const r=o._visibleColumns.length-1;r<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(n,r)),ht(o))}get focusedCell(){const e=this.#o;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 o=this.#o._virtualization;if(!o.enabled)return;const i=o.container;if(!i)return;const n=this.#o._rows.length;if(0===n)return;const r=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,c;const d=o.positionCache;o.variableHeights&&d&&d.length>r?(a=d[r].offset,c=d[r].height):(a=r*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p);const w=st(p,o.scrollMapping);"smooth"===l?i.scrollTo({top:w,behavior:"smooth"}):i.scrollTop=w}scrollToRowById(e,t){const o=this.#o._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#k.has(e))return;this.#k.add(e);const t=new AbortController,o=t.signal,i=this.#o;e.addEventListener("focusin",e=>{i.dataset.hasFocus="",this.#z(e.target)},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus,null===t&&this.#N()},{signal:o}),this.#L.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#k.delete(e);const t=this.#L.get(e);t&&(t(),this.#L.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#o.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#k)if(t.contains(e))return!0;return!1}#I(){const e=this.#o,t=new AbortController,o=t.signal;e.addEventListener("focusin",e=>this.#z(e.target),{signal:o,capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#N()},{signal:o}),this.#D=()=>t.abort()}#z(e){if(!(e instanceof HTMLElement))return;if(e===this.#o)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#O=e)}#N(){queueMicrotask(()=>{if(!this.#o.isConnected)return;document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#O;if(!e)return!1;if(!e.isConnected)return this.#O=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#O?.isConnected?this.#O:null}destroy(){for(const e of this.#L.values())e();this.#L.clear(),this.#k.clear(),this.#D?.(),this.#D=null,this.#O=null}}const vt="function"==typeof requestIdleCallback;function Ct(e){vt?cancelIdleCallback(e):clearTimeout(e)}function yt(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}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 _t(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 o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}function Rt(e){let t=null,o=null,i=null,n=null;const r=i=>{if(!t)return;const n=i.clientX-t.startX,r=Math.max(40,t.startWidth+n),s=e._visibleColumns[t.colIndex];s.width=r,s.__userResized=!0,s.__renderedWidth=r,null==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:r}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,o){const i=o.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const o=e._visibleColumns[n];if(null==o.width&&!o.__userResized){const e=i[n],t=e?.getBoundingClientRect().width;t&&(o.width=Math.round(t),o.__userResized=!0,o.__renderedWidth=o.width)}}}(s,c);const d=e._visibleColumns[s],h="number"==typeof d?.width?d.width:void 0,u=d?.__renderedWidth??h??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:u},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),null===i&&(i=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 o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const St="data-animating",Et={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},xt={change:500,insert:300,remove:200};function Tt(e,t){const o=Et[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return xt[t]}function At(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(St),e.offsetWidth,e.setAttribute(St,t);const i=Tt(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(St),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Pt(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function Ht(e,t,o){const i=Pt(e,o);return void 0===i&&T("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Mt{#o;constructor(e){this.#o=e}resolveRowId(e){return Ht(e,this.#o.id,this.#o.effectiveConfig?.getRowId)}getRow(e){return this.#o._getRowEntry(e)?.row}getRowEntry(e){return this.#o._getRowEntry(e)}updateRow(e,t,o="api"){const i=this.#o,n=i._getRowEntry(e);n||T(l,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:r,index:s}=n,a=[];for(const[l,c]of Object.entries(t)){const e=r[l];e!==c&&(a.push({field:l,oldValue:e,newValue:c}),r[l]=c,se(r,l))}for(const{field:l,oldValue:c,newValue:d}of a)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:r,rowId:e,rowIndex:s,field:l,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));a.length>0&&(Ye(i),i._requestSchedulerPhase(Ee.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#o;let i=!1;for(const{id:n,changes:r}of e){const e=o._getRowEntry(n);e||T(l,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:s,index:a}=e;for(const[l,c]of Object.entries(r)){const e=s[l];e!==c&&(i=!0,s[l]=c,se(s,l),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:n,rowIndex:a,field:l,oldValue:e,newValue:c,changes:r,source:t},bubbles:!0,composed:!0})))}}i&&(Ye(o),o._requestSchedulerPhase(Ee.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#o,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const r=[...i._rows];r.splice(n,0,t),i._rows=r,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Ye(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let s=0;s<i._rowPool.length;s++)i._rowPool[s].__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await At(i,n,"insert"))}async removeRow(e,t=!0){const o=this.#o,i=o._rows[e];if(!i)return;t&&await At(o,e,"remove");const n=o._rows.indexOf(i);if(n<0)return i;const r=[...o._rows];r.splice(n,1),o._rows=r;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Ye(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let l=0;l<o._rowPool.length;l++)o._rowPool[l].__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}async applyTransaction(e,t=!0){const o=this.#o,i={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:l}of e.remove){const e=o._getRowEntry(l);if(!e)continue;const{row:n}=e;if(t){const e=o._rows.indexOf(n);e>=0&&await At(o,e,"remove")}const r=o._rows.indexOf(n);if(r<0){i.removed.push(n);continue}const s=[...o._rows];s.splice(r,1),o._rows=s;const a=o.sourceRows.indexOf(n);if(a>=0){const e=[...o.sourceRows];e.splice(a,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(n);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}i.removed.push(n)}const n=new Set(e.remove?.map(e=>e.id));if(e.update?.length)for(const{id:l,changes:a}of e.update){if(n.has(l))continue;const e=o._getRowEntry(l);if(!e)continue;const{row:t,index:r}=e;let s=!1;for(const[i,n]of Object.entries(a)){const e=t[i];e!==n&&(s=!0,t[i]=n,se(t,i),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:l,rowIndex:r,field:i,oldValue:e,newValue:n,changes:a,source:"api"},bubbles:!0,composed:!0})))}s&&i.updated.push(t)}if(e.add?.length)for(const l of e.add){o.sourceRows=[...o.sourceRows,l];const e=[...o._rows];e.push(l),o._rows=e,o._sortState&&(o.__originalOrder=[...o.__originalOrder,l]),i.added.push(l)}const r=i.added.length>0||i.removed.length>0,s=i.updated.length>0;if(r){Ye(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let e=0;e<o._rowPool.length;e++)o._rowPool[e].__epoch=-1;o.refreshVirtualWindow(!0)}else s&&(Ye(o),o._requestSchedulerPhase(Ee.VIRTUALIZATION,"applyTransaction"));if((r||s)&&o._emitDataChange(),t&&i.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of i.added){const t=o._rows.indexOf(e);t>=0&&await At(o,t,"insert")}}if(t&&i.updated.length>0)for(const l of i.updated){const e=o._rows.indexOf(l);e>=0&&await At(o,e,"change")}return t&&i.removed.length>0&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}#q=null;#$=[];#F=null;applyTransactionAsync(e){return this.#q||(this.#q={add:[],update:[],remove:[]}),e.add&&this.#q.add.push(...e.add),e.update&&this.#q.update.push(...e.update),e.remove&&this.#q.remove.push(...e.remove),new Promise(e=>{this.#$.push(e),null===this.#F&&(this.#F=requestAnimationFrame(()=>{this.#F=null;const e=this.#q,t=this.#$;this.#q=null,this.#$=[],this.applyTransaction(e,!1).then(e=>{for(const o of t)o(e)})}))})}}function kt(e,t){if(t)for(const o in t){const i=t[o];null!=i&&e.setAttribute(o,i)}}function Lt(e,t,o){const i=document.createElement(e);return kt(i,t),i}function Ot(e,t){const o=document.createElement("div");return e&&(o.className=e),kt(o,t),o}function Dt(e,t,o){const i=document.createElement("button");return i.type="button",e&&(i.className=e),kt(i,t),i}const It=document.createElement("template");function zt(){return It.content.cloneNode(!0)}function Nt(e){const t=document.createDocumentFragment(),o=Ot(e.hasShell?`${z.ROOT} has-shell`:z.ROOT);if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ot("tbw-grid-content");e.appendChild(zt()),o.appendChild(e)}return t.appendChild(o),t}function qt(e){const t=Ot("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ot("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ot("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ot("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&i.appendChild(Ot("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&i.appendChild(Ot("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const n=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),r=e.hasPanels&&!1!==e.showToggle;if(n&&r&&i.appendChild(Ot("tbw-toolbar-separator")),r){const t=Dt(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=K(e.toolPanelIcon)),i.appendChild(t)}return t.appendChild(i),t}function $t(e){const t=Ot("tbw-shell-body",{"data-mode":e.mode??"overlay"}),o=e.panels.length>0,i=1===e.panels.length,n=Ot("tbw-grid-content");n.appendChild(zt());let r=null;if(o){r=Lt("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";r.appendChild(Ot("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ot("tbw-tool-panel-content",{role:"presentation"}),n=Ot("tbw-accordion");for(const r of e.panels){const t=Ot(`tbw-accordion-section${r.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":r.id}),o=Dt("tbw-accordion-header",{"aria-expanded":String(r.isExpanded),"aria-controls":`tbw-section-${r.id}`});if(i&&o.setAttribute("aria-disabled","true"),r.icon){const e=Lt("span",{class:"tbw-accordion-icon"});e.innerHTML=K(r.icon),o.appendChild(e)}const s=Lt("span",{class:"tbw-accordion-title"});if(s.textContent=r.title,o.appendChild(s),!i){const t=Lt("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=K(e.expandIcon)),o.appendChild(t)}t.appendChild(o),t.appendChild(Ot("tbw-accordion-content",{id:`tbw-section-${r.id}`,role:"presentation"})),n.appendChild(t)}o.appendChild(n),r.appendChild(o)}return"left"===e.position&&r?(t.appendChild(r),t.appendChild(n)):(t.appendChild(n),r&&t.appendChild(r)),t}function Ft(e){return e?"string"==typeof e?K(e):e.outerHTML:""}function Wt(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function Bt(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function Vt(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),i.style.display="none"}function Ut(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,n=i.getAttribute("id"),r=i.getAttribute("title");if(!n||!r)return void A("TBW070",`Tool panel missing required id or title attribute: id="${n??""}", title="${r??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=K(i.innerHTML.trim());c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(n);if(h){if(d){const e=!t.adapterBoundToolPanelIds.has(n),o=h.order!==a||h.icon!==s||h.tooltip!==l;if(h.render=c,h.order=a,h.icon=s,h.tooltip=l,t.adapterBoundToolPanelIds.add(n),e||o){const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n))}}return}const u={id:n,title:r,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(n,u),t.lightDomToolPanelIds.add(n),d&&t.adapterBoundToolPanelIds.add(n),i.style.display="none"})}function Gt(e,t,o){const i=t?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(e=>e.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function jt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const n=e.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",n.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of r){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=n.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),n.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function Yt(e,t,o){if(t.isPanelOpen)for(const[i,n]of t.toolPanels){const o=t.expandedSections.has(i),r=e.querySelector(`[data-section="${i}"]`),s=r?.querySelector(".tbw-accordion-content");if(!r||!s)continue;r.classList.toggle("expanded",o);const l=r.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=n.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function Xt(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function Kt(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function Zt(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function Qt(e,t,o){const i=void 0!==o?.toolPanel?Ft(o.toolPanel):void 0,n=void 0!==o?.expand?Ft(o.expand):void 0,r=void 0!==o?.collapse?Ft(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),l=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:l.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:i,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:n,collapseIcon:r,panels:l.map(e=>({id:e.id,title:e.title,icon:Ft(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function Jt(e,t,o,i){const n=Wt(t),r=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(z.ROOT)||r.push(s);e.replaceChildren();for(const s of r)e.appendChild(s);if(n){const{headerOptions:n,bodyOptions:r}=Qt(t,o,i),s=Nt({hasShell:!0,shellHeader:qt(n),shellBody:$t(r)});e.appendChild(s)}else{const t=Nt({hasShell:!1});e.appendChild(t)}return n}function eo(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}It.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';const to="tbw-grid-styles";let oo="";const io=/* @__PURE__ */new Map;function no(){const e=function(){const e=Co.activeTag;return e===Co.tagName?to:`${to}-${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 ro(e){const t=Co.activeTag;return t===Co.tagName?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function so(){const e=no(),t=Array.from(io.values()).join("\n");e.textContent=`${oo}\n\n/* Plugin Styles */\n${t}`}async function lo(e){if(oo)return;if("string"==typeof e&&e.length>0)return oo=ro(e),void so();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){A("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(oo=ro(t),so()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||A("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 ao(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function co(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function ho(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 o=.95,i=1;let n=performance.now();const r=()=>{const s=performance.now(),l=s-n;n=s;const a=l/16,c=Math.pow(o,a);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,h=16*e.velocityX,u=Math.abs(d)>=i,g=Math.abs(h)>=i;u&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=h),e.momentumRaf=u||g?requestAnimationFrame(r):0};e.momentumRaf=requestAnimationFrame(r)}(e,t),ao(e)}function uo(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){co(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const n=performance.now(),r=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=n-o.lastTime;e>0&&(o.velocityY=r/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=n,o.locked){const{scrollTop:e,scrollHeight:t,clientHeight:o}=i.fauxScrollbar;if(r>0&&e<t-o||r<0&&e>0?i.fauxScrollbar.scrollTop+=r:0!==r&&window.scrollBy(0,r),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:o}=i.scrollArea;s>0&&e<t-o||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ho(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ao(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ao(t))},{passive:!0,signal:i})}const go=[{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}],fo=[{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 po(e){return`import { ${wo(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function wo(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mo(e,t){return e.some(e=>e.name===t)}class bo{#o;state;constructor(e,t){this.#o=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,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,n,r;if(t){const e=o.container??this.#o._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,n=t?.clientHeight??0,r=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=n,o.cachedScrollAreaHeight=r}else i=o.cachedFauxHeight,n=o.cachedViewportHeight,r=o.cachedScrollAreaHeight||i;const s=r-n,l=Math.max(0,i-r);let a;return a=o.variableHeights&&o.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):e*o.rowHeight,o.scrollMapping=nt(a,n),o.scrollMapping.spacerHeight+s+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#o,o=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,r=t.effectiveConfig?.getRowId,s=r?e=>r(e):void 0;e.positionCache=function(e,t,o,i,n){const r=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=n?.(a,l),d=void 0!==c;void 0===c&&(c=Je(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(n){const t=n(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let n=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(r+=o.height,n++)}}return{measuredCount:n,averageHeight:n>0?r/n:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#o._rows;if(e<0||e>=i.length)return;const n=i[e];let r=t;void 0===r&&(r=this.#o._getPluginRowHeight(n,e)),void 0===r&&(r=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-r)<1)&&(et(o.positionCache,e,r),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#o,n=i._bodyEl;if(!n)return;const r=n.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=ot({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},r);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#o,n=i._bodyEl;if(!n)return!1;const r=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,r),t||i._afterPluginRender(),!0;if(r<=o.bypassThreshold)return o.start=0,o.end=r,e&&(n.style.transform="translateY(0px)"),i._renderVisibleRows(0,r,i.__rowRenderEpoch),e&&o.variableHeights&&this.initializePositionCache(),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(r,!0)}px`),i._updateAriaCounts(r,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=rt(s.scrollTop,o.scrollMapping);let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;o.variableHeights&&u&&u.length>0?(h=tt(u,d),-1===h&&(h=0)):h=Math.floor(d/c),h-=h%2,h<0&&(h=0),r>0&&h>r-1&&(h=r-1);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<r&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,r))}else{f=h+(Math.ceil(a/c)+3)}f>r&&(f=r);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const m=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===m&&a>0)return i._requestSchedulerPhase(Ee.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(r);o.totalHeightEl.style.height=`${e}px`}let b;b=o.variableHeights&&u&&u[h]?u[h].offset:h*c;const v=-(d-b);return n.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(r,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(r);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class vo{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;#W=/* @__PURE__ */new Map;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;attachAll(e){const t=this.#B(e);for(const o of t)this.attach(o)}#B(e){if(e.length<2)return e;const t=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=[];for(const n of e){const e=n.constructor,r=t.get(e);if(!r){t.set(e,n),i.push(n);continue}const s=o.get(r)??[];s.push(n),o.set(r,s)}if(0===o.size)return i;for(const[n,r]of o)n.mergeConfigsFrom(r);return i}attach(e){if(function(e,t,o){const i=e.name,n=e.constructor.dependencies??[];for(const r of n){const e=r.name,n=r.required??!0,s=r.reason;if(!t.some(t=>t.name===e)){const t=s??`${wo(i)}Plugin requires ${wo(e)}Plugin`,r=po(e);n&&T("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${wo(i)}Plugin:\n ${r}\n plugins: [new ${wo(e)}Plugin(), new ${wo(i)}Plugin()]`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),e.attach(this.grid),this.#V();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 o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.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.#W.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 o of this.#U("processRows")){const e=o.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const o of this.#U("processColumns"))t=o.processColumns(t);return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.#U("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#U("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#U("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#V(){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.#W.clear()}#U(e){let t=this.#W.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const o=t=>{const o=t.constructor.manifest?.hookPriority;if(!o)return 0;return o[e]??0};return t.some(e=>0!==o(e))&&t.sort((e,t)=>o(e)-o(t)),this.#W.set(e,t),t}onScrollRender(){for(const e of this.#U("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const r=n.adjustVirtualStart(e,t,o);r<i&&(i=r)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=/* @__PURE__ */new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const n of o.values())try{n(t)}catch(i){H("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#U("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#U("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#U("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#U("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#U("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#U("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#U("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#U("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,n=!1;for(const r of this.plugins){const s=r.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:o,right:i,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class Co extends HTMLElement{static tagName="tbw-grid";static version="2.14.0";static activeTag="tbw-grid";static#G=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#j(){return this}#Y=!1;#r;#s;#X=[];get#m(){return this.#K?.effective??{}}#Z=!1;#Q=!1;#J={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#ee;#te=0;#oe=null;#ie=!1;#ne=!1;#re=0;#se;#le={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#ae;#ce;#de;#he;#ue={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ge;#fe;#pe;#we;#me;#be;get _pluginManager(){return this.#ge}#ve=!1;#Ce;#ye;#R;#K;#_e=function(){return{toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1}}();#Re;#Se;#Ee;#xe=!1;#Te=/* @__PURE__ */new Set;#Ae=/* @__PURE__ */new Map;#Pe;#He={};#Me=/* @__PURE__ */new Map;#ke=!1;_rows=[];#Le=[];get _columns(){return this.#m.columns??[]}set _columns(e){this.#m.columns=e,this.#Oe=void 0}#Oe;get _visibleColumns(){return this.#Oe??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Oe=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#we.state}set _virtualization(e){Object.assign(this.#we.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#K?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#K&&(this.#K.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#K?.originalColumnNodes}set __originalColumnNodes(e){this.#K&&(this.#K.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],o=this.#X;this.#X=t,o!==t&&this.#De("rows")}get sourceRows(){return this.#X}set sourceRows(e){this.#X=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=this.#K?.getColumns();this.#K?.setColumns(e),t!==e&&this.#De("columns")}get gridConfig(){return this.#m}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#K?.getGridConfig();this.#K?.setGridConfig(e),t!==e&&(this.#K.clearLightDomCache(),this.#De("gridConfig"))}get fitMode(){return this.#m.fitMode??"stretch"}set fitMode(e){const t=this.#K?.getFitMode();this.#K?.setFitMode(e),t!==e&&this.#De("fitMode")}get loading(){return this.#xe}set loading(e){const t=this.#xe;this.#xe=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Ie(),this.#ze())}setRowLoading(e,t){const o=this.#Te.has(e);t?this.#Te.add(e):this.#Te.delete(e),o!==t&&this.#Ne(e,t)}setCellLoading(e,t,o){let i=this.#Ae.get(e);const n=i?.has(t)??!1;o?(i||(i=/* @__PURE__ */new Set,this.#Ae.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#Ae.delete(e)),n!==o&&this.#qe(e,t,o)}isRowLoading(e){return this.#Te.has(e)}isCellLoading(e,t){return this.#Ae.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Te)this.#Ne(e,!1);this.#Te.clear();for(const[e,t]of this.#Ae)for(const o of t)this.#qe(e,o,!1);this.#Ae.clear()}get effectiveConfig(){return this.#m}get disconnectSignal(){return this.#ae||(this.#ae=new AbortController),this.#ae.signal}constructor(){super(),this.#$e(),this.#r=new Promise(e=>this.#s=e),this.#we=new bo(this),this.#me=new bt(this),this.#be=new Mt(this),this.#ee=new xe(this),this.#ee.setInitialReadyResolver(()=>this.#s?.()),this.#Re=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o){if(0===e.toolPanels.size)return void A("TBW071","No tool panels registered",t.id);let n;if(void 0!==o&&(e.toolPanels.has(o)?n=o:A(d,`Tool panel "${o}" not found`,t.id)),e.isPanelOpen&&n&&e.expandedSections.has(n))return;if(e.isPanelOpen&&n&&!e.expandedSections.has(n))return void i.toggleToolPanelSection(n);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(n)e.expandedSections.add(n);else{const o=t.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(o&&e.toolPanels.has(o))e.expandedSections.add(o);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(n&&!e.expandedSections.has(n)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(n)}const r=t._renderRoot;Xt(r,e),Kt(r,e),Yt(r,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(t.effectiveConfig?.shell?.toolPanel?.locked)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;Xt(o,e),Kt(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void A(d,`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const n=t._renderRoot,r=e.expandedSections.has(o);if(r){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),eo(n,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),eo(n,t,!1);const r=n.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),eo(n,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const n=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&t.panelCleanups.set(o,r)}(n,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!r})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?A("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?A("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&jt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const n=e.headerContents.get(o);n?.onDestroy?.(),e.headerContents.delete(o);const r=t._renderRoot.querySelector(`[data-header-content="${o}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?A("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const n=e.toolbarContentCleanups.get(i);n&&(n(),e.toolbarContentCleanups.delete(i));const r=e.toolbarContents.get(i);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#_e,this),this.#K=new Te(this)}async#$e(){await lo('@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-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select: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-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.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}}}\n@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-shell-body[data-mode=push]{.tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none;&.open{border-left:1px solid var(--tbw-tool-panel-border)}&[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}}.tbw-tool-panel-resize{display:none}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display: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.#ge?.getPlugin(e)}getPluginByName(e){return this.#ge?.getPluginByName(e)}requestRender(){this.#ee.requestPhase(Ee.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#ee.requestPhase(Ee.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#ee.requestPhase(Ee.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){I(this)}requestAfterRender(){this.#ee.requestPhase(Ee.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Fe(){this.#ge=new vo(this);const e=this.#m?.plugins,t=Array.isArray(e)?e:[],o=this.#m?.features;let i,n=[];if(o&&wt&&(n=wt(o)),0===n.length)i=t;else if(0===t.length)i=n;else{const e=new Set(t.map(e=>e.name));i=[...n.filter(t=>!e.has(t.name)),...t]}this.#ge.attachAll(i)}#We(){!function(e){let t=!1;for(const{name:o,styles:i}of e)io.has(o)||(io.set(o,ro(i)),t=!0);t&&so()}(this.#ge?.getPluginStyles()??[])}#Be(){const e=this.#m?.plugins,t=Array.isArray(e)?e:[],o=this.#m?.features??void 0,i=o!==this.#pe;if((this.#fe===t||void 0!==this.#fe&&this.#fe.length===t.length&&this.#fe.every((e,o)=>e===t[o]))&&!i)return void(this.#fe=t);this.#ge&&this.#ge.detachAll();for(const r of this.#_e.toolPanels.keys()){const e=this.#_e.lightDomToolPanelIds.has(r),t=this.#_e.apiToolPanelIds.has(r);if(!e&&!t){const e=this.#_e.panelCleanups.get(r);e&&(e(),this.#_e.panelCleanups.delete(r)),this.#_e.toolPanels.delete(r)}}for(const r of this.#_e.headerContents.keys()){if(this.#_e.apiHeaderContentIds.has(r))continue;const e=this.#_e.headerContentCleanups.get(r);e&&(e(),this.#_e.headerContentCleanups.delete(r)),this.#_e.headerContents.delete(r)}this.#Fe(),this.#We(),this.#fe=t,this.#pe=o,this.#Ve(),this.#Ue();const n=this.#ie;if(this.#ie=this.#ge?.getAll().some(e=>e.onScroll)??!1,!n&&this.#ie){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.querySelector(".tbw-grid-root");this.#Ge(e)}}#je(){this.#ge?.detachAll()}#Ue(){if(!this.#ge)return;const e=this.#ge.getToolPanels();for(const{panel:o}of e)this.#_e.toolPanels.has(o.id)||this.#_e.toolPanels.set(o.id,o);const t=this.#ge.getHeaderContents();for(const{content:o}of t)this.#_e.headerContents.has(o.id)||this.#_e.headerContents.set(o.id,o)}#Ye(){const e=Co.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",Co.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++Co.#G),this._rows=Array.isArray(this.#X)?[...this.#X]:[],this.#ae&&(this.#ae.abort(),this.#ve=!1),this.#ae=new AbortController,this.#he&&(Ct(this.#he),this.#he=void 0),this.#Xe(),this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Fe();const e=this.#m?.plugins;var t,o;this.#fe=Array.isArray(e)?e:[],this.#pe=this.#m?.features??void 0,this.#Ue(),this.#Y||(this.#Ke(),this.#We(),this.#Y=!0),this.#Ze(),this.#he=(t=()=>{this.#Qe()},o={timeout:100},vt?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#he&&(Ct(this.#he),this.#he=void 0),this.#re&&(clearTimeout(this.#re),this.#re=0),this.#je(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#_e),this.#Re.setInitialized(!1),this.#Se?.(),this.#Se=void 0,this.#Ee?.(),this.#Ee=void 0,co(this.#le),this.#ae&&(this.#ae.abort(),this.#ae=void 0),this.#Ce?.abort(),this.#Ce=void 0,this.#ve=!1,this._resizeController&&this._resizeController.dispose(),this.#ce&&(this.#ce.disconnect(),this.#ce=void 0),this.#de&&(this.#de.disconnect(),this.#de=void 0,this.#Je=!1,this.#et=0),Ye(this),this.#tt.clear(),this._virtualization.heightCache?.byKey.clear(),this.#fe=void 0,this.#pe=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#Z=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{A("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#Ze(){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.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.#Re.isInitialized){jt(this.#j,this.#_e),Gt(this.#j,this.#m?.shell,this.#_e);const e=this.#m?.shell?.toolPanel,t=e?.defaultOpen;t&&this.#_e.toolPanels.has(t)&&this.#_e.expandedSections.add(t);const o=!0===e?.locked||"open"===e?.initialState||void 0===e?.initialState&&void 0!==t&&this.#_e.toolPanels.has(t);!this.#_e.isPanelOpen&&this.#_e.toolPanels.size>0&&o&&this.openToolPanel(),this.#_e.isPanelOpen&&(Kt(this.#j,this.#_e),Yt(this.#j,this.#_e,(this.#m,this.#m)),Xt(this.#j,this.#_e))}if(this.setAttribute("data-upgraded",""),this.#Z=!0,this._resizeController=Rt(this),this.#ot(),this.#Ge(e),this.#ve)return;this.#ve=!0;const t=this.disconnectSignal;pt(this,this,this.#j,t),this.#Ve(),queueMicrotask(()=>this.#it()),this.#ee.requestPhase(Ee.FULL,"afterConnect")}#Ve(){const e=this.#m.rowHeight,t=this.#ge.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.#we.initializePositionCache(),"function"!=typeof e&&(this.#ne=!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.#nt())}#nt(){if(this.#ge.hasRowHeightPlugin())return;const e=this.#m.rowHeight;if("number"==typeof e&&e>0)return;const t=this._bodyEl?.querySelector(".data-grid-row");if(!t)return;if(t.style.getPropertyValue("--tbw-row-height"))return;const o=this.#rt(),i=t.querySelectorAll(".cell");let n=0;i.forEach(e=>{const t=e.offsetHeight;t>n&&(n=t)});const r=t.getBoundingClientRect(),s=Math.max(r.height,n),l=this._virtualization.rowHeight,a=this.#et,c=o>0&&a>0&&Math.abs(o-a)>1,d=o>0&&0===a,h=s>0&&s-l>1;if(o>0&&(this.#et=o),c||d||h){const e=c||d?Math.max(o,s):s;Math.abs(e-l)>1&&(this._virtualization.rowHeight=e,this.#ee.requestPhase(Ee.VIRTUALIZATION,"measureRowHeight"))}}#rt(){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 o=parseFloat(getComputedStyle(t).minHeight);return o>0?o:0}#st(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#we.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#we.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Ge(e){this.#Ce?.abort(),this.#Ce=new AbortController;const t=this.#Ce.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#ie=this.#ge?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#ie)return;const e=o.scrollTop,t=rt(e,this._virtualization.scrollMapping),n=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const e=this._virtualization.positionCache;let o,r;if(this._virtualization.variableHeights&&e&&e.length>0){o=tt(e,t),-1===o&&(o=0);const i=o-o%2;r=e[i]?.offset??i*n}else{o=Math.floor(t/n);r=(o-o%2)*n}const s=-(t-r);i.style.transform=`translateY(${s}px)`}this.#oe=e,this.#te||(this.#te=requestAnimationFrame(()=>{this.#te=0,null!==this.#oe&&(this.#lt(this.#oe),this.#oe=null)}))},{passive:!0,signal:t});const e=this.#j.querySelector(".tbw-scroll-area");this.#ye=e,this._virtualization.scrollAreaEl=e,e&&this.#ie&&e.addEventListener("scroll",()=>{const t=this.#ue;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#ge?.onScroll(t)},{passive:!0,signal:t});const n=this.#j.querySelector(".tbw-grid-content"),r=this.#ye;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&&r){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:o,scrollWidth:i,clientWidth:n}=r;(t>0&&o<i-n||t<0&&o>0)&&(e.preventDefault(),r.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:n}=o;(e.deltaY>0&&t<i-n||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),uo(n,this.#le,{fauxScrollbar:o,scrollArea:r},t))}var n,r,s;this._bodyEl&&(n=this,r=this._bodyEl,s=t,r.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(z.EDITING))return;const o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),gt(n,t)},{signal:s}),r.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&Ze(n,e,t),!document.activeElement?.closest(`.cell.${z.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),r.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&Ze(n,e,t)},{signal:s})),this.#ce?.disconnect(),this._virtualization.viewportEl&&(this.#ce=new ResizeObserver(()=>{this.#at(),this.#ee.requestPhase(Ee.VIRTUALIZATION,"resize-observer")}),this.#ce.observe(this._virtualization.viewportEl)),this.#j.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#j.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#j.contains(t)||this.#me.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Je=!1;#et=0;#ct(){if(this.#Je)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Je=!0,this.#de?.disconnect(),this.#de=new ResizeObserver(()=>{this.#nt()}),this.#de.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#dt(e,t){this.#Z&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#dt("data-change",{rowCount:this._rows.length,sourceRowCount:this.#X.length}),function(e,t,o){if(o===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=o,0===o&&i<0||n(e,r(e,"dataLoaded",o))}(this,this.#ht,this.#X.length)}#it(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#De(e){this.#J[e]=!0,this.#Q||(this.#Q=!0,queueMicrotask(()=>this.#ut()))}#ut(){if(!this.#Q||!this.#Z)return void(this.#Q=!1);const e=this.#J;if(this.#Q=!1,this.#J={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#gt(),void(e.rows&&this.#ft());e.columns&&this.#pt(),e.rows&&this.#ft(),e.fitMode&&this.#wt()}#ft(){this._rows=Array.isArray(this.#X)?[...this.#X]:[],this.#ke=!0,this.#ee.requestPhase(Ee.ROWS,"applyRowsUpdate")}#mt(){this.#ke&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#ke=!1,this.#Me.clear();const e=this.#m.getRowId;for(let t=0;t<this._rows.length;t++){const o=Pt(this._rows[t],e);void 0!==o&&this.#Me.set(o,{row:this._rows[t],index:t})}}#pt(){Ye(this),this.#K.merge(),this.#ot()}#wt(){this.#K.merge();if("fixed"===this.#m.fitMode)this.__didInitialAutoSize=!1,L(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}I(this)}}#gt(){Bt(this,this.#_e),Vt(this,this.#_e);const e=!!this.#j.querySelector(".has-shell"),t=!!this.#j.querySelector(".tbw-tool-panel"),o=this.#j.querySelectorAll(".tbw-accordion-section").length,i=this.#j.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Be(),this.#Ve(),Ut(this,this.#_e,this.#Ye()),this.#K.markSourcesChanged(),this.#K.merge();const n=this.#K.initialColumnState;if(n){this.#K.initialColumnState=void 0,this.#R=void 0;const e=this.#ge?.getAll()??[];this.#K.applyState(n,e)}const r=Wt(this.#m?.shell),s=(this.#m?.shell?.toolPanels?.length??0)>0,l=this.#m?.shell?.toolPanels?.length??0,a=this.#m?.shell?.toolPanel?.position??"right";if(e!==r||!t&&s||t&&l!==o||t&&i!==a)return Zt(this.#_e),this.#Ke(),this.#We(),this.#Ze(),void this._rebuildRowIdMap();e&&this.#bt(),this.#_e.isPanelOpen&&Yt(this.#j,this.#_e,(this.#m,this.#m)),this._rebuildRowIdMap(),this.#ee.requestPhase(Ee.COLUMNS,"applyGridConfigUpdate")}#bt(){const e=this.#j.querySelector(".tbw-shell-header");if(!e)return;const t=this.#m.shell?.header?.title??this.#_e.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#vt(){if(this.__rowRenderEpoch++,this.#ge){const e=this.#Le.length>0?this.#Le:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#ge.processColumns([...t]);if(i!==t){const n=new Set(i.map(e=>e.field));!t.some(e=>n.has(e.field))&&i.length>0?this._columns=[...i,...o]:this._columns=this.#Ct(e,i,o)}else this._columns=[...e]}}#Ct(e,t,o){if(0===o.length)return t;const i=/* @__PURE__ */new Map;for(const l of t)i.set(l.field,l);const n=new Set(e.map(e=>e.field)),r=[];for(const l of t)n.has(l.field)||r.push(l);const s=[];for(const l of e){const e=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...r),s}#yt(){Ye(this);const e=this.#X;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#we.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#m.initialSort){const{field:e,direction:t}=this.#m.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,o=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??ae;if(i===ae)return o||(e.__originalOrder=t.slice()),ue(t,e._sortState.field,e._sortState.direction,e._columns),t;o||(e.__originalOrder=t);const n=i(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),o=this.#ge?.processRows(t)??t;this._rows=o,this.#ke=!0,this._emitDataChange()}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#se||(this.#se=(e,t,o)=>this.#ge?.renderRow(e,t,o)??!1),function(e,t,o,i,n){const r=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<r;){const t=je();e._rowPool.push(t)}if(e._rowPool.length>r){const t=e.__frameworkAdapter,o=t?.releaseCell;t?.beginBatch?.(e);try{for(let i=r;i<e._rowPool.length;i++){const n=e._rowPool[i];if(o){const e=n.children;for(let i=0;i<e.length;i++){const n=e[i];n.firstElementChild&&o.call(t,n)}}n.parentNode===s&&n.remove()}e._rowPool.length=r}finally{t?.endBatch?.(e)}}const d=n&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,u=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<r;f++){const o=t+f,r=e._rows[o],p=e._rowPool[f];if(p.setAttribute("aria-rowindex",String(o+c+1)),d&&n(r,p,o)){p.__epoch=i,p.__rowDataRef=r,p.parentNode!==s&&s.appendChild(p);continue}const w=p.__epoch,m=p.__rowDataRef;let b=p.children.length;b>a&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const v=w===i&&b===a,C=m!==r,y=!!e._isGridEditMode;let _=!1;if(v&&C)for(let e=0;e<a;e++)if(l[e].externalView&&!p.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){_=!0;break}if(!v||_){const t=We(p),n=y&&!C||e._activeEditRows===o;t&&!n?(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):t&&n?(Xe(e,p,r,o),p.__rowDataRef=r):(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r)}else if(C){const t=We(p),n=e._activeEditRows===o;t&&!n?(Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):(Xe(e,p,r,o),p.__rowDataRef=r)}else{const t=We(p),n=y||e._activeEditRows===o;t&&!n?(Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):Xe(e,p,r,o)}let R=!1;const S=e._changedRowIdSet;if(S&&S.size>0)try{const t=e.getRowId?.(r);t&&(R=S.has(t))}catch{}R!==p.classList.contains("changed")&&p.classList.toggle("changed",R);const E=e.effectiveConfig?.rowClass;if(E){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=E(r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(p.classList.add(i),e+=(e?" ":"")+i)}p.setAttribute("data-dynamic-classes",e)}else p.removeAttribute("data-dynamic-classes")}catch(g){A("TBW060",`rowClass callback error: ${g}`,e.id),p.removeAttribute("data-dynamic-classes")}}if(u){const e=u(r,o);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}h&&e._afterRowRender?.({row:r,rowIndex:o,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,o,this.#se),this.#Te.size>0)for(const i of this.#Te)this.#Ne(i,!0)}#ht={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,o,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const r=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==r&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#ht,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#ee.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#ge?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,o){return this.#ge?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#ge?.afterRender()}_emitPluginEvent(e,t){this.#ge?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Be(),function(e,t,o){const i=go,n=fo,r=/* @__PURE__ */new Map;function s(e,t,o,i,n=!1){r.has(e)||r.set(e,{description:t,importHint:o,fields:[],isConfigProperty:n});const s=r.get(e);s.fields.includes(i)||s.fields.push(i)}const l=e.features;function a(e){return!!l&&!1===l[e]}for(const d of n){const o=e[d.property];if((d.isUsed?d.isUsed(o):void 0!==o)&&!mo(t,d.pluginName)&&!a(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,po(d.pluginName),d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of i){const o=d[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!mo(t,e.pluginName)&&!a(e.pluginName)){const t=d.field||"<unknown>",o=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,o,po(e.pluginName),t)}}if(r.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:n,isConfigProperty:s}]of r)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${wo(t)}Plugin(), ...]`);else{const r=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${r}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${wo(t)}Plugin(), ...]`)}T([...r.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.`,o)}}(this.#m,this.#ge?.getPlugins()??[],this.id),function(e,t){const o=[],i=[];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=`[${wo(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&Me())for(const n of i)A("TBW004",n,t);o.length>0&&T("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#ge?.getPlugins()??[],this.id),function(e,t){if(!Me())return;const o=new Set(e.map(e=>e.name)),i=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const r of e.incompatibleWith)if(o.has(r.name)){const e=[n.name,r.name].sort().join("↔");if(i.has(e))continue;i.add(e),A("TBW022",`${wo(n.name)}Plugin and ${wo(r.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${r.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ge?.getPlugins()??[],this.id),this.#_t(),this.#Le=[...this._columns]}_schedulerProcessColumns(){this.#vt()}_schedulerProcessRows(){this.#yt()}_schedulerRenderHeader(){Re(this)}_schedulerUpdateTemplate(){I(this)}_schedulerAfterRender(){this.#ge?.afterRender(),this.#ze(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#we.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#m.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,L(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,ht(this)),this._virtualization.enabled&&!this.#Je&&this.#ct(),this.#ne&&(this.#ne=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#st()})})),this.#xe&&this.#Ie()}get _schedulerIsConnected(){return this.isConnected&&this.#Z}get _hostElement(){return this}get _renderRoot(){return this.#j}_emit(e,t){this.#dt(e,t)}get _accordionIcons(){return{expand:this.#m?.icons?.expand??i.expand,collapse:this.#m?.icons?.collapse??i.collapse}}get _shellState(){return this.#_e}_clearRowPool(){const e=this.__frameworkAdapter,t=e?.releaseCell;if(t){e?.beginBatch?.(this);try{for(let o=0;o<this._rowPool.length;o++){const i=this._rowPool[o].children;for(let o=0;o<i.length;o++){const n=i[o];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.#ot()}_applyAnimationConfig(e){const t={...o,...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}#_t(){!function(e,t,o,i){if(!t)return!1;let n=!1;const r=o?.gridAriaLabelledBy,s=r?void 0:function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);r!==e.ariaLabelledBy&&(e.ariaLabelledBy=r,r?t.setAttribute("aria-labelledby",r):t.removeAttribute("aria-labelledby"),n=!0),s!==e.ariaLabel&&(e.ariaLabel=s,s?t.setAttribute("aria-label",s):t.removeAttribute("aria-label"),n=!0);const l=o?.gridAriaDescribedBy;l!==e.ariaDescribedBy&&(e.ariaDescribedBy=l,l?t.setAttribute("aria-describedby",l):t.removeAttribute("aria-describedby"),n=!0);const a=o?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),n=!0)}(this.#ht,this.__rowsBodyEl,this.#m,this.#_e)}#Ie(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#xe?(this.#Pe||(this.#Pe=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(yt("large",e)),t}(this.#m?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#Pe)):(t=this.#Pe,t?.remove()))}#ze(){!function(e,t,o,i,n,r,s){if(!e)return;if(!function(e,t,o){return!(e||t>0||null===o)}(t,o,n))return He(s.el),s.el=void 0,s.renderer=void 0,s.target=void 0,s.sourceRows=void 0,void(s.filteredOut=void 0);const l=i.length,a=l>0&&0===o;if(s.el&&s.renderer===n&&s.target===r&&s.sourceRows===i&&s.filteredOut===a)return;const c="grid"===r?e:e.querySelector(".rows-container")??e;He(s.el),s.el=Pe({sourceRowCount:l,filteredOut:a},n??void 0,r),function(e,t){e.appendChild(t)}(c,s.el),s.renderer=n,s.target=r,s.sourceRows=i,s.filteredOut=a}(this.querySelector(".tbw-grid-root"),this.#xe,this._rows.length,this.#X,this.#m?.emptyRenderer,this.#m?.emptyOverlay??"rows",this.#He)}#Ne(e,t){this.#mt();const o=this.#Me.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&_t(i,t)}#qe(e,t,o){this.#mt();const i=this.#Me.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const r=this._visibleColumns.findIndex(e=>e.field===t);if(r<0)return;const s=n.children[r];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,o)}#ot(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#K.parseLightDomColumns(this),this.#R){const e=this.#R;this.#R=void 0,this.#K.merge();const t=this.#ge?.getAll()??[];this.#K.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#ee.requestPhase(Ee.FULL,"setup")}}#lt(e){const t=this._virtualization.container,o=this.#ye,i=o?.scrollLeft??0,n=t?.scrollHeight??0,r=o?.scrollWidth??0,s=t?.clientHeight??0,l=o?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#ge?.onScrollRender(),this._virtualization.variableHeights&&(this.#re&&clearTimeout(this.#re),this.#re=window.setTimeout(()=>{this.#re=0,this.#we.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#ie){const t=this.#ue;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=n,t.scrollWidth=r,t.clientHeight=s,t.clientWidth=l,this.#ge?.onScroll(t)}this.#dt("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#j.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const n=this._rows[t],r=this._visibleColumns[o];if(!n||!r)return!1;const s=r.field,l=n[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:o,column:r,field:s,value:l,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:o,column:r,field:s,value:l,cellEl:i,originalEvent:e},d=this.#ge?.onCellClick(c)??!1;return this.#dt("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const n={rowIndex:t,row:o,rowEl:i,originalEvent:e},r=this.#ge?.onRowClick(n)??!1;return this.#dt("row-click",n),r}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#ge?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ge?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ge?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#ge?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ge?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ge?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ge?.onCellMouseUp(e)}_afterCellRender(e){this.#ge?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ge?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ge?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ge?.hasAfterRowRenderHook()??!1}async ready(){return this.#r}async forceLayout(){return 0===this.#ee.pendingPhase&&this.#ee.requestPhase(Ee.FULL,"forceLayout"),this.#ee.whenReady()}async getConfig(){return Object.freeze({...this.#m||{}})}getRowId(e){return Ht(e,this.id,this.#m.getRowId)}getRow(e){return this.#be.getRow(e)}_getRowEntry(e){return this.#mt(),this.#Me.get(e)}updateRow(e,t,o="api"){this.#be.updateRow(e,t,o)}updateRows(e,t="api"){this.#be.updateRows(e,t)}animateRow(e,t){return At(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>At(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const r=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return r<0?Promise.resolve(!1):At(e,r,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#be.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#be.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#be.applyTransaction(e,t)}applyTransactionAsync(e){return this.#be.applyTransactionAsync(e)}focusCell(e,t){this.#me.focusCell(e,t)}get focusedCell(){return this.#me.focusedCell}scrollToRow(e,t){this.#me.scrollToRow(e,t)}scrollToRowById(e,t){this.#me.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#K.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#K.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#K.isColumnVisible(e)}showAllColumns(){this.#K.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#K.getAllColumns()}setColumnOrder(e){this.#K.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#K.getColumnOrder()}getColumnState(){const e=this.#ge?.getAll()??[];return this.#K.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#Y?this.#Rt(e):(this.#R=e,this.#K.initialColumnState=e))}#Rt(e){const t=this._columns,o=this._sortState,i=this.#ge?.getAll()??[];this.#K.applyState(e,i);if(!e.columns.some(e=>void 0!==e.sort)&&this.#St(t,o))return this.#Oe=void 0,I(this),void this.#ee.requestPhase(Ee.STYLE,"column-width");this.#ot()}#St(e,t){const o=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==o.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],i=o[n];if(t.field!==i.field)return!1;if(!!t.hidden!=!!i.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=[],Re(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 o=this._columns.find(t=>t.field===e);o&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),me(this,o,"desc"===t?-1:1)):we(this,o))}requestStateChange(){const e=this.#ge?.getAll()??[];this.#K.requestStateChange(e)}resetColumnState(){this.#R=void 0,this.__originalOrder=[];const e=this.#ge?.getAll()??[];this.#K.resetState(e),this.#K.merge(),this.#ot()}get isToolPanelOpen(){return this.#Re.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#Re.expandedSections}openToolPanel(e){this.#Re.openToolPanel(e)}closeToolPanel(){this.#Re.closeToolPanel()}toggleToolPanel(){this.#Re.toggleToolPanel()}toggleToolPanelSection(e){this.#Re.toggleToolPanelSection(e)}getToolPanels(){return this.#Re.getToolPanels()}registerToolPanel(e){this.#_e.apiToolPanelIds.add(e.id),this.#Re.registerToolPanel(e)}unregisterToolPanel(e){this.#_e.apiToolPanelIds.delete(e),this.#Re.unregisterToolPanel(e)}getHeaderContents(){return this.#Re.getHeaderContents()}registerHeaderContent(e){this.#_e.apiHeaderContentIds.add(e.id),this.#Re.registerHeaderContent(e)}unregisterHeaderContent(e){this.#_e.apiHeaderContentIds.delete(e),this.#Re.unregisterHeaderContent(e)}getToolbarContents(){return this.#Re.getToolbarContents()}registerToolbarContent(e){this.#Re.registerToolbarContent(e)}unregisterToolbarContent(e){this.#Re.unregisterToolbarContent(e)}#Et=!1;refreshShellHeader(){this.#Et||(this.#Et=!0,queueMicrotask(()=>{if(this.#Et=!1,!this.isConnected)return;this.#Xe(),this.#K.markSourcesChanged(),this.#K.merge(),Zt(this.#_e);(function(e,t,o,i){const n=e.querySelector(`.${z.ROOT}`),r=n?.querySelector(".tbw-grid-content");if(!n||!r)return Jt(e,t,o,i);r.remove();const s=Wt(t);if(n.replaceChildren(),s){n.className=`${z.ROOT} has-shell`;const{headerOptions:e,bodyOptions:s}=Qt(t,o,i),l=qt(e),a=$t(s),c=a.querySelector(".tbw-grid-content");c&&c.replaceWith(r),n.appendChild(l),n.appendChild(a)}else n.className=z.ROOT,n.appendChild(r);return s})(this.#j,this.#m?.shell,{isPanelOpen:this.#_e.isPanelOpen,expandedSections:this.#_e.expandedSections},this.#m?.icons)&&(this.#xt(),this.#Re.setInitialized(!0)),this.#Tt()}))}#Tt(){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.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.#Re.isInitialized){jt(this.#j,this.#_e),Gt(this.#j,this.#m?.shell,this.#_e);const e=this.#m?.shell?.toolPanel,t=e?.defaultOpen;t&&this.#_e.toolPanels.has(t)&&this.#_e.expandedSections.add(t);const o=!0===e?.locked||"open"===e?.initialState||void 0===e?.initialState&&void 0!==t&&this.#_e.toolPanels.has(t);!this.#_e.isPanelOpen&&this.#_e.toolPanels.size>0&&o&&this.openToolPanel(),this.#_e.isPanelOpen&&(Kt(this.#j,this.#_e),Yt(this.#j,this.#_e,(this.#m,this.#m)),Xt(this.#j,this.#_e))}this._resizeController=Rt(this),this.#Ge(e),this.#ee.requestPhase(Ee.COLUMNS,"shellRefresh")}#tt=/* @__PURE__ */new Map;registerStyles(e,t){let o=this.#tt.get(e);o||(o=new CSSStyleSheet,this.#tt.set(e,o)),o.replaceSync(t),this.#At()}unregisterStyles(e){this.#tt.delete(e)&&this.#At()}getRegisteredStyles(){return Array.from(this.#tt.keys())}#At(){const e=Array.from(this.#tt.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#tt.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#me.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#me.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#me.containsFocus(e)}get lastFocusedElement(){return this.#me.lastFocusedElement}restoreLastFocus(){return this.#me.restoreLastFocus()}#Xe(){Bt(this,this.#_e),Vt(this,this.#_e),Ut(this,this.#_e,this.#Ye())}#Pt(){const e=this.#j.querySelector(".tbw-shell-header");if(!e)return;Zt(this.#_e);const t=function(e,t,o){const i=e?.header?.title??t.lightDomTitle??"",n=!!i;let r="";void 0!==o&&(r="string"==typeof o?K(o):o.outerHTML);const s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const b of l)a.has(b.id)||c.push(b);const d=c.length>0,h=t.toolPanels.size>0,u=!0===e?.toolPanel?.locked,g=h&&!1!==e?.header?.toolPanelToggle&&!u,f=d&&g,p=[...c].sort((e,t)=>(e.order??0)-(t.order??0));let w="";for(const b of p)w+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${b.id}"></div>`;if(f&&(w+='<div class="tbw-toolbar-separator"></div>'),g){const e=t.isPanelOpen;w+=`<button type="button" class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle data-icon="tool-panel" title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${r}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${n?`<div class="tbw-shell-title">${m=i,m&&"string"==typeof m?m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${w}\n </div>\n </div>\n `;var m}(this.#m.shell,this.#_e,this.#m.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#xt(),Gt(this.#j,this.#m?.shell,this.#_e))}#Qe(){const e=()=>{const e=this.#_e.lightDomTitle,t=this.#_e.hasToolButtonsContainer;this.#Xe();const o=this.#_e.lightDomTitle,i=this.#_e.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#K.markSourcesChanged(),this.#K.merge(),this.#Pt())},t=()=>{this.__lightDomColumnsCache=void 0,this.#ot()};this.#K.registerLightDomHandler("tbw-grid-header",e),this.#K.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#K.registerLightDomHandler("tbw-grid-tool-panel",e),this.#K.registerLightDomHandler("tbw-grid-column",t),this.#K.registerLightDomHandler("tbw-grid-detail",t),this.#K.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Ye(this),this.#K.parseLightDomColumns(this);const e=this.#_e.lightDomTitle,t=this.#_e.hasToolButtonsContainer;this.#Xe();const o=this.#_e.lightDomTitle,i=this.#_e.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#K.markSourcesChanged(),this.#K.merge(),this.#Pt()),this.#ee.requestPhase(Ee.COLUMNS,"refreshColumns")}#at(){this.#we.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#we.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#we.invalidateRowHeight(e,t)}#Ke(){this.#Xe(),this.#K.markSourcesChanged(),this.#K.merge();const e=this.#m?.shell;Jt(this.#j,e,{isPanelOpen:this.#_e.isPanelOpen,expandedSections:this.#_e.expandedSections},this.#m?.icons)&&(this.#xt(),this.#Re.setInitialized(!0))}#xt(){!function(e,t,o,i){const n=e.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.onPanelToggle()});const r=e.querySelector(".tbw-accordion");r&&r.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#j,this.#m,this.#_e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#Se?.(),this.#Se=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),n=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return n.addEventListener("mousedown",g),()=>{n.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#j,this.#m?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#Ee?.(),this.#Ee=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===t.toolPanel.mode)return()=>{};const n=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",n),()=>e.removeEventListener("mousedown",n)}(this,this.#m?.shell,this.#_e,()=>this.closeToolPanel())}}!function(){const e=Co.tagName,t=customElements.get(e);if(!t)return customElements.define(e,Co),void(Co.activeTag=e);if(t.version===Co.version)return void(Co.activeTag=e);const o=`${e}-v${Co.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(o)||customElements.define(o,Co),Co.activeTag=o}(),globalThis.DataGridElement||(globalThis.DataGridElement=Co);const yo=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"];function _o(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t}function Ro(e,t,o){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!o),n?customElements.whenDefined(Co.tagName).then(()=>i.querySelector(e)):i.querySelector(e)}const So={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change",TBW_SCROLL:"tbw-scroll"},Eo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",TREE_LOAD_START:"tree-load-start",TREE_LOAD_END:"tree-load-end",TREE_LOAD_ERROR:"tree-load-error",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"};function xo(e,t,o){return o?.valueAccessor?re(e,o):e?.[t]}function To(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const Ao={sum:(e,t,o)=>{let i=0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||(i+=s)}return i},avg:(e,t,o)=>{if(!e.length)return 0;let i=0,n=0;for(let r=0;r<e.length;r++){const s=xo(e[r],t,o);if(To(s))continue;const l=Number(s);isNaN(l)||(i+=l,n++)}return n>0?i/n:0},count:e=>e.length,min:(e,t,o)=>{if(!e.length)return 0;let i=1/0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,o)=>{if(!e.length)return 0;let i=-1/0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,o)=>e[0]?xo(e[0],t,o):void 0,last:(e,t,o)=>e.length?xo(e[e.length-1],t,o):void 0},Po=/* @__PURE__ */new Map,Ho={register(e,t){Po.set(e,t)},unregister(e){Po.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Po.get(e)??Ao[e]},run(e,t,o,i){const n=this.get(e);return n?n(t,o,i):void 0},has:e=>Po.has(e)||e in Ao,list:()=>[...Object.keys(Ao),...Po.keys()]},Mo={sum:e=>{let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]<t&&(t=e[o]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]>t&&(t=e[o]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function ko(e){return Mo[e]??Mo.sum}function Lo(e,t){return ko(e)(t)}export{ie as BaseGridPlugin,w as C,yo as CORE_CONSUMED_ADAPTER_METHODS,_ as D,t as DEFAULT_A11Y_MESSAGES,o as DEFAULT_ANIMATION_CONFIG,i as DEFAULT_GRID_ICONS,So as DGEvents,Co as DataGridElement,h as E,Fe as F,e as FitModeEnum,$ as GridCSSVars,z as GridClasses,N as GridDataAttrs,Co as GridElement,q as GridSelectors,m as M,it as MAX_ELEMENT_HEIGHT_PX,v as N,p as P,Eo as PluginEvents,vo as PluginManager,Ee as RenderPhase,b as T,n as a,Ho as aggregatorRegistry,at as b,ae as builtInSort,lt as c,nt as computeScrollMapping,_o as createGrid,T as d,le as defaultComparator,ht as e,Le as f,st as fromVirtualScrollTop,r as g,ko as getValueAggregator,C as h,y as i,se as invalidateAccessorCache,_t as j,Q as k,Ie as l,u as m,g as n,H as o,f as p,Oe as q,Ro as queryGrid,Ne as r,re as resolveCellValue,Lo as runValueAggregator,K as s,mt as setFeatureResolver,oe as t,rt as toVirtualScrollTop,De as u,P as v,A as w,S as x,R as y,E as z};//# sourceMappingURL=index.js.map
1
+ const e={STRETCH:"stretch",FIXED:"fixed"},t={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`},o={mode:"reduced-motion",duration:200,easing:"ease-out"},i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;const o="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===o?.a11y?.announcements)return;const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}function r(e,o,...i){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,r=n?.a11y?.messages?.[o];return r?r(...i):t[o](...i)}function s(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const l="TBW041",a="TBW061",c="TBW062",d="TBW072",h="TBW080",u="TBW090",g="TBW091",f="TBW092",p="TBW093",w="TBW100",m="TBW110",b="TBW111",v="TBW112",C="TBW113",y="TBW114",_="TBW140",R="TBW141",S="TBW142",E="TBW143";function x(e,t,o,i){return`${s(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function T(e,t,o,i){throw new Error(x(e,t,o,i))}function A(e,t,o,i){console.warn(x(e,t,o,i))}function P(e,t,o,i){console.debug(x(e,t,o,i))}function H(e,t,o,i){console.error(x(e,t,o,i))}function M(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const o={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=o[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.editable&&(t.editable=!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.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}}const n=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const n=t.renderer||t.viewRenderer,r=i.renderer||i.viewRenderer;return n&&!r&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i}),r=Object.keys(o);for(let s=0;s<r.length;s++)n.push(o[r[s]]);return n}function k(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function L(t){const o=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;if(o!==e.STRETCH&&o!==e.FIXED)return;if(t.__didInitialAutoSize)return;if(!t.isConnected)return;const i=Array.from(t._headerRowEl?.children||[]);if(!i.length)return;let n=!1;const r=t._visibleColumns;for(let e=0;e<r.length;e++){const o=r[e];if(o.width)continue;const s=i[e];let l=s?s.scrollWidth:0;for(let i=0;i<t._rowPool.length;i++){const o=t._rowPool[i].children[e];if(o){const e=o.scrollWidth;e>l&&(l=e)}}l>0&&(o.width=l+2,o.__autoSized=!0,n=!0)}n&&I(t),t.__didInitialAutoSize=!0}const O=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function D(e,t){return"number"==typeof e?`${e}px`:(O.test(e)||A("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 I(t){const o=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;t._gridTemplate=o===e.STRETCH?t._visibleColumns.map(e=>{if(null!=e.width)return D(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?D(e.width,e.field):"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}const z={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},N={FIELD:"data-field",GROUP_KEY:"data-group-key"},q={ROOT:`.${z.ROOT}`,HEADER:`.${z.HEADER}`,HEADER_ROW:`.${z.HEADER_ROW}`,HEADER_CELL:`.${z.HEADER_CELL}`,ROWS_VIEWPORT:`.${z.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${z.ROWS_CONTAINER}`,DATA_ROW:`.${z.DATA_ROW}`,DATA_CELL:`.${z.DATA_CELL}`,GROUP_ROW:`.${z.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${z.DATA_CELL}[${N.FIELD}="${e}"]`,SELECTED_ROWS:`.${z.DATA_ROW}.${z.SELECTED}`,EDITING_CELL:`.${z.DATA_CELL}.${z.EDITING}`},$={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"},F=/{{\s*([^}]+)\s*}}/g,W="__DG_EMPTY__",B=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,V="__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("")),U=new RegExp(`__(proto|defineGetter|defineSetter)|${V.slice(3).join("|")}|this\\b`);const G=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("|")),j=/^on\w+$/i,Y=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),X=/^\s*(javascript|vbscript|data|blob):/i;function K(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=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(G.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>j.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();j.test(e)?o.push(t.name):(Y.has(e)&&X.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function Z(e,t){const o=function(e){const t=[];let o=0;for(;o<e.length;){const i=e[o];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&o+1<e.length&&e[o+1]>="0"&&e[o+1]<="9"){const i=o;for(;o<e.length&&(e[o]>="0"&&e[o]<="9"||"."===e[o]);)o++;t.push({type:"num",v:Number(e.slice(i,o))});continue}if("'"===i){let i="";for(o++;o<e.length&&"'"!==e[o];)i+=e[o++];if(o>=e.length)return null;o++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=o;for(;o<e.length&&/[\w$.]/.test(e[o]);)o++;t.push({type:"id",v:e.slice(i,o)});continue}if(o+2<e.length){const i=e.slice(o,o+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),o+=3;continue}}if(o+1<e.length){const i=e.slice(o,o+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),o+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),o++}else o++}return t}(e);if(!o)return;const i=o;let n=0;function r(){return i[n]}function s(){return i[n++]}function l(e,t){const o=r();return!!o&&(o.type===e&&(void 0===t||o.v===t))}function a(){const e=function(){let e=c();for(;l("op","||");)s(),e=e||c();return e}();if(l("op","?")){s();const t=a();if(!l("op",":"))return;s();const o=a();return e?t:o}return e}function c(){let e=d();for(;l("op","&&");)s(),e=e&&d();return e}function d(){let e=h();for(;;){const t=r();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=u();for(;;){const t=r();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=g();for(;;){const t=r();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=r();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 l("op","!")?(s(),!f()):p()}function p(){const e=r();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 o=e.slice(4);return t.row?t.row[o]:void 0}return"row"===e?t.row:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=a();return l("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=a();return n<i.length?void 0:w}function Q(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(F,(e,i)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return W;if(J.test(e))return W;if("value"===e)return null==t.value?W:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?W:String(i)}if(e.length>80)return W;if(!B.test(e)||U.test(e))return W;const o=e.match(/\./g);if(o&&o.length>1)return W;try{const o=Z(e,t),i=null==o?"":String(o);return J.test(i)?W:i||W}catch{return W}}(i,t);return o.push({expr:i.trim(),result:n}),n}),n=(r=i)?r.replace(new RegExp(W,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):r;var r;const s=o.length&&o.every(e=>""===e.result||e.result===W);return J.test(e)||s?"":n}const J=/Reflect|Proxy|ownKeys/;function ee(e){if(J.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&J.test(t.textContent||"")&&(t.textContent="");J.test(e.textContent||"")&&(e.textContent="")}}function te(e){if(J.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>Q(e,t);return t.__blocked=!1,t}function oe(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}class ie{static dependencies;static manifest;aliases;version="2.14.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const i of Object.keys(t))o[i]=this;for(const i of e){const e=i.userConfig;for(const[n,r]of Object.entries(e)){if(void 0===r)continue;if(!(n in t)){t[n]=r,o[n]=i;continue}if(t[n]===r)continue;const e=o[n]?.constructor.name??this.constructor.name,s=i.constructor.name,l=x("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(l)}}Object.assign(this.userConfig,t)}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 o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.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{...i,...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(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=oe(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#t(t,o);void 0!==i?"string"==typeof i?e.innerHTML=K(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.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 o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(o,i):e.appendChild(o),o}warn(e,t){void 0!==t?console.warn(x(e,t,this.gridElement.id,this.name)):console.warn(`${s(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(x(e,t,this.gridElement.id,this.name))}}const ne=/* @__PURE__ */new WeakMap;function re(e,t,o=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:o});const i=e,n=t.field;let r=ne.get(i);if(r){const e=r.get(n);if(void 0!==e)return e.v}else r=/* @__PURE__ */new Map,ne.set(i,r);const s=t.valueAccessor({row:e,column:t,rowIndex:o});return r.set(n,{v:s}),s}function se(e,t){e&&(t?ne.get(e)?.delete(t):ne.delete(e))}function le(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function ae(e,t,o){const i=o.find(e=>e.field===t.field),n=i?.sortComparator,{field:r,direction:s}=t,l=[...e];return n?i?.valueAccessor?l.sort((e,t)=>n(re(e,i),re(t,i),e,t)*s):l.sort((e,t)=>n(e[r],t[r],e,t)*s):i?.valueAccessor?de(l,i,s):ce(l,r,s),l}function ce(e,t,o){e.sort((e,i)=>{const n=he(e,i);if(0!==n)return n;const r=e[t],s=i[t];return null==r&&null==s?0:null==r?-o:null==s||r>s?o:r<s?-o:0})}function de(e,t,o){e.sort((e,i)=>{const n=he(e,i);if(0!==n)return n;const r=re(e,t),s=re(i,t);return null==r&&null==s?0:null==r?-o:null==s||r>s?o:r<s?-o:0})}function he(e,t){const o=!0===e?.__loading;return o===(!0===t?.__loading)?0:o?1:-1}function ue(e,t,o,i){const n=i.find(e=>e.field===t),r=n?.sortComparator;r?n?.valueAccessor?e.sort((e,t)=>r(re(e,n),re(t,n),e,t)*o):e.sort((e,i)=>r(e[t],i[t],e,i)*o):n?.valueAccessor?de(e,n,o):ce(e,t,o)}function ge(e,t,o,i){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;Re(e),e.refreshVirtualWindow(!0),fe(e,o,i)}function fe(e,t,o){const i={field:t.field,direction:o};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,r(e,0===o?"sortCleared":"sortApplied",t.header??t.field,1===o?"ascending":"descending")),e.requestStateChange?.()}function pe(e){return e._pluginManager?._hasRowStructurePlugins??!1}function we(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)me(e,t,-1);else{if(e._sortState=null,pe(e))return e._requestSchedulerPhase(4,"sort-clear"),void fe(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=[],Re(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(o)for(let t=0;t<o.length;t++){const i=o[t];i.getAttribute("aria-sort")&&("ascending"!==i.getAttribute("aria-sort")&&"descending"!==i.getAttribute("aria-sort")||e._sortState)||i.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),fe(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),me(e,t,1)}function me(e,t,o){if(e._sortState={field:t.field,direction:o},pe(e))return e._requestSchedulerPhase(4,"sort-apply"),void fe(e,t,o);const i={field:t.field,direction:o},n=e._columns,r=e.effectiveConfig?.sortHandler??ae;if(r===ae)return ue(e._rows,i.field,o,n),void ge(e,e._rows,t,o);const s=r(e._rows,i,n);s&&"function"==typeof s.then?s.then(i=>{ge(e,i,t,o)}):ge(e,s,t,o)}function be(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function ve(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Ce(e,t){const o=document.createElement("span");k(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,n=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";o.dataset.icon=oe(n);const r=e.icons?.[n];return void 0!==r&&function(e,t){"string"==typeof t?e.innerHTML=K(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,r),o}function ye(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function _e(e,t,o,i){i.classList.add(z.SORTABLE),i.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),i.addEventListener("click",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||we(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;we(e,t)}})}function Re(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",k(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i)),o.type&&n.setAttribute("data-type",o.type);const r=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>be(e,o)?Ce(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=K(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),be(e,o)&&_e(e,o,0,n),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}else if(o.headerLabelRenderer){const t={column:o,value:r},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=r:"string"==typeof s?l.innerHTML=K(s):s instanceof Node&&l.appendChild(s),n.appendChild(l),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)));else{const t=document.createElement("span");t.textContent=r,n.appendChild(t),be(e,o)&&(_e(e,o,0,n),n.appendChild(Ce(e,o))),ve(e,o)&&(n.classList.add("resizable"),n.appendChild(ye(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${z.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 Se(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[e],i=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:i}}),n={};return i.forEach(e=>{n[e.field]=e.type||"string"}),{columns:i,typeMap:n}}const Ee={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class xe{#o;#i=0;#n=0;#r=null;#s=null;#l=null;#a=!1;constructor(e){this.#o=e}requestPhase(e,t){e>this.#i&&(this.#i=e),0===this.#n&&(this.#c(),this.#n=requestAnimationFrame(()=>this.#d()))}whenReady(){return this.#r?this.#r:Promise.resolve()}setInitialReadyResolver(e){this.#l=e}cancel(){0!==this.#n&&(cancelAnimationFrame(this.#n),this.#n=0),this.#i=0,this.#s&&(this.#s(),this.#s=null,this.#r=null)}get isPending(){return 0!==this.#i}get pendingPhase(){return this.#i}#c(){this.#r||(this.#r=new Promise(e=>{this.#s=e}))}#d(){if(this.#n=0,!this.#o._schedulerIsConnected)return this.#i=0,void(this.#s&&(this.#s(),this.#s=null,this.#r=null));const e=this.#i;this.#i=0,e>=Ee.COLUMNS&&this.#o._schedulerMergeConfig(),e>=Ee.ROWS&&this.#o._schedulerProcessRows(),e>=Ee.COLUMNS&&(this.#o._schedulerProcessColumns(),this.#o._schedulerUpdateTemplate()),e>=Ee.HEADER&&this.#o._schedulerRenderHeader(),e>=Ee.VIRTUALIZATION&&this.#o.refreshVirtualWindow(!0,!0),e>=Ee.STYLE&&this.#o._schedulerAfterRender(),!this.#a&&this.#l&&(this.#a=!0,this.#l()),this.#s&&(this.#s(),this.#s=null,this.#r=null)}}class Te{#h;#u;#g;#f;#p;#w={};#m={};#b=!0;#v=[];#C;#y;#_;#R;#o;#S;constructor(e){this.#o=e}get original(){return this.#w}get effective(){return this.#m}get columns(){return this.#m.columns??[]}set columns(e){this.#m.columns=e}get lightDomColumnsCache(){return this.#f}set lightDomColumnsCache(e){this.#f=e}get originalColumnNodes(){return this.#p}set originalColumnNodes(e){this.#p=e}get lightDomTitle(){return this.#S}set lightDomTitle(e){this.#S=e}get initialColumnState(){return this.#R}set initialColumnState(e){this.#R=e}get sourcesChanged(){return this.#b}markSourcesChanged(){this.#b=!0}setGridConfig(e){this.#h!==e&&(this.#h=e,this.#b=!0,this.#f=void 0)}getGridConfig(){return this.#h}setColumns(e){this.#u=e,this.#b=!0}getColumns(){return this.#u}setFitMode(e){this.#g=e,this.#b=!0}getFitMode(){return this.#g}merge(){const e=(this.#m.columns?.length??0)>0;if(!this.#b&&e)return;const t=this.#E();this.#b=!1,this.#w=t,Object.freeze(this.#w),this.#w.columns&&Object.freeze(this.#w.columns),this.#m=this.#x(this.#w),this.#T()}#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}#T(){const e=this.#m;if(this.#A(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#o._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#o._applyAnimationConfig(e)}#A(){const e=this.#m.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#E(){const e=this.#h?{...this.#h}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#f??[]).map(e=>({...e}));let i=M(t,o);this.#u&&this.#u.length&&(i=M(this.#u,o));const n=this.#o.sourceRows;if(0===i.length&&n.length){i=Se(n).columns}return i.length&&(i.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)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=te(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=te(e.__editorTemplate.innerHTML))}),e.columns=i),this.#g&&(e.fitMode=this.#g),e.fitMode||(e.fitMode="stretch"),this.#P(e),e.columnState&&!this.#R&&(this.#R=e.columnState),e}#P(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#o._shellState.lightDomTitle;t&&(this.#S=t),this.#S&&!e.shell.header.title&&(e.shell.header.title=this.#S);const o=this.#o._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#o._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#o._shellState.toolPanels;if(i.size>0){const t=Array.from(i.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const n=this.#o._shellState.headerContents;if(n.size>0){const t=Array.from(n.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const r=this.#o._shellState.toolbarContents,s=Array.from(r.values()),l=this.#h?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#H();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},r=t;void 0!==r.__renderedWidth?n.width=r.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=o.get(t.field);s&&(n.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const r=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(r.length>0){const e=r[0];e.sort&&(this.#o._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#o._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#R=void 0,this.#o._sortState=null,this.#m=this.#x(this.#w),this.#T();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)}#H(){const e=/* @__PURE__ */new Map,t=this.#o._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=void 0;const t=this.collectState(e);this.#o._emit("column-state-change",t)},100)}setColumnVisible(e,t){const o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#o._emit("column-visibility",{field:e,visible:t,visibleColumns:o.filter(e=>!e.hidden).map(e=>e.field)}),this.#o._clearRowPool(),this.#o._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.#o._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#o._clearRowPool(),this.#o._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])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,this.#o._invalidateVisibleColumnsCache(),Re(this.#o),I(this.#o),this.#o._requestSchedulerPhase(Ee.COLUMNS,"configManager")}parseLightDomColumns(e){this.#f||(this.#p=Array.from(e.querySelectorAll("tbw-grid-column")),this.#f=this.#p.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const o=e.getAttribute("type")||void 0,i={field:t,type:o&&/* @__PURE__ */new Set(["number","string","date","boolean","select"]).has(o)?o:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const r=e.getAttribute("minWidth")||e.getAttribute("min-width");if(r){const e=parseFloat(r);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,m=g.find(e=>e.canHandle(w));if(m){const e=m.createEditor(w);e&&(i.editor=e)}return i}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#f=void 0}#M=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#M.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#M.delete(e.toLowerCase())}observeLightDOM(e){this.#C&&this.#C.disconnect();const t=/* @__PURE__ */new Set,o=()=>{this.#_=void 0;for(const e of t){const t=this.#M.get(e);t?.()}t.clear()};this.#C=new MutationObserver(e=>{for(const o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#M.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#M.has(e)&&t.add(e)}}t.size>0&&!this.#_&&(this.#_=setTimeout(o,0))}),this.#C.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#v.push(e)}notifyChange(){for(const e of this.#v)e()}dispose(){this.#C?.disconnect(),this.#v=[],this.#y&&clearTimeout(this.#y),this.#_&&(clearTimeout(this.#_),this.#_=void 0)}}function Ae(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 Pe(e,t,o="rows"){const i=document.createElement("div");return i.className="tbw-empty-overlay",i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("data-overlay-target",o),i.appendChild(function(e,t){const o=(t??Ae)(e);if("string"==typeof o){const e=document.createElement("div");return e.className="tbw-empty-message",e.innerHTML=K(o),e}return o}(e,t)),i}function He(e){e?.remove()}function Me(){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 ke(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"&#x1F5F9;":"&#9744;"}</span>`}function Le(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 Oe(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function De(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Ie(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 ze(e){return"rtl"===Ie(e)}function Ne(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function qe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(t.type,e._hostElement);if(o?.renderer)return o.renderer}}function $e(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}const Fe='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function We(e){return(e.__editingCellCount??0)>0}function Be(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${z.EDITING}`).forEach(e=>e.classList.remove(z.EDITING))}const Ve=document.createElement("template");Ve.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ue=document.createElement("template");function Ge(){return Ve.content.firstElementChild.cloneNode(!0)}function je(){return Ue.content.firstElementChild.cloneNode(!0)}function Ye(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Xe(e,t,o,i){const n=t.children,r=e._visibleColumns,s=r.length,l=n.length,d=s<l?s:l,h=e._focusRow,u=e._focusCol,g=e._hasAfterCellRenderHook?.()??!1;let f=e.__hasSpecialColumns;if(void 0===f){f=!1;const t=e.__frameworkAdapter;for(let o=0;o<s;o++){const i=r[o];if(i.__viewTemplate||i.__compiledView||i.renderer||i.viewRenderer||i.externalView||i.format||i.cellClass||"date"===i.type||"boolean"===i.type||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.renderer||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.format){f=!0;break}}e.__hasSpecialColumns=f}const p=String(i);if(f){for(let s=0;s<d;s++){if(r[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void Ke(e,t,o,i)}}for(let s=0;s<d;s++){const l=r[s],d=n[s];d.getAttribute("data-row")!==p&&d.setAttribute("data-row",p);const f=d.classList.contains(z.EDITING);if(!f){const e=h===i&&u===s;e!==d.classList.contains("cell-focus")&&(d.classList.toggle("cell-focus",e),d.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=d.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&d.classList.remove(e[t])}try{const e=m(re(o,l,i),o,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(d.classList.add(i),e+=(e?" ":"")+i)}d.setAttribute("data-dynamic-classes",e)}else d.removeAttribute("data-dynamic-classes")}catch(w){A(a,`cellClass callback error for column '${l.field}': ${w}`,e.id),d.removeAttribute("data-dynamic-classes")}}if(f)continue;const b=qe(e,l);if(b){const n=re(o,l,i),r=b({row:o,value:n,field:l.field,column:l,grid:e,cellEl:d});"string"==typeof r?(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(r)):r instanceof Node?r.parentElement!==d&&(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML="",d.appendChild(r)):null==r&&(e.__frameworkAdapter?.releaseCell?.(d),d.textContent=null==n?"":String(n)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.__compiledView){const n=re(o,l,i),r=l.__compiledView({row:o,value:n,field:l.field,column:l});l.__compiledView.__blocked?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(r),ee(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.__viewTemplate){const n=re(o,l,i),r=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(r)?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=K(Q(r,{row:o,value:n})),ee(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(l.externalView)continue;const v=re(o,l,i);let C;d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d);const y=$e(e,l);if(y){try{const e=y(v,o);C=null==e?"":String(e)}catch(w){A(c,`Format error in column '${l.field}': ${w}`,e.id),C=null==v?"":String(v)}d.textContent=C}else"date"===l.type?(C=Le(v),d.textContent=C):"boolean"===l.type?d.innerHTML=ke(!!v):(C=null==v?"":String(v),d.textContent=C);g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:v,cellElement:d,rowElement:t})}}else for(let a=0;a<d;a++){const s=n[a];if(s.classList.contains(z.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=r[a],c=re(o,l,i);s.textContent=null==c?"":String(c),s.getAttribute("data-row")!==p&&s.setAttribute("data-row",p);const d=h===i&&u===a;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),g&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:a,value:c,cellElement:s,rowElement:t})}}function Ke(e,t,o,i){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 r=e._visibleColumns,s=r.length,l=e._focusRow,d=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let f=0;f<s;f++){const n=r[f],s=Ge();s.setAttribute("aria-colindex",String(f+1)),s.setAttribute("data-col",String(f)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let p=re(o,n,i);const w=$e(e,n);if(w)try{p=w(p,o)}catch(g){A(c,`Format error in column '${n.field}': ${g}`,e.id)}const m=n.__compiledView,b=n.__viewTemplate,v=qe(e,n),C=n.externalView;let y=!1;if(v){const t=v({row:o,value:p,field:n.field,column:n,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=K(t),y=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==p?"":String(p))}else if(C){const t=C,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",n.field),s.appendChild(i);const r={row:o,value:p,field:n.field,column:n,grid:e};if(t.mount)try{t.mount({placeholder:i,context:r,spec:t})}catch(g){A("TBW063",`External view mount error for column '${n.field}': ${g}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:i,spec:t,context:r}}))}catch(g){A("TBW064",`External view event dispatch error for column '${n.field}': ${g}`,e.id)}});i.setAttribute("data-mounted","")}else if(m){const e=m({row:o,value:p,field:n.field,column:n}),t=m.__blocked;s.innerHTML=t?"":K(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(b){const e=b.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=K(Q(e,{row:o,value:p})),y=!0)}else w?s.textContent=null==p?"":String(p):"date"===n.type?s.textContent=Le(p):"boolean"===n.type?s.innerHTML=ke(!!p):s.textContent=null==p?"":String(p);if(y){ee(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(o):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===i&&d===f?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const _=n.cellClass;if(_)try{const e=_(re(o,n,i),o,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(g){A(a,`cellClass callback error for column '${n.field}': ${g}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:n,colIndex:f,value:p,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function Ze(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=Oe(o.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,o))return;const r=t.target?.closest(".cell[data-col]");if(r){const o=Number(r.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,r))return;const n=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,r.classList.contains(z.EDITING)){n&&(De(e._bodyEl??e),r.classList.add("cell-focus"));const o=t.target,i=r.contains(o)&&o.matches(Fe)?o:r.querySelector(Fe);try{i?.focus({preventScroll:!0})}catch{}return}ht(e)}}}function Qe(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 Je(e,t,o){const i=Qe(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function et(e,t,o){if(t<0||t>=e.length)return;const i=e[t],n=o-i.height;if(0!==n){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=n}}function tt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const n=Math.floor((o+i)/2),r=e[n],s=r.offset+r.height;if(t<r.offset)i=n-1;else{if(!(t>=s))return n;o=n+1}}return Math.max(0,Math.min(o,e.length-1))}function ot(e,t){const{positionCache:o,heightCache:i,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<r||d>=s||d>=n.length)return;const h=n[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(et(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(et(o,d,g),function(e,t,o,i){const n=Qe(t,i);"string"==typeof n?e.byKey.set(n,o):n&&"object"==typeof n&&e.byRef.set(n,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const n of e)n.measured&&(o+=n.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}Ue.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const it=335e5;function nt(e,t,o=it){return{rawContentHeight:e,spacerHeight:Math.min(e,o),viewportHeight:t,capped:e>o}}function rt(e,t){if(!t.capped)return e;const o=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;if(o<=0||i<=0)return e;const n=e*i/o;return n<0?0:n>i?i:n}function st(e,t){if(!t.capped)return e;const o=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;return o<=0||i<=0?e:e*o/i}function lt(e){const{totalRows:t,viewportHeight:o,scrollTop:i,rowHeight:n,overscan:r,maxSpacerHeight:s=it}=e,l=Math.ceil(o/n),a=t*n,c=nt(a,o,s),d=rt(i,c);let h=Math.floor(d/n)-r;h<0&&(h=0);let u=h+l+2*r;return u>t&&(u=t),u===t&&h>0&&(h=Math.max(0,u-l-2*r)),{start:h,end:u,offsetY:h*n,totalHeight:c.spacerHeight,rawContentHeight:a}}function at(e,t){return e<=t}function ct(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function dt(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function ht(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i,scrollMapping:n}=e._virtualization,r=o,s=i?.clientHeight??r?.clientHeight??0;if(r&&s>0){const o=e._focusRow*t,i=n?rt(r.scrollTop,n):r.scrollTop;if(o<i)r.scrollTop=n?st(o,n):o;else if(o+t>i+s){const e=o-s+t;r.scrollTop=n?st(e,n):e}}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),De(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,n=e._virtualization.start??0,r=e._virtualization.end??e._rows.length;if(i>=n&&i<r){const r=e._bodyEl.querySelectorAll(".data-grid-row")[i-n];let s=r?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=r?.querySelector(`.cell[data-col="${e._focusCol}"]`)??r?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(r??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),n=e.left-o.left+i.scrollLeft,r=n+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;n<l?i.scrollLeft=n-t.left:r>a&&(i.scrollLeft=r-i.clientWidth+t.right)}}if(o&&s.classList.contains(z.EDITING)){const e=s.querySelector(Fe);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!o){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 ut=/* @__PURE__ */new WeakMap;function gt(e,t){const o=Oe(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,De(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 ft(e,t,o,i){let n=null;const r=o.composedPath?.();if(n=r&&r.length>0?r[0]:o.target,n&&!t.contains(n)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function pt(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,r=e._visibleColumns[e._focusCol],s=r?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target;if((!a||a===e||a.closest?.(".rows-body"))&&(!dt(a)||"Home"!==t.key&&"End"!==t.key)&&!(dt(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||dt(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||dt(a)&&("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&&ct(e),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:(ct(e),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void ht(e);case"ArrowDown":n&&ct(e),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&ct(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=ze(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=ze(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&ct(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void ht(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&ct(e),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void ht(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],r=e._rows[o],s=n?.field??"",l=s&&r?r[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:n,field:s,value:l,row:r,cellEl:a,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}ht(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=ft(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&ut.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!ut.get(e))return;const i=ft(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!ut.get(e))return;const i=ft(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),ut.set(e,!1)}(e,o,t),{signal:i})}let wt;function mt(e){wt=e}class bt{#o;#k=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#O=null;#D=null;constructor(e){this.#o=e,this.#I()}focusCell(e,t){const o=this.#o,i=o._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=o._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const r=o._visibleColumns.length-1;r<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(n,r)),ht(o))}get focusedCell(){const e=this.#o;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 o=this.#o._virtualization;if(!o.enabled)return;const i=o.container;if(!i)return;const n=this.#o._rows.length;if(0===n)return;const r=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,c;const d=o.positionCache;o.variableHeights&&d&&d.length>r?(a=d[r].offset,c=d[r].height):(a=r*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p);const w=st(p,o.scrollMapping);"smooth"===l?i.scrollTo({top:w,behavior:"smooth"}):i.scrollTop=w}scrollToRowById(e,t){const o=this.#o._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#k.has(e))return;this.#k.add(e);const t=new AbortController,o=t.signal,i=this.#o;e.addEventListener("focusin",e=>{i.dataset.hasFocus="",this.#z(e.target)},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus,null===t&&this.#N()},{signal:o}),this.#L.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#k.delete(e);const t=this.#L.get(e);t&&(t(),this.#L.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#o.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#k)if(t.contains(e))return!0;return!1}#I(){const e=this.#o,t=new AbortController,o=t.signal;e.addEventListener("focusin",e=>this.#z(e.target),{signal:o,capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#N()},{signal:o}),this.#D=()=>t.abort()}#z(e){if(!(e instanceof HTMLElement))return;if(e===this.#o)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#O=e)}#N(){queueMicrotask(()=>{if(!this.#o.isConnected)return;document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#O;if(!e)return!1;if(!e.isConnected)return this.#O=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#O?.isConnected?this.#O:null}destroy(){for(const e of this.#L.values())e();this.#L.clear(),this.#k.clear(),this.#D?.(),this.#D=null,this.#O=null}}const vt="function"==typeof requestIdleCallback;function Ct(e){vt?cancelIdleCallback(e):clearTimeout(e)}function yt(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}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 _t(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 o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}function Rt(e){let t=null,o=null,i=null,n=null;const r=i=>{if(!t)return;const n=i.clientX-t.startX,r=Math.max(40,t.startWidth+n),s=e._visibleColumns[t.colIndex];s.width=r,s.__userResized=!0,s.__renderedWidth=r,null==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:r}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,o){const i=o.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const o=e._visibleColumns[n];if(null==o.width&&!o.__userResized){const e=i[n],t=e?.getBoundingClientRect().width;t&&(o.width=Math.round(t),o.__userResized=!0,o.__renderedWidth=o.width)}}}(s,c);const d=e._visibleColumns[s],h="number"==typeof d?.width?d.width:void 0,u=d?.__renderedWidth??h??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:u},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),null===i&&(i=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 o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const St="data-animating",Et={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},xt={change:500,insert:300,remove:200};function Tt(e,t){const o=Et[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return xt[t]}function At(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(St),e.offsetWidth,e.setAttribute(St,t);const i=Tt(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(St),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Pt(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function Ht(e,t,o){const i=Pt(e,o);return void 0===i&&T("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Mt{#o;constructor(e){this.#o=e}resolveRowId(e){return Ht(e,this.#o.id,this.#o.effectiveConfig?.getRowId)}getRow(e){return this.#o._getRowEntry(e)?.row}getRowEntry(e){return this.#o._getRowEntry(e)}updateRow(e,t,o="api"){const i=this.#o,n=i._getRowEntry(e);n||T(l,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:r,index:s}=n,a=[];for(const[l,c]of Object.entries(t)){const e=r[l];e!==c&&(a.push({field:l,oldValue:e,newValue:c}),r[l]=c,se(r,l))}for(const{field:l,oldValue:c,newValue:d}of a)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:r,rowId:e,rowIndex:s,field:l,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));a.length>0&&(Ye(i),i._requestSchedulerPhase(Ee.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#o;let i=!1;for(const{id:n,changes:r}of e){const e=o._getRowEntry(n);e||T(l,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:s,index:a}=e;for(const[l,c]of Object.entries(r)){const e=s[l];e!==c&&(i=!0,s[l]=c,se(s,l),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:n,rowIndex:a,field:l,oldValue:e,newValue:c,changes:r,source:t},bubbles:!0,composed:!0})))}}i&&(Ye(o),o._requestSchedulerPhase(Ee.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#o,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const r=[...i._rows];r.splice(n,0,t),i._rows=r,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Ye(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let s=0;s<i._rowPool.length;s++)i._rowPool[s].__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await At(i,n,"insert"))}async removeRow(e,t=!0){const o=this.#o,i=o._rows[e];if(!i)return;t&&await At(o,e,"remove");const n=o._rows.indexOf(i);if(n<0)return i;const r=[...o._rows];r.splice(n,1),o._rows=r;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Ye(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let l=0;l<o._rowPool.length;l++)o._rowPool[l].__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}async applyTransaction(e,t=!0){const o=this.#o,i={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:l}of e.remove){const e=o._getRowEntry(l);if(!e)continue;const{row:n}=e;if(t){const e=o._rows.indexOf(n);e>=0&&await At(o,e,"remove")}const r=o._rows.indexOf(n);if(r<0){i.removed.push(n);continue}const s=[...o._rows];s.splice(r,1),o._rows=s;const a=o.sourceRows.indexOf(n);if(a>=0){const e=[...o.sourceRows];e.splice(a,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(n);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}i.removed.push(n)}const n=new Set(e.remove?.map(e=>e.id));if(e.update?.length)for(const{id:l,changes:a}of e.update){if(n.has(l))continue;const e=o._getRowEntry(l);if(!e)continue;const{row:t,index:r}=e;let s=!1;for(const[i,n]of Object.entries(a)){const e=t[i];e!==n&&(s=!0,t[i]=n,se(t,i),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:l,rowIndex:r,field:i,oldValue:e,newValue:n,changes:a,source:"api"},bubbles:!0,composed:!0})))}s&&i.updated.push(t)}if(e.add?.length)for(const l of e.add){o.sourceRows=[...o.sourceRows,l];const e=[...o._rows];e.push(l),o._rows=e,o._sortState&&(o.__originalOrder=[...o.__originalOrder,l]),i.added.push(l)}const r=i.added.length>0||i.removed.length>0,s=i.updated.length>0;if(r){Ye(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let e=0;e<o._rowPool.length;e++)o._rowPool[e].__epoch=-1;o.refreshVirtualWindow(!0)}else s&&(Ye(o),o._requestSchedulerPhase(Ee.VIRTUALIZATION,"applyTransaction"));if((r||s)&&o._emitDataChange(),t&&i.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of i.added){const t=o._rows.indexOf(e);t>=0&&await At(o,t,"insert")}}if(t&&i.updated.length>0)for(const l of i.updated){const e=o._rows.indexOf(l);e>=0&&await At(o,e,"change")}return t&&i.removed.length>0&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}#q=null;#$=[];#F=null;applyTransactionAsync(e){return this.#q||(this.#q={add:[],update:[],remove:[]}),e.add&&this.#q.add.push(...e.add),e.update&&this.#q.update.push(...e.update),e.remove&&this.#q.remove.push(...e.remove),new Promise(e=>{this.#$.push(e),null===this.#F&&(this.#F=requestAnimationFrame(()=>{this.#F=null;const e=this.#q,t=this.#$;this.#q=null,this.#$=[],this.applyTransaction(e,!1).then(e=>{for(const o of t)o(e)})}))})}}function kt(e,t){if(t)for(const o in t){const i=t[o];null!=i&&e.setAttribute(o,i)}}function Lt(e,t,o){const i=document.createElement(e);return kt(i,t),i}function Ot(e,t){const o=document.createElement("div");return e&&(o.className=e),kt(o,t),o}function Dt(e,t,o){const i=document.createElement("button");return i.type="button",e&&(i.className=e),kt(i,t),i}const It=document.createElement("template");function zt(){return It.content.cloneNode(!0)}function Nt(e){const t=document.createDocumentFragment(),o=Ot(e.hasShell?`${z.ROOT} has-shell`:z.ROOT);if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ot("tbw-grid-content");e.appendChild(zt()),o.appendChild(e)}return t.appendChild(o),t}function qt(e){const t=Ot("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ot("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ot("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ot("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&i.appendChild(Ot("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&i.appendChild(Ot("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const n=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),r=e.hasPanels&&!1!==e.showToggle;if(n&&r&&i.appendChild(Ot("tbw-toolbar-separator")),r){const t=Dt(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=K(e.toolPanelIcon)),i.appendChild(t)}return t.appendChild(i),t}function $t(e){const t=Ot("tbw-shell-body",{"data-mode":e.mode??"overlay"}),o=e.panels.length>0,i=1===e.panels.length,n=Ot("tbw-grid-content");n.appendChild(zt());let r=null;if(o){r=Lt("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";r.appendChild(Ot("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ot("tbw-tool-panel-content",{role:"presentation"}),n=Ot("tbw-accordion");for(const r of e.panels){const t=Ot(`tbw-accordion-section${r.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":r.id}),o=Dt("tbw-accordion-header",{"aria-expanded":String(r.isExpanded),"aria-controls":`tbw-section-${r.id}`});if(i&&o.setAttribute("aria-disabled","true"),r.icon){const e=Lt("span",{class:"tbw-accordion-icon"});e.innerHTML=K(r.icon),o.appendChild(e)}const s=Lt("span",{class:"tbw-accordion-title"});if(s.textContent=r.title,o.appendChild(s),!i){const t=Lt("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=K(e.expandIcon)),o.appendChild(t)}t.appendChild(o),t.appendChild(Ot("tbw-accordion-content",{id:`tbw-section-${r.id}`,role:"presentation"})),n.appendChild(t)}o.appendChild(n),r.appendChild(o)}return"left"===e.position&&r?(t.appendChild(r),t.appendChild(n)):(t.appendChild(n),r&&t.appendChild(r)),t}function Ft(e){return e?"string"==typeof e?K(e):e.outerHTML:""}function Wt(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function Bt(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function Vt(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),i.style.display="none"}function Ut(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,n=i.getAttribute("id"),r=i.getAttribute("title");if(!n||!r)return void A("TBW070",`Tool panel missing required id or title attribute: id="${n??""}", title="${r??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=K(i.innerHTML.trim());c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(n);if(h){if(d){const e=!t.adapterBoundToolPanelIds.has(n),o=h.order!==a||h.icon!==s||h.tooltip!==l;if(h.render=c,h.order=a,h.icon=s,h.tooltip=l,t.adapterBoundToolPanelIds.add(n),e||o){const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n))}}return}const u={id:n,title:r,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(n,u),t.lightDomToolPanelIds.add(n),d&&t.adapterBoundToolPanelIds.add(n),i.style.display="none"})}function Gt(e,t,o){const i=t?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(e=>e.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function jt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const n=e.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",n.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of r){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=n.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),n.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function Yt(e,t,o){if(t.isPanelOpen)for(const[i,n]of t.toolPanels){const o=t.expandedSections.has(i),r=e.querySelector(`[data-section="${i}"]`),s=r?.querySelector(".tbw-accordion-content");if(!r||!s)continue;r.classList.toggle("expanded",o);const l=r.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=n.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function Xt(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function Kt(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function Zt(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function Qt(e,t,o){const i=void 0!==o?.toolPanel?Ft(o.toolPanel):void 0,n=void 0!==o?.expand?Ft(o.expand):void 0,r=void 0!==o?.collapse?Ft(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),l=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:l.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:i,showToggle:!1!==e.header?.toolPanelToggle&&!0!==e.toolPanel?.locked,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",mode:e.toolPanel?.mode??"overlay",isPanelOpen:t.isPanelOpen,expandIcon:n,collapseIcon:r,panels:l.map(e=>({id:e.id,title:e.title,icon:Ft(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function Jt(e,t,o,i){const n=Wt(t),r=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(z.ROOT)||r.push(s);e.replaceChildren();for(const s of r)e.appendChild(s);if(n){const{headerOptions:n,bodyOptions:r}=Qt(t,o,i),s=Nt({hasShell:!0,shellHeader:qt(n),shellBody:$t(r)});e.appendChild(s)}else{const t=Nt({hasShell:!1});e.appendChild(t)}return n}function eo(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}It.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';const to="tbw-grid-styles";let oo="";const io=/* @__PURE__ */new Map;function no(){const e=function(){const e=Co.activeTag;return e===Co.tagName?to:`${to}-${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 ro(e){const t=Co.activeTag;return t===Co.tagName?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function so(){const e=no(),t=Array.from(io.values()).join("\n");e.textContent=`${oo}\n\n/* Plugin Styles */\n${t}`}async function lo(e){if(oo)return;if("string"==typeof e&&e.length>0)return oo=ro(e),void so();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){A("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(oo=ro(t),so()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||A("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 ao(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function co(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function ho(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 o=.95,i=1;let n=performance.now();const r=()=>{const s=performance.now(),l=s-n;n=s;const a=l/16,c=Math.pow(o,a);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,h=16*e.velocityX,u=Math.abs(d)>=i,g=Math.abs(h)>=i;u&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=h),e.momentumRaf=u||g?requestAnimationFrame(r):0};e.momentumRaf=requestAnimationFrame(r)}(e,t),ao(e)}function uo(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){co(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const n=performance.now(),r=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=n-o.lastTime;e>0&&(o.velocityY=r/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=n,o.locked){const{scrollTop:e,scrollHeight:t,clientHeight:o}=i.fauxScrollbar;if(r>0&&e<t-o||r<0&&e>0?i.fauxScrollbar.scrollTop+=r:0!==r&&window.scrollBy(0,r),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:o}=i.scrollArea;s>0&&e<t-o||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ho(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ao(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ao(t))},{passive:!0,signal:i})}const go=[{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}],fo=[{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 po(e){return`import { ${wo(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function wo(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mo(e,t){return e.some(e=>e.name===t)}class bo{#o;state;constructor(e,t){this.#o=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,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,n,r;if(t){const e=o.container??this.#o._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,n=t?.clientHeight??0,r=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=n,o.cachedScrollAreaHeight=r}else i=o.cachedFauxHeight,n=o.cachedViewportHeight,r=o.cachedScrollAreaHeight||i;const s=r-n,l=Math.max(0,i-r);let a;return a=o.variableHeights&&o.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):e*o.rowHeight,o.scrollMapping=nt(a,n),o.scrollMapping.spacerHeight+s+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#o,o=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,r=t.effectiveConfig?.getRowId,s=r?e=>r(e):void 0;e.positionCache=function(e,t,o,i,n){const r=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=n?.(a,l),d=void 0!==c;void 0===c&&(c=Je(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(n){const t=n(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let n=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(r+=o.height,n++)}}return{measuredCount:n,averageHeight:n>0?r/n:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#o._rows;if(e<0||e>=i.length)return;const n=i[e];let r=t;void 0===r&&(r=this.#o._getPluginRowHeight(n,e)),void 0===r&&(r=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-r)<1)&&(et(o.positionCache,e,r),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#o,n=i._bodyEl;if(!n)return;const r=n.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=ot({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},r);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#o,n=i._bodyEl;if(!n)return!1;const r=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,r),t||i._afterPluginRender(),!0;if(r<=o.bypassThreshold)return o.start=0,o.end=r,e&&(n.style.transform="translateY(0px)"),i._renderVisibleRows(0,r,i.__rowRenderEpoch),e&&o.variableHeights&&this.initializePositionCache(),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(r,!0)}px`),i._updateAriaCounts(r,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=rt(s.scrollTop,o.scrollMapping);let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;o.variableHeights&&u&&u.length>0?(h=tt(u,d),-1===h&&(h=0)):h=Math.floor(d/c),h-=h%2,h<0&&(h=0),r>0&&h>r-1&&(h=r-1);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<r&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,r))}else{f=h+(Math.ceil(a/c)+3)}f>r&&(f=r);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const m=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===m&&a>0)return i._requestSchedulerPhase(Ee.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(r);o.totalHeightEl.style.height=`${e}px`}let b;b=o.variableHeights&&u&&u[h]?u[h].offset:h*c;const v=-(d-b);return n.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(r,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(r);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class vo{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;#W=/* @__PURE__ */new Map;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;attachAll(e){const t=this.#B(e);for(const o of t)this.attach(o)}#B(e){if(e.length<2)return e;const t=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=[];for(const n of e){const e=n.constructor,r=t.get(e);if(!r){t.set(e,n),i.push(n);continue}const s=o.get(r)??[];s.push(n),o.set(r,s)}if(0===o.size)return i;for(const[n,r]of o)n.mergeConfigsFrom(r);return i}attach(e){if(function(e,t,o){const i=e.name,n=e.constructor.dependencies??[];for(const r of n){const e=r.name,n=r.required??!0,s=r.reason;if(!t.some(t=>t.name===e)){const t=s??`${wo(i)}Plugin requires ${wo(e)}Plugin`,r=po(e);n&&T("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${wo(i)}Plugin:\n ${r}\n plugins: [new ${wo(e)}Plugin(), new ${wo(i)}Plugin()]`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),e.attach(this.grid),this.#V();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 o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.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.#W.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 o of this.#U("processRows")){const e=o.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const o of this.#U("processColumns"))t=o.processColumns(t);return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.#U("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#U("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#U("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#V(){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.#W.clear()}#U(e){let t=this.#W.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const o=t=>{const o=t.constructor.manifest?.hookPriority;if(!o)return 0;return o[e]??0};return t.some(e=>0!==o(e))&&t.sort((e,t)=>o(e)-o(t)),this.#W.set(e,t),t}onScrollRender(){for(const e of this.#U("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const r=n.adjustVirtualStart(e,t,o);r<i&&(i=r)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=/* @__PURE__ */new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const n of o.values())try{n(t)}catch(i){H("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#U("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#U("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#U("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#U("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#U("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#U("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#U("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#U("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,n=!1;for(const r of this.plugins){const s=r.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:o,right:i,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class Co extends HTMLElement{static tagName="tbw-grid";static version="2.14.1";static activeTag="tbw-grid";static#G=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#j(){return this}#Y=!1;#r;#s;#X=[];get#m(){return this.#K?.effective??{}}#Z=!1;#Q=!1;#J={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#ee;#te=0;#oe=null;#ie=!1;#ne=!1;#re=0;#se;#le={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#ae;#ce;#de;#he;#ue={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ge;#fe;#pe;#we;#me;#be;get _pluginManager(){return this.#ge}#ve=!1;#Ce;#ye;#R;#K;#_e=function(){return{toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,adapterBoundToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1}}();#Re;#Se;#Ee;#xe=!1;#Te=/* @__PURE__ */new Set;#Ae=/* @__PURE__ */new Map;#Pe;#He={};#Me=/* @__PURE__ */new Map;#ke=!1;_rows=[];#Le=[];get _columns(){return this.#m.columns??[]}set _columns(e){this.#m.columns=e,this.#Oe=void 0}#Oe;get _visibleColumns(){return this.#Oe??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Oe=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#we.state}set _virtualization(e){Object.assign(this.#we.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#K?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#K&&(this.#K.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#K?.originalColumnNodes}set __originalColumnNodes(e){this.#K&&(this.#K.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],o=this.#X;this.#X=t,o!==t&&this.#De("rows")}get sourceRows(){return this.#X}set sourceRows(e){this.#X=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=this.#K?.getColumns();this.#K?.setColumns(e),t!==e&&this.#De("columns")}get gridConfig(){return this.#m}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#K?.getGridConfig();this.#K?.setGridConfig(e),t!==e&&(this.#K.clearLightDomCache(),this.#De("gridConfig"))}get fitMode(){return this.#m.fitMode??"stretch"}set fitMode(e){const t=this.#K?.getFitMode();this.#K?.setFitMode(e),t!==e&&this.#De("fitMode")}get loading(){return this.#xe}set loading(e){const t=this.#xe;this.#xe=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Ie(),this.#ze())}setRowLoading(e,t){const o=this.#Te.has(e);t?this.#Te.add(e):this.#Te.delete(e),o!==t&&this.#Ne(e,t)}setCellLoading(e,t,o){let i=this.#Ae.get(e);const n=i?.has(t)??!1;o?(i||(i=/* @__PURE__ */new Set,this.#Ae.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#Ae.delete(e)),n!==o&&this.#qe(e,t,o)}isRowLoading(e){return this.#Te.has(e)}isCellLoading(e,t){return this.#Ae.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Te)this.#Ne(e,!1);this.#Te.clear();for(const[e,t]of this.#Ae)for(const o of t)this.#qe(e,o,!1);this.#Ae.clear()}get effectiveConfig(){return this.#m}get disconnectSignal(){return this.#ae||(this.#ae=new AbortController),this.#ae.signal}constructor(){super(),this.#$e(),this.#r=new Promise(e=>this.#s=e),this.#we=new bo(this),this.#me=new bt(this),this.#be=new Mt(this),this.#ee=new xe(this),this.#ee.setInitialReadyResolver(()=>this.#s?.()),this.#Re=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o){if(0===e.toolPanels.size)return void A("TBW071","No tool panels registered",t.id);let n;if(void 0!==o&&(e.toolPanels.has(o)?n=o:A(d,`Tool panel "${o}" not found`,t.id)),e.isPanelOpen&&n&&e.expandedSections.has(n))return;if(e.isPanelOpen&&n&&!e.expandedSections.has(n))return void i.toggleToolPanelSection(n);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(n)e.expandedSections.add(n);else{const o=t.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(o&&e.toolPanels.has(o))e.expandedSections.add(o);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(n&&!e.expandedSections.has(n)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(n)}const r=t._renderRoot;Xt(r,e),Kt(r,e),Yt(r,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(t.effectiveConfig?.shell?.toolPanel?.locked)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;Xt(o,e),Kt(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void A(d,`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const n=t._renderRoot,r=e.expandedSections.has(o);if(r){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),eo(n,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),eo(n,t,!1);const r=n.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),eo(n,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const n=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&t.panelCleanups.set(o,r)}(n,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!r})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?A("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?A("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&jt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const n=e.headerContents.get(o);n?.onDestroy?.(),e.headerContents.delete(o);const r=t._renderRoot.querySelector(`[data-header-content="${o}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?A("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const n=e.toolbarContentCleanups.get(i);n&&(n(),e.toolbarContentCleanups.delete(i));const r=e.toolbarContents.get(i);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#_e,this),this.#K=new Te(this)}async#$e(){await lo('@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-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select: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-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.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}}}\n@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-shell-body[data-mode=push]{.tbw-tool-panel{position:relative;inset:auto;flex-shrink:0;box-shadow:none;z-index:auto;border-left:none;border-right:none;&.open{border-left:1px solid var(--tbw-tool-panel-border)}&[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}}.tbw-tool-panel-resize{display:none}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display: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.#ge?.getPlugin(e)}getPluginByName(e){return this.#ge?.getPluginByName(e)}requestRender(){this.#ee.requestPhase(Ee.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#ee.requestPhase(Ee.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#ee.requestPhase(Ee.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){I(this)}requestAfterRender(){this.#ee.requestPhase(Ee.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Fe(){this.#ge=new vo(this);const e=this.#m?.plugins,t=Array.isArray(e)?e:[],o=this.#m?.features;let i,n=[];if(o&&wt&&(n=wt(o)),0===n.length)i=t;else if(0===t.length)i=n;else{const e=new Set(t.map(e=>e.name));i=[...n.filter(t=>!e.has(t.name)),...t]}this.#ge.attachAll(i)}#We(){!function(e){let t=!1;for(const{name:o,styles:i}of e)io.has(o)||(io.set(o,ro(i)),t=!0);t&&so()}(this.#ge?.getPluginStyles()??[])}#Be(){const e=this.#m?.plugins,t=Array.isArray(e)?e:[],o=this.#m?.features??void 0,i=o!==this.#pe;if((this.#fe===t||void 0!==this.#fe&&this.#fe.length===t.length&&this.#fe.every((e,o)=>e===t[o]))&&!i)return void(this.#fe=t);this.#ge&&this.#ge.detachAll();for(const r of this.#_e.toolPanels.keys()){const e=this.#_e.lightDomToolPanelIds.has(r),t=this.#_e.apiToolPanelIds.has(r);if(!e&&!t){const e=this.#_e.panelCleanups.get(r);e&&(e(),this.#_e.panelCleanups.delete(r)),this.#_e.toolPanels.delete(r)}}for(const r of this.#_e.headerContents.keys()){if(this.#_e.apiHeaderContentIds.has(r))continue;const e=this.#_e.headerContentCleanups.get(r);e&&(e(),this.#_e.headerContentCleanups.delete(r)),this.#_e.headerContents.delete(r)}this.#Fe(),this.#We(),this.#fe=t,this.#pe=o,this.#Ve(),this.#Ue();const n=this.#ie;if(this.#ie=this.#ge?.getAll().some(e=>e.onScroll)??!1,!n&&this.#ie){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.querySelector(".tbw-grid-root");this.#Ge(e)}}#je(){this.#ge?.detachAll()}#Ue(){if(!this.#ge)return;const e=this.#ge.getToolPanels();for(const{panel:o}of e)this.#_e.toolPanels.has(o.id)||this.#_e.toolPanels.set(o.id,o);const t=this.#ge.getHeaderContents();for(const{content:o}of t)this.#_e.headerContents.has(o.id)||this.#_e.headerContents.set(o.id,o)}#Ye(){const e=Co.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",Co.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++Co.#G),this._rows=Array.isArray(this.#X)?[...this.#X]:[],this.#ae&&(this.#ae.abort(),this.#ve=!1),this.#ae=new AbortController,this.#he&&(Ct(this.#he),this.#he=void 0),this.#Xe(),this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Fe();const e=this.#m?.plugins;var t,o;this.#fe=Array.isArray(e)?e:[],this.#pe=this.#m?.features??void 0,this.#Ue(),this.#Y||(this.#Ke(),this.#We(),this.#Y=!0),this.#Ze(),this.#he=(t=()=>{this.#Qe()},o={timeout:100},vt?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#he&&(Ct(this.#he),this.#he=void 0),this.#re&&(clearTimeout(this.#re),this.#re=0),this.#je(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.adapterBoundToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#_e),this.#Re.setInitialized(!1),this.#Se?.(),this.#Se=void 0,this.#Ee?.(),this.#Ee=void 0,co(this.#le),this.#ae&&(this.#ae.abort(),this.#ae=void 0),this.#Ce?.abort(),this.#Ce=void 0,this.#ve=!1,this._resizeController&&this._resizeController.dispose(),this.#ce&&(this.#ce.disconnect(),this.#ce=void 0),this.#de&&(this.#de.disconnect(),this.#de=void 0,this.#Je=!1,this.#et=0),Ye(this),this.#tt.clear(),this._virtualization.heightCache?.byKey.clear(),this.#fe=void 0,this.#pe=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#Z=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{A("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#Ze(){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.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.#Re.isInitialized){jt(this.#j,this.#_e),Gt(this.#j,this.#m?.shell,this.#_e);const e=this.#m?.shell?.toolPanel,t=e?.defaultOpen;t&&this.#_e.toolPanels.has(t)&&this.#_e.expandedSections.add(t);const o=!0===e?.locked||"open"===e?.initialState||void 0===e?.initialState&&void 0!==t&&this.#_e.toolPanels.has(t);!this.#_e.isPanelOpen&&this.#_e.toolPanels.size>0&&o&&this.openToolPanel(),this.#_e.isPanelOpen&&(Kt(this.#j,this.#_e),Yt(this.#j,this.#_e,(this.#m,this.#m)),Xt(this.#j,this.#_e))}if(this.setAttribute("data-upgraded",""),this.#Z=!0,this._resizeController=Rt(this),this.#ot(),this.#Ge(e),this.#ve)return;this.#ve=!0;const t=this.disconnectSignal;pt(this,this,this.#j,t),this.#Ve(),queueMicrotask(()=>this.#it()),this.#ee.requestPhase(Ee.FULL,"afterConnect")}#Ve(){const e=this.#m.rowHeight,t=this.#ge.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.#we.initializePositionCache(),"function"!=typeof e&&(this.#ne=!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.#nt())}#nt(){if(this.#ge.hasRowHeightPlugin())return;const e=this.#m.rowHeight;if("number"==typeof e&&e>0)return;const t=this._bodyEl?.querySelector(".data-grid-row");if(!t)return;if(t.style.getPropertyValue("--tbw-row-height"))return;const o=this.#rt(),i=t.querySelectorAll(".cell");let n=0;i.forEach(e=>{const t=e.offsetHeight;t>n&&(n=t)});const r=t.getBoundingClientRect(),s=Math.max(r.height,n),l=this._virtualization.rowHeight,a=this.#et,c=o>0&&a>0&&Math.abs(o-a)>1,d=o>0&&0===a,h=s>0&&s-l>1;if(o>0&&(this.#et=o),c||d||h){const e=c||d?Math.max(o,s):s;Math.abs(e-l)>1&&(this._virtualization.rowHeight=e,this.#ee.requestPhase(Ee.VIRTUALIZATION,"measureRowHeight"))}}#rt(){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 o=parseFloat(getComputedStyle(t).minHeight);return o>0?o:0}#st(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#we.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#we.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Ge(e){this.#Ce?.abort(),this.#Ce=new AbortController;const t=this.#Ce.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#ie=this.#ge?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#ie)return;const e=o.scrollTop,t=rt(e,this._virtualization.scrollMapping),n=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const e=this._virtualization.positionCache;let o,r;if(this._virtualization.variableHeights&&e&&e.length>0){o=tt(e,t),-1===o&&(o=0);const i=o-o%2;r=e[i]?.offset??i*n}else{o=Math.floor(t/n);r=(o-o%2)*n}const s=-(t-r);i.style.transform=`translateY(${s}px)`}this.#oe=e,this.#te||(this.#te=requestAnimationFrame(()=>{this.#te=0,null!==this.#oe&&(this.#lt(this.#oe),this.#oe=null)}))},{passive:!0,signal:t});const e=this.#j.querySelector(".tbw-scroll-area");this.#ye=e,this._virtualization.scrollAreaEl=e,e&&this.#ie&&e.addEventListener("scroll",()=>{const t=this.#ue;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#ge?.onScroll(t)},{passive:!0,signal:t});const n=this.#j.querySelector(".tbw-grid-content"),r=this.#ye;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&&r){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:o,scrollWidth:i,clientWidth:n}=r;(t>0&&o<i-n||t<0&&o>0)&&(e.preventDefault(),r.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:n}=o;(e.deltaY>0&&t<i-n||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),uo(n,this.#le,{fauxScrollbar:o,scrollArea:r},t))}var n,r,s;this._bodyEl&&(n=this,r=this._bodyEl,s=t,r.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(z.EDITING))return;const o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),gt(n,t)},{signal:s}),r.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&Ze(n,e,t),!document.activeElement?.closest(`.cell.${z.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),r.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&Ze(n,e,t)},{signal:s})),this.#ce?.disconnect(),this._virtualization.viewportEl&&(this.#ce=new ResizeObserver(()=>{this.#at(),this.#ee.requestPhase(Ee.VIRTUALIZATION,"resize-observer")}),this.#ce.observe(this._virtualization.viewportEl)),this.#j.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#j.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#j.contains(t)||this.#me.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Je=!1;#et=0;#ct(){if(this.#Je)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Je=!0,this.#de?.disconnect(),this.#de=new ResizeObserver(()=>{this.#nt()}),this.#de.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#dt(e,t){this.#Z&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#dt("data-change",{rowCount:this._rows.length,sourceRowCount:this.#X.length}),function(e,t,o){if(o===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=o,0===o&&i<0||n(e,r(e,"dataLoaded",o))}(this,this.#ht,this.#X.length)}#it(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#De(e){this.#J[e]=!0,this.#Q||(this.#Q=!0,queueMicrotask(()=>this.#ut()))}#ut(){if(!this.#Q||!this.#Z)return void(this.#Q=!1);const e=this.#J;if(this.#Q=!1,this.#J={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#gt(),void(e.rows&&this.#ft());e.columns&&this.#pt(),e.rows&&this.#ft(),e.fitMode&&this.#wt()}#ft(){this._rows=Array.isArray(this.#X)?[...this.#X]:[],this.#ke=!0,this.#ee.requestPhase(Ee.ROWS,"applyRowsUpdate")}#mt(){this.#ke&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#ke=!1,this.#Me.clear();const e=this.#m.getRowId;for(let t=0;t<this._rows.length;t++){const o=Pt(this._rows[t],e);void 0!==o&&this.#Me.set(o,{row:this._rows[t],index:t})}}#pt(){Ye(this),this.#K.merge(),this.#ot()}#wt(){this.#K.merge();if("fixed"===this.#m.fitMode)this.__didInitialAutoSize=!1,L(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}I(this)}}#gt(){Bt(this,this.#_e),Vt(this,this.#_e);const e=!!this.#j.querySelector(".has-shell"),t=!!this.#j.querySelector(".tbw-tool-panel"),o=this.#j.querySelectorAll(".tbw-accordion-section").length,i=this.#j.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Be(),this.#Ve(),Ut(this,this.#_e,this.#Ye()),this.#K.markSourcesChanged(),this.#K.merge();const n=this.#K.initialColumnState;if(n){this.#K.initialColumnState=void 0,this.#R=void 0;const e=this.#ge?.getAll()??[];this.#K.applyState(n,e)}const r=Wt(this.#m?.shell),s=(this.#m?.shell?.toolPanels?.length??0)>0,l=this.#m?.shell?.toolPanels?.length??0,a=this.#m?.shell?.toolPanel?.position??"right";if(e!==r||!t&&s||t&&l!==o||t&&i!==a)return Zt(this.#_e),this.#Ke(),this.#We(),this.#Ze(),void this._rebuildRowIdMap();e&&this.#bt(),this.#_e.isPanelOpen&&Yt(this.#j,this.#_e,(this.#m,this.#m)),this._rebuildRowIdMap(),this.#ee.requestPhase(Ee.COLUMNS,"applyGridConfigUpdate")}#bt(){const e=this.#j.querySelector(".tbw-shell-header");if(!e)return;const t=this.#m.shell?.header?.title??this.#_e.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#vt(){if(this.__rowRenderEpoch++,this.#ge){const e=this.#Le.length>0?this.#Le:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#ge.processColumns([...t]);if(i!==t){const n=new Set(i.map(e=>e.field));!t.some(e=>n.has(e.field))&&i.length>0?this._columns=[...i,...o]:this._columns=this.#Ct(e,i,o)}else this._columns=[...e]}}#Ct(e,t,o){if(0===o.length)return t;const i=/* @__PURE__ */new Map;for(const l of t)i.set(l.field,l);const n=new Set(e.map(e=>e.field)),r=[];for(const l of t)n.has(l.field)||r.push(l);const s=[];for(const l of e){const e=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...r),s}#yt(){Ye(this);const e=this.#X;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#we.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#m.initialSort){const{field:e,direction:t}=this.#m.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,o=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??ae;if(i===ae)return o||(e.__originalOrder=t.slice()),ue(t,e._sortState.field,e._sortState.direction,e._columns),t;o||(e.__originalOrder=t);const n=i(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),o=this.#ge?.processRows(t)??t;this._rows=o,this.#ke=!0,this._emitDataChange()}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#se||(this.#se=(e,t,o)=>this.#ge?.renderRow(e,t,o)??!1),function(e,t,o,i,n){const r=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<r;){const t=je();e._rowPool.push(t)}if(e._rowPool.length>r){const t=e.__frameworkAdapter,o=t?.releaseCell;t?.beginBatch?.(e);try{for(let i=r;i<e._rowPool.length;i++){const n=e._rowPool[i];if(o){const e=n.children;for(let i=0;i<e.length;i++){const n=e[i];n.firstElementChild&&o.call(t,n)}}n.parentNode===s&&n.remove()}e._rowPool.length=r}finally{t?.endBatch?.(e)}}const d=n&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,u=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<r;f++){const o=t+f,r=e._rows[o],p=e._rowPool[f];if(p.setAttribute("aria-rowindex",String(o+c+1)),d&&n(r,p,o)){p.__epoch=i,p.__rowDataRef=r,p.parentNode!==s&&s.appendChild(p);continue}const w=p.__epoch,m=p.__rowDataRef;let b=p.children.length;b>a&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const v=w===i&&b===a,C=m!==r,y=!!e._isGridEditMode;let _=!1;if(v&&C)for(let e=0;e<a;e++)if(l[e].externalView&&!p.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){_=!0;break}if(!v||_){const t=We(p),n=y&&!C||e._activeEditRows===o;t&&!n?(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):t&&n?(Xe(e,p,r,o),p.__rowDataRef=r):(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r)}else if(C){const t=We(p),n=e._activeEditRows===o;t&&!n?(Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):(Xe(e,p,r,o),p.__rowDataRef=r)}else{const t=We(p),n=y||e._activeEditRows===o;t&&!n?(Be(p),Ke(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):Xe(e,p,r,o)}let R=!1;const S=e._changedRowIdSet;if(S&&S.size>0)try{const t=e.getRowId?.(r);t&&(R=S.has(t))}catch{}R!==p.classList.contains("changed")&&p.classList.toggle("changed",R);const E=e.effectiveConfig?.rowClass;if(E){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=E(r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(p.classList.add(i),e+=(e?" ":"")+i)}p.setAttribute("data-dynamic-classes",e)}else p.removeAttribute("data-dynamic-classes")}catch(g){A("TBW060",`rowClass callback error: ${g}`,e.id),p.removeAttribute("data-dynamic-classes")}}if(u){const e=u(r,o);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}h&&e._afterRowRender?.({row:r,rowIndex:o,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,o,this.#se),this.#Te.size>0)for(const i of this.#Te)this.#Ne(i,!0)}#ht={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,o,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const r=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==r&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#ht,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#ee.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#ge?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,o){return this.#ge?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#ge?.afterRender()}_emitPluginEvent(e,t){this.#ge?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#K.parseLightDomColumns(this),this.#K.merge(),this.#Be(),function(e,t,o){const i=go,n=fo,r=/* @__PURE__ */new Map;function s(e,t,o,i,n=!1){r.has(e)||r.set(e,{description:t,importHint:o,fields:[],isConfigProperty:n});const s=r.get(e);s.fields.includes(i)||s.fields.push(i)}const l=e.features;function a(e){return!!l&&!1===l[e]}for(const d of n){const o=e[d.property];if((d.isUsed?d.isUsed(o):void 0!==o)&&!mo(t,d.pluginName)&&!a(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,po(d.pluginName),d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of i){const o=d[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!mo(t,e.pluginName)&&!a(e.pluginName)){const t=d.field||"<unknown>",o=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,o,po(e.pluginName),t)}}if(r.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:n,isConfigProperty:s}]of r)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${wo(t)}Plugin(), ...]`);else{const r=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${r}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${wo(t)}Plugin(), ...]`)}T([...r.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.`,o)}}(this.#m,this.#ge?.getPlugins()??[],this.id),function(e,t){const o=[],i=[];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=`[${wo(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&Me())for(const n of i)A("TBW004",n,t);o.length>0&&T("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#ge?.getPlugins()??[],this.id),function(e,t){if(!Me())return;const o=new Set(e.map(e=>e.name)),i=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const r of e.incompatibleWith)if(o.has(r.name)){const e=[n.name,r.name].sort().join("↔");if(i.has(e))continue;i.add(e),A("TBW022",`${wo(n.name)}Plugin and ${wo(r.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${r.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ge?.getPlugins()??[],this.id),this.#_t(),this.#Le=[...this._columns]}_schedulerProcessColumns(){this.#vt()}_schedulerProcessRows(){this.#yt()}_schedulerRenderHeader(){Re(this)}_schedulerUpdateTemplate(){I(this)}_schedulerAfterRender(){this.#ge?.afterRender(),this.#ze(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#we.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#m.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,L(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,ht(this)),this._virtualization.enabled&&!this.#Je&&this.#ct(),this.#ne&&(this.#ne=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#st()})})),this.#xe&&this.#Ie()}get _schedulerIsConnected(){return this.isConnected&&this.#Z}get _hostElement(){return this}get _renderRoot(){return this.#j}_emit(e,t){this.#dt(e,t)}get _accordionIcons(){return{expand:this.#m?.icons?.expand??i.expand,collapse:this.#m?.icons?.collapse??i.collapse}}get _shellState(){return this.#_e}_clearRowPool(){const e=this.__frameworkAdapter,t=e?.releaseCell;if(t){e?.beginBatch?.(this);try{for(let o=0;o<this._rowPool.length;o++){const i=this._rowPool[o].children;for(let o=0;o<i.length;o++){const n=i[o];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.#ot()}_applyAnimationConfig(e){const t={...o,...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}#_t(){!function(e,t,o,i){if(!t)return!1;let n=!1;const r=o?.gridAriaLabelledBy,s=r?void 0:function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);r!==e.ariaLabelledBy&&(e.ariaLabelledBy=r,r?t.setAttribute("aria-labelledby",r):t.removeAttribute("aria-labelledby"),n=!0),s!==e.ariaLabel&&(e.ariaLabel=s,s?t.setAttribute("aria-label",s):t.removeAttribute("aria-label"),n=!0);const l=o?.gridAriaDescribedBy;l!==e.ariaDescribedBy&&(e.ariaDescribedBy=l,l?t.setAttribute("aria-describedby",l):t.removeAttribute("aria-describedby"),n=!0);const a=o?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),n=!0)}(this.#ht,this.__rowsBodyEl,this.#m,this.#_e)}#Ie(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#xe?(this.#Pe||(this.#Pe=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(yt("large",e)),t}(this.#m?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#Pe)):(t=this.#Pe,t?.remove()))}#ze(){!function(e,t,o,i,n,r,s){if(!e)return;if(!function(e,t,o){return!(e||t>0||null===o)}(t,o,n))return He(s.el),s.el=void 0,s.renderer=void 0,s.target=void 0,s.sourceRows=void 0,void(s.filteredOut=void 0);const l=i.length,a=l>0&&0===o;if(s.el&&s.renderer===n&&s.target===r&&s.sourceRows===i&&s.filteredOut===a)return;const c="grid"===r?e:e.querySelector(".rows-container")??e;He(s.el),s.el=Pe({sourceRowCount:l,filteredOut:a},n??void 0,r),function(e,t){e.appendChild(t)}(c,s.el),s.renderer=n,s.target=r,s.sourceRows=i,s.filteredOut=a}(this.querySelector(".tbw-grid-root"),this.#xe,this._rows.length,this.#X,this.#m?.emptyRenderer,this.#m?.emptyOverlay??"rows",this.#He)}#Ne(e,t){this.#mt();const o=this.#Me.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&_t(i,t)}#qe(e,t,o){this.#mt();const i=this.#Me.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const r=this._visibleColumns.findIndex(e=>e.field===t);if(r<0)return;const s=n.children[r];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,o)}#ot(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#K.parseLightDomColumns(this),this.#R){const e=this.#R;this.#R=void 0,this.#K.merge();const t=this.#ge?.getAll()??[];this.#K.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#ee.requestPhase(Ee.FULL,"setup")}}#lt(e){const t=this._virtualization.container,o=this.#ye,i=o?.scrollLeft??0,n=t?.scrollHeight??0,r=o?.scrollWidth??0,s=t?.clientHeight??0,l=o?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#ge?.onScrollRender(),this._virtualization.variableHeights&&(this.#re&&clearTimeout(this.#re),this.#re=window.setTimeout(()=>{this.#re=0,this.#we.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#ie){const t=this.#ue;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=n,t.scrollWidth=r,t.clientHeight=s,t.clientWidth=l,this.#ge?.onScroll(t)}this.#dt("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#j.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const n=this._rows[t],r=this._visibleColumns[o];if(!n||!r)return!1;const s=r.field,l=n[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:o,column:r,field:s,value:l,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:o,column:r,field:s,value:l,cellEl:i,originalEvent:e},d=this.#ge?.onCellClick(c)??!1;return this.#dt("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const n={rowIndex:t,row:o,rowEl:i,originalEvent:e},r=this.#ge?.onRowClick(n)??!1;return this.#dt("row-click",n),r}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#ge?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ge?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ge?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#ge?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ge?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ge?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ge?.onCellMouseUp(e)}_afterCellRender(e){this.#ge?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ge?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ge?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ge?.hasAfterRowRenderHook()??!1}async ready(){return this.#r}async forceLayout(){return 0===this.#ee.pendingPhase&&this.#ee.requestPhase(Ee.FULL,"forceLayout"),this.#ee.whenReady()}async getConfig(){return Object.freeze({...this.#m||{}})}getRowId(e){return Ht(e,this.id,this.#m.getRowId)}getRow(e){return this.#be.getRow(e)}_getRowEntry(e){return this.#mt(),this.#Me.get(e)}updateRow(e,t,o="api"){this.#be.updateRow(e,t,o)}updateRows(e,t="api"){this.#be.updateRows(e,t)}animateRow(e,t){return At(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>At(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const r=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return r<0?Promise.resolve(!1):At(e,r,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#be.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#be.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#be.applyTransaction(e,t)}applyTransactionAsync(e){return this.#be.applyTransactionAsync(e)}focusCell(e,t){this.#me.focusCell(e,t)}get focusedCell(){return this.#me.focusedCell}scrollToRow(e,t){this.#me.scrollToRow(e,t)}scrollToRowById(e,t){this.#me.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#K.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#K.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#K.isColumnVisible(e)}showAllColumns(){this.#K.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#K.getAllColumns()}setColumnOrder(e){this.#K.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#K.getColumnOrder()}getColumnState(){const e=this.#ge?.getAll()??[];return this.#K.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#Y?this.#Rt(e):(this.#R=e,this.#K.initialColumnState=e))}#Rt(e){const t=this._columns,o=this._sortState,i=this.#ge?.getAll()??[];this.#K.applyState(e,i);if(!e.columns.some(e=>void 0!==e.sort)&&this.#St(t,o))return this.#Oe=void 0,I(this),void this.#ee.requestPhase(Ee.STYLE,"column-width");this.#ot()}#St(e,t){const o=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==o.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],i=o[n];if(t.field!==i.field)return!1;if(!!t.hidden!=!!i.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=[],Re(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 o=this._columns.find(t=>t.field===e);o&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),me(this,o,"desc"===t?-1:1)):we(this,o))}requestStateChange(){const e=this.#ge?.getAll()??[];this.#K.requestStateChange(e)}resetColumnState(){this.#R=void 0,this.__originalOrder=[];const e=this.#ge?.getAll()??[];this.#K.resetState(e),this.#K.merge(),this.#ot()}get isToolPanelOpen(){return this.#Re.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#Re.expandedSections}openToolPanel(e){this.#Re.openToolPanel(e)}closeToolPanel(){this.#Re.closeToolPanel()}toggleToolPanel(){this.#Re.toggleToolPanel()}toggleToolPanelSection(e){this.#Re.toggleToolPanelSection(e)}getToolPanels(){return this.#Re.getToolPanels()}registerToolPanel(e){this.#_e.apiToolPanelIds.add(e.id),this.#Re.registerToolPanel(e)}unregisterToolPanel(e){this.#_e.apiToolPanelIds.delete(e),this.#Re.unregisterToolPanel(e)}getHeaderContents(){return this.#Re.getHeaderContents()}registerHeaderContent(e){this.#_e.apiHeaderContentIds.add(e.id),this.#Re.registerHeaderContent(e)}unregisterHeaderContent(e){this.#_e.apiHeaderContentIds.delete(e),this.#Re.unregisterHeaderContent(e)}getToolbarContents(){return this.#Re.getToolbarContents()}registerToolbarContent(e){this.#Re.registerToolbarContent(e)}unregisterToolbarContent(e){this.#Re.unregisterToolbarContent(e)}#Et=!1;refreshShellHeader(){this.#Et||(this.#Et=!0,queueMicrotask(()=>{if(this.#Et=!1,!this.isConnected)return;this.#Xe(),this.#K.markSourcesChanged(),this.#K.merge(),Zt(this.#_e);(function(e,t,o,i){const n=e.querySelector(`.${z.ROOT}`),r=n?.querySelector(".tbw-grid-content");if(!n||!r)return Jt(e,t,o,i);r.remove();const s=Wt(t);if(n.replaceChildren(),s){n.className=`${z.ROOT} has-shell`;const{headerOptions:e,bodyOptions:s}=Qt(t,o,i),l=qt(e),a=$t(s),c=a.querySelector(".tbw-grid-content");c&&c.replaceWith(r),n.appendChild(l),n.appendChild(a)}else n.className=z.ROOT,n.appendChild(r);return s})(this.#j,this.#m?.shell,{isPanelOpen:this.#_e.isPanelOpen,expandedSections:this.#_e.expandedSections},this.#m?.icons)&&(this.#xt(),this.#Re.setInitialized(!0)),this.#Tt()}))}#Tt(){const e=this.#j.querySelector(".tbw-grid-content")??this.#j.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.#Re.isInitialized){jt(this.#j,this.#_e),Gt(this.#j,this.#m?.shell,this.#_e);const e=this.#m?.shell?.toolPanel,t=e?.defaultOpen;t&&this.#_e.toolPanels.has(t)&&this.#_e.expandedSections.add(t);const o=!0===e?.locked||"open"===e?.initialState||void 0===e?.initialState&&void 0!==t&&this.#_e.toolPanels.has(t);!this.#_e.isPanelOpen&&this.#_e.toolPanels.size>0&&o&&this.openToolPanel(),this.#_e.isPanelOpen&&(Kt(this.#j,this.#_e),Yt(this.#j,this.#_e,(this.#m,this.#m)),Xt(this.#j,this.#_e))}this._resizeController=Rt(this),this.#Ge(e),this.#ee.requestPhase(Ee.COLUMNS,"shellRefresh")}#tt=/* @__PURE__ */new Map;registerStyles(e,t){let o=this.#tt.get(e);o||(o=new CSSStyleSheet,this.#tt.set(e,o)),o.replaceSync(t),this.#At()}unregisterStyles(e){this.#tt.delete(e)&&this.#At()}getRegisteredStyles(){return Array.from(this.#tt.keys())}#At(){const e=Array.from(this.#tt.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#tt.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#me.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#me.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#me.containsFocus(e)}get lastFocusedElement(){return this.#me.lastFocusedElement}restoreLastFocus(){return this.#me.restoreLastFocus()}#Xe(){Bt(this,this.#_e),Vt(this,this.#_e),Ut(this,this.#_e,this.#Ye())}#Pt(){const e=this.#j.querySelector(".tbw-shell-header");if(!e)return;Zt(this.#_e);const t=function(e,t,o){const i=e?.header?.title??t.lightDomTitle??"",n=!!i;let r="";void 0!==o&&(r="string"==typeof o?K(o):o.outerHTML);const s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const b of l)a.has(b.id)||c.push(b);const d=c.length>0,h=t.toolPanels.size>0,u=!0===e?.toolPanel?.locked,g=h&&!1!==e?.header?.toolPanelToggle&&!u,f=d&&g,p=[...c].sort((e,t)=>(e.order??0)-(t.order??0));let w="";for(const b of p)w+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${b.id}"></div>`;if(f&&(w+='<div class="tbw-toolbar-separator"></div>'),g){const e=t.isPanelOpen;w+=`<button type="button" class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle data-icon="tool-panel" title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${r}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${n?`<div class="tbw-shell-title">${m=i,m&&"string"==typeof m?m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${w}\n </div>\n </div>\n `;var m}(this.#m.shell,this.#_e,this.#m.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#xt(),Gt(this.#j,this.#m?.shell,this.#_e))}#Qe(){const e=()=>{const e=this.#_e.lightDomTitle,t=this.#_e.hasToolButtonsContainer;this.#Xe();const o=this.#_e.lightDomTitle,i=this.#_e.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#K.markSourcesChanged(),this.#K.merge(),this.#Pt())},t=()=>{this.__lightDomColumnsCache=void 0,this.#ot()};this.#K.registerLightDomHandler("tbw-grid-header",e),this.#K.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#K.registerLightDomHandler("tbw-grid-tool-panel",e),this.#K.registerLightDomHandler("tbw-grid-column",t),this.#K.registerLightDomHandler("tbw-grid-detail",t),this.#K.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Ye(this),this.#K.parseLightDomColumns(this);const e=this.#_e.lightDomTitle,t=this.#_e.hasToolButtonsContainer;this.#Xe();const o=this.#_e.lightDomTitle,i=this.#_e.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#K.markSourcesChanged(),this.#K.merge(),this.#Pt()),this.#ee.requestPhase(Ee.COLUMNS,"refreshColumns")}#at(){this.#we.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#we.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#we.invalidateRowHeight(e,t)}#Ke(){this.#Xe(),this.#K.markSourcesChanged(),this.#K.merge();const e=this.#m?.shell;Jt(this.#j,e,{isPanelOpen:this.#_e.isPanelOpen,expandedSections:this.#_e.expandedSections},this.#m?.icons)&&(this.#xt(),this.#Re.setInitialized(!0))}#xt(){!function(e,t,o,i){const n=e.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.onPanelToggle()});const r=e.querySelector(".tbw-accordion");r&&r.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#j,this.#m,this.#_e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#Se?.(),this.#Se=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),n=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return n.addEventListener("mousedown",g),()=>{n.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#j,this.#m?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#Ee?.(),this.#Ee=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===t.toolPanel.mode)return()=>{};const n=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",n),()=>e.removeEventListener("mousedown",n)}(this,this.#m?.shell,this.#_e,()=>this.closeToolPanel())}}!function(){const e=Co.tagName,t=customElements.get(e);if(!t)return customElements.define(e,Co),void(Co.activeTag=e);if(t.version===Co.version)return void(Co.activeTag=e);const o=`${e}-v${Co.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(o)||customElements.define(o,Co),Co.activeTag=o}(),globalThis.DataGridElement||(globalThis.DataGridElement=Co);const yo=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"];function _o(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t}function Ro(e,t,o){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!o),n?customElements.whenDefined(Co.tagName).then(()=>i.querySelector(e)):i.querySelector(e)}const So={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change",TBW_SCROLL:"tbw-scroll"},Eo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",TREE_LOAD_START:"tree-load-start",TREE_LOAD_END:"tree-load-end",TREE_LOAD_ERROR:"tree-load-error",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"};function xo(e,t,o){return o?.valueAccessor?re(e,o):e?.[t]}function To(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const Ao={sum:(e,t,o)=>{let i=0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||(i+=s)}return i},avg:(e,t,o)=>{if(!e.length)return 0;let i=0,n=0;for(let r=0;r<e.length;r++){const s=xo(e[r],t,o);if(To(s))continue;const l=Number(s);isNaN(l)||(i+=l,n++)}return n>0?i/n:0},count:e=>e.length,min:(e,t,o)=>{if(!e.length)return 0;let i=1/0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,o)=>{if(!e.length)return 0;let i=-1/0;for(let n=0;n<e.length;n++){const r=xo(e[n],t,o);if(To(r))continue;const s=Number(r);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,o)=>e[0]?xo(e[0],t,o):void 0,last:(e,t,o)=>e.length?xo(e[e.length-1],t,o):void 0},Po=/* @__PURE__ */new Map,Ho={register(e,t){Po.set(e,t)},unregister(e){Po.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Po.get(e)??Ao[e]},run(e,t,o,i){const n=this.get(e);return n?n(t,o,i):void 0},has:e=>Po.has(e)||e in Ao,list:()=>[...Object.keys(Ao),...Po.keys()]},Mo={sum:e=>{let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]<t&&(t=e[o]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]>t&&(t=e[o]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function ko(e){return Mo[e]??Mo.sum}function Lo(e,t){return ko(e)(t)}export{ie as BaseGridPlugin,w as C,yo as CORE_CONSUMED_ADAPTER_METHODS,_ as D,t as DEFAULT_A11Y_MESSAGES,o as DEFAULT_ANIMATION_CONFIG,i as DEFAULT_GRID_ICONS,So as DGEvents,Co as DataGridElement,h as E,Fe as F,e as FitModeEnum,$ as GridCSSVars,z as GridClasses,N as GridDataAttrs,Co as GridElement,q as GridSelectors,m as M,it as MAX_ELEMENT_HEIGHT_PX,v as N,p as P,Eo as PluginEvents,vo as PluginManager,Ee as RenderPhase,b as T,n as a,Ho as aggregatorRegistry,at as b,ae as builtInSort,lt as c,nt as computeScrollMapping,_o as createGrid,T as d,le as defaultComparator,ht as e,Le as f,st as fromVirtualScrollTop,r as g,ko as getValueAggregator,C as h,y as i,se as invalidateAccessorCache,_t as j,Q as k,Ie as l,u as m,g as n,H as o,f as p,Oe as q,Ro as queryGrid,Ne as r,re as resolveCellValue,Lo as runValueAggregator,K as s,mt as setFeatureResolver,oe as t,rt as toVirtualScrollTop,De as u,P as v,A as w,S as x,R as y,E as z};//# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{setFeatureResolver as o}from"@toolbox-web/grid";function t(o,t,e,n){console.warn(function(o,t){return`[tbw-grid] ${o}: ${t}\n\n → More info: ${function(o){return`https://toolboxjs.com/grid/errors#${o.toLowerCase()}`}(o)}`}(o,t))}const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Set,r=()=>"undefined"!=typeof window&&("localhost"===window.location?.hostname||"127.0.0.1"===window.location?.hostname);function i(o,n,i){r()&&e.has(o)&&!i?.override&&t("TBW030",`Feature "${o}" was re-registered. Previous registration overwritten.`),e.set(o,{factory:n,name:o})}function s(o){return e.has(o)}function c(o){return e.get(o)?.factory}function f(){return Array.from(e.keys())}const u={undoRedo:["editing"],clipboard:["selection"]};function a(o,i){const s=e.get(o);if(s)return s.factory(i);if(r()&&!n.has(o)){n.add(o);const e=o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();t("TBW031",`Feature "${o}" is configured but not registered.\nAdd this import to enable it:\n\n import '@toolbox-web/grid/features/${e}';\n`)}}function d(o){const e=[],n=[];for(const[t,r]of Object.entries(o))void 0!==r&&!1!==r&&n.push(t);!function(o){const e=new Set(o);for(const n of o){const o=u[n];if(o)for(const i of o)e.has(i)||r()&&t("TBW032",`Feature "${n}" requires "${i}" to be enabled. Add "${i}" to your features configuration.`)}}(n);const i=["selection","editing",...n.filter(o=>"selection"!==o&&"editing"!==o)],s=[...new Set(i)].filter(o=>n.includes(o));for(const t of s){const n=o[t];if(void 0===n||!1===n)continue;const r=a(t,n);r&&e.push(r)}return e}function l(){e.clear(),n.clear()}o(d);export{l as clearFeatureRegistry,a as createPluginFromFeature,d as createPluginsFromFeatures,c as getFeatureFactory,f as getRegisteredFeatures,s as isFeatureRegistered,i as registerFeature};
1
+ import{setFeatureResolver as o}from"@toolbox-web/grid";function e(o,e,t,n){console.warn(function(o,e){return`[tbw-grid] ${o}: ${e}\n\n → More info: ${function(o){return`https://toolboxjs.com/grid/errors#${o.toLowerCase()}`}(o)}`}(o,e))}const t="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev",n=/* @__PURE__ */Symbol.for(`@toolbox-web/grid:feature-registry@${t}/v1`),r=/* @__PURE__ */Symbol.for(`@toolbox-web/grid:feature-registry-warned@${t}/v1`);function i(o,e){let t=Reflect.get(globalThis,o);return void 0===t&&(t=e(),Reflect.set(globalThis,o,t)),t}const s=i(n,()=>/* @__PURE__ */new Map),c=i(r,()=>/* @__PURE__ */new Set),f=()=>"undefined"!=typeof window&&("localhost"===window.location?.hostname||"127.0.0.1"===window.location?.hostname);function u(o,t,n){f()&&s.has(o)&&!n?.override&&e("TBW030",`Feature "${o}" was re-registered. Previous registration overwritten.`),s.set(o,{factory:t,name:o})}function a(o){return s.has(o)}function d(o){return s.get(o)?.factory}function l(){return Array.from(s.keys())}const g={undoRedo:["editing"],clipboard:["selection"]};function w(o,t){const n=s.get(o);if(n)return n.factory(t);if(f()&&!c.has(o)){c.add(o);const t=o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();e("TBW031",`Feature "${o}" is configured but not registered.\nAdd this import to enable it:\n\n import '@toolbox-web/grid/features/${t}';\n`)}}function b(o){const t=[],n=[];for(const[e,s]of Object.entries(o))void 0!==s&&!1!==s&&n.push(e);!function(o){const t=new Set(o);for(const n of o){const o=g[n];if(o)for(const r of o)t.has(r)||f()&&e("TBW032",`Feature "${n}" requires "${r}" to be enabled. Add "${r}" to your features configuration.`)}}(n);const r=["selection","editing",...n.filter(o=>"selection"!==o&&"editing"!==o)],i=[...new Set(r)].filter(o=>n.includes(o));for(const e of i){const n=o[e];if(void 0===n||!1===n)continue;const r=w(e,n);r&&t.push(r)}return t}function $(){s.clear(),c.clear()}o(b);export{$ as clearFeatureRegistry,w as createPluginFromFeature,b as createPluginsFromFeatures,d as getFeatureFactory,l as getRegisteredFeatures,a as isFeatureRegistered,u as registerFeature};
2
2
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sources":["../../../../../libs/grid/src/lib/core/internal/diagnostics.ts","../../../../../libs/grid/src/lib/features/registry.ts"],"sourcesContent":["/**\n * Centralized diagnostic messages for @toolbox-web/grid.\n *\n * Every user-facing warning, error, or info message in the grid has a unique\n * diagnostic code (e.g. `TBW001`). Each code maps to a section on the online\n * troubleshooting page, giving developers a direct link to resolution steps.\n *\n * ## Usage\n *\n * ```ts\n * import { MISSING_BREAKPOINT, warnDiagnostic, throwDiagnostic } from './diagnostics';\n *\n * // Warn with a code\n * warnDiagnostic(MISSING_BREAKPOINT, 'Set a breakpoint...', gridId);\n *\n * // Throw with a code\n * throwDiagnostic(MISSING_ROW_ID, 'Configure getRowId...', gridId);\n * ```\n *\n * Plugins should prefer `this.warn(MISSING_BREAKPOINT, message)` via BaseGridPlugin\n * instead of importing this module directly.\n *\n * @internal\n */\n\n// #region Grid Prefix\n\n/**\n * Build the `[tbw-grid]` or `[tbw-grid#my-id]` log prefix.\n * Pass `pluginName` for a scoped prefix like `[tbw-grid:SelectionPlugin]`.\n */\nexport function gridPrefix(gridId?: string, pluginName?: string): string {\n const id = gridId ? `#${gridId}` : '';\n const plugin = pluginName ? `:${pluginName}` : '';\n return `[tbw-grid${id}${plugin}]`;\n}\n\n// #endregion\n\n// #region Diagnostic Codes\n\n/**\n * Diagnostic codes used across the grid library.\n *\n * Each code is an individual export so that unused codes are tree-shaken\n * from bundles that don't reference them (esbuild can't tree-shake\n * properties from a single object).\n *\n * Naming: TBW + 3-digit number.\n * Ranges:\n * 001–019 Configuration validation (missing plugins, bad config)\n * 020–029 Plugin lifecycle (dependencies, incompatibilities, deprecation)\n * 030–039 Feature registry\n * 040–049 Row operations (row ID, row mutations)\n * 050–059 Column operations (width, template)\n * 060–069 Rendering (callbacks, formatters, external views)\n * 070–079 Shell (tool panels, header/toolbar content)\n * 080–089 Editing & editors\n * 090–099 Print\n * 100–109 Clipboard\n * 110–119 Plugin-specific (responsive, undo-redo, grouping-columns)\n * 120–129 Style injection\n * 130–139 Attribute parsing\n */\n\n// --- Config validation (001–019) ---\n/** Column uses a plugin-owned property but the plugin is not loaded. */\nexport const MISSING_PLUGIN = 'TBW001' as const;\n/** Grid config uses a plugin-owned property but the plugin is not loaded. */\nexport const MISSING_PLUGIN_CONFIG = 'TBW002' as const;\n/** Plugin config rule violation (error severity). */\nexport const CONFIG_RULE_ERROR = 'TBW003' as const;\n/** Plugin config rule violation (warning severity). */\nexport const CONFIG_RULE_WARN = 'TBW004' as const;\n\n// --- Plugin lifecycle (020–029) ---\n/** Required plugin dependency is missing. */\nexport const MISSING_DEPENDENCY = 'TBW020' as const;\n/** Optional plugin dependency is missing. */\nexport const OPTIONAL_DEPENDENCY = 'TBW021' as const;\n/** Two loaded plugins are incompatible. */\nexport const INCOMPATIBLE_PLUGINS = 'TBW022' as const;\n/** Two plugin instances resolve to the same canonical name (alias collapse). */\nexport const PLUGIN_ALIAS_COLLAPSE = 'TBW023' as const;\n/** Error thrown inside a plugin event handler. */\nexport const PLUGIN_EVENT_ERROR = 'TBW024' as const;\n/** Conflicting config values found while merging alias-collapsed plugin instances. */\nexport const PLUGIN_ALIAS_CONFIG_CONFLICT = 'TBW025' as const;\n\n// --- Feature registry (030–039) ---\n/** Feature was re-registered (overwritten). */\nexport const FEATURE_REREGISTERED = 'TBW030' as const;\n/** Feature configured but not imported. */\nexport const FEATURE_NOT_IMPORTED = 'TBW031' as const;\n/** Feature depends on another feature that is not enabled. */\nexport const FEATURE_MISSING_DEP = 'TBW032' as const;\n\n// --- Row operations (040–049) ---\n/** Cannot determine row ID (no getRowId and no id property). */\nexport const MISSING_ROW_ID = 'TBW040' as const;\n/** Row with given ID not found. */\nexport const ROW_NOT_FOUND = 'TBW041' as const;\n\n// --- Column operations (050–059) ---\n/** Column has an invalid CSS width value. */\nexport const INVALID_COLUMN_WIDTH = 'TBW050' as const;\n\n// --- Rendering callbacks (060–069) ---\n/** rowClass callback threw an error. */\nexport const ROW_CLASS_ERROR = 'TBW060' as const;\n/** cellClass callback threw an error. */\nexport const CELL_CLASS_ERROR = 'TBW061' as const;\n/** Column format function threw an error. */\nexport const FORMAT_ERROR = 'TBW062' as const;\n/** External view mount() threw an error. */\nexport const VIEW_MOUNT_ERROR = 'TBW063' as const;\n/** External view event dispatch error. */\nexport const VIEW_DISPATCH_ERROR = 'TBW064' as const;\n\n// --- Shell (070–079) ---\n/** Tool panel missing required id or title. */\nexport const TOOL_PANEL_MISSING_ATTR = 'TBW070' as const;\n/** No tool panels registered. */\nexport const NO_TOOL_PANELS = 'TBW071' as const;\n/** Tool panel section not found. */\nexport const TOOL_PANEL_NOT_FOUND = 'TBW072' as const;\n/** Tool panel already registered. */\nexport const TOOL_PANEL_DUPLICATE = 'TBW073' as const;\n/** Header content already registered. */\nexport const HEADER_CONTENT_DUPLICATE = 'TBW074' as const;\n/** Toolbar content already registered. */\nexport const TOOLBAR_CONTENT_DUPLICATE = 'TBW075' as const;\n\n// --- Editing & editors (080–089) ---\n/** External editor mount() threw an error. */\nexport const EDITOR_MOUNT_ERROR = 'TBW080' as const;\n\n// --- Print (090–099) ---\n/** Print already in progress. */\nexport const PRINT_IN_PROGRESS = 'TBW090' as const;\n/** Grid not available for printing. */\nexport const PRINT_NO_GRID = 'TBW091' as const;\n/** Print operation failed. */\nexport const PRINT_FAILED = 'TBW092' as const;\n/** Multiple elements share the same grid ID (print isolation issue). */\nexport const PRINT_DUPLICATE_ID = 'TBW093' as const;\n\n// --- Clipboard (100–109) ---\n/** Clipboard API write failed. */\nexport const CLIPBOARD_FAILED = 'TBW100' as const;\n\n// --- Plugin-specific (110–119) ---\n/** ResponsivePlugin: no breakpoint configured. */\nexport const MISSING_BREAKPOINT = 'TBW110' as const;\n/** UndoRedoPlugin: transaction already in progress. */\nexport const TRANSACTION_IN_PROGRESS = 'TBW111' as const;\n/** UndoRedoPlugin: no transaction in progress. */\nexport const NO_TRANSACTION = 'TBW112' as const;\n/** GroupingColumnsPlugin: missing id or header on column group definition. */\nexport const COLUMN_GROUP_NO_ID = 'TBW113' as const;\n/** GroupingColumnsPlugin: conflicting columnGroups sources. */\nexport const COLUMN_GROUPS_CONFLICT = 'TBW114' as const;\n\n// --- Style injection (120–129) ---\n/** Failed to extract grid.css from document stylesheets. */\nexport const STYLE_EXTRACT_FAILED = 'TBW120' as const;\n/** Could not find grid.css in document.styleSheets. */\nexport const STYLE_NOT_FOUND = 'TBW121' as const;\n\n// --- Attribute parsing (130–139) ---\n/** Invalid JSON in an HTML attribute. */\nexport const INVALID_ATTRIBUTE_JSON = 'TBW130' as const;\n\n// --- DataSource / ServerSide (140–149) ---\n/** ServerSidePlugin: getRows() rejected. */\nexport const DATASOURCE_FETCH_ERROR = 'TBW140' as const;\n/** ServerSidePlugin: getChildRows() rejected. */\nexport const DATASOURCE_CHILD_FETCH_ERROR = 'TBW141' as const;\n/** ServerSidePlugin: getChildRows() not implemented but a plugin queried for children. */\nexport const DATASOURCE_NO_CHILD_HANDLER = 'TBW142' as const;\n/** ServerSidePlugin: concurrent request limit reached, request deferred. */\nexport const DATASOURCE_THROTTLED = 'TBW143' as const;\n\nexport type DiagnosticCode =\n | typeof MISSING_PLUGIN\n | typeof MISSING_PLUGIN_CONFIG\n | typeof CONFIG_RULE_ERROR\n | typeof CONFIG_RULE_WARN\n | typeof MISSING_DEPENDENCY\n | typeof OPTIONAL_DEPENDENCY\n | typeof INCOMPATIBLE_PLUGINS\n | typeof PLUGIN_ALIAS_COLLAPSE\n | typeof PLUGIN_EVENT_ERROR\n | typeof PLUGIN_ALIAS_CONFIG_CONFLICT\n | typeof FEATURE_REREGISTERED\n | typeof FEATURE_NOT_IMPORTED\n | typeof FEATURE_MISSING_DEP\n | typeof MISSING_ROW_ID\n | typeof ROW_NOT_FOUND\n | typeof INVALID_COLUMN_WIDTH\n | typeof ROW_CLASS_ERROR\n | typeof CELL_CLASS_ERROR\n | typeof FORMAT_ERROR\n | typeof VIEW_MOUNT_ERROR\n | typeof VIEW_DISPATCH_ERROR\n | typeof TOOL_PANEL_MISSING_ATTR\n | typeof NO_TOOL_PANELS\n | typeof TOOL_PANEL_NOT_FOUND\n | typeof TOOL_PANEL_DUPLICATE\n | typeof HEADER_CONTENT_DUPLICATE\n | typeof TOOLBAR_CONTENT_DUPLICATE\n | typeof EDITOR_MOUNT_ERROR\n | typeof PRINT_IN_PROGRESS\n | typeof PRINT_NO_GRID\n | typeof PRINT_FAILED\n | typeof PRINT_DUPLICATE_ID\n | typeof CLIPBOARD_FAILED\n | typeof MISSING_BREAKPOINT\n | typeof TRANSACTION_IN_PROGRESS\n | typeof NO_TRANSACTION\n | typeof COLUMN_GROUP_NO_ID\n | typeof COLUMN_GROUPS_CONFLICT\n | typeof STYLE_EXTRACT_FAILED\n | typeof STYLE_NOT_FOUND\n | typeof INVALID_ATTRIBUTE_JSON\n | typeof DATASOURCE_FETCH_ERROR\n | typeof DATASOURCE_CHILD_FETCH_ERROR\n | typeof DATASOURCE_NO_CHILD_HANDLER\n | typeof DATASOURCE_THROTTLED;\n\n// #endregion\n\n// #region Docs URL\n\nconst DOCS_BASE = 'https://toolboxjs.com/grid/errors';\n\n/** Build a direct link to the troubleshooting section for a code. */\nfunction docsUrl(code: DiagnosticCode): string {\n return `${DOCS_BASE}#${code.toLowerCase()}`;\n}\n\n// #endregion\n\n// #region Formatting\n\n/**\n * Format a diagnostic message with prefix, code, and docs link.\n *\n * Output format:\n * ```\n * [tbw-grid#my-id] TBW001: Your message here.\n *\n * → More info: https://toolboxjs.com/grid/errors#tbw001\n * ```\n */\nexport function formatDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): string {\n const prefix = gridPrefix(gridId, pluginName);\n return `${prefix} ${code}: ${message}\\n\\n → More info: ${docsUrl(code)}`;\n}\n\n// #endregion\n\n// #region Public API\n\n/**\n * Throw an error with a diagnostic code and docs link.\n * Use for configuration errors and API misuse that should halt execution.\n */\nexport function throwDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): never {\n throw new Error(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log a warning with a diagnostic code and docs link.\n * Use for recoverable issues the developer should fix.\n */\nexport function warnDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.warn(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log a debug message with a diagnostic code and docs link.\n * Use for optional/soft dependency notifications — visible only when\n * the browser DevTools \"Verbose\" log level is enabled.\n */\nexport function debugDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.debug(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log an error with a diagnostic code and docs link.\n * Use for non-throwing errors (e.g., failed async operations).\n */\nexport function errorDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.error(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n// #endregion\n","/**\n * Core Feature Registry for @toolbox-web/grid\n *\n * This module provides a framework-agnostic registry for plugin factories.\n * Features are registered via side-effect imports, enabling tree-shaking\n * while maintaining a clean declarative API.\n *\n * @example\n * ```typescript\n * // Import features you need (side-effect imports)\n * import '@toolbox-web/grid/features/selection';\n * import '@toolbox-web/grid/features/filtering';\n *\n * // Configure grid declaratively\n * grid.gridConfig = {\n * features: {\n * selection: 'range',\n * filtering: { debounceMs: 200 },\n * },\n * };\n * ```\n *\n * @packageDocumentation\n * @module Features\n */\n\nimport {\n FEATURE_MISSING_DEP,\n FEATURE_NOT_IMPORTED,\n FEATURE_REREGISTERED,\n warnDiagnostic,\n} from '../core/internal/diagnostics';\nimport { setFeatureResolver } from '../core/internal/feature-hook';\nimport type { FeatureConfig, GridPlugin } from '../core/types';\n\n// #region Types\n\n/** Feature name — keys of the augmented FeatureConfig interface. */\nexport type FeatureName = keyof FeatureConfig;\n\n/** Factory function that creates a plugin from a feature config value. */\nexport type PluginFactory<TConfig = unknown> = (config: TConfig) => GridPlugin;\n\ninterface RegistryEntry {\n factory: PluginFactory;\n name: string;\n}\n\n// #endregion\n\n// #region Registry State\n\nconst featureRegistry = new Map<string, RegistryEntry>();\nconst warnedFeatures = new Set<string>();\n\n// #endregion\n\n// #region Registration API\n\n/** Runtime dev-mode check (localhost or 127.0.0.1). */\nconst isDev = (): boolean =>\n typeof window !== 'undefined' &&\n (window.location?.hostname === 'localhost' || window.location?.hostname === '127.0.0.1');\n\n/** Optional flags passed to {@link registerFeature}. */\nexport interface RegisterFeatureOptions {\n /**\n * Set to `true` when the registration is intentionally overwriting an\n * existing entry (e.g. a framework adapter wrapping the vanilla factory\n * with reactive bridging). Suppresses the TBW030 dev-mode warning.\n */\n override?: boolean;\n}\n\n/**\n * Register a feature's plugin factory.\n * Called by side-effect feature imports (e.g., `import '@toolbox-web/grid/features/selection'`).\n *\n * @param name - The feature name (matches a key on FeatureConfig)\n * @param factory - Function that creates a plugin instance from config\n * @param options - Pass `{ override: true }` for intentional re-registration\n * (framework adapters bridging the vanilla factory) to suppress TBW030.\n */\nexport function registerFeature<K extends FeatureName>(\n name: K,\n factory: PluginFactory<FeatureConfig[K]>,\n options?: RegisterFeatureOptions,\n): void;\nexport function registerFeature(name: string, factory: PluginFactory, options?: RegisterFeatureOptions): void;\nexport function registerFeature(name: string, factory: PluginFactory, options?: RegisterFeatureOptions): void {\n if (isDev() && featureRegistry.has(name) && !options?.override) {\n warnDiagnostic(FEATURE_REREGISTERED, `Feature \"${name}\" was re-registered. Previous registration overwritten.`);\n }\n featureRegistry.set(name, { factory, name });\n}\n\n/**\n * Check if a feature has been registered.\n */\nexport function isFeatureRegistered(name: string): boolean {\n return featureRegistry.has(name);\n}\n\n/**\n * Get a registered feature's factory. Returns undefined if not registered.\n */\nexport function getFeatureFactory(name: string): PluginFactory | undefined {\n return featureRegistry.get(name)?.factory;\n}\n\n/**\n * Get all registered feature names.\n */\nexport function getRegisteredFeatures(): string[] {\n return Array.from(featureRegistry.keys());\n}\n\n// #endregion\n\n// #region Plugin Creation\n\n/**\n * Plugin dependency declarations.\n * Some plugins require others to be loaded first.\n */\nconst PLUGIN_DEPENDENCIES: Record<string, string[]> = {\n undoRedo: ['editing'],\n clipboard: ['selection'],\n};\n\n/**\n * Create a plugin instance for a single feature.\n * Shows a warning if the feature is not registered.\n */\nexport function createPluginFromFeature(name: string, config: unknown): GridPlugin | undefined {\n const entry = featureRegistry.get(name);\n\n if (!entry) {\n if (isDev() && !warnedFeatures.has(name)) {\n warnedFeatures.add(name);\n const kebab = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n warnDiagnostic(\n FEATURE_NOT_IMPORTED,\n `Feature \"${name}\" is configured but not registered.\\n` +\n `Add this import to enable it:\\n\\n` +\n ` import '@toolbox-web/grid/features/${kebab}';\\n`,\n );\n }\n return undefined;\n }\n\n return entry.factory(config);\n}\n\n/**\n * Validate feature dependencies and log warnings for missing ones.\n */\nfunction validateDependencies(featureNames: string[]): void {\n const featureSet = new Set(featureNames);\n\n for (const feature of featureNames) {\n const deps = PLUGIN_DEPENDENCIES[feature];\n if (!deps) continue;\n\n for (const dep of deps) {\n if (!featureSet.has(dep)) {\n if (isDev()) {\n warnDiagnostic(\n FEATURE_MISSING_DEP,\n `Feature \"${feature}\" requires \"${dep}\" to be enabled. ` + `Add \"${dep}\" to your features configuration.`,\n );\n }\n }\n }\n }\n}\n\n/**\n * Create plugin instances from a features configuration object.\n *\n * Handles:\n * - Dependency validation (clipboard needs selection)\n * - Dependency ordering (selection before clipboard)\n * - Skipping false/undefined values\n *\n * @param features - Partial FeatureConfig object\n * @returns Array of plugin instances ready for gridConfig.plugins\n */\nexport function createPluginsFromFeatures(features: Record<string, unknown>): GridPlugin[] {\n const plugins: GridPlugin[] = [];\n const enabledFeatures: string[] = [];\n\n // Collect enabled feature names\n for (const [key, value] of Object.entries(features)) {\n if (value === undefined || value === false) continue;\n enabledFeatures.push(key);\n }\n\n // Validate dependencies\n validateDependencies(enabledFeatures);\n\n // Create plugins in dependency order: dep-targets first, then the rest\n const dependencyOrder: string[] = [\n 'selection',\n 'editing',\n ...enabledFeatures.filter((f) => f !== 'selection' && f !== 'editing'),\n ];\n const orderedFeatures = [...new Set(dependencyOrder)].filter((f) => enabledFeatures.includes(f));\n\n for (const featureName of orderedFeatures) {\n const config = features[featureName];\n if (config === undefined || config === false) continue;\n\n const plugin = createPluginFromFeature(featureName, config);\n if (plugin) {\n plugins.push(plugin);\n }\n }\n\n return plugins;\n}\n\n// #endregion\n\n// #region Auto-Registration\n\n// Wire feature resolver into grid core so `gridConfig.features` is handled automatically.\n// This runs when any feature module is imported (they all import this registry).\nsetFeatureResolver(createPluginsFromFeatures as (features: Record<string, unknown>) => GridPlugin[]);\n\n// #endregion\n\n// #region Testing Utilities\n\n/**\n * Clear the registry. For testing only.\n * @internal\n */\nexport function clearFeatureRegistry(): void {\n featureRegistry.clear();\n warnedFeatures.clear();\n}\n\n// #endregion\n"],"names":["warnDiagnostic","code","message","gridId","pluginName","console","warn","toLowerCase","docsUrl","formatDiagnostic","featureRegistry","Map","warnedFeatures","Set","isDev","window","location","hostname","registerFeature","name","factory","options","has","override","set","isFeatureRegistered","getFeatureFactory","get","getRegisteredFeatures","Array","from","keys","PLUGIN_DEPENDENCIES","undoRedo","clipboard","createPluginFromFeature","config","entry","add","kebab","replace","createPluginsFromFeatures","features","plugins","enabledFeatures","key","value","Object","entries","push","featureNames","featureSet","feature","deps","dep","validateDependencies","dependencyOrder","filter","f","orderedFeatures","includes","featureName","plugin","clearFeatureRegistry","clear","setFeatureResolver"],"mappings":"uDAoRO,SAASA,EAAeC,EAAsBC,EAAiBC,EAAiBC,GACrFC,QAAQC,KAtBH,SAA0BL,EAAsBC,GAErD,MAAO,cAAaD,MAASC,uBApB/B,SAAiBD,GACf,MAAO,qCAAgBA,EAAKM,eAC9B,CAkB4DC,CAAQP,IACpE,CAmBeQ,CAAiBR,EAAMC,GACtC,CClOA,MAAMQ,qBAAsBC,IACtBC,qBAAqBC,IAOrBC,EAAQ,IACM,oBAAXC,SACwB,cAA9BA,OAAOC,UAAUC,UAA0D,cAA9BF,OAAOC,UAAUC,UA2B1D,SAASC,EAAgBC,EAAcC,EAAwBC,GAChEP,KAAWJ,EAAgBY,IAAIH,KAAUE,GAASE,UACpDvB,EDAgC,SCAK,YAAYmB,4DAEnDT,EAAgBc,IAAIL,EAAM,CAAEC,UAASD,QACvC,CAKO,SAASM,EAAoBN,GAClC,OAAOT,EAAgBY,IAAIH,EAC7B,CAKO,SAASO,EAAkBP,GAChC,OAAOT,EAAgBiB,IAAIR,IAAOC,OACpC,CAKO,SAASQ,IACd,OAAOC,MAAMC,KAAKpB,EAAgBqB,OACpC,CAUA,MAAMC,EAAgD,CACpDC,SAAU,CAAC,WACXC,UAAW,CAAC,cAOP,SAASC,EAAwBhB,EAAciB,GACpD,MAAMC,EAAQ3B,EAAgBiB,IAAIR,GAElC,GAAKkB,EAcL,OAAOA,EAAMjB,QAAQgB,GAbnB,GAAItB,MAAYF,EAAeU,IAAIH,GAAO,CACxCP,EAAe0B,IAAInB,GACnB,MAAMoB,EAAQpB,EAAKqB,QAAQ,kBAAmB,SAASjC,cACvDP,EDhD8B,SCkD5B,YAAYmB,+GAE8BoB,QAE9C,CAKJ,CAoCO,SAASE,EAA0BC,GACxC,MAAMC,EAAwB,GACxBC,EAA4B,GAGlC,IAAA,MAAYC,EAAKC,KAAUC,OAAOC,QAAQN,QAC1B,IAAVI,IAAiC,IAAVA,GAC3BF,EAAgBK,KAAKJ,IAtCzB,SAA8BK,GAC5B,MAAMC,EAAa,IAAItC,IAAIqC,GAE3B,IAAA,MAAWE,KAAWF,EAAc,CAClC,MAAMG,EAAOrB,EAAoBoB,GACjC,GAAKC,EAEL,IAAA,MAAWC,KAAOD,EACXF,EAAW7B,IAAIgC,IACdxC,KACFd,EDxEyB,SC0EvB,YAAYoD,gBAAsBE,0BAAiCA,qCAK7E,CACF,CAwBEC,CAAqBX,GAGrB,MAAMY,EAA4B,CAChC,YACA,aACGZ,EAAgBa,OAAQC,GAAY,cAANA,GAA2B,YAANA,IAElDC,EAAkB,IAAI,IAAI9C,IAAI2C,IAAkBC,OAAQC,GAAMd,EAAgBgB,SAASF,IAE7F,IAAA,MAAWG,KAAeF,EAAiB,CACzC,MAAMvB,EAASM,EAASmB,GACxB,QAAe,IAAXzB,IAAmC,IAAXA,EAAkB,SAE9C,MAAM0B,EAAS3B,EAAwB0B,EAAazB,GAChD0B,GACFnB,EAAQM,KAAKa,EAEjB,CAEA,OAAOnB,CACT,CAkBO,SAASoB,IACdrD,EAAgBsD,QAChBpD,EAAeoD,OACjB,CAbAC,EAAmBxB"}
1
+ {"version":3,"file":"registry.js","sources":["../../../../../libs/grid/src/lib/core/internal/diagnostics.ts","../../../../../libs/grid/src/lib/features/registry.ts"],"sourcesContent":["/**\n * Centralized diagnostic messages for @toolbox-web/grid.\n *\n * Every user-facing warning, error, or info message in the grid has a unique\n * diagnostic code (e.g. `TBW001`). Each code maps to a section on the online\n * troubleshooting page, giving developers a direct link to resolution steps.\n *\n * ## Usage\n *\n * ```ts\n * import { MISSING_BREAKPOINT, warnDiagnostic, throwDiagnostic } from './diagnostics';\n *\n * // Warn with a code\n * warnDiagnostic(MISSING_BREAKPOINT, 'Set a breakpoint...', gridId);\n *\n * // Throw with a code\n * throwDiagnostic(MISSING_ROW_ID, 'Configure getRowId...', gridId);\n * ```\n *\n * Plugins should prefer `this.warn(MISSING_BREAKPOINT, message)` via BaseGridPlugin\n * instead of importing this module directly.\n *\n * @internal\n */\n\n// #region Grid Prefix\n\n/**\n * Build the `[tbw-grid]` or `[tbw-grid#my-id]` log prefix.\n * Pass `pluginName` for a scoped prefix like `[tbw-grid:SelectionPlugin]`.\n */\nexport function gridPrefix(gridId?: string, pluginName?: string): string {\n const id = gridId ? `#${gridId}` : '';\n const plugin = pluginName ? `:${pluginName}` : '';\n return `[tbw-grid${id}${plugin}]`;\n}\n\n// #endregion\n\n// #region Diagnostic Codes\n\n/**\n * Diagnostic codes used across the grid library.\n *\n * Each code is an individual export so that unused codes are tree-shaken\n * from bundles that don't reference them (esbuild can't tree-shake\n * properties from a single object).\n *\n * Naming: TBW + 3-digit number.\n * Ranges:\n * 001–019 Configuration validation (missing plugins, bad config)\n * 020–029 Plugin lifecycle (dependencies, incompatibilities, deprecation)\n * 030–039 Feature registry\n * 040–049 Row operations (row ID, row mutations)\n * 050–059 Column operations (width, template)\n * 060–069 Rendering (callbacks, formatters, external views)\n * 070–079 Shell (tool panels, header/toolbar content)\n * 080–089 Editing & editors\n * 090–099 Print\n * 100–109 Clipboard\n * 110–119 Plugin-specific (responsive, undo-redo, grouping-columns)\n * 120–129 Style injection\n * 130–139 Attribute parsing\n */\n\n// --- Config validation (001–019) ---\n/** Column uses a plugin-owned property but the plugin is not loaded. */\nexport const MISSING_PLUGIN = 'TBW001' as const;\n/** Grid config uses a plugin-owned property but the plugin is not loaded. */\nexport const MISSING_PLUGIN_CONFIG = 'TBW002' as const;\n/** Plugin config rule violation (error severity). */\nexport const CONFIG_RULE_ERROR = 'TBW003' as const;\n/** Plugin config rule violation (warning severity). */\nexport const CONFIG_RULE_WARN = 'TBW004' as const;\n\n// --- Plugin lifecycle (020–029) ---\n/** Required plugin dependency is missing. */\nexport const MISSING_DEPENDENCY = 'TBW020' as const;\n/** Optional plugin dependency is missing. */\nexport const OPTIONAL_DEPENDENCY = 'TBW021' as const;\n/** Two loaded plugins are incompatible. */\nexport const INCOMPATIBLE_PLUGINS = 'TBW022' as const;\n/** Two plugin instances resolve to the same canonical name (alias collapse). */\nexport const PLUGIN_ALIAS_COLLAPSE = 'TBW023' as const;\n/** Error thrown inside a plugin event handler. */\nexport const PLUGIN_EVENT_ERROR = 'TBW024' as const;\n/** Conflicting config values found while merging alias-collapsed plugin instances. */\nexport const PLUGIN_ALIAS_CONFIG_CONFLICT = 'TBW025' as const;\n\n// --- Feature registry (030–039) ---\n/** Feature was re-registered (overwritten). */\nexport const FEATURE_REREGISTERED = 'TBW030' as const;\n/** Feature configured but not imported. */\nexport const FEATURE_NOT_IMPORTED = 'TBW031' as const;\n/** Feature depends on another feature that is not enabled. */\nexport const FEATURE_MISSING_DEP = 'TBW032' as const;\n\n// --- Row operations (040–049) ---\n/** Cannot determine row ID (no getRowId and no id property). */\nexport const MISSING_ROW_ID = 'TBW040' as const;\n/** Row with given ID not found. */\nexport const ROW_NOT_FOUND = 'TBW041' as const;\n\n// --- Column operations (050–059) ---\n/** Column has an invalid CSS width value. */\nexport const INVALID_COLUMN_WIDTH = 'TBW050' as const;\n\n// --- Rendering callbacks (060–069) ---\n/** rowClass callback threw an error. */\nexport const ROW_CLASS_ERROR = 'TBW060' as const;\n/** cellClass callback threw an error. */\nexport const CELL_CLASS_ERROR = 'TBW061' as const;\n/** Column format function threw an error. */\nexport const FORMAT_ERROR = 'TBW062' as const;\n/** External view mount() threw an error. */\nexport const VIEW_MOUNT_ERROR = 'TBW063' as const;\n/** External view event dispatch error. */\nexport const VIEW_DISPATCH_ERROR = 'TBW064' as const;\n\n// --- Shell (070–079) ---\n/** Tool panel missing required id or title. */\nexport const TOOL_PANEL_MISSING_ATTR = 'TBW070' as const;\n/** No tool panels registered. */\nexport const NO_TOOL_PANELS = 'TBW071' as const;\n/** Tool panel section not found. */\nexport const TOOL_PANEL_NOT_FOUND = 'TBW072' as const;\n/** Tool panel already registered. */\nexport const TOOL_PANEL_DUPLICATE = 'TBW073' as const;\n/** Header content already registered. */\nexport const HEADER_CONTENT_DUPLICATE = 'TBW074' as const;\n/** Toolbar content already registered. */\nexport const TOOLBAR_CONTENT_DUPLICATE = 'TBW075' as const;\n\n// --- Editing & editors (080–089) ---\n/** External editor mount() threw an error. */\nexport const EDITOR_MOUNT_ERROR = 'TBW080' as const;\n\n// --- Print (090–099) ---\n/** Print already in progress. */\nexport const PRINT_IN_PROGRESS = 'TBW090' as const;\n/** Grid not available for printing. */\nexport const PRINT_NO_GRID = 'TBW091' as const;\n/** Print operation failed. */\nexport const PRINT_FAILED = 'TBW092' as const;\n/** Multiple elements share the same grid ID (print isolation issue). */\nexport const PRINT_DUPLICATE_ID = 'TBW093' as const;\n\n// --- Clipboard (100–109) ---\n/** Clipboard API write failed. */\nexport const CLIPBOARD_FAILED = 'TBW100' as const;\n\n// --- Plugin-specific (110–119) ---\n/** ResponsivePlugin: no breakpoint configured. */\nexport const MISSING_BREAKPOINT = 'TBW110' as const;\n/** UndoRedoPlugin: transaction already in progress. */\nexport const TRANSACTION_IN_PROGRESS = 'TBW111' as const;\n/** UndoRedoPlugin: no transaction in progress. */\nexport const NO_TRANSACTION = 'TBW112' as const;\n/** GroupingColumnsPlugin: missing id or header on column group definition. */\nexport const COLUMN_GROUP_NO_ID = 'TBW113' as const;\n/** GroupingColumnsPlugin: conflicting columnGroups sources. */\nexport const COLUMN_GROUPS_CONFLICT = 'TBW114' as const;\n\n// --- Style injection (120–129) ---\n/** Failed to extract grid.css from document stylesheets. */\nexport const STYLE_EXTRACT_FAILED = 'TBW120' as const;\n/** Could not find grid.css in document.styleSheets. */\nexport const STYLE_NOT_FOUND = 'TBW121' as const;\n\n// --- Attribute parsing (130–139) ---\n/** Invalid JSON in an HTML attribute. */\nexport const INVALID_ATTRIBUTE_JSON = 'TBW130' as const;\n\n// --- DataSource / ServerSide (140–149) ---\n/** ServerSidePlugin: getRows() rejected. */\nexport const DATASOURCE_FETCH_ERROR = 'TBW140' as const;\n/** ServerSidePlugin: getChildRows() rejected. */\nexport const DATASOURCE_CHILD_FETCH_ERROR = 'TBW141' as const;\n/** ServerSidePlugin: getChildRows() not implemented but a plugin queried for children. */\nexport const DATASOURCE_NO_CHILD_HANDLER = 'TBW142' as const;\n/** ServerSidePlugin: concurrent request limit reached, request deferred. */\nexport const DATASOURCE_THROTTLED = 'TBW143' as const;\n\nexport type DiagnosticCode =\n | typeof MISSING_PLUGIN\n | typeof MISSING_PLUGIN_CONFIG\n | typeof CONFIG_RULE_ERROR\n | typeof CONFIG_RULE_WARN\n | typeof MISSING_DEPENDENCY\n | typeof OPTIONAL_DEPENDENCY\n | typeof INCOMPATIBLE_PLUGINS\n | typeof PLUGIN_ALIAS_COLLAPSE\n | typeof PLUGIN_EVENT_ERROR\n | typeof PLUGIN_ALIAS_CONFIG_CONFLICT\n | typeof FEATURE_REREGISTERED\n | typeof FEATURE_NOT_IMPORTED\n | typeof FEATURE_MISSING_DEP\n | typeof MISSING_ROW_ID\n | typeof ROW_NOT_FOUND\n | typeof INVALID_COLUMN_WIDTH\n | typeof ROW_CLASS_ERROR\n | typeof CELL_CLASS_ERROR\n | typeof FORMAT_ERROR\n | typeof VIEW_MOUNT_ERROR\n | typeof VIEW_DISPATCH_ERROR\n | typeof TOOL_PANEL_MISSING_ATTR\n | typeof NO_TOOL_PANELS\n | typeof TOOL_PANEL_NOT_FOUND\n | typeof TOOL_PANEL_DUPLICATE\n | typeof HEADER_CONTENT_DUPLICATE\n | typeof TOOLBAR_CONTENT_DUPLICATE\n | typeof EDITOR_MOUNT_ERROR\n | typeof PRINT_IN_PROGRESS\n | typeof PRINT_NO_GRID\n | typeof PRINT_FAILED\n | typeof PRINT_DUPLICATE_ID\n | typeof CLIPBOARD_FAILED\n | typeof MISSING_BREAKPOINT\n | typeof TRANSACTION_IN_PROGRESS\n | typeof NO_TRANSACTION\n | typeof COLUMN_GROUP_NO_ID\n | typeof COLUMN_GROUPS_CONFLICT\n | typeof STYLE_EXTRACT_FAILED\n | typeof STYLE_NOT_FOUND\n | typeof INVALID_ATTRIBUTE_JSON\n | typeof DATASOURCE_FETCH_ERROR\n | typeof DATASOURCE_CHILD_FETCH_ERROR\n | typeof DATASOURCE_NO_CHILD_HANDLER\n | typeof DATASOURCE_THROTTLED;\n\n// #endregion\n\n// #region Docs URL\n\nconst DOCS_BASE = 'https://toolboxjs.com/grid/errors';\n\n/** Build a direct link to the troubleshooting section for a code. */\nfunction docsUrl(code: DiagnosticCode): string {\n return `${DOCS_BASE}#${code.toLowerCase()}`;\n}\n\n// #endregion\n\n// #region Formatting\n\n/**\n * Format a diagnostic message with prefix, code, and docs link.\n *\n * Output format:\n * ```\n * [tbw-grid#my-id] TBW001: Your message here.\n *\n * → More info: https://toolboxjs.com/grid/errors#tbw001\n * ```\n */\nexport function formatDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): string {\n const prefix = gridPrefix(gridId, pluginName);\n return `${prefix} ${code}: ${message}\\n\\n → More info: ${docsUrl(code)}`;\n}\n\n// #endregion\n\n// #region Public API\n\n/**\n * Throw an error with a diagnostic code and docs link.\n * Use for configuration errors and API misuse that should halt execution.\n */\nexport function throwDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): never {\n throw new Error(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log a warning with a diagnostic code and docs link.\n * Use for recoverable issues the developer should fix.\n */\nexport function warnDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.warn(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log a debug message with a diagnostic code and docs link.\n * Use for optional/soft dependency notifications — visible only when\n * the browser DevTools \"Verbose\" log level is enabled.\n */\nexport function debugDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.debug(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n/**\n * Log an error with a diagnostic code and docs link.\n * Use for non-throwing errors (e.g., failed async operations).\n */\nexport function errorDiagnostic(code: DiagnosticCode, message: string, gridId?: string, pluginName?: string): void {\n console.error(formatDiagnostic(code, message, gridId, pluginName));\n}\n\n// #endregion\n","/**\n * Core Feature Registry for @toolbox-web/grid\n *\n * This module provides a framework-agnostic registry for plugin factories.\n * Features are registered via side-effect imports, enabling tree-shaking\n * while maintaining a clean declarative API.\n *\n * @example\n * ```typescript\n * // Import features you need (side-effect imports)\n * import '@toolbox-web/grid/features/selection';\n * import '@toolbox-web/grid/features/filtering';\n *\n * // Configure grid declaratively\n * grid.gridConfig = {\n * features: {\n * selection: 'range',\n * filtering: { debounceMs: 200 },\n * },\n * };\n * ```\n *\n * @packageDocumentation\n * @module Features\n */\n\nimport {\n FEATURE_MISSING_DEP,\n FEATURE_NOT_IMPORTED,\n FEATURE_REREGISTERED,\n warnDiagnostic,\n} from '../core/internal/diagnostics';\nimport { setFeatureResolver } from '../core/internal/feature-hook';\nimport type { FeatureConfig, GridPlugin } from '../core/types';\n\n// #region Types\n\n/** Feature name — keys of the augmented FeatureConfig interface. */\nexport type FeatureName = keyof FeatureConfig;\n\n/** Factory function that creates a plugin from a feature config value. */\nexport type PluginFactory<TConfig = unknown> = (config: TConfig) => GridPlugin;\n\ninterface RegistryEntry {\n factory: PluginFactory;\n name: string;\n}\n\n// #endregion\n\n// #region Registry State\n\n/*\n * Cross-bundle singleton (version-scoped).\n *\n * The custom-elements registry is realm-global, but `import` graphs are not:\n * when two micro-frontend widgets on the same page bundle their own copy of\n * `@toolbox-web/grid`, each copy gets its own `featureRegistry` Map. The\n * `<tbw-grid>` class is realm-global (see `registerDataGrid()` in\n * `core/grid.ts`), so the *running* class resolves features via the resolver\n * its own bundle wired up — which closes over the *local* Map. Side-effect\n * imports from any other bundle (`import '@toolbox-web/grid/features/tree'`)\n * land in a different Map that the running class never reads, producing\n * spurious TBW031 \"feature not registered\" warnings.\n *\n * Fix: persist the Map on `globalThis` under a `Symbol.for(...)` key so every\n * loaded copy of this module reads and writes the same instance.\n *\n * The key embeds `__GRID_VERSION__` so **only same-version** bundles share a\n * registry. `registerDataGrid()` already isolates differently-versioned grid\n * classes by registering them under suffixed tag names — the version is\n * sanitized to ASCII letters/digits/dashes, so `2.14.0` becomes the tag\n * `tbw-grid-v2-14-0` (issue #339). The feature registry must mirror that\n * isolation, otherwise the last-loaded bundle's plugin factories would\n * overwrite earlier versions' entries and the running grid would attach\n * plugin instances built against a different internal contract. The trailing\n * `/v1` is a schema version for the slot shape — bump if the stored value's\n * shape changes incompatibly.\n *\n * Issue: planning #9 (two Roma widgets each bundling their own grid copy).\n */\ndeclare const __GRID_VERSION__: string;\nconst GRID_VERSION = typeof __GRID_VERSION__ !== 'undefined' ? __GRID_VERSION__ : 'dev';\nconst REGISTRY_KEY = Symbol.for(`@toolbox-web/grid:feature-registry@${GRID_VERSION}/v1`);\nconst WARNED_KEY = Symbol.for(`@toolbox-web/grid:feature-registry-warned@${GRID_VERSION}/v1`);\n\nfunction getOrCreateGlobal<T>(key: symbol, make: () => T): T {\n let value = Reflect.get(globalThis, key) as T | undefined;\n if (value === undefined) {\n value = make();\n Reflect.set(globalThis, key, value);\n }\n return value;\n}\n\nconst featureRegistry = getOrCreateGlobal(REGISTRY_KEY, () => new Map<string, RegistryEntry>());\nconst warnedFeatures = getOrCreateGlobal(WARNED_KEY, () => new Set<string>());\n\n// #endregion\n\n// #region Registration API\n\n/** Runtime dev-mode check (localhost or 127.0.0.1). */\nconst isDev = (): boolean =>\n typeof window !== 'undefined' &&\n (window.location?.hostname === 'localhost' || window.location?.hostname === '127.0.0.1');\n\n/** Optional flags passed to {@link registerFeature}. */\nexport interface RegisterFeatureOptions {\n /**\n * Set to `true` when the registration is intentionally overwriting an\n * existing entry (e.g. a framework adapter wrapping the vanilla factory\n * with reactive bridging). Suppresses the TBW030 dev-mode warning.\n */\n override?: boolean;\n}\n\n/**\n * Register a feature's plugin factory.\n * Called by side-effect feature imports (e.g., `import '@toolbox-web/grid/features/selection'`).\n *\n * @param name - The feature name (matches a key on FeatureConfig)\n * @param factory - Function that creates a plugin instance from config\n * @param options - Pass `{ override: true }` for intentional re-registration\n * (framework adapters bridging the vanilla factory) to suppress TBW030.\n */\nexport function registerFeature<K extends FeatureName>(\n name: K,\n factory: PluginFactory<FeatureConfig[K]>,\n options?: RegisterFeatureOptions,\n): void;\nexport function registerFeature(name: string, factory: PluginFactory, options?: RegisterFeatureOptions): void;\nexport function registerFeature(name: string, factory: PluginFactory, options?: RegisterFeatureOptions): void {\n if (isDev() && featureRegistry.has(name) && !options?.override) {\n warnDiagnostic(FEATURE_REREGISTERED, `Feature \"${name}\" was re-registered. Previous registration overwritten.`);\n }\n featureRegistry.set(name, { factory, name });\n}\n\n/**\n * Check if a feature has been registered.\n */\nexport function isFeatureRegistered(name: string): boolean {\n return featureRegistry.has(name);\n}\n\n/**\n * Get a registered feature's factory. Returns undefined if not registered.\n */\nexport function getFeatureFactory(name: string): PluginFactory | undefined {\n return featureRegistry.get(name)?.factory;\n}\n\n/**\n * Get all registered feature names.\n */\nexport function getRegisteredFeatures(): string[] {\n return Array.from(featureRegistry.keys());\n}\n\n// #endregion\n\n// #region Plugin Creation\n\n/**\n * Plugin dependency declarations.\n * Some plugins require others to be loaded first.\n */\nconst PLUGIN_DEPENDENCIES: Record<string, string[]> = {\n undoRedo: ['editing'],\n clipboard: ['selection'],\n};\n\n/**\n * Create a plugin instance for a single feature.\n * Shows a warning if the feature is not registered.\n */\nexport function createPluginFromFeature(name: string, config: unknown): GridPlugin | undefined {\n const entry = featureRegistry.get(name);\n\n if (!entry) {\n if (isDev() && !warnedFeatures.has(name)) {\n warnedFeatures.add(name);\n const kebab = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n warnDiagnostic(\n FEATURE_NOT_IMPORTED,\n `Feature \"${name}\" is configured but not registered.\\n` +\n `Add this import to enable it:\\n\\n` +\n ` import '@toolbox-web/grid/features/${kebab}';\\n`,\n );\n }\n return undefined;\n }\n\n return entry.factory(config);\n}\n\n/**\n * Validate feature dependencies and log warnings for missing ones.\n */\nfunction validateDependencies(featureNames: string[]): void {\n const featureSet = new Set(featureNames);\n\n for (const feature of featureNames) {\n const deps = PLUGIN_DEPENDENCIES[feature];\n if (!deps) continue;\n\n for (const dep of deps) {\n if (!featureSet.has(dep)) {\n if (isDev()) {\n warnDiagnostic(\n FEATURE_MISSING_DEP,\n `Feature \"${feature}\" requires \"${dep}\" to be enabled. ` + `Add \"${dep}\" to your features configuration.`,\n );\n }\n }\n }\n }\n}\n\n/**\n * Create plugin instances from a features configuration object.\n *\n * Handles:\n * - Dependency validation (clipboard needs selection)\n * - Dependency ordering (selection before clipboard)\n * - Skipping false/undefined values\n *\n * @param features - Partial FeatureConfig object\n * @returns Array of plugin instances ready for gridConfig.plugins\n */\nexport function createPluginsFromFeatures(features: Record<string, unknown>): GridPlugin[] {\n const plugins: GridPlugin[] = [];\n const enabledFeatures: string[] = [];\n\n // Collect enabled feature names\n for (const [key, value] of Object.entries(features)) {\n if (value === undefined || value === false) continue;\n enabledFeatures.push(key);\n }\n\n // Validate dependencies\n validateDependencies(enabledFeatures);\n\n // Create plugins in dependency order: dep-targets first, then the rest\n const dependencyOrder: string[] = [\n 'selection',\n 'editing',\n ...enabledFeatures.filter((f) => f !== 'selection' && f !== 'editing'),\n ];\n const orderedFeatures = [...new Set(dependencyOrder)].filter((f) => enabledFeatures.includes(f));\n\n for (const featureName of orderedFeatures) {\n const config = features[featureName];\n if (config === undefined || config === false) continue;\n\n const plugin = createPluginFromFeature(featureName, config);\n if (plugin) {\n plugins.push(plugin);\n }\n }\n\n return plugins;\n}\n\n// #endregion\n\n// #region Auto-Registration\n\n// Wire feature resolver into grid core so `gridConfig.features` is handled automatically.\n// This runs when any feature module is imported (they all import this registry).\nsetFeatureResolver(createPluginsFromFeatures as (features: Record<string, unknown>) => GridPlugin[]);\n\n// #endregion\n\n// #region Testing Utilities\n\n/**\n * Clear the registry. For testing only.\n * @internal\n */\nexport function clearFeatureRegistry(): void {\n featureRegistry.clear();\n warnedFeatures.clear();\n}\n\n// #endregion\n"],"names":["warnDiagnostic","code","message","gridId","pluginName","console","warn","toLowerCase","docsUrl","formatDiagnostic","GRID_VERSION","__GRID_VERSION__","REGISTRY_KEY","Symbol","for","WARNED_KEY","getOrCreateGlobal","key","make","value","Reflect","get","globalThis","set","featureRegistry","Map","warnedFeatures","Set","isDev","window","location","hostname","registerFeature","name","factory","options","has","override","isFeatureRegistered","getFeatureFactory","getRegisteredFeatures","Array","from","keys","PLUGIN_DEPENDENCIES","undoRedo","clipboard","createPluginFromFeature","config","entry","add","kebab","replace","createPluginsFromFeatures","features","plugins","enabledFeatures","Object","entries","push","featureNames","featureSet","feature","deps","dep","validateDependencies","dependencyOrder","filter","f","orderedFeatures","includes","featureName","plugin","clearFeatureRegistry","clear","setFeatureResolver"],"mappings":"uDAoRO,SAASA,EAAeC,EAAsBC,EAAiBC,EAAiBC,GACrFC,QAAQC,KAtBH,SAA0BL,EAAsBC,GAErD,MAAO,cAAaD,MAASC,uBApB/B,SAAiBD,GACf,MAAO,qCAAgBA,EAAKM,eAC9B,CAkB4DC,CAAQP,IACpE,CAmBeQ,CAAiBR,EAAMC,GACtC,CCpMA,MAAMQ,EAA2C,oBAArBC,iBAAmCA,iBAAmB,MAC5EC,iBAAeC,OAAOC,IAAI,sCAAsCJ,QAChEK,iBAAaF,OAAOC,IAAI,6CAA6CJ,QAE3E,SAASM,EAAqBC,EAAaC,GACzC,IAAIC,EAAQC,QAAQC,IAAIC,WAAYL,GAKpC,YAJc,IAAVE,IACFA,EAAQD,IACRE,QAAQG,IAAID,WAAYL,EAAKE,IAExBA,CACT,CAEA,MAAMK,EAAkBR,EAAkBJ,EAAc,mBAAM,IAAIa,KAC5DC,EAAiBV,EAAkBD,EAAY,mBAAM,IAAIY,KAOzDC,EAAQ,IACM,oBAAXC,SACwB,cAA9BA,OAAOC,UAAUC,UAA0D,cAA9BF,OAAOC,UAAUC,UA2B1D,SAASC,EAAgBC,EAAcC,EAAwBC,GAChEP,KAAWJ,EAAgBY,IAAIH,KAAUE,GAASE,UACpDrC,ED3CgC,SC2CK,YAAYiC,4DAEnDT,EAAgBD,IAAIU,EAAM,CAAEC,UAASD,QACvC,CAKO,SAASK,EAAoBL,GAClC,OAAOT,EAAgBY,IAAIH,EAC7B,CAKO,SAASM,EAAkBN,GAChC,OAAOT,EAAgBH,IAAIY,IAAOC,OACpC,CAKO,SAASM,IACd,OAAOC,MAAMC,KAAKlB,EAAgBmB,OACpC,CAUA,MAAMC,EAAgD,CACpDC,SAAU,CAAC,WACXC,UAAW,CAAC,cAOP,SAASC,EAAwBd,EAAce,GACpD,MAAMC,EAAQzB,EAAgBH,IAAIY,GAElC,GAAKgB,EAcL,OAAOA,EAAMf,QAAQc,GAbnB,GAAIpB,MAAYF,EAAeU,IAAIH,GAAO,CACxCP,EAAewB,IAAIjB,GACnB,MAAMkB,EAAQlB,EAAKmB,QAAQ,kBAAmB,SAAS7C,cACvDP,ED3F8B,SC6F5B,YAAYiC,+GAE8BkB,QAE9C,CAKJ,CAoCO,SAASE,EAA0BC,GACxC,MAAMC,EAAwB,GACxBC,EAA4B,GAGlC,IAAA,MAAYvC,EAAKE,KAAUsC,OAAOC,QAAQJ,QAC1B,IAAVnC,IAAiC,IAAVA,GAC3BqC,EAAgBG,KAAK1C,IAtCzB,SAA8B2C,GAC5B,MAAMC,EAAa,IAAIlC,IAAIiC,GAE3B,IAAA,MAAWE,KAAWF,EAAc,CAClC,MAAMG,EAAOnB,EAAoBkB,GACjC,GAAKC,EAEL,IAAA,MAAWC,KAAOD,EACXF,EAAWzB,IAAI4B,IACdpC,KACF5B,EDnHyB,SCqHvB,YAAY8D,gBAAsBE,0BAAiCA,qCAK7E,CACF,CAwBEC,CAAqBT,GAGrB,MAAMU,EAA4B,CAChC,YACA,aACGV,EAAgBW,OAAQC,GAAY,cAANA,GAA2B,YAANA,IAElDC,EAAkB,IAAI,IAAI1C,IAAIuC,IAAkBC,OAAQC,GAAMZ,EAAgBc,SAASF,IAE7F,IAAA,MAAWG,KAAeF,EAAiB,CACzC,MAAMrB,EAASM,EAASiB,GACxB,QAAe,IAAXvB,IAAmC,IAAXA,EAAkB,SAE9C,MAAMwB,EAASzB,EAAwBwB,EAAavB,GAChDwB,GACFjB,EAAQI,KAAKa,EAEjB,CAEA,OAAOjB,CACT,CAkBO,SAASkB,IACdjD,EAAgBkD,QAChBhD,EAAegD,OACjB,CAbAC,EAAmBtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "description": "Zero-dependency, framework-agnostic data grid web component with virtualization, sorting, filtering, editing, and 20+ plugins. Works in vanilla JS, React, Vue, Angular, and any framework.",
5
5
  "type": "module",
6
6
  "main": "./index.js",