@toolbox-web/grid 2.17.3 → 2.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/index.js +1 -1
  2. package/index.js.map +1 -1
  3. package/lib/core/types.d.ts +1 -1
  4. package/lib/features/registry.js +1 -1
  5. package/lib/plugins/clipboard/index.js +1 -1
  6. package/lib/plugins/clipboard/index.js.map +1 -1
  7. package/lib/plugins/column-virtualization/index.js +1 -1
  8. package/lib/plugins/column-virtualization/index.js.map +1 -1
  9. package/lib/plugins/context-menu/index.js +1 -1
  10. package/lib/plugins/context-menu/index.js.map +1 -1
  11. package/lib/plugins/editing/index.js +1 -1
  12. package/lib/plugins/editing/index.js.map +1 -1
  13. package/lib/plugins/export/index.js +1 -1
  14. package/lib/plugins/export/index.js.map +1 -1
  15. package/lib/plugins/filtering/index.js +1 -1
  16. package/lib/plugins/filtering/index.js.map +1 -1
  17. package/lib/plugins/grouping-columns/index.js +1 -1
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js +1 -1
  20. package/lib/plugins/grouping-rows/index.js.map +1 -1
  21. package/lib/plugins/master-detail/index.js +1 -1
  22. package/lib/plugins/master-detail/index.js.map +1 -1
  23. package/lib/plugins/multi-sort/index.js +1 -1
  24. package/lib/plugins/multi-sort/index.js.map +1 -1
  25. package/lib/plugins/pinned-columns/index.js +1 -1
  26. package/lib/plugins/pinned-columns/index.js.map +1 -1
  27. package/lib/plugins/pinned-rows/index.js +1 -1
  28. package/lib/plugins/pinned-rows/index.js.map +1 -1
  29. package/lib/plugins/pivot/index.js +1 -1
  30. package/lib/plugins/pivot/index.js.map +1 -1
  31. package/lib/plugins/print/index.js +1 -1
  32. package/lib/plugins/print/index.js.map +1 -1
  33. package/lib/plugins/reorder-columns/index.js +1 -1
  34. package/lib/plugins/reorder-columns/index.js.map +1 -1
  35. package/lib/plugins/reorder-rows/index.js +1 -1
  36. package/lib/plugins/reorder-rows/index.js.map +1 -1
  37. package/lib/plugins/responsive/index.js +1 -1
  38. package/lib/plugins/responsive/index.js.map +1 -1
  39. package/lib/plugins/row-drag-drop/index.js +1 -1
  40. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  41. package/lib/plugins/selection/index.js +1 -1
  42. package/lib/plugins/selection/index.js.map +1 -1
  43. package/lib/plugins/server-side/index.js +1 -1
  44. package/lib/plugins/server-side/index.js.map +1 -1
  45. package/lib/plugins/shell/index.js +1 -1
  46. package/lib/plugins/shell/index.js.map +1 -1
  47. package/lib/plugins/sticky-rows/index.js +1 -1
  48. package/lib/plugins/sticky-rows/index.js.map +1 -1
  49. package/lib/plugins/tooltip/index.js +1 -1
  50. package/lib/plugins/tooltip/index.js.map +1 -1
  51. package/lib/plugins/tree/index.js +1 -1
  52. package/lib/plugins/tree/index.js.map +1 -1
  53. package/lib/plugins/undo-redo/index.js +1 -1
  54. package/lib/plugins/undo-redo/index.js.map +1 -1
  55. package/lib/plugins/visibility/index.js +1 -1
  56. package/lib/plugins/visibility/index.js.map +1 -1
  57. package/package.json +1 -1
  58. package/umd/grid.all.umd.js +1 -1
  59. package/umd/grid.all.umd.js.map +1 -1
  60. package/umd/grid.umd.js +1 -1
  61. package/umd/grid.umd.js.map +1 -1
