@toolbox-web/grid 2.13.1 → 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.
Files changed (48) hide show
  1. package/all.js +2 -2
  2. package/all.js.map +1 -1
  3. package/custom-elements.json +18 -0
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +23 -0
  7. package/lib/core/internal/style-injector.d.ts +0 -8
  8. package/lib/features/registry.js +1 -1
  9. package/lib/features/registry.js.map +1 -1
  10. package/lib/plugins/filtering/index.js +1 -1
  11. package/lib/plugins/filtering/index.js.map +1 -1
  12. package/lib/plugins/filtering/types.d.ts +0 -28
  13. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +0 -1
  14. package/lib/plugins/master-detail/index.js +1 -1
  15. package/lib/plugins/master-detail/index.js.map +1 -1
  16. package/lib/plugins/master-detail/types.d.ts +0 -2
  17. package/lib/plugins/responsive/index.js +1 -1
  18. package/lib/plugins/responsive/index.js.map +1 -1
  19. package/lib/plugins/responsive/types.d.ts +11 -2
  20. package/lib/plugins/server-side/datasource-types.d.ts +8 -0
  21. package/lib/plugins/server-side/index.js +1 -1
  22. package/lib/plugins/server-side/index.js.map +1 -1
  23. package/lib/plugins/server-side/types.d.ts +9 -10
  24. package/lib/plugins/visibility/index.js +1 -1
  25. package/lib/plugins/visibility/index.js.map +1 -1
  26. package/lib/plugins/visibility/types.d.ts +5 -10
  27. package/lib/plugins/visibility/visibility.d.ts +5 -3
  28. package/package.json +1 -1
  29. package/themes/dg-theme-bootstrap.css +2 -2
  30. package/themes/dg-theme-contrast.css +1 -1
  31. package/themes/dg-theme-large.css +1 -1
  32. package/themes/dg-theme-material.css +2 -2
  33. package/themes/dg-theme-standard.css +1 -1
  34. package/themes/dg-theme-vibrant.css +1 -1
  35. package/umd/grid.all.umd.js +1 -1
  36. package/umd/grid.all.umd.js.map +1 -1
  37. package/umd/grid.umd.js +1 -1
  38. package/umd/grid.umd.js.map +1 -1
  39. package/umd/plugins/filtering.umd.js +1 -1
  40. package/umd/plugins/filtering.umd.js.map +1 -1
  41. package/umd/plugins/master-detail.umd.js +1 -1
  42. package/umd/plugins/master-detail.umd.js.map +1 -1
  43. package/umd/plugins/responsive.umd.js +1 -1
  44. package/umd/plugins/responsive.umd.js.map +1 -1
  45. package/umd/plugins/server-side.umd.js +1 -1
  46. package/umd/plugins/server-side.umd.js.map +1 -1
  47. package/umd/plugins/visibility.umd.js +1 -1
  48. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -10,6 +10,29 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
10
10
  static readonly tagName = "tbw-grid";
11
11
  /** Version of the grid component, injected at build time from package.json */
12
12
  static readonly version: string;
