@cngx/ui 0.1.0-rc.7 → 0.1.0-rc.9

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 (101) hide show
  1. package/README.md +0 -1
  2. package/a11y/README.md +11 -5
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +227 -0
  7. package/data-grid-accordion/README.md +76 -2
  8. package/feedback/README.md +40 -0
  9. package/fesm2022/cngx-ui-a11y.mjs +189 -57
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +120 -36
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +121 -56
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +228 -108
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +204 -62
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +395 -119
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +209 -40
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -101
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +1074 -460
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-mat-accordion.mjs +76 -7
  32. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  34. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  36. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-tabs.mjs +555 -204
  38. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  40. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-paginator.mjs +553 -198
  42. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  43. package/fesm2022/cngx-ui-sidenav.mjs +344 -109
  44. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-skeleton.mjs +4 -16
  46. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-speak.mjs +107 -8
  48. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-stat-card.mjs +146 -46
  50. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-stepper.mjs +234 -99
  52. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-tabs.mjs +88 -25
  54. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-timeline.mjs +98 -23
  56. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-toc.mjs +101 -33
  58. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  59. package/fesm2022/cngx-ui.mjs +15 -20
  60. package/fesm2022/cngx-ui.mjs.map +1 -1
  61. package/mat-paginator/README.md +9 -2
  62. package/mat-tabs/README.md +30 -6
  63. package/mat-tabs/styles/mat-tabs.css +188 -42
  64. package/overlay/README.md +9 -4
  65. package/package.json +31 -7
  66. package/paginator/README.md +8 -4
  67. package/schematics/collection.json +9 -0
  68. package/schematics/ng-add/index.js +9 -0
  69. package/schematics/ng-add/schema.json +91 -0
  70. package/schematics/package.json +3 -0
  71. package/sidenav/README.md +33 -11
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +14 -2
  74. package/timeline/README.md +1 -1
  75. package/toc/README.md +4 -1
  76. package/types/cngx-ui-a11y.d.ts +121 -30
  77. package/types/cngx-ui-accordion.d.ts +100 -28
  78. package/types/cngx-ui-action-button.d.ts +44 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +167 -60
  80. package/types/cngx-ui-chart-panel.d.ts +122 -18
  81. package/types/cngx-ui-collection.d.ts +157 -55
  82. package/types/cngx-ui-command-palette.d.ts +297 -183
  83. package/types/cngx-ui-context-menu.d.ts +140 -10
  84. package/types/cngx-ui-data-grid-accordion.d.ts +278 -39
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +605 -59
  87. package/types/cngx-ui-mat-accordion.d.ts +30 -1
  88. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  89. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  90. package/types/cngx-ui-mat-tabs.d.ts +250 -34
  91. package/types/cngx-ui-overlay.d.ts +56 -10
  92. package/types/cngx-ui-paginator.d.ts +425 -136
  93. package/types/cngx-ui-sidenav.d.ts +248 -74
  94. package/types/cngx-ui-skeleton.d.ts +6 -7
  95. package/types/cngx-ui-speak.d.ts +118 -5
  96. package/types/cngx-ui-stat-card.d.ts +117 -33
  97. package/types/cngx-ui-stepper.d.ts +88 -49
  98. package/types/cngx-ui-tabs.d.ts +6 -4
  99. package/types/cngx-ui-timeline.d.ts +35 -11
  100. package/types/cngx-ui-toc.d.ts +93 -16
  101. package/types/cngx-ui.d.ts +7 -4
@@ -1,14 +1,35 @@
1
1
  import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, inject, TemplateRef, Directive, PLATFORM_ID, input, booleanAttribute, output, viewChild, contentChild, signal, computed, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, afterNextRender, makeEnvironmentProviders } from '@angular/core';
3
+ import { InjectionToken, inject, TemplateRef, Directive, PLATFORM_ID, input, booleanAttribute, output, viewChild, contentChild, signal, computed, DestroyRef, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, afterNextRender, makeEnvironmentProviders } from '@angular/core';
4
+ import { arrayEqual, cngxDevWarn, CngxRuntimeError } from '@cngx/utils';
4
5
  import { injectMediaQuery, CngxScrollSpy } from '@cngx/common/layout';
6
+ import { createFilledOverrideMerge, createOverrideMerge } from '@cngx/core/utils';
7
+ import { createLanguageSection } from '@cngx/core/i18n';
5
8
  import { outputToObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
6
9
  import { Router, ActivatedRoute } from '@angular/router';
7
10
 
8
11
  /**
9
- * Library defaults for the toc configuration cascade. English by default per
10
- * `feedback_en_default_locale`; locale overrides ride the `withTocAriaLabels`
11
- * feature. The spy defaults (`rootMargin` / `threshold`) mirror
12
+ * The English toc section: the single source of the toc's English copy. The
13
+ * `CNGX_TOC_CONFIG` labels default to it.
14
+ *
15
+ * @category ui/toc/i18n
16
+ * @since 0.1.0
17
+ * @relatedTo CNGX_TOC_CONFIG
18
+ */
19
+ const CNGX_TOC_LANGUAGE_EN = {
20
+ nav: 'On this page',
21
+ };
22
+
23
+ /**
24
+ * @internal The toc section of the active pack over the English section,
25
+ * shared app-wide. Consumers override copy through `withTocAriaLabels`.
26
+ */
27
+ const injectTocSiteCopy = createLanguageSection('toc', CNGX_TOC_LANGUAGE_EN);
28
+
29
+ /**
30
+ * Library defaults for the toc configuration cascade. Carries no copy: the
31
+ * `ariaLabels` defaults are the `toc` section of the language pack; single
32
+ * keys ride the `withTocAriaLabels` feature. The spy defaults (`rootMargin` / `threshold`) mirror
12
33
  * `CngxScrollSpy`'s own input defaults so an un-configured toc tracks
13
34
  * scrolling identically to a hand-wired spy.
14
35
  *
@@ -20,9 +41,6 @@ import { Router, ActivatedRoute } from '@angular/router';
20
41
  * @internal
21
42
  */
22
43
  const CNGX_TOC_DEFAULTS = {
23
- ariaLabels: {
24
- nav: 'On this page',
25
- },
26
44
  scrollBehavior: 'smooth',
27
45
  spy: {
28
46
  rootMargin: '0px',
@@ -73,6 +91,19 @@ const CNGX_TOC_CONFIG = new InjectionToken('CNGX_TOC_CONFIG', {
73
91
  function injectTocConfig() {
74
92
  return inject(CNGX_TOC_CONFIG);
75
93
  }
94
+ /**
95
+ * The resolved accessible names of the toc config in scope, every key the
96
+ * config leaves unset (also a key an override sets to `undefined`) filled from
97
+ * the `toc` section of the active pack, as a Signal that follows a runtime
98
+ * language switch. Runs in injection context; read it inside a `computed()`, a template
99
+ * or a handler.
100
+ *
101
+ * @category ui/toc
102
+ * @since 0.1.0
103
+ */
104
+ function injectTocAriaLabels() {
105
+ return createFilledOverrideMerge(injectTocSiteCopy(), injectTocConfig().ariaLabels);
106
+ }
76
107
 
77
108
  /**
78
109
  * Per-item template slot for `CngxToc`. Project an `<ng-template cngxTocItem>`
@@ -131,10 +162,6 @@ const CNGX_TOC = new InjectionToken('CNGX_TOC');
131
162
  const EMPTY_IDS = [];
132
163
  /** Shared empty outline so the pre-scan / no-headings state is reference-stable. */
133
164
  const EMPTY_ITEMS = [];
134
- /** Element-wise string-array compare - the shared comparator for both the flat-id list and the active trail. */
135
- function idsEqual(a, b) {
136
- return a.length === b.length && a.every((value, index) => value === b[index]);
137
- }
138
165
  /**
139
166
  * Structural compare of two discovered outlines (id + label + nesting). Guards
140
167
  * the `discovered` signal so a re-scan of unchanged headings keeps the same
@@ -178,10 +205,12 @@ function itemsEqual(a, b) {
178
205
  * @relatedTo CngxScrollSpy, CngxTocRouterSync, CngxSidenav
179
206
  * <example-url>http://localhost:4200/#/ui/toc/basic/on-this-page-rail</example-url>
180
207
  * <example-url>http://localhost:4200/#/ui/toc/auto/heading-auto-discovery</example-url>
208
+ * @slot cngxTocItem Replaces the plain label inside each item's link at every depth, ahead of CNGX_TOC_CONFIG.templates.item; gets the item as $implicit, plus active and the zero-based depth.
181
209
  */
182
210
  class CngxToc {
183
211
  doc = inject(DOCUMENT);
184
212
  cfg = injectTocConfig();
213
+ ariaLabels = injectTocAriaLabels();
185
214
  reducedMotion = injectMediaQuery('(prefers-reduced-motion: reduce)');
186
215
  isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
187
216
  /**
@@ -218,26 +247,36 @@ class CngxToc {
218
247
  discovered = signal(EMPTY_ITEMS, { ...(ngDevMode ? { debugName: "discovered" } : /* istanbul ignore next */ {}), equal: itemsEqual });
219
248
  /** The outline actually rendered: the discovered headings when `[autoDiscover]` is on, else `[items]`. */
220
249
  resolvedItems = computed(() => this.autoDiscover() ? this.discovered() : this.items(), ...(ngDevMode ? [{ debugName: "resolvedItems" }] : /* istanbul ignore next */ []));
221
- /** Accessible name of the `nav` landmark, from the config cascade. */
222
- navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page', ...(ngDevMode ? [{ debugName: "navLabel" }] : /* istanbul ignore next */ []));
250
+ /** Accessible name of the `nav` landmark, from the config cascade; follows a language switch. */
251
+ navLabel = computed(() => this.ariaLabels().nav, ...(ngDevMode ? [{ debugName: "navLabel" }] : /* istanbul ignore next */ []));
223
252
  /**
224
- * Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: idsEqual`
253
+ * Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: arrayEqual`
225
254
  * keeps the reference stable across same-shape re-sets so a re-render does
226
255
  * not re-create the observer.
227
256
  */
228
- flatIds = computed(() => this.collectIds(this.resolvedItems()), { ...(ngDevMode ? { debugName: "flatIds" } : /* istanbul ignore next */ {}), equal: idsEqual });
257
+ flatIds = computed(() => this.collectIds(this.resolvedItems()), { ...(ngDevMode ? { debugName: "flatIds" } : /* istanbul ignore next */ {}), equal: arrayEqual });
229
258
  constructor() {
230
259
  // Re-scan whenever the discovery inputs change. The DOM read + discovered
231
260
  // write are deferred to a microtask so no signal is written during effect
232
261
  // execution (Pillar 1) and the just-rendered content has settled - the same
233
- // queueMicrotask discipline the panel-lifecycle focus restore uses.
262
+ // queueMicrotask discipline the panel-lifecycle focus restore uses. The
263
+ // destroyed guard keeps a microtask queued right before teardown from
264
+ // scanning a detached DOM.
265
+ let destroyed = false;
266
+ inject(DestroyRef).onDestroy(() => {
267
+ destroyed = true;
268
+ });
234
269
  effect(() => {
235
270
  if (!this.autoDiscover()) {
236
271
  return;
237
272
  }
238
273
  this.contentRoot();
239
274
  this.headingSelector();
240
- queueMicrotask(() => this.refresh());
275
+ queueMicrotask(() => {
276
+ if (!destroyed) {
277
+ this.refresh();
278
+ }
279
+ });
241
280
  });
242
281
  }
243
282
  /**
@@ -252,7 +291,7 @@ class CngxToc {
252
291
  * feeding an attribute binding must not allocate a fresh array every spy
253
292
  * tick (reference_signal_architecture Equality Rule).
254
293
  */
255
- activeTrail = computed(() => this.computeTrail(), { ...(ngDevMode ? { debugName: "activeTrail" } : /* istanbul ignore next */ {}), equal: idsEqual });
294
+ activeTrail = computed(() => this.computeTrail(), { ...(ngDevMode ? { debugName: "activeTrail" } : /* istanbul ignore next */ {}), equal: arrayEqual });
256
295
  /** Resolved item template: instance slot -> config default -> built-in label. */
257
296
  resolvedItemTpl = computed(() => this.itemSlot()?.templateRef ?? this.cfg.templates?.item ?? null, ...(ngDevMode ? [{ debugName: "resolvedItemTpl" }] : /* istanbul ignore next */ []));
258
297
  /**
@@ -421,11 +460,11 @@ class CngxToc {
421
460
  return { id: node.id, label: node.label, children: node.children.map((child) => this.freeze(child)) };
422
461
  }
423
462
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToc, deps: [], target: i0.ɵɵFactoryTarget.Component });
424
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxToc, isStandalone: true, selector: "cngx-toc", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, autoDiscover: { classPropertyName: "autoDiscover", publicName: "autoDiscover", isSignal: true, isRequired: false, transformFunction: null }, headingSelector: { classPropertyName: "headingSelector", publicName: "headingSelector", isSignal: true, isRequired: false, transformFunction: null }, contentRoot: { classPropertyName: "contentRoot", publicName: "contentRoot", isSignal: true, isRequired: false, transformFunction: null }, rootMargin: { classPropertyName: "rootMargin", publicName: "rootMargin", isSignal: true, isRequired: false, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated" }, providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], queries: [{ propertyName: "itemSlot", first: true, predicate: CngxTocItemSlot, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "spy", first: true, predicate: CngxScrollSpy, descendants: true, isSignal: true }], ngImport: i0, template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxScrollSpy, selector: "[cngxScrollSpy]", inputs: ["cngxScrollSpy", "threshold", "root", "rootMargin"], outputs: ["activeIdChange"], exportAs: ["cngxScrollSpy"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
463
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxToc, isStandalone: true, selector: "cngx-toc", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, autoDiscover: { classPropertyName: "autoDiscover", publicName: "autoDiscover", isSignal: true, isRequired: false, transformFunction: null }, headingSelector: { classPropertyName: "headingSelector", publicName: "headingSelector", isSignal: true, isRequired: false, transformFunction: null }, contentRoot: { classPropertyName: "contentRoot", publicName: "contentRoot", isSignal: true, isRequired: false, transformFunction: null }, rootMargin: { classPropertyName: "rootMargin", publicName: "rootMargin", isSignal: true, isRequired: false, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated" }, providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], queries: [{ propertyName: "itemSlot", first: true, predicate: CngxTocItemSlot, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "spy", first: true, predicate: CngxScrollSpy, descendants: true, isSignal: true }], ngImport: i0, template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-text, oklch(.2 .01 250)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}@media(forced-colors:active){.cngx-toc__link{border-inline-start-color:Canvas}.cngx-toc__link[aria-current]{border-inline-start-color:Highlight}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxScrollSpy, selector: "[cngxScrollSpy]", inputs: ["cngxScrollSpy", "threshold", "root", "rootMargin"], outputs: ["activeIdChange"], exportAs: ["cngxScrollSpy"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
425
464
  }
426
465
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToc, decorators: [{
427
466
  type: Component,
428
- args: [{ selector: 'cngx-toc', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, CngxScrollSpy], providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}\n"] }]
467
+ args: [{ selector: 'cngx-toc', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, CngxScrollSpy], providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-text, oklch(.2 .01 250)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}@media(forced-colors:active){.cngx-toc__link{border-inline-start-color:Canvas}.cngx-toc__link[aria-current]{border-inline-start-color:Highlight}}\n"] }]
429
468
  }], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], autoDiscover: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoDiscover", required: false }] }], headingSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingSelector", required: false }] }], contentRoot: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentRoot", required: false }] }], rootMargin: [{ type: i0.Input, args: [{ isSignal: true, alias: "rootMargin", required: false }] }], threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }], activated: [{ type: i0.Output, args: ["activated"] }], spy: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxScrollSpy), { isSignal: true }] }], itemSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTocItemSlot), { isSignal: true }] }] } });
430
469
 
431
470
  /**
@@ -437,8 +476,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
437
476
  *
438
477
  * @internal
439
478
  */
440
- function warnRouterAbsent(directive, enables) {
441
- console.warn(`${directive}: no Router available - directive is a no-op. ` +
479
+ function warnRouterAbsent(selector, enables) {
480
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
481
+ return;
482
+ }
483
+ cngxDevWarn('CNGX3001', `[${selector}] no Router / ActivatedRoute available - directive is a no-op. ` +
442
484
  `Provide @angular/router via provideRouter(...) to enable ${enables}.`);
443
485
  }
444
486
  /**
@@ -462,21 +504,26 @@ function warnRouterAbsent(directive, enables) {
462
504
  * <example-url>http://localhost:4200/#/ui/toc/router/fragment-deep-link</example-url>
463
505
  */
464
506
  class CngxTocRouterSync {
465
- toc = inject(CNGX_TOC, { host: true });
507
+ toc = injectRouterSyncToc();
466
508
  router = inject(Router, { optional: true });
467
509
  route = inject(ActivatedRoute, { optional: true });
468
510
  constructor() {
469
511
  if (!this.router || !this.route) {
470
- afterNextRender(() => warnRouterAbsent('CngxTocRouterSync', 'fragment deep-linking'));
512
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
513
+ afterNextRender(() => warnRouterAbsent('cngxTocRouterSync', 'fragment deep-linking'));
514
+ }
471
515
  return;
472
516
  }
473
517
  const router = this.router;
474
518
  // Write the fragment on every activation. replaceUrl keeps a scroll-driven
475
- // rail from pushing a history entry per section.
519
+ // rail from pushing a history entry per section; 'merge' keeps the query
520
+ // params a bare fragment navigate would otherwise wipe.
476
521
  outputToObservable(this.toc.activated)
477
522
  .pipe(takeUntilDestroyed())
478
523
  .subscribe((item) => {
479
- void router.navigate([], { fragment: item.id, replaceUrl: true });
524
+ router
525
+ .navigate([], { fragment: item.id, replaceUrl: true, queryParamsHandling: 'merge' })
526
+ .catch(() => undefined);
480
527
  });
481
528
  // One-shot deep-link scroll: read the fragment present at load and bring
482
529
  // that section into view after the first render.
@@ -501,10 +548,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
501
548
  standalone: true,
502
549
  }]
503
550
  }], ctorParameters: () => [] });
