@cngx/common 0.0.1-rc.0

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
@@ -0,0 +1,2943 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, TemplateRef, Directive, contentChildren, contentChild, isDevMode, afterNextRender } from '@angular/core';
3
+ import { NgTemplateOutlet } from '@angular/common';
4
+ import * as i1 from '@cngx/common/layout';
5
+ import { CngxResizeObserver } from '@cngx/common/layout';
6
+ import { resolveAsyncView } from '@cngx/common/data';
7
+ import { nextUid } from '@cngx/core/utils';
8
+
9
+ /**
10
+ * Pure-TS linear scale. Maps a numeric domain `[d0, d1]` to a numeric
11
+ * range `[r0, r1]` via standard linear interpolation. Domain may be
12
+ * inverted (`d0 > d1`) for SVG Y-axes where the top of the chart is the
13
+ * highest data value but the lowest pixel coordinate.
14
+ *
15
+ * Values outside the domain extrapolate. Charts that need overflow
16
+ * clamping clamp at the data layer, not the scale.
17
+ *
18
+ * @param domain `[start, end]` data range. Equal endpoints collapse the
19
+ * scale to a constant function returning `range[0]`.
20
+ * @param range `[start, end]` output range (typically pixel coordinates).
21
+ * @returns `(v: number) => number` mapping domain values to range values.
22
+ */
23
+ function createLinearScale(domain, range) {
24
+ const [d0, d1] = domain;
25
+ const [r0, r1] = range;
26
+ const dSpan = d1 - d0;
27
+ if (dSpan === 0) {
28
+ return () => r0;
29
+ }
30
+ const rSpan = r1 - r0;
31
+ return (v) => r0 + ((v - d0) / dSpan) * rSpan;
32
+ }
33
+
34
+ /**
35
+ * Pure-TS time scale. Reuses {@link createLinearScale} after coercing
36
+ * `Date` endpoints (and inputs) to epoch milliseconds. Supports
37
+ * inverted domains and bare-number timestamps interchangeably.
38
+ *
39
+ * @param domain `[start, end]` time range. `Date` and `number` are
40
+ * interchangeable on either endpoint.
41
+ * @param range `[start, end]` output range (typically pixel coordinates).
42
+ * @returns `(v: Date | number) => number` mapping time values to range
43
+ * values.
44
+ */
45
+ function createTimeScale(domain, range) {
46
+ const d0 = toMs$2(domain[0]);
47
+ const d1 = toMs$2(domain[1]);
48
+ const linear = createLinearScale([d0, d1], range);
49
+ return (v) => linear(toMs$2(v));
50
+ }
51
+ function toMs$2(v) {
52
+ return typeof v === 'number' ? v : v.getTime();
53
+ }
54
+
55
+ /**
56
+ * Construct a {@link BandScale} from a categorical domain and a numeric
57
+ * range. See the type-level documentation above for parameter
58
+ * semantics.
59
+ */
60
+ function createBandScale(domain, range, padding = 0) {
61
+ const [r0, r1] = range;
62
+ const n = domain.length;
63
+ const span = r1 - r0;
64
+ const slot = n === 0 ? 0 : span / n;
65
+ const inner = slot * (1 - padding);
66
+ const offset = (slot - inner) / 2;
67
+ const lookup = new Map();
68
+ for (let i = 0; i < n; i++) {
69
+ lookup.set(domain[i], r0 + i * slot + offset);
70
+ }
71
+ const fn = ((v) => {
72
+ return lookup.get(v) ?? NaN;
73
+ });
74
+ fn.bandwidth = () => inner;
75
+ return fn;
76
+ }
77
+
78
+ /**
79
+ * Pure-TS ordinal scale. Maps a discrete categorical domain to a
80
+ * cycling palette of values (typically colours). When the domain is
81
+ * longer than the palette, mappings wrap modulo palette length.
82
+ *
83
+ * @param domain Ordered list of categorical values. Values are matched
84
+ * by reference equality on lookup.
85
+ * @param colors Palette to cycle through. Must have at least one entry;
86
+ * an empty palette throws synchronously at construction time.
87
+ * @returns Callable `(v: T) => string` returning the palette entry for
88
+ * `v`. Lookup of an unknown value returns the palette's first entry.
89
+ */
90
+ function createOrdinalScale(domain, colors) {
91
+ if (colors.length === 0) {
92
+ throw new Error('createOrdinalScale: colors palette must not be empty');
93
+ }
94
+ const lookup = new Map();
95
+ for (let i = 0; i < domain.length; i++) {
96
+ lookup.set(domain[i], colors[i % colors.length]);
97
+ }
98
+ return (v) => lookup.get(v) ?? colors[0];
99
+ }
100
+
101
+ /**
102
+ * Injection token consumed by every chart child (`[cngxAxis]`, layer
103
+ * atoms, `<cngx-chart-data-table>`). `<cngx-chart>` provides itself
104
+ * via `useExisting`; child queries narrow the generic on the consumer
105
+ * side.
106
+ */
107
+ const CNGX_CHART_CONTEXT = new InjectionToken('CngxChartContext');
108
+ /**
109
+ * Inject the parent chart's reactive context. Throws a clear dev-mode
110
+ * error when the consumer is not mounted as a content child of
111
+ * `<cngx-chart>`. The `consumerName` argument is interpolated into the
112
+ * error message so the consumer-class name surfaces at the call site
113
+ * rather than a generic guard string.
114
+ *
115
+ * Replaces six verbatim copies of the same six-line helper that
116
+ * previously lived inline in every layer atom.
117
+ */
118
+ function injectChartContext(consumerName) {
119
+ const ctx = inject(CNGX_CHART_CONTEXT, { optional: true });
120
+ if (!ctx) {
121
+ throw new Error(`${consumerName}: missing CNGX_CHART_CONTEXT — must be a content child of <cngx-chart>`);
122
+ }
123
+ return ctx;
124
+ }
125
+
126
+ const DEFAULT_TICK_COUNT = 5;
127
+ const TICK_LENGTH = 5;
128
+ const LABEL_OFFSET = 4;
129
+ const AXIS_LABEL_OFFSET_INLINE = 32;
130
+ const AXIS_LABEL_OFFSET_BLOCK = 36;
131
+ /**
132
+ * Declarative axis directive. Lives as a content child of
133
+ * `<cngx-chart>`; its `position` + `type` + `domain` inputs feed the
134
+ * parent's scale derivation. Renders SVG ticks and labels in the
135
+ * coordinate system the parent publishes via {@link CNGX_CHART_CONTEXT}.
136
+ *
137
+ * Attribute-selector on `<svg:g>` — the host element IS the SVG group.
138
+ * This keeps the namespace boundary clean: a `<cngx-axis>` element
139
+ * inside `<svg>` would be in the XHTML namespace and SVG layout would
140
+ * not flow through it. By making the directive attribute-only, the
141
+ * host stays in the SVG namespace and the browser lays out tick lines
142
+ * and labels exactly where the geometry says.
143
+ *
144
+ * Host carries `aria-hidden="true"` — axis text is decoration; the
145
+ * semantic data view lives on the parent chart's auto-Summary and
146
+ * Data Table.
147
+ */
148
+ class CngxAxis {
149
+ position = input.required(...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
150
+ type = input('linear', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
151
+ domain = input(undefined, ...(ngDevMode ? [{ debugName: "domain" }] : /* istanbul ignore next */ []));
152
+ tickCount = input(undefined, { ...(ngDevMode ? { debugName: "tickCount" } : /* istanbul ignore next */ {}), alias: 'ticks' });
153
+ format = input(defaultTickFormat, ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
154
+ /**
155
+ * Render decorative gridlines extending from each tick across the
156
+ * chart's perpendicular dimension. Theming via the
157
+ * `--cngx-axis-grid-color` / `--cngx-axis-grid-opacity` /
158
+ * `--cngx-axis-grid-stroke-width` / `--cngx-axis-grid-dasharray`
159
+ * CSS custom properties (defaults: chart-level grid colour, 0.6
160
+ * opacity, 1px solid). Aliased as `[grid]` for terseness.
161
+ */
162
+ showGrid = input(false, { ...(ngDevMode ? { debugName: "showGrid" } : /* istanbul ignore next */ {}), alias: 'grid' });
163
+ /**
164
+ * Optional axis title rendered alongside the tick labels —
165
+ * "Months", "Revenue (k€)", etc. The title is positioned outside
166
+ * the tick labels (further from the chart area) and rotated -90°
167
+ * for left/right axes so it reads bottom-to-top. Theming via the
168
+ * `--cngx-axis-axis-label-color` and `--cngx-axis-axis-label-font-size`
169
+ * CSS custom properties (default: chart text colour + 12px). Aliased
170
+ * `[label]` for terseness.
171
+ */
172
+ axisLabel = input(null, { ...(ngDevMode ? { debugName: "axisLabel" } : /* istanbul ignore next */ {}), alias: 'label' });
173
+ ctx = inject(CNGX_CHART_CONTEXT);
174
+ /**
175
+ * Tick values to render. Resolution order:
176
+ * 1. `type='band'` and `[domain]` provided → one tick per domain
177
+ * value.
178
+ * 2. linear/time + `[domain]` provided → `[ticks]`-many evenly
179
+ * spaced positions across the domain (default 5).
180
+ * 3. Otherwise → empty array. Axis still renders the line.
181
+ */
182
+ tickValues = computed(() => {
183
+ const dom = this.domain();
184
+ const count = this.tickCount() ?? DEFAULT_TICK_COUNT;
185
+ const t = this.type();
186
+ if (t === 'band') {
187
+ return dom ?? [];
188
+ }
189
+ if (!dom || dom.length < 2) {
190
+ return [];
191
+ }
192
+ if (t === 'time') {
193
+ const start = toMs$1(dom[0]);
194
+ const end = toMs$1(dom[dom.length - 1]);
195
+ return spread(start, end, count).map((ms) => new Date(ms));
196
+ }
197
+ const start = Number(dom[0]);
198
+ const end = Number(dom[dom.length - 1]);
199
+ return spread(start, end, count);
200
+ }, { ...(ngDevMode ? { debugName: "tickValues" } : /* istanbul ignore next */ {}), equal: (a, b) => {
201
+ if (a === b) {
202
+ return true;
203
+ }
204
+ if (a.length !== b.length) {
205
+ return false;
206
+ }
207
+ for (let i = 0; i < a.length; i++) {
208
+ const av = a[i];
209
+ const bv = b[i];
210
+ if (Object.is(av, bv)) {
211
+ continue;
212
+ }
213
+ if (av instanceof Date && bv instanceof Date && av.getTime() === bv.getTime()) {
214
+ continue;
215
+ }
216
+ return false;
217
+ }
218
+ return true;
219
+ } });
220
+ hostClass = computed(() => `cngx-axis cngx-axis--${this.position()}`, ...(ngDevMode ? [{ debugName: "hostClass" }] : /* istanbul ignore next */ []));
221
+ axisLabelGeometry = computed(() => {
222
+ const { width, height } = this.ctx.dimensions();
223
+ if (width <= 0 || height <= 0) {
224
+ return null;
225
+ }
226
+ return buildAxisLabelGeometry(this.position(), width, height);
227
+ }, { ...(ngDevMode ? { debugName: "axisLabelGeometry" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
228
+ (a !== null && b !== null && a.transform === b.transform && a.anchor === b.anchor && a.baseline === b.baseline) });
229
+ axisGeometry = computed(() => {
230
+ const { width, height } = this.ctx.dimensions();
231
+ if (width <= 0 || height <= 0) {
232
+ return null;
233
+ }
234
+ const pos = this.position();
235
+ return buildAxisGeometry(pos, width, height);
236
+ }, { ...(ngDevMode ? { debugName: "axisGeometry" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
237
+ (a !== null &&
238
+ b !== null &&
239
+ a.transform === b.transform &&
240
+ a.line.x1 === b.line.x1 &&
241
+ a.line.y1 === b.line.y1 &&
242
+ a.line.x2 === b.line.x2 &&
243
+ a.line.y2 === b.line.y2) });
244
+ tickRenderings = computed(() => {
245
+ const pos = this.position();
246
+ const values = this.tickValues();
247
+ const fmt = this.format();
248
+ const { width, height } = this.ctx.dimensions();
249
+ const isHorizontal = pos === 'top' || pos === 'bottom';
250
+ const scale = isHorizontal ? this.ctx.xScale() : this.ctx.yScale();
251
+ return values.map((v, i) => {
252
+ const offset = scale(v);
253
+ return buildTickRendering(pos, offset, fmt(v), `${i}-${String(v)}`, width, height);
254
+ });
255
+ }, { ...(ngDevMode ? { debugName: "tickRenderings" } : /* istanbul ignore next */ {}), equal: (a, b) => {
256
+ if (a === b) {
257
+ return true;
258
+ }
259
+ if (a.length !== b.length) {
260
+ return false;
261
+ }
262
+ for (let i = 0; i < a.length; i++) {
263
+ const ta = a[i];
264
+ const tb = b[i];
265
+ if (ta.key !== tb.key ||
266
+ ta.transform !== tb.transform ||
267
+ ta.label.text !== tb.label.text ||
268
+ ta.tickLine.x1 !== tb.tickLine.x1 ||
269
+ ta.tickLine.y1 !== tb.tickLine.y1 ||
270
+ ta.tickLine.x2 !== tb.tickLine.x2 ||
271
+ ta.tickLine.y2 !== tb.tickLine.y2 ||
272
+ ta.gridLine.x2 !== tb.gridLine.x2 ||
273
+ ta.gridLine.y2 !== tb.gridLine.y2) {
274
+ return false;
275
+ }
276
+ }
277
+ return true;
278
+ } });
279
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAxis, deps: [], target: i0.ɵɵFactoryTarget.Component });
280
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxAxis, isStandalone: true, selector: "[cngxAxis]", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: true, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, domain: { classPropertyName: "domain", publicName: "domain", isSignal: true, isRequired: false, transformFunction: null }, tickCount: { classPropertyName: "tickCount", publicName: "ticks", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, showGrid: { classPropertyName: "showGrid", publicName: "grid", isSignal: true, isRequired: false, transformFunction: null }, axisLabel: { classPropertyName: "axisLabel", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" }, properties: { "attr.transform": "axisGeometry()?.transform ?? null", "attr.class": "hostClass()" } }, exportAs: ["cngxAxis"], ngImport: i0, template: `
281
+ @if (axisGeometry(); as g) {
282
+ @if (showGrid()) {
283
+ @for (tick of tickRenderings(); track tick.key) {
284
+ <svg:line
285
+ [attr.transform]="tick.transform"
286
+ [attr.x1]="0"
287
+ [attr.y1]="0"
288
+ [attr.x2]="tick.gridLine.x2"
289
+ [attr.y2]="tick.gridLine.y2"
290
+ class="cngx-axis__grid-line"
291
+ />
292
+ }
293
+ }
294
+ <svg:line
295
+ [attr.x1]="g.line.x1"
296
+ [attr.y1]="g.line.y1"
297
+ [attr.x2]="g.line.x2"
298
+ [attr.y2]="g.line.y2"
299
+ class="cngx-axis__line"
300
+ />
301
+ @for (tick of tickRenderings(); track tick.key) {
302
+ <svg:g [attr.transform]="tick.transform" class="cngx-axis__tick">
303
+ <svg:line
304
+ [attr.x1]="tick.tickLine.x1"
305
+ [attr.y1]="tick.tickLine.y1"
306
+ [attr.x2]="tick.tickLine.x2"
307
+ [attr.y2]="tick.tickLine.y2"
308
+ class="cngx-axis__tick-line"
309
+ />
310
+ <svg:text
311
+ [attr.x]="tick.label.x"
312
+ [attr.y]="tick.label.y"
313
+ [attr.text-anchor]="tick.label.anchor"
314
+ [attr.dominant-baseline]="tick.label.baseline"
315
+ class="cngx-axis__tick-label"
316
+ >
317
+ {{ tick.label.text }}
318
+ </svg:text>
319
+ </svg:g>
320
+ }
321
+ @if (axisLabel(); as title) {
322
+ @if (axisLabelGeometry(); as g) {
323
+ <svg:text
324
+ class="cngx-axis__axis-label"
325
+ [attr.transform]="g.transform"
326
+ [attr.text-anchor]="g.anchor"
327
+ [attr.dominant-baseline]="g.baseline"
328
+ >{{ title }}</svg:text>
329
+ }
330
+ }
331
+ }
332
+ `, isInline: true, styles: [".cngx-axis__line,.cngx-axis__tick-line{stroke:var(--cngx-axis-color, var(--cngx-chart-axis-color, currentColor));stroke-width:var(--cngx-axis-stroke-width, 1px);fill:none}.cngx-axis__tick-label{fill:var(--cngx-axis-text-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-font-size, 11px)}.cngx-axis__grid-line{stroke:var(--cngx-axis-grid-color, var(--cngx-chart-grid-color, currentColor));stroke-opacity:var(--cngx-axis-grid-opacity, .6);stroke-width:var(--cngx-axis-grid-stroke-width, 1px);stroke-dasharray:var(--cngx-axis-grid-dasharray, 0);fill:none;pointer-events:none}.cngx-axis__axis-label{fill:var(--cngx-axis-axis-label-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-axis-label-font-size, 12px);font-weight:var(--cngx-axis-axis-label-font-weight, 500)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
333
+ }
334
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAxis, decorators: [{
335
+ type: Component,
336
+ args: [{ selector: '[cngxAxis]', exportAs: 'cngxAxis', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
337
+ 'aria-hidden': 'true',
338
+ '[attr.transform]': 'axisGeometry()?.transform ?? null',
339
+ '[attr.class]': 'hostClass()',
340
+ }, template: `
341
+ @if (axisGeometry(); as g) {
342
+ @if (showGrid()) {
343
+ @for (tick of tickRenderings(); track tick.key) {
344
+ <svg:line
345
+ [attr.transform]="tick.transform"
346
+ [attr.x1]="0"
347
+ [attr.y1]="0"
348
+ [attr.x2]="tick.gridLine.x2"
349
+ [attr.y2]="tick.gridLine.y2"
350
+ class="cngx-axis__grid-line"
351
+ />
352
+ }
353
+ }
354
+ <svg:line
355
+ [attr.x1]="g.line.x1"
356
+ [attr.y1]="g.line.y1"
357
+ [attr.x2]="g.line.x2"
358
+ [attr.y2]="g.line.y2"
359
+ class="cngx-axis__line"
360
+ />
361
+ @for (tick of tickRenderings(); track tick.key) {
362
+ <svg:g [attr.transform]="tick.transform" class="cngx-axis__tick">
363
+ <svg:line
364
+ [attr.x1]="tick.tickLine.x1"
365
+ [attr.y1]="tick.tickLine.y1"
366
+ [attr.x2]="tick.tickLine.x2"
367
+ [attr.y2]="tick.tickLine.y2"
368
+ class="cngx-axis__tick-line"
369
+ />
370
+ <svg:text
371
+ [attr.x]="tick.label.x"
372
+ [attr.y]="tick.label.y"
373
+ [attr.text-anchor]="tick.label.anchor"
374
+ [attr.dominant-baseline]="tick.label.baseline"
375
+ class="cngx-axis__tick-label"
376
+ >
377
+ {{ tick.label.text }}
378
+ </svg:text>
379
+ </svg:g>
380
+ }
381
+ @if (axisLabel(); as title) {
382
+ @if (axisLabelGeometry(); as g) {
383
+ <svg:text
384
+ class="cngx-axis__axis-label"
385
+ [attr.transform]="g.transform"
386
+ [attr.text-anchor]="g.anchor"
387
+ [attr.dominant-baseline]="g.baseline"
388
+ >{{ title }}</svg:text>
389
+ }
390
+ }
391
+ }
392
+ `, styles: [".cngx-axis__line,.cngx-axis__tick-line{stroke:var(--cngx-axis-color, var(--cngx-chart-axis-color, currentColor));stroke-width:var(--cngx-axis-stroke-width, 1px);fill:none}.cngx-axis__tick-label{fill:var(--cngx-axis-text-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-font-size, 11px)}.cngx-axis__grid-line{stroke:var(--cngx-axis-grid-color, var(--cngx-chart-grid-color, currentColor));stroke-opacity:var(--cngx-axis-grid-opacity, .6);stroke-width:var(--cngx-axis-grid-stroke-width, 1px);stroke-dasharray:var(--cngx-axis-grid-dasharray, 0);fill:none;pointer-events:none}.cngx-axis__axis-label{fill:var(--cngx-axis-axis-label-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-axis-axis-label-font-size, 12px);font-weight:var(--cngx-axis-axis-label-font-weight, 500)}\n"] }]
393
+ }], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: true }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], domain: [{ type: i0.Input, args: [{ isSignal: true, alias: "domain", required: false }] }], tickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "ticks", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], showGrid: [{ type: i0.Input, args: [{ isSignal: true, alias: "grid", required: false }] }], axisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
394
+ function spread(start, end, count) {
395
+ if (count <= 1) {
396
+ return [start];
397
+ }
398
+ const span = end - start;
399
+ const step = span / (count - 1);
400
+ const out = new Array(count);
401
+ for (let i = 0; i < count; i++) {
402
+ out[i] = start + step * i;
403
+ }
404
+ return out;
405
+ }
406
+ function toMs$1(v) {
407
+ if (typeof v === 'number') {
408
+ return v;
409
+ }
410
+ if (v instanceof Date) {
411
+ return v.getTime();
412
+ }
413
+ return Number(v);
414
+ }
415
+ function buildAxisGeometry(pos, width, height) {
416
+ switch (pos) {
417
+ case 'top':
418
+ return {
419
+ transform: 'translate(0,0)',
420
+ line: { x1: 0, y1: 0, x2: width, y2: 0 },
421
+ };
422
+ case 'bottom':
423
+ return {
424
+ transform: `translate(0,${height})`,
425
+ line: { x1: 0, y1: 0, x2: width, y2: 0 },
426
+ };
427
+ case 'left':
428
+ return {
429
+ transform: 'translate(0,0)',
430
+ line: { x1: 0, y1: 0, x2: 0, y2: height },
431
+ };
432
+ case 'right':
433
+ return {
434
+ transform: `translate(${width},0)`,
435
+ line: { x1: 0, y1: 0, x2: 0, y2: height },
436
+ };
437
+ }
438
+ }
439
+ function buildTickRendering(pos, offset, text, key, width, height) {
440
+ switch (pos) {
441
+ case 'bottom':
442
+ return {
443
+ key,
444
+ transform: `translate(${offset},0)`,
445
+ tickLine: { x1: 0, y1: 0, x2: 0, y2: TICK_LENGTH },
446
+ gridLine: { x2: 0, y2: -height },
447
+ label: {
448
+ x: 0,
449
+ y: TICK_LENGTH + LABEL_OFFSET,
450
+ anchor: 'middle',
451
+ baseline: 'hanging',
452
+ text,
453
+ },
454
+ };
455
+ case 'top':
456
+ return {
457
+ key,
458
+ transform: `translate(${offset},0)`,
459
+ tickLine: { x1: 0, y1: 0, x2: 0, y2: -TICK_LENGTH },
460
+ gridLine: { x2: 0, y2: height },
461
+ label: {
462
+ x: 0,
463
+ y: -TICK_LENGTH - LABEL_OFFSET,
464
+ anchor: 'middle',
465
+ baseline: 'auto',
466
+ text,
467
+ },
468
+ };
469
+ case 'left':
470
+ return {
471
+ key,
472
+ transform: `translate(0,${offset})`,
473
+ tickLine: { x1: 0, y1: 0, x2: -TICK_LENGTH, y2: 0 },
474
+ gridLine: { x2: width, y2: 0 },
475
+ label: {
476
+ x: -TICK_LENGTH - LABEL_OFFSET,
477
+ y: 0,
478
+ anchor: 'end',
479
+ baseline: 'middle',
480
+ text,
481
+ },
482
+ };
483
+ case 'right':
484
+ return {
485
+ key,
486
+ transform: `translate(0,${offset})`,
487
+ tickLine: { x1: 0, y1: 0, x2: TICK_LENGTH, y2: 0 },
488
+ gridLine: { x2: -width, y2: 0 },
489
+ label: {
490
+ x: TICK_LENGTH + LABEL_OFFSET,
491
+ y: 0,
492
+ anchor: 'start',
493
+ baseline: 'middle',
494
+ text,
495
+ },
496
+ };
497
+ }
498
+ }
499
+ /**
500
+ * Default tick label formatter. Strips floating-point arithmetic
501
+ * noise from non-integer numbers — `6.6000000000000005` becomes
502
+ * `'6.6'`, `2.2` stays `'2.2'`, `25` stays `'25'` — without rounding
503
+ * away meaningful precision. Dates and other types fall through to
504
+ * `String(v)`; consumers needing a richer format bind `[format]`.
505
+ */
506
+ function defaultTickFormat(v) {
507
+ if (typeof v === 'number') {
508
+ if (Number.isInteger(v)) {
509
+ return String(v);
510
+ }
511
+ if (!Number.isFinite(v)) {
512
+ return String(v);
513
+ }
514
+ // 12 significant digits is more than enough for any sensible
515
+ // chart domain while collapsing the trailing 1e-15 noise
516
+ // produced by accumulated float math.
517
+ return Number(v.toPrecision(12)).toString();
518
+ }
519
+ return String(v);
520
+ }
521
+ function buildAxisLabelGeometry(pos, width, height) {
522
+ switch (pos) {
523
+ case 'bottom':
524
+ return {
525
+ transform: `translate(${width / 2},${AXIS_LABEL_OFFSET_INLINE})`,
526
+ anchor: 'middle',
527
+ baseline: 'hanging',
528
+ };
529
+ case 'top':
530
+ return {
531
+ transform: `translate(${width / 2},${-AXIS_LABEL_OFFSET_INLINE})`,
532
+ anchor: 'middle',
533
+ baseline: 'auto',
534
+ };
535
+ case 'left':
536
+ return {
537
+ transform: `translate(${-AXIS_LABEL_OFFSET_BLOCK},${height / 2}) rotate(-90)`,
538
+ anchor: 'middle',
539
+ baseline: 'auto',
540
+ };
541
+ case 'right':
542
+ return {
543
+ transform: `translate(${AXIS_LABEL_OFFSET_BLOCK},${height / 2}) rotate(90)`,
544
+ anchor: 'middle',
545
+ baseline: 'auto',
546
+ };
547
+ }
548
+ }
549
+
550
+ /**
551
+ * Threshold reference atom. Renders a single horizontal `<line>` at
552
+ * `yScale(value)` spanning the chart's full width, plus an optional
553
+ * `<text>` label at the right edge.
554
+ *
555
+ * Common use: target threshold ("budget cap"), warning bands, or any
556
+ * "line at value" reference. Always reads scales from
557
+ * {@link CNGX_CHART_CONTEXT}.
558
+ *
559
+ * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
560
+ */
561
+ class CngxThreshold {
562
+ value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
563
+ label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
564
+ dashed = input(false, ...(ngDevMode ? [{ debugName: "dashed" }] : /* istanbul ignore next */ []));
565
+ ctx = injectChartContext('CngxThreshold');
566
+ geometry = computed(() => {
567
+ const { width, height } = this.ctx.dimensions();
568
+ if (width <= 0 || height <= 0) {
569
+ return null;
570
+ }
571
+ const y = this.ctx.yScale()(this.value());
572
+ return { width, y };
573
+ }, { ...(ngDevMode ? { debugName: "geometry" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b || (a !== null && b !== null && a.width === b.width && a.y === b.y) });
574
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxThreshold, deps: [], target: i0.ɵɵFactoryTarget.Component });
575
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxThreshold, isStandalone: true, selector: "[cngxThreshold]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, dashed: { classPropertyName: "dashed", publicName: "dashed", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxThreshold"], ngImport: i0, template: `
576
+ @if (geometry(); as g) {
577
+ <svg:line
578
+ class="cngx-threshold__line"
579
+ [attr.x1]="0"
580
+ [attr.y1]="g.y"
581
+ [attr.x2]="g.width"
582
+ [attr.y2]="g.y"
583
+ [attr.stroke-dasharray]="dashed() ? '4 3' : null"
584
+ />
585
+ @if (label(); as l) {
586
+ <svg:text
587
+ class="cngx-threshold__label"
588
+ [attr.x]="g.width - 4"
589
+ [attr.y]="g.y - 4"
590
+ text-anchor="end"
591
+ >
592
+ {{ l }}
593
+ </svg:text>
594
+ }
595
+ }
596
+ `, isInline: true, styles: [".cngx-threshold__line{stroke:var(--cngx-threshold-color, var(--cngx-chart-danger, currentColor));stroke-width:var(--cngx-threshold-stroke-width, 1px);fill:none;animation:cngx-threshold-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}.cngx-threshold__label{fill:var(--cngx-threshold-text-color, var(--cngx-chart-danger, currentColor));font-size:var(--cngx-threshold-font-size, 11px);animation:cngx-threshold-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-threshold-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-threshold__line,.cngx-threshold__label{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
597
+ }
598
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxThreshold, decorators: [{
599
+ type: Component,
600
+ args: [{ selector: '[cngxThreshold]', exportAs: 'cngxThreshold', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
601
+ @if (geometry(); as g) {
602
+ <svg:line
603
+ class="cngx-threshold__line"
604
+ [attr.x1]="0"
605
+ [attr.y1]="g.y"
606
+ [attr.x2]="g.width"
607
+ [attr.y2]="g.y"
608
+ [attr.stroke-dasharray]="dashed() ? '4 3' : null"
609
+ />
610
+ @if (label(); as l) {
611
+ <svg:text
612
+ class="cngx-threshold__label"
613
+ [attr.x]="g.width - 4"
614
+ [attr.y]="g.y - 4"
615
+ text-anchor="end"
616
+ >
617
+ {{ l }}
618
+ </svg:text>
619
+ }
620
+ }
621
+ `, styles: [".cngx-threshold__line{stroke:var(--cngx-threshold-color, var(--cngx-chart-danger, currentColor));stroke-width:var(--cngx-threshold-stroke-width, 1px);fill:none;animation:cngx-threshold-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}.cngx-threshold__label{fill:var(--cngx-threshold-text-color, var(--cngx-chart-danger, currentColor));font-size:var(--cngx-threshold-font-size, 11px);animation:cngx-threshold-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-threshold-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-threshold__line,.cngx-threshold__label{animation:none}}\n"] }]
622
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], dashed: [{ type: i0.Input, args: [{ isSignal: true, alias: "dashed", required: false }] }] } });
623
+
624
+ /**
625
+ * Injection token for chart i18n strings. Defaults to English via
626
+ * `factory:`. Override at app root with {@link provideChartI18n}.
627
+ */
628
+ const CNGX_CHART_I18N = new InjectionToken('CngxChartI18n', {
629
+ providedIn: 'root',
630
+ factory: () => ({
631
+ summary: ({ trend, min, max, current, thresholds }) => {
632
+ const trendText = trend === 'up' ? 'Trending up' : trend === 'down' ? 'Trending down' : 'Flat';
633
+ const thresholdText = thresholds.length === 0
634
+ ? 'No thresholds.'
635
+ : thresholds.length === 1
636
+ ? 'One threshold crossing.'
637
+ : `${thresholds.length} threshold crossings.`;
638
+ return `${trendText}. Min ${min}, max ${max}, current ${current}. ${thresholdText}`;
639
+ },
640
+ dataTable: () => 'Data table',
641
+ valueColumnLabel: () => 'Value',
642
+ trendChanged: (trend) => trend === 'up' ? 'Trend changed to up' : trend === 'down' ? 'Trend changed to down' : 'Trend flattened',
643
+ thresholdAlert: (threshold) => `Threshold ${threshold} crossed`,
644
+ empty: () => 'No data',
645
+ loading: () => 'Loading',
646
+ error: () => 'Error loading chart',
647
+ }),
648
+ });
649
+ /**
650
+ * Provider helper for custom chart i18n strings.
651
+ *
652
+ * ```typescript
653
+ * providers: [provideChartI18n({
654
+ * summary: ({ trend, min, max, current, thresholds }) =>
655
+ * `${trend === 'up' ? 'Aufwärtstrend' : 'Abwärtstrend'}. Min ${min}, Max ${max}, aktuell ${current}.`,
656
+ * dataTable: () => 'Datentabelle',
657
+ * // ...remaining keys
658
+ * })]
659
+ * ```
660
+ */
661
+ function provideChartI18n(i18n) {
662
+ return { provide: CNGX_CHART_I18N, useValue: i18n };
663
+ }
664
+
665
+ /**
666
+ * Internal SR-only data-table view. The parent `<cngx-chart>` mounts
667
+ * one of these and links it via `aria-describedby`. The element is
668
+ * always present in the DOM — visibility flips through `aria-hidden`
669
+ * controlled by the chart's `tableActive` predicate. This is the
670
+ * Pillar-2 always-in-DOM contract: the linked id never disappears
671
+ * from the host, only the row content's accessibility-tree visibility
672
+ * does.
673
+ *
674
+ * V1 surface is single-column ("Value") backed by the chart's
675
+ * `summary`-projected numeric values. Phase 4+ may widen to one
676
+ * column per layer accessor; the column header derivation is
677
+ * intentionally minimal until that lands.
678
+ *
679
+ * @internal
680
+ */
681
+ class CngxChartDataTable {
682
+ values = input.required(...(ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []));
683
+ hidden = input.required(...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
684
+ /**
685
+ * Stable id consumed by the chart's `aria-describedby` binding.
686
+ * Optional input — when omitted, falls back to a per-instance
687
+ * `nextUid`-allocated default. Two standalone tables without an
688
+ * explicit `[id]` therefore receive different ids; the always-in-
689
+ * DOM rule cannot be violated by an unset input.
690
+ */
691
+ id = input(undefined, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
692
+ defaultId = nextUid('cngx-chart-data-table');
693
+ i18n = inject(CNGX_CHART_I18N);
694
+ /**
695
+ * Resolved host id — the explicit `[id]` input wins over the
696
+ * per-instance default. The host binding reads this signal so
697
+ * external `aria-describedby` references stay live across input
698
+ * changes.
699
+ */
700
+ resolvedId = computed(() => this.id() ?? this.defaultId, ...(ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []));
701
+ caption = computed(() => this.i18n.dataTable(), ...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
702
+ valueColumnLabel = computed(() => this.i18n.valueColumnLabel(), ...(ngDevMode ? [{ debugName: "valueColumnLabel" }] : /* istanbul ignore next */ []));
703
+ rows = computed(() => {
704
+ const vs = this.values();
705
+ const out = new Array(vs.length);
706
+ for (let i = 0; i < vs.length; i++) {
707
+ out[i] = { index: i, value: vs[i] };
708
+ }
709
+ return out;
710
+ }, { ...(ngDevMode ? { debugName: "rows" } : /* istanbul ignore next */ {}), equal: (a, b) => {
711
+ if (a === b) {
712
+ return true;
713
+ }
714
+ if (a.length !== b.length) {
715
+ return false;
716
+ }
717
+ for (let i = 0; i < a.length; i++) {
718
+ if (a[i].index !== b[i].index || !Object.is(a[i].value, b[i].value)) {
719
+ return false;
720
+ }
721
+ }
722
+ return true;
723
+ } });
724
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartDataTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
725
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChartDataTable, isStandalone: true, selector: "cngx-chart-data-table", inputs: { values: { classPropertyName: "values", publicName: "values", isSignal: true, isRequired: true, transformFunction: null }, hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: true, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "id": "resolvedId()", "attr.aria-hidden": "hidden() ? \"true\" : \"false\"" } }, ngImport: i0, template: `
726
+ <table class="cngx-chart-data-table__table">
727
+ <caption>{{ caption() }}</caption>
728
+ <thead>
729
+ <tr>
730
+ <th scope="col">#</th>
731
+ <th scope="col">{{ valueColumnLabel() }}</th>
732
+ </tr>
733
+ </thead>
734
+ <tbody>
735
+ @for (row of rows(); track row.index) {
736
+ <tr>
737
+ <th scope="row">{{ row.index + 1 }}</th>
738
+ <td>{{ row.value }}</td>
739
+ </tr>
740
+ }
741
+ </tbody>
742
+ </table>
743
+ `, isInline: true, styles: ["cngx-chart-data-table{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
744
+ }
745
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartDataTable, decorators: [{
746
+ type: Component,
747
+ args: [{ selector: 'cngx-chart-data-table', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
748
+ '[id]': 'resolvedId()',
749
+ '[attr.aria-hidden]': 'hidden() ? "true" : "false"',
750
+ }, template: `
751
+ <table class="cngx-chart-data-table__table">
752
+ <caption>{{ caption() }}</caption>
753
+ <thead>
754
+ <tr>
755
+ <th scope="col">#</th>
756
+ <th scope="col">{{ valueColumnLabel() }}</th>
757
+ </tr>
758
+ </thead>
759
+ <tbody>
760
+ @for (row of rows(); track row.index) {
761
+ <tr>
762
+ <th scope="row">{{ row.index + 1 }}</th>
763
+ <td>{{ row.value }}</td>
764
+ </tr>
765
+ }
766
+ </tbody>
767
+ </table>
768
+ `, styles: ["cngx-chart-data-table{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}\n"] }]
769
+ }], propDecorators: { values: [{ type: i0.Input, args: [{ isSignal: true, alias: "values", required: true }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: true }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
770
+
771
+ /**
772
+ * Threshold (px) below which `CngxChartSlotContext.small` is true.
773
+ * Hardcoded for v1; later releases may make this a config token.
774
+ */
775
+ const CHART_SMALL_BREAKPOINT_PX = 400;
776
+ /**
777
+ * Per-instance loading slot for `<cngx-chart>`. Project an
778
+ * `<ng-template cngxChartLoading>` to override the default centred
779
+ * spinner. The template receives a {@link CngxChartSlotContext} with
780
+ * the chart's rendered width/height plus a `small` flag for
781
+ * container-size-aware branching.
782
+ *
783
+ * ```html
784
+ * <cngx-chart [state]="state()">
785
+ * <ng-template cngxChartLoading let-small="small">
786
+ * @if (small) { <my-mini-spinner /> }
787
+ * @else { <my-branded-spinner /> }
788
+ * </ng-template>
789
+ * </cngx-chart>
790
+ * ```
791
+ */
792
+ class CngxChartLoading {
793
+ templateRef = inject((TemplateRef));
794
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartLoading, deps: [], target: i0.ɵɵFactoryTarget.Directive });
795
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxChartLoading, isStandalone: true, selector: "ng-template[cngxChartLoading]", ngImport: i0 });
796
+ }
797
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartLoading, decorators: [{
798
+ type: Directive,
799
+ args: [{
800
+ selector: 'ng-template[cngxChartLoading]',
801
+ standalone: true,
802
+ }]
803
+ }] });
804
+ /**
805
+ * Per-instance empty slot for `<cngx-chart>`. Receives a
806
+ * {@link CngxChartSlotContext} so the consumer can branch on chart
807
+ * size — typically a compact text fallback when `small` is true and
808
+ * a richer surface (`<cngx-empty-state>`, illustration, action) at
809
+ * regular sizes.
810
+ */
811
+ class CngxChartEmpty {
812
+ templateRef = inject((TemplateRef));
813
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
814
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxChartEmpty, isStandalone: true, selector: "ng-template[cngxChartEmpty]", ngImport: i0 });
815
+ }
816
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartEmpty, decorators: [{
817
+ type: Directive,
818
+ args: [{
819
+ selector: 'ng-template[cngxChartEmpty]',
820
+ standalone: true,
821
+ }]
822
+ }] });
823
+ /**
824
+ * `*cngxChartError` slot — overrides the chart-level error placeholder.
825
+ * Receives a {@link CngxChartErrorContext}.
826
+ */
827
+ class CngxChartError {
828
+ templateRef = inject((TemplateRef));
829
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
830
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxChartError, isStandalone: true, selector: "ng-template[cngxChartError]", ngImport: i0 });
831
+ }
832
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartError, decorators: [{
833
+ type: Directive,
834
+ args: [{
835
+ selector: 'ng-template[cngxChartError]',
836
+ standalone: true,
837
+ }]
838
+ }] });
839
+
840
+ /**
841
+ * Pure helper that derives a `CngxChartSummary` from already-projected
842
+ * numeric values plus a list of threshold values. The chart component
843
+ * passes the result to `CngxChartI18n.summary()` to produce the
844
+ * `aria-label` text the host announces to screen readers.
845
+ *
846
+ * Trend rule: if the last value is more than 5% of the data's range
847
+ * above the first, the trend is `'up'`; below, `'down'`; otherwise
848
+ * `'flat'`. The 5% deadband prevents trivial fluctuations from
849
+ * flipping the trend label and keeps the summary stable across
850
+ * minor data refreshes.
851
+ *
852
+ * Threshold rule: a threshold is "crossed" if the data series goes
853
+ * from above to below or vice versa anywhere in the projected range.
854
+ * The returned `thresholds` list is the subset of input thresholds
855
+ * the data actually crosses, in input order.
856
+ */
857
+ function computeChartSummary(values, thresholds) {
858
+ if (values.length === 0) {
859
+ return { trend: 'flat', min: 0, max: 0, current: 0, thresholds: [] };
860
+ }
861
+ let min = values[0];
862
+ let max = values[0];
863
+ for (let i = 1; i < values.length; i++) {
864
+ const v = values[i];
865
+ if (v < min) {
866
+ min = v;
867
+ }
868
+ if (v > max) {
869
+ max = v;
870
+ }
871
+ }
872
+ const first = values[0];
873
+ const current = values[values.length - 1];
874
+ const range = max - min;
875
+ const deadband = range * 0.05;
876
+ const delta = current - first;
877
+ const trend = delta > deadband ? 'up' : delta < -deadband ? 'down' : 'flat';
878
+ const crossed = thresholds.filter((t) => crossesThreshold(values, t));
879
+ return { trend, min, max, current, thresholds: crossed };
880
+ }
881
+ function crossesThreshold(values, threshold) {
882
+ let above = values[0] > threshold;
883
+ for (let i = 1; i < values.length; i++) {
884
+ const nowAbove = values[i] > threshold;
885
+ if (nowAbove !== above) {
886
+ return true;
887
+ }
888
+ above = nowAbove;
889
+ }
890
+ return false;
891
+ }
892
+
893
+ /**
894
+ * Internal `equal` fn helpers shared by the chart graph's bespoke
895
+ * cascade guards. Each helper is two-line trivial; the bespoke fns on
896
+ * heterogeneous shapes (axis tick rendering, layer rect/circle arrays)
897
+ * stay inline at their call sites — this file only carries the
898
+ * recurring shapes (numeric arrays, dimension objects).
899
+ *
900
+ * Not exported from `public-api.ts`. Internal to `@cngx/common/chart`.
901
+ *
902
+ * @internal
903
+ */
904
+ /**
905
+ * Length + `Object.is` per-index equality on a readonly numeric array.
906
+ * Used by `summaryValues` and `summary.thresholds`. Reference-equal
907
+ * arrays short-circuit immediately.
908
+ */
909
+ function sameNumberArr(a, b) {
910
+ if (a === b) {
911
+ return true;
912
+ }
913
+ if (a.length !== b.length) {
914
+ return false;
915
+ }
916
+ for (let i = 0; i < a.length; i++) {
917
+ if (!Object.is(a[i], b[i])) {
918
+ return false;
919
+ }
920
+ }
921
+ return true;
922
+ }
923
+ /**
924
+ * Field-wise equality on the chart's `{ width, height }` dimension
925
+ * shape. Used by the `dimensions` computed; every `ResizeObserver` tick
926
+ * produces a fresh literal even when the numeric pair is unchanged, so
927
+ * an `equal` fn on this signal is the foundation of the chart-graph
928
+ * cascade short-circuit.
929
+ */
930
+ function dimensionsEqual(a, b) {
931
+ return a.width === b.width && a.height === b.height;
932
+ }
933
+
934
+ const NOOP_SCALE = () => 0;
935
+ const NOOP_Y_SCALE = () => 0;
936
+ /**
937
+ * Stable reference for the default `summaryAccessor`. Exposed so the
938
+ * dev-mode warning can detect "consumer omitted [summaryAccessor] on
939
+ * non-numeric data" without false positives when the consumer happens
940
+ * to pass an identical-looking arrow.
941
+ */
942
+ const DEFAULT_SUMMARY_ACCESSOR = (d) => Number(d);
943
+ /**
944
+ * Top-level chart container. Hosts an `<svg>` viewBox, applies
945
+ * {@link CngxResizeObserver} via `hostDirectives` to track its rendered
946
+ * size, and provides {@link CNGX_CHART_CONTEXT} so child atoms
947
+ * (`[cngxAxis]`, layer atoms) read the live scales without injecting
948
+ * the concrete `CngxChart` class.
949
+ *
950
+ * Layer atoms and `[cngxAxis]` are attribute directives: consumers
951
+ * mount them on `<svg:g>` hosts inside the chart so the SVG namespace
952
+ * boundary stays clean. An element selector (`<cngx-axis>` etc.)
953
+ * inside `<svg>` would create an XHTML-namespaced custom element
954
+ * whose SVG-namespaced children would not lay out, leaving the chart
955
+ * blank in real browsers (jsdom is permissive and would mask this).
956
+ *
957
+ * Scales are derived from content-child `[cngxAxis]` directives:
958
+ * the X axis (top/bottom position) drives `xScale`, the Y axis
959
+ * (left/right) drives `yScale`. With no axis present, the
960
+ * corresponding scale falls back to a no-op `() => 0` and content
961
+ * children may render off-canvas — consumers must mount at least
962
+ * one axis per direction they actually use.
963
+ *
964
+ * The `[width]` / `[height]` inputs override the resize observer for
965
+ * fixed-dimension presets (inline sparkline at 80×24, etc.).
966
+ */
967
+ class CngxChart {
968
+ /**
969
+ * Raw data input. Aliased as `data` at the template-binding level so
970
+ * consumer markup stays `<cngx-chart [data]="rows">`. The public,
971
+ * typed read surface is the `data<U>()` method below — layer atoms
972
+ * call `this.ctx.data<T>()` to narrow without per-site casts.
973
+ *
974
+ * @internal — alias for the public `data<U>()` method
975
+ */
976
+ dataInput = input.required({ ...(ngDevMode ? { debugName: "dataInput" } : /* istanbul ignore next */ {}), alias: 'data' });
977
+ width = input(undefined, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
978
+ height = input(undefined, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
979
+ preserveAspectRatio = input('xMidYMid meet', ...(ngDevMode ? [{ debugName: "preserveAspectRatio" }] : /* istanbul ignore next */ []));
980
+ /**
981
+ * Optional explicit `aria-label` override. When set, supersedes the
982
+ * auto-Summary derived from data + threshold layers. Use when the
983
+ * default summary phrasing does not fit the chart's domain.
984
+ */
985
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
986
+ /**
987
+ * Numeric accessor used to project generic data to the values fed
988
+ * into the auto-Summary. Default `Number(d)` works for `readonly
989
+ * number[]` data; structured data must override.
990
+ */
991
+ summaryAccessor = input(DEFAULT_SUMMARY_ACCESSOR, ...(ngDevMode ? [{ debugName: "summaryAccessor" }] : /* istanbul ignore next */ []));
992
+ /**
993
+ * Controls when the SR-only data-table view is exposed to assistive
994
+ * technology. `'auto'` (default) shows the table whenever the data
995
+ * has more than one point — a single value is announced via the
996
+ * `aria-label`, no table needed. `'off'` keeps the table hidden
997
+ * regardless. The table element is always present in the DOM —
998
+ * visibility flips through `aria-hidden`, the linked id on
999
+ * `aria-describedby` never disappears.
1000
+ */
1001
+ accessibleTable = input('auto', ...(ngDevMode ? [{ debugName: "accessibleTable" }] : /* istanbul ignore next */ []));
1002
+ /**
1003
+ * Optional async-state envelope. When bound, the chart routes through
1004
+ * the same skeleton / empty / error / content state machine that the
1005
+ * preset molecules use. Without this input, the chart always renders
1006
+ * its content (Pillar-2 always-in-DOM data-table id stays stable, but
1007
+ * the SR data-table only flips out of `aria-hidden` when the active
1008
+ * view is `'content'`).
1009
+ *
1010
+ * Accepts the standard `CngxAsyncState<T>` shape (any producer:
1011
+ * `createManualState`, `createAsyncState`, `injectAsyncState`,
1012
+ * `fromHttpResource`, `tap*` pipeline output). The chart provides
1013
+ * `CNGX_STATEFUL` for downstream bridge directives — composing
1014
+ * `<cngx-toast-on />` etc. inside the chart works automatically.
1015
+ */
1016
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
1017
+ resize = inject(CngxResizeObserver, { host: true });
1018
+ axes = contentChildren(CngxAxis, { ...(ngDevMode ? { debugName: "axes" } : /* istanbul ignore next */ {}), descendants: true });
1019
+ thresholds = contentChildren(CngxThreshold, { ...(ngDevMode ? { debugName: "thresholds" } : /* istanbul ignore next */ {}), descendants: true });
1020
+ i18n = inject(CNGX_CHART_I18N);
1021
+ dataTableId = nextUid('cngx-chart-data-table');
1022
+ loadingSlot = contentChild(CngxChartLoading, ...(ngDevMode ? [{ debugName: "loadingSlot" }] : /* istanbul ignore next */ []));
1023
+ emptySlot = contentChild(CngxChartEmpty, ...(ngDevMode ? [{ debugName: "emptySlot" }] : /* istanbul ignore next */ []));
1024
+ errorSlot = contentChild(CngxChartError, ...(ngDevMode ? [{ debugName: "errorSlot" }] : /* istanbul ignore next */ []));
1025
+ /** Resolved consumer-projected loading template (null when no slot bound). */
1026
+ loadingTpl = computed(() => this.loadingSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
1027
+ /** Resolved consumer-projected empty template (null when no slot bound). */
1028
+ emptyTpl = computed(() => this.emptySlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
1029
+ /** Resolved consumer-projected error template (null when no slot bound). */
1030
+ errorTpl = computed(() => this.errorSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
1031
+ /**
1032
+ * Common context for every slot template (loading, empty, error).
1033
+ * Carries the chart's current rendered width/height plus a `small`
1034
+ * flag flipped at the {@link CHART_SMALL_BREAKPOINT_PX} threshold,
1035
+ * so consumers can branch on container size:
1036
+ *
1037
+ * ```html
1038
+ * <ng-template cngxChartEmpty let-small="small">
1039
+ * @if (small) { <span>No data</span> }
1040
+ * @else { <cngx-empty-state title="No telemetry yet" /> }
1041
+ * </ng-template>
1042
+ * ```
1043
+ *
1044
+ * Reads directly from the resize observer (host's actual painted
1045
+ * size) — NOT from `dimensions()` which prefers the logical
1046
+ * `[width]`/`[height]` inputs. This matters when an explicit
1047
+ * `[width]="480"` chart squeezes via `max-width: 100%` on a narrow
1048
+ * viewport: the rendered width is what the consumer cares about
1049
+ * for fallback layout, not the logical viewBox dimension.
1050
+ */
1051
+ slotContext = computed(() => {
1052
+ const width = this.resize.width();
1053
+ const height = this.resize.height();
1054
+ return {
1055
+ width,
1056
+ height,
1057
+ small: width > 0 && width < CHART_SMALL_BREAKPOINT_PX,
1058
+ };
1059
+ }, ...(ngDevMode ? [{ debugName: "slotContext" }] : /* istanbul ignore next */ []));
1060
+ /**
1061
+ * Error-slot context — extends {@link slotContext} with the live
1062
+ * error value under `$implicit` and `error` keys, so a consumer can
1063
+ * render a typed message AND branch on chart size in the same
1064
+ * template.
1065
+ */
1066
+ errorContext = computed(() => {
1067
+ const err = this.state()?.error?.() ?? null;
1068
+ return { ...this.slotContext(), $implicit: err, error: err };
1069
+ }, ...(ngDevMode ? [{ debugName: "errorContext" }] : /* istanbul ignore next */ []));
1070
+ constructor() {
1071
+ if (isDevMode()) {
1072
+ afterNextRender(() => {
1073
+ if (this.summaryAccessor() !== DEFAULT_SUMMARY_ACCESSOR) {
1074
+ return;
1075
+ }
1076
+ const data = this.dataInput();
1077
+ if (data.length === 0) {
1078
+ return;
1079
+ }
1080
+ const projected = Number(data[0]);
1081
+ if (Number.isFinite(projected)) {
1082
+ return;
1083
+ }
1084
+ console.warn('CngxChart: data is non-numeric and no [summaryAccessor] is bound. ' +
1085
+ 'Auto-Summary and the SR data-table will silently fall back to NaN. ' +
1086
+ 'Bind [summaryAccessor]="(d) => d.yourField" or pass a numeric data array.');
1087
+ });
1088
+ }
1089
+ }
1090
+ dataLength = computed(() => this.dataInput().length, ...(ngDevMode ? [{ debugName: "dataLength" }] : /* istanbul ignore next */ []));
1091
+ /**
1092
+ * Generic-aware data accessor satisfying {@link CngxChartContext.data}.
1093
+ * The single boundary cast lives here; layer atoms call
1094
+ * `this.ctx.data<T>()` and receive `readonly T[]` directly with no
1095
+ * per-site `as` cast.
1096
+ */
1097
+ data() {
1098
+ return this.dataInput();
1099
+ }
1100
+ dimensions = computed(() => ({
1101
+ width: this.width() ?? this.resize.width(),
1102
+ height: this.height() ?? this.resize.height(),
1103
+ }), { ...(ngDevMode ? { debugName: "dimensions" } : /* istanbul ignore next */ {}), equal: dimensionsEqual });
1104
+ viewBox = computed(() => {
1105
+ const { width, height } = this.dimensions();
1106
+ return `0 0 ${width || 0} ${height || 0}`;
1107
+ }, ...(ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []));
1108
+ xScaleCache = createScaleLru();
1109
+ yScaleCache = createScaleLru();
1110
+ xScale = computed(() => {
1111
+ const axes = this.axes();
1112
+ const { width } = this.dimensions();
1113
+ if (width <= 0) {
1114
+ return NOOP_SCALE;
1115
+ }
1116
+ const xAxis = axes.find((a) => isHorizontalPosition(a.position()));
1117
+ if (!xAxis) {
1118
+ return NOOP_SCALE;
1119
+ }
1120
+ return this.xScaleCache.get(xAxis.type(), xAxis.domain() ?? [], [0, width]);
1121
+ }, { ...(ngDevMode ? { debugName: "xScale" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b });
1122
+ yScale = computed(() => {
1123
+ const axes = this.axes();
1124
+ const { height } = this.dimensions();
1125
+ if (height <= 0) {
1126
+ return NOOP_Y_SCALE;
1127
+ }
1128
+ const yAxis = axes.find((a) => isVerticalPosition(a.position()));
1129
+ if (!yAxis) {
1130
+ return NOOP_Y_SCALE;
1131
+ }
1132
+ // SVG Y-axis is flipped — domain[max] maps to range[0] (top), domain[min] to range[height] (bottom).
1133
+ return this.yScaleCache.get(yAxis.type(), yAxis.domain() ?? [], [height, 0]);
1134
+ }, { ...(ngDevMode ? { debugName: "yScale" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b });
1135
+ /**
1136
+ * Auto-Summary derived from `data` and `<cngx-threshold>` content
1137
+ * children. Drives the host's reactive `aria-label`. Layer atoms do
1138
+ * not contribute to the summary on Phase 3 — Phase 5/6 may extend
1139
+ * with per-layer hints.
1140
+ */
1141
+ summary = computed(() => {
1142
+ const acc = this.summaryAccessor();
1143
+ const data = this.dataInput();
1144
+ const values = new Array(data.length);
1145
+ for (let i = 0; i < data.length; i++) {
1146
+ values[i] = acc(data[i], i);
1147
+ }
1148
+ const thresholds = this.thresholds().map((t) => t.value());
1149
+ return computeChartSummary(values, thresholds);
1150
+ }, { ...(ngDevMode ? { debugName: "summary" } : /* istanbul ignore next */ {}), equal: (a, b) => a.trend === b.trend &&
1151
+ a.min === b.min &&
1152
+ a.max === b.max &&
1153
+ a.current === b.current &&
1154
+ sameNumberArr(a.thresholds, b.thresholds) });
1155
+ /**
1156
+ * Active view for the optional state-machine envelope. Returns
1157
+ * `'content'` when no `[state]` is bound, falling through to the
1158
+ * default branch that renders the SVG content. Otherwise routes
1159
+ * through {@link resolveAsyncView} using the same status / firstLoad
1160
+ * / empty triple every preset and async-aware atom in the library
1161
+ * uses.
1162
+ */
1163
+ activeView = computed(() => {
1164
+ const s = this.state();
1165
+ if (!s) {
1166
+ return 'content';
1167
+ }
1168
+ return resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
1169
+ }, ...(ngDevMode ? [{ debugName: "activeView" }] : /* istanbul ignore next */ []));
1170
+ /** True when the chart is currently rendering its skeleton view. */
1171
+ busy = computed(() => this.activeView() === 'skeleton', ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
1172
+ /**
1173
+ * Responsive mode is active when neither `[width]` nor `[height]` is
1174
+ * bound. The host then fills its parent's width and derives height
1175
+ * from the `--cngx-chart-aspect-ratio` CSS custom property (default
1176
+ * `16 / 9`). The resize observer feeds `dimensions()` which drives
1177
+ * the SVG sizing + scale math, so axes and layer atoms re-flow
1178
+ * reactively as the parent resizes.
1179
+ */
1180
+ isResponsive = computed(() => this.width() === undefined && this.height() === undefined, ...(ngDevMode ? [{ debugName: "isResponsive" }] : /* istanbul ignore next */ []));
1181
+ /**
1182
+ * Aspect-ratio host style for the explicit-dimension case. Computed
1183
+ * from `[width] / [height]` so the chart stays proportional when
1184
+ * `max-width: 100%` shrinks the host below the explicit width on a
1185
+ * narrow viewport (mobile portrait, constrained dashboard cell).
1186
+ * Returns `null` in responsive mode so the
1187
+ * `--cngx-chart-aspect-ratio` CSS variable on `.cngx-chart--responsive`
1188
+ * wins, and `null` when only one of width/height is bound (caller
1189
+ * intentionally drove just one dimension; we do not invent a ratio).
1190
+ */
1191
+ explicitAspectRatio = computed(() => {
1192
+ const w = this.width();
1193
+ const h = this.height();
1194
+ if (w === undefined || h === undefined || w <= 0 || h <= 0) {
1195
+ return null;
1196
+ }
1197
+ return `${w} / ${h}`;
1198
+ }, ...(ngDevMode ? [{ debugName: "explicitAspectRatio" }] : /* istanbul ignore next */ []));
1199
+ /**
1200
+ * Reactive `aria-label` text the host announces. Skeleton / empty /
1201
+ * error states announce localised i18n strings; the auto-Summary
1202
+ * runs only in the content branch so AT does not read stale data
1203
+ * during a refetch.
1204
+ */
1205
+ ariaLabelText = computed(() => {
1206
+ const view = this.activeView();
1207
+ if (view === 'skeleton') {
1208
+ return this.i18n.loading();
1209
+ }
1210
+ if (view === 'empty') {
1211
+ return this.i18n.empty();
1212
+ }
1213
+ if (view === 'error') {
1214
+ return this.i18n.error();
1215
+ }
1216
+ const explicit = this.ariaLabel();
1217
+ if (explicit !== null && explicit !== undefined && explicit !== '') {
1218
+ return explicit;
1219
+ }
1220
+ return this.i18n.summary(this.summary());
1221
+ }, ...(ngDevMode ? [{ debugName: "ariaLabelText" }] : /* istanbul ignore next */ []));
1222
+ /** Numeric projection of `data` reused by the data-table view. */
1223
+ summaryValues = computed(() => {
1224
+ const acc = this.summaryAccessor();
1225
+ const data = this.dataInput();
1226
+ const out = new Array(data.length);
1227
+ for (let i = 0; i < data.length; i++) {
1228
+ out[i] = acc(data[i], i);
1229
+ }
1230
+ return out;
1231
+ }, { ...(ngDevMode ? { debugName: "summaryValues" } : /* istanbul ignore next */ {}), equal: sameNumberArr });
1232
+ /**
1233
+ * Auto-mode predicate. Drives the data-table's `aria-hidden`
1234
+ * binding. The id on `aria-describedby` is invariant — it stays on
1235
+ * the host whether the table is active or not. Single-value charts
1236
+ * speak via the `aria-label` summary; multi-value charts add the
1237
+ * table for row-by-row exploration.
1238
+ */
1239
+ tableActive = computed(() => {
1240
+ const mode = this.accessibleTable();
1241
+ if (mode === 'off') {
1242
+ return false;
1243
+ }
1244
+ return this.dataInput().length > 1;
1245
+ }, ...(ngDevMode ? [{ debugName: "tableActive" }] : /* istanbul ignore next */ []));
1246
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
1247
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChart, isStandalone: true, selector: "cngx-chart", inputs: { dataInput: { classPropertyName: "dataInput", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, preserveAspectRatio: { classPropertyName: "preserveAspectRatio", publicName: "preserveAspectRatio", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, summaryAccessor: { classPropertyName: "summaryAccessor", publicName: "summaryAccessor", isSignal: true, isRequired: false, transformFunction: null }, accessibleTable: { classPropertyName: "accessibleTable", publicName: "accessibleTable", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.aria-label": "ariaLabelText()", "attr.aria-describedby": "dataTableId", "attr.aria-busy": "busy() ? \"true\" : null", "class.cngx-chart--responsive": "isResponsive()", "style.width.px": "width() ?? null", "style.aspect-ratio": "explicitAspectRatio()" } }, providers: [{ provide: CNGX_CHART_CONTEXT, useExisting: CngxChart }], queries: [{ propertyName: "axes", predicate: CngxAxis, descendants: true, isSignal: true }, { propertyName: "thresholds", predicate: CngxThreshold, descendants: true, isSignal: true }, { propertyName: "loadingSlot", first: true, predicate: CngxChartLoading, descendants: true, isSignal: true }, { propertyName: "emptySlot", first: true, predicate: CngxChartEmpty, descendants: true, isSignal: true }, { propertyName: "errorSlot", first: true, predicate: CngxChartError, descendants: true, isSignal: true }], exportAs: ["cngxChart"], hostDirectives: [{ directive: i1.CngxResizeObserver }], ngImport: i0, template: `
1248
+ @switch (activeView()) {
1249
+ @case ('skeleton') {
1250
+ @if (loadingTpl(); as tpl) {
1251
+ <div class="cngx-chart__fallback-frame">
1252
+ <ng-container *ngTemplateOutlet="tpl; context: slotContext()" />
1253
+ </div>
1254
+ } @else {
1255
+ <div class="cngx-chart__loading" [attr.aria-hidden]="true">
1256
+ <div class="cngx-chart__spinner"></div>
1257
+ </div>
1258
+ }
1259
+ }
1260
+ @case ('empty') {
1261
+ @if (emptyTpl(); as tpl) {
1262
+ <div class="cngx-chart__fallback-frame">
1263
+ <ng-container *ngTemplateOutlet="tpl; context: slotContext()" />
1264
+ </div>
1265
+ } @else {
1266
+ <div class="cngx-chart__fallback" [attr.aria-hidden]="true">{{ i18n.empty() }}</div>
1267
+ }
1268
+ }
1269
+ @case ('error') {
1270
+ @if (errorTpl(); as tpl) {
1271
+ <div class="cngx-chart__fallback-frame">
1272
+ <ng-container *ngTemplateOutlet="tpl; context: errorContext()" />
1273
+ </div>
1274
+ } @else {
1275
+ <div
1276
+ class="cngx-chart__fallback cngx-chart__fallback--error"
1277
+ [attr.aria-hidden]="true"
1278
+ >{{ i18n.error() }}</div>
1279
+ }
1280
+ }
1281
+ @case ('none') {}
1282
+ @default {
1283
+ <svg
1284
+ [attr.viewBox]="viewBox()"
1285
+ [attr.preserveAspectRatio]="preserveAspectRatio()"
1286
+ >
1287
+ <svg:title>{{ ariaLabelText() }}</svg:title>
1288
+ <ng-content />
1289
+ </svg>
1290
+ }
1291
+ }
1292
+ <cngx-chart-data-table
1293
+ [id]="dataTableId"
1294
+ [values]="summaryValues()"
1295
+ [hidden]="!tableActive() || activeView() !== 'content'"
1296
+ />
1297
+ `, isInline: true, styles: [":root{--cngx-chart-primary: var(--accent, #4c8bf5);--cngx-chart-secondary: var(--accent-secondary, #7d8997);--cngx-chart-danger: var(--danger, #d2452f);--cngx-chart-success: var(--success, #1f9d55);--cngx-chart-grid-color: var(--border, #e5e7eb);--cngx-chart-axis-color: var(--text-secondary, #6b7280);--cngx-chart-text-color: var(--text-primary, #1f2937);--cngx-chart-aspect-ratio: 5 / 2}\n", "cngx-chart{display:inline-block;max-width:100%}cngx-chart.cngx-chart--responsive{display:block;width:100%;aspect-ratio:var(--cngx-chart-aspect-ratio, 5 / 2)}cngx-chart>svg{display:block;width:100%;height:100%;overflow:visible}cngx-chart>.cngx-chart__fallback-frame{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart>.cngx-chart__loading{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart .cngx-chart__spinner{width:var(--cngx-chart-spinner-size, 32px);height:var(--cngx-chart-spinner-size, 32px);border:var(--cngx-chart-spinner-thickness, 3px) solid var(--cngx-chart-spinner-track, rgb(0 0 0 / .08));border-top-color:var(--cngx-chart-spinner-color, var(--cngx-chart-primary, currentColor));border-radius:50%;animation:cngx-chart-spin .8s linear infinite}cngx-chart>.cngx-chart__fallback{display:flex;align-items:center;justify-content:center;width:100%;height:100%;min-height:var(--cngx-chart-fallback-min-height, 48px);font-size:var(--cngx-chart-fallback-font-size, .875rem);color:var(--cngx-chart-text-color, currentColor);opacity:var(--cngx-chart-fallback-opacity, .7);padding:var(--cngx-chart-fallback-padding, 1rem);text-align:center;box-sizing:border-box}cngx-chart>.cngx-chart__fallback--error{color:var(--cngx-chart-danger, currentColor);opacity:1}@keyframes cngx-chart-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){cngx-chart .cngx-chart__spinner{animation:none}}\n"], dependencies: [{ kind: "component", type: CngxChartDataTable, selector: "cngx-chart-data-table", inputs: ["values", "hidden", "id"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1298
+ }
1299
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChart, decorators: [{
1300
+ type: Component,
1301
+ args: [{ selector: 'cngx-chart', exportAs: 'cngxChart', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1302
+ role: 'img',
1303
+ '[attr.aria-label]': 'ariaLabelText()',
1304
+ '[attr.aria-describedby]': 'dataTableId',
1305
+ '[attr.aria-busy]': 'busy() ? "true" : null',
1306
+ '[class.cngx-chart--responsive]': 'isResponsive()',
1307
+ '[style.width.px]': 'width() ?? null',
1308
+ '[style.aspect-ratio]': 'explicitAspectRatio()',
1309
+ }, hostDirectives: [CngxResizeObserver], providers: [{ provide: CNGX_CHART_CONTEXT, useExisting: CngxChart }], imports: [CngxChartDataTable, NgTemplateOutlet], template: `
1310
+ @switch (activeView()) {
1311
+ @case ('skeleton') {
1312
+ @if (loadingTpl(); as tpl) {
1313
+ <div class="cngx-chart__fallback-frame">
1314
+ <ng-container *ngTemplateOutlet="tpl; context: slotContext()" />
1315
+ </div>
1316
+ } @else {
1317
+ <div class="cngx-chart__loading" [attr.aria-hidden]="true">
1318
+ <div class="cngx-chart__spinner"></div>
1319
+ </div>
1320
+ }
1321
+ }
1322
+ @case ('empty') {
1323
+ @if (emptyTpl(); as tpl) {
1324
+ <div class="cngx-chart__fallback-frame">
1325
+ <ng-container *ngTemplateOutlet="tpl; context: slotContext()" />
1326
+ </div>
1327
+ } @else {
1328
+ <div class="cngx-chart__fallback" [attr.aria-hidden]="true">{{ i18n.empty() }}</div>
1329
+ }
1330
+ }
1331
+ @case ('error') {
1332
+ @if (errorTpl(); as tpl) {
1333
+ <div class="cngx-chart__fallback-frame">
1334
+ <ng-container *ngTemplateOutlet="tpl; context: errorContext()" />
1335
+ </div>
1336
+ } @else {
1337
+ <div
1338
+ class="cngx-chart__fallback cngx-chart__fallback--error"
1339
+ [attr.aria-hidden]="true"
1340
+ >{{ i18n.error() }}</div>
1341
+ }
1342
+ }
1343
+ @case ('none') {}
1344
+ @default {
1345
+ <svg
1346
+ [attr.viewBox]="viewBox()"
1347
+ [attr.preserveAspectRatio]="preserveAspectRatio()"
1348
+ >
1349
+ <svg:title>{{ ariaLabelText() }}</svg:title>
1350
+ <ng-content />
1351
+ </svg>
1352
+ }
1353
+ }
1354
+ <cngx-chart-data-table
1355
+ [id]="dataTableId"
1356
+ [values]="summaryValues()"
1357
+ [hidden]="!tableActive() || activeView() !== 'content'"
1358
+ />
1359
+ `, styles: [":root{--cngx-chart-primary: var(--accent, #4c8bf5);--cngx-chart-secondary: var(--accent-secondary, #7d8997);--cngx-chart-danger: var(--danger, #d2452f);--cngx-chart-success: var(--success, #1f9d55);--cngx-chart-grid-color: var(--border, #e5e7eb);--cngx-chart-axis-color: var(--text-secondary, #6b7280);--cngx-chart-text-color: var(--text-primary, #1f2937);--cngx-chart-aspect-ratio: 5 / 2}\n", "cngx-chart{display:inline-block;max-width:100%}cngx-chart.cngx-chart--responsive{display:block;width:100%;aspect-ratio:var(--cngx-chart-aspect-ratio, 5 / 2)}cngx-chart>svg{display:block;width:100%;height:100%;overflow:visible}cngx-chart>.cngx-chart__fallback-frame{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart>.cngx-chart__loading{display:flex;align-items:center;justify-content:center;width:100%;height:100%}cngx-chart .cngx-chart__spinner{width:var(--cngx-chart-spinner-size, 32px);height:var(--cngx-chart-spinner-size, 32px);border:var(--cngx-chart-spinner-thickness, 3px) solid var(--cngx-chart-spinner-track, rgb(0 0 0 / .08));border-top-color:var(--cngx-chart-spinner-color, var(--cngx-chart-primary, currentColor));border-radius:50%;animation:cngx-chart-spin .8s linear infinite}cngx-chart>.cngx-chart__fallback{display:flex;align-items:center;justify-content:center;width:100%;height:100%;min-height:var(--cngx-chart-fallback-min-height, 48px);font-size:var(--cngx-chart-fallback-font-size, .875rem);color:var(--cngx-chart-text-color, currentColor);opacity:var(--cngx-chart-fallback-opacity, .7);padding:var(--cngx-chart-fallback-padding, 1rem);text-align:center;box-sizing:border-box}cngx-chart>.cngx-chart__fallback--error{color:var(--cngx-chart-danger, currentColor);opacity:1}@keyframes cngx-chart-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){cngx-chart .cngx-chart__spinner{animation:none}}\n"] }]
1360
+ }], ctorParameters: () => [], propDecorators: { dataInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], preserveAspectRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveAspectRatio", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], summaryAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "summaryAccessor", required: false }] }], accessibleTable: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessibleTable", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], axes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxAxis), { ...{ descendants: true }, isSignal: true }] }], thresholds: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxThreshold), { ...{ descendants: true }, isSignal: true }] }], loadingSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartLoading), { isSignal: true }] }], emptySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartEmpty), { isSignal: true }] }], errorSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxChartError), { isSignal: true }] }] } });
1361
+ function isHorizontalPosition(p) {
1362
+ return p === 'top' || p === 'bottom';
1363
+ }
1364
+ function isVerticalPosition(p) {
1365
+ return p === 'left' || p === 'right';
1366
+ }
1367
+ function buildScale(type, domain, range) {
1368
+ if (domain.length < 2) {
1369
+ return NOOP_SCALE;
1370
+ }
1371
+ switch (type) {
1372
+ case 'linear': {
1373
+ const linear = createLinearScale([Number(domain[0]), Number(domain[domain.length - 1])], range);
1374
+ return (v) => linear(typeof v === 'number' ? v : Number(v));
1375
+ }
1376
+ case 'time': {
1377
+ const time = createTimeScale([toMs(domain[0]), toMs(domain[domain.length - 1])], range);
1378
+ return (v) => time(v instanceof Date ? v : Number(v));
1379
+ }
1380
+ case 'band': {
1381
+ const band = createBandScale(domain, range);
1382
+ // createBandScale returns the leading edge; chart consumers
1383
+ // (ticks, line/area/scatter, threshold/band yScale) want the
1384
+ // centre so ticks align with their slot and lines trace through
1385
+ // bar centres. Bar atom uses its own slot logic — unaffected.
1386
+ const half = band.bandwidth() / 2;
1387
+ return (v) => band(v) + half;
1388
+ }
1389
+ }
1390
+ }
1391
+ function createScaleLru() {
1392
+ let lastType = null;
1393
+ let lastDomainLen = -1;
1394
+ let lastDomainStart = null;
1395
+ let lastDomainEnd = null;
1396
+ let lastDomainAllKeys = null;
1397
+ let lastRange0 = NaN;
1398
+ let lastRange1 = NaN;
1399
+ let lastFn = NOOP_SCALE;
1400
+ return {
1401
+ get(type, domain, range) {
1402
+ const keyStart = endpointKey(domain[0]);
1403
+ const keyEnd = endpointKey(domain[domain.length - 1]);
1404
+ // For band scales, the cache must invalidate on any reorder/swap of
1405
+ // values; cheap stringification of all keys is sufficient because
1406
+ // band domains are typically short.
1407
+ const allKeys = type === 'band' ? domain.map(endpointKey).join('|') : null;
1408
+ if (type === lastType &&
1409
+ domain.length === lastDomainLen &&
1410
+ keyStart === lastDomainStart &&
1411
+ keyEnd === lastDomainEnd &&
1412
+ allKeys === lastDomainAllKeys &&
1413
+ range[0] === lastRange0 &&
1414
+ range[1] === lastRange1) {
1415
+ return lastFn;
1416
+ }
1417
+ lastType = type;
1418
+ lastDomainLen = domain.length;
1419
+ lastDomainStart = keyStart;
1420
+ lastDomainEnd = keyEnd;
1421
+ lastDomainAllKeys = allKeys;
1422
+ lastRange0 = range[0];
1423
+ lastRange1 = range[1];
1424
+ lastFn = buildScale(type, domain, range);
1425
+ return lastFn;
1426
+ },
1427
+ };
1428
+ }
1429
+ function endpointKey(v) {
1430
+ if (v instanceof Date) {
1431
+ return v.getTime();
1432
+ }
1433
+ if (typeof v === 'number' || typeof v === 'string') {
1434
+ return v;
1435
+ }
1436
+ return String(v);
1437
+ }
1438
+ function toMs(v) {
1439
+ if (typeof v === 'number') {
1440
+ return v;
1441
+ }
1442
+ if (v instanceof Date) {
1443
+ return v.getTime();
1444
+ }
1445
+ return Number(v);
1446
+ }
1447
+
1448
+ /**
1449
+ * Presentational legend atom — a row (or column) of coloured swatches
1450
+ * paired with labels. Decoupled from `<cngx-chart>` and the layer
1451
+ * atoms by design: the consumer drives the items array, so the
1452
+ * legend stays a pure rendering surface with zero opinions about
1453
+ * series-discovery, visibility-toggling, or interaction.
1454
+ *
1455
+ * Compose alongside a chart wherever a multi-layer composition needs
1456
+ * a label key:
1457
+ *
1458
+ * ```html
1459
+ * <cngx-chart [data]="series">
1460
+ * <svg:g cngxLine [data]="traffic" style="--cngx-line-color: #3b82f6"></svg:g>
1461
+ * <svg:g cngxLine [data]="errors" style="--cngx-line-color: #d2452f"></svg:g>
1462
+ * </cngx-chart>
1463
+ * <cngx-chart-legend
1464
+ * [items]="[
1465
+ * { label: 'Traffic', color: '#3b82f6' },
1466
+ * { label: 'Errors', color: '#d2452f' }
1467
+ * ]"
1468
+ * />
1469
+ * ```
1470
+ *
1471
+ * Theming via `--cngx-chart-legend-gap`,
1472
+ * `--cngx-chart-legend-swatch-size`, `--cngx-chart-legend-swatch-radius`,
1473
+ * `--cngx-chart-legend-font-size`. `[orientation]` flips between row
1474
+ * and column; `[align]` aligns along the main axis (`start`, `center`,
1475
+ * `end`).
1476
+ */
1477
+ class CngxChartLegend {
1478
+ items = input.required(...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
1479
+ orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
1480
+ align = input('start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
1481
+ flexAlign = computed(() => {
1482
+ switch (this.align()) {
1483
+ case 'center':
1484
+ return 'center';
1485
+ case 'end':
1486
+ return 'flex-end';
1487
+ default:
1488
+ return 'flex-start';
1489
+ }
1490
+ }, ...(ngDevMode ? [{ debugName: "flexAlign" }] : /* istanbul ignore next */ []));
1491
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartLegend, deps: [], target: i0.ɵɵFactoryTarget.Component });
1492
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChartLegend, isStandalone: true, selector: "cngx-chart-legend", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "list" }, properties: { "class.cngx-chart-legend--vertical": "orientation() === \"vertical\"", "style.justify-content": "flexAlign()" }, classAttribute: "cngx-chart-legend" }, exportAs: ["cngxChartLegend"], ngImport: i0, template: `
1493
+ @for (item of items(); track $index) {
1494
+ <span class="cngx-chart-legend__item" role="listitem">
1495
+ <span
1496
+ class="cngx-chart-legend__swatch"
1497
+ [style.background]="item.color ?? null"
1498
+ aria-hidden="true"
1499
+ ></span>
1500
+ <span class="cngx-chart-legend__label">{{ item.label }}</span>
1501
+ </span>
1502
+ }
1503
+ `, isInline: true, styles: ["cngx-chart-legend{display:flex;flex-wrap:wrap;gap:var(--cngx-chart-legend-gap, 12px);font-size:var(--cngx-chart-legend-font-size, .8125rem);color:var(--cngx-chart-legend-color, var(--cngx-chart-text-color, currentColor));align-items:center}cngx-chart-legend.cngx-chart-legend--vertical{flex-direction:column;align-items:flex-start}cngx-chart-legend .cngx-chart-legend__item{display:inline-flex;align-items:center;gap:var(--cngx-chart-legend-item-gap, 6px)}cngx-chart-legend .cngx-chart-legend__swatch{display:inline-block;width:var(--cngx-chart-legend-swatch-size, 12px);height:var(--cngx-chart-legend-swatch-size, 12px);background:var(--cngx-chart-primary, currentColor);border-radius:var(--cngx-chart-legend-swatch-radius, 2px)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1504
+ }
1505
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChartLegend, decorators: [{
1506
+ type: Component,
1507
+ args: [{ selector: 'cngx-chart-legend', exportAs: 'cngxChartLegend', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1508
+ role: 'list',
1509
+ class: 'cngx-chart-legend',
1510
+ '[class.cngx-chart-legend--vertical]': 'orientation() === "vertical"',
1511
+ '[style.justify-content]': 'flexAlign()',
1512
+ }, template: `
1513
+ @for (item of items(); track $index) {
1514
+ <span class="cngx-chart-legend__item" role="listitem">
1515
+ <span
1516
+ class="cngx-chart-legend__swatch"
1517
+ [style.background]="item.color ?? null"
1518
+ aria-hidden="true"
1519
+ ></span>
1520
+ <span class="cngx-chart-legend__label">{{ item.label }}</span>
1521
+ </span>
1522
+ }
1523
+ `, styles: ["cngx-chart-legend{display:flex;flex-wrap:wrap;gap:var(--cngx-chart-legend-gap, 12px);font-size:var(--cngx-chart-legend-font-size, .8125rem);color:var(--cngx-chart-legend-color, var(--cngx-chart-text-color, currentColor));align-items:center}cngx-chart-legend.cngx-chart-legend--vertical{flex-direction:column;align-items:flex-start}cngx-chart-legend .cngx-chart-legend__item{display:inline-flex;align-items:center;gap:var(--cngx-chart-legend-item-gap, 6px)}cngx-chart-legend .cngx-chart-legend__swatch{display:inline-block;width:var(--cngx-chart-legend-swatch-size, 12px);height:var(--cngx-chart-legend-swatch-size, 12px);background:var(--cngx-chart-primary, currentColor);border-radius:var(--cngx-chart-legend-swatch-radius, 2px)}\n"] }]
1524
+ }], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }] } });
1525
+
1526
+ /**
1527
+ * Build the SVG `d` attribute for a sequence of points.
1528
+ *
1529
+ * @param points Pixel-coordinate points to connect.
1530
+ * @param curve Interpolation strategy. `'linear'` joins points with
1531
+ * straight `L` commands; `'monotone'` uses cubic Béziers with the
1532
+ * monotone-X tangent rule (Fritsch-Carlson) so the curve never
1533
+ * overshoots between data points.
1534
+ * @returns The full path data starting with `M`. Returns `''` when
1535
+ * the input is empty; `M x y` when the input has one point.
1536
+ */
1537
+ function buildCurvePath(points, curve) {
1538
+ if (points.length === 0) {
1539
+ return '';
1540
+ }
1541
+ if (points.length === 1) {
1542
+ const p = points[0];
1543
+ return `M ${p.x} ${p.y}`;
1544
+ }
1545
+ if (curve === 'linear') {
1546
+ return buildLinearPath(points);
1547
+ }
1548
+ return buildMonotonePath(points);
1549
+ }
1550
+ function buildLinearPath(points) {
1551
+ const start = points[0];
1552
+ let out = `M ${start.x} ${start.y}`;
1553
+ for (let i = 1; i < points.length; i++) {
1554
+ out += ` L ${points[i].x} ${points[i].y}`;
1555
+ }
1556
+ return out;
1557
+ }
1558
+ /**
1559
+ * Monotone cubic Bézier interpolation (Fritsch-Carlson tangents on the
1560
+ * X dimension). Input points must have strictly increasing `x`
1561
+ * coordinates.
1562
+ */
1563
+ function buildMonotonePath(points) {
1564
+ const n = points.length;
1565
+ const slopes = new Array(n - 1);
1566
+ for (let i = 0; i < n - 1; i++) {
1567
+ const dx = points[i + 1].x - points[i].x;
1568
+ slopes[i] = dx === 0 ? 0 : (points[i + 1].y - points[i].y) / dx;
1569
+ }
1570
+ const tangents = new Array(n);
1571
+ tangents[0] = slopes[0];
1572
+ tangents[n - 1] = slopes[n - 2];
1573
+ for (let i = 1; i < n - 1; i++) {
1574
+ const m1 = slopes[i - 1];
1575
+ const m2 = slopes[i];
1576
+ if (m1 * m2 <= 0) {
1577
+ tangents[i] = 0;
1578
+ }
1579
+ else {
1580
+ tangents[i] = (2 * m1 * m2) / (m1 + m2);
1581
+ }
1582
+ }
1583
+ let out = `M ${points[0].x} ${points[0].y}`;
1584
+ for (let i = 0; i < n - 1; i++) {
1585
+ const p0 = points[i];
1586
+ const p1 = points[i + 1];
1587
+ const dx = p1.x - p0.x;
1588
+ const c1x = p0.x + dx / 3;
1589
+ const c1y = p0.y + (tangents[i] * dx) / 3;
1590
+ const c2x = p1.x - dx / 3;
1591
+ const c2y = p1.y - (tangents[i + 1] * dx) / 3;
1592
+ out += ` C ${c1x} ${c1y}, ${c2x} ${c2y}, ${p1.x} ${p1.y}`;
1593
+ }
1594
+ return out;
1595
+ }
1596
+
1597
+ /**
1598
+ * Pure-TS path builder with single-slot LRU memo on
1599
+ * `(data, xScale, yScale)` reference identity. Pure TS, no Angular
1600
+ * dep. Compute guard only — does not know about signals or `equal`
1601
+ * functions; the `d` computed in `<cngx-line>` carries the cascade
1602
+ * guard separately.
1603
+ *
1604
+ * The cache returns the previous result when all three inputs are
1605
+ * reference-equal to the previous call. Any reference mismatch
1606
+ * triggers a rebuild and updates the slot.
1607
+ *
1608
+ * Each call to `createPathBuilder` returns a fresh builder with its
1609
+ * own `lastData / lastX / lastY` slots — there is no cross-call /
1610
+ * cross-consumer state. The cascade guard for layer atoms is the
1611
+ * `equal: (a, b) => a === b` on the `builder` `computed`; combined
1612
+ * with Angular signals' default behaviour of skipping re-emissions
1613
+ * when the inputs to the `computed` are unchanged, two consecutive
1614
+ * cascade ticks with the same `(y, x, curve)` produce the same
1615
+ * builder instance.
1616
+ */
1617
+ function createPathBuilder(opts) {
1618
+ const yAcc = opts.y;
1619
+ const xAcc = opts.x ?? ((_, i) => i);
1620
+ const curve = opts.curve;
1621
+ let lastData = null;
1622
+ let lastX = null;
1623
+ let lastY = null;
1624
+ let lastResult = '';
1625
+ let rebuilds = 0;
1626
+ return {
1627
+ build(data, xScale, yScale) {
1628
+ if (data === lastData && xScale === lastX && yScale === lastY) {
1629
+ return lastResult;
1630
+ }
1631
+ const points = projectPoints(data, xAcc, yAcc, xScale, yScale);
1632
+ const d = buildCurvePath(points, curve);
1633
+ lastData = data;
1634
+ lastX = xScale;
1635
+ lastY = yScale;
1636
+ lastResult = d;
1637
+ rebuilds++;
1638
+ return d;
1639
+ },
1640
+ rebuildCount() {
1641
+ return rebuilds;
1642
+ },
1643
+ };
1644
+ }
1645
+ function projectPoints(data, xAcc, yAcc, xScale, yScale) {
1646
+ const out = new Array(data.length);
1647
+ for (let i = 0; i < data.length; i++) {
1648
+ out[i] = { x: xScale(xAcc(data[i], i)), y: yScale(yAcc(data[i], i)) };
1649
+ }
1650
+ return out;
1651
+ }
1652
+
1653
+ /**
1654
+ * Line layer atom. Renders a single SVG `<path>` connecting the data
1655
+ * points projected through the parent chart's scales. Reads scales
1656
+ * from {@link CNGX_CHART_CONTEXT}, NOT from a parent class.
1657
+ *
1658
+ * Attribute-selector on `<svg:g>` — the host element IS the SVG group.
1659
+ * Element selectors create XHTML-namespaced custom elements inside
1660
+ * SVG, which break layout for the namespaced children. Apply this
1661
+ * directive on an `<svg:g>` host instead.
1662
+ *
1663
+ * The `d` string is cascade-guarded with string equality on its
1664
+ * `computed` so downstream effects only re-run when the path
1665
+ * geometry actually changes. The `createPathBuilder` cache provides
1666
+ * the **compute guard** — same `(data, xScale, yScale)` triple by
1667
+ * reference skips the per-datapoint projection work.
1668
+ */
1669
+ class CngxLine {
1670
+ accessor = input((d) => Number(d), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
1671
+ xAccessor = input(undefined, ...(ngDevMode ? [{ debugName: "xAccessor" }] : /* istanbul ignore next */ []));
1672
+ color = input(null, ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
1673
+ strokeWidth = input(null, ...(ngDevMode ? [{ debugName: "strokeWidth" }] : /* istanbul ignore next */ []));
1674
+ curve = input('linear', ...(ngDevMode ? [{ debugName: "curve" }] : /* istanbul ignore next */ []));
1675
+ data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1676
+ ctx = injectChartContext('CngxLine');
1677
+ builder = computed(() => createPathBuilder({
1678
+ y: this.accessor(),
1679
+ x: this.xAccessor(),
1680
+ curve: this.curve(),
1681
+ }), ...(ngDevMode ? [{ debugName: "builder" }] : /* istanbul ignore next */ []));
1682
+ resolvedData = computed(() => {
1683
+ const local = this.data();
1684
+ if (local !== undefined) {
1685
+ return local;
1686
+ }
1687
+ return this.ctx.data();
1688
+ }, ...(ngDevMode ? [{ debugName: "resolvedData" }] : /* istanbul ignore next */ []));
1689
+ d = computed(() => this.builder().build(this.resolvedData(), this.ctx.xScale(), this.ctx.yScale()), { ...(ngDevMode ? { debugName: "d" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b });
1690
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, deps: [], target: i0.ɵɵFactoryTarget.Component });
1691
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxLine, isStandalone: true, selector: "[cngxLine]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, xAccessor: { classPropertyName: "xAccessor", publicName: "xAccessor", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, curve: { classPropertyName: "curve", publicName: "curve", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxLine"], ngImport: i0, template: `
1692
+ <svg:path
1693
+ class="cngx-line"
1694
+ [attr.d]="d()"
1695
+ [attr.fill]="'none'"
1696
+ [attr.stroke]="color()"
1697
+ [attr.stroke-width]="strokeWidth()"
1698
+ [attr.stroke-linejoin]="'round'"
1699
+ [attr.stroke-linecap]="'round'"
1700
+ />
1701
+ `, isInline: true, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-line{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1702
+ }
1703
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLine, decorators: [{
1704
+ type: Component,
1705
+ args: [{ selector: '[cngxLine]', exportAs: 'cngxLine', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
1706
+ <svg:path
1707
+ class="cngx-line"
1708
+ [attr.d]="d()"
1709
+ [attr.fill]="'none'"
1710
+ [attr.stroke]="color()"
1711
+ [attr.stroke-width]="strokeWidth()"
1712
+ [attr.stroke-linejoin]="'round'"
1713
+ [attr.stroke-linecap]="'round'"
1714
+ />
1715
+ `, styles: [".cngx-line{stroke:var(--cngx-line-color, var(--cngx-chart-primary, currentColor));stroke-width:var(--cngx-line-stroke-width, 1.5px);animation:cngx-line-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-line-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-line{animation:none}}\n"] }]
1716
+ }], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], xAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAccessor", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], strokeWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "strokeWidth", required: false }] }], curve: [{ type: i0.Input, args: [{ isSignal: true, alias: "curve", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
1717
+
1718
+ /**
1719
+ * Area layer atom. Reuses {@link createPathBuilder} for the upper edge
1720
+ * (same compute guard as `[cngxLine]`) and closes the polygon to a
1721
+ * `[baseline]` (default `0`) so SVG can fill it.
1722
+ *
1723
+ * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1724
+ *
1725
+ * The `d` string is cascade-guarded with string equality on its
1726
+ * `computed` so a no-op data refresh does not force a fill repaint.
1727
+ */
1728
+ class CngxArea {
1729
+ accessor = input((d) => Number(d), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
1730
+ xAccessor = input(undefined, ...(ngDevMode ? [{ debugName: "xAccessor" }] : /* istanbul ignore next */ []));
1731
+ opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
1732
+ curve = input('linear', ...(ngDevMode ? [{ debugName: "curve" }] : /* istanbul ignore next */ []));
1733
+ baseline = input(0, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
1734
+ data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1735
+ ctx = injectChartContext('CngxArea');
1736
+ builder = computed(() => createPathBuilder({
1737
+ y: this.accessor(),
1738
+ x: this.xAccessor(),
1739
+ curve: this.curve(),
1740
+ }), ...(ngDevMode ? [{ debugName: "builder" }] : /* istanbul ignore next */ []));
1741
+ resolvedData = computed(() => {
1742
+ const local = this.data();
1743
+ if (local !== undefined) {
1744
+ return local;
1745
+ }
1746
+ return this.ctx.data();
1747
+ }, ...(ngDevMode ? [{ debugName: "resolvedData" }] : /* istanbul ignore next */ []));
1748
+ d = computed(() => {
1749
+ const data = this.resolvedData();
1750
+ if (data.length === 0) {
1751
+ return '';
1752
+ }
1753
+ const xScale = this.ctx.xScale();
1754
+ const yScale = this.ctx.yScale();
1755
+ const upper = this.builder().build(data, xScale, yScale);
1756
+ const baselineY = yScale(this.baseline());
1757
+ const xAcc = this.xAccessor() ?? ((_, i) => i);
1758
+ const lastX = xScale(xAcc(data[data.length - 1], data.length - 1));
1759
+ const firstX = xScale(xAcc(data[0], 0));
1760
+ return `${upper} L ${lastX} ${baselineY} L ${firstX} ${baselineY} Z`;
1761
+ }, { ...(ngDevMode ? { debugName: "d" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b });
1762
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxArea, deps: [], target: i0.ɵɵFactoryTarget.Component });
1763
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxArea, isStandalone: true, selector: "[cngxArea]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, xAccessor: { classPropertyName: "xAccessor", publicName: "xAccessor", isSignal: true, isRequired: false, transformFunction: null }, opacity: { classPropertyName: "opacity", publicName: "opacity", isSignal: true, isRequired: false, transformFunction: null }, curve: { classPropertyName: "curve", publicName: "curve", isSignal: true, isRequired: false, transformFunction: null }, baseline: { classPropertyName: "baseline", publicName: "baseline", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxArea"], ngImport: i0, template: `
1764
+ <svg:path
1765
+ class="cngx-area"
1766
+ [attr.d]="d()"
1767
+ [attr.fill-opacity]="opacity()"
1768
+ />
1769
+ `, isInline: true, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-area{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1770
+ }
1771
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxArea, decorators: [{
1772
+ type: Component,
1773
+ args: [{ selector: '[cngxArea]', exportAs: 'cngxArea', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
1774
+ <svg:path
1775
+ class="cngx-area"
1776
+ [attr.d]="d()"
1777
+ [attr.fill-opacity]="opacity()"
1778
+ />
1779
+ `, styles: [".cngx-area{fill:var(--cngx-area-fill, var(--cngx-chart-primary, currentColor));fill-opacity:var(--cngx-area-opacity, .18);stroke:none;animation:cngx-area-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-area-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-area{animation:none}}\n"] }]
1780
+ }], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], xAccessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAccessor", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }], curve: [{ type: i0.Input, args: [{ isSignal: true, alias: "curve", required: false }] }], baseline: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseline", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
1781
+
1782
+ const FALLBACK_BASELINE = 0;
1783
+ /**
1784
+ * Bar layer atom. Renders one `<rect>` per datapoint. Bar width comes
1785
+ * from `dimensions.width / dataLength` (one slot per datapoint) shrunk
1786
+ * by the optional `[gap]` ratio. Bar height runs from `yScale(value)`
1787
+ * down to `yScale(baseline)` (default 0) — SVG bottom-anchored.
1788
+ *
1789
+ * Bar does NOT require a band X scale; the slot width is purely
1790
+ * geometric. This keeps the atom usable with linear or band X axes
1791
+ * interchangeably.
1792
+ *
1793
+ * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1794
+ */
1795
+ class CngxBar {
1796
+ accessor = input(((d) => Number(d)), ...(ngDevMode ? [{ debugName: "accessor" }] : /* istanbul ignore next */ []));
1797
+ gap = input(0.1, ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
1798
+ baseline = input(FALLBACK_BASELINE, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
1799
+ data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1800
+ ctx = injectChartContext('CngxBar');
1801
+ resolvedData = computed(() => {
1802
+ const local = this.data();
1803
+ if (local !== undefined) {
1804
+ return local;
1805
+ }
1806
+ return this.ctx.data();
1807
+ }, ...(ngDevMode ? [{ debugName: "resolvedData" }] : /* istanbul ignore next */ []));
1808
+ rects = computed(() => {
1809
+ const data = this.resolvedData();
1810
+ const n = data.length;
1811
+ if (n === 0) {
1812
+ return [];
1813
+ }
1814
+ const { width } = this.ctx.dimensions();
1815
+ const yScale = this.ctx.yScale();
1816
+ const slot = width / n;
1817
+ const gap = clamp01(this.gap());
1818
+ const inner = slot * (1 - gap);
1819
+ const offset = (slot - inner) / 2;
1820
+ const baselineY = yScale(this.baseline());
1821
+ const yAcc = this.accessor();
1822
+ const out = new Array(n);
1823
+ for (let i = 0; i < n; i++) {
1824
+ const value = yAcc(data[i], i);
1825
+ const valueY = yScale(value);
1826
+ const top = Math.min(valueY, baselineY);
1827
+ const bottom = Math.max(valueY, baselineY);
1828
+ out[i] = {
1829
+ key: i,
1830
+ x: i * slot + offset,
1831
+ y: top,
1832
+ width: inner,
1833
+ height: bottom - top,
1834
+ };
1835
+ }
1836
+ return out;
1837
+ }, { ...(ngDevMode ? { debugName: "rects" } : /* istanbul ignore next */ {}), equal: rectsEqual });
1838
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
1839
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBar, isStandalone: true, selector: "[cngxBar]", inputs: { accessor: { classPropertyName: "accessor", publicName: "accessor", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, baseline: { classPropertyName: "baseline", publicName: "baseline", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxBar"], ngImport: i0, template: `
1840
+ @for (rect of rects(); track rect.key) {
1841
+ <svg:rect
1842
+ class="cngx-bar"
1843
+ [attr.x]="rect.x"
1844
+ [attr.y]="rect.y"
1845
+ [attr.width]="rect.width"
1846
+ [attr.height]="rect.height"
1847
+ />
1848
+ }
1849
+ `, isInline: true, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1850
+ }
1851
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBar, decorators: [{
1852
+ type: Component,
1853
+ args: [{ selector: '[cngxBar]', exportAs: 'cngxBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
1854
+ @for (rect of rects(); track rect.key) {
1855
+ <svg:rect
1856
+ class="cngx-bar"
1857
+ [attr.x]="rect.x"
1858
+ [attr.y]="rect.y"
1859
+ [attr.width]="rect.width"
1860
+ [attr.height]="rect.height"
1861
+ />
1862
+ }
1863
+ `, styles: [".cngx-bar{fill:var(--cngx-bar-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 100%;transform-box:fill-box;animation:cngx-bar-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.2, .64, 1))}@keyframes cngx-bar-enter{0%{transform:scaleY(0);opacity:0}to{transform:scaleY(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-bar{animation:none}}\n"] }]
1864
+ }], propDecorators: { accessor: [{ type: i0.Input, args: [{ isSignal: true, alias: "accessor", required: false }] }], gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }], baseline: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseline", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
1865
+ function clamp01(v) {
1866
+ if (v < 0) {
1867
+ return 0;
1868
+ }
1869
+ if (v > 1) {
1870
+ return 1;
1871
+ }
1872
+ return v;
1873
+ }
1874
+ function rectsEqual(a, b) {
1875
+ if (a === b) {
1876
+ return true;
1877
+ }
1878
+ if (a.length !== b.length) {
1879
+ return false;
1880
+ }
1881
+ for (let i = 0; i < a.length; i++) {
1882
+ const x = a[i];
1883
+ const y = b[i];
1884
+ if (x.x !== y.x || x.y !== y.y || x.width !== y.width || x.height !== y.height) {
1885
+ return false;
1886
+ }
1887
+ }
1888
+ return true;
1889
+ }
1890
+
1891
+ /**
1892
+ * Scatter layer atom. Renders one `<circle>` per datapoint. X and Y
1893
+ * accessors are independent — neither defaults to index, since the
1894
+ * defining trait of a scatter chart is two genuine data dimensions.
1895
+ *
1896
+ * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1897
+ */
1898
+ class CngxScatter {
1899
+ x = input.required(...(ngDevMode ? [{ debugName: "x" }] : /* istanbul ignore next */ []));
1900
+ y = input.required(...(ngDevMode ? [{ debugName: "y" }] : /* istanbul ignore next */ []));
1901
+ radius = input(3, ...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
1902
+ data = input(undefined, ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1903
+ ctx = injectChartContext('CngxScatter');
1904
+ resolvedData = computed(() => {
1905
+ const local = this.data();
1906
+ if (local !== undefined) {
1907
+ return local;
1908
+ }
1909
+ return this.ctx.data();
1910
+ }, ...(ngDevMode ? [{ debugName: "resolvedData" }] : /* istanbul ignore next */ []));
1911
+ circles = computed(() => {
1912
+ const data = this.resolvedData();
1913
+ const xScale = this.ctx.xScale();
1914
+ const yScale = this.ctx.yScale();
1915
+ const xAcc = this.x();
1916
+ const yAcc = this.y();
1917
+ const out = new Array(data.length);
1918
+ for (let i = 0; i < data.length; i++) {
1919
+ out[i] = {
1920
+ key: i,
1921
+ cx: xScale(xAcc(data[i], i)),
1922
+ cy: yScale(yAcc(data[i], i)),
1923
+ };
1924
+ }
1925
+ return out;
1926
+ }, { ...(ngDevMode ? { debugName: "circles" } : /* istanbul ignore next */ {}), equal: circlesEqual });
1927
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, deps: [], target: i0.ɵɵFactoryTarget.Component });
1928
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxScatter, isStandalone: true, selector: "[cngxScatter]", inputs: { x: { classPropertyName: "x", publicName: "x", isSignal: true, isRequired: true, transformFunction: null }, y: { classPropertyName: "y", publicName: "y", isSignal: true, isRequired: true, transformFunction: null }, radius: { classPropertyName: "radius", publicName: "radius", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxScatter"], ngImport: i0, template: `
1929
+ @for (c of circles(); track c.key) {
1930
+ <svg:circle
1931
+ class="cngx-scatter"
1932
+ [attr.cx]="c.cx"
1933
+ [attr.cy]="c.cy"
1934
+ [attr.r]="radius()"
1935
+ />
1936
+ }
1937
+ `, isInline: true, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1938
+ }
1939
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScatter, decorators: [{
1940
+ type: Component,
1941
+ args: [{ selector: '[cngxScatter]', exportAs: 'cngxScatter', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
1942
+ @for (c of circles(); track c.key) {
1943
+ <svg:circle
1944
+ class="cngx-scatter"
1945
+ [attr.cx]="c.cx"
1946
+ [attr.cy]="c.cy"
1947
+ [attr.r]="radius()"
1948
+ />
1949
+ }
1950
+ `, styles: [".cngx-scatter{fill:var(--cngx-scatter-color, var(--cngx-chart-primary, currentColor));transform-origin:50% 50%;transform-box:fill-box;animation:cngx-scatter-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.34, 1.56, .64, 1)) backwards}@keyframes cngx-scatter-enter{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-scatter{animation:none}}\n"] }]
1951
+ }], propDecorators: { x: [{ type: i0.Input, args: [{ isSignal: true, alias: "x", required: true }] }], y: [{ type: i0.Input, args: [{ isSignal: true, alias: "y", required: true }] }], radius: [{ type: i0.Input, args: [{ isSignal: true, alias: "radius", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }] } });
1952
+ function circlesEqual(a, b) {
1953
+ if (a === b) {
1954
+ return true;
1955
+ }
1956
+ if (a.length !== b.length) {
1957
+ return false;
1958
+ }
1959
+ for (let i = 0; i < a.length; i++) {
1960
+ if (a[i].cx !== b[i].cx || a[i].cy !== b[i].cy) {
1961
+ return false;
1962
+ }
1963
+ }
1964
+ return true;
1965
+ }
1966
+
1967
+ /**
1968
+ * Band reference atom. Renders a `<rect>` across a vertical Y-range
1969
+ * (`from..to`) spanning the chart's full width. Use to highlight a
1970
+ * value range (e.g. "good zone", "watch zone") behind primary layers.
1971
+ *
1972
+ * Default opacity is low (`var(--cngx-band-opacity, 0.12)`) so the
1973
+ * band sits behind line / area / bar layers without dominating.
1974
+ *
1975
+ * Attribute-selector on `<svg:g>` — see {@link CngxLine} for why.
1976
+ */
1977
+ class CngxBand {
1978
+ from = input.required(...(ngDevMode ? [{ debugName: "from" }] : /* istanbul ignore next */ []));
1979
+ to = input.required(...(ngDevMode ? [{ debugName: "to" }] : /* istanbul ignore next */ []));
1980
+ label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1981
+ opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
1982
+ ctx = injectChartContext('CngxBand');
1983
+ rect = computed(() => {
1984
+ const { width, height } = this.ctx.dimensions();
1985
+ if (width <= 0 || height <= 0) {
1986
+ return null;
1987
+ }
1988
+ const yScale = this.ctx.yScale();
1989
+ const yA = yScale(this.from());
1990
+ const yB = yScale(this.to());
1991
+ const top = Math.min(yA, yB);
1992
+ const bottom = Math.max(yA, yB);
1993
+ return { width, y: top, height: bottom - top };
1994
+ }, { ...(ngDevMode ? { debugName: "rect" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
1995
+ (a !== null &&
1996
+ b !== null &&
1997
+ a.width === b.width &&
1998
+ a.y === b.y &&
1999
+ a.height === b.height) });
2000
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBand, deps: [], target: i0.ɵɵFactoryTarget.Component });
2001
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBand, isStandalone: true, selector: "[cngxBand]", inputs: { from: { classPropertyName: "from", publicName: "from", isSignal: true, isRequired: true, transformFunction: null }, to: { classPropertyName: "to", publicName: "to", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, opacity: { classPropertyName: "opacity", publicName: "opacity", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxBand"], ngImport: i0, template: `
2002
+ @if (rect(); as r) {
2003
+ <svg:rect
2004
+ class="cngx-band__rect"
2005
+ [attr.x]="0"
2006
+ [attr.y]="r.y"
2007
+ [attr.width]="r.width"
2008
+ [attr.height]="r.height"
2009
+ [attr.fill-opacity]="opacity()"
2010
+ />
2011
+ @if (label(); as l) {
2012
+ <svg:text
2013
+ class="cngx-band__label"
2014
+ [attr.x]="4"
2015
+ [attr.y]="r.y + r.height / 2"
2016
+ text-anchor="start"
2017
+ dominant-baseline="middle"
2018
+ >
2019
+ {{ l }}
2020
+ </svg:text>
2021
+ }
2022
+ }
2023
+ `, isInline: true, styles: [".cngx-band__rect{fill:var(--cngx-band-color, var(--cngx-chart-secondary, currentColor));fill-opacity:var(--cngx-band-opacity, .12);stroke:none;animation:cngx-band-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}.cngx-band__label{fill:var(--cngx-band-text-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-band-font-size, 11px);animation:cngx-band-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-band-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-band__rect,.cngx-band__label{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2024
+ }
2025
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBand, decorators: [{
2026
+ type: Component,
2027
+ args: [{ selector: '[cngxBand]', exportAs: 'cngxBand', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
2028
+ @if (rect(); as r) {
2029
+ <svg:rect
2030
+ class="cngx-band__rect"
2031
+ [attr.x]="0"
2032
+ [attr.y]="r.y"
2033
+ [attr.width]="r.width"
2034
+ [attr.height]="r.height"
2035
+ [attr.fill-opacity]="opacity()"
2036
+ />
2037
+ @if (label(); as l) {
2038
+ <svg:text
2039
+ class="cngx-band__label"
2040
+ [attr.x]="4"
2041
+ [attr.y]="r.y + r.height / 2"
2042
+ text-anchor="start"
2043
+ dominant-baseline="middle"
2044
+ >
2045
+ {{ l }}
2046
+ </svg:text>
2047
+ }
2048
+ }
2049
+ `, styles: [".cngx-band__rect{fill:var(--cngx-band-color, var(--cngx-chart-secondary, currentColor));fill-opacity:var(--cngx-band-opacity, .12);stroke:none;animation:cngx-band-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}.cngx-band__label{fill:var(--cngx-band-text-color, var(--cngx-chart-text-color, currentColor));font-size:var(--cngx-band-font-size, 11px);animation:cngx-band-enter var(--cngx-chart-enter-duration, .48s) var(--cngx-chart-enter-easing, cubic-bezier(.4, 0, .2, 1))}@keyframes cngx-band-enter{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.cngx-band__rect,.cngx-band__label{animation:none}}\n"] }]
2050
+ }], propDecorators: { from: [{ type: i0.Input, args: [{ isSignal: true, alias: "from", required: true }] }], to: [{ type: i0.Input, args: [{ isSignal: true, alias: "to", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }] } });
2051
+
2052
+ /**
2053
+ * Shared `[state]` → `activeView` derivation for chart presets. Maps
2054
+ * a `CngxAsyncState` (when bound) to the same `AsyncView` discriminator
2055
+ * the select family uses; presets render skeleton / empty / error /
2056
+ * content branches off the same enum.
2057
+ *
2058
+ * Returns `'content'` when `state` is unbound — the preset renders its
2059
+ * SVG/DOM body without any state envelope. Treats `'content+error'`
2060
+ * the same as `'content'` for v1: a four-rect chart preset has no
2061
+ * room for an inline-error overlay; consumers compose
2062
+ * `<cngx-banner-on />` against the same `[state]` if they need
2063
+ * explicit transition feedback.
2064
+ *
2065
+ * @internal
2066
+ */
2067
+ function injectPresetState(state) {
2068
+ const i18n = inject(CNGX_CHART_I18N);
2069
+ const activeView = computed(() => {
2070
+ const s = state();
2071
+ if (!s) {
2072
+ return 'content';
2073
+ }
2074
+ return resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
2075
+ }, ...(ngDevMode ? [{ debugName: "activeView" }] : /* istanbul ignore next */ []));
2076
+ return { i18n, activeView };
2077
+ }
2078
+
2079
+ /**
2080
+ * Inline sparkline — a tiny line chart for KPI cards and dashboard
2081
+ * tiles. Composes `<cngx-chart>` + `<cngx-line>` (+ optional
2082
+ * `<cngx-area>`) with hidden axes that publish the scale domain
2083
+ * derived from the `data` array.
2084
+ *
2085
+ * Default viewBox is 80×24, intended for inline placement next to a
2086
+ * label or numeric value. Theming via `--cngx-sparkline-color`
2087
+ * (atom-local) → `--cngx-chart-primary` (chart-level) cascade.
2088
+ *
2089
+ * The host carries `role="img"` and a reactive `aria-label` derived
2090
+ * from the chart's auto-Summary; consumers can override via
2091
+ * `[ariaLabel]`.
2092
+ */
2093
+ class CngxSparkline {
2094
+ data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
2095
+ width = input(80, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
2096
+ height = input(24, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
2097
+ strokeWidth = input(null, ...(ngDevMode ? [{ debugName: "strokeWidth" }] : /* istanbul ignore next */ []));
2098
+ showArea = input(false, ...(ngDevMode ? [{ debugName: "showArea" }] : /* istanbul ignore next */ []));
2099
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2100
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2101
+ preset = injectPresetState(() => this.state());
2102
+ i18n = this.preset.i18n;
2103
+ activeView = this.preset.activeView;
2104
+ xDomain = computed(() => {
2105
+ const n = this.data().length;
2106
+ return n < 2 ? [0, 1] : [0, n - 1];
2107
+ }, ...(ngDevMode ? [{ debugName: "xDomain" }] : /* istanbul ignore next */ []));
2108
+ yDomain = computed(() => {
2109
+ const d = this.data();
2110
+ if (d.length === 0) {
2111
+ return [0, 1];
2112
+ }
2113
+ let min = d[0];
2114
+ let max = d[0];
2115
+ for (let i = 1; i < d.length; i++) {
2116
+ const v = d[i];
2117
+ if (v < min) {
2118
+ min = v;
2119
+ }
2120
+ if (v > max) {
2121
+ max = v;
2122
+ }
2123
+ }
2124
+ if (min === max) {
2125
+ return [min - 1, max + 1];
2126
+ }
2127
+ return [min, max];
2128
+ }, ...(ngDevMode ? [{ debugName: "yDomain" }] : /* istanbul ignore next */ []));
2129
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSparkline, deps: [], target: i0.ɵɵFactoryTarget.Component });
2130
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSparkline, isStandalone: true, selector: "cngx-sparkline", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, showArea: { classPropertyName: "showArea", publicName: "showArea", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-sparkline" }, exportAs: ["cngxSparkline"], ngImport: i0, template: `
2131
+ @switch (activeView()) {
2132
+ @case ('skeleton') {
2133
+ <span
2134
+ class="cngx-preset-skeleton"
2135
+ [style.width.px]="width()"
2136
+ [style.height.px]="height()"
2137
+ [attr.aria-busy]="true"
2138
+ [attr.aria-label]="i18n.loading()"
2139
+ ></span>
2140
+ }
2141
+ @case ('empty') {
2142
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2143
+ }
2144
+ @case ('error') {
2145
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2146
+ }
2147
+ @case ('none') {}
2148
+ @default {
2149
+ <cngx-chart
2150
+ [data]="data()"
2151
+ [width]="width()"
2152
+ [height]="height()"
2153
+ [aria-label]="ariaLabel()"
2154
+ >
2155
+ <svg:g cngxAxis position="bottom" type="linear" [domain]="xDomain()"></svg:g>
2156
+ <svg:g cngxAxis position="left" type="linear" [domain]="yDomain()"></svg:g>
2157
+ @if (showArea()) {
2158
+ <svg:g cngxArea [baseline]="yDomain()[0]"></svg:g>
2159
+ }
2160
+ <svg:g cngxLine [strokeWidth]="strokeWidth()"></svg:g>
2161
+ </cngx-chart>
2162
+ }
2163
+ }
2164
+ `, isInline: true, styles: ["cngx-sparkline{display:inline-block;line-height:0;--cngx-line-color: var(--cngx-sparkline-color, var(--cngx-chart-primary, currentColor));--cngx-area-fill: var(--cngx-sparkline-color, var(--cngx-chart-primary, currentColor))}cngx-sparkline [cngxAxis]{display:none}cngx-sparkline .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-preset-skeleton-radius, 2px);animation:cngx-preset-shimmer 1.4s linear infinite;background-image:linear-gradient(90deg,transparent 0,var(--cngx-skeleton-shimmer, rgb(255 255 255 / .3)) 50%,transparent 100%);background-size:200% 100%}cngx-sparkline .cngx-preset-fallback{display:inline-block;line-height:normal;font-size:var(--cngx-preset-fallback-font-size, .75rem);color:var(--cngx-chart-text-color, currentColor);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-sparkline .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}@keyframes cngx-preset-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){cngx-sparkline .cngx-preset-skeleton{animation:none}}\n"], dependencies: [{ kind: "component", type: CngxChart, selector: "cngx-chart", inputs: ["data", "width", "height", "preserveAspectRatio", "aria-label", "summaryAccessor", "accessibleTable", "state"], exportAs: ["cngxChart"] }, { kind: "component", type: CngxAxis, selector: "[cngxAxis]", inputs: ["position", "type", "domain", "ticks", "format", "grid", "label"], exportAs: ["cngxAxis"] }, { kind: "component", type: CngxLine, selector: "[cngxLine]", inputs: ["accessor", "xAccessor", "color", "strokeWidth", "curve", "data"], exportAs: ["cngxLine"] }, { kind: "component", type: CngxArea, selector: "[cngxArea]", inputs: ["accessor", "xAccessor", "opacity", "curve", "baseline", "data"], exportAs: ["cngxArea"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2165
+ }
2166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSparkline, decorators: [{
2167
+ type: Component,
2168
+ args: [{ selector: 'cngx-sparkline', exportAs: 'cngxSparkline', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxChart, CngxAxis, CngxLine, CngxArea], host: { class: 'cngx-sparkline' }, template: `
2169
+ @switch (activeView()) {
2170
+ @case ('skeleton') {
2171
+ <span
2172
+ class="cngx-preset-skeleton"
2173
+ [style.width.px]="width()"
2174
+ [style.height.px]="height()"
2175
+ [attr.aria-busy]="true"
2176
+ [attr.aria-label]="i18n.loading()"
2177
+ ></span>
2178
+ }
2179
+ @case ('empty') {
2180
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2181
+ }
2182
+ @case ('error') {
2183
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2184
+ }
2185
+ @case ('none') {}
2186
+ @default {
2187
+ <cngx-chart
2188
+ [data]="data()"
2189
+ [width]="width()"
2190
+ [height]="height()"
2191
+ [aria-label]="ariaLabel()"
2192
+ >
2193
+ <svg:g cngxAxis position="bottom" type="linear" [domain]="xDomain()"></svg:g>
2194
+ <svg:g cngxAxis position="left" type="linear" [domain]="yDomain()"></svg:g>
2195
+ @if (showArea()) {
2196
+ <svg:g cngxArea [baseline]="yDomain()[0]"></svg:g>
2197
+ }
2198
+ <svg:g cngxLine [strokeWidth]="strokeWidth()"></svg:g>
2199
+ </cngx-chart>
2200
+ }
2201
+ }
2202
+ `, styles: ["cngx-sparkline{display:inline-block;line-height:0;--cngx-line-color: var(--cngx-sparkline-color, var(--cngx-chart-primary, currentColor));--cngx-area-fill: var(--cngx-sparkline-color, var(--cngx-chart-primary, currentColor))}cngx-sparkline [cngxAxis]{display:none}cngx-sparkline .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-preset-skeleton-radius, 2px);animation:cngx-preset-shimmer 1.4s linear infinite;background-image:linear-gradient(90deg,transparent 0,var(--cngx-skeleton-shimmer, rgb(255 255 255 / .3)) 50%,transparent 100%);background-size:200% 100%}cngx-sparkline .cngx-preset-fallback{display:inline-block;line-height:normal;font-size:var(--cngx-preset-fallback-font-size, .75rem);color:var(--cngx-chart-text-color, currentColor);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-sparkline .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}@keyframes cngx-preset-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){cngx-sparkline .cngx-preset-skeleton{animation:none}}\n"] }]
2203
+ }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], strokeWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "strokeWidth", required: false }] }], showArea: [{ type: i0.Input, args: [{ isSignal: true, alias: "showArea", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2204
+
2205
+ /**
2206
+ * Mini horizontal bar — a single-value bounded indicator. Renders
2207
+ * pure DOM (no SVG), positioned with CSS only. Host carries
2208
+ * `role="meter"` per the WAI-ARIA pattern for single-value bounded
2209
+ * indicators; `aria-valuenow` / `aria-valuemin` / `aria-valuemax`
2210
+ * tell AT the exact reading without a separate Summary.
2211
+ */
2212
+ class CngxMiniBar {
2213
+ value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
2214
+ max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
2215
+ min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
2216
+ label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
2217
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2218
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2219
+ preset = injectPresetState(() => this.state());
2220
+ i18n = this.preset.i18n;
2221
+ activeView = this.preset.activeView;
2222
+ percent = computed(() => {
2223
+ const v = this.value();
2224
+ const lo = this.min();
2225
+ const hi = this.max();
2226
+ if (hi === lo) {
2227
+ return 0;
2228
+ }
2229
+ const ratio = ((v - lo) / (hi - lo)) * 100;
2230
+ if (ratio < 0) {
2231
+ return 0;
2232
+ }
2233
+ if (ratio > 100) {
2234
+ return 100;
2235
+ }
2236
+ return ratio;
2237
+ }, ...(ngDevMode ? [{ debugName: "percent" }] : /* istanbul ignore next */ []));
2238
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMiniBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
2239
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxMiniBar, isStandalone: true, selector: "cngx-mini-bar", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "meter" }, properties: { "attr.aria-valuenow": "value()", "attr.aria-valuemin": "min()", "attr.aria-valuemax": "max()", "attr.aria-label": "ariaLabel()" }, classAttribute: "cngx-mini-bar" }, exportAs: ["cngxMiniBar"], ngImport: i0, template: `
2240
+ @switch (activeView()) {
2241
+ @case ('skeleton') {
2242
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2243
+ }
2244
+ @case ('empty') {
2245
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2246
+ }
2247
+ @case ('error') {
2248
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2249
+ }
2250
+ @case ('none') {}
2251
+ @default {
2252
+ <div class="cngx-mini-bar__track">
2253
+ <div class="cngx-mini-bar__fill" [style.width.%]="percent()"></div>
2254
+ </div>
2255
+ }
2256
+ }
2257
+ `, isInline: true, styles: ["cngx-mini-bar{display:inline-block;width:var(--cngx-mini-bar-width, 80px);--cngx-mini-bar-color: var(--cngx-bar-color, var(--cngx-chart-primary, currentColor))}cngx-mini-bar .cngx-mini-bar__track{position:relative;height:var(--cngx-mini-bar-height, 6px);background:var(--cngx-mini-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-mini-bar-radius, 3px);overflow:hidden}cngx-mini-bar .cngx-mini-bar__fill{height:100%;background:var(--cngx-mini-bar-color);border-radius:inherit;transition:width var(--cngx-mini-bar-transition, .24s) ease-out}cngx-mini-bar .cngx-preset-skeleton{display:block;height:var(--cngx-mini-bar-height, 6px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-mini-bar-radius, 3px)}cngx-mini-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-mini-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2258
+ }
2259
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMiniBar, decorators: [{
2260
+ type: Component,
2261
+ args: [{ selector: 'cngx-mini-bar', exportAs: 'cngxMiniBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2262
+ role: 'meter',
2263
+ '[attr.aria-valuenow]': 'value()',
2264
+ '[attr.aria-valuemin]': 'min()',
2265
+ '[attr.aria-valuemax]': 'max()',
2266
+ '[attr.aria-label]': 'ariaLabel()',
2267
+ class: 'cngx-mini-bar',
2268
+ }, template: `
2269
+ @switch (activeView()) {
2270
+ @case ('skeleton') {
2271
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2272
+ }
2273
+ @case ('empty') {
2274
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2275
+ }
2276
+ @case ('error') {
2277
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2278
+ }
2279
+ @case ('none') {}
2280
+ @default {
2281
+ <div class="cngx-mini-bar__track">
2282
+ <div class="cngx-mini-bar__fill" [style.width.%]="percent()"></div>
2283
+ </div>
2284
+ }
2285
+ }
2286
+ `, styles: ["cngx-mini-bar{display:inline-block;width:var(--cngx-mini-bar-width, 80px);--cngx-mini-bar-color: var(--cngx-bar-color, var(--cngx-chart-primary, currentColor))}cngx-mini-bar .cngx-mini-bar__track{position:relative;height:var(--cngx-mini-bar-height, 6px);background:var(--cngx-mini-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-mini-bar-radius, 3px);overflow:hidden}cngx-mini-bar .cngx-mini-bar__fill{height:100%;background:var(--cngx-mini-bar-color);border-radius:inherit;transition:width var(--cngx-mini-bar-transition, .24s) ease-out}cngx-mini-bar .cngx-preset-skeleton{display:block;height:var(--cngx-mini-bar-height, 6px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-mini-bar-radius, 3px)}cngx-mini-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-mini-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2287
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2288
+
2289
+ /**
2290
+ * Mini deviation bar — a single-value indicator that diverges from a
2291
+ * `[baseline]` (default `0`) in either direction. Negative deviations
2292
+ * render to the left of the baseline mark, positive to the right.
2293
+ * Pure DOM, no SVG. Host carries `role="meter"`.
2294
+ *
2295
+ * Use cases: budget variance ("$+45k over"), score deltas ("−12%
2296
+ * vs target"), KPI swing visualisations.
2297
+ */
2298
+ class CngxDeviationBar {
2299
+ value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
2300
+ baseline = input(0, ...(ngDevMode ? [{ debugName: "baseline" }] : /* istanbul ignore next */ []));
2301
+ magnitude = input(100, ...(ngDevMode ? [{ debugName: "magnitude" }] : /* istanbul ignore next */ []));
2302
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2303
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2304
+ preset = injectPresetState(() => this.state());
2305
+ i18n = this.preset.i18n;
2306
+ activeView = this.preset.activeView;
2307
+ geometry = computed(() => {
2308
+ const v = this.value();
2309
+ const b = this.baseline();
2310
+ const m = this.magnitude();
2311
+ if (m <= 0) {
2312
+ return null;
2313
+ }
2314
+ const delta = v - b;
2315
+ if (delta === 0) {
2316
+ return null;
2317
+ }
2318
+ const positive = delta > 0;
2319
+ const ratio = Math.min(Math.abs(delta) / m, 1) * 50;
2320
+ if (positive) {
2321
+ return { positive, left: 50, width: ratio };
2322
+ }
2323
+ return { positive, left: 50 - ratio, width: ratio };
2324
+ }, ...(ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []));
2325
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDeviationBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
2326
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxDeviationBar, isStandalone: true, selector: "cngx-deviation-bar", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, baseline: { classPropertyName: "baseline", publicName: "baseline", isSignal: true, isRequired: false, transformFunction: null }, magnitude: { classPropertyName: "magnitude", publicName: "magnitude", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "meter" }, properties: { "attr.aria-valuenow": "value()", "attr.aria-valuemin": "-magnitude()", "attr.aria-valuemax": "magnitude()", "attr.aria-label": "ariaLabel()" }, classAttribute: "cngx-deviation-bar" }, exportAs: ["cngxDeviationBar"], ngImport: i0, template: `
2327
+ @switch (activeView()) {
2328
+ @case ('skeleton') {
2329
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2330
+ }
2331
+ @case ('empty') {
2332
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2333
+ }
2334
+ @case ('error') {
2335
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2336
+ }
2337
+ @case ('none') {}
2338
+ @default {
2339
+ <div class="cngx-deviation-bar__track">
2340
+ <div class="cngx-deviation-bar__baseline"></div>
2341
+ @if (geometry(); as g) {
2342
+ <div
2343
+ class="cngx-deviation-bar__fill"
2344
+ [class.cngx-deviation-bar__fill--positive]="g.positive"
2345
+ [class.cngx-deviation-bar__fill--negative]="!g.positive"
2346
+ [style.left.%]="g.left"
2347
+ [style.width.%]="g.width"
2348
+ ></div>
2349
+ }
2350
+ </div>
2351
+ }
2352
+ }
2353
+ `, isInline: true, styles: ["cngx-deviation-bar{display:inline-block;width:var(--cngx-deviation-bar-width, 100px);--cngx-deviation-positive: var(--cngx-chart-success, #1f9d55);--cngx-deviation-negative: var(--cngx-chart-danger, #d2452f)}cngx-deviation-bar .cngx-deviation-bar__track{position:relative;height:var(--cngx-deviation-bar-height, 6px);background:var(--cngx-deviation-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-deviation-bar-radius, 3px);overflow:hidden}cngx-deviation-bar .cngx-deviation-bar__baseline{position:absolute;left:50%;top:0;bottom:0;width:1px;background:var(--cngx-deviation-bar-baseline-color, var(--cngx-chart-axis-color, currentColor));opacity:var(--cngx-deviation-bar-baseline-opacity, .5)}cngx-deviation-bar .cngx-deviation-bar__fill{position:absolute;top:0;bottom:0;transition:left var(--cngx-deviation-bar-transition, .24s) ease-out,width var(--cngx-deviation-bar-transition, .24s) ease-out}cngx-deviation-bar .cngx-deviation-bar__fill--positive{background:var(--cngx-deviation-positive)}cngx-deviation-bar .cngx-deviation-bar__fill--negative{background:var(--cngx-deviation-negative)}cngx-deviation-bar .cngx-preset-skeleton{display:block;height:var(--cngx-deviation-bar-height, 6px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-deviation-bar-radius, 3px)}cngx-deviation-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-deviation-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2354
+ }
2355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDeviationBar, decorators: [{
2356
+ type: Component,
2357
+ args: [{ selector: 'cngx-deviation-bar', exportAs: 'cngxDeviationBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2358
+ role: 'meter',
2359
+ '[attr.aria-valuenow]': 'value()',
2360
+ '[attr.aria-valuemin]': '-magnitude()',
2361
+ '[attr.aria-valuemax]': 'magnitude()',
2362
+ '[attr.aria-label]': 'ariaLabel()',
2363
+ class: 'cngx-deviation-bar',
2364
+ }, template: `
2365
+ @switch (activeView()) {
2366
+ @case ('skeleton') {
2367
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2368
+ }
2369
+ @case ('empty') {
2370
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2371
+ }
2372
+ @case ('error') {
2373
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2374
+ }
2375
+ @case ('none') {}
2376
+ @default {
2377
+ <div class="cngx-deviation-bar__track">
2378
+ <div class="cngx-deviation-bar__baseline"></div>
2379
+ @if (geometry(); as g) {
2380
+ <div
2381
+ class="cngx-deviation-bar__fill"
2382
+ [class.cngx-deviation-bar__fill--positive]="g.positive"
2383
+ [class.cngx-deviation-bar__fill--negative]="!g.positive"
2384
+ [style.left.%]="g.left"
2385
+ [style.width.%]="g.width"
2386
+ ></div>
2387
+ }
2388
+ </div>
2389
+ }
2390
+ }
2391
+ `, styles: ["cngx-deviation-bar{display:inline-block;width:var(--cngx-deviation-bar-width, 100px);--cngx-deviation-positive: var(--cngx-chart-success, #1f9d55);--cngx-deviation-negative: var(--cngx-chart-danger, #d2452f)}cngx-deviation-bar .cngx-deviation-bar__track{position:relative;height:var(--cngx-deviation-bar-height, 6px);background:var(--cngx-deviation-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-deviation-bar-radius, 3px);overflow:hidden}cngx-deviation-bar .cngx-deviation-bar__baseline{position:absolute;left:50%;top:0;bottom:0;width:1px;background:var(--cngx-deviation-bar-baseline-color, var(--cngx-chart-axis-color, currentColor));opacity:var(--cngx-deviation-bar-baseline-opacity, .5)}cngx-deviation-bar .cngx-deviation-bar__fill{position:absolute;top:0;bottom:0;transition:left var(--cngx-deviation-bar-transition, .24s) ease-out,width var(--cngx-deviation-bar-transition, .24s) ease-out}cngx-deviation-bar .cngx-deviation-bar__fill--positive{background:var(--cngx-deviation-positive)}cngx-deviation-bar .cngx-deviation-bar__fill--negative{background:var(--cngx-deviation-negative)}cngx-deviation-bar .cngx-preset-skeleton{display:block;height:var(--cngx-deviation-bar-height, 6px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-deviation-bar-radius, 3px)}cngx-deviation-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-deviation-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2392
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], baseline: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseline", required: false }] }], magnitude: [{ type: i0.Input, args: [{ isSignal: true, alias: "magnitude", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2393
+
2394
+ /**
2395
+ * Inline mini area — a tiny filled-area chart for KPI cards. Sibling
2396
+ * of {@link CngxSparkline}; renders only the area (no line stroke).
2397
+ * Default viewBox 80×24. Theming via `--cngx-mini-area-color`
2398
+ * (atom-local) → `--cngx-chart-primary` (chart-level) cascade.
2399
+ */
2400
+ class CngxMiniArea {
2401
+ data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
2402
+ width = input(80, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
2403
+ height = input(24, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
2404
+ opacity = input(null, ...(ngDevMode ? [{ debugName: "opacity" }] : /* istanbul ignore next */ []));
2405
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2406
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2407
+ preset = injectPresetState(() => this.state());
2408
+ i18n = this.preset.i18n;
2409
+ activeView = this.preset.activeView;
2410
+ xDomain = computed(() => {
2411
+ const n = this.data().length;
2412
+ return n < 2 ? [0, 1] : [0, n - 1];
2413
+ }, ...(ngDevMode ? [{ debugName: "xDomain" }] : /* istanbul ignore next */ []));
2414
+ yDomain = computed(() => {
2415
+ const d = this.data();
2416
+ if (d.length === 0) {
2417
+ return [0, 1];
2418
+ }
2419
+ let min = d[0];
2420
+ let max = d[0];
2421
+ for (let i = 1; i < d.length; i++) {
2422
+ const v = d[i];
2423
+ if (v < min) {
2424
+ min = v;
2425
+ }
2426
+ if (v > max) {
2427
+ max = v;
2428
+ }
2429
+ }
2430
+ if (min === max) {
2431
+ return [min - 1, max + 1];
2432
+ }
2433
+ return [min, max];
2434
+ }, ...(ngDevMode ? [{ debugName: "yDomain" }] : /* istanbul ignore next */ []));
2435
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMiniArea, deps: [], target: i0.ɵɵFactoryTarget.Component });
2436
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxMiniArea, isStandalone: true, selector: "cngx-mini-area", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, opacity: { classPropertyName: "opacity", publicName: "opacity", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-mini-area" }, exportAs: ["cngxMiniArea"], ngImport: i0, template: `
2437
+ @switch (activeView()) {
2438
+ @case ('skeleton') {
2439
+ <span
2440
+ class="cngx-preset-skeleton"
2441
+ [style.width.px]="width()"
2442
+ [style.height.px]="height()"
2443
+ [attr.aria-busy]="true"
2444
+ [attr.aria-label]="i18n.loading()"
2445
+ ></span>
2446
+ }
2447
+ @case ('empty') {
2448
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2449
+ }
2450
+ @case ('error') {
2451
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2452
+ }
2453
+ @case ('none') {}
2454
+ @default {
2455
+ <cngx-chart
2456
+ [data]="data()"
2457
+ [width]="width()"
2458
+ [height]="height()"
2459
+ [aria-label]="ariaLabel()"
2460
+ >
2461
+ <svg:g cngxAxis position="bottom" type="linear" [domain]="xDomain()"></svg:g>
2462
+ <svg:g cngxAxis position="left" type="linear" [domain]="yDomain()"></svg:g>
2463
+ <svg:g cngxArea [opacity]="opacity()" [baseline]="yDomain()[0]"></svg:g>
2464
+ </cngx-chart>
2465
+ }
2466
+ }
2467
+ `, isInline: true, styles: ["cngx-mini-area{display:inline-block;line-height:0;--cngx-area-fill: var(--cngx-mini-area-color, var(--cngx-chart-primary, currentColor))}cngx-mini-area [cngxAxis]{display:none}cngx-mini-area .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-preset-skeleton-radius, 2px)}cngx-mini-area .cngx-preset-fallback{display:inline-block;line-height:normal;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-mini-area .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], dependencies: [{ kind: "component", type: CngxChart, selector: "cngx-chart", inputs: ["data", "width", "height", "preserveAspectRatio", "aria-label", "summaryAccessor", "accessibleTable", "state"], exportAs: ["cngxChart"] }, { kind: "component", type: CngxAxis, selector: "[cngxAxis]", inputs: ["position", "type", "domain", "ticks", "format", "grid", "label"], exportAs: ["cngxAxis"] }, { kind: "component", type: CngxArea, selector: "[cngxArea]", inputs: ["accessor", "xAccessor", "opacity", "curve", "baseline", "data"], exportAs: ["cngxArea"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2468
+ }
2469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMiniArea, decorators: [{
2470
+ type: Component,
2471
+ args: [{ selector: 'cngx-mini-area', exportAs: 'cngxMiniArea', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxChart, CngxAxis, CngxArea], host: { class: 'cngx-mini-area' }, template: `
2472
+ @switch (activeView()) {
2473
+ @case ('skeleton') {
2474
+ <span
2475
+ class="cngx-preset-skeleton"
2476
+ [style.width.px]="width()"
2477
+ [style.height.px]="height()"
2478
+ [attr.aria-busy]="true"
2479
+ [attr.aria-label]="i18n.loading()"
2480
+ ></span>
2481
+ }
2482
+ @case ('empty') {
2483
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2484
+ }
2485
+ @case ('error') {
2486
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2487
+ }
2488
+ @case ('none') {}
2489
+ @default {
2490
+ <cngx-chart
2491
+ [data]="data()"
2492
+ [width]="width()"
2493
+ [height]="height()"
2494
+ [aria-label]="ariaLabel()"
2495
+ >
2496
+ <svg:g cngxAxis position="bottom" type="linear" [domain]="xDomain()"></svg:g>
2497
+ <svg:g cngxAxis position="left" type="linear" [domain]="yDomain()"></svg:g>
2498
+ <svg:g cngxArea [opacity]="opacity()" [baseline]="yDomain()[0]"></svg:g>
2499
+ </cngx-chart>
2500
+ }
2501
+ }
2502
+ `, styles: ["cngx-mini-area{display:inline-block;line-height:0;--cngx-area-fill: var(--cngx-mini-area-color, var(--cngx-chart-primary, currentColor))}cngx-mini-area [cngxAxis]{display:none}cngx-mini-area .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-preset-skeleton-radius, 2px)}cngx-mini-area .cngx-preset-fallback{display:inline-block;line-height:normal;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-mini-area .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2503
+ }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2504
+
2505
+ const TWO_PI = Math.PI * 2;
2506
+ /**
2507
+ * Circular donut gauge — a single-value bounded indicator. Renders a
2508
+ * background ring + a foreground arc whose length is proportional to
2509
+ * `value / max`. Host carries `role="meter"`; the optional `[label]`
2510
+ * input renders an SR-only label inside the ring's centre.
2511
+ */
2512
+ class CngxDonut {
2513
+ value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
2514
+ max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
2515
+ size = input(48, ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
2516
+ thickness = input(6, ...(ngDevMode ? [{ debugName: "thickness" }] : /* istanbul ignore next */ []));
2517
+ label = input(null, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
2518
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2519
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2520
+ preset = injectPresetState(() => this.state());
2521
+ i18n = this.preset.i18n;
2522
+ activeView = this.preset.activeView;
2523
+ center = computed(() => this.size() / 2, ...(ngDevMode ? [{ debugName: "center" }] : /* istanbul ignore next */ []));
2524
+ radius = computed(() => (this.size() - this.thickness()) / 2, ...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
2525
+ circumference = computed(() => TWO_PI * this.radius(), ...(ngDevMode ? [{ debugName: "circumference" }] : /* istanbul ignore next */ []));
2526
+ dasharray = computed(() => {
2527
+ const c = this.circumference();
2528
+ return `${c} ${c}`;
2529
+ }, ...(ngDevMode ? [{ debugName: "dasharray" }] : /* istanbul ignore next */ []));
2530
+ dashoffset = computed(() => {
2531
+ const c = this.circumference();
2532
+ const m = this.max();
2533
+ if (m <= 0) {
2534
+ return c;
2535
+ }
2536
+ const ratio = Math.min(Math.max(this.value() / m, 0), 1);
2537
+ return c * (1 - ratio);
2538
+ }, ...(ngDevMode ? [{ debugName: "dashoffset" }] : /* istanbul ignore next */ []));
2539
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDonut, deps: [], target: i0.ɵɵFactoryTarget.Component });
2540
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxDonut, isStandalone: true, selector: "cngx-donut", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, thickness: { classPropertyName: "thickness", publicName: "thickness", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "meter" }, properties: { "attr.aria-valuenow": "value()", "attr.aria-valuemin": "0", "attr.aria-valuemax": "max()", "attr.aria-label": "ariaLabel()" }, classAttribute: "cngx-donut" }, exportAs: ["cngxDonut"], ngImport: i0, template: `
2541
+ @switch (activeView()) {
2542
+ @case ('skeleton') {
2543
+ <span
2544
+ class="cngx-preset-skeleton cngx-donut__skeleton"
2545
+ [style.width.px]="size()"
2546
+ [style.height.px]="size()"
2547
+ [attr.aria-busy]="true"
2548
+ [attr.aria-label]="i18n.loading()"
2549
+ ></span>
2550
+ }
2551
+ @case ('empty') {
2552
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2553
+ }
2554
+ @case ('error') {
2555
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2556
+ }
2557
+ @case ('none') {}
2558
+ @default {
2559
+ <svg
2560
+ [attr.viewBox]="'0 0 ' + size() + ' ' + size()"
2561
+ [attr.width]="size()"
2562
+ [attr.height]="size()"
2563
+ aria-hidden="true"
2564
+ >
2565
+ <svg:circle
2566
+ class="cngx-donut__track"
2567
+ [attr.cx]="center()"
2568
+ [attr.cy]="center()"
2569
+ [attr.r]="radius()"
2570
+ [attr.stroke-width]="thickness()"
2571
+ fill="none"
2572
+ />
2573
+ <svg:circle
2574
+ class="cngx-donut__fill"
2575
+ [attr.cx]="center()"
2576
+ [attr.cy]="center()"
2577
+ [attr.r]="radius()"
2578
+ [attr.stroke-width]="thickness()"
2579
+ [attr.stroke-dasharray]="dasharray()"
2580
+ [attr.stroke-dashoffset]="dashoffset()"
2581
+ [attr.transform]="'rotate(-90 ' + center() + ' ' + center() + ')'"
2582
+ fill="none"
2583
+ stroke-linecap="round"
2584
+ />
2585
+ </svg>
2586
+ @if (label(); as l) {
2587
+ <span class="cngx-donut__label">{{ l }}</span>
2588
+ }
2589
+ }
2590
+ }
2591
+ `, isInline: true, styles: ["cngx-donut{display:inline-block;position:relative;line-height:0;--cngx-donut-color: var(--cngx-chart-primary, currentColor)}cngx-donut .cngx-donut__track{stroke:var(--cngx-donut-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)))}cngx-donut .cngx-donut__fill{stroke:var(--cngx-donut-color);transition:stroke-dashoffset var(--cngx-donut-transition, .32s) ease-out}cngx-donut .cngx-donut__label{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:var(--cngx-donut-label-font-size, .875rem);line-height:1;color:var(--cngx-chart-text-color, currentColor)}cngx-donut .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:50%}cngx-donut .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-donut .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2592
+ }
2593
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDonut, decorators: [{
2594
+ type: Component,
2595
+ args: [{ selector: 'cngx-donut', exportAs: 'cngxDonut', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2596
+ role: 'meter',
2597
+ '[attr.aria-valuenow]': 'value()',
2598
+ '[attr.aria-valuemin]': '0',
2599
+ '[attr.aria-valuemax]': 'max()',
2600
+ '[attr.aria-label]': 'ariaLabel()',
2601
+ class: 'cngx-donut',
2602
+ }, template: `
2603
+ @switch (activeView()) {
2604
+ @case ('skeleton') {
2605
+ <span
2606
+ class="cngx-preset-skeleton cngx-donut__skeleton"
2607
+ [style.width.px]="size()"
2608
+ [style.height.px]="size()"
2609
+ [attr.aria-busy]="true"
2610
+ [attr.aria-label]="i18n.loading()"
2611
+ ></span>
2612
+ }
2613
+ @case ('empty') {
2614
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2615
+ }
2616
+ @case ('error') {
2617
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2618
+ }
2619
+ @case ('none') {}
2620
+ @default {
2621
+ <svg
2622
+ [attr.viewBox]="'0 0 ' + size() + ' ' + size()"
2623
+ [attr.width]="size()"
2624
+ [attr.height]="size()"
2625
+ aria-hidden="true"
2626
+ >
2627
+ <svg:circle
2628
+ class="cngx-donut__track"
2629
+ [attr.cx]="center()"
2630
+ [attr.cy]="center()"
2631
+ [attr.r]="radius()"
2632
+ [attr.stroke-width]="thickness()"
2633
+ fill="none"
2634
+ />
2635
+ <svg:circle
2636
+ class="cngx-donut__fill"
2637
+ [attr.cx]="center()"
2638
+ [attr.cy]="center()"
2639
+ [attr.r]="radius()"
2640
+ [attr.stroke-width]="thickness()"
2641
+ [attr.stroke-dasharray]="dasharray()"
2642
+ [attr.stroke-dashoffset]="dashoffset()"
2643
+ [attr.transform]="'rotate(-90 ' + center() + ' ' + center() + ')'"
2644
+ fill="none"
2645
+ stroke-linecap="round"
2646
+ />
2647
+ </svg>
2648
+ @if (label(); as l) {
2649
+ <span class="cngx-donut__label">{{ l }}</span>
2650
+ }
2651
+ }
2652
+ }
2653
+ `, styles: ["cngx-donut{display:inline-block;position:relative;line-height:0;--cngx-donut-color: var(--cngx-chart-primary, currentColor)}cngx-donut .cngx-donut__track{stroke:var(--cngx-donut-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)))}cngx-donut .cngx-donut__fill{stroke:var(--cngx-donut-color);transition:stroke-dashoffset var(--cngx-donut-transition, .32s) ease-out}cngx-donut .cngx-donut__label{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:var(--cngx-donut-label-font-size, .875rem);line-height:1;color:var(--cngx-chart-text-color, currentColor)}cngx-donut .cngx-preset-skeleton{display:inline-block;background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:50%}cngx-donut .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-donut .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2654
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], thickness: [{ type: i0.Input, args: [{ isSignal: true, alias: "thickness", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2655
+
2656
+ /**
2657
+ * Bullet chart — Stephen Few's compact KPI visualisation. Three
2658
+ * stacked layers: background `[ranges]` (qualitative bands), an
2659
+ * `[actual]` filled bar, and a `[target]` vertical marker. Pure DOM,
2660
+ * no SVG. Host carries `role="meter"`.
2661
+ */
2662
+ class CngxBullet {
2663
+ actual = input.required(...(ngDevMode ? [{ debugName: "actual" }] : /* istanbul ignore next */ []));
2664
+ target = input(null, ...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
2665
+ max = input(null, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
2666
+ ranges = input([], ...(ngDevMode ? [{ debugName: "ranges" }] : /* istanbul ignore next */ []));
2667
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2668
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2669
+ preset = injectPresetState(() => this.state());
2670
+ i18n = this.preset.i18n;
2671
+ activeView = this.preset.activeView;
2672
+ maxValue = computed(() => {
2673
+ const explicit = this.max();
2674
+ if (explicit !== null && explicit > 0) {
2675
+ return explicit;
2676
+ }
2677
+ const ranges = this.ranges();
2678
+ let m = Math.max(this.actual(), this.target() ?? 0);
2679
+ for (const r of ranges) {
2680
+ if (r.to > m) {
2681
+ m = r.to;
2682
+ }
2683
+ }
2684
+ return m > 0 ? m : 1;
2685
+ }, ...(ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []));
2686
+ actualPercent = computed(() => pct(this.actual(), this.maxValue()), ...(ngDevMode ? [{ debugName: "actualPercent" }] : /* istanbul ignore next */ []));
2687
+ targetPercent = computed(() => {
2688
+ const t = this.target();
2689
+ if (t === null) {
2690
+ return 0;
2691
+ }
2692
+ return pct(t, this.maxValue());
2693
+ }, ...(ngDevMode ? [{ debugName: "targetPercent" }] : /* istanbul ignore next */ []));
2694
+ rangeRenderings = computed(() => {
2695
+ const m = this.maxValue();
2696
+ return this.ranges().map((r, i) => {
2697
+ const lo = Math.min(r.from, r.to);
2698
+ const hi = Math.max(r.from, r.to);
2699
+ return {
2700
+ key: `${i}-${r.label ?? ''}`,
2701
+ left: pct(lo, m),
2702
+ width: pct(hi - lo, m),
2703
+ color: r.color ?? null,
2704
+ };
2705
+ });
2706
+ }, ...(ngDevMode ? [{ debugName: "rangeRenderings" }] : /* istanbul ignore next */ []));
2707
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBullet, deps: [], target: i0.ɵɵFactoryTarget.Component });
2708
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBullet, isStandalone: true, selector: "cngx-bullet", inputs: { actual: { classPropertyName: "actual", publicName: "actual", isSignal: true, isRequired: true, transformFunction: null }, target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, ranges: { classPropertyName: "ranges", publicName: "ranges", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "meter" }, properties: { "attr.aria-valuenow": "actual()", "attr.aria-valuemin": "0", "attr.aria-valuemax": "maxValue()", "attr.aria-label": "ariaLabel()" }, classAttribute: "cngx-bullet" }, exportAs: ["cngxBullet"], ngImport: i0, template: `
2709
+ @switch (activeView()) {
2710
+ @case ('skeleton') {
2711
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2712
+ }
2713
+ @case ('empty') {
2714
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2715
+ }
2716
+ @case ('error') {
2717
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2718
+ }
2719
+ @case ('none') {}
2720
+ @default {
2721
+ <div class="cngx-bullet__track">
2722
+ @for (r of rangeRenderings(); track r.key) {
2723
+ <div
2724
+ class="cngx-bullet__range"
2725
+ [style.left.%]="r.left"
2726
+ [style.width.%]="r.width"
2727
+ [style.background]="r.color"
2728
+ [attr.aria-hidden]="true"
2729
+ ></div>
2730
+ }
2731
+ <div
2732
+ class="cngx-bullet__actual"
2733
+ [style.width.%]="actualPercent()"
2734
+ [attr.aria-hidden]="true"
2735
+ ></div>
2736
+ <div
2737
+ class="cngx-bullet__target"
2738
+ [style.left.%]="targetPercent()"
2739
+ [attr.aria-hidden]="true"
2740
+ ></div>
2741
+ </div>
2742
+ }
2743
+ }
2744
+ `, isInline: true, styles: ["cngx-bullet{display:block;width:var(--cngx-bullet-width, 200px);--cngx-bullet-actual-color: var(--cngx-chart-primary, currentColor);--cngx-bullet-target-color: var(--cngx-chart-text-color, currentColor)}cngx-bullet .cngx-bullet__track{position:relative;height:var(--cngx-bullet-height, 16px);background:var(--cngx-bullet-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .06)));border-radius:var(--cngx-bullet-radius, 2px);overflow:hidden}cngx-bullet .cngx-bullet__range{position:absolute;top:0;bottom:0;opacity:var(--cngx-bullet-range-opacity, .35)}cngx-bullet .cngx-bullet__actual{position:absolute;top:25%;bottom:25%;left:0;background:var(--cngx-bullet-actual-color);border-radius:var(--cngx-bullet-actual-radius, 1px);transition:width var(--cngx-bullet-transition, .24s) ease-out}cngx-bullet .cngx-bullet__target{position:absolute;top:10%;bottom:10%;width:2px;margin-left:-1px;background:var(--cngx-bullet-target-color);transition:left var(--cngx-bullet-transition, .24s) ease-out}cngx-bullet .cngx-preset-skeleton{display:block;height:var(--cngx-bullet-height, 16px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-bullet-radius, 2px)}cngx-bullet .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-bullet .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2745
+ }
2746
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBullet, decorators: [{
2747
+ type: Component,
2748
+ args: [{ selector: 'cngx-bullet', exportAs: 'cngxBullet', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2749
+ role: 'meter',
2750
+ '[attr.aria-valuenow]': 'actual()',
2751
+ '[attr.aria-valuemin]': '0',
2752
+ '[attr.aria-valuemax]': 'maxValue()',
2753
+ '[attr.aria-label]': 'ariaLabel()',
2754
+ class: 'cngx-bullet',
2755
+ }, template: `
2756
+ @switch (activeView()) {
2757
+ @case ('skeleton') {
2758
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2759
+ }
2760
+ @case ('empty') {
2761
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2762
+ }
2763
+ @case ('error') {
2764
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2765
+ }
2766
+ @case ('none') {}
2767
+ @default {
2768
+ <div class="cngx-bullet__track">
2769
+ @for (r of rangeRenderings(); track r.key) {
2770
+ <div
2771
+ class="cngx-bullet__range"
2772
+ [style.left.%]="r.left"
2773
+ [style.width.%]="r.width"
2774
+ [style.background]="r.color"
2775
+ [attr.aria-hidden]="true"
2776
+ ></div>
2777
+ }
2778
+ <div
2779
+ class="cngx-bullet__actual"
2780
+ [style.width.%]="actualPercent()"
2781
+ [attr.aria-hidden]="true"
2782
+ ></div>
2783
+ <div
2784
+ class="cngx-bullet__target"
2785
+ [style.left.%]="targetPercent()"
2786
+ [attr.aria-hidden]="true"
2787
+ ></div>
2788
+ </div>
2789
+ }
2790
+ }
2791
+ `, styles: ["cngx-bullet{display:block;width:var(--cngx-bullet-width, 200px);--cngx-bullet-actual-color: var(--cngx-chart-primary, currentColor);--cngx-bullet-target-color: var(--cngx-chart-text-color, currentColor)}cngx-bullet .cngx-bullet__track{position:relative;height:var(--cngx-bullet-height, 16px);background:var(--cngx-bullet-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .06)));border-radius:var(--cngx-bullet-radius, 2px);overflow:hidden}cngx-bullet .cngx-bullet__range{position:absolute;top:0;bottom:0;opacity:var(--cngx-bullet-range-opacity, .35)}cngx-bullet .cngx-bullet__actual{position:absolute;top:25%;bottom:25%;left:0;background:var(--cngx-bullet-actual-color);border-radius:var(--cngx-bullet-actual-radius, 1px);transition:width var(--cngx-bullet-transition, .24s) ease-out}cngx-bullet .cngx-bullet__target{position:absolute;top:10%;bottom:10%;width:2px;margin-left:-1px;background:var(--cngx-bullet-target-color);transition:left var(--cngx-bullet-transition, .24s) ease-out}cngx-bullet .cngx-preset-skeleton{display:block;height:var(--cngx-bullet-height, 16px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-bullet-radius, 2px)}cngx-bullet .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-bullet .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2792
+ }], propDecorators: { actual: [{ type: i0.Input, args: [{ isSignal: true, alias: "actual", required: true }] }], target: [{ type: i0.Input, args: [{ isSignal: true, alias: "target", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], ranges: [{ type: i0.Input, args: [{ isSignal: true, alias: "ranges", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2793
+ function pct(v, max) {
2794
+ if (max <= 0) {
2795
+ return 0;
2796
+ }
2797
+ const ratio = (v / max) * 100;
2798
+ if (ratio < 0) {
2799
+ return 0;
2800
+ }
2801
+ if (ratio > 100) {
2802
+ return 100;
2803
+ }
2804
+ return ratio;
2805
+ }
2806
+
2807
+ /**
2808
+ * Single-bar stacked composition — visualises proportional shares of
2809
+ * a fixed total. Pure DOM, no SVG. Host carries `role="img"` because
2810
+ * a stacked bar communicates a multi-segment ratio, not a single
2811
+ * bounded reading; the SR description enumerates segments via the
2812
+ * auto-generated `aria-label` (or the `[ariaLabel]` override).
2813
+ */
2814
+ class CngxStackedBar {
2815
+ segments = input.required(...(ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []));
2816
+ total = input(null, ...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
2817
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2818
+ ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
2819
+ preset = injectPresetState(() => this.state());
2820
+ i18n = this.preset.i18n;
2821
+ activeView = this.preset.activeView;
2822
+ resolvedTotal = computed(() => {
2823
+ const explicit = this.total();
2824
+ if (explicit !== null && explicit > 0) {
2825
+ return explicit;
2826
+ }
2827
+ let sum = 0;
2828
+ for (const s of this.segments()) {
2829
+ sum += s.value;
2830
+ }
2831
+ return sum > 0 ? sum : 1;
2832
+ }, ...(ngDevMode ? [{ debugName: "resolvedTotal" }] : /* istanbul ignore next */ []));
2833
+ segmentRenderings = computed(() => {
2834
+ const total = this.resolvedTotal();
2835
+ let runningLeft = 0;
2836
+ return this.segments().map((s, i) => {
2837
+ const width = (s.value / total) * 100;
2838
+ const left = runningLeft;
2839
+ runningLeft += width;
2840
+ return {
2841
+ key: `${i}-${s.label}`,
2842
+ left,
2843
+ width,
2844
+ color: s.color ?? null,
2845
+ label: s.label,
2846
+ value: s.value,
2847
+ };
2848
+ });
2849
+ }, ...(ngDevMode ? [{ debugName: "segmentRenderings" }] : /* istanbul ignore next */ []));
2850
+ effectiveAriaLabel = computed(() => {
2851
+ const explicit = this.ariaLabel();
2852
+ if (explicit !== null && explicit !== '') {
2853
+ return explicit;
2854
+ }
2855
+ const segments = this.segments();
2856
+ if (segments.length === 0) {
2857
+ return 'Empty stacked bar';
2858
+ }
2859
+ const total = this.resolvedTotal();
2860
+ const parts = segments.map((s) => `${s.label}: ${s.value}`);
2861
+ return `Total ${total}. ${parts.join(', ')}.`;
2862
+ }, ...(ngDevMode ? [{ debugName: "effectiveAriaLabel" }] : /* istanbul ignore next */ []));
2863
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStackedBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
2864
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxStackedBar, isStandalone: true, selector: "cngx-stacked-bar", inputs: { segments: { classPropertyName: "segments", publicName: "segments", isSignal: true, isRequired: true, transformFunction: null }, total: { classPropertyName: "total", publicName: "total", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.aria-label": "effectiveAriaLabel()" }, classAttribute: "cngx-stacked-bar" }, exportAs: ["cngxStackedBar"], ngImport: i0, template: `
2865
+ @switch (activeView()) {
2866
+ @case ('skeleton') {
2867
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2868
+ }
2869
+ @case ('empty') {
2870
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2871
+ }
2872
+ @case ('error') {
2873
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2874
+ }
2875
+ @case ('none') {}
2876
+ @default {
2877
+ <div class="cngx-stacked-bar__track">
2878
+ @for (s of segmentRenderings(); track s.key) {
2879
+ <div
2880
+ class="cngx-stacked-bar__segment"
2881
+ [style.left.%]="s.left"
2882
+ [style.width.%]="s.width"
2883
+ [style.background]="s.color"
2884
+ [attr.title]="s.label + ': ' + s.value"
2885
+ [attr.aria-hidden]="true"
2886
+ ></div>
2887
+ }
2888
+ </div>
2889
+ }
2890
+ }
2891
+ `, isInline: true, styles: ["cngx-stacked-bar{display:block;width:var(--cngx-stacked-bar-width, 200px)}cngx-stacked-bar .cngx-stacked-bar__track{position:relative;height:var(--cngx-stacked-bar-height, 12px);background:var(--cngx-stacked-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .05)));border-radius:var(--cngx-stacked-bar-radius, 6px);overflow:hidden}cngx-stacked-bar .cngx-stacked-bar__segment{position:absolute;top:0;bottom:0;background:var(--cngx-stacked-bar-segment-color, var(--cngx-chart-primary, currentColor));transition:width var(--cngx-stacked-bar-transition, .24s) ease-out,left var(--cngx-stacked-bar-transition, .24s) ease-out}cngx-stacked-bar .cngx-preset-skeleton{display:block;height:var(--cngx-stacked-bar-height, 12px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-stacked-bar-radius, 6px)}cngx-stacked-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-stacked-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2892
+ }
2893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStackedBar, decorators: [{
2894
+ type: Component,
2895
+ args: [{ selector: 'cngx-stacked-bar', exportAs: 'cngxStackedBar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2896
+ role: 'img',
2897
+ '[attr.aria-label]': 'effectiveAriaLabel()',
2898
+ class: 'cngx-stacked-bar',
2899
+ }, template: `
2900
+ @switch (activeView()) {
2901
+ @case ('skeleton') {
2902
+ <span class="cngx-preset-skeleton" [attr.aria-busy]="true" [attr.aria-label]="i18n.loading()"></span>
2903
+ }
2904
+ @case ('empty') {
2905
+ <span class="cngx-preset-fallback">{{ i18n.empty() }}</span>
2906
+ }
2907
+ @case ('error') {
2908
+ <span class="cngx-preset-fallback cngx-preset-fallback--error">{{ i18n.error() }}</span>
2909
+ }
2910
+ @case ('none') {}
2911
+ @default {
2912
+ <div class="cngx-stacked-bar__track">
2913
+ @for (s of segmentRenderings(); track s.key) {
2914
+ <div
2915
+ class="cngx-stacked-bar__segment"
2916
+ [style.left.%]="s.left"
2917
+ [style.width.%]="s.width"
2918
+ [style.background]="s.color"
2919
+ [attr.title]="s.label + ': ' + s.value"
2920
+ [attr.aria-hidden]="true"
2921
+ ></div>
2922
+ }
2923
+ </div>
2924
+ }
2925
+ }
2926
+ `, styles: ["cngx-stacked-bar{display:block;width:var(--cngx-stacked-bar-width, 200px)}cngx-stacked-bar .cngx-stacked-bar__track{position:relative;height:var(--cngx-stacked-bar-height, 12px);background:var(--cngx-stacked-bar-track, var(--cngx-chart-grid-color, rgb(0 0 0 / .05)));border-radius:var(--cngx-stacked-bar-radius, 6px);overflow:hidden}cngx-stacked-bar .cngx-stacked-bar__segment{position:absolute;top:0;bottom:0;background:var(--cngx-stacked-bar-segment-color, var(--cngx-chart-primary, currentColor));transition:width var(--cngx-stacked-bar-transition, .24s) ease-out,left var(--cngx-stacked-bar-transition, .24s) ease-out}cngx-stacked-bar .cngx-preset-skeleton{display:block;height:var(--cngx-stacked-bar-height, 12px);background:var(--cngx-skeleton-bg, var(--cngx-chart-grid-color, rgb(0 0 0 / .08)));border-radius:var(--cngx-stacked-bar-radius, 6px)}cngx-stacked-bar .cngx-preset-fallback{display:inline-block;font-size:var(--cngx-preset-fallback-font-size, .75rem);opacity:var(--cngx-preset-fallback-opacity, .7)}cngx-stacked-bar .cngx-preset-fallback--error{color:var(--cngx-chart-danger, currentColor)}\n"] }]
2927
+ }], propDecorators: { segments: [{ type: i0.Input, args: [{ isSignal: true, alias: "segments", required: true }] }], total: [{ type: i0.Input, args: [{ isSignal: true, alias: "total", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
2928
+
2929
+ /**
2930
+ * @module @cngx/common/chart
2931
+ *
2932
+ * Declarative, Signal-first chart system. Two-level architecture:
2933
+ * composable atoms (`<cngx-chart>` element + `[cngxAxis]` and layer
2934
+ * atoms applied to `<svg:g>` hosts) and preset molecules
2935
+ * (`<cngx-sparkline>`, `<cngx-donut>`, etc.).
2936
+ */
2937
+
2938
+ /**
2939
+ * Generated bundle index. Do not edit.
2940
+ */
2941
+
2942
+ export { CHART_SMALL_BREAKPOINT_PX, CNGX_CHART_CONTEXT, CNGX_CHART_I18N, CngxArea, CngxAxis, CngxBand, CngxBar, CngxBullet, CngxChart, CngxChartEmpty, CngxChartError, CngxChartLegend, CngxChartLoading, CngxDeviationBar, CngxDonut, CngxLine, CngxMiniArea, CngxMiniBar, CngxScatter, CngxSparkline, CngxStackedBar, CngxThreshold, buildCurvePath, createBandScale, createLinearScale, createOrdinalScale, createPathBuilder, createTimeScale, provideChartI18n };
2943
+ //# sourceMappingURL=cngx-common-chart.mjs.map