13
+ /**
14
+ * Tag name this bundle should render and query for.
15
+ *
16
+ * In the common (single-version) case this equals {@link tagName}
17
+ * (`'tbw-grid'`).
18
+ *
19
+ * Resolution rules (see `registerDataGrid()` at the bottom of this file):
20
+ * - **No existing registration** → this class registers under `tbw-grid`;
21
+ * `activeTag === 'tbw-grid'`.
22
+ * - **Existing registration at the SAME version** → this class is NOT
23
+ * redefined (the first-loaded bundle's class keeps the registration),
24
+ * and `activeTag` still points at `'tbw-grid'` so adapters render the
25
+ * shared element. Note that in this branch `customElements.get(activeTag)`
26
+ * returns the OTHER bundle's class, not this one.
27
+ * - **Existing registration at a DIFFERENT version** → this class
28
+ * registers under a version-suffixed tag like `tbw-grid-v2-14-0` and
29
+ * `activeTag` reflects that suffixed name; the two implementations
30
+ * coexist on the page.
31
+ *
32
+ * Adapters and consumers that need to construct or query for the grid
33
+ * element MUST use this property, not the hard-coded `tagName` literal.
34
+ */
35
+ static activeTag: string;
13
36
  /**
14
37
  * Registry of framework adapters that handle converting light DOM elements
15
38
  * to functional renderers/editors. Framework libraries (Angular, React, Vue)
@@ -1,11 +1,3 @@
1
- /**
2
- * Style Injector Module
3
- *
4
- * Handles injection of grid and plugin styles into the document.
5
- * Uses a singleton pattern to avoid duplicate injection across multiple grid instances.
6
- *
7
- * @module internal/style-injector
8
- */
9
1
  /**
10
2
  * Add plugin styles to the accumulated plugin styles map.
11
3
  * Returns true if any new styles were added.
@@ -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"}
@@ -1,2 +1,2 @@
1
- const e="(Blank)";function t(e){if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=Number(e);if(!isNaN(t))return t;return new Date(e).getTime()}function r(r,n,i=!1,l){if(!n.length)return r;const a=n.map(r=>function(r,n,i){const l=r.field,a=r.operator,s=i?e=>i(e[l],e):e=>e[l];if("blank"===a)return e=>{const t=s(e);return null==t||""===t||"number"==typeof t&&isNaN(t)};if("notBlank"===a)return e=>{const t=s(e);return null!=t&&""!==t&&!("number"==typeof t&&isNaN(t))};if(i&&("notIn"===a||"in"===a)){const t=r.value;if("notIn"===a){if(!Array.isArray(t))return()=>!0;const r=new Set(t);return t=>{const n=i(t[l],t),a=Array.isArray(n)?n:null!=n?[n]:[];return 0===a.length?!r.has(e):!a.some(e=>r.has(e))}}if(!Array.isArray(t))return()=>!1;const n=new Set(t);return t=>{const r=i(t[l],t),a=Array.isArray(r)?r:null!=r?[r]:[];return 0===a.length?n.has(e):a.some(e=>n.has(e))}}if("notIn"===a){if(!Array.isArray(r.value))return()=>!0;const t=new Set(r.value);return r=>{const n=r[l];return null==n||""===n?!t.has(e):!t.has(n)}}if("in"===a){if(!Array.isArray(r.value))return()=>!1;const t=new Set(r.value);return r=>{const n=r[l];return null==n||""===n?t.has(e):t.has(n)}}const o="number"===r.type&&!i,c=e=>null==e||""===e||"number"==typeof e&&isNaN(e);if("greaterThan"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r>e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i>e}}if("greaterThanOrEqual"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r>=e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i>=e}}if("lessThan"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r<e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i<e}}if("lessThanOrEqual"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r<=e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i<=e}}if("between"===a){const e=t(r.value),n=t(r.valueTo);return o?t=>{const r=t[l];return!c(r)&&(r>=e&&r<=n)}:r=>{const i=s(r);if(c(i))return!1;const l=t(i);return!isNaN(l)&&l>=e&&l<=n}}const d=n?String(r.value):String(r.value).toLowerCase();return"contains"===a?n?e=>{const t=s(e);return null!=t&&String(t).includes(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().includes(d)}:"notContains"===a?n?e=>{const t=s(e);return null!=t&&!String(t).includes(d)}:e=>{const t=s(e);return null!=t&&!String(t).toLowerCase().includes(d)}:"equals"===a?n?e=>{const t=s(e);return null!=t&&String(t)===d}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase()===d}:"notEquals"===a?n?e=>{const t=s(e);return null!=t&&String(t)!==d}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase()!==d}:"startsWith"===a?n?e=>{const t=s(e);return null!=t&&String(t).startsWith(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().startsWith(d)}:"endsWith"===a?n?e=>{const t=s(e);return null!=t&&String(t).endsWith(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().endsWith(d)}:()=>!0}(r,i,l?.get(r.field)));return 1===a.length?r.filter(a[0]):r.filter(e=>{for(let t=0;t<a.length;t++)if(!a[t](e))return!1;return!0})}function n(t,r,n){const i=/* @__PURE__ */new Set;let l=!1;for(const e of t){const t=e[r];if(n){const r=n(t,e);if(Array.isArray(r)){0===r.length&&(l=!0);for(const e of r)null!=e&&i.add(e)}else null!=r?i.add(r):l=!0}else null!=t&&""!==t?i.add(t):l=!0}return l&&i.add(e),[...i].sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:String(e).localeCompare(String(t)))}const i={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},l={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function a(e,t){if(!e)return;const r="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===r?.a11y?.announcements)return;const n=e.querySelector?.(".tbw-sr-only");n&&(n.textContent="",requestAnimationFrame(()=>{n.textContent=t}))}function s(e,t,...r){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,l=n?.a11y?.messages?.[t];return l?l(...r):i[t](...r)}const o=/* @__PURE__ */new WeakMap;function c(e,t,r=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let l=o.get(n);if(l){const e=l.get(i);if(void 0!==e)return e.v}else l=/* @__PURE__ */new Map,o.set(n,l);const a=t.valueAccessor({row:e,column:t,rowIndex:r});return l.set(i,{v:a}),a}function d(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function u(e,t,r,n){return`${d(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}const p="__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)|${p.slice(3).join("|")}|this\\b`);const f=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("|")),h=/^on\w+$/i,b=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),g=/^\s*(javascript|vbscript|data|blob):/i;function m(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=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(f.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>h.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();h.test(e)?r.push(t.name):(b.has(e)&&g.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}class v{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";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},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[i,l]of Object.entries(e)){if(void 0===l)continue;if(!(i in t)){t[i]=l,r[i]=n;continue}if(t[i]===l)continue;const e=r[i]?.constructor.name??this.constructor.name,a=n.constructor.name,s=u("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${e} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(s)}}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 r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.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{...l,...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(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){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,r);void 0!==n?"string"==typeof n?e.innerHTML=m(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 r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(u(e,t,this.gridElement.id,this.name)):console.warn(`${d(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(u(e,t,this.gridElement.id,this.name))}}function w(e){return e?e.toISOString().split("T")[0]:""}function y(e){return e?"string"==typeof e?e:"number"==typeof e?w(new Date(e)):"":""}const x=335e5;function C(e){const{totalRows:t,viewportHeight:r,scrollTop:n,rowHeight:i,overscan:l,maxSpacerHeight:a=x}=e,s=Math.ceil(r/i),o=t*i,c=function(e,t,r=x){return{rawContentHeight:e,spacerHeight:Math.min(e,r),viewportHeight:t,capped:e>r}}(o,r,a),d=function(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,n=t.rawContentHeight-t.viewportHeight;if(r<=0||n<=0)return e;const i=e*n/r;return i<0?0:i>n?n:i}(n,c);let u=Math.floor(d/i)-l;u<0&&(u=0);let p=u+s+2*l;return p>t&&(p=t),p===t&&u>0&&(u=Math.max(0,p-s-2*l)),{start:u,end:p,offsetY:u*i,totalHeight:c.spacerHeight,rawContentHeight:o}}function E(e,t,r,n,i,l){const{field:a,column:s}=t,o=function(e){if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-filter-item-height");if(t&&t.trim()){const e=parseFloat(t);if(!isNaN(e)&&e>0)return e}}return 28}(e),c=e=>{if(null==e)return"(Blank)";if(s.format&&!s.filterValue){const t=s.format(e,void 0);if(t)return t}return String(e)};r=r.slice().sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:c(e).localeCompare(c(t)));const d=document.createElement("div");d.className="tbw-filter-search";const u=document.createElement("input");u.type="text",u.placeholder="Search...",u.className="tbw-filter-search-input",u.value=l.get(a)??"",d.appendChild(u),e.appendChild(d);const p=document.createElement("div");p.className="tbw-filter-actions";const f=document.createElement("label");f.className="tbw-filter-value-item",f.style.padding="0",f.style.margin="0";const h=document.createElement("input");h.type="checkbox",h.className="tbw-filter-checkbox";const b=document.createElement("span");b.textContent="Select All",f.appendChild(h),f.appendChild(b),p.appendChild(f);const g=/* @__PURE__ */new Map;r.forEach(e=>{const t=null==e?"__null__":String(e);g.set(t,!n.has(e))});const m=()=>{const e=[...g.values()],t=e.every(e=>e),r=e.every(e=>!e);h.checked=t,h.indeterminate=!t&&!r};h.addEventListener("change",()=>{const e=h.checked;for(const t of g.keys())g.set(t,e);m(),S()}),m(),e.appendChild(p);const v=document.createElement("div");v.className="tbw-filter-values";const w=document.createElement("div");w.className="tbw-filter-values-spacer",v.appendChild(w);const y=document.createElement("div");y.className="tbw-filter-values-content",v.appendChild(y);let x=[];const E=(e,t)=>{const r=c(e),n=null==e?"__null__":String(e),i=document.createElement("label");i.className="tbw-filter-value-item",i.style.position="absolute",i.style.top=`calc(var(--tbw-filter-item-height, 28px) * ${t})`,i.style.left="0",i.style.right="0",i.style.boxSizing="border-box";const l=document.createElement("input");l.type="checkbox",l.className="tbw-filter-checkbox",l.checked=g.get(n)??!0,l.dataset.value=n,l.addEventListener("change",()=>{g.set(n,l.checked),m()});const a=document.createElement("span");return a.textContent=r,i.appendChild(l),i.appendChild(a),i},S=()=>{const e=x.length,t=v.clientHeight,r=v.scrollTop;if(w.style.height=e*o+"px",e<=50/3)return y.innerHTML="",y.style.transform="translateY(0px)",void x.forEach((e,t)=>{y.appendChild(E(e,t))});const n=C({totalRows:e,viewportHeight:t,scrollTop:r,rowHeight:o,overscan:3});y.style.transform=`translateY(${n.offsetY}px)`,y.innerHTML="";for(let i=n.start;i<n.end;i++)y.appendChild(E(x[i],i-n.start))},k=e=>{const t=i.caseSensitive??!1,n=t?e:e.toLowerCase();if(x=r.filter(r=>{const i=c(r),l=t?i:i.toLowerCase();return!e||l.includes(n)}),x.sort((e,t)=>{const r=null==e?"__null__":String(e),n=null==t?"__null__":String(t),i=g.get(r)??!0;return i!==(g.get(n)??!0)?i?-1:1:"number"==typeof e&&"number"==typeof t?e-t:c(e).localeCompare(c(t))}),0===x.length){w.style.height="0px",y.innerHTML="";const e=document.createElement("div");return e.className="tbw-filter-no-match",e.textContent="No matching values",void y.appendChild(e)}S()};let F;v.addEventListener("scroll",()=>{x.length>0&&S()},{passive:!0}),k(u.value),e.appendChild(v),u.addEventListener("input",()=>{clearTimeout(F),F=setTimeout(()=>{l.set(a,u.value),k(u.value)},i.debounceMs??150)});const A=document.createElement("div");A.className="tbw-filter-buttons";const N=document.createElement("button");N.type="button",N.className="tbw-filter-apply-btn",N.textContent="Apply",N.addEventListener("click",()=>{const e=[];for(const[t,n]of g)if(!n)if("__null__"===t)e.push(null);else{const n=r.find(e=>String(e)===t);e.push(void 0!==n?n:t)}t.applySetFilter(e)}),A.appendChild(N);const T=document.createElement("button");T.type="button",T.className="tbw-filter-clear-btn",T.textContent="Clear Filter",T.addEventListener("click",()=>{t.clearFilter()}),A.appendChild(T),e.appendChild(A)}function S(e,t){if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);return isNaN(r)?t:r}return t}class k extends v{static manifest={events:[{type:"filter-change",description:"Emitted when filter criteria change. Broadcast to both DOM consumers and plugin bus."}],queries:[{type:"getContextMenuItems",description:"Contributes filter-related items to the header context menu"}]};name="filtering";styles='@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s,display 0s allow-discrete;color:inherit;vertical-align:middle;transition-behavior:allow-discrete}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1;visibility:visible;display:inline-flex}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}tbw-grid .header-row .cell:hover .tbw-filter-btn,tbw-grid .header-row .cell.filtered .tbw-filter-btn{display:inline-flex;visibility:visible}}';get defaultConfig(){return{debounceMs:300,caseSensitive:!1,trimInput:!0,useWorker:!0}}isFilteringEnabled(){return!1!==this.grid.effectiveConfig?.filterable}isColumnFilterable(e){return!!this.isFilteringEnabled()&&!1!==e.filterable}getDataRows(){const e=this.sourceRows;if(e.length>0)return e;const t=this.rows;return 0===t.length?t:t.filter(e=>null!=e&&!0!==e.__loading)}getFilterValues(){const e=this.grid.effectiveConfig?.columns;if(!e)return;let t;for(const r of e)if(r.field)if(r.filterValue)t||(t=/* @__PURE__ */new Map),t.set(r.field,r.filterValue);else if(r.valueAccessor){t||(t=/* @__PURE__ */new Map);const e=r;t.set(r.field,(t,r)=>c(r,e))}return t}filters=/* @__PURE__ */new Map;cachedResult=null;cacheKey=null;cachedInputSpot=null;openPanelField=null;panelElement=null;panelAnchorElement=null;panelButtonElement=null;searchText=/* @__PURE__ */new Map;excludedValues=/* @__PURE__ */new Map;panelAbortController=null;globalStylesInjected=!1;columnLookup=null;columnLookupRef=null;getColumnByField(e){const t=this.grid.effectiveConfig?.columns;if(!t)return;let r=this.columnLookup;if(t!==this.columnLookupRef||!r){r=/* @__PURE__ */new Map;for(const e of t)e.field&&r.set(e.field,e);this.columnLookup=r,this.columnLookupRef=t}return r.get(e)}computeSelected(){const t={},r=[];for(const[e,n]of this.filters)if("set"===n.type)if("in"===n.operator&&Array.isArray(n.value))t[e]=n.value;else if("notIn"===n.operator){const t=this.getColumnByField(e),n=t?.filterValue??(t?.valueAccessor?(e,r)=>c(r,t):void 0);r.push({field:e,filterValue:n})}if(r.length>0){const n=function(t,r){const n=/* @__PURE__ */new Map;for(const{field:e,filterValue:l}of r)n.set(e,{values:/* @__PURE__ */new Set,hasBlank:!1,hasExtractor:!!l});for(const e of t)for(const{field:t,filterValue:i}of r){const r=n.get(t),l=e[t];if(i){const t=i(l,e);if(Array.isArray(t)){0===t.length&&(r.hasBlank=!0);for(const e of t)null!=e&&r.values.add(e)}else null!=t?r.values.add(t):r.hasBlank=!0}else null!=l&&""!==l?r.values.add(l):r.hasBlank=!0}const i=/* @__PURE__ */new Map;for(const[l,{values:a,hasBlank:s}]of n)s&&a.add(e),i.set(l,[...a].sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:String(e).localeCompare(String(t))));return i}(this.getDataRows(),r);for(const{field:e}of r){const r=this.excludedValues.get(e),i=n.get(e)??[];t[e]=r?i.filter(e=>!r.has(e)):i}}return t}syncExcludedValues(t,r){if(r)if("set"===r.type&&"notIn"===r.operator&&Array.isArray(r.value))this.excludedValues.set(t,new Set(r.value));else if("set"===r.type&&"in"===r.operator&&Array.isArray(r.value)){const n=this.getDataRows();if(!n||0===n.length)return void this.excludedValues.delete(t);const i=r.value,l=new Set(i.map(t=>null==t?e:t)),a=this.getUniqueValues(t),s=new Set(a.filter(e=>!l.has(e)));this.excludedValues.set(t,s)}else"set"===r.type&&this.excludedValues.delete(t);else this.excludedValues.delete(t)}attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,this.columnLookup=null,this.columnLookupRef=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}handleQuery(e){if("filter:get-model"===e.type){if(!this.filters.size)return;return Object.fromEntries(this.filters)}if("getContextMenuItems"===e.type){const t=e.context;if(!t.isHeader)return;const r=t.column;if(!r?.field)return;if(!this.isFilteringEnabled())return;if(!this.isColumnFilterable(r))return;const n=[],i=this.isFieldFiltered(r.field),l=this.filters.size>0;return i&&n.push({id:"filtering/clear-column-filter",label:"Clear Filter",icon:"✕",order:20,action:()=>this.clearFieldFilter(r.field)}),l&&n.push({id:"filtering/clear-all-filters",label:"Clear All Filters",icon:"✕",order:21,disabled:!l,action:()=>this.clearAllFilters()}),n.length>0?n:void 0}}processRows(e){if(!this.filters.size)return e;const t=[...this.filters.values()];if(this.config.filterHandler)return this.cachedResult?this.cachedResult:e;const n=(i=t,JSON.stringify(i.map(e=>({field:e.field,operator:e.operator,value:e.value,valueTo:e.valueTo}))));var i;const l={len:e.length,first:e[0],mid:e[Math.floor(e.length/2)],last:e[e.length-1]},a=null!=this.cachedInputSpot&&l.len===this.cachedInputSpot.len&&l.first===this.cachedInputSpot.first&&l.mid===this.cachedInputSpot.mid&&l.last===this.cachedInputSpot.last;if(this.cacheKey===n&&this.cachedResult&&a)return this.cachedResult;if(!a)for(const[r,o]of this.filters)"set"===o.type&&"in"===o.operator&&this.syncExcludedValues(r,o);const s=r(e,t,this.config.caseSensitive,this.getFilterValues());return this.cachedResult=s,this.cacheKey=n,this.cachedInputSpot=l,s}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(e=>{const t=e.getAttribute("data-col");if(null===t)return;const r=this.visibleColumns[parseInt(t,10)];if(!r||!this.isColumnFilterable(r))return;if(!0===r.utility)return;const n=r.field;if(!n)return;const i=this.filters.has(n);let l=e.querySelector(".tbw-filter-btn");if(l){const t=l.classList.contains("active");return l.classList.toggle("active",i),e.classList.toggle("filtered",i),i?e.setAttribute("aria-description","Filtered"):e.removeAttribute("aria-description"),void(t!==i&&this.setIcon(l,i?"filterActive":"filter"))}l=document.createElement("button"),l.type="button",l.className="tbw-filter-btn",l.setAttribute("aria-label",`Filter ${r.header??n}`),this.setIcon(l,i?"filterActive":"filter"),i&&(l.classList.add("active"),e.classList.add("filtered"),e.setAttribute("aria-description","Filtered")),l.addEventListener("click",e=>{e.stopPropagation(),this.toggleFilterPanel(n,r,l)});const a=e.querySelector(".resize-handle");a?e.insertBefore(l,a):e.appendChild(l)})}setFilter(e,t,r){if(null===t)this.filters.delete(e),this.syncExcludedValues(e,null);else{const r={...t,field:e};this.filters.set(e,r),this.syncExcludedValues(e,r)}if(this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,r?.silent)this.emitPluginEvent("filter-change",{filters:[...this.filters.values()]});else{this.broadcast("filter-change",{filters:[...this.filters.values()],filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.();const r=this.getColumnByField(e)?.header??e;a(this.gridElement,s(this.gridElement,null===t?"filterCleared":"filterApplied",r))}this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e,t){this.filters.clear(),this.excludedValues.clear();for(const r of e)this.filters.set(r.field,r),this.syncExcludedValues(r.field,r);this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,t?.silent?this.emitPluginEvent("filter-change",{filters:[...this.filters.values()]}):(this.broadcast("filter-change",{filters:[...this.filters.values()],filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()}clearAllFilters(e){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.applyFiltersInternal(e?.silent),e?.silent||a(this.gridElement,s(this.gridElement,"allFiltersCleared"))}clearFieldFilter(e,t){if(this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.applyFiltersInternal(t?.silent),!t?.silent){const t=this.getColumnByField(e)?.header??e;a(this.gridElement,s(this.gridElement,"filterCleared",t))}}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){const t=this.getColumnByField(e),r=t?.filterValue;return n(this.getDataRows(),e,r)}getStaleFilters(){const e=[];for(const[t,r]of this.filters){if("set"!==r.type)continue;const n=this.getUniqueValues(t);if("notIn"===r.operator&&Array.isArray(r.value)){const t=new Set(r.value);0===n.filter(e=>!t.has(e)).length&&e.push(r)}else if("in"===r.operator&&Array.isArray(r.value)){const t=new Set(r.value);0===n.filter(e=>t.has(e)).length&&e.push(r)}}return e}getBlankMode(e){const t=this.filters.get(e);return"blank"===t?.operator?"blanksOnly":"notBlank"===t?.operator?"nonBlanksOnly":"all"}toggleBlankFilter(e,t){if("all"===t){const t=this.filters.get(e);if(t?.valueTo&&"object"==typeof t.valueTo){const r=t.valueTo;this.setFilter(e,r)}else this.setFilter(e,null);return}const r=this.filters.get(e),n=r&&"blank"!==r.operator&&"notBlank"!==r.operator?{type:r.type,operator:r.operator,value:r.value,valueTo:r.valueTo}:r?.valueTo;this.setFilter(e,{type:r?.type??"text",operator:"blanksOnly"===t?"blank":"notBlank",value:"",valueTo:n})}copyGridThemeContext(e){const t=this.gridElement;if(!t)return;for(const n of t.classList)n.startsWith("tbw-")||"selecting"===n||e.classList.add(n);const r=t.dataset.theme;r&&(e.dataset.theme=r)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles"))return void(this.globalStylesInjected=!0);const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent="@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);right:anchor(right);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-search-input{height:var(--tbw-filter-item-height, 28px);width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-actions .tbw-filter-value-item{flex:1}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-range-inputs,.tbw-filter-date-range{display:flex;align-items:flex-end;gap:var(--tbw-spacing-sm, .375rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-group,.tbw-filter-date-group{display:flex;flex-direction:column;gap:var(--tbw-spacing-xs, .25rem);flex:1}.tbw-filter-range-label{font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)))}.tbw-filter-range-input,.tbw-filter-date-input{width:100%;height:var(--tbw-filter-item-height, 28px);padding:var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-sm, .375rem);background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-range-input:focus,.tbw-filter-date-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-range-separator{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding-bottom:var(--tbw-spacing-xs, .25rem)}.tbw-filter-blank-option{display:flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-spacing-xs, .25rem) 0;margin-bottom:var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-sm, .8125rem);cursor:pointer;-webkit-user-select:none;user-select:none}.tbw-filter-blank-checkbox{accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));margin:0;cursor:pointer}.tbw-filter-date-range.tbw-filter-disabled,.tbw-filter-range-inputs.tbw-filter-disabled,.tbw-filter-range-slider.tbw-filter-disabled{opacity:.4;pointer-events:none}.tbw-filter-range-slider{position:relative;height:24px;margin:var(--tbw-spacing-md, .5rem) 0 var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-track{position:absolute;top:50%;left:0;right:0;height:4px;background:var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-fill{position:absolute;top:50%;height:4px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-thumb{position:absolute;top:0;width:100%;height:100%;background:none;pointer-events:none;-webkit-appearance:none;appearance:none}.tbw-filter-range-thumb::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-moz-range-thumb{width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-webkit-slider-thumb:hover{transform:scale(1.1)}.tbw-filter-range-thumb::-moz-range-thumb:hover{transform:scale(1.1)}}",document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,r){if(this.openPanelField===e)return void this.closeFilterPanel();this.closeFilterPanel();const i=document.createElement("div");if(i.className="tbw-filter-panel",this.copyGridThemeContext(i),this.isAnimationEnabled&&i.classList.add("tbw-filter-panel-animated"),this.panelElement=i,this.openPanelField=e,r.classList.add("active"),this.panelButtonElement=r,this.config.valuesHandler)return i.innerHTML='<div class="tbw-filter-loading">Loading...</div>',document.body.appendChild(i),this.positionPanel(i,r),this.setupPanelCloseHandler(i,r),void this.config.valuesHandler(e,t).then(r=>{this.openPanelField===e&&this.panelElement&&(i.innerHTML="",this.renderPanelContent(e,t,i,r))});const l=t.filterValue??(t.valueAccessor?(e,r)=>c(r,t):void 0),a=n(this.getDataRows(),e,l);document.body.appendChild(i),this.positionPanel(i,r),this.renderPanelContent(e,t,i,a),this.setupPanelCloseHandler(i,r)}renderPanelContent(t,r,n,i){const l=this.filters.get(t);if("in"===l?.operator&&"set"===l.type&&Array.isArray(l.value)&&!this.excludedValues.has(t)){const r=l.value,n=new Set(r.map(t=>null==t?e:t)),a=new Set(i.filter(e=>!n.has(e)));this.excludedValues.set(t,a)}let a=this.excludedValues.get(t);a||(a=/* @__PURE__ */new Set,this.excludedValues.set(t,a));const s=this.searchText.get(t)??"",o={field:t,column:r,uniqueValues:i,excludedValues:a,searchText:s,currentFilter:this.filters.get(t),applySetFilter:(e,r)=>{this.applySetFilter(t,e,r),this.closeFilterPanel()},applyTextFilter:(e,r,n)=>{this.applyTextFilter(t,e,r,n),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(t),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let c=!1;if(this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(n,o),c=n.children.length>0),!c&&r.type){const e=this.grid.effectiveConfig.typeDefaults?.[r.type];e?.filterPanelRenderer&&(e.filterPanelRenderer(n,o),c=n.children.length>0)}if(!c){const e=r.filterType??r.type;"number"===e?function(e,t,r,n){const{field:i,column:l}=t,a=l.filterParams,s=l.editorParams,o=r.filter(e=>"number"==typeof e&&!isNaN(e)),c=o.length>0?Math.min(...o):0,d=o.length>0?Math.max(...o):100,u=S(a?.min??s?.min,c),p=S(a?.max??s?.max,d),f=a?.step??s?.step??1,h=n.get(i);let b=u,g=p;const m="blank"===h?.operator;"between"===h?.operator?(b=S(h.value,u),g=S(h.valueTo,p)):"greaterThanOrEqual"===h?.operator?b=S(h.value,u):"lessThanOrEqual"===h?.operator&&(g=S(h.value,p));const v=document.createElement("div");v.className="tbw-filter-range-inputs";const w=document.createElement("div");w.className="tbw-filter-range-group";const y=document.createElement("label");y.textContent="Min",y.className="tbw-filter-range-label";const x=document.createElement("input");x.type="number",x.className="tbw-filter-range-input",x.min=String(u),x.max=String(p),x.step=String(f),x.value=String(b),w.appendChild(y),w.appendChild(x),v.appendChild(w);const C=document.createElement("span");C.className="tbw-filter-range-separator",C.textContent="–",v.appendChild(C);const E=document.createElement("div");E.className="tbw-filter-range-group";const k=document.createElement("label");k.textContent="Max",k.className="tbw-filter-range-label";const F=document.createElement("input");F.type="number",F.className="tbw-filter-range-input",F.min=String(u),F.max=String(p),F.step=String(f),F.value=String(g),E.appendChild(k),E.appendChild(F),v.appendChild(E),e.appendChild(v);const A=document.createElement("div");A.className="tbw-filter-range-slider";const N=document.createElement("div");N.className="tbw-filter-range-track";const T=document.createElement("div");T.className="tbw-filter-range-fill";const R=document.createElement("input");R.type="range",R.className="tbw-filter-range-thumb tbw-filter-range-thumb-min",R.min=String(u),R.max=String(p),R.step=String(f),R.value=String(b);const L=document.createElement("input");L.type="range",L.className="tbw-filter-range-thumb tbw-filter-range-thumb-max",L.min=String(u),L.max=String(p),L.step=String(f),L.value=String(g),A.appendChild(N),A.appendChild(T),A.appendChild(R),A.appendChild(L),e.appendChild(A);const P=document.createElement("label");P.className="tbw-filter-blank-option";const M=document.createElement("input");M.type="checkbox",M.className="tbw-filter-blank-checkbox",M.checked=m;const I=document.createTextNode("Blank");P.appendChild(M),P.appendChild(I);const _=e=>{x.disabled=e,F.disabled=e,R.disabled=e,L.disabled=e,v.classList.toggle("tbw-filter-disabled",e),A.classList.toggle("tbw-filter-disabled",e)};_(m),M.addEventListener("change",()=>{_(M.checked)}),e.appendChild(P);const q=()=>{const e=parseFloat(R.value),t=parseFloat(L.value),r=p-u,n=(e-u)/r*100,i=(t-u)/r*100;T.style.left=`${n}%`,T.style.width=i-n+"%"};R.addEventListener("input",()=>{const e=Math.min(parseFloat(R.value),parseFloat(L.value));R.value=String(e),x.value=String(e),q()}),L.addEventListener("input",()=>{const e=Math.max(parseFloat(L.value),parseFloat(R.value));L.value=String(e),F.value=String(e),q()}),x.addEventListener("input",()=>{const e=parseFloat(x.value);let t=Number.isFinite(e)?e:u;t=Math.max(u,Math.min(t,parseFloat(F.value))),R.value=String(t),q()}),F.addEventListener("input",()=>{const e=parseFloat(F.value);let t=Number.isFinite(e)?e:p;t=Math.min(p,Math.max(t,parseFloat(x.value))),L.value=String(t),q()}),q();const V=document.createElement("div");V.className="tbw-filter-buttons";const B=document.createElement("button");B.type="button",B.className="tbw-filter-apply-btn",B.textContent="Apply",B.addEventListener("click",()=>{if(M.checked)return void t.applyTextFilter("blank","");const e=parseFloat(x.value),r=parseFloat(F.value),n=Number.isFinite(e)?e:u,i=Number.isFinite(r)?r:p;n!==u||i!==p?t.applyTextFilter("between",n,i):t.clearFilter()}),V.appendChild(B);const H=document.createElement("button");H.type="button",H.className="tbw-filter-clear-btn",H.textContent="Clear Filter",H.addEventListener("click",()=>{t.clearFilter()}),V.appendChild(H),e.appendChild(V)}(n,o,i,this.filters):"date"===e?function(e,t,r,n){const{field:i,column:l}=t,a=l.filterParams,s=l.editorParams,o=r.filter(e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e))).map(e=>e instanceof Date?e:new Date(e)).filter(e=>!isNaN(e.getTime())),c=o.length>0?new Date(Math.min(...o.map(e=>e.getTime()))):null,d=o.length>0?new Date(Math.max(...o.map(e=>e.getTime()))):null,u=y(a?.min)||y(s?.min)||w(c),p=y(a?.max)||y(s?.max)||w(d),f=n.get(i);let h="",b="";const g="blank"===f?.operator;"between"===f?.operator?(h=y(f.value)||"",b=y(f.valueTo)||""):"greaterThanOrEqual"===f?.operator?h=y(f.value)||"":"lessThanOrEqual"===f?.operator&&(b=y(f.value)||"");const m=document.createElement("div");m.className="tbw-filter-date-range";const v=document.createElement("div");v.className="tbw-filter-date-group";const x=document.createElement("label");x.textContent="From",x.className="tbw-filter-range-label";const C=document.createElement("input");C.type="date",C.className="tbw-filter-date-input",u&&(C.min=u),p&&(C.max=p),C.value=h,v.appendChild(x),v.appendChild(C),m.appendChild(v);const E=document.createElement("span");E.className="tbw-filter-range-separator",E.textContent="–",m.appendChild(E);const S=document.createElement("div");S.className="tbw-filter-date-group";const k=document.createElement("label");k.textContent="To",k.className="tbw-filter-range-label";const F=document.createElement("input");F.type="date",F.className="tbw-filter-date-input",u&&(F.min=u),p&&(F.max=p),F.value=b,S.appendChild(k),S.appendChild(F),m.appendChild(S),e.appendChild(m);const A=document.createElement("label");A.className="tbw-filter-blank-option";const N=document.createElement("input");N.type="checkbox",N.className="tbw-filter-blank-checkbox",N.checked=g;const T=document.createTextNode("Show only blank");A.appendChild(N),A.appendChild(T);const R=e=>{C.disabled=e,F.disabled=e,m.classList.toggle("tbw-filter-disabled",e)};R(g),N.addEventListener("change",()=>{R(N.checked)}),e.appendChild(A);const L=document.createElement("div");L.className="tbw-filter-buttons";const P=document.createElement("button");P.type="button",P.className="tbw-filter-apply-btn",P.textContent="Apply",P.addEventListener("click",()=>{if(N.checked)return void t.applyTextFilter("blank","");const e=C.value,r=F.value;e&&r?t.applyTextFilter("between",e,r):e?t.applyTextFilter("greaterThanOrEqual",e):r?t.applyTextFilter("lessThanOrEqual",r):t.clearFilter()}),L.appendChild(P);const M=document.createElement("button");M.type="button",M.className="tbw-filter-clear-btn",M.textContent="Clear Filter",M.addEventListener("click",()=>{t.clearFilter()}),L.appendChild(M),e.appendChild(L)}(n,o,i,this.filters):E(n,o,i,a,{caseSensitive:this.config.caseSensitive,debounceMs:this.config.debounceMs},this.searchText)}}setupPanelCloseHandler(e,t){this.panelAbortController=new AbortController;const{signal:r}=this.panelAbortController;setTimeout(()=>{r.aborted||document.addEventListener("click",r=>{e.contains(r.target)||r.target===t||this.closeFilterPanel()},{signal:r})},0)}closeFilterPanel(){const e=this.panelElement;if(e&&(e.remove(),this.panelElement=null),this.panelAnchorElement&&(this.panelAnchorElement.style.anchorName="",this.panelAnchorElement=null),this.panelButtonElement){const e=this.openPanelField;e&&this.filters.has(e)||this.panelButtonElement.classList.remove("active"),this.panelButtonElement=null}this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}static supportsAnchorPositioning=null;static checkAnchorPositioningSupport(){return null===k.supportsAnchorPositioning&&(k.supportsAnchorPositioning=CSS.supports("anchor-name","--test")),k.supportsAnchorPositioning}positionPanel(e,t){const r=t.closest(".header-row")??t;if(r.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=r,k.checkAnchorPositioningSupport()){r.style.anchorName="",t.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=t;const n=r.getBoundingClientRect().bottom-t.getBoundingClientRect().bottom;return e.style.marginTop=`${n+4}px`,void requestAnimationFrame(()=>{const r=e.getBoundingClientRect(),n=t.getBoundingClientRect();r.top<n.top&&e.classList.add("tbw-filter-panel-above")})}const n=r.getBoundingClientRect(),i=t.getBoundingClientRect();e.style.position="fixed",e.style.top=`${n.bottom+4}px`,e.style.left=`${i.right}px`,requestAnimationFrame(()=>{const t=e.getBoundingClientRect();e.style.left=i.right-t.width+"px";i.right-t.width<8&&(e.style.left=`${i.left}px`),t.bottom>window.innerHeight-8&&(e.style.top=n.top-t.height-4+"px",e.classList.add("tbw-filter-panel-above"))})}applySetFilter(e,t,r){if(this.excludedValues.set(e,new Set(t)),0===t.length)this.filters.delete(e);else{const n=this.filters.get(e);if("in"===n?.operator){const n=this.getUniqueValues(e),i=new Set(t),l=n.filter(e=>!i.has(e));this.filters.set(e,{field:e,type:"set",operator:"in",value:l,...void 0!==r&&{valueTo:r}})}else this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t,...void 0!==r&&{valueTo:r}})}this.applyFiltersInternal()}applyTextFilter(e,t,r,n){const i=this.getColumnByField(e),l=i?.filterType??i?.type??"text";this.filters.set(e,{field:e,type:l,operator:t,value:r,valueTo:n}),this.applyFiltersInternal()}applyFiltersInternal(e){this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null;const t=[...this.filters.values()];if(this.config.filterHandler){this.gridElement.setAttribute("aria-busy","true");const r=this.config.filterHandler(t,this.sourceRows),n=r=>{this.gridElement.removeAttribute("aria-busy"),this.cachedResult=r,this.grid.rows=r,e?this.emitPluginEvent("filter-change",{filters:t}):(this.broadcast("filter-change",{filters:t,filteredRowCount:r.length,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()};return void(r&&"function"==typeof r.then?r.then(n):n(r))}e?this.emitPluginEvent("filter-change",{filters:t}):(this.broadcast("filter-change",{filters:t,filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()}getColumnState(e){if(!this.config.trackColumnState)return;const t=this.filters.get(e);return t?{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}:void 0}applyColumnState(e,t){if(!this.config.trackColumnState)return;if(!t.filter)return void this.filters.delete(e);const r={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,r),this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null}}export{e as BLANK_FILTER_VALUE,k as FilteringPlugin};
1
+ const e="(Blank)";function t(e){if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=Number(e);if(!isNaN(t))return t;return new Date(e).getTime()}function r(r,n,i=!1,l){if(!n.length)return r;const a=n.map(r=>function(r,n,i){const l=r.field,a=r.operator,s=i?e=>i(e[l],e):e=>e[l];if("blank"===a)return e=>{const t=s(e);return null==t||""===t||"number"==typeof t&&isNaN(t)};if("notBlank"===a)return e=>{const t=s(e);return null!=t&&""!==t&&!("number"==typeof t&&isNaN(t))};if(i&&("notIn"===a||"in"===a)){const t=r.value;if("notIn"===a){if(!Array.isArray(t))return()=>!0;const r=new Set(t);return t=>{const n=i(t[l],t),a=Array.isArray(n)?n:null!=n?[n]:[];return 0===a.length?!r.has(e):!a.some(e=>r.has(e))}}if(!Array.isArray(t))return()=>!1;const n=new Set(t);return t=>{const r=i(t[l],t),a=Array.isArray(r)?r:null!=r?[r]:[];return 0===a.length?n.has(e):a.some(e=>n.has(e))}}if("notIn"===a){if(!Array.isArray(r.value))return()=>!0;const t=new Set(r.value);return r=>{const n=r[l];return null==n||""===n?!t.has(e):!t.has(n)}}if("in"===a){if(!Array.isArray(r.value))return()=>!1;const t=new Set(r.value);return r=>{const n=r[l];return null==n||""===n?t.has(e):t.has(n)}}const o="number"===r.type&&!i,c=e=>null==e||""===e||"number"==typeof e&&isNaN(e);if("greaterThan"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r>e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i>e}}if("greaterThanOrEqual"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r>=e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i>=e}}if("lessThan"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r<e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i<e}}if("lessThanOrEqual"===a){const e=t(r.value);return o?t=>{const r=t[l];return!c(r)&&r<=e}:r=>{const n=s(r);if(c(n))return!1;const i=t(n);return!isNaN(i)&&i<=e}}if("between"===a){const e=t(r.value),n=t(r.valueTo);return o?t=>{const r=t[l];return!c(r)&&(r>=e&&r<=n)}:r=>{const i=s(r);if(c(i))return!1;const l=t(i);return!isNaN(l)&&l>=e&&l<=n}}const d=n?String(r.value):String(r.value).toLowerCase();return"contains"===a?n?e=>{const t=s(e);return null!=t&&String(t).includes(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().includes(d)}:"notContains"===a?n?e=>{const t=s(e);return null!=t&&!String(t).includes(d)}:e=>{const t=s(e);return null!=t&&!String(t).toLowerCase().includes(d)}:"equals"===a?n?e=>{const t=s(e);return null!=t&&String(t)===d}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase()===d}:"notEquals"===a?n?e=>{const t=s(e);return null!=t&&String(t)!==d}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase()!==d}:"startsWith"===a?n?e=>{const t=s(e);return null!=t&&String(t).startsWith(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().startsWith(d)}:"endsWith"===a?n?e=>{const t=s(e);return null!=t&&String(t).endsWith(d)}:e=>{const t=s(e);return null!=t&&String(t).toLowerCase().endsWith(d)}:()=>!0}(r,i,l?.get(r.field)));return 1===a.length?r.filter(a[0]):r.filter(e=>{for(let t=0;t<a.length;t++)if(!a[t](e))return!1;return!0})}function n(t,r,n){const i=/* @__PURE__ */new Set;let l=!1;for(const e of t){const t=e[r];if(n){const r=n(t,e);if(Array.isArray(r)){0===r.length&&(l=!0);for(const e of r)null!=e&&i.add(e)}else null!=r?i.add(r):l=!0}else null!=t&&""!==t?i.add(t):l=!0}return l&&i.add(e),[...i].sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:String(e).localeCompare(String(t)))}const i={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},l={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function a(e,t){if(!e)return;const r="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===r?.a11y?.announcements)return;const n=e.querySelector?.(".tbw-sr-only");n&&(n.textContent="",requestAnimationFrame(()=>{n.textContent=t}))}function s(e,t,...r){const n=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,l=n?.a11y?.messages?.[t];return l?l(...r):i[t](...r)}const o=/* @__PURE__ */new WeakMap;function c(e,t,r=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const n=e,i=t.field;let l=o.get(n);if(l){const e=l.get(i);if(void 0!==e)return e.v}else l=/* @__PURE__ */new Map,o.set(n,l);const a=t.valueAccessor({row:e,column:t,rowIndex:r});return l.set(i,{v:a}),a}function d(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function u(e,t,r,n){return`${d(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}const p="__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)|${p.slice(3).join("|")}|this\\b`);const f=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("|")),h=/^on\w+$/i,b=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),g=/^\s*(javascript|vbscript|data|blob):/i;function m(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=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(f.has(e)){t.push(n);continue}if("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI){if(Array.from(n.attributes).some(e=>h.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();h.test(e)?r.push(t.name):(b.has(e)&&g.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}class v{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";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},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[i,l]of Object.entries(e)){if(void 0===l)continue;if(!(i in t)){t[i]=l,r[i]=n;continue}if(t[i]===l)continue;const e=r[i]?.constructor.name??this.constructor.name,a=n.constructor.name,s=u("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${i}" supplied by both ${e} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(s)}}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 r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.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{...l,...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(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){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,r);void 0!==n?"string"==typeof n?e.innerHTML=m(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 r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(u(e,t,this.gridElement.id,this.name)):console.warn(`${d(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(u(e,t,this.gridElement.id,this.name))}}function w(e){return e?e.toISOString().split("T")[0]:""}function y(e){return e?"string"==typeof e?e:"number"==typeof e?w(new Date(e)):"":""}const x=335e5;function C(e){const{totalRows:t,viewportHeight:r,scrollTop:n,rowHeight:i,overscan:l,maxSpacerHeight:a=x}=e,s=Math.ceil(r/i),o=t*i,c=function(e,t,r=x){return{rawContentHeight:e,spacerHeight:Math.min(e,r),viewportHeight:t,capped:e>r}}(o,r,a),d=function(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,n=t.rawContentHeight-t.viewportHeight;if(r<=0||n<=0)return e;const i=e*n/r;return i<0?0:i>n?n:i}(n,c);let u=Math.floor(d/i)-l;u<0&&(u=0);let p=u+s+2*l;return p>t&&(p=t),p===t&&u>0&&(u=Math.max(0,p-s-2*l)),{start:u,end:p,offsetY:u*i,totalHeight:c.spacerHeight,rawContentHeight:o}}function E(e,t,r,n,i,l){const{field:a,column:s}=t,o=function(e){if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-filter-item-height");if(t&&t.trim()){const e=parseFloat(t);if(!isNaN(e)&&e>0)return e}}return 28}(e),c=e=>{if(null==e)return"(Blank)";if(s.format&&!s.filterValue){const t=s.format(e,void 0);if(t)return t}return String(e)};r=r.slice().sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:c(e).localeCompare(c(t)));const d=document.createElement("div");d.className="tbw-filter-search";const u=document.createElement("input");u.type="text",u.placeholder="Search...",u.className="tbw-filter-search-input",u.value=l.get(a)??"",d.appendChild(u),e.appendChild(d);const p=document.createElement("div");p.className="tbw-filter-actions";const f=document.createElement("label");f.className="tbw-filter-value-item",f.style.padding="0",f.style.margin="0";const h=document.createElement("input");h.type="checkbox",h.className="tbw-filter-checkbox";const b=document.createElement("span");b.textContent="Select All",f.appendChild(h),f.appendChild(b),p.appendChild(f);const g=/* @__PURE__ */new Map;r.forEach(e=>{const t=null==e?"__null__":String(e);g.set(t,!n.has(e))});const m=()=>{const e=[...g.values()],t=e.every(e=>e),r=e.every(e=>!e);h.checked=t,h.indeterminate=!t&&!r};h.addEventListener("change",()=>{const e=h.checked;for(const t of g.keys())g.set(t,e);m(),S()}),m(),e.appendChild(p);const v=document.createElement("div");v.className="tbw-filter-values";const w=document.createElement("div");w.className="tbw-filter-values-spacer",v.appendChild(w);const y=document.createElement("div");y.className="tbw-filter-values-content",v.appendChild(y);let x=[];const E=(e,t)=>{const r=c(e),n=null==e?"__null__":String(e),i=document.createElement("label");i.className="tbw-filter-value-item",i.style.position="absolute",i.style.top=`calc(var(--tbw-filter-item-height, 28px) * ${t})`,i.style.left="0",i.style.right="0",i.style.boxSizing="border-box";const l=document.createElement("input");l.type="checkbox",l.className="tbw-filter-checkbox",l.checked=g.get(n)??!0,l.dataset.value=n,l.addEventListener("change",()=>{g.set(n,l.checked),m()});const a=document.createElement("span");return a.textContent=r,i.appendChild(l),i.appendChild(a),i},S=()=>{const e=x.length,t=v.clientHeight,r=v.scrollTop;if(w.style.height=e*o+"px",e<=50/3)return y.innerHTML="",y.style.transform="translateY(0px)",void x.forEach((e,t)=>{y.appendChild(E(e,t))});const n=C({totalRows:e,viewportHeight:t,scrollTop:r,rowHeight:o,overscan:3});y.style.transform=`translateY(${n.offsetY}px)`,y.innerHTML="";for(let i=n.start;i<n.end;i++)y.appendChild(E(x[i],i-n.start))},k=e=>{const t=i.caseSensitive??!1,n=t?e:e.toLowerCase();if(x=r.filter(r=>{const i=c(r),l=t?i:i.toLowerCase();return!e||l.includes(n)}),x.sort((e,t)=>{const r=null==e?"__null__":String(e),n=null==t?"__null__":String(t),i=g.get(r)??!0;return i!==(g.get(n)??!0)?i?-1:1:"number"==typeof e&&"number"==typeof t?e-t:c(e).localeCompare(c(t))}),0===x.length){w.style.height="0px",y.innerHTML="";const e=document.createElement("div");return e.className="tbw-filter-no-match",e.textContent="No matching values",void y.appendChild(e)}S()};let F;v.addEventListener("scroll",()=>{x.length>0&&S()},{passive:!0}),k(u.value),e.appendChild(v),u.addEventListener("input",()=>{clearTimeout(F),F=setTimeout(()=>{l.set(a,u.value),k(u.value)},i.debounceMs??150)});const A=document.createElement("div");A.className="tbw-filter-buttons";const N=document.createElement("button");N.type="button",N.className="tbw-filter-apply-btn",N.textContent="Apply",N.addEventListener("click",()=>{const e=[];for(const[t,n]of g)if(!n)if("__null__"===t)e.push(null);else{const n=r.find(e=>String(e)===t);e.push(void 0!==n?n:t)}t.applySetFilter(e)}),A.appendChild(N);const T=document.createElement("button");T.type="button",T.className="tbw-filter-clear-btn",T.textContent="Clear Filter",T.addEventListener("click",()=>{t.clearFilter()}),A.appendChild(T),e.appendChild(A)}function S(e,t){if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);return isNaN(r)?t:r}return t}class k extends v{static manifest={events:[{type:"filter-change",description:"Emitted when filter criteria change. Broadcast to both DOM consumers and plugin bus."}],queries:[{type:"getContextMenuItems",description:"Contributes filter-related items to the header context menu"}]};name="filtering";styles='@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s,display 0s allow-discrete;color:inherit;vertical-align:middle;transition-behavior:allow-discrete}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1;visibility:visible;display:inline-flex}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}tbw-grid .header-row .cell:hover .tbw-filter-btn,tbw-grid .header-row .cell.filtered .tbw-filter-btn{display:inline-flex;visibility:visible}}';get defaultConfig(){return{debounceMs:300,caseSensitive:!1}}isFilteringEnabled(){return!1!==this.grid.effectiveConfig?.filterable}isColumnFilterable(e){return!!this.isFilteringEnabled()&&!1!==e.filterable}getDataRows(){const e=this.sourceRows;if(e.length>0)return e;const t=this.rows;return 0===t.length?t:t.filter(e=>null!=e&&!0!==e.__loading)}getFilterValues(){const e=this.grid.effectiveConfig?.columns;if(!e)return;let t;for(const r of e)if(r.field)if(r.filterValue)t||(t=/* @__PURE__ */new Map),t.set(r.field,r.filterValue);else if(r.valueAccessor){t||(t=/* @__PURE__ */new Map);const e=r;t.set(r.field,(t,r)=>c(r,e))}return t}filters=/* @__PURE__ */new Map;cachedResult=null;cacheKey=null;cachedInputSpot=null;openPanelField=null;panelElement=null;panelAnchorElement=null;panelButtonElement=null;searchText=/* @__PURE__ */new Map;excludedValues=/* @__PURE__ */new Map;panelAbortController=null;globalStylesInjected=!1;columnLookup=null;columnLookupRef=null;getColumnByField(e){const t=this.grid.effectiveConfig?.columns;if(!t)return;let r=this.columnLookup;if(t!==this.columnLookupRef||!r){r=/* @__PURE__ */new Map;for(const e of t)e.field&&r.set(e.field,e);this.columnLookup=r,this.columnLookupRef=t}return r.get(e)}computeSelected(){const t={},r=[];for(const[e,n]of this.filters)if("set"===n.type)if("in"===n.operator&&Array.isArray(n.value))t[e]=n.value;else if("notIn"===n.operator){const t=this.getColumnByField(e),n=t?.filterValue??(t?.valueAccessor?(e,r)=>c(r,t):void 0);r.push({field:e,filterValue:n})}if(r.length>0){const n=function(t,r){const n=/* @__PURE__ */new Map;for(const{field:e,filterValue:l}of r)n.set(e,{values:/* @__PURE__ */new Set,hasBlank:!1,hasExtractor:!!l});for(const e of t)for(const{field:t,filterValue:i}of r){const r=n.get(t),l=e[t];if(i){const t=i(l,e);if(Array.isArray(t)){0===t.length&&(r.hasBlank=!0);for(const e of t)null!=e&&r.values.add(e)}else null!=t?r.values.add(t):r.hasBlank=!0}else null!=l&&""!==l?r.values.add(l):r.hasBlank=!0}const i=/* @__PURE__ */new Map;for(const[l,{values:a,hasBlank:s}]of n)s&&a.add(e),i.set(l,[...a].sort((e,t)=>"number"==typeof e&&"number"==typeof t?e-t:String(e).localeCompare(String(t))));return i}(this.getDataRows(),r);for(const{field:e}of r){const r=this.excludedValues.get(e),i=n.get(e)??[];t[e]=r?i.filter(e=>!r.has(e)):i}}return t}syncExcludedValues(t,r){if(r)if("set"===r.type&&"notIn"===r.operator&&Array.isArray(r.value))this.excludedValues.set(t,new Set(r.value));else if("set"===r.type&&"in"===r.operator&&Array.isArray(r.value)){const n=this.getDataRows();if(!n||0===n.length)return void this.excludedValues.delete(t);const i=r.value,l=new Set(i.map(t=>null==t?e:t)),a=this.getUniqueValues(t),s=new Set(a.filter(e=>!l.has(e)));this.excludedValues.set(t,s)}else"set"===r.type&&this.excludedValues.delete(t);else this.excludedValues.delete(t)}attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,this.columnLookup=null,this.columnLookupRef=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}handleQuery(e){if("filter:get-model"===e.type){if(!this.filters.size)return;return Object.fromEntries(this.filters)}if("getContextMenuItems"===e.type){const t=e.context;if(!t.isHeader)return;const r=t.column;if(!r?.field)return;if(!this.isFilteringEnabled())return;if(!this.isColumnFilterable(r))return;const n=[],i=this.isFieldFiltered(r.field),l=this.filters.size>0;return i&&n.push({id:"filtering/clear-column-filter",label:"Clear Filter",icon:"✕",order:20,action:()=>this.clearFieldFilter(r.field)}),l&&n.push({id:"filtering/clear-all-filters",label:"Clear All Filters",icon:"✕",order:21,disabled:!l,action:()=>this.clearAllFilters()}),n.length>0?n:void 0}}processRows(e){if(!this.filters.size)return e;const t=[...this.filters.values()];if(this.config.filterHandler)return this.cachedResult?this.cachedResult:e;const n=(i=t,JSON.stringify(i.map(e=>({field:e.field,operator:e.operator,value:e.value,valueTo:e.valueTo}))));var i;const l={len:e.length,first:e[0],mid:e[Math.floor(e.length/2)],last:e[e.length-1]},a=null!=this.cachedInputSpot&&l.len===this.cachedInputSpot.len&&l.first===this.cachedInputSpot.first&&l.mid===this.cachedInputSpot.mid&&l.last===this.cachedInputSpot.last;if(this.cacheKey===n&&this.cachedResult&&a)return this.cachedResult;if(!a)for(const[r,o]of this.filters)"set"===o.type&&"in"===o.operator&&this.syncExcludedValues(r,o);const s=r(e,t,this.config.caseSensitive,this.getFilterValues());return this.cachedResult=s,this.cacheKey=n,this.cachedInputSpot=l,s}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(e=>{const t=e.getAttribute("data-col");if(null===t)return;const r=this.visibleColumns[parseInt(t,10)];if(!r||!this.isColumnFilterable(r))return;if(!0===r.utility)return;const n=r.field;if(!n)return;const i=this.filters.has(n);let l=e.querySelector(".tbw-filter-btn");if(l){const t=l.classList.contains("active");return l.classList.toggle("active",i),e.classList.toggle("filtered",i),i?e.setAttribute("aria-description","Filtered"):e.removeAttribute("aria-description"),void(t!==i&&this.setIcon(l,i?"filterActive":"filter"))}l=document.createElement("button"),l.type="button",l.className="tbw-filter-btn",l.setAttribute("aria-label",`Filter ${r.header??n}`),this.setIcon(l,i?"filterActive":"filter"),i&&(l.classList.add("active"),e.classList.add("filtered"),e.setAttribute("aria-description","Filtered")),l.addEventListener("click",e=>{e.stopPropagation(),this.toggleFilterPanel(n,r,l)});const a=e.querySelector(".resize-handle");a?e.insertBefore(l,a):e.appendChild(l)})}setFilter(e,t,r){if(null===t)this.filters.delete(e),this.syncExcludedValues(e,null);else{const r={...t,field:e};this.filters.set(e,r),this.syncExcludedValues(e,r)}if(this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,r?.silent)this.emitPluginEvent("filter-change",{filters:[...this.filters.values()]});else{this.broadcast("filter-change",{filters:[...this.filters.values()],filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.();const r=this.getColumnByField(e)?.header??e;a(this.gridElement,s(this.gridElement,null===t?"filterCleared":"filterApplied",r))}this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e,t){this.filters.clear(),this.excludedValues.clear();for(const r of e)this.filters.set(r.field,r),this.syncExcludedValues(r.field,r);this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null,t?.silent?this.emitPluginEvent("filter-change",{filters:[...this.filters.values()]}):(this.broadcast("filter-change",{filters:[...this.filters.values()],filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()}clearAllFilters(e){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.applyFiltersInternal(e?.silent),e?.silent||a(this.gridElement,s(this.gridElement,"allFiltersCleared"))}clearFieldFilter(e,t){if(this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.applyFiltersInternal(t?.silent),!t?.silent){const t=this.getColumnByField(e)?.header??e;a(this.gridElement,s(this.gridElement,"filterCleared",t))}}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){const t=this.getColumnByField(e),r=t?.filterValue;return n(this.getDataRows(),e,r)}getStaleFilters(){const e=[];for(const[t,r]of this.filters){if("set"!==r.type)continue;const n=this.getUniqueValues(t);if("notIn"===r.operator&&Array.isArray(r.value)){const t=new Set(r.value);0===n.filter(e=>!t.has(e)).length&&e.push(r)}else if("in"===r.operator&&Array.isArray(r.value)){const t=new Set(r.value);0===n.filter(e=>t.has(e)).length&&e.push(r)}}return e}getBlankMode(e){const t=this.filters.get(e);return"blank"===t?.operator?"blanksOnly":"notBlank"===t?.operator?"nonBlanksOnly":"all"}toggleBlankFilter(e,t){if("all"===t){const t=this.filters.get(e);if(t?.valueTo&&"object"==typeof t.valueTo){const r=t.valueTo;this.setFilter(e,r)}else this.setFilter(e,null);return}const r=this.filters.get(e),n=r&&"blank"!==r.operator&&"notBlank"!==r.operator?{type:r.type,operator:r.operator,value:r.value,valueTo:r.valueTo}:r?.valueTo;this.setFilter(e,{type:r?.type??"text",operator:"blanksOnly"===t?"blank":"notBlank",value:"",valueTo:n})}copyGridThemeContext(e){const t=this.gridElement;if(!t)return;for(const n of t.classList)n.startsWith("tbw-")||"selecting"===n||e.classList.add(n);const r=t.dataset.theme;r&&(e.dataset.theme=r)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles"))return void(this.globalStylesInjected=!0);const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent="@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);right:anchor(right);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-search-input{height:var(--tbw-filter-item-height, 28px);width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-actions .tbw-filter-value-item{flex:1}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-range-inputs,.tbw-filter-date-range{display:flex;align-items:flex-end;gap:var(--tbw-spacing-sm, .375rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-group,.tbw-filter-date-group{display:flex;flex-direction:column;gap:var(--tbw-spacing-xs, .25rem);flex:1}.tbw-filter-range-label{font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)))}.tbw-filter-range-input,.tbw-filter-date-input{width:100%;height:var(--tbw-filter-item-height, 28px);padding:var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-sm, .375rem);background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-range-input:focus,.tbw-filter-date-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-range-separator{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding-bottom:var(--tbw-spacing-xs, .25rem)}.tbw-filter-blank-option{display:flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-spacing-xs, .25rem) 0;margin-bottom:var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-sm, .8125rem);cursor:pointer;-webkit-user-select:none;user-select:none}.tbw-filter-blank-checkbox{accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));margin:0;cursor:pointer}.tbw-filter-date-range.tbw-filter-disabled,.tbw-filter-range-inputs.tbw-filter-disabled,.tbw-filter-range-slider.tbw-filter-disabled{opacity:.4;pointer-events:none}.tbw-filter-range-slider{position:relative;height:24px;margin:var(--tbw-spacing-md, .5rem) 0 var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-track{position:absolute;top:50%;left:0;right:0;height:4px;background:var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-fill{position:absolute;top:50%;height:4px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-thumb{position:absolute;top:0;width:100%;height:100%;background:none;pointer-events:none;-webkit-appearance:none;appearance:none}.tbw-filter-range-thumb::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-moz-range-thumb{width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-webkit-slider-thumb:hover{transform:scale(1.1)}.tbw-filter-range-thumb::-moz-range-thumb:hover{transform:scale(1.1)}}",document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,r){if(this.openPanelField===e)return void this.closeFilterPanel();this.closeFilterPanel();const i=document.createElement("div");if(i.className="tbw-filter-panel",this.copyGridThemeContext(i),this.isAnimationEnabled&&i.classList.add("tbw-filter-panel-animated"),this.panelElement=i,this.openPanelField=e,r.classList.add("active"),this.panelButtonElement=r,this.config.valuesHandler)return i.innerHTML='<div class="tbw-filter-loading">Loading...</div>',document.body.appendChild(i),this.positionPanel(i,r),this.setupPanelCloseHandler(i,r),void this.config.valuesHandler(e,t).then(r=>{this.openPanelField===e&&this.panelElement&&(i.innerHTML="",this.renderPanelContent(e,t,i,r))});const l=t.filterValue??(t.valueAccessor?(e,r)=>c(r,t):void 0),a=n(this.getDataRows(),e,l);document.body.appendChild(i),this.positionPanel(i,r),this.renderPanelContent(e,t,i,a),this.setupPanelCloseHandler(i,r)}renderPanelContent(t,r,n,i){const l=this.filters.get(t);if("in"===l?.operator&&"set"===l.type&&Array.isArray(l.value)&&!this.excludedValues.has(t)){const r=l.value,n=new Set(r.map(t=>null==t?e:t)),a=new Set(i.filter(e=>!n.has(e)));this.excludedValues.set(t,a)}let a=this.excludedValues.get(t);a||(a=/* @__PURE__ */new Set,this.excludedValues.set(t,a));const s=this.searchText.get(t)??"",o={field:t,column:r,uniqueValues:i,excludedValues:a,searchText:s,currentFilter:this.filters.get(t),applySetFilter:(e,r)=>{this.applySetFilter(t,e,r),this.closeFilterPanel()},applyTextFilter:(e,r,n)=>{this.applyTextFilter(t,e,r,n),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(t),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let c=!1;if(this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(n,o),c=n.children.length>0),!c&&r.type){const e=this.grid.effectiveConfig.typeDefaults?.[r.type];e?.filterPanelRenderer&&(e.filterPanelRenderer(n,o),c=n.children.length>0)}if(!c){const e=r.filterType??r.type;"number"===e?function(e,t,r,n){const{field:i,column:l}=t,a=l.filterParams,s=l.editorParams,o=r.filter(e=>"number"==typeof e&&!isNaN(e)),c=o.length>0?Math.min(...o):0,d=o.length>0?Math.max(...o):100,u=S(a?.min??s?.min,c),p=S(a?.max??s?.max,d),f=a?.step??s?.step??1,h=n.get(i);let b=u,g=p;const m="blank"===h?.operator;"between"===h?.operator?(b=S(h.value,u),g=S(h.valueTo,p)):"greaterThanOrEqual"===h?.operator?b=S(h.value,u):"lessThanOrEqual"===h?.operator&&(g=S(h.value,p));const v=document.createElement("div");v.className="tbw-filter-range-inputs";const w=document.createElement("div");w.className="tbw-filter-range-group";const y=document.createElement("label");y.textContent="Min",y.className="tbw-filter-range-label";const x=document.createElement("input");x.type="number",x.className="tbw-filter-range-input",x.min=String(u),x.max=String(p),x.step=String(f),x.value=String(b),w.appendChild(y),w.appendChild(x),v.appendChild(w);const C=document.createElement("span");C.className="tbw-filter-range-separator",C.textContent="–",v.appendChild(C);const E=document.createElement("div");E.className="tbw-filter-range-group";const k=document.createElement("label");k.textContent="Max",k.className="tbw-filter-range-label";const F=document.createElement("input");F.type="number",F.className="tbw-filter-range-input",F.min=String(u),F.max=String(p),F.step=String(f),F.value=String(g),E.appendChild(k),E.appendChild(F),v.appendChild(E),e.appendChild(v);const A=document.createElement("div");A.className="tbw-filter-range-slider";const N=document.createElement("div");N.className="tbw-filter-range-track";const T=document.createElement("div");T.className="tbw-filter-range-fill";const R=document.createElement("input");R.type="range",R.className="tbw-filter-range-thumb tbw-filter-range-thumb-min",R.min=String(u),R.max=String(p),R.step=String(f),R.value=String(b);const L=document.createElement("input");L.type="range",L.className="tbw-filter-range-thumb tbw-filter-range-thumb-max",L.min=String(u),L.max=String(p),L.step=String(f),L.value=String(g),A.appendChild(N),A.appendChild(T),A.appendChild(R),A.appendChild(L),e.appendChild(A);const P=document.createElement("label");P.className="tbw-filter-blank-option";const M=document.createElement("input");M.type="checkbox",M.className="tbw-filter-blank-checkbox",M.checked=m;const _=document.createTextNode("Blank");P.appendChild(M),P.appendChild(_);const I=e=>{x.disabled=e,F.disabled=e,R.disabled=e,L.disabled=e,v.classList.toggle("tbw-filter-disabled",e),A.classList.toggle("tbw-filter-disabled",e)};I(m),M.addEventListener("change",()=>{I(M.checked)}),e.appendChild(P);const q=()=>{const e=parseFloat(R.value),t=parseFloat(L.value),r=p-u,n=(e-u)/r*100,i=(t-u)/r*100;T.style.left=`${n}%`,T.style.width=i-n+"%"};R.addEventListener("input",()=>{const e=Math.min(parseFloat(R.value),parseFloat(L.value));R.value=String(e),x.value=String(e),q()}),L.addEventListener("input",()=>{const e=Math.max(parseFloat(L.value),parseFloat(R.value));L.value=String(e),F.value=String(e),q()}),x.addEventListener("input",()=>{const e=parseFloat(x.value);let t=Number.isFinite(e)?e:u;t=Math.max(u,Math.min(t,parseFloat(F.value))),R.value=String(t),q()}),F.addEventListener("input",()=>{const e=parseFloat(F.value);let t=Number.isFinite(e)?e:p;t=Math.min(p,Math.max(t,parseFloat(x.value))),L.value=String(t),q()}),q();const V=document.createElement("div");V.className="tbw-filter-buttons";const B=document.createElement("button");B.type="button",B.className="tbw-filter-apply-btn",B.textContent="Apply",B.addEventListener("click",()=>{if(M.checked)return void t.applyTextFilter("blank","");const e=parseFloat(x.value),r=parseFloat(F.value),n=Number.isFinite(e)?e:u,i=Number.isFinite(r)?r:p;n!==u||i!==p?t.applyTextFilter("between",n,i):t.clearFilter()}),V.appendChild(B);const H=document.createElement("button");H.type="button",H.className="tbw-filter-clear-btn",H.textContent="Clear Filter",H.addEventListener("click",()=>{t.clearFilter()}),V.appendChild(H),e.appendChild(V)}(n,o,i,this.filters):"date"===e?function(e,t,r,n){const{field:i,column:l}=t,a=l.filterParams,s=l.editorParams,o=r.filter(e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e))).map(e=>e instanceof Date?e:new Date(e)).filter(e=>!isNaN(e.getTime())),c=o.length>0?new Date(Math.min(...o.map(e=>e.getTime()))):null,d=o.length>0?new Date(Math.max(...o.map(e=>e.getTime()))):null,u=y(a?.min)||y(s?.min)||w(c),p=y(a?.max)||y(s?.max)||w(d),f=n.get(i);let h="",b="";const g="blank"===f?.operator;"between"===f?.operator?(h=y(f.value)||"",b=y(f.valueTo)||""):"greaterThanOrEqual"===f?.operator?h=y(f.value)||"":"lessThanOrEqual"===f?.operator&&(b=y(f.value)||"");const m=document.createElement("div");m.className="tbw-filter-date-range";const v=document.createElement("div");v.className="tbw-filter-date-group";const x=document.createElement("label");x.textContent="From",x.className="tbw-filter-range-label";const C=document.createElement("input");C.type="date",C.className="tbw-filter-date-input",u&&(C.min=u),p&&(C.max=p),C.value=h,v.appendChild(x),v.appendChild(C),m.appendChild(v);const E=document.createElement("span");E.className="tbw-filter-range-separator",E.textContent="–",m.appendChild(E);const S=document.createElement("div");S.className="tbw-filter-date-group";const k=document.createElement("label");k.textContent="To",k.className="tbw-filter-range-label";const F=document.createElement("input");F.type="date",F.className="tbw-filter-date-input",u&&(F.min=u),p&&(F.max=p),F.value=b,S.appendChild(k),S.appendChild(F),m.appendChild(S),e.appendChild(m);const A=document.createElement("label");A.className="tbw-filter-blank-option";const N=document.createElement("input");N.type="checkbox",N.className="tbw-filter-blank-checkbox",N.checked=g;const T=document.createTextNode("Show only blank");A.appendChild(N),A.appendChild(T);const R=e=>{C.disabled=e,F.disabled=e,m.classList.toggle("tbw-filter-disabled",e)};R(g),N.addEventListener("change",()=>{R(N.checked)}),e.appendChild(A);const L=document.createElement("div");L.className="tbw-filter-buttons";const P=document.createElement("button");P.type="button",P.className="tbw-filter-apply-btn",P.textContent="Apply",P.addEventListener("click",()=>{if(N.checked)return void t.applyTextFilter("blank","");const e=C.value,r=F.value;e&&r?t.applyTextFilter("between",e,r):e?t.applyTextFilter("greaterThanOrEqual",e):r?t.applyTextFilter("lessThanOrEqual",r):t.clearFilter()}),L.appendChild(P);const M=document.createElement("button");M.type="button",M.className="tbw-filter-clear-btn",M.textContent="Clear Filter",M.addEventListener("click",()=>{t.clearFilter()}),L.appendChild(M),e.appendChild(L)}(n,o,i,this.filters):E(n,o,i,a,{caseSensitive:this.config.caseSensitive,debounceMs:this.config.debounceMs},this.searchText)}}setupPanelCloseHandler(e,t){this.panelAbortController=new AbortController;const{signal:r}=this.panelAbortController;setTimeout(()=>{r.aborted||document.addEventListener("click",r=>{e.contains(r.target)||r.target===t||this.closeFilterPanel()},{signal:r})},0)}closeFilterPanel(){const e=this.panelElement;if(e&&(e.remove(),this.panelElement=null),this.panelAnchorElement&&(this.panelAnchorElement.style.anchorName="",this.panelAnchorElement=null),this.panelButtonElement){const e=this.openPanelField;e&&this.filters.has(e)||this.panelButtonElement.classList.remove("active"),this.panelButtonElement=null}this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}static supportsAnchorPositioning=null;static checkAnchorPositioningSupport(){return null===k.supportsAnchorPositioning&&(k.supportsAnchorPositioning=CSS.supports("anchor-name","--test")),k.supportsAnchorPositioning}positionPanel(e,t){const r=t.closest(".header-row")??t;if(r.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=r,k.checkAnchorPositioningSupport()){r.style.anchorName="",t.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=t;const n=r.getBoundingClientRect().bottom-t.getBoundingClientRect().bottom;return e.style.marginTop=`${n+4}px`,void requestAnimationFrame(()=>{const r=e.getBoundingClientRect(),n=t.getBoundingClientRect();r.top<n.top&&e.classList.add("tbw-filter-panel-above")})}const n=r.getBoundingClientRect(),i=t.getBoundingClientRect();e.style.position="fixed",e.style.top=`${n.bottom+4}px`,e.style.left=`${i.right}px`,requestAnimationFrame(()=>{const t=e.getBoundingClientRect();e.style.left=i.right-t.width+"px";i.right-t.width<8&&(e.style.left=`${i.left}px`),t.bottom>window.innerHeight-8&&(e.style.top=n.top-t.height-4+"px",e.classList.add("tbw-filter-panel-above"))})}applySetFilter(e,t,r){if(this.excludedValues.set(e,new Set(t)),0===t.length)this.filters.delete(e);else{const n=this.filters.get(e);if("in"===n?.operator){const n=this.getUniqueValues(e),i=new Set(t),l=n.filter(e=>!i.has(e));this.filters.set(e,{field:e,type:"set",operator:"in",value:l,...void 0!==r&&{valueTo:r}})}else this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t,...void 0!==r&&{valueTo:r}})}this.applyFiltersInternal()}applyTextFilter(e,t,r,n){const i=this.getColumnByField(e),l=i?.filterType??i?.type??"text";this.filters.set(e,{field:e,type:l,operator:t,value:r,valueTo:n}),this.applyFiltersInternal()}applyFiltersInternal(e){this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null;const t=[...this.filters.values()];if(this.config.filterHandler){this.gridElement.setAttribute("aria-busy","true");const r=this.config.filterHandler(t,this.sourceRows),n=r=>{this.gridElement.removeAttribute("aria-busy"),this.cachedResult=r,this.grid.rows=r,e?this.emitPluginEvent("filter-change",{filters:t}):(this.broadcast("filter-change",{filters:t,filteredRowCount:r.length,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()};return void(r&&"function"==typeof r.then?r.then(n):n(r))}e?this.emitPluginEvent("filter-change",{filters:t}):(this.broadcast("filter-change",{filters:t,filteredRowCount:0,selected:this.computeSelected()}),this.config.trackColumnState&&this.grid.requestStateChange?.()),this.requestRender()}getColumnState(e){if(!this.config.trackColumnState)return;const t=this.filters.get(e);return t?{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}:void 0}applyColumnState(e,t){if(!this.config.trackColumnState)return;if(!t.filter)return void this.filters.delete(e);const r={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,r),this.cachedResult=null,this.cacheKey=null,this.cachedInputSpot=null}}export{e as BLANK_FILTER_VALUE,k as FilteringPlugin};
2
2
  //# sourceMappingURL=index.js.map