@@ -1,2 +1,2 @@
1
- function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const t="TBW072",o="TBW073";function n(t,o,n,r){return`${e(n,r)} ${t}: ${o}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}function r(e,t,o,r){console.warn(n(e,t,o,r))}const l="__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(""));new RegExp(`__(proto|defineGetter|defineSetter)|${l.slice(3).join("|")}|this\\b`);const s=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("|")),i=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function c(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 n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();i.test(e)?o.push(t.name):(a.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class p{static dependencies;static manifest;aliases;version="2.17.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const n of Object.keys(t))o[n]=this;for(const r of e){const e=r.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=r;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=r.constructor.name,a=n("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig;for(const o of Object.keys(t))delete t[o];Object.assign(t,e.userConfig)}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{...h,...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=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.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 n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(n(e,t,this.gridElement.id,this.name))}}const u="tbw-grid-root";function g(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function b(e,t,o){const n=document.createElement(e);return g(n,t),n}function f(e,t){const o=document.createElement("div");return e&&(o.className=e),g(o,t),o}function w(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),g(n,t),n}const m=document.createElement("template");function C(){return m.content.cloneNode(!0)}function v(e){const t=document.createDocumentFragment(),o=f(e.hasShell?`${u} has-shell`:u);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=f("tbw-grid-content");e.appendChild(C()),o.appendChild(e)}return t.appendChild(o),t}function y(e){const t=f("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=f("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=f("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=f("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(f("tbw-toolbar-separator")),l){const t=w(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=c(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function P(e){const t=e.mode??"overlay",o=f("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=f("tbw-grid-content");l.appendChild(C());let s=null;if(n){s=b("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(f("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=w(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=f("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=f("tbw-tool-panel-content",{role:"presentation"}),a=f("tbw-accordion");for(const t of e.panels){const o=f(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=w("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=b("span",{class:"tbw-accordion-icon"});e.innerHTML=c(t.icon),s.appendChild(e)}const i=b("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=b("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=c(e.expandIcon)),s.appendChild(t)}if(l){const e=f("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(f("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?c(e):e.outerHTML:""}function S(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function T(e){return!1!==e?.header?.visible}function O(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 n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function E(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const l={id:r,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(r,l),t.lightDomToolbarContentIds.add(r),n.style.display="none"}function _(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const l=e,s=l.getAttribute("id"),i=l.getAttribute("title");if(!s||!i)return void r("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=l.getAttribute("icon")??void 0,d=l.getAttribute("tooltip")??void 0,h=parseInt(l.getAttribute("order")??"100",10);let p;const u=n?.(l);if(u)p=u;else{const e=c(l.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return r(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(l.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==h||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=h,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:h,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),l.style.display="none"})}function D(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function A(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function H(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.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 k="--tbw-tool-panel-anchor";let q=0;function $(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",k)}function z(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if($()){const e=`${k}-${++q}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(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 M(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,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:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function B(e,t,o,n){const r=e.querySelector(`.${u}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=S(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(u)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=M(t,o,n),s=v({hasShell:!0,shellHeader:T(t)?y(r):void 0,shellBody:P(l)});e.appendChild(s)}else{const t=v({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=S(t);if(r.replaceChildren(),s){r.className=`${u} has-shell`;const{headerOptions:e,bodyOptions:s}=M(t,o,n),i=T(t)?y(e):void 0,a=P(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=u,r.appendChild(l);return s}function N(e,n){let l=!1;const s={get isInitialized(){return l},setInitialized(e){l=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,l){if(0===e.toolPanels.size)return void r("TBW071","No tool panels registered",n.id);let i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:r(t,`Tool panel "${o}" not found`,n.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=n.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=n._renderRoot;if(A(a,e),H(a,e),R(a,e,n._accordionIcons),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=n._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:n._hostElement,corner:!0}}(l?.anchor);z(a,e,t,o)}n._emit("tool-panel-open",{sections:s.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(n.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=n._renderRoot;A(t,e),H(t,e),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),n._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?s.closeToolPanel():s.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==n.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==n._hostElement){const e=n._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=n._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==n._hostElement){if(e.dropdownAnchorName&&$()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(n._renderRoot,e,o))return;z(n._renderRoot,e,o,!1)}else t!==n._hostElement||z(n._renderRoot,e,n._hostElement,!0)},toggleToolPanelSection(o){const l=e.toolPanels.get(o);if(!l)return void r(t,`Tool panel section "${o}" not found`,n.id);if(1===e.toolPanels.size)return;const s=n._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),l.onClose?.(),e.expandedSections.delete(o),j(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),j(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),j(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}n._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?r(o,`Tool panel "${t.id}" already registered`,n.id):(e.toolPanels.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),l&&n.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?r("TBW074",`Header content "${t.id}" already registered`,n.id):(e.headerContents.set(t.id,t),l&&L(n._renderRoot,e))},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const r=e.headerContents.get(t);r?.onDestroy?.(),e.headerContents.delete(t);const l=n._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?r("TBW075",`Toolbar content "${t.id}" already registered`,n.id):(e.toolbarContents.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const r=e.toolbarContents.get(t);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(t),l&&n.refreshShellHeader?.()}};return s}function j(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class W extends p{name="shell";styles="@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-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@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)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-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}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={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,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=N(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e);const t=()=>this.#c(e);this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#h(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState),_(t,this.shellState,e._getToolPanelRendererFactory())}#c(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#h(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState)}_parseLightDomToolPanels(e){_(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&I(this.shellState)}_renderOpenPanelContent(e){this.hasState&&R(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return S(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),r=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],l=new Set(r.map(e=>e.id)),s=[...r];for(const i of n)l.has(i.id)||s.push(i);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;B(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;e&&this.hasState&&(this.shellState.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#g(e)):this.#b())}#g(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#b()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#b()}#b(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;L(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(H(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),A(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.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&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&D(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#f(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#f(),this.#b(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!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.#o),this.#n?.setInitialized(!1))}}export{W as ShellPlugin};
1
+ function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const t="TBW072",o="TBW073";function n(t,o,n,r){return`${e(n,r)} ${t}: ${o}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}function r(e,t,o,r){console.warn(n(e,t,o,r))}const l="__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(""));new RegExp(`__(proto|defineGetter|defineSetter)|${l.slice(3).join("|")}|this\\b`);const s=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("|")),i=/^on\w+$/i,a=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),d=/^\s*(javascript|vbscript|data|blob):/i;function c(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 n of o){const e=n.tagName.toLowerCase();if(s.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>i.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const o=[];for(const t of n.attributes){const e=t.name.toLowerCase();i.test(e)?o.push(t.name):(a.has(e)&&d.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}const h={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};class p{static dependencies;static manifest;aliases;version="2.17.5";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const n of Object.keys(t))o[n]=this;for(const r of e){const e=r.userConfig;for(const[l,s]of Object.entries(e)){if(void 0===s)continue;if(!(l in t)){t[l]=s,o[l]=r;continue}if(t[l]===s)continue;const e=o[l]?.constructor.name??this.constructor.name,i=r.constructor.name,a=n("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${l}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,o={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,o)}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{...h,...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=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,o);void 0!==n?"string"==typeof n?e.innerHTML=c(n):n instanceof HTMLElement&&(e.innerHTML="",e.appendChild(n.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 n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(o,n):e.appendChild(o),o}warn(t,o){void 0!==o?console.warn(n(t,o,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${t}`)}throwDiagnostic(e,t){throw new Error(n(e,t,this.gridElement.id,this.name))}}const u="tbw-grid-root";function g(e,t){if(t)for(const o in t){const n=t[o];null!=n&&e.setAttribute(o,n)}}function b(e,t,o){const n=document.createElement(e);return g(n,t),n}function f(e,t){const o=document.createElement("div");return e&&(o.className=e),g(o,t),o}function w(e,t,o){const n=document.createElement("button");return n.type="button",e&&(n.className=e),g(n,t),n}const m=document.createElement("template");function C(){return m.content.cloneNode(!0)}function v(e){const t=document.createDocumentFragment(),o=f(e.hasShell?`${u} has-shell`:u);if(e.hasShell&&e.shellBody)e.shellHeader&&o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=f("tbw-grid-content");e.appendChild(C()),o.appendChild(e)}return t.appendChild(o),t}function y(e){const t=f("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=f("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=f("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const n=f("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const s of e.configButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));for(const s of e.apiButtons)s.hasRender&&n.appendChild(f("tbw-toolbar-content-slot",{"data-toolbar-content":s.id}));const r=e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender),l=e.hasPanels&&!1!==e.showToggle;if(r&&l&&n.appendChild(f("tbw-toolbar-separator")),l){const t=w(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=c(e.toolPanelIcon)),n.appendChild(t)}return t.appendChild(n),t}function P(e){const t=e.mode??"overlay",o=f("tbw-shell-body",{"data-mode":t}),n=e.panels.length>0,r=1===e.panels.length,l=f("tbw-grid-content");l.appendChild(C());let s=null;if(n){s=b("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel",..."dropdown"===t?{popover:"manual"}:{}});const o="left"===e.position?"right":"left";s.appendChild(f("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":o,"aria-hidden":"true"}));const n=e=>{const t=w(e?"tbw-tool-panel-close tbw-tool-panel-close--inline":"tbw-tool-panel-close",{part:"tool-panel-close","data-panel-close":"",title:"Close panel","aria-label":"Close panel","aria-controls":"tbw-tool-panel"});return t.textContent="✕",t},l=!0===e.showCloseButton&&r;if(e.showCloseButton&&!r){const e=f("tbw-tool-panel-header",{part:"tool-panel-header"});e.appendChild(n(!1)),s.appendChild(e)}const i=f("tbw-tool-panel-content",{role:"presentation"}),a=f("tbw-accordion");for(const t of e.panels){const o=f(`tbw-accordion-section${t.isExpanded?" expanded":""}${r?" single":""}${l?" has-inline-close":""}`,{"data-section":t.id}),s=w("tbw-accordion-header",{"aria-expanded":String(t.isExpanded),"aria-controls":`tbw-section-${t.id}`});if(r&&s.setAttribute("aria-disabled","true"),t.icon){const e=b("span",{class:"tbw-accordion-icon"});e.innerHTML=c(t.icon),s.appendChild(e)}const i=b("span",{class:"tbw-accordion-title"});if(i.textContent=t.title,s.appendChild(i),!r){const t=b("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=c(e.expandIcon)),s.appendChild(t)}if(l){const e=f("tbw-accordion-header-row");e.appendChild(s),e.appendChild(n(!0)),o.appendChild(e)}else o.appendChild(s);o.appendChild(f("tbw-accordion-content",{id:`tbw-section-${t.id}`,role:"presentation"})),a.appendChild(o)}i.appendChild(a),s.appendChild(i)}return"left"===e.position&&s?(o.appendChild(s),o.appendChild(l)):(o.appendChild(l),s&&o.appendChild(s)),o}function x(e){return e?"string"==typeof e?c(e):e.outerHTML:""}function S(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function T(e){return!1!==e?.header?.visible}function O(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 n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function E(e,t,o){const n=e.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const l={id:r,order:0,render:e=>{for(;n.firstChild;)e.appendChild(n.firstChild);return()=>{for(;e.firstChild;)n.appendChild(e.firstChild)}}};t.toolbarContents.set(r,l),t.lightDomToolbarContentIds.add(r),n.style.display="none"}function _(e,t,n){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const l=e,s=l.getAttribute("id"),i=l.getAttribute("title");if(!s||!i)return void r("TBW070",`Tool panel missing required id or title attribute: id="${s??""}", title="${i??""}"`);const a=l.getAttribute("icon")??void 0,d=l.getAttribute("tooltip")??void 0,h=parseInt(l.getAttribute("order")??"100",10);let p;const u=n?.(l);if(u)p=u;else{const e=c(l.innerHTML.trim());p=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const g=t.toolPanels.get(s);if(g&&!t.lightDomToolPanelIds.has(s))return r(o,`Tool panel "${s}" is already provided by a plugin or the grid API; ignoring the matching light-DOM <tbw-grid-tool-panel>.`),void(l.style.display="none");if(g){if(u){const e=!t.adapterBoundToolPanelIds.has(s),o=g.order!==h||g.icon!==a||g.tooltip!==d;if(g.render=p,g.order=h,g.icon=a,g.tooltip=d,t.adapterBoundToolPanelIds.add(s),e||o){const e=t.panelCleanups.get(s);e&&(e(),t.panelCleanups.delete(s))}}return}const b={id:s,title:i,icon:a,tooltip:d,order:h,render:p};t.toolPanels.set(s,b),t.lightDomToolPanelIds.add(s),u&&t.adapterBoundToolPanelIds.add(s),l.style.display="none"})}function D(e,t){if(t.contains(e))return!0;const o=e.getRootNode();return o instanceof ShadowRoot&&o.host===t}function L(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,n=t.headerContents.size>0;if(!o&&!n)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const l=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of l){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const n=s.render(o);n&&t.headerContentCleanups.set(s.id,n)}}function R(e,t,o){if(t.isPanelOpen)for(const[n,r]of t.toolPanels){const o=t.expandedSections.has(n),l=e.querySelector(`[data-section="${n}"]`),s=l?.querySelector(".tbw-accordion-content");if(!l||!s)continue;l.classList.toggle("expanded",o);const i=l.querySelector(".tbw-accordion-header");if(i&&i.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(n,e)}}else{const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n)),s.innerHTML=""}}}function A(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function H(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}m.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 k="--tbw-tool-panel-anchor";let q=0;function $(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("anchor-name",k)}function z(e,t,o,n){const r=e.querySelector(".tbw-tool-panel");if(r){if(t.dropdownAnchorEl=o,r.dataset.anchor=n?"corner":"below",r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}if($()){const e=`${k}-${++q}`;t.dropdownAnchorName=e,o.style.setProperty("anchor-name",e),r.style.setProperty("position-anchor",e),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right")}else!function(e,t,o){const n=t.getBoundingClientRect(),r=e.getAttribute("data-position")??"right";if(e.style.position="fixed",e.style.top=`${Math.round((o?n.top:n.bottom)+4)}px`,"left"===r)e.style.left=`${Math.round(n.left)}px`,e.style.right="auto";else{const t="undefined"!=typeof window?window.innerWidth:0;e.style.left="auto",e.style.right=`${Math.round(t-n.right)}px`}}(r,o,n)}}function I(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 M(e,t,o){const n=void 0!==o?.toolPanel?x(o.toolPanel):void 0,r=void 0!==o?.expand?x(o.expand):void 0,l=void 0!==o?.collapse?x(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),i=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:i.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:n,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:r,collapseIcon:l,showCloseButton:!1===e.header?.visible&&!0!==e.toolPanel?.locked&&"dropdown"!==(e.toolPanel?.mode??"overlay"),panels:i.map(e=>({id:e.id,title:e.title,icon:x(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function B(e,t,o,n){const r=e.querySelector(`.${u}`),l=r?.querySelector(".tbw-grid-content");if(!r||!l)return function(e,t,o,n){const r=S(t),l=[];for(let s=e.firstChild;s;s=s.nextSibling)1===s.nodeType&&s.classList.contains(u)||l.push(s);e.replaceChildren();for(const s of l)e.appendChild(s);if(r){const{headerOptions:r,bodyOptions:l}=M(t,o,n),s=v({hasShell:!0,shellHeader:T(t)?y(r):void 0,shellBody:P(l)});e.appendChild(s)}else{const t=v({hasShell:!1});e.appendChild(t)}return r}(e,t,o,n);l.remove();const s=S(t);if(r.replaceChildren(),s){r.className=`${u} has-shell`;const{headerOptions:e,bodyOptions:s}=M(t,o,n),i=T(t)?y(e):void 0,a=P(s),d=a.querySelector(".tbw-grid-content");d&&d.replaceWith(l),i&&r.appendChild(i),r.appendChild(a)}else r.className=u,r.appendChild(l);return s}function N(e,n){let l=!1;const s={get isInitialized(){return l},setInitialized(e){l=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(o,l){if(0===e.toolPanels.size)return void r("TBW071","No tool panels registered",n.id);let i;if(void 0!==o&&(e.toolPanels.has(o)?i=o:r(t,`Tool panel "${o}" not found`,n.id)),e.isPanelOpen&&i&&e.expandedSections.has(i))return;if(e.isPanelOpen&&i&&!e.expandedSections.has(i))return void s.toggleToolPanelSection(i);if(e.isPanelOpen)return;if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0)if(i)e.expandedSections.add(i);else{const t=n.effectiveConfig?.shell?.toolPanel?.defaultOpen;if(t&&e.toolPanels.has(t))e.expandedSections.add(t);else{const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}}else if(i&&!e.expandedSections.has(i)){for(const t of[...e.expandedSections])e.expandedSections.delete(t);e.expandedSections.add(i)}const a=n._renderRoot;if(A(a,e),H(a,e),R(a,e,n._accordionIcons),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode){const{el:t,corner:o}=function(e){if(e)return{el:e,corner:!1};const t=n._renderRoot.querySelector("[data-panel-toggle]");return t?{el:t,corner:!1}:{el:n._hostElement,corner:!0}}(l?.anchor);z(a,e,t,o)}n._emit("tool-panel-open",{sections:s.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;if(n.effectiveConfig?.shell?.toolPanel?.locked)return;for(const o of e.panelCleanups.values())o();e.panelCleanups.clear();for(const o of e.toolPanels.values())o.onClose?.();e.isPanelOpen=!1;const t=n._renderRoot;A(t,e),H(t,e),"dropdown"===n.effectiveConfig?.shell?.toolPanel?.mode&&function(e,t){const o=e.querySelector(".tbw-tool-panel");if(o){if(o.hasAttribute("popover")&&"function"==typeof o.hidePopover)try{o.hidePopover()}catch{}o.style.removeProperty("position-anchor"),o.style.removeProperty("position"),o.style.removeProperty("top"),o.style.removeProperty("left"),o.style.removeProperty("right"),delete o.dataset.anchor}t.dropdownAnchorEl&&(t.dropdownAnchorEl.style.removeProperty("anchor-name"),t.dropdownAnchorEl=null),t.dropdownAnchorName=null}(t,e),n._emit("tool-panel-close",{})},toggleToolPanel(t){e.isPanelOpen?s.closeToolPanel():s.openToolPanel(void 0,t)},reanchorOpenDropdown(){if(!e.isPanelOpen)return;if("dropdown"!==n.effectiveConfig?.shell?.toolPanel?.mode)return;const t=e.dropdownAnchorEl;if(t&&t.isConnected&&e.dropdownAnchorName&&t.style.getPropertyValue("anchor-name")===e.dropdownAnchorName)return;if(!e.dropdownAnchorName&&t&&t.isConnected&&t!==n._hostElement){const e=n._renderRoot.querySelector(".tbw-tool-panel");if("below"===e?.dataset.anchor)return}const o=n._renderRoot.querySelector("[data-panel-toggle]");if(o&&o!==n._hostElement){if(e.dropdownAnchorName&&$()&&function(e,t,o){const n=t.dropdownAnchorName;if(!n)return!1;const r=e.querySelector(".tbw-tool-panel");if(!r)return!1;const l=t.dropdownAnchorEl;if(l&&l!==o&&l.style.removeProperty("anchor-name"),o.style.setProperty("anchor-name",n),r.style.setProperty("position-anchor",n),r.style.removeProperty("top"),r.style.removeProperty("left"),r.style.removeProperty("right"),r.dataset.anchor="below",t.dropdownAnchorEl=o,r.hasAttribute("popover")&&"function"==typeof r.showPopover)try{r.showPopover()}catch{}return!0}(n._renderRoot,e,o))return;z(n._renderRoot,e,o,!1)}else t!==n._hostElement||z(n._renderRoot,e,n._hostElement,!0)},toggleToolPanelSection(o){const l=e.toolPanels.get(o);if(!l)return void r(t,`Tool panel section "${o}" not found`,n.id);if(1===e.toolPanels.size)return;const s=n._renderRoot,i=e.expandedSections.has(o);if(i){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),l.onClose?.(),e.expandedSections.delete(o),j(s,o,!1)}else{for(const[t,n]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),n.onClose?.(),e.expandedSections.delete(t),j(s,t,!1);const r=s.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),j(s,o,!0),function(e,t,o){const n=t.toolPanels.get(o);if(!n?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const l=n.render(r);l&&t.panelCleanups.set(o,l)}(s,e,o)}n._emit("tool-panel-section-toggle",{id:o,expanded:!i})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(t){e.toolPanels.has(t.id)?r(o,`Tool panel "${t.id}" already registered`,n.id):(e.toolPanels.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolPanel(t){if(e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),e.expandedSections.delete(t)}e.toolPanels.delete(t),l&&n.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(t){e.headerContents.has(t.id)?r("TBW074",`Header content "${t.id}" already registered`,n.id):(e.headerContents.set(t.id,t),l&&L(n._renderRoot,e))},unregisterHeaderContent(t){const o=e.headerContentCleanups.get(t);o&&(o(),e.headerContentCleanups.delete(t));const r=e.headerContents.get(t);r?.onDestroy?.(),e.headerContents.delete(t);const l=n._renderRoot.querySelector(`[data-header-content="${t}"]`);l?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(t){e.toolbarContents.has(t.id)?r("TBW075",`Toolbar content "${t.id}" already registered`,n.id):(e.toolbarContents.set(t.id,t),l&&n.refreshShellHeader?.())},unregisterToolbarContent(t){const o=e.toolbarContentCleanups.get(t);o&&(o(),e.toolbarContentCleanups.delete(t));const r=e.toolbarContents.get(t);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(t),l&&n.refreshShellHeader?.()}};return s}function j(e,t,o){const n=e.querySelector(`[data-section="${t}"]`);n&&n.classList.toggle("expanded",o)}class W extends p{name="shell";styles="@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-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}}@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)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-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}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel.open{border-left:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel[data-position=left].open{border-left:none;border-right:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-shell-body[data-mode=push] .tbw-tool-panel-resize{display:none}tbw-grid .tbw-tool-panel[popover]{position:fixed;inset:auto;width:var(--tbw-tool-panel-width);max-width:calc(100vw - 16px);height:auto;max-height:min(70vh,480px);overflow:hidden auto;margin:4px 0 0;padding:0;border:1px solid var(--tbw-tool-panel-border);border-radius:var(--tbw-border-radius, 6px);box-shadow:0 8px 24px var(--tbw-color-shadow);transition:none;display:none}tbw-grid .tbw-tool-panel[popover]:popover-open,tbw-grid .tbw-tool-panel[popover].open{display:flex;width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel[popover] .tbw-tool-panel-resize{display:none}@supports (anchor-name: --x){tbw-grid .tbw-tool-panel[popover]{top:anchor(bottom);right:anchor(right);left:auto;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline}tbw-grid .tbw-tool-panel[popover][data-anchor=corner]{top:anchor(top)}tbw-grid .tbw-tool-panel[popover][data-position=left]{left:anchor(left);right:auto}}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:flex-end;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-accordion-header-row{display:flex;align-items:stretch}tbw-grid .tbw-accordion-header-row .tbw-accordion-header{flex:1;min-width:0}tbw-grid .tbw-tool-panel-close--inline{align-self:center;flex-shrink:0;margin-inline-end:8px}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}}";#o;#n;#r;#l;#s;#i;#a;#d=!1;get hasState(){return void 0!==this.#o}ensureState(e){if(this.#o)return;const t={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,dropdownAnchorEl:null,dropdownAnchorName:null};this.#o=t,this.#n=N(t,e)}get shellState(){return this.#o}get shellController(){return this.#n}get isToolPanelOpen(){return!!this.hasState&&this.shellController.isPanelOpen}get expandedToolPanelSections(){return this.hasState?this.shellController.expandedSections:[]}openToolPanel(e,t){this.shellController?.openToolPanel(e,t)}closeToolPanel(){this.shellController?.closeToolPanel()}toggleToolPanel(e){this.shellController?.toggleToolPanel(e)}toggleToolPanelSection(e){this.shellController?.toggleToolPanelSection(e)}getToolPanels(){return this.hasState?this.shellController.getToolPanels():[]}registerToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.add(e.id),this.shellController.registerToolPanel(e))}unregisterToolPanel(e){this.hasState&&(this.shellState.apiToolPanelIds.delete(e),this.shellController.unregisterToolPanel(e))}getHeaderContents(){return this.hasState?this.shellController.getHeaderContents():[]}registerHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.add(e.id),this.shellController.registerHeaderContent(e))}unregisterHeaderContent(e){this.hasState&&(this.shellState.apiHeaderContentIds.delete(e),this.shellController.unregisterHeaderContent(e))}getToolbarContents(){return this.hasState?this.shellController.getToolbarContents():[]}registerToolbarContent(e){this.shellController?.registerToolbarContent(e)}unregisterToolbarContent(e){this.shellController?.unregisterToolbarContent(e)}attach(e){super.attach(e);const t=()=>this.#c(e);this.#i=t,e._registerLightDomHandler("tbw-grid-header",t),e._registerLightDomHandler("tbw-grid-tool-buttons",t),e._registerLightDomHandler("tbw-grid-tool-panel",t)}#h(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState),_(t,this.shellState,e._getToolPanelRendererFactory())}#c(e){if(!this.hasState)return;const t=this.shellState,o=t.lightDomTitle,n=t.hasToolButtonsContainer;this.#h(e);const r=t.lightDomTitle,l=t.hasToolButtonsContainer;(r&&!o||l&&!n)&&(e._requestConfigMerge(),e._renderRoot.querySelector(".tbw-shell-header")&&(I(t),this.afterStructuralRender()))}_parseLightDomHeader(e){const t=e._hostElement;O(t,this.shellState),E(t,this.shellState)}_parseLightDomToolPanels(e){_(e._hostElement,this.shellState,e._getToolPanelRendererFactory())}_parseLightDomAll(e){this._parseLightDomHeader(e),this._parseLightDomToolPanels(e)}_prepareForRerender(){this.hasState&&I(this.shellState)}_renderOpenPanelContent(e){this.hasState&&R(e._renderRoot,this.shellState)}_shouldRenderHeader(e){return S(e)}processConfig(e){if(!this.hasState)return;const t=this.shellState,o=this.resolvedConfig;if(e.shell={...o,...e.shell},e.shell.header={...o.header,...e.shell.header},t.lightDomTitle&&!e.shell.header.title&&(e.shell.header.title=t.lightDomTitle),t.lightDomHeaderContent?.length>0&&(e.shell.header.lightDomContent=t.lightDomHeaderContent),t.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0),t.toolPanels.size>0){const o=Array.from(t.toolPanels.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=o}if(t.headerContents.size>0){const o=Array.from(t.headerContents.values());o.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=o}const n=Array.from(t.toolbarContents.values()),r=this.grid?._sourceConfig?.shell?.header?.toolbarContents??[],l=new Set(r.map(e=>e.id)),s=[...r];for(const i of n)l.has(i.id)||s.push(i);s.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=s}afterStructuralRender(){const e=this.grid;if(!e||!this.hasState)return;const t=this.shellState;B(e._renderRoot,e.effectiveConfig?.shell,{isPanelOpen:t.isPanelOpen,expandedSections:t.expandedSections},e.effectiveConfig?.icons)&&(this.#p(e),this.shellController.setInitialized(!0),this.#u(e))}afterRender(){const e=this.grid;e&&this.hasState&&(this.shellState.isPanelOpen?(this.shellController.reanchorOpenDropdown(),this.#g(e)):this.#b())}#g(e){"dropdown"===e.effectiveConfig?.shell?.toolPanel?.mode?"undefined"!=typeof MutationObserver&&(this.#a||(this.#a=new MutationObserver(()=>{this.grid&&this.hasState&&this.shellState.isPanelOpen?this.shellController.reanchorOpenDropdown():this.#b()})),this.#d||(this.#a.observe(e._renderRoot,{childList:!0,subtree:!0}),this.#d=!0)):this.#b()}#b(){this.#a&&this.#d&&(this.#a.disconnect(),this.#d=!1)}#u(e){const t=this.shellState,o=e._renderRoot,n=e.effectiveConfig?.shell;L(o,t),function(e,t,o){const n=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],l=new Set(n.map(e=>e.id)),s=[...n];for(const i of r)l.has(i.id)||s.push(i);for(const i of s){if(o.toolbarContentCleanups.has(i.id))continue;if(!i.render)continue;const t=e.querySelector(`[data-toolbar-content="${i.id}"]`);if(!t)continue;const n=i.render(t);n&&o.toolbarContentCleanups.set(i.id,n)}}(o,n,t);const r=n?.toolPanel,l=r?.defaultOpen;l&&t.toolPanels.has(l)&&t.expandedSections.add(l);const s=!0===r?.locked||"open"===r?.initialState||void 0===r?.initialState&&void 0!==l&&t.toolPanels.has(l);!t.isPanelOpen&&t.toolPanels.size>0&&s&&this.openToolPanel(),t.isPanelOpen&&(H(o,t),R(o,t,(e.effectiveConfig,e.effectiveConfig)),A(o,t),this.shellController.reanchorOpenDropdown())}#p(e){const t=e._renderRoot,o=e.effectiveConfig?.shell,n=this.shellState;!function(e,t,o,n){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&n.onPanelToggle()});const l=e.querySelector(".tbw-tool-panel");l&&n.onPanelClose&&l.addEventListener("click",e=>{e.target.closest("[data-panel-close]")&&n.onPanelClose()});const s=e.querySelector(".tbw-accordion");s&&s.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&&n.onSectionToggle(o)}})}(t,0,0,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onPanelClose:()=>this.closeToolPanel()}),this.#r?.(),this.#r=function(e,t,o){const n=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),l=e.querySelector(".tbw-shell-body");if(!n||!r||!l)return()=>{};const s=t?.toolPanel?.position??"right";let i=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-i:i-e.clientX,o=Math.min(d,Math.max(200,a+t));n.style.width=`${o}px`},p=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=n.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)},u=e=>{e.preventDefault(),c=!0,i=e.clientX,a=n.getBoundingClientRect().width,d=l.getBoundingClientRect().width-20,r.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)};return r.addEventListener("mousedown",u),()=>{r.removeEventListener("mousedown",u),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)}}(t,o,t=>{e._hostElement.style.setProperty("--tbw-tool-panel-width",`${t}px`)}),this.#l?.(),this.#l=function(e,t,o,n){const r=t?.toolPanel?.mode;if("dropdown"!==r&&!t?.toolPanel?.closeOnClickOutside)return()=>{};if("push"===r)return()=>{};const l=t=>{if(!o.isPanelOpen)return;const r=o.dropdownAnchorEl;for(const o of t.composedPath()){if(null!=r&&o===r)return;if(o instanceof Element&&(o.classList?.contains("tbw-tool-panel")||o.matches?.("[data-panel-toggle]"))&&D(o,e))return}n()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}(e._hostElement,o,n,()=>this.closeToolPanel()),this.#s?.(),this.#s=function(e,t,o){if("push"===e?.toolPanel?.mode)return()=>{};const n=e=>{"Escape"!==e.key||e.defaultPrevented||t.isPanelOpen&&o()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}(o,n,()=>this.closeToolPanel())}#f(){this.#r?.(),this.#r=void 0,this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=void 0}detach(){super.detach()}disposeShellState(){this.#f(),this.#b(),this.#a=void 0;const e=this.grid;e&&this.#i&&(e._unregisterLightDomHandler("tbw-grid-header"),e._unregisterLightDomHandler("tbw-grid-tool-buttons"),e._unregisterLightDomHandler("tbw-grid-tool-panel"),this.#i=void 0),this.#o&&(!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.#o),this.#n?.setInitialized(!1))}}export{W as ShellPlugin};
2
2
  //# sourceMappingURL=index.js.map