551
+ function injectRouterSyncToc() {
552
+ const toc = inject(CNGX_TOC, { host: true, optional: true });
553
+ if (!toc) {
554
+ throw new CngxRuntimeError('CNGX3021', typeof ngDevMode !== 'undefined' &&
555
+ ngDevMode &&
556
+ '[cngxTocRouterSync] must be placed on or inside <cngx-toc>.');
557
+ }
558
+ return toc;
559
+ }
504
560
 
505
561
  /**
506
562
  * Override the toc's ARIA-string fallback - the accessible name of the `nav`
507
- * landmark that wraps the link list (default `'On this page'`).
563
+ * landmark that wraps the link list (default `'On this page'`). Pass a
564
+ * `Signal` to switch the language at runtime.
508
565
  *
509
566
  * ```ts
510
567
  * provideTocConfig(withTocAriaLabels({ nav: 'Auf dieser Seite' }));
@@ -553,10 +610,20 @@ function withTocSpy(payload) {
553
610
  * `*cngxTocItem` slot and before the built-in plain-label rendering, so every
554
611
  * un-slotted toc renders the same custom item markup.
555
612
  *
613
+ * A `TemplateRef` exists only once a view renders, so it cannot go into
614
+ * `viewProviders` or the root providers. Build the scope from the rendered
615
+ * template and hand it to `ngTemplateOutlet`:
616
+ *
556
617
  * ```ts
557
- * @Component({
558
- * viewProviders: [provideTocConfigAt(withTocTemplates({ item: myItemTpl }))],
559
- * })
618
+ * private readonly injector = inject(Injector);
619
+ * private readonly itemTpl = viewChild.required<TemplateRef<CngxTocItemContext>>('tocItem');
620
+ * protected readonly tocScope = computed(() =>
621
+ * Injector.create({
622
+ * parent: this.injector,
623
+ * providers: [provideTocConfigAt(withTocTemplates({ item: this.itemTpl() }))],
624
+ * }),
625
+ * );
626
+ * // <ng-container *ngTemplateOutlet="tocTpl; injector: tocScope()" />
560
627
  * ```
561
628
  *
562
629
  * @category ui/toc
@@ -566,6 +633,7 @@ function withTocTemplates(payload) {
566
633
  return { kind: 'templates', payload };
567
634
  }
568
635
 
636
+ const NO_ARIA_LABELS = {};
569
637
  /**
570
638
  * Reduces a list of feature objects into a partial config - last write wins
571
639
  * per sub-tree. Inner objects are spread-merged so partial overrides compose
@@ -578,7 +646,7 @@ function reduceFeatures(features) {
578
646
  for (const f of features) {
579
647
  switch (f.kind) {
580
648
  case 'ariaLabels':
581
- out.ariaLabels = { ...out.ariaLabels, ...f.payload };
649
+ out.ariaLabels = createOverrideMerge(out.ariaLabels ?? NO_ARIA_LABELS, f.payload);
582
650
  break;
583
651
  case 'scrollBehavior':
584
652
  out.scrollBehavior = f.payload.scrollBehavior;
@@ -604,7 +672,7 @@ function reduceFeatures(features) {
604
672
  */
605
673
  function mergeConfig(base, partial) {
606
674
  return {
607
- ariaLabels: { ...base.ariaLabels, ...partial.ariaLabels },
675
+ ariaLabels: createOverrideMerge(base.ariaLabels ?? NO_ARIA_LABELS, partial.ariaLabels),
608
676
  scrollBehavior: partial.scrollBehavior ?? base.scrollBehavior,
609
677
  spy: { ...base.spy, ...partial.spy },
610
678
  templates: { ...base.templates, ...partial.templates },
@@ -700,5 +768,5 @@ function provideTocConfigAt(...features) {
700
768
  * Generated bundle index. Do not edit.
701
769
  */
702
770
 
703
- export { CNGX_TOC, CNGX_TOC_CONFIG, CngxToc, CngxTocItemSlot, CngxTocRouterSync, injectTocConfig, provideTocConfig, provideTocConfigAt, withTocAriaLabels, withTocScrollBehavior, withTocSpy, withTocTemplates };
771
+ export { CNGX_TOC, CNGX_TOC_CONFIG, CNGX_TOC_DEFAULTS, CNGX_TOC_LANGUAGE_EN, CngxToc, CngxTocItemSlot, CngxTocRouterSync, injectTocAriaLabels, injectTocConfig, provideTocConfig, provideTocConfigAt, withTocAriaLabels, withTocScrollBehavior, withTocSpy, withTocTemplates };
704
772
  //# sourceMappingURL=cngx-ui-toc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-toc.mjs","sources":["../../../projects/ui/toc/config/toc.config.defaults.ts","../../../projects/ui/toc/config/inject-toc-config.ts","../../../projects/ui/toc/toc-item-slot.ts","../../../projects/ui/toc/toc-token.ts","../../../projects/ui/toc/toc.component.ts","../../../projects/ui/toc/toc.component.html","../../../projects/ui/toc/toc-router-sync.directive.ts","../../../projects/ui/toc/config/features.ts","../../../projects/ui/toc/config/provide-toc-config.ts","../../../projects/ui/toc/public-api.ts","../../../projects/ui/toc/cngx-ui-toc.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport type { CngxTocConfig } from './toc.config';\n\n/**\n * Library defaults for the toc configuration cascade. English by default per\n * `feedback_en_default_locale`; locale overrides ride the `withTocAriaLabels`\n * feature. The spy defaults (`rootMargin` / `threshold`) mirror\n * `CngxScrollSpy`'s own input defaults so an un-configured toc tracks\n * scrolling identically to a hand-wired spy.\n *\n * Exported for intra-lib consumers (`provideTocConfig` deep-merges with this\n * base) but **NOT** re-exported from `public-api.ts` - downstream consumers\n * reach the defaults via `inject(CNGX_TOC_CONFIG)` so `provideTocConfig` /\n * `provideTocConfigAt` overrides take precedence.\n *\n * @internal\n */\nexport const CNGX_TOC_DEFAULTS: CngxTocConfig = {\n ariaLabels: {\n nav: 'On this page',\n },\n scrollBehavior: 'smooth',\n spy: {\n rootMargin: '0px',\n threshold: 0.3,\n },\n};\n\n/**\n * App-wide configuration cascade for the table-of-contents organism. Resolves\n * in priority order:\n *\n * 1. Per-instance Input binding.\n * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.\n * 3. `provideTocConfig(...)` at the application root.\n * 4. Library defaults (this token's `factory`).\n *\n * `providedIn: 'root'` with a default factory means consumers never need to\n * provide the token explicitly - `inject(CNGX_TOC_CONFIG)` always resolves.\n * Consumers who want overrides call `provideTocConfig(...)` in\n * `bootstrapApplication` providers (root cascade) or `provideTocConfigAt(...)`\n * in a component's `viewProviders` (sub-tree cascade).\n *\n * @category ui/toc\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/config/toc.config.defaults.ts\n * @since 0.1.0\n */\nexport const CNGX_TOC_CONFIG = new InjectionToken<CngxTocConfig>('CNGX_TOC_CONFIG', {\n providedIn: 'root',\n factory: () => CNGX_TOC_DEFAULTS,\n});\n","import { inject } from '@angular/core';\n\nimport type { CngxTocConfig } from './toc.config';\nimport { CNGX_TOC_CONFIG } from './toc.config.defaults';\n\n/**\n * Convenience accessor for the toc configuration cascade. Runs in injection\n * context; resolves through the priority chain (per-instance Input ->\n * `provideTocConfigAt` -> `provideTocConfig` -> library defaults). Equivalent\n * to `inject(CNGX_TOC_CONFIG)` - the helper exists so consumers don't import\n * the token directly. Mirrors `injectBreadcrumbConfig`.\n *\n * ```ts\n * export class CngxToc {\n * private readonly cfg = injectTocConfig();\n * protected readonly navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page');\n * }\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function injectTocConfig(): CngxTocConfig {\n return inject(CNGX_TOC_CONFIG);\n}\n","import { Directive, inject, TemplateRef } from '@angular/core';\n\nimport type { CngxTocItemContext } from './toc.types';\n\n/**\n * Per-item template slot for `CngxToc`. Project an `<ng-template cngxTocItem>`\n * inside `<cngx-toc>` to replace the built-in plain-label rendering with\n * custom markup - the `let-` variables come out typed via\n * `ngTemplateContextGuard`:\n *\n * ```html\n * <cngx-toc [items]=\"toc\" contentRoot=\"#article\">\n * <ng-template cngxTocItem let-item let-active=\"active\" let-depth=\"depth\">\n * <span [class.is-active]=\"active\">{{ item.label }}</span>\n * @if (depth === 0) { <cngx-badge>{{ item.children?.length }}</cngx-badge> }\n * </ng-template>\n * </cngx-toc>\n * ```\n *\n * Named `CngxTocItemSlot` (not `*Directive`) per the repo's no-artifact-suffix\n * rule; the selector stays `cngxTocItem`, which is what consumers write.\n * Resolves ahead of `CNGX_TOC_CONFIG.templates.item` and the built-in label.\n *\n * @category ui/toc\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-item-slot.ts\n * @since 0.1.0\n * @relatedTo CngxToc\n * <example-url>http://localhost:4200/#/ui/toc/slots/custom-item-template</example-url>\n */\n@Directive({\n selector: 'ng-template[cngxTocItem]',\n standalone: true,\n exportAs: 'cngxTocItem',\n})\nexport class CngxTocItemSlot {\n readonly templateRef = inject<TemplateRef<CngxTocItemContext>>(TemplateRef);\n\n static ngTemplateContextGuard(\n _dir: CngxTocItemSlot,\n ctx: unknown,\n ): ctx is CngxTocItemContext {\n return true;\n }\n}\n","import { InjectionToken, type OutputRef, type Signal } from '@angular/core';\n\nimport type { CngxTocItem } from './toc.types';\n\n/**\n * Minimal contract a toc rail exposes to its collaborators (the opt-in\n * `CngxTocRouterSync` fragment directive): the active-section signal it\n * derives, the activation output it emits, and the imperative `scrollTo`\n * it owns. Injected via {@link CNGX_TOC} + `useExisting`, never by injecting\n * the concrete `CngxToc` class - that would create a cyclic type dependency\n * and block the decompose brain/skin split.\n *\n * Direction mirrors `CNGX_SIDENAV`, not `CNGX_BREADCRUMB_ITEMS_SOURCE`: the\n * rail owns the state (`activeId`, `scrollTo`) and the collaborator consumes\n * it, so the toc *provides* the token and the sync directive *injects* it.\n *\n * @category ui/toc\n * @since 0.1.0\n * @relatedTo CngxToc, CngxTocRouterSync\n */\nexport interface CngxTocContract {\n /** The section currently most visible, or `null` before the spy resolves. */\n readonly activeId: Signal<string | null>;\n /** Fires when a link is activated (click / Enter), carrying its item. */\n readonly activated: OutputRef<CngxTocItem>;\n /** Scroll the section with this id into view and move focus to it. */\n scrollTo(id: string): void;\n}\n\n/**\n * Contract token for a toc rail. `CngxToc` provides it via\n * `{ provide: CNGX_TOC, useExisting: CngxToc }`, so a collaborator injects the\n * narrow {@link CngxTocContract} instead of the concrete class.\n *\n * @category ui/toc\n * @since 0.1.0\n * @relatedTo CngxToc, CngxTocRouterSync\n */\nexport const CNGX_TOC = new InjectionToken<CngxTocContract>('CNGX_TOC');\n","import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n effect,\n inject,\n input,\n output,\n PLATFORM_ID,\n signal,\n ViewEncapsulation,\n viewChild,\n type Signal,\n} from '@angular/core';\nimport { CngxScrollSpy, injectMediaQuery } from '@cngx/common/layout';\n\nimport { injectTocConfig } from './config/inject-toc-config';\nimport { CngxTocItemSlot } from './toc-item-slot';\nimport { CNGX_TOC, type CngxTocContract } from './toc-token';\nimport type { CngxTocItem } from './toc.types';\n\n/** Shared empty result so the no-active-section trail is reference-stable. */\nconst EMPTY_IDS: readonly string[] = [];\n\n/** Shared empty outline so the pre-scan / no-headings state is reference-stable. */\nconst EMPTY_ITEMS: readonly CngxTocItem[] = [];\n\n/** Mutable node used while building the discovered tree, before it is frozen to CngxTocItem. */\ninterface MutableItem {\n id: string;\n label: string;\n children: MutableItem[];\n}\n\n/** Element-wise string-array compare - the shared comparator for both the flat-id list and the active trail. */\nfunction idsEqual(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((value, index) => value === b[index]);\n}\n\n/**\n * Structural compare of two discovered outlines (id + label + nesting). Guards\n * the `discovered` signal so a re-scan of unchanged headings keeps the same\n * reference and never re-stamps the outline outlet.\n */\nfunction itemsEqual(a: readonly CngxTocItem[], b: readonly CngxTocItem[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n const x = a[i];\n const y = b[i];\n if (x.id !== y.id || x.label !== y.label) {\n return false;\n }\n if (!itemsEqual(x.children ?? EMPTY_ITEMS, y.children ?? EMPTY_ITEMS)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * \"On this page\" navigation rail. Renders a `<nav>` of anchor links from a\n * {@link CngxTocItem} outline, tracks the most-visible section through an\n * internal {@link CngxScrollSpy}, and communicates the active link via\n * `aria-current` inside the `computed()` graph. Nested items render as\n * indented sub-lists; native link semantics and tab order stay intact (a toc\n * is a navigation landmark of links, not a treeview).\n *\n * Composition over configuration: the spy is bound in this component's own\n * template rather than via `hostDirectives`, because the organism - not the\n * consumer - owns the flat id list the spy observes, and `[cngxScrollSpy]` is\n * a required input. The spy resolves its targets through `getElementById`, so\n * its host placement is irrelevant to its function.\n *\n * @category ui/toc\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc.component.ts\n * @since 0.1.0\n * @relatedTo CngxScrollSpy, CngxTocRouterSync, CngxSidenav\n * <example-url>http://localhost:4200/#/ui/toc/basic/on-this-page-rail</example-url>\n * <example-url>http://localhost:4200/#/ui/toc/auto/heading-auto-discovery</example-url>\n */\n@Component({\n selector: 'cngx-toc',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [NgTemplateOutlet, CngxScrollSpy],\n providers: [{ provide: CNGX_TOC, useExisting: CngxToc }],\n templateUrl: './toc.component.html',\n styleUrl: './toc.component.css',\n})\nexport class CngxToc implements CngxTocContract {\n private readonly doc = inject(DOCUMENT);\n private readonly cfg = injectTocConfig();\n private readonly reducedMotion = injectMediaQuery('(prefers-reduced-motion: reduce)');\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * The outline to render. Tree-shaped; nested `children` become sub-lists.\n * Ignored when `[autoDiscover]` is set - the headings under `contentRoot`\n * become the outline instead.\n */\n readonly items = input<readonly CngxTocItem[]>(EMPTY_ITEMS);\n /**\n * Derive the outline from the heading elements under `contentRoot` instead\n * of a hand-maintained `[items]` array. Headings nest by their level\n * (`h2 > h3`), and a heading with no `id` gets a slugified one written onto\n * it so the link can target it. Scans once after the first render; call\n * {@link refresh} after you inject or remove sections at runtime.\n */\n readonly autoDiscover = input(false, { transform: booleanAttribute });\n /** Which headings `[autoDiscover]` collects, in CSS-selector form. */\n readonly headingSelector = input<string>('h2, h3');\n /**\n * CSS selector for the scroll container the spy observes. `null` (default)\n * uses the viewport. Forwarded to the spy's `[root]`; also the root the\n * `[autoDiscover]` scan walks for headings.\n */\n readonly contentRoot = input<string | null>(null);\n /** Root margin forwarded to the spy. Defaults to the config cascade. */\n readonly rootMargin = input<string>(this.cfg.spy?.rootMargin ?? '0px');\n /** Minimum visibility ratio forwarded to the spy. Defaults to the config cascade. */\n readonly threshold = input<number>(this.cfg.spy?.threshold ?? 0.3);\n\n /** Fires when a link is activated (click / Enter). */\n readonly activated = output<CngxTocItem>();\n\n private readonly spy = viewChild(CngxScrollSpy);\n private readonly itemSlot = contentChild(CngxTocItemSlot);\n\n /** Headings discovered by the last `[autoDiscover]` scan. */\n private readonly discovered = signal<readonly CngxTocItem[]>(EMPTY_ITEMS, { equal: itemsEqual });\n\n /** The outline actually rendered: the discovered headings when `[autoDiscover]` is on, else `[items]`. */\n protected readonly resolvedItems = computed(() =>\n this.autoDiscover() ? this.discovered() : this.items(),\n );\n\n /** Accessible name of the `nav` landmark, from the config cascade. */\n protected readonly navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page');\n\n /**\n * Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: idsEqual`\n * keeps the reference stable across same-shape re-sets so a re-render does\n * not re-create the observer.\n */\n protected readonly flatIds = computed(() => this.collectIds(this.resolvedItems()), {\n equal: idsEqual,\n });\n\n constructor() {\n // Re-scan whenever the discovery inputs change. The DOM read + discovered\n // write are deferred to a microtask so no signal is written during effect\n // execution (Pillar 1) and the just-rendered content has settled - the same\n // queueMicrotask discipline the panel-lifecycle focus restore uses.\n effect(() => {\n if (!this.autoDiscover()) {\n return;\n }\n this.contentRoot();\n this.headingSelector();\n queueMicrotask(() => this.refresh());\n });\n }\n\n /**\n * The active section, or `null`. `viewChild` is a view query, so `spy()` is\n * `undefined` during the creation pass; `?? null` makes that an explicit\n * value every downstream computed is defined at.\n */\n readonly activeId: Signal<string | null> = computed(() => this.spy()?.activeId() ?? null);\n\n /**\n * Ancestor-id chain of the active leaf - the parent links that get\n * `data-active-trail`. Same `equal` as `flatIds`: an array-valued computed\n * feeding an attribute binding must not allocate a fresh array every spy\n * tick (reference_signal_architecture Equality Rule).\n */\n protected readonly activeTrail = computed(() => this.computeTrail(), { equal: idsEqual });\n\n /** Resolved item template: instance slot -> config default -> built-in label. */\n protected readonly resolvedItemTpl = computed(\n () => this.itemSlot()?.templateRef ?? this.cfg.templates?.item ?? null,\n );\n\n /**\n * Scroll the section with this id into view and move focus to it. Honours\n * `prefers-reduced-motion` - the configured `scrollBehavior` is swapped for\n * `'auto'` (instant) whenever reduced motion is requested. A visual-only\n * jump is a silent state change for screen-reader users, so focus follows\n * the scroll (Pillar 2).\n */\n scrollTo(id: string): void {\n const target = this.doc.getElementById(id);\n if (target === null) {\n return;\n }\n const behavior = this.reducedMotion() ? 'auto' : (this.cfg.scrollBehavior ?? 'smooth');\n target.scrollIntoView({ behavior });\n this.focusTarget(target);\n }\n\n /** Click / Enter handler: takes over the native anchor jump, scrolls, and announces the activation. */\n protected handleActivate(item: CngxTocItem, event?: Event): void {\n event?.preventDefault();\n this.scrollTo(item.id);\n this.activated.emit(item);\n }\n\n /**\n * Move focus to the scrolled-to section. `preventScroll` keeps `focus()`\n * from fighting the smooth `scrollIntoView` above with a second instant\n * jump. Section elements are consumer-owned DOM, so `tabindex=\"-1\"` is set\n * imperatively only when the element is not focusable by default and the\n * consumer set no `tabindex` - an author-set value is never overwritten.\n * That persistent attribute on borrowed DOM is the entry's tracked debt.\n */\n private focusTarget(target: HTMLElement): void {\n const needsTabindex = !target.hasAttribute('tabindex') && !this.isFocusableByDefault(target);\n if (needsTabindex) {\n target.setAttribute('tabindex', '-1');\n }\n target.focus({ preventScroll: true });\n }\n\n /** Elements that take focus without an author `tabindex`. */\n private isFocusableByDefault(el: HTMLElement): boolean {\n return /^(a|button|input|select|textarea|summary|iframe)$/i.test(el.tagName);\n }\n\n /** Depth-first collect of every id in the outline. */\n private collectIds(items: readonly CngxTocItem[], acc: string[] = []): string[] {\n for (const item of items) {\n acc.push(item.id);\n if (item.children?.length) {\n this.collectIds(item.children, acc);\n }\n }\n return acc;\n }\n\n /** Ancestor ids of the active leaf (path from root, excluding the leaf itself). */\n private computeTrail(): readonly string[] {\n const id = this.activeId();\n if (id === null) {\n return EMPTY_IDS;\n }\n const path = this.pathTo(id, this.resolvedItems());\n return path ? path.slice(0, -1) : EMPTY_IDS;\n }\n\n /** Root-to-target id path, or `null` when the id is not in the outline. */\n private pathTo(target: string, items: readonly CngxTocItem[]): readonly string[] | null {\n for (const item of items) {\n if (item.id === target) {\n return [item.id];\n }\n const childPath = item.children?.length ? this.pathTo(target, item.children) : null;\n if (childPath) {\n return [item.id, ...childPath];\n }\n }\n return null;\n }\n\n /**\n * Re-run the `[autoDiscover]` heading scan. No-op unless `[autoDiscover]` is\n * set and we are on the browser. Call it after injecting or removing sections\n * at runtime - discovery is one-shot by design, not a live observer.\n */\n refresh(): void {\n if (!this.autoDiscover() || !this.isBrowser) {\n return;\n }\n this.discovered.set(this.scanHeadings());\n }\n\n /** Walk the headings under `contentRoot` into a level-nested outline. */\n private scanHeadings(): readonly CngxTocItem[] {\n const rootSelector = this.contentRoot();\n let root: ParentNode = this.doc;\n if (rootSelector) {\n const matched = this.doc.querySelector(rootSelector);\n // A set-but-unmatched root scans nothing, not the whole document -\n // falling back to `doc` would sweep site chrome into the outline.\n if (matched === null) {\n return EMPTY_ITEMS;\n }\n root = matched;\n }\n const headings = Array.from(root.querySelectorAll<HTMLElement>(this.headingSelector()));\n if (headings.length === 0) {\n return EMPTY_ITEMS;\n }\n\n const roots: MutableItem[] = [];\n const stack: { level: number; node: MutableItem }[] = [];\n const used = new Set<string>();\n\n for (const el of headings) {\n const level = this.headingLevel(el);\n const node: MutableItem = { id: this.ensureId(el, used), label: this.headingLabel(el), children: [] };\n while (stack.length > 0 && stack[stack.length - 1].level >= level) {\n stack.pop();\n }\n const parent = stack[stack.length - 1];\n if (parent) {\n parent.node.children.push(node);\n } else {\n roots.push(node);\n }\n stack.push({ level, node });\n }\n\n return roots.map((node) => this.freeze(node));\n }\n\n /** Numeric level of a heading element (`h2` -> 2). Non-heading matches read as level 1. */\n private headingLevel(el: HTMLElement): number {\n const match = /^h([1-6])$/i.exec(el.tagName);\n return match ? Number(match[1]) : 1;\n }\n\n /** Visible text of a heading, collapsed to a single spaced line. */\n private headingLabel(el: HTMLElement): string {\n return (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n }\n\n /**\n * Return the heading's id, generating and writing a slug when it has none.\n * The write mutates consumer-owned DOM (tracked debt); an author-set id is\n * kept verbatim. Collisions against prior scan ids and existing document ids\n * get a `-2`, `-3`, ... suffix.\n */\n private ensureId(el: HTMLElement, used: Set<string>): string {\n if (el.id) {\n used.add(el.id);\n return el.id;\n }\n const base = this.slugify(this.headingLabel(el)) || 'section';\n let candidate = base;\n let n = 2;\n while (used.has(candidate) || this.doc.getElementById(candidate) !== null) {\n candidate = `${base}-${n++}`;\n }\n used.add(candidate);\n el.setAttribute('id', candidate);\n return candidate;\n }\n\n /** Lowercase, strip diacritics-free non-alphanumerics to hyphens, collapse and trim. */\n private slugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n }\n\n /** Freeze a mutable node into a CngxTocItem, dropping empty children arrays. */\n private freeze(node: MutableItem): CngxTocItem {\n if (node.children.length === 0) {\n return { id: node.id, label: node.label };\n }\n return { id: node.id, label: node.label, children: node.children.map((child) => this.freeze(child)) };\n }\n}\n","<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n","import { afterNextRender, Directive, inject } from '@angular/core';\nimport { outputToObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\n\nimport { CNGX_TOC } from './toc-token';\n\n/**\n * Dev-warning emitted when `@angular/router` is absent. A deliberate small\n * local copy of the `@cngx/common/layout` kernel's warning rather than a\n * shared import - sharing would force the helper onto a `public-api.ts`, and\n * `warn*` matches no approved public-API prefix (same call the tabs and\n * sidenav sync directives make).\n *\n * @internal\n */\nfunction warnRouterAbsent(directive: string, enables: string): void {\n console.warn(\n `${directive}: no Router available - directive is a no-op. ` +\n `Provide @angular/router via provideRouter(...) to enable ${enables}.`,\n );\n}\n\n/**\n * Deep-links a `CngxToc` into the URL fragment. Opt-in via\n * `[cngxTocRouterSync]` on the same host as `<cngx-toc>`: activating a link\n * writes `#<section-id>` (replacing the history entry, so a scroll-driven rail\n * never floods the back stack), and a deep link like `/guide#pricing` scrolls\n * to that section once on load.\n *\n * Reaches the rail through the {@link CNGX_TOC} contract token, never the\n * concrete `CngxToc` class. The activation subscription is torn down with the\n * directive via `takeUntilDestroyed` - an `OutputRef` subscription would\n * otherwise outlive route changes. Without `@angular/router` the directive\n * dev-warns once and no-ops.\n *\n * @category ui/toc\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-router-sync.directive.ts\n * @since 0.1.0\n * @relatedTo CngxToc, CNGX_TOC\n * <example-url>http://localhost:4200/#/ui/toc/router/fragment-deep-link</example-url>\n */\n@Directive({\n selector: '[cngxTocRouterSync]',\n exportAs: 'cngxTocRouterSync',\n standalone: true,\n})\nexport class CngxTocRouterSync {\n private readonly toc = inject(CNGX_TOC, { host: true });\n private readonly router = inject(Router, { optional: true });\n private readonly route = inject(ActivatedRoute, { optional: true });\n\n constructor() {\n if (!this.router || !this.route) {\n afterNextRender(() => warnRouterAbsent('CngxTocRouterSync', 'fragment deep-linking'));\n return;\n }\n const router = this.router;\n\n // Write the fragment on every activation. replaceUrl keeps a scroll-driven\n // rail from pushing a history entry per section.\n outputToObservable(this.toc.activated)\n .pipe(takeUntilDestroyed())\n .subscribe((item) => {\n void router.navigate([], { fragment: item.id, replaceUrl: true });\n });\n\n // One-shot deep-link scroll: read the fragment present at load and bring\n // that section into view after the first render.\n const fragment = toSignal(this.route.fragment, {\n initialValue: this.route.snapshot.fragment,\n });\n afterNextRender(() => {\n const initial = fragment();\n if (initial) {\n this.toc.scrollTo(initial);\n }\n });\n }\n}\n","import type { CngxTocConfig } from './toc.config';\nimport type { CngxTocConfigFeature } from './provide-toc-config';\n\n/**\n * Override the toc's ARIA-string fallback - the accessible name of the `nav`\n * landmark that wraps the link list (default `'On this page'`).\n *\n * ```ts\n * provideTocConfig(withTocAriaLabels({ nav: 'Auf dieser Seite' }));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocAriaLabels(\n payload: NonNullable<CngxTocConfig['ariaLabels']>,\n): CngxTocConfigFeature {\n return { kind: 'ariaLabels', payload };\n}\n\n/**\n * Set the app-wide default scroll behaviour used when a link is activated.\n * `'smooth'` by default; the organism still swaps to `'auto'` at runtime\n * whenever `prefers-reduced-motion: reduce` matches, so this only chooses the\n * motion-allowed behaviour.\n *\n * ```ts\n * provideTocConfig(withTocScrollBehavior('auto'));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocScrollBehavior(\n scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']>,\n): CngxTocConfigFeature {\n return { kind: 'scrollBehavior', payload: { scrollBehavior } };\n}\n\n/**\n * Move the app-wide `CngxScrollSpy` defaults - the `rootMargin` and\n * `threshold` the rail forwards to its internal spy. Per-instance\n * `[rootMargin]` / `[threshold]` bindings still win; this only sets the\n * cascade default (e.g. a fixed-header offset every toc should share).\n *\n * ```ts\n * provideTocConfig(withTocSpy({ rootMargin: '-80px 0px 0px 0px' }));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocSpy(payload: NonNullable<CngxTocConfig['spy']>): CngxTocConfigFeature {\n return { kind: 'spy', payload };\n}\n\n/**\n * Register a global default item template. Resolves after a per-instance\n * `*cngxTocItem` slot and before the built-in plain-label rendering, so every\n * un-slotted toc renders the same custom item markup.\n *\n * ```ts\n * @Component({\n * viewProviders: [provideTocConfigAt(withTocTemplates({ item: myItemTpl }))],\n * })\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocTemplates(\n payload: NonNullable<CngxTocConfig['templates']>,\n): CngxTocConfigFeature {\n return { kind: 'templates', payload };\n}\n","import {\n inject,\n makeEnvironmentProviders,\n type EnvironmentProviders,\n type Provider,\n} from '@angular/core';\n\nimport type { CngxTocConfig } from './toc.config';\nimport { CNGX_TOC_CONFIG, CNGX_TOC_DEFAULTS } from './toc.config.defaults';\n\n/**\n * Discriminated-union shape returned by the toc config features -\n * `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`, and\n * `withTocTemplates`. The\n * reducer in `provideTocConfig` / `provideTocConfigAt` matches on `kind` and\n * merges `payload` into the corresponding config sub-tree. Mirrors\n * `CngxBreadcrumbConfigFeature` so the consumer's mental model is one across\n * feature areas.\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport type CngxTocConfigFeature =\n | {\n readonly kind: 'ariaLabels';\n readonly payload: NonNullable<CngxTocConfig['ariaLabels']>;\n }\n | {\n readonly kind: 'scrollBehavior';\n readonly payload: { readonly scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']> };\n }\n | {\n readonly kind: 'spy';\n readonly payload: NonNullable<CngxTocConfig['spy']>;\n }\n | {\n readonly kind: 'templates';\n readonly payload: NonNullable<CngxTocConfig['templates']>;\n };\n\n/**\n * Reduces a list of feature objects into a partial config - last write wins\n * per sub-tree. Inner objects are spread-merged so partial overrides compose\n * cleanly with prior writes.\n *\n * @internal\n */\nfunction reduceFeatures(features: readonly CngxTocConfigFeature[]): Partial<CngxTocConfig> {\n const out: {\n ariaLabels?: NonNullable<CngxTocConfig['ariaLabels']>;\n scrollBehavior?: NonNullable<CngxTocConfig['scrollBehavior']>;\n spy?: NonNullable<CngxTocConfig['spy']>;\n templates?: NonNullable<CngxTocConfig['templates']>;\n } = {};\n for (const f of features) {\n switch (f.kind) {\n case 'ariaLabels':\n out.ariaLabels = { ...out.ariaLabels, ...f.payload };\n break;\n case 'scrollBehavior':\n out.scrollBehavior = f.payload.scrollBehavior;\n break;\n case 'spy':\n out.spy = { ...out.spy, ...f.payload };\n break;\n case 'templates':\n out.templates = { ...out.templates, ...f.payload };\n break;\n }\n }\n return out;\n}\n\n/**\n * Deep merge: the nested sub-trees (`ariaLabels` / `spy` / `templates`) are\n * spread-merged so a partial fills in missing keys without nuking unrelated\n * sub-trees; the flat scalar `scrollBehavior` takes the partial when present,\n * else the base. Inner objects are flat (one level), so a single spread per\n * key suffices.\n *\n * @internal\n */\nfunction mergeConfig(\n base: CngxTocConfig,\n partial: Partial<CngxTocConfig>,\n): CngxTocConfig {\n return {\n ariaLabels: { ...base.ariaLabels, ...partial.ariaLabels },\n scrollBehavior: partial.scrollBehavior ?? base.scrollBehavior,\n spy: { ...base.spy, ...partial.spy },\n templates: { ...base.templates, ...partial.templates },\n };\n}\n\n/**\n * Application-root configuration cascade for the toc organism. Pass any\n * combination of `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`,\n * and `withTocTemplates` features in `bootstrapApplication`'s providers array.\n *\n * Resolution priority (high -> low):\n * 1. Per-instance Input binding.\n * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.\n * 3. `provideTocConfig(...)` at the application root.\n * 4. Library defaults (`CNGX_TOC_DEFAULTS`).\n *\n * The provider deep-merges supplied features with the library defaults so\n * consumers only declare keys they want to override.\n *\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideTocConfig(\n * withTocAriaLabels({ nav: 'On this page' }),\n * withTocScrollBehavior('smooth'),\n * ),\n * ],\n * });\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function provideTocConfig(...features: CngxTocConfigFeature[]): EnvironmentProviders {\n // Empty-features: skip the override so the root factory's CNGX_TOC_DEFAULTS\n // reference flows through untouched. A fresh mergeConfig(...) would allocate\n // identical content under a new reference and bust identity comparisons.\n if (features.length === 0) {\n return makeEnvironmentProviders([]);\n }\n const partial = reduceFeatures(features);\n return makeEnvironmentProviders([\n {\n provide: CNGX_TOC_CONFIG,\n useValue: mergeConfig(CNGX_TOC_DEFAULTS, partial),\n },\n ]);\n}\n\n/**\n * Component-scoped configuration cascade for the toc organism. Pass any\n * combination of feature factories in a parent component's `viewProviders`\n * array.\n *\n * Unlike `provideTocConfig` (root-only), `provideTocConfigAt` injects the\n * parent injector's `CNGX_TOC_CONFIG` value (resolves through the priority\n * chain) and deep-merges the supplied features on top. Descendant toc\n * instances see the merged config; sibling sub-trees keep the inherited value.\n *\n * ```ts\n * @Component({\n * viewProviders: [provideTocConfigAt(withTocScrollBehavior('auto'))],\n * template: '<cngx-toc [items]=\"toc\" contentRoot=\"#article\" />',\n * })\n * class Guide {}\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function provideTocConfigAt(...features: CngxTocConfigFeature[]): Provider[] {\n // Empty-features call: parent value flows through untouched. Skipping the\n // factory preserves reference identity through the sub-tree.\n if (features.length === 0) {\n return [];\n }\n const partial = reduceFeatures(features);\n return [\n {\n provide: CNGX_TOC_CONFIG,\n useFactory: () => {\n const parent = inject(CNGX_TOC_CONFIG, { skipSelf: true });\n return mergeConfig(parent, partial);\n },\n },\n ];\n}\n","/**\n * @module @cngx/ui/toc\n */\n\nexport { CngxToc } from './toc.component';\nexport { CngxTocRouterSync } from './toc-router-sync.directive';\nexport { CngxTocItemSlot } from './toc-item-slot';\nexport { CNGX_TOC, type CngxTocContract } from './toc-token';\nexport type { CngxTocItem, CngxTocItemContext } from './toc.types';\nexport type { CngxTocConfig } from './config/toc.config';\nexport { CNGX_TOC_CONFIG } from './config/toc.config.defaults';\nexport {\n withTocAriaLabels,\n withTocScrollBehavior,\n withTocSpy,\n withTocTemplates,\n} from './config/features';\nexport {\n provideTocConfig,\n provideTocConfigAt,\n type CngxTocConfigFeature,\n} from './config/provide-toc-config';\nexport { injectTocConfig } from './config/inject-toc-config';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;;;;;AAaG;AACI,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,UAAU,EAAE;AACV,QAAA,GAAG,EAAE,cAAc;AACpB,KAAA;AACD,IAAA,cAAc,EAAE,QAAQ;AACxB,IAAA,GAAG,EAAE;AACH,QAAA,UAAU,EAAE,KAAK;AACjB,QAAA,SAAS,EAAE,GAAG;AACf,KAAA;CACF;AAED;;;;;;;;;;;;;;;;;;AAkBG;MACU,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB,EAAE;AAClF,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,iBAAiB;AACjC,CAAA;;AC9CD;;;;;;;;;;;;;;;;AAgBG;SACa,eAAe,GAAA;AAC7B,IAAA,OAAO,MAAM,CAAC,eAAe,CAAC;AAChC;;ACpBA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MAMU,eAAe,CAAA;AACjB,IAAA,WAAW,GAAG,MAAM,CAAkC,WAAW,CAAC;AAE3E,IAAA,OAAO,sBAAsB,CAC3B,IAAqB,EACrB,GAAY,EAAA;AAEZ,QAAA,OAAO,IAAI;IACb;uGARW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAf,eAAe,EAAA,YAAA,EAAA,IAAA,EA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AO,EAAE,eAAe;YACxB,UAAU,EAAE,MAAK;AACf,gBAAA,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC1D,gBAAA,OAAO,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;YACrC,CAAC;AACF,SAAA;KACF;AACH;;AC/KA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-toc.mjs","sources":["../../../projects/ui/toc/i18n/toc-language-section.ts","../../../projects/ui/toc/i18n/toc-i18n.ts","../../../projects/ui/toc/config/toc.config.defaults.ts","../../../projects/ui/toc/config/inject-toc-config.ts","../../../projects/ui/toc/toc-item-slot.ts","../../../projects/ui/toc/toc-token.ts","../../../projects/ui/toc/toc.component.ts","../../../projects/ui/toc/toc.component.html","../../../projects/ui/toc/toc-router-sync.directive.ts","../../../projects/ui/toc/config/features.ts","../../../projects/ui/toc/config/provide-toc-config.ts","../../../projects/ui/toc/public-api.ts","../../../projects/ui/toc/cngx-ui-toc.ts"],"sourcesContent":["/**\n * The toc section of a {@link CngxLanguagePack}: the accessible names of\n * `CngxToc`. It feeds the `ariaLabels` of `CNGX_TOC_CONFIG`; a key set through\n * `withTocAriaLabels` still wins.\n *\n * @category ui/toc/i18n\n * @since 0.1.0\n * @relatedTo CNGX_TOC_CONFIG, withTocAriaLabels\n */\nexport interface CngxTocLanguageSection {\n /** Accessible name of the `nav` landmark. */\n readonly nav: string;\n}\n\n/**\n * The English toc section: the single source of the toc's English copy. The\n * `CNGX_TOC_CONFIG` labels default to it.\n *\n * @category ui/toc/i18n\n * @since 0.1.0\n * @relatedTo CNGX_TOC_CONFIG\n */\nexport const CNGX_TOC_LANGUAGE_EN: CngxTocLanguageSection = {\n nav: 'On this page',\n};\n\ndeclare module '@cngx/core/i18n' {\n interface CngxLanguagePack {\n readonly toc: CngxTocLanguageSection;\n }\n}\n","import { createLanguageSection } from '@cngx/core/i18n';\n\nimport { CNGX_TOC_LANGUAGE_EN } from './toc-language-section';\n\n/**\n * @internal The toc section of the active pack over the English section,\n * shared app-wide. Consumers override copy through `withTocAriaLabels`.\n */\nexport const injectTocSiteCopy = createLanguageSection('toc', CNGX_TOC_LANGUAGE_EN);\n","import { InjectionToken } from '@angular/core';\n\nimport type { CngxTocConfig } from './toc.config';\n\n/**\n * Library defaults for the toc configuration cascade. Carries no copy: the\n * `ariaLabels` defaults are the `toc` section of the language pack; single\n * keys ride the `withTocAriaLabels` feature. The spy defaults (`rootMargin` / `threshold`) mirror\n * `CngxScrollSpy`'s own input defaults so an un-configured toc tracks\n * scrolling identically to a hand-wired spy.\n *\n * Exported for intra-lib consumers (`provideTocConfig` deep-merges with this\n * base) but **NOT** re-exported from `public-api.ts` - downstream consumers\n * reach the defaults via `inject(CNGX_TOC_CONFIG)` so `provideTocConfig` /\n * `provideTocConfigAt` overrides take precedence.\n *\n * @internal\n */\nexport const CNGX_TOC_DEFAULTS: CngxTocConfig = {\n scrollBehavior: 'smooth',\n spy: {\n rootMargin: '0px',\n threshold: 0.3,\n },\n};\n\n/**\n * App-wide configuration cascade for the table-of-contents organism. Resolves\n * in priority order:\n *\n * 1. Per-instance Input binding.\n * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.\n * 3. `provideTocConfig(...)` at the application root.\n * 4. Library defaults (this token's `factory`).\n *\n * `providedIn: 'root'` with a default factory means consumers never need to\n * provide the token explicitly - `inject(CNGX_TOC_CONFIG)` always resolves.\n * Consumers who want overrides call `provideTocConfig(...)` in\n * `bootstrapApplication` providers (root cascade) or `provideTocConfigAt(...)`\n * in a component's `viewProviders` (sub-tree cascade).\n *\n * @category ui/toc\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/config/toc.config.defaults.ts\n * @since 0.1.0\n */\nexport const CNGX_TOC_CONFIG = new InjectionToken<CngxTocConfig>('CNGX_TOC_CONFIG', {\n providedIn: 'root',\n factory: () => CNGX_TOC_DEFAULTS,\n});\n","import { inject, type Signal } from '@angular/core';\nimport { createFilledOverrideMerge } from '@cngx/core/utils';\n\nimport { injectTocSiteCopy } from '../i18n/toc-i18n';\nimport type { CngxTocAriaLabels, CngxTocConfig } from './toc.config';\nimport { CNGX_TOC_CONFIG } from './toc.config.defaults';\n\n/**\n * Convenience accessor for the toc configuration cascade. Runs in injection\n * context; resolves through the priority chain (per-instance Input ->\n * `provideTocConfigAt` -> `provideTocConfig` -> library defaults). Equivalent\n * to `inject(CNGX_TOC_CONFIG)` - the helper exists so consumers don't import\n * the token directly. Mirrors `injectBreadcrumbConfig`.\n *\n * ```ts\n * export class CngxToc {\n * private readonly cfg = injectTocConfig();\n * protected readonly navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page');\n * }\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function injectTocConfig(): CngxTocConfig {\n return inject(CNGX_TOC_CONFIG);\n}\n\n/**\n * The resolved accessible names of the toc config in scope, every key the\n * config leaves unset (also a key an override sets to `undefined`) filled from\n * the `toc` section of the active pack, as a Signal that follows a runtime\n * language switch. Runs in injection context; read it inside a `computed()`, a template\n * or a handler.\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function injectTocAriaLabels(): Signal<Required<CngxTocAriaLabels>> {\n return createFilledOverrideMerge(injectTocSiteCopy(), injectTocConfig().ariaLabels);\n}\n","import { Directive, inject, TemplateRef } from '@angular/core';\n\nimport type { CngxTocItemContext } from './toc.types';\n\n/**\n * Per-item template slot for `CngxToc`. Project an `<ng-template cngxTocItem>`\n * inside `<cngx-toc>` to replace the built-in plain-label rendering with\n * custom markup - the `let-` variables come out typed via\n * `ngTemplateContextGuard`:\n *\n * ```html\n * <cngx-toc [items]=\"toc\" contentRoot=\"#article\">\n * <ng-template cngxTocItem let-item let-active=\"active\" let-depth=\"depth\">\n * <span [class.is-active]=\"active\">{{ item.label }}</span>\n * @if (depth === 0) { <cngx-badge>{{ item.children?.length }}</cngx-badge> }\n * </ng-template>\n * </cngx-toc>\n * ```\n *\n * Named `CngxTocItemSlot` (not `*Directive`) per the repo's no-artifact-suffix\n * rule; the selector stays `cngxTocItem`, which is what consumers write.\n * Resolves ahead of `CNGX_TOC_CONFIG.templates.item` and the built-in label.\n *\n * @category ui/toc\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-item-slot.ts\n * @since 0.1.0\n * @relatedTo CngxToc\n * <example-url>http://localhost:4200/#/ui/toc/slots/custom-item-template</example-url>\n */\n@Directive({\n selector: 'ng-template[cngxTocItem]',\n standalone: true,\n exportAs: 'cngxTocItem',\n})\nexport class CngxTocItemSlot {\n readonly templateRef = inject<TemplateRef<CngxTocItemContext>>(TemplateRef);\n\n static ngTemplateContextGuard(\n _dir: CngxTocItemSlot,\n ctx: unknown,\n ): ctx is CngxTocItemContext {\n return true;\n }\n}\n","import { InjectionToken, type OutputRef, type Signal } from '@angular/core';\n\nimport type { CngxTocItem } from './toc.types';\n\n/**\n * Minimal contract a toc rail exposes to its collaborators (the opt-in\n * `CngxTocRouterSync` fragment directive): the active-section signal it\n * derives, the activation output it emits, and the imperative `scrollTo`\n * it owns. Injected via {@link CNGX_TOC} + `useExisting`, never by injecting\n * the concrete `CngxToc` class - that would create a cyclic type dependency\n * and block the decompose brain/skin split.\n *\n * Direction mirrors `CNGX_SIDENAV`, not `CNGX_BREADCRUMB_ITEMS_SOURCE`: the\n * rail owns the state (`activeId`, `scrollTo`) and the collaborator consumes\n * it, so the toc *provides* the token and the sync directive *injects* it.\n *\n * @category ui/toc\n * @since 0.1.0\n * @relatedTo CngxToc, CngxTocRouterSync\n */\nexport interface CngxTocContract {\n /** The section currently most visible, or `null` before the spy resolves. */\n readonly activeId: Signal<string | null>;\n /** Fires when a link is activated (click / Enter), carrying its item. */\n readonly activated: OutputRef<CngxTocItem>;\n /** Scroll the section with this id into view and move focus to it. */\n scrollTo(id: string): void;\n}\n\n/**\n * Contract token for a toc rail. `CngxToc` provides it via\n * `{ provide: CNGX_TOC, useExisting: CngxToc }`, so a collaborator injects the\n * narrow {@link CngxTocContract} instead of the concrete class.\n *\n * @category ui/toc\n * @since 0.1.0\n * @relatedTo CngxToc, CngxTocRouterSync\n */\nexport const CNGX_TOC = new InjectionToken<CngxTocContract>('CNGX_TOC');\n","import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n DestroyRef,\n effect,\n inject,\n input,\n output,\n PLATFORM_ID,\n signal,\n ViewEncapsulation,\n viewChild,\n type Signal,\n} from '@angular/core';\nimport { arrayEqual } from '@cngx/utils';\nimport { CngxScrollSpy, injectMediaQuery } from '@cngx/common/layout';\n\nimport { injectTocAriaLabels, injectTocConfig } from './config/inject-toc-config';\nimport { CngxTocItemSlot } from './toc-item-slot';\nimport { CNGX_TOC, type CngxTocContract } from './toc-token';\nimport type { CngxTocItem } from './toc.types';\n\n/** Shared empty result so the no-active-section trail is reference-stable. */\nconst EMPTY_IDS: readonly string[] = [];\n\n/** Shared empty outline so the pre-scan / no-headings state is reference-stable. */\nconst EMPTY_ITEMS: readonly CngxTocItem[] = [];\n\n/** Mutable node used while building the discovered tree, before it is frozen to CngxTocItem. */\ninterface MutableItem {\n id: string;\n label: string;\n children: MutableItem[];\n}\n\n/**\n * Structural compare of two discovered outlines (id + label + nesting). Guards\n * the `discovered` signal so a re-scan of unchanged headings keeps the same\n * reference and never re-stamps the outline outlet.\n */\nfunction itemsEqual(a: readonly CngxTocItem[], b: readonly CngxTocItem[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n const x = a[i];\n const y = b[i];\n if (x.id !== y.id || x.label !== y.label) {\n return false;\n }\n if (!itemsEqual(x.children ?? EMPTY_ITEMS, y.children ?? EMPTY_ITEMS)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * \"On this page\" navigation rail. Renders a `<nav>` of anchor links from a\n * {@link CngxTocItem} outline, tracks the most-visible section through an\n * internal {@link CngxScrollSpy}, and communicates the active link via\n * `aria-current` inside the `computed()` graph. Nested items render as\n * indented sub-lists; native link semantics and tab order stay intact (a toc\n * is a navigation landmark of links, not a treeview).\n *\n * Composition over configuration: the spy is bound in this component's own\n * template rather than via `hostDirectives`, because the organism - not the\n * consumer - owns the flat id list the spy observes, and `[cngxScrollSpy]` is\n * a required input. The spy resolves its targets through `getElementById`, so\n * its host placement is irrelevant to its function.\n *\n * @category ui/toc\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc.component.ts\n * @since 0.1.0\n * @relatedTo CngxScrollSpy, CngxTocRouterSync, CngxSidenav\n * <example-url>http://localhost:4200/#/ui/toc/basic/on-this-page-rail</example-url>\n * <example-url>http://localhost:4200/#/ui/toc/auto/heading-auto-discovery</example-url>\n * @slot cngxTocItem Replaces the plain label inside each item's link at every depth, ahead of CNGX_TOC_CONFIG.templates.item; gets the item as $implicit, plus active and the zero-based depth.\n */\n@Component({\n selector: 'cngx-toc',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [NgTemplateOutlet, CngxScrollSpy],\n providers: [{ provide: CNGX_TOC, useExisting: CngxToc }],\n templateUrl: './toc.component.html',\n styleUrl: './toc.component.css',\n})\nexport class CngxToc implements CngxTocContract {\n private readonly doc = inject(DOCUMENT);\n private readonly cfg = injectTocConfig();\n private readonly ariaLabels = injectTocAriaLabels();\n private readonly reducedMotion = injectMediaQuery('(prefers-reduced-motion: reduce)');\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * The outline to render. Tree-shaped; nested `children` become sub-lists.\n * Ignored when `[autoDiscover]` is set - the headings under `contentRoot`\n * become the outline instead.\n */\n readonly items = input<readonly CngxTocItem[]>(EMPTY_ITEMS);\n /**\n * Derive the outline from the heading elements under `contentRoot` instead\n * of a hand-maintained `[items]` array. Headings nest by their level\n * (`h2 > h3`), and a heading with no `id` gets a slugified one written onto\n * it so the link can target it. Scans once after the first render; call\n * {@link refresh} after you inject or remove sections at runtime.\n */\n readonly autoDiscover = input(false, { transform: booleanAttribute });\n /** Which headings `[autoDiscover]` collects, in CSS-selector form. */\n readonly headingSelector = input<string>('h2, h3');\n /**\n * CSS selector for the scroll container the spy observes. `null` (default)\n * uses the viewport. Forwarded to the spy's `[root]`; also the root the\n * `[autoDiscover]` scan walks for headings.\n */\n readonly contentRoot = input<string | null>(null);\n /** Root margin forwarded to the spy. Defaults to the config cascade. */\n readonly rootMargin = input<string>(this.cfg.spy?.rootMargin ?? '0px');\n /** Minimum visibility ratio forwarded to the spy. Defaults to the config cascade. */\n readonly threshold = input<number>(this.cfg.spy?.threshold ?? 0.3);\n\n /** Fires when a link is activated (click / Enter). */\n readonly activated = output<CngxTocItem>();\n\n private readonly spy = viewChild(CngxScrollSpy);\n private readonly itemSlot = contentChild(CngxTocItemSlot);\n\n /** Headings discovered by the last `[autoDiscover]` scan. */\n private readonly discovered = signal<readonly CngxTocItem[]>(EMPTY_ITEMS, { equal: itemsEqual });\n\n /** The outline actually rendered: the discovered headings when `[autoDiscover]` is on, else `[items]`. */\n protected readonly resolvedItems = computed(() =>\n this.autoDiscover() ? this.discovered() : this.items(),\n );\n\n /** Accessible name of the `nav` landmark, from the config cascade; follows a language switch. */\n protected readonly navLabel = computed(() => this.ariaLabels().nav);\n\n /**\n * Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: arrayEqual`\n * keeps the reference stable across same-shape re-sets so a re-render does\n * not re-create the observer.\n */\n protected readonly flatIds = computed(() => this.collectIds(this.resolvedItems()), {\n equal: arrayEqual,\n });\n\n constructor() {\n // Re-scan whenever the discovery inputs change. The DOM read + discovered\n // write are deferred to a microtask so no signal is written during effect\n // execution (Pillar 1) and the just-rendered content has settled - the same\n // queueMicrotask discipline the panel-lifecycle focus restore uses. The\n // destroyed guard keeps a microtask queued right before teardown from\n // scanning a detached DOM.\n let destroyed = false;\n inject(DestroyRef).onDestroy(() => {\n destroyed = true;\n });\n effect(() => {\n if (!this.autoDiscover()) {\n return;\n }\n this.contentRoot();\n this.headingSelector();\n queueMicrotask(() => {\n if (!destroyed) {\n this.refresh();\n }\n });\n });\n }\n\n /**\n * The active section, or `null`. `viewChild` is a view query, so `spy()` is\n * `undefined` during the creation pass; `?? null` makes that an explicit\n * value every downstream computed is defined at.\n */\n readonly activeId: Signal<string | null> = computed(() => this.spy()?.activeId() ?? null);\n\n /**\n * Ancestor-id chain of the active leaf - the parent links that get\n * `data-active-trail`. Same `equal` as `flatIds`: an array-valued computed\n * feeding an attribute binding must not allocate a fresh array every spy\n * tick (reference_signal_architecture Equality Rule).\n */\n protected readonly activeTrail = computed(() => this.computeTrail(), { equal: arrayEqual });\n\n /** Resolved item template: instance slot -> config default -> built-in label. */\n protected readonly resolvedItemTpl = computed(\n () => this.itemSlot()?.templateRef ?? this.cfg.templates?.item ?? null,\n );\n\n /**\n * Scroll the section with this id into view and move focus to it. Honours\n * `prefers-reduced-motion` - the configured `scrollBehavior` is swapped for\n * `'auto'` (instant) whenever reduced motion is requested. A visual-only\n * jump is a silent state change for screen-reader users, so focus follows\n * the scroll (Pillar 2).\n */\n scrollTo(id: string): void {\n const target = this.doc.getElementById(id);\n if (target === null) {\n return;\n }\n const behavior = this.reducedMotion() ? 'auto' : (this.cfg.scrollBehavior ?? 'smooth');\n target.scrollIntoView({ behavior });\n this.focusTarget(target);\n }\n\n /** Click / Enter handler: takes over the native anchor jump, scrolls, and announces the activation. */\n protected handleActivate(item: CngxTocItem, event?: Event): void {\n event?.preventDefault();\n this.scrollTo(item.id);\n this.activated.emit(item);\n }\n\n /**\n * Move focus to the scrolled-to section. `preventScroll` keeps `focus()`\n * from fighting the smooth `scrollIntoView` above with a second instant\n * jump. Section elements are consumer-owned DOM, so `tabindex=\"-1\"` is set\n * imperatively only when the element is not focusable by default and the\n * consumer set no `tabindex` - an author-set value is never overwritten.\n * That persistent attribute on borrowed DOM is the entry's tracked debt.\n */\n private focusTarget(target: HTMLElement): void {\n const needsTabindex = !target.hasAttribute('tabindex') && !this.isFocusableByDefault(target);\n if (needsTabindex) {\n target.setAttribute('tabindex', '-1');\n }\n target.focus({ preventScroll: true });\n }\n\n /** Elements that take focus without an author `tabindex`. */\n private isFocusableByDefault(el: HTMLElement): boolean {\n return /^(a|button|input|select|textarea|summary|iframe)$/i.test(el.tagName);\n }\n\n /** Depth-first collect of every id in the outline. */\n private collectIds(items: readonly CngxTocItem[], acc: string[] = []): string[] {\n for (const item of items) {\n acc.push(item.id);\n if (item.children?.length) {\n this.collectIds(item.children, acc);\n }\n }\n return acc;\n }\n\n /** Ancestor ids of the active leaf (path from root, excluding the leaf itself). */\n private computeTrail(): readonly string[] {\n const id = this.activeId();\n if (id === null) {\n return EMPTY_IDS;\n }\n const path = this.pathTo(id, this.resolvedItems());\n return path ? path.slice(0, -1) : EMPTY_IDS;\n }\n\n /** Root-to-target id path, or `null` when the id is not in the outline. */\n private pathTo(target: string, items: readonly CngxTocItem[]): readonly string[] | null {\n for (const item of items) {\n if (item.id === target) {\n return [item.id];\n }\n const childPath = item.children?.length ? this.pathTo(target, item.children) : null;\n if (childPath) {\n return [item.id, ...childPath];\n }\n }\n return null;\n }\n\n /**\n * Re-run the `[autoDiscover]` heading scan. No-op unless `[autoDiscover]` is\n * set and we are on the browser. Call it after injecting or removing sections\n * at runtime - discovery is one-shot by design, not a live observer.\n */\n refresh(): void {\n if (!this.autoDiscover() || !this.isBrowser) {\n return;\n }\n this.discovered.set(this.scanHeadings());\n }\n\n /** Walk the headings under `contentRoot` into a level-nested outline. */\n private scanHeadings(): readonly CngxTocItem[] {\n const rootSelector = this.contentRoot();\n let root: ParentNode = this.doc;\n if (rootSelector) {\n const matched = this.doc.querySelector(rootSelector);\n // A set-but-unmatched root scans nothing, not the whole document -\n // falling back to `doc` would sweep site chrome into the outline.\n if (matched === null) {\n return EMPTY_ITEMS;\n }\n root = matched;\n }\n const headings = Array.from(root.querySelectorAll<HTMLElement>(this.headingSelector()));\n if (headings.length === 0) {\n return EMPTY_ITEMS;\n }\n\n const roots: MutableItem[] = [];\n const stack: { level: number; node: MutableItem }[] = [];\n const used = new Set<string>();\n\n for (const el of headings) {\n const level = this.headingLevel(el);\n const node: MutableItem = { id: this.ensureId(el, used), label: this.headingLabel(el), children: [] };\n while (stack.length > 0 && stack[stack.length - 1].level >= level) {\n stack.pop();\n }\n const parent = stack[stack.length - 1];\n if (parent) {\n parent.node.children.push(node);\n } else {\n roots.push(node);\n }\n stack.push({ level, node });\n }\n\n return roots.map((node) => this.freeze(node));\n }\n\n /** Numeric level of a heading element (`h2` -> 2). Non-heading matches read as level 1. */\n private headingLevel(el: HTMLElement): number {\n const match = /^h([1-6])$/i.exec(el.tagName);\n return match ? Number(match[1]) : 1;\n }\n\n /** Visible text of a heading, collapsed to a single spaced line. */\n private headingLabel(el: HTMLElement): string {\n return (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n }\n\n /**\n * Return the heading's id, generating and writing a slug when it has none.\n * The write mutates consumer-owned DOM (tracked debt); an author-set id is\n * kept verbatim. Collisions against prior scan ids and existing document ids\n * get a `-2`, `-3`, ... suffix.\n */\n private ensureId(el: HTMLElement, used: Set<string>): string {\n if (el.id) {\n used.add(el.id);\n return el.id;\n }\n const base = this.slugify(this.headingLabel(el)) || 'section';\n let candidate = base;\n let n = 2;\n while (used.has(candidate) || this.doc.getElementById(candidate) !== null) {\n candidate = `${base}-${n++}`;\n }\n used.add(candidate);\n el.setAttribute('id', candidate);\n return candidate;\n }\n\n /** Lowercase, strip diacritics-free non-alphanumerics to hyphens, collapse and trim. */\n private slugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n }\n\n /** Freeze a mutable node into a CngxTocItem, dropping empty children arrays. */\n private freeze(node: MutableItem): CngxTocItem {\n if (node.children.length === 0) {\n return { id: node.id, label: node.label };\n }\n return { id: node.id, label: node.label, children: node.children.map((child) => this.freeze(child)) };\n }\n}\n","<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n","import { afterNextRender, Directive, inject } from '@angular/core';\nimport { outputToObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { CngxRuntimeError, cngxDevWarn } from '@cngx/utils';\n\nimport { CNGX_TOC, type CngxTocContract } from './toc-token';\n\n/**\n * Dev-warning emitted when `@angular/router` is absent. A deliberate small\n * local copy of the `@cngx/common/layout` kernel's warning rather than a\n * shared import - sharing would force the helper onto a `public-api.ts`, and\n * `warn*` matches no approved public-API prefix (same call the tabs and\n * sidenav sync directives make).\n *\n * @internal\n */\nfunction warnRouterAbsent(selector: string, enables: string): void {\n if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {\n return;\n }\n cngxDevWarn(\n 'CNGX3001',\n `[${selector}] no Router / ActivatedRoute available - directive is a no-op. ` +\n `Provide @angular/router via provideRouter(...) to enable ${enables}.`,\n );\n}\n\n/**\n * Deep-links a `CngxToc` into the URL fragment. Opt-in via\n * `[cngxTocRouterSync]` on the same host as `<cngx-toc>`: activating a link\n * writes `#<section-id>` (replacing the history entry, so a scroll-driven rail\n * never floods the back stack), and a deep link like `/guide#pricing` scrolls\n * to that section once on load.\n *\n * Reaches the rail through the {@link CNGX_TOC} contract token, never the\n * concrete `CngxToc` class. The activation subscription is torn down with the\n * directive via `takeUntilDestroyed` - an `OutputRef` subscription would\n * otherwise outlive route changes. Without `@angular/router` the directive\n * dev-warns once and no-ops.\n *\n * @category ui/toc\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-router-sync.directive.ts\n * @since 0.1.0\n * @relatedTo CngxToc, CNGX_TOC\n * <example-url>http://localhost:4200/#/ui/toc/router/fragment-deep-link</example-url>\n */\n@Directive({\n selector: '[cngxTocRouterSync]',\n exportAs: 'cngxTocRouterSync',\n standalone: true,\n})\nexport class CngxTocRouterSync {\n private readonly toc = injectRouterSyncToc();\n private readonly router = inject(Router, { optional: true });\n private readonly route = inject(ActivatedRoute, { optional: true });\n\n constructor() {\n if (!this.router || !this.route) {\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n afterNextRender(() => warnRouterAbsent('cngxTocRouterSync', 'fragment deep-linking'));\n }\n return;\n }\n const router = this.router;\n\n // Write the fragment on every activation. replaceUrl keeps a scroll-driven\n // rail from pushing a history entry per section; 'merge' keeps the query\n // params a bare fragment navigate would otherwise wipe.\n outputToObservable(this.toc.activated)\n .pipe(takeUntilDestroyed())\n .subscribe((item) => {\n router\n .navigate([], { fragment: item.id, replaceUrl: true, queryParamsHandling: 'merge' })\n .catch(() => undefined);\n });\n\n // One-shot deep-link scroll: read the fragment present at load and bring\n // that section into view after the first render.\n const fragment = toSignal(this.route.fragment, {\n initialValue: this.route.snapshot.fragment,\n });\n afterNextRender(() => {\n const initial = fragment();\n if (initial) {\n this.toc.scrollTo(initial);\n }\n });\n }\n}\n\nfunction injectRouterSyncToc(): CngxTocContract {\n const toc = inject(CNGX_TOC, { host: true, optional: true });\n if (!toc) {\n throw new CngxRuntimeError(\n 'CNGX3021',\n typeof ngDevMode !== 'undefined' &&\n ngDevMode &&\n '[cngxTocRouterSync] must be placed on or inside <cngx-toc>.',\n );\n }\n return toc;\n}\n","import type { Signal } from '@angular/core';\n\nimport type { CngxTocAriaLabels, CngxTocConfig } from './toc.config';\nimport type { CngxTocConfigFeature } from './provide-toc-config';\n\n/**\n * Override the toc's ARIA-string fallback - the accessible name of the `nav`\n * landmark that wraps the link list (default `'On this page'`). Pass a\n * `Signal` to switch the language at runtime.\n *\n * ```ts\n * provideTocConfig(withTocAriaLabels({ nav: 'Auf dieser Seite' }));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocAriaLabels(\n payload: CngxTocAriaLabels | Signal<CngxTocAriaLabels>,\n): CngxTocConfigFeature {\n return { kind: 'ariaLabels', payload };\n}\n\n/**\n * Set the app-wide default scroll behaviour used when a link is activated.\n * `'smooth'` by default; the organism still swaps to `'auto'` at runtime\n * whenever `prefers-reduced-motion: reduce` matches, so this only chooses the\n * motion-allowed behaviour.\n *\n * ```ts\n * provideTocConfig(withTocScrollBehavior('auto'));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocScrollBehavior(\n scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']>,\n): CngxTocConfigFeature {\n return { kind: 'scrollBehavior', payload: { scrollBehavior } };\n}\n\n/**\n * Move the app-wide `CngxScrollSpy` defaults - the `rootMargin` and\n * `threshold` the rail forwards to its internal spy. Per-instance\n * `[rootMargin]` / `[threshold]` bindings still win; this only sets the\n * cascade default (e.g. a fixed-header offset every toc should share).\n *\n * ```ts\n * provideTocConfig(withTocSpy({ rootMargin: '-80px 0px 0px 0px' }));\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocSpy(payload: NonNullable<CngxTocConfig['spy']>): CngxTocConfigFeature {\n return { kind: 'spy', payload };\n}\n\n/**\n * Register a global default item template. Resolves after a per-instance\n * `*cngxTocItem` slot and before the built-in plain-label rendering, so every\n * un-slotted toc renders the same custom item markup.\n *\n * A `TemplateRef` exists only once a view renders, so it cannot go into\n * `viewProviders` or the root providers. Build the scope from the rendered\n * template and hand it to `ngTemplateOutlet`:\n *\n * ```ts\n * private readonly injector = inject(Injector);\n * private readonly itemTpl = viewChild.required<TemplateRef<CngxTocItemContext>>('tocItem');\n * protected readonly tocScope = computed(() =>\n * Injector.create({\n * parent: this.injector,\n * providers: [provideTocConfigAt(withTocTemplates({ item: this.itemTpl() }))],\n * }),\n * );\n * // <ng-container *ngTemplateOutlet=\"tocTpl; injector: tocScope()\" />\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function withTocTemplates(\n payload: NonNullable<CngxTocConfig['templates']>,\n): CngxTocConfigFeature {\n return { kind: 'templates', payload };\n}\n","import {\n inject,\n makeEnvironmentProviders,\n type EnvironmentProviders,\n type Provider,\n type Signal,\n} from '@angular/core';\nimport { createOverrideMerge } from '@cngx/core/utils';\n\nimport type { CngxTocAriaLabels, CngxTocConfig } from './toc.config';\nimport { CNGX_TOC_CONFIG, CNGX_TOC_DEFAULTS } from './toc.config.defaults';\n\nconst NO_ARIA_LABELS: CngxTocAriaLabels = {};\n\n/**\n * Discriminated-union shape returned by the toc config features -\n * `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`, and\n * `withTocTemplates`. The\n * reducer in `provideTocConfig` / `provideTocConfigAt` matches on `kind` and\n * merges `payload` into the corresponding config sub-tree. Mirrors\n * `CngxBreadcrumbConfigFeature` so the consumer's mental model is one across\n * feature areas.\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport type CngxTocConfigFeature =\n | {\n readonly kind: 'ariaLabels';\n readonly payload: CngxTocAriaLabels | Signal<CngxTocAriaLabels>;\n }\n | {\n readonly kind: 'scrollBehavior';\n readonly payload: { readonly scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']> };\n }\n | {\n readonly kind: 'spy';\n readonly payload: NonNullable<CngxTocConfig['spy']>;\n }\n | {\n readonly kind: 'templates';\n readonly payload: NonNullable<CngxTocConfig['templates']>;\n };\n\n/**\n * Reduces a list of feature objects into a partial config - last write wins\n * per sub-tree. Inner objects are spread-merged so partial overrides compose\n * cleanly with prior writes.\n *\n * @internal\n */\nfunction reduceFeatures(features: readonly CngxTocConfigFeature[]): Partial<CngxTocConfig> {\n const out: {\n ariaLabels?: CngxTocAriaLabels | Signal<CngxTocAriaLabels>;\n scrollBehavior?: NonNullable<CngxTocConfig['scrollBehavior']>;\n spy?: NonNullable<CngxTocConfig['spy']>;\n templates?: NonNullable<CngxTocConfig['templates']>;\n } = {};\n for (const f of features) {\n switch (f.kind) {\n case 'ariaLabels':\n out.ariaLabels = createOverrideMerge(out.ariaLabels ?? NO_ARIA_LABELS, f.payload);\n break;\n case 'scrollBehavior':\n out.scrollBehavior = f.payload.scrollBehavior;\n break;\n case 'spy':\n out.spy = { ...out.spy, ...f.payload };\n break;\n case 'templates':\n out.templates = { ...out.templates, ...f.payload };\n break;\n }\n }\n return out;\n}\n\n/**\n * Deep merge: the nested sub-trees (`ariaLabels` / `spy` / `templates`) are\n * spread-merged so a partial fills in missing keys without nuking unrelated\n * sub-trees; the flat scalar `scrollBehavior` takes the partial when present,\n * else the base. Inner objects are flat (one level), so a single spread per\n * key suffices.\n *\n * @internal\n */\nfunction mergeConfig(\n base: CngxTocConfig,\n partial: Partial<CngxTocConfig>,\n): CngxTocConfig {\n return {\n ariaLabels: createOverrideMerge(base.ariaLabels ?? NO_ARIA_LABELS, partial.ariaLabels),\n scrollBehavior: partial.scrollBehavior ?? base.scrollBehavior,\n spy: { ...base.spy, ...partial.spy },\n templates: { ...base.templates, ...partial.templates },\n };\n}\n\n/**\n * Application-root configuration cascade for the toc organism. Pass any\n * combination of `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`,\n * and `withTocTemplates` features in `bootstrapApplication`'s providers array.\n *\n * Resolution priority (high -> low):\n * 1. Per-instance Input binding.\n * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.\n * 3. `provideTocConfig(...)` at the application root.\n * 4. Library defaults (`CNGX_TOC_DEFAULTS`).\n *\n * The provider deep-merges supplied features with the library defaults so\n * consumers only declare keys they want to override.\n *\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideTocConfig(\n * withTocAriaLabels({ nav: 'On this page' }),\n * withTocScrollBehavior('smooth'),\n * ),\n * ],\n * });\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function provideTocConfig(...features: CngxTocConfigFeature[]): EnvironmentProviders {\n // Empty-features: skip the override so the root factory's CNGX_TOC_DEFAULTS\n // reference flows through untouched. A fresh mergeConfig(...) would allocate\n // identical content under a new reference and bust identity comparisons.\n if (features.length === 0) {\n return makeEnvironmentProviders([]);\n }\n const partial = reduceFeatures(features);\n return makeEnvironmentProviders([\n {\n provide: CNGX_TOC_CONFIG,\n useValue: mergeConfig(CNGX_TOC_DEFAULTS, partial),\n },\n ]);\n}\n\n/**\n * Component-scoped configuration cascade for the toc organism. Pass any\n * combination of feature factories in a parent component's `viewProviders`\n * array.\n *\n * Unlike `provideTocConfig` (root-only), `provideTocConfigAt` injects the\n * parent injector's `CNGX_TOC_CONFIG` value (resolves through the priority\n * chain) and deep-merges the supplied features on top. Descendant toc\n * instances see the merged config; sibling sub-trees keep the inherited value.\n *\n * ```ts\n * @Component({\n * viewProviders: [provideTocConfigAt(withTocScrollBehavior('auto'))],\n * template: '<cngx-toc [items]=\"toc\" contentRoot=\"#article\" />',\n * })\n * class Guide {}\n * ```\n *\n * @category ui/toc\n * @since 0.1.0\n */\nexport function provideTocConfigAt(...features: CngxTocConfigFeature[]): Provider[] {\n // Empty-features call: parent value flows through untouched. Skipping the\n // factory preserves reference identity through the sub-tree.\n if (features.length === 0) {\n return [];\n }\n const partial = reduceFeatures(features);\n return [\n {\n provide: CNGX_TOC_CONFIG,\n useFactory: () => {\n const parent = inject(CNGX_TOC_CONFIG, { skipSelf: true });\n return mergeConfig(parent, partial);\n },\n },\n ];\n}\n","/**\n * @module @cngx/ui/toc\n */\n\nexport { CngxToc } from './toc.component';\nexport { CngxTocRouterSync } from './toc-router-sync.directive';\nexport { CngxTocItemSlot } from './toc-item-slot';\nexport { CNGX_TOC, type CngxTocContract } from './toc-token';\nexport type { CngxTocItem, CngxTocItemContext } from './toc.types';\nexport type { CngxTocAriaLabels, CngxTocConfig } from './config/toc.config';\nexport { CNGX_TOC_CONFIG, CNGX_TOC_DEFAULTS } from './config/toc.config.defaults';\nexport {\n withTocAriaLabels,\n withTocScrollBehavior,\n withTocSpy,\n withTocTemplates,\n} from './config/features';\nexport {\n provideTocConfig,\n provideTocConfigAt,\n type CngxTocConfigFeature,\n} from './config/provide-toc-config';\nexport { injectTocAriaLabels, injectTocConfig } from './config/inject-toc-config';\nexport { CNGX_TOC_LANGUAGE_EN, type CngxTocLanguageSection } from './i18n/toc-language-section';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAcA;;;;;;;AAOG;AACI,MAAM,oBAAoB,GAA2B;AAC1D,IAAA,GAAG,EAAE,cAAc;;;ACnBrB;;;AAGG;AACI,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,CAAC;;ACJnF;;;;;;;;;;;;;AAaG;AACI,MAAM,iBAAiB,GAAkB;AAC9C,IAAA,cAAc,EAAE,QAAQ;AACxB,IAAA,GAAG,EAAE;AACH,QAAA,UAAU,EAAE,KAAK;AACjB,QAAA,SAAS,EAAE,GAAG;AACf,KAAA;;AAGH;;;;;;;;;;;;;;;;;;AAkBG;MACU,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB,EAAE;AAClF,IAAA,UAAU,EAAE,MAAM;AA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