@alfadocs/ui-kit-debug 1.65.0 → 1.66.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.
- package/dist/_chunks/chart-CwmyCuWe.js +1340 -0
- package/dist/_chunks/chart-CwmyCuWe.js.map +1 -0
- package/dist/_chunks/heatmap-C1TeC7wT.js +3650 -0
- package/dist/_chunks/heatmap-C1TeC7wT.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/use-apex-radial-centre.d.ts +7 -4
- package/dist/components/_shared/use-apex-radial-centre.d.ts.map +1 -1
- package/dist/components/chart/index.js +1 -1
- package/dist/components/heatmap/heatmap-context.d.ts +3 -0
- package/dist/components/heatmap/heatmap-context.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap-disclosure.d.ts +67 -0
- package/dist/components/heatmap/heatmap-disclosure.d.ts.map +1 -0
- package/dist/components/heatmap/heatmap-format.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap-grid.d.ts +1 -1
- package/dist/components/heatmap/heatmap-grid.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap-legend.d.ts +5 -2
- package/dist/components/heatmap/heatmap-legend.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap-model.d.ts +107 -15
- package/dist/components/heatmap/heatmap-model.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap-table-view.d.ts +3 -2
- package/dist/components/heatmap/heatmap-table-view.d.ts.map +1 -1
- package/dist/components/heatmap/heatmap.d.ts +33 -7
- package/dist/components/heatmap/heatmap.d.ts.map +1 -1
- package/dist/components/heatmap/index.d.ts +1 -1
- package/dist/components/heatmap/index.d.ts.map +1 -1
- package/dist/components/heatmap/index.js +1 -1
- package/dist/i18n/locales/ar.d.ts +2 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +2 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +2 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +2 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +2 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +2 -0
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +2 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +2 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +2 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +2 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +2 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +2 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +2 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +2 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +2 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +2 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +2 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +2 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +2 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +2 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +2 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +2 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +2 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +2 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +2 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +2 -0
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +2 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +2 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +2 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +2 -0
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +2 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +2 -0
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +2 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +2 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +2 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +2 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/locales/ar.json +2 -0
- package/dist/locales/de.json +2 -0
- package/dist/locales/el.json +2 -0
- package/dist/locales/en.json +2 -0
- package/dist/locales/es.json +2 -0
- package/dist/locales/fr.json +2 -0
- package/dist/locales/hi.json +2 -0
- package/dist/locales/it.json +2 -0
- package/dist/locales/ja.json +2 -0
- package/dist/locales/nl.json +2 -0
- package/dist/locales/pl.json +2 -0
- package/dist/locales/pt.json +2 -0
- package/dist/locales/ro.json +2 -0
- package/dist/locales/ru.json +2 -0
- package/dist/locales/sq.json +2 -0
- package/dist/locales/sv.json +2 -0
- package/dist/locales/tr.json +2 -0
- package/dist/locales/zh.json +2 -0
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/chart-CIzXxNeM.js +0 -1322
- package/dist/_chunks/chart-CIzXxNeM.js.map +0 -1
- package/dist/_chunks/heatmap-BxRHM8Et.js +0 -2865
- package/dist/_chunks/heatmap-BxRHM8Et.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chart-CIzXxNeM.js","sources":["../../node_modules/lucide-react/dist/esm/icons/chart-area.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-column.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-line.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-pie.mjs","../../node_modules/lucide-react/dist/esm/icons/donut.mjs","../../src/components/_shared/use-apex-chart-semantics.ts","../../src/components/_shared/use-apex-legend-scroll.ts","../../src/components/_shared/use-apex-x-label-spacing.ts","../../src/components/_shared/use-apex-radial-centre.ts","../../src/components/chart/chart.agent.ts","../../src/components/chart/chart.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\n \"path\",\n {\n d: \"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z\",\n key: \"q0gr47\"\n }\n ]\n];\nconst ChartArea = createLucideIcon(\"chart-area\", __iconNode);\n\nexport { __iconNode, ChartArea as default };\n//# sourceMappingURL=chart-area.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\"path\", { d: \"M18 17V9\", key: \"2bz60n\" }],\n [\"path\", { d: \"M13 17V5\", key: \"1frdt8\" }],\n [\"path\", { d: \"M8 17v-3\", key: \"17ska0\" }]\n];\nconst ChartColumn = createLucideIcon(\"chart-column\", __iconNode);\n\nexport { __iconNode, ChartColumn as default };\n//# sourceMappingURL=chart-column.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\"path\", { d: \"m19 9-5 5-4-4-3 3\", key: \"2osh9i\" }]\n];\nconst ChartLine = createLucideIcon(\"chart-line\", __iconNode);\n\nexport { __iconNode, ChartLine as default };\n//# sourceMappingURL=chart-line.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z\",\n key: \"pzmjnu\"\n }\n ],\n [\"path\", { d: \"M21.21 15.89A10 10 0 1 1 8 2.83\", key: \"k2fpak\" }]\n];\nconst ChartPie = createLucideIcon(\"chart-pie\", __iconNode);\n\nexport { __iconNode, ChartPie as default };\n//# sourceMappingURL=chart-pie.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3\",\n key: \"19sr3x\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"3\", key: \"1v7zrd\" }]\n];\nconst Donut = createLucideIcon(\"donut\", __iconNode);\n\nexport { __iconNode, Donut as default };\n//# sourceMappingURL=donut.mjs.map\n","import { useEffect } from 'react';\n\n// ApexCharts puts its plot, hover aids and its legend/toolbar buttons in one\n// container. Hide every layer but the controls from assistive technology, so\n// no button sits in a hidden subtree, and the host's data table speaks for the plot.\nconst CONTROL_LAYERS = '.apexcharts-legend, .apexcharts-toolbar';\n\nfunction setAttr(el: Element | null, name: string, value: string | null) {\n if (!el || el.getAttribute(name) === value) return;\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * `legendToggles`: whether a legend press hides its series. It does on axis\n * charts and radialBar; on pie and donut it selects the slice instead.\n */\nexport function useApexChartSemantics(\n root: HTMLElement | null,\n legendToggles: boolean,\n): void {\n useEffect(() => {\n if (!root) return undefined;\n\n // Re-run on every mutation: Apex rebuilds the legend on each toggle and\n // update. Only a real change writes, so the observer settles at once.\n const apply = () => {\n root\n .querySelectorAll<HTMLElement>('.apexcharts-canvas')\n .forEach((canvas) => {\n Array.from(canvas.children).forEach((layer) => {\n if (!layer.matches(CONTROL_LAYERS)) {\n setAttr(layer, 'aria-hidden', 'true');\n }\n });\n });\n // Apex hides the closed export menu with opacity only. `inert`, not\n // aria-hidden, so nothing rewrites its items' tabindex while it is shut.\n root\n .querySelectorAll<HTMLElement>('.apexcharts-toolbar')\n .forEach((toolbar) => {\n const open =\n toolbar\n .querySelector('.apexcharts-menu-icon')\n ?.getAttribute('aria-expanded') === 'true';\n setAttr(\n toolbar.querySelector('.apexcharts-menu'),\n 'inert',\n open ? null : '',\n );\n });\n root\n .querySelectorAll<HTMLElement>(\n '.apexcharts-legend-series[role=\"button\"]',\n )\n .forEach((item) => {\n // Apex's label is fixed English (\"X, visible. Press Enter…\"); without\n // it the visible series name is the name. `aria-pressed` then has to\n // mean \"shown\": Apex sets it for \"hidden\" and lets the label explain.\n setAttr(item, 'aria-label', null);\n const shown =\n item.getAttribute('data:collapsed') === 'true' ? 'false' : 'true';\n setAttr(item, 'aria-pressed', legendToggles ? shown : null);\n });\n };\n\n // A toggle rebuilds the legend. Apex refocuses the item after a key press\n // only, so do the same after a click (a screen reader's browse-mode press).\n let frame = 0;\n const onClick = (event: MouseEvent) => {\n const item =\n event.target instanceof Element\n ? event.target.closest('.apexcharts-legend-series')\n : null;\n const rel = item?.getAttribute('rel');\n if (!rel) return;\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n const active = document.activeElement;\n if (active && active !== document.body) return;\n root\n .querySelector<HTMLElement>(\n `.apexcharts-legend-series[rel=\"${CSS.escape(rel)}\"]`,\n )\n ?.focus();\n });\n };\n\n apply();\n const observer = new MutationObserver(apply);\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\n 'aria-hidden',\n 'aria-label',\n 'aria-pressed',\n 'aria-expanded',\n ],\n });\n root.addEventListener('click', onClick);\n return () => {\n observer.disconnect();\n root.removeEventListener('click', onClick);\n cancelAnimationFrame(frame);\n };\n }, [root, legendToggles]);\n}\n","import { useEffect } from 'react';\n\nconst ITEM = '.apexcharts-legend-series[role=\"button\"]';\nconst TEXT = '.apexcharts-legend-text';\n/** Read by apexcharts-theme.css: every item's size while the row overflows. */\nconst ITEM_SIZE = '--chart-legend-item-size';\n/** On an item that carries a value: the value's width, added to its floor. */\nconst VALUE_SIZE = '--chart-legend-value-size';\n/** A value that never shrinks, and the name beside it (chart.tsx). */\nconst VALUE = '.chart-legend-value';\nconst NAME = '.chart-legend-name';\n/**\n * The longest a tap's click can trail its pointerup: the double-tap wait,\n * 300ms in Chromium and 350ms in WebKit. A mouse or pen sends its click in\n * the same task as the pointerup.\n */\nconst TAP_CLICK_MS = 350;\n\nfunction setFlag(el: HTMLElement, name: string, on: boolean) {\n if (on && el.getAttribute(name) !== 'true') el.setAttribute(name, 'true');\n else if (!on && el.hasAttribute(name)) el.removeAttribute(name);\n}\n\nconst px = (style: CSSStyleDeclaration, property: string) =>\n Number.parseFloat(style.getPropertyValue(property)) || 0;\n\n/**\n * For a legend kept to one row (apexcharts-theme.css): flags the edges that\n * hide items (`data-fade-start` / `-end`) for the TabBar-style fade; once the\n * row overflows, sizes the items so it ends halfway through one; names a cut\n * label in a `title` as the pointer reaches it; moves the row (never the\n * page) to bring a focused item fully into view, unless a pointer press\n * focused it; and keeps the row where it was through ApexCharts' rebuilds.\n * Off when not `enabled`.\n */\nexport function useApexLegendScroll(\n root: HTMLElement | null,\n enabled: boolean,\n): void {\n useEffect(() => {\n if (!root || !enabled) return undefined;\n let legend: HTMLElement | null = null;\n let frame = 0;\n // Where the row was last seen, so a rebuild or a press keeps it there.\n let fromStartSeen = 0;\n\n // |scrollLeft| is the distance from the start in LTR and in RTL alike.\n const measure = () => {\n if (!legend) return;\n const fromStart = Math.abs(legend.scrollLeft);\n const maxScroll = legend.scrollWidth - legend.clientWidth;\n fromStartSeen = fromStart;\n setFlag(legend, 'data-fade-start', fromStart > 1);\n setFlag(legend, 'data-fade-end', maxScroll - fromStart > 1);\n };\n\n const restore = () => {\n if (!legend) return;\n const sign = getComputedStyle(legend).direction === 'rtl' ? -1 : 1;\n if (Math.abs(Math.abs(legend.scrollLeft) - fromStartSeen) > 1) {\n legend.scrollLeft = sign * fromStartSeen;\n }\n };\n\n // A row that overflows even with every item at its floor could end in\n // the gap between two items, which looks complete where there is no fade.\n // Size every item so the row ends halfway through one instead. Everything\n // laid out is read first: after the size is cleared only styles are read,\n // so no in-between layout can pull the row's scroll back.\n const fit = () => {\n if (!legend) return;\n const view = legend.clientWidth;\n const items = Array.from(\n legend.querySelectorAll<HTMLElement>(`:scope > ${ITEM}`),\n ).filter((item) => item.getClientRects().length > 0);\n // A value never shrinks: its item is never narrower than the value\n // plus the item's own chrome, its dot and the text's inline edges.\n const inline = (style: CSSStyleDeclaration, box: string, part = '') =>\n px(style, `${box}-inline-start${part}`) +\n px(style, `${box}-inline-end${part}`);\n const values = items.map((item) => {\n const value = item.querySelector<HTMLElement>(VALUE);\n if (!value) return 0;\n const own = getComputedStyle(item);\n let chrome = inline(own, 'padding') + inline(own, 'border', '-width');\n for (const child of Array.from(item.children)) {\n const style = getComputedStyle(child);\n chrome +=\n inline(style, 'margin') +\n (child.contains(value)\n ? inline(style, 'padding') + inline(style, 'border', '-width')\n : child.getBoundingClientRect().width);\n }\n return chrome + value.getBoundingClientRect().width;\n });\n const box = getComputedStyle(legend);\n const start = px(box, 'padding-inline-start');\n const end = px(box, 'padding-inline-end');\n const before = legend.style.getPropertyValue(ITEM_SIZE);\n legend.style.removeProperty(ITEM_SIZE);\n if (items.length === 0) return;\n items.forEach((item, i) => {\n if (values[i] > 0) {\n // Inline style: permitted per 23-constraints §Runtime-computed\n // dimensions (custom property setter from a measured width).\n item.style.setProperty(VALUE_SIZE, `${Math.ceil(values[i])}px`);\n } else {\n item.style.removeProperty(VALUE_SIZE);\n }\n });\n const floors = items.map((item) =>\n px(getComputedStyle(item), 'min-inline-size'),\n );\n const floor = Math.max(...floors);\n const item = getComputedStyle(items[0]);\n const gap =\n px(item, 'margin-inline-start') + px(item, 'margin-inline-end');\n const needed = floors.reduce((sum, each) => sum + each + gap, 0);\n if (floor <= 0 || start + end + needed <= view) {\n return;\n }\n // The most whole items before one that sits across the edge.\n const whole = Math.floor(\n (view - start - gap / 2 - floor / 2) / (floor + gap),\n );\n if (whole < 1) return;\n const size = (view - start - gap / 2 - whole * gap) / (whole + 0.5);\n legend.style.setProperty(\n ITEM_SIZE,\n before && Math.abs(Number.parseFloat(before) - size) < 0.5\n ? before\n : `${Math.floor(size * 100) / 100}px`,\n );\n };\n\n const sized = new ResizeObserver(() => {\n fit();\n measure();\n });\n // A web font that arrives after the draw changes what a value needs.\n const { fonts } = root.ownerDocument;\n const refit = () => {\n fit();\n measure();\n };\n\n // ApexCharts rebuilds the legend on every update, a series toggle too:\n // follow the current one, kept where the row was.\n const bind = () => {\n const current = root.querySelector<HTMLElement>('.apexcharts-legend');\n const rebuilt = current !== legend;\n if (rebuilt) {\n if (legend) {\n legend.removeEventListener('scroll', measure);\n sized.unobserve(legend);\n }\n legend = current;\n if (legend) {\n legend.addEventListener('scroll', measure, { passive: true });\n sized.observe(legend);\n }\n }\n fit();\n if (rebuilt) restore();\n measure();\n };\n\n // A pointer press on the row lasts through its click until a frame after\n // the kit refocuses the item it toggled, which it does one frame after\n // the click (use-apex-chart-semantics). A press that ends without a\n // click ends once one can no longer come: the next task for a mouse or\n // pen, TAP_CLICK_MS for a touch. One that ends off the row, a cancelled\n // one, a key press or the window losing focus ends it at once.\n let pressed = false;\n let pressFrame = 0;\n let pressTimer: ReturnType<typeof setTimeout> | undefined;\n const onRow = (event: Event) =>\n legend !== null &&\n event.target instanceof Node &&\n legend.contains(event.target);\n const unpress = () => {\n cancelAnimationFrame(pressFrame);\n clearTimeout(pressTimer);\n pressed = false;\n };\n const press = (event: PointerEvent) => {\n unpress();\n pressed = onRow(event);\n };\n const lift = (event: PointerEvent) => {\n if (!pressed) return;\n if (!onRow(event)) {\n unpress();\n return;\n }\n clearTimeout(pressTimer);\n pressTimer = setTimeout(\n unpress,\n event.pointerType === 'touch' ? TAP_CLICK_MS : 0,\n );\n };\n const clicked = () => {\n if (!pressed) return;\n clearTimeout(pressTimer);\n cancelAnimationFrame(pressFrame);\n pressFrame = requestAnimationFrame(() => {\n pressFrame = requestAnimationFrame(() => {\n pressed = false;\n });\n });\n };\n\n // Moves the row, never the page, until the item sits inside its scroll\n // padding: clear of the fade, ring included.\n const bringIn = (item: HTMLElement) => {\n if (!legend) return;\n const row = legend.getBoundingClientRect();\n const box = item.getBoundingClientRect();\n const style = getComputedStyle(legend);\n const left = row.left + px(style, 'scroll-padding-left');\n const right = row.right - px(style, 'scroll-padding-right');\n if (box.left < left || box.width > right - left) {\n legend.scrollLeft -= left - box.left;\n } else if (box.right > right) {\n legend.scrollLeft += box.right - right;\n }\n };\n\n // The browser's own focus scroll would leave a half-hidden item under the\n // fade, so focus brings the item fully into view. Focus from a press, or\n // the refocus after the toggle it made, leaves the row where it was: a\n // click lands where it began. A keyboard-focused item shows its whole\n // name, so the overflow may change.\n const reveal = (event: FocusEvent) => {\n const { target } = event;\n if (!legend || !(target instanceof HTMLElement)) return;\n if (!legend.contains(target)) return;\n if (pressed && !target.matches(':focus-visible')) restore();\n else bringIn(target);\n measure();\n };\n const settle = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(measure);\n };\n\n // A cut name is the label's `title`, so the pointer can read it whole.\n // The text, not the button: a title there would repeat the button's name.\n const name = (event: MouseEvent) => {\n const { target } = event;\n const text =\n target instanceof Element\n ? target.closest(ITEM)?.querySelector<HTMLElement>(TEXT)\n : null;\n if (!text || !legend?.contains(text)) return;\n // A ring's name is cut on its own, beside a value that never is.\n const cut = text.querySelector<HTMLElement>(NAME) ?? text;\n if (cut.scrollWidth > cut.clientWidth) {\n const full = text.textContent ?? '';\n if (text.title !== full) text.title = full;\n } else if (text.hasAttribute('title')) {\n text.removeAttribute('title');\n }\n };\n\n // Only a legend rebuild re-binds, not ApexCharts' tooltip and plot redraws.\n const inLegend = (node: Node) =>\n node instanceof Element &&\n (node.closest('.apexcharts-legend') !== null ||\n node.querySelector('.apexcharts-legend') !== null);\n const rebuilds = new MutationObserver((records) => {\n const touched = records.some((record) =>\n [record.target, ...record.addedNodes, ...record.removedNodes].some(\n inLegend,\n ),\n );\n if (touched) bind();\n });\n\n // On the window: a press can end outside the chart.\n const view = root.ownerDocument.defaultView ?? window;\n\n bind();\n rebuilds.observe(root, { childList: true, subtree: true });\n view.addEventListener('pointerdown', press, true);\n view.addEventListener('pointerup', lift, true);\n view.addEventListener('pointercancel', unpress, true);\n view.addEventListener('click', clicked, true);\n view.addEventListener('blur', unpress);\n root.addEventListener('keydown', unpress);\n root.addEventListener('focusin', reveal);\n root.addEventListener('focusout', settle);\n root.addEventListener('mouseover', name);\n fonts?.addEventListener('loadingdone', refit);\n return () => {\n rebuilds.disconnect();\n sized.disconnect();\n cancelAnimationFrame(frame);\n unpress();\n view.removeEventListener('pointerdown', press, true);\n view.removeEventListener('pointerup', lift, true);\n view.removeEventListener('pointercancel', unpress, true);\n view.removeEventListener('click', clicked, true);\n view.removeEventListener('blur', unpress);\n root.removeEventListener('keydown', unpress);\n root.removeEventListener('focusin', reveal);\n root.removeEventListener('focusout', settle);\n root.removeEventListener('mouseover', name);\n fonts?.removeEventListener('loadingdone', refit);\n root\n .querySelectorAll<HTMLElement>(`${TEXT}[title]`)\n .forEach((text) => text.removeAttribute('title'));\n if (!legend) return;\n legend.removeEventListener('scroll', measure);\n legend.style.removeProperty(ITEM_SIZE);\n legend\n .querySelectorAll<HTMLElement>(ITEM)\n .forEach((item) => item.style.removeProperty(VALUE_SIZE));\n setFlag(legend, 'data-fade-start', false);\n setFlag(legend, 'data-fade-end', false);\n };\n }, [root, enabled]);\n}\n","import { useEffect } from 'react';\n\nconst LABEL = '.apexcharts-xaxis-texts-g > text.apexcharts-xaxis-label';\n/** The least clear space between two shown x labels, in ems of their font. */\nconst GAP_EM = 0.5;\n\ntype Point = { x: number; y: number };\n\n/** A drawn label's corners in the chart's SVG space, turned or not. */\nfunction cornersOf(label: SVGTextElement): Point[] | null {\n const matrix = label.getCTM();\n if (!matrix) return null;\n const { x, y, width, height } = label.getBBox();\n if (width === 0 && height === 0) return null;\n return [\n [x, y],\n [x + width, y],\n [x + width, y + height],\n [x, y + height],\n ].map(([px, py]) => {\n const point = new DOMPoint(px, py).matrixTransform(matrix);\n return { x: point.x, y: point.y };\n });\n}\n\n/**\n * Whether two labels stand at least `gap` apart: some edge normal of either\n * separates them by that much (the separating axis test on two rectangles).\n */\nfunction apart(a: Point[], b: Point[], gap: number): boolean {\n return [a, b].some((shape) =>\n shape.some((corner, i) => {\n const next = shape[(i + 1) % shape.length];\n const nx = corner.y - next.y;\n const ny = next.x - corner.x;\n const length = Math.hypot(nx, ny);\n if (length === 0) return false;\n const project = (points: Point[]) =>\n points.map((p) => (p.x * nx + p.y * ny) / length);\n const pa = project(a);\n const pb = project(b);\n return (\n Math.min(...pb) - Math.max(...pa) >= gap ||\n Math.min(...pa) - Math.max(...pb) >= gap\n );\n }),\n );\n}\n\n/**\n * ApexCharts' own x-label thinning keeps a label once its centre is the\n * previous label's width away, whatever its own width, so two labels can touch\n * or overlap. Chart has ApexCharts draw every label, and this shows every k-th\n * one instead, for the smallest k at which no two shown labels come within\n * half an em of each other. It measures the drawn labels, turned or not, in\n * either direction, and runs on every redraw before the page paints, and\n * again once a web font has loaded.\n */\nexport function useApexXLabelSpacing(root: HTMLElement | null): void {\n useEffect(() => {\n if (!root) return undefined;\n\n const space = () => {\n const labels = Array.from(\n root.querySelectorAll<SVGTextElement>(LABEL),\n ).filter((label) => (label.textContent ?? '').trim() !== '');\n if (labels.length === 0 || typeof labels[0].getBBox !== 'function') {\n return;\n }\n const shapes = labels.map(cornersOf);\n const gap =\n GAP_EM * (Number.parseFloat(getComputedStyle(labels[0]).fontSize) || 0);\n const fits = (step: number) => {\n for (let i = step; i < labels.length; i += step) {\n const a = shapes[i - step];\n const b = shapes[i];\n if (a && b && !apart(a, b, gap)) return false;\n }\n return true;\n };\n let step = 1;\n while (step < labels.length && !fits(step)) step += 1;\n labels.forEach((label, i) => {\n const shown = i % step === 0;\n if (shown && label.hasAttribute('visibility')) {\n label.removeAttribute('visibility');\n } else if (!shown && label.getAttribute('visibility') !== 'hidden') {\n label.setAttribute('visibility', 'hidden');\n }\n });\n };\n\n // ApexCharts redraws its axes on every update and resize.\n const inXAxis = (node: Node) =>\n node instanceof Element &&\n (node.closest('.apexcharts-xaxis') !== null ||\n node.querySelector('.apexcharts-xaxis') !== null);\n const redraws = new MutationObserver((records) => {\n if (\n records.some((record) =>\n [record.target, ...record.addedNodes].some(inXAxis),\n )\n ) {\n space();\n }\n });\n\n // A web font that arrives after the draw widens the labels in place.\n const { fonts } = root.ownerDocument;\n\n space();\n redraws.observe(root, { childList: true, subtree: true });\n fonts?.addEventListener('loadingdone', space);\n return () => {\n redraws.disconnect();\n fonts?.removeEventListener('loadingdone', space);\n };\n }, [root]);\n}\n","import { useEffect } from 'react';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst GROUP = '.apexcharts-radialbar .apexcharts-datalabels-group';\nconst NAME = '.apexcharts-datalabel-label';\nconst VALUE = '.apexcharts-datalabel-value';\nconst HOLLOW = '.apexcharts-radialbar-hollow';\n/** Read by apexcharts-theme.css: a centre label's size, once lowered. */\nconst SIZE = '--chart-centre-size';\n/** The least either label shrinks to: the kit's label role. */\nconst FLOOR = 'var(--type-label-size)';\n/** How far a name's size steps down at a time, in px. */\nconst STEP_PX = 0.5;\n/** Clear space between the name and the value, in ems of the value. */\nconst GAP_EM = 0.25;\n/** Kept clear inside the hole's edge, in px. */\nconst INSET_PX = 1;\n/** On the name: the name as ApexCharts wrote it, before it was broken. */\nconst SOURCE = 'data-centre-name';\n/** On each line of a broken name. */\nconst LINE = 'data-centre-line';\n\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}]/u;\n/** What a CJK line may not start with, or end with (kinsoku). */\nconst NO_LINE_START = /^[)\\]})】」』〕〉》、。,.・:;!?ー…]/u;\nconst NO_LINE_END = /[([{(【「『〔〈《]$/u;\n\n/** Word breaks for the locale, or the default's when it is malformed. */\nfunction segmenterFor(locale: string): Intl.Segmenter | null {\n if (typeof Intl.Segmenter !== 'function') return null;\n try {\n return new Intl.Segmenter(locale, { granularity: 'word' });\n } catch {\n return new Intl.Segmenter(undefined, { granularity: 'word' });\n }\n}\n\n/** The name whole, then its two-line splits: at a space, or between CJK words. */\nexport function splits(name: string, locale: string): string[][] {\n const options: string[][] = [[name]];\n const segmenter = segmenterFor(locale);\n const parts = segmenter\n ? Array.from(segmenter.segment(name), (part) => part.segment)\n : name.split(/(\\s+)/);\n let at = 0;\n parts.forEach((part, i) => {\n at += part.length;\n const next = parts[i + 1];\n if (next === undefined) return;\n const space = /^\\s+$/.test(part) || /^\\s+$/.test(next);\n const cjk = CJK.test(part.slice(-1)) || CJK.test(next.charAt(0));\n if (!space && !cjk) return;\n const first = name.slice(0, at).trim();\n const second = name.slice(at).trim();\n if (!first || !second) return;\n if (NO_LINE_START.test(second) || NO_LINE_END.test(first)) return;\n // Either side of a space gives the same split.\n if (options.some(([a, b]) => a === first && b === second)) return;\n options.push([first, second]);\n });\n return options;\n}\n\n/**\n * A radialBar's centre labels sit in the ring's hole. ApexCharts draws the\n * series name on one line at a fixed size, so a long name runs across the\n * ring, or out of the drawing. This fits the centre the way a donut or gauge\n * centre label is fitted: the value is the primary figure and always shows,\n * at its own size unless the hole is too small for it alone, and never below\n * the label role; the name fits the chord of the hole at each of its lines,\n * first on one line, then on two, then smaller, down to the label role, and\n * is hidden when it still cannot fit. The hole is measured from what\n * ApexCharts drew, on every redraw and hover, before the page paints, and\n * again once a web font loads or a theme around the chart changes. The name\n * stays the chart's to announce: the summary table carries it.\n */\nexport function useApexRadialCentre(\n root: HTMLElement | null,\n enabled: boolean,\n /** The chart's locale, for where a name may break. */\n locale: string,\n): void {\n useEffect(() => {\n if (!root || !enabled) return undefined;\n let warned = false;\n\n const fit = () => {\n try {\n place();\n } finally {\n // These writes are this pass's own, not a redraw to answer.\n redraws.takeRecords();\n }\n };\n\n const place = () => {\n // A hidden chart measures nothing; it is fitted once it shows.\n if (root.getClientRects().length === 0) return;\n const group = root.querySelector<SVGGElement>(GROUP);\n // Not always the labels' sibling: a hover-out redraws them elsewhere.\n const hollow = root.querySelector<SVGCircleElement>(HOLLOW);\n const value = group?.querySelector<SVGTextElement>(VALUE) ?? null;\n const name = group?.querySelector<SVGTextElement>(NAME) ?? null;\n if (!group || !hollow) return;\n\n // The hole in the labels' own space.\n const fromHole = hollow.getCTM();\n const fromLabels = group.getCTM();\n if (!fromHole || !fromLabels) return;\n const toLabels = fromLabels.inverse().multiply(fromHole);\n const centre = new DOMPoint(\n hollow.cx.baseVal.value,\n hollow.cy.baseVal.value,\n ).matrixTransform(toLabels);\n const radius =\n hollow.r.baseVal.value * Math.hypot(toLabels.a, toLabels.b) - INSET_PX;\n if (radius <= 0) return;\n const { x: cx, y: cy } = centre;\n const inside = (width: number, top: number, bottom: number) => {\n const dy = Math.max(Math.abs(top - cy), Math.abs(bottom - cy));\n return dy < radius && width / 2 <= Math.sqrt(radius ** 2 - dy ** 2);\n };\n\n // The name as ApexCharts wrote it: a hover rewrites it whole.\n const source =\n name && name.querySelector(`tspan[${LINE}]`)\n ? (name.getAttribute(SOURCE) ?? '')\n : (name?.textContent ?? '');\n\n // Sizes from the type roles, and the widths at those sizes. Clearing\n // the runtime size (23-constraints §Runtime-computed dimensions).\n for (const label of [name, value]) {\n label?.style.removeProperty(SIZE);\n label?.removeAttribute('visibility');\n }\n const sizeOf = (label: SVGTextElement) =>\n Number.parseFloat(getComputedStyle(label).fontSize) || 0;\n // Inline style: permitted per 23-constraints §Runtime-computed\n // dimensions (custom property setter, read back to measure the\n // label role's size; the font-size rule lives in apexcharts-theme.css).\n const floorOf = (label: SVGTextElement, size: number) => {\n label.style.setProperty(SIZE, FLOOR);\n const floor = Math.min(sizeOf(label), size);\n label.style.removeProperty(SIZE);\n return floor;\n };\n\n let valueSize = 0;\n let valueWidth = 0;\n let valuePitch = 0;\n if (value && (value.textContent ?? '') !== '') {\n valueSize = sizeOf(value);\n const floor = floorOf(value, valueSize);\n valueWidth = value.getComputedTextLength();\n valuePitch = value.getBBox().height;\n // The value alone, centred, at most at its own size and never\n // below the label role: a hole too small for that is a gauge too\n // small to read (about 110px, 120px accessible, by macOS metrics;\n // the warning asks for 10px more, room for other platforms' text).\n const half = Math.hypot(valueWidth / 2, valuePitch / 2);\n if (half > radius) {\n const scale = Math.max(radius / half, floor / valueSize);\n valueSize *= scale;\n valueWidth *= scale;\n valuePitch *= scale;\n if (\n import.meta.env.DEV &&\n !warned &&\n Math.hypot(valueWidth / 2, valuePitch / 2) > radius + 0.5\n ) {\n warned = true;\n console.warn(\n 'Chart: this radialBar is too small for its centre value to fit its hole at a readable size. Draw a single ring at least 120px across (130px in the accessible themes), and several rings larger.',\n );\n }\n }\n }\n const gap = valueSize > 0 ? GAP_EM * valueSize : 0;\n const gapFor = (lines: string[]) => (lines.length > 0 ? gap : 0);\n // A name line's height per px of its size.\n let pitchPerPx = 0;\n\n let chosen: { lines: string[]; size: number } | null = null;\n let nameStart = 0;\n if (name && source.trim() !== '') {\n nameStart = sizeOf(name);\n const floor = floorOf(name, nameStart);\n\n // Widths at the starting size scale with the size.\n const measure = (text: string) => {\n name.textContent = text;\n return name.getComputedTextLength();\n };\n name.textContent = source;\n pitchPerPx = name.getBBox().height / nameStart;\n const [whole, ...pairs] = splits(source, locale).map((lines) => ({\n lines,\n widths: lines.map(measure),\n }));\n // One line, then every two-line split, the most even first.\n const tries = [\n whole,\n ...pairs.sort(\n (a, b) => Math.max(...a.widths) - Math.max(...b.widths),\n ),\n ];\n const sizes: number[] = [];\n for (let size = nameStart; size > floor + 0.01; size -= STEP_PX) {\n sizes.push(size);\n }\n sizes.push(floor);\n\n for (const size of sizes) {\n const scale = size / nameStart;\n const pitch = pitchPerPx * size;\n const fits = tries.find(({ lines, widths }) => {\n const height = lines.length * pitch + gapFor(lines) + valuePitch;\n const top = cy - height / 2;\n const linesFit = widths.every((width, i) =>\n inside(width * scale, top + i * pitch, top + (i + 1) * pitch),\n );\n const valueTop = top + lines.length * pitch + gapFor(lines);\n return (\n linesFit &&\n (valuePitch === 0 ||\n inside(valueWidth, valueTop, valueTop + valuePitch))\n );\n });\n if (fits) {\n chosen = { lines: fits.lines, size };\n break;\n }\n }\n }\n\n // Lay the centre out as one block: the name's lines, then the value.\n const lines = chosen?.lines ?? [];\n const namePitch = chosen ? pitchPerPx * chosen.size : 0;\n const height = lines.length * namePitch + gapFor(lines) + valuePitch;\n const top = cy - height / 2;\n if (name) {\n name.textContent = '';\n name.setAttribute(SOURCE, source);\n name.setAttribute('dominant-baseline', 'central');\n name.setAttribute('x', String(cx));\n name.setAttribute('y', String(top + namePitch / 2));\n lines.forEach((line, i) => {\n const span = root.ownerDocument.createElementNS(SVG_NS, 'tspan');\n span.setAttribute(LINE, '');\n span.setAttribute('x', String(cx));\n span.setAttribute('y', String(top + (i + 0.5) * namePitch));\n span.textContent = line;\n name.appendChild(span);\n });\n if (!chosen) {\n // Too small a hole for the name: the value alone.\n const span = root.ownerDocument.createElementNS(SVG_NS, 'tspan');\n span.setAttribute(LINE, '');\n span.textContent = source;\n name.appendChild(span);\n name.setAttribute('visibility', 'hidden');\n } else if (chosen.size < nameStart - 0.01) {\n // Inline style: permitted per 23-constraints §Runtime-computed\n // dimensions (custom property setter from measured sizes).\n name.style.setProperty(SIZE, `${chosen.size}px`);\n }\n }\n if (value && valuePitch > 0) {\n value.setAttribute('dominant-baseline', 'central');\n value.setAttribute('x', String(cx));\n value.setAttribute('y', String(top + height - valuePitch / 2));\n if (valueSize < sizeOf(value) - 0.01) {\n // Inline style: permitted per 23-constraints §Runtime-computed\n // dimensions (custom property setter from measured sizes).\n value.style.setProperty(SIZE, `${valueSize}px`);\n }\n }\n };\n\n // ApexCharts redraws the centre on every update and resize, and\n // rewrites it on a hover over a ring and back.\n const inCentre = (node: Node) =>\n (node instanceof Element &&\n (node.closest(GROUP) !== null || node.querySelector(GROUP) !== null)) ||\n (node instanceof Text && node.parentElement?.closest(GROUP) != null);\n const redraws = new MutationObserver((records) => {\n if (\n records.some((record) =>\n [record.target, ...record.addedNodes].some(inCentre),\n )\n ) {\n fit();\n }\n });\n // A theme class on any ancestor (a nested ThemeRoot) changes the type\n // sizes without a redraw.\n const themeClasses = (value: string | null) =>\n (value ?? '')\n .split(/\\s+/)\n .filter((name) => name.startsWith('theme-'))\n .sort()\n .join(' ');\n const themes = new MutationObserver((records) => {\n if (\n records.some(\n (record) =>\n record.target instanceof Element &&\n themeClasses(record.oldValue) !==\n themeClasses(record.target.getAttribute('class')),\n )\n ) {\n fit();\n }\n });\n for (let node = root.parentElement; node; node = node.parentElement) {\n themes.observe(node, {\n attributes: true,\n attributeFilter: ['class'],\n attributeOldValue: true,\n });\n }\n // A web font that arrives after the draw widens the labels in place.\n const { fonts } = root.ownerDocument;\n\n fit();\n redraws.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n fonts?.addEventListener('loadingdone', fit);\n return () => {\n redraws.disconnect();\n themes.disconnect();\n fonts?.removeEventListener('loadingdone', fit);\n };\n }, [root, enabled, locale]);\n}\n","import type { AgentAdapter } from '../../agent/types';\nimport type { ChartHandle } from './chart';\n\nexport const chartAgent: AgentAdapter<ChartHandle> = {\n id: 'chart',\n // view_change backs the opt-in type switcher (`switchableTypes` prop):\n // the same chart re-presented as line / bar / area / pie / donut.\n capabilities: ['view_change'],\n state: {\n declaredType: {\n type: \"'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar'\",\n descriptionKey: 'ui.agent.chart.state.declaredType',\n description:\n 'The consumer-declared chart type — the shape `update_series` expects.',\n read: (handle) => handle.getTypeState().declaredType,\n },\n effectiveType: {\n type: \"'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar'\",\n descriptionKey: 'ui.agent.chart.state.effectiveType',\n description:\n 'The type currently rendered — differs from declaredType after a type-switcher pick.',\n read: (handle) => handle.getTypeState().effectiveType,\n },\n availableTypes: {\n type: 'ChartType[]',\n descriptionKey: 'ui.agent.chart.state.availableTypes',\n description:\n 'Types the switcher offers. Empty when the chart has no type switcher.',\n read: (handle) => handle.getTypeState().availableTypes,\n },\n },\n actions: {\n change_view: {\n // Switching the presentation is a write (it changes what the user\n // sees) but is trivially reversible by switching back.\n safety: 'write',\n argsType: 'type',\n argsSchema: {\n type: 'object',\n properties: {\n type: {\n type: 'string',\n enum: ['line', 'bar', 'area', 'pie', 'donut'],\n description: 'The chart type to render.',\n },\n },\n required: ['type'],\n },\n returns: 'boolean (accepted)',\n returnsSchema: {\n type: 'boolean',\n description:\n 'True when the switch was applied; false when the chart has no type switcher or the type is not offered (check availableTypes first).',\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.changeView',\n description:\n 'Switch the rendered chart type via the type switcher. No-op (returns false) when the chart has no switcher or the type is not offered.',\n invoke: (handle, args: { type: string }) =>\n handle.setType(args.type as Parameters<ChartHandle['setType']>[0]),\n },\n update_series: {\n // Replacing the rendered series mutates what the chart displays — it\n // is a write, reversible by pushing the prior series back.\n safety: 'write',\n argsType: 'series',\n // `series` is `ChartSeries[]` (line/bar/area) OR `number[]`\n // (pie/donut/radialBar). Both shapes are accepted; the handle routes\n // by chart type internally.\n argsSchema: {\n type: 'object',\n properties: {\n series: {\n oneOf: [\n {\n type: 'array',\n description: 'Categorical series for line / bar / area charts.',\n items: {\n type: 'object',\n properties: {\n name: { type: 'string' },\n data: { type: 'array', items: { type: 'number' } },\n role: {\n type: 'string',\n enum: ['primary', 'compare'],\n description:\n \"Optional. 'compare' renders this series as a secondary, colour-blind-safe overlay (e.g. the previous period) — a dotted stroke in its paired primary's colour for line/area, a tinted bar with a dotted outline for bar. Omit for a normal primary series.\",\n },\n },\n required: ['name', 'data'],\n },\n },\n {\n type: 'array',\n description: 'Flat values for pie / donut / radialBar charts.',\n items: { type: 'number' },\n },\n ],\n },\n },\n required: ['series'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.updateSeries',\n description:\n 'Replace the chart series without remounting. Pass the DECLARED type’s shape (see declaredType state); when the user has switched the view cross-shape the values are converted to the rendered shape. The data and its summary table persist across type switches, resizes and theme changes until the host passes a new series prop.',\n invoke: (\n handle,\n args: { series: Parameters<ChartHandle['updateSeries']>[0] },\n ) => {\n handle.updateSeries(args.series);\n },\n },\n export_png: {\n safety: 'read',\n returns: 'string (PNG data URI)',\n returnsSchema: {\n type: 'string',\n description: 'A `data:image/png;base64,…` URI of the rendered chart.',\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.exportPng',\n description:\n 'Return a PNG data URI of the chart for export or screenshotting. Waits until series pushed with update_series are drawn.',\n invoke: (handle) => handle.dataURI(),\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'chart' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* Chart — thin, typed wrapper over ApexCharts (react-apexcharts). */\n/* */\n/* - All chrome, colours, and fonts flow from */\n/* `src/tokens/apexcharts-theme.ts` — never hex literals in user */\n/* code. A MutationObserver on `<html class>` re-reads the bridge so */\n/* theme changes repaint without remount. */\n/* - A ResizeObserver on the wrapper keeps the chart responsive */\n/* without listening on `window.resize`. */\n/* - Accessibility: the wrapper is a `role=\"figure\"` named by `title`, */\n/* described by a visually-hidden series × categories `<table>`; the */\n/* plot is hidden, the legend/toolbar buttons stay keyboard-operable. */\n/* - Colour-blind users: `patterns` prop flips `fill.type` to pattern */\n/* using ApexCharts' built-in pattern presets. */\n/* - Numbers format via `Intl.NumberFormat(locale)` — no hand-rolled */\n/* `toFixed()`. */\n/* ------------------------------------------------------------------ */\n\nimport {\n type CSSProperties,\n type RefObject,\n forwardRef,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport ReactApexChart from 'react-apexcharts';\nimport ApexCharts from 'apexcharts';\nimport {\n ChartArea,\n ChartColumn,\n ChartLine,\n ChartPie,\n Donut,\n} from 'lucide-react';\nimport {\n getApexChartsTheme,\n getCompareFillOpacity,\n resolveCompareTint,\n type ApexChartsTheme,\n} from '../../tokens/apexcharts-theme';\nimport '../../tokens/apexcharts-theme.css';\nimport {\n useIsomorphicLayoutEffect,\n usePrefersReducedMotion,\n} from '../../hooks';\nimport { useNeutraliseHiddenFocus } from '../_shared/use-neutralize-hidden-focus';\nimport { useKeepApexTooltipInside } from '../_shared/use-keep-apex-tooltip-inside';\nimport { useApexChartSemantics } from '../_shared/use-apex-chart-semantics';\nimport { useApexLegendScroll } from '../_shared/use-apex-legend-scroll';\nimport { useApexXLabelSpacing } from '../_shared/use-apex-x-label-spacing';\nimport { useApexRadialCentre } from '../_shared/use-apex-radial-centre';\nimport { canonicalLocale } from '../_shared/intl-locale';\nimport { escapeHtml } from '../_shared/escape-html';\nimport { composeRefs } from '../_shared/compose-refs';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { chartAgent } from './chart.agent';\nimport { IconButton } from '../button/icon-button';\nimport { IconButtonGroup } from '../icon-button-group';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\n// `apex-theme-alfadocs` scopes the token focus ring and target sizes in\n// apexcharts-theme.css.\nconst chartVariants = cva(\n 'ds:relative ds:block ds:w-full apex-theme-alfadocs',\n {\n variants: {\n density: {\n compact: 'ds:min-h-[var(--chart-min-height-compact)]',\n comfortable: 'ds:min-h-[var(--chart-min-height-comfortable)]',\n // Applied when an explicit `height` prop is given and no density was\n // requested: the wrapper must not exceed the caller's height (a 96px\n // KPI chart inside a card must not reserve 320px).\n none: '',\n },\n },\n defaultVariants: { density: 'comfortable' },\n },\n);\n\n// A `%` height: the Chart's root takes that share of its parent through\n// --chart-fill-size, and never less than --chart-min-height-fill, so what\n// ApexCharts draws always fits the root. Kept out of chartVariants, which\n// types public props.\nconst chartFillVariants = cva('', {\n variants: {\n fill: {\n none: '',\n // The figure is the root: it takes the share itself.\n root: 'ds:h-[var(--chart-fill-size)] ds:min-h-[var(--chart-min-height-fill)]',\n // Below the switcher row: the rest.\n rest: 'ds:min-h-[var(--chart-min-height-fill)] ds:flex-1',\n },\n },\n defaultVariants: { fill: 'none' },\n});\n\n// ApexCharts' box in a filled figure: out of flow, so what it last drew never\n// sizes the figure, and the root's floor is the switcher row plus the figure's.\nconst chartPlotVariants = cva('', {\n variants: {\n fill: { false: '', true: 'ds:absolute ds:inset-0' },\n },\n defaultVariants: { fill: false },\n});\n\n// The root that holds the switcher row above the figure.\nconst chartFrameVariants = cva('ds:w-full', {\n variants: {\n fill: {\n false: 'ds:block',\n true: 'ds:flex ds:flex-col ds:h-[var(--chart-fill-size)] ds:min-h-min',\n },\n },\n defaultVariants: { fill: false },\n});\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type ChartType = 'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar';\n\nexport interface ChartSeries {\n name: string;\n data: number[];\n /**\n * Marks this series as a secondary \"compare\" overlay — e.g. the previous\n * period in a current-vs-previous financial view. Rendered visually\n * subordinate and colour-blind-safe, distinguished from primary series by\n * BOTH a non-colour cue AND a lighter shade of the SAME hue (never colour\n * alone). The compare series inherits its PAIRED primary's colour (k-th\n * compare pairs with the k-th primary, by order), then:\n * - line / area: a round-DOTTED stroke in the paired-primary colour (the\n * dotted-vs-solid pattern is the non-colour cue); area also gets a tinted\n * fill at `--chart-compare-fill-opacity`.\n * - bar: a tinted fill (paired-primary hue at `--chart-compare-fill-opacity`)\n * under a full-strength DOTTED outline that is OPEN at the baseline — so a\n * compare bar reads as an outlined \"ghost\" of its solid primary.\n * The legend swatch shows the lighter tint (via `legend.markers.fillColors`),\n * and the series name (e.g. \"Revenue (previous period)\") remains the primary\n * signal in the legend and the screen-reader table.\n * Only meaningful on axis types (line / area / bar); it is structurally\n * impossible on pie / donut / radialBar (their `series` is `number[]`, which\n * cannot carry this field), so the axis-only invariant is enforced by the\n * type system with no runtime guard. On an axis→slice type switch the compare\n * series are dropped from the slice (a previous-period total is not a slice of\n * the current whole; DEV warn). Omit (or `'primary'`) to render normally — a\n * chart with NO compare series renders as before this field existed, and\n * removing or moving the role through `series` clears it from the old series.\n * @default 'primary'\n */\n role?: 'primary' | 'compare';\n}\n\n/** Bar orientation. `'horizontal'` renders a ranking sideways. Default `'vertical'`. */\nexport type ChartOrientation = 'vertical' | 'horizontal';\n\n/** Line / area stroke interpolation. Default `'smooth'`. */\nexport type ChartCurve = 'smooth' | 'straight' | 'stepline';\n\nexport interface ChartProps extends VariantProps<typeof chartVariants> {\n /** Required — drives aria-label and sr-only table caption. */\n title: string;\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /** Chart visual type. */\n type: ChartType;\n /**\n * For `line` / `bar` / `area`: an array of `ChartSeries`.\n * For `pie` / `donut` / `radialBar`: an array of numbers matched to `labels`.\n */\n series: ChartSeries[] | number[];\n /** Category axis labels (line / bar / area). */\n categories?: string[];\n /** Slice labels (pie / donut / radialBar). */\n labels?: string[];\n /** Defaults to 320px. A number or `px` is the plot area's ApexCharts height; a\n * `%` sizes the whole Chart (switcher row, legend, plot) to that share of its\n * parent's height, at least 160px: `\"100%\"` fills a definite-height parent. */\n height?: number | string;\n /** Width override. Defaults to 100% of container. */\n width?: number | string;\n /** Opt-in pattern fills for colour-blind users. */\n patterns?: boolean;\n /**\n * Stack multiple `bar` / `area` series into a composition-over-time view.\n * Maps to ApexCharts `chart.stacked`. Only applies to the axis types\n * (`line` / `bar` / `area`); slice types (`pie` / `donut` / `radialBar`)\n * have no axis to stack against and ignore it. Default `false`: an\n * unstacked chart renders as before this prop existed, and turning it off\n * after the first render unstacks the bars in place.\n */\n stacked?: boolean;\n /**\n * Orientation for the `bar` type. `'horizontal'` renders the bars sideways\n * (ApexCharts `plotOptions.bar.horizontal`) for ranking-style charts where\n * the category is a name and the value runs across the horizontal axis.\n * Still an axis chart — pass `series` as `ChartSeries[]` with `categories`.\n * Ignored for every non-`bar` type. Default `'vertical'`.\n */\n orientation?: ChartOrientation;\n /**\n * Stroke interpolation for `line` / `area` charts (ApexCharts\n * `stroke.curve`). `'straight'` avoids the overshoot a smoothed spline\n * introduces on spiky monthly financials — where a `'smooth'` curve can dip\n * visually below zero between two positive points. Inert on `bar` (stroke\n * width is 0) and ignored on slice types. Default `'smooth'` — existing\n * charts are unaffected.\n */\n curve?: ChartCurve;\n /**\n * Override the series colour ramp. Pass **already-resolved** colour strings\n * (e.g. the live value of `var(--success)` sampled by the consumer) — these\n * are handed straight to ApexCharts, which can't read CSS custom properties.\n * When omitted, the theme bridge's `colors` ramp from `apexcharts-theme.ts`\n * is used, so existing consumers are unaffected. Typical use: a single-arc\n * `radialBar` gauge (e.g. BMI) that must change hue with the value —\n * green in the healthy band, amber/red outside it.\n */\n colors?: string[];\n /**\n * Show the ApexCharts toolbar. Its buttons are --min-target-size boxes in a\n * band reserved above the plot; zoomable types need about 300px of width.\n * Defaults to false.\n */\n toolbar?: boolean;\n /** Locale override — defaults to the active i18next language. */\n locale?: string;\n /**\n * radialBar only. Formats a ring's value: in the centre, in the summary\n * table and, with several rings, in each ring's legend item. Use when the\n * gauge represents a non-percentage figure: pass the arc fill (0–100) as the\n * `series` value and return the real figure here (e.g. `() => '22.4'` for a\n * single ring). It is called with each ring's own value, so with several\n * rings it must use that value. Ignored for every other chart type.\n * Defaults to a percent in the chart's locale.\n */\n radialValueFormatter?: (value: number) => string;\n /**\n * Formats the numeric value of each data point wherever it is surfaced as\n * text — the tooltip, the value (y) axis on categorical charts, and the\n * screen-reader summary table. Use it to append a unit or currency symbol,\n * e.g. `(v) => new Intl.NumberFormat(locale, { style: 'currency', currency:\n * 'EUR' }).format(v)`. Defaults to `Intl.NumberFormat(locale)` (grouped\n * number, no unit). Does not apply to a `radialBar`: its centre, legend\n * and summary table use `radialValueFormatter`.\n */\n valueFormatter?: (value: number) => string;\n /**\n * Opt-in type switcher. Pass two or more of `'line' | 'bar' | 'area' |\n * 'pie' | 'donut'` to render an icon radiogroup (an `IconButtonGroup`)\n * above the plot that lets the user flip the chart between those types.\n * `type` is the initial selection and is always offered; the user's pick\n * then sticks across re-renders (remount with a new `key` to reset it).\n * When the picked type reads the other data shape, the data adapts: axis\n * series collapse to one slice per series (that series' total) for `pie` /\n * `donut`, and slice values become a single-series axis chart with\n * `labels` as the categories. `radialBar` cannot participate — such\n * entries are ignored (DEV warning) and a `radialBar` chart never shows\n * the switcher.\n */\n switchableTypes?: ChartType[];\n /** Called when the user picks a different type via the switcher. */\n onTypeChange?: (type: ChartType) => void;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport interface ChartHandle {\n /** Returns a PNG data URI for the chart, after any pushed series is drawn. */\n dataURI: () => Promise<string>;\n /**\n * Updates series without remounting. Always pass the DECLARED `type`'s\n * shape — while the user has switched the view across the axis/slice\n * boundary the values (and, for axis→slice, the slice labels) are\n * converted to the rendered shape; for slice→axis the categories stay\n * the `labels` prop, so keep the value count stable. The update also\n * reaches the summary table, and holds until the `series` prop changes;\n * `dataURI` waits for it to be drawn.\n */\n updateSeries: (next: ChartProps['series']) => void;\n /**\n * Switches the rendered type via the type switcher. Returns `false`\n * (no-op) when the switcher is not enabled or the type is not offered.\n */\n setType: (next: ChartType) => boolean;\n /** Declared vs rendered type plus the types the switcher offers ([] when disabled). */\n getTypeState: () => {\n declaredType: ChartType;\n effectiveType: ChartType;\n availableTypes: ChartType[];\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Constants */\n/* ------------------------------------------------------------------ */\n\nconst PATTERN_STYLES = [\n 'verticalLines',\n 'horizontalLines',\n 'slantedLines',\n 'squares',\n 'circles',\n] as const;\n\n/** Types where `categories` belong on an x-axis. */\nconst CATEGORICAL_TYPES: ReadonlyArray<ChartType> = ['line', 'bar', 'area'];\n\n/** Types where `series` is a flat `number[]` paired with `labels`. */\nconst SLICE_TYPES: ReadonlyArray<ChartType> = ['pie', 'donut', 'radialBar'];\n\n/** Types the switcher may offer. `radialBar` is excluded — its series are\n * synthetic arc percents that cannot be re-plotted on an axis or as slices. */\nconst SWITCHABLE_TYPES: ReadonlyArray<ChartType> = [\n 'line',\n 'bar',\n 'area',\n 'pie',\n 'donut',\n];\n\ntype SwitchableType = Exclude<ChartType, 'radialBar'>;\n\n/* Static key map (not template-built) so the i18n coverage tooling can see\n every key literally. */\nconst TYPE_SWITCHER_LABEL_KEYS: Record<SwitchableType, string> = {\n line: 'chart.typeSwitcher.line',\n bar: 'chart.typeSwitcher.bar',\n area: 'chart.typeSwitcher.area',\n pie: 'chart.typeSwitcher.pie',\n donut: 'chart.typeSwitcher.donut',\n};\n\nconst TYPE_SWITCHER_ICONS: Record<SwitchableType, React.ReactNode> = {\n line: <ChartLine />,\n bar: <ChartColumn />,\n area: <ChartArea />,\n pie: <ChartPie />,\n donut: <Donut />,\n};\n\n/* Compare-overlay geometry. Colours come only from tokens (via the bridge);\n these are pure numeric/dash literals, consistent with the pre-existing\n stroke width:2 / dashArray literals the component already used. */\nconst COMPARE_OUTLINE_WIDTH = 2; // dotted outline / stroke width (~1.5–2px)\nconst COMPARE_DOT_DASH = '0 6'; // 0-length dash + round cap ⇒ round dots, 6px pitch\n\n/** ApexCharts' default `title.margin`, sent when the toolbar is off. */\nconst APEX_TITLE_MARGIN = 5;\n\n/**\n * Px ApexCharts keeps above an axis chart's plot for a title and subtitle\n * (10, then 5 for each), which Chart never draws. A short chart takes it back.\n */\nconst APEX_TITLE_ALLOWANCE = 20;\n\n/** ApexCharts' default `xaxis.labels.rotate`, for crowded labels on a wide chart. */\nconst APEX_LABEL_ROTATE = -45;\n\n/** Below `--breakpoint-sm` (640px) a chart is narrow: crowded labels thin out. */\nconst NARROW_CHART_WIDTH = 640;\n\n/**\n * Below this a two-row legend is as tall as the plot or taller (measured: from\n * 280px, about 304px accessible), so it keeps to one row that scrolls sideways.\n */\nconst SHORT_CHART_HEIGHT = 300;\n\n/**\n * What a `%` height draws at before its first measure: the figure's own CSS\n * floor, --chart-min-height-fill. A one-row legend (52px) and the axes (about\n * 52px) still leave a 56px plot, 48px accessible. A shorter parent sees the\n * root overflow it.\n */\nconst MIN_FILL_HEIGHT = 160;\n\n/**\n * Rewrite each COMPARE bar into a 3-sided OPEN path (drop the baseline edge and\n * the implicit close) and round-dot its outline. A bar is natively one closed\n * path, so \"open at the bottom\" is impossible via config — this post-render DOM\n * patch is the only way. Verified safe against ApexCharts 5.10.6: animation\n * continuity is read from a separate `pathTo`/`pathFrom` attribute, never the\n * live `d`, so overwriting `d` never corrupts entrance/update animation or\n * `previousPaths`; the same element is kept so tooltips/crosshair still bind.\n * Idempotent (re-running writes the same `d`).\n *\n * Only applied to VERTICAL, positive-valued bars: the open edge is assumed to be\n * the bbox bottom. A horizontal or negative compare bar keeps the native\n * 4-sided dotted outline (still a valid non-colour cue) — see the guard in the\n * component. jsdom lacks `getBBox`, so the per-path guard makes this a no-op in\n * unit tests (exercised in the real-browser story run instead).\n */\nfunction patchCompareBars(\n root: HTMLElement | null,\n compareRealIndexes: number[],\n): void {\n if (!root || compareRealIndexes.length === 0) return;\n root\n .querySelectorAll<SVGGElement>(\n '.apexcharts-bar-series > .apexcharts-series',\n )\n .forEach((g) => {\n const ri = Number(g.getAttribute('data:realIndex'));\n if (!compareRealIndexes.includes(ri)) return;\n g.querySelectorAll<SVGPathElement>('path.apexcharts-bar-area').forEach(\n (p) => {\n if (typeof p.getBBox !== 'function') return; // jsdom guard\n const b = p.getBBox(); // final rendered box, stroke-excluded\n // 3-sided OPEN path: bottom-left → up left → across top → down right.\n // SVG fills the implicit close (bottom-right → bottom-left), so the\n // tint fill stays full-height; the stroke omits the baseline edge.\n p.setAttribute(\n 'd',\n `M ${b.x} ${b.y + b.height} L ${b.x} ${b.y} ` +\n `L ${b.x + b.width} ${b.y} L ${b.x + b.width} ${b.y + b.height}`,\n );\n p.setAttribute('stroke-dasharray', COMPARE_DOT_DASH); // round-dot rhythm\n p.setAttribute('stroke-linecap', 'round');\n },\n );\n });\n}\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\n/** Px kept clear above the plot for the toolbar, from the tokens at `el`. */\nfunction toolbarBandOf(el: Element): number {\n const styles = getComputedStyle(el);\n const px = (token: string) =>\n Number.parseFloat(styles.getPropertyValue(token)) || 0;\n return (\n px('--min-target-size') +\n px('--focus-ring-offset') +\n px('--focus-ring-width')\n );\n}\n\n/**\n * The px width ApexCharts draws at, by its own rule: a number or `px` as is,\n * a `%` of the element it draws into. Any other unit gives NaN, as it does there.\n */\nfunction drawnWidth(width: number | string | undefined, into: number): number {\n if (width === undefined) return into;\n if (typeof width === 'number') return width;\n // parseInt, not parseFloat: ApexCharts drops the fraction too, so this\n // matches the width it actually draws.\n const value = Number.parseInt(width, 10);\n return width.trim().endsWith('%') ? (into * value) / 100 : value;\n}\n\n/**\n * How a radialBar ring's value reads: the consumer's `radialValueFormatter`,\n * else a percent in the chart's locale (\"85.9%\", \"85,9 %\").\n */\nfunction radialText(\n locale: string,\n radialValueFormatter: ((value: number) => string) | undefined,\n): (value: number) => string {\n if (radialValueFormatter) return radialValueFormatter;\n const percent = new Intl.NumberFormat(locale, {\n style: 'percent',\n maximumFractionDigits: 2,\n });\n return (value) => percent.format(value / 100);\n}\n\n/** The px height ApexCharts draws at for a number or `px`; NaN for a `%`. */\nfunction drawnHeight(height: number | string): number {\n if (typeof height === 'number') return height;\n return height.trim().endsWith('%') ? Number.NaN : Number.parseInt(height, 10);\n}\n\n/**\n * The series, categories and labels the rendered type reads. Axis series\n * collapse to one slice per series (its total) on a slice view; slice\n * values become one axis series with `labels` as the categories.\n */\nfunction adaptSeries(\n series: ChartSeries[] | number[],\n categories: string[] | undefined,\n labels: string[] | undefined,\n declaredIsSlice: boolean,\n effectiveIsSlice: boolean,\n valueName: string,\n): {\n effectiveSeries: ChartSeries[] | number[];\n effectiveCategories: string[] | undefined;\n effectiveLabels: string[] | undefined;\n} {\n if (declaredIsSlice === effectiveIsSlice) {\n return {\n effectiveSeries: series,\n effectiveCategories: categories,\n effectiveLabels: labels,\n };\n }\n if (!declaredIsSlice) {\n const allRows = series as ChartSeries[];\n // A previous-period total is not a slice of the current whole, so\n // compare overlays are dropped from the axis→slice collapse (their\n // grey \"prev\" slice would misread as part of the current mix). This\n // also makes compareFlags naturally [] on the slice side.\n const rows = allRows.filter((row) => row.role !== 'compare');\n if (import.meta.env.DEV && rows.length !== allRows.length) {\n console.warn(\n 'Chart: compare series are dropped on an axis→slice switch — a previous-period total is not a slice of the current whole.',\n );\n }\n const totals = rows.map((row) => row.data.reduce((sum, v) => sum + v, 0));\n if (import.meta.env.DEV && totals.some((v) => v < 0)) {\n console.warn(\n 'Chart: the axis→slice adaptation produced a negative series total — pie/donut cannot represent negative values. Offer only axis types in `switchableTypes` for delta-style data.',\n );\n }\n return {\n effectiveSeries: totals,\n effectiveCategories: undefined,\n effectiveLabels: rows.map((row) => row.name),\n };\n }\n const values = series as number[];\n return {\n effectiveSeries: [{ name: valueName, data: values }] as ChartSeries[],\n effectiveCategories: labels ?? [],\n effectiveLabels: undefined,\n };\n}\n\ntype ApexLocaleOption = NonNullable<\n NonNullable<ApexCharts.ApexOptions['chart']>['locales']\n>[number];\n\n/** Everything the ApexCharts options are built from, for one rendered view. */\ninterface ChartOptionInputs {\n themeOptions: ApexChartsTheme;\n toolbarBand: number;\n chartId: string;\n toolbar: boolean;\n reducedMotion: boolean;\n toolbarLocale: ApexLocaleOption;\n locale: string;\n effectiveLabels: string[] | undefined;\n formatValue: (value: number) => string;\n noDataText: string;\n effectiveType: ChartType;\n effectiveSeries: ChartSeries[] | number[];\n effectiveCategories: string[] | undefined;\n isRtl: boolean;\n patterns: boolean;\n stacked: boolean;\n orientation: ChartOrientation;\n curve: ChartCurve;\n colors: string[] | undefined;\n radialValueFormatter: ((value: number) => string) | undefined;\n /** Narrower than NARROW_CHART_WIDTH. */\n narrow: boolean;\n /** Shorter than SHORT_CHART_HEIGHT. */\n short: boolean;\n wrapperRef: RefObject<HTMLDivElement | null>;\n}\n\n/** The ApexCharts options for one view: used by render and by the handle. */\nfunction buildChartOptions({\n themeOptions,\n toolbarBand,\n chartId,\n toolbar,\n reducedMotion,\n toolbarLocale,\n locale,\n effectiveLabels,\n formatValue,\n noDataText,\n effectiveType,\n effectiveSeries,\n effectiveCategories,\n isRtl,\n patterns,\n stacked,\n orientation,\n curve,\n colors,\n radialValueFormatter,\n narrow,\n short,\n wrapperRef,\n}: ChartOptionInputs): ApexCharts.ApexOptions {\n // Split the resolved compare colours off the theme object BEFORE spread:\n // `base` is exactly today's theme shape (colours / chart / grid), so\n // `...base` emits the same keys as before. The theme no longer carries a\n // `compare` object — the redesign never uses grey; the compare fill is a\n // tint of the paired-primary hue, resolved below from a token.\n const base = themeOptions;\n\n // Per-series compare flags, derived at build time from the EFFECTIVE\n // series/type so the type switcher composes: only axis types carry the\n // `role` field (slice `series` is `number[]`), so a slice view yields [].\n const compareFlags =\n isCategoricalType(effectiveType) && Array.isArray(effectiveSeries)\n ? (effectiveSeries as ChartSeries[]).map((s) => s.role === 'compare')\n : [];\n const hasCompare = compareFlags.some(Boolean);\n const barCompare = hasCompare && effectiveType === 'bar';\n // The open-at-the-baseline bar rewrite (patchCompareBars) assumes the\n // baseline is the bbox BOTTOM — true only for vertical, non-negative bars.\n // A horizontal or negative compare bar keeps the native 4-sided dotted\n // outline (still a valid non-colour cue), so the hook is gated off for it.\n const compareHasNegative =\n barCompare &&\n (effectiveSeries as ChartSeries[]).some(\n (s) => s.role === 'compare' && s.data.some((v) => v < 0),\n );\n const openBottomBars =\n barCompare && orientation === 'vertical' && !compareHasNegative;\n // Compare fill opacity + per-series tints (legend swatch), resolved from\n // the token via the bridge so no hex literal lives in component code.\n const compareFillOpacity = hasCompare ? getCompareFillOpacity() : 0.3;\n\n if (\n import.meta.env.DEV &&\n hasCompare &&\n stacked &&\n isCategoricalType(effectiveType)\n ) {\n console.warn(\n 'Chart: `stacked` with a compare series — a compare overlay is normally a grouped, not stacked, series. It will be stacked with the primaries.',\n );\n }\n\n const options: ApexCharts.ApexOptions = {\n ...base,\n chart: {\n ...base.chart,\n id: chartId,\n toolbar: { show: toolbar },\n zoom: { enabled: toolbar },\n animations: {\n enabled: !reducedMotion,\n dynamicAnimation: { enabled: !reducedMotion },\n },\n locales: [toolbarLocale],\n defaultLocale: locale,\n parentHeightOffset: 0,\n // Keep the keyboard-operable legend; drop Apex's data-point navigation\n // and live announcements (English-only, and the summary table covers them).\n accessibility: {\n enabled: true,\n announcements: { enabled: false },\n keyboard: { enabled: true, navigation: { enabled: false } },\n },\n // Stacking is axis-only, so a slice or radial chart never receives it.\n // Sent as false too: ApexCharts merges an update into its config, so\n // leaving it out would keep an earlier `true`.\n ...(isCategoricalType(effectiveType) ? { stacked } : {}),\n },\n // Only set `labels` when the effective type actually has them (slice\n // charts). Emitting `labels: undefined` crashes ApexCharts' bar\n // renderer — `parseDataAxisCharts` reads `labels.length` and throws\n // \"Cannot read properties of undefined (reading 'length')\", which\n // aborts the render and leaves a blank chart. Absent is safe; area /\n // line tolerate the undefined but bar does not, so never pass it.\n ...(effectiveLabels ? { labels: effectiveLabels } : {}),\n legend: {\n ...base.legend,\n position: 'bottom',\n // ApexCharts legend.horizontalAlign is a physical prop mapped internally\n // to the chart's own text flow. For RTL we flip via `yaxis.opposite`\n // and ApexCharts' own `direction: 'rtl'` handling; legend stays anchored\n // to the inline-start by asking for 'left' on LTR and 'right' on RTL.\n horizontalAlign: isRtl ? 'right' : 'left',\n fontFamily: 'inherit',\n // apexcharts-theme.css sizes the legend hit areas and ring room from\n // this 4px; pinned so an ApexCharts default change cannot break them.\n itemMargin: { horizontal: 5, vertical: 4 },\n // ApexCharts writes legend text as HTML: a series named \"R&D\" or\n // \"<b>\" must read as written, not as markup.\n formatter: (name: string) => escapeHtml(String(name)),\n },\n // The tooltip, like the legend, is written as HTML: its heading (the\n // category) and each series name are escaped too.\n tooltip: {\n ...base.tooltip,\n x: {\n ...base.tooltip?.x,\n // A line or area chart hands ApexCharts its categories as positions\n // (1..n), so the heading is named from the point's index, as\n // ApexCharts' own axis label is.\n formatter: (\n value: string | number,\n opts?: { dataPointIndex?: number },\n ) =>\n escapeHtml(\n String(effectiveCategories?.[opts?.dataPointIndex ?? -1] ?? value),\n ),\n },\n y: {\n formatter: (value: number) => formatValue(value),\n title: {\n formatter: (name: string) =>\n name ? `${escapeHtml(String(name))}: ` : '',\n },\n },\n },\n noData: {\n text: noDataText,\n },\n };\n\n // Room above the plot. ApexCharts reads grid.padding only on creation but a\n // title's margin on every update, so no remount. An empty title's margin\n // keeps the toolbar band clear and, on a short axis chart, takes back the\n // title allowance. Otherwise the title's defaults are sent, or an update\n // would keep the band.\n const band = toolbar && toolbarBand ? toolbarBand : 0;\n const reclaim =\n short && isCategoricalType(effectiveType) ? APEX_TITLE_ALLOWANCE : 0;\n options.title =\n band || reclaim\n ? { ...options.title, text: '', margin: band - reclaim }\n : { ...options.title, text: undefined, margin: APEX_TITLE_MARGIN };\n\n // Consumer-supplied, already-resolved colour ramp wins over the theme\n // bridge's `colors`. Ignored when absent so existing charts keep the\n // tokenised ramp. ApexCharts can't read `var(--…)`, so the consumer is\n // responsible for sampling the live token value before passing it in.\n if (colors && colors.length > 0) {\n options.colors = colors;\n }\n\n // Step 1 (compare) — pair each compare series with a primary and inherit\n // its colour. The k-th `role:'compare'` pairs with the k-th `role:'primary'`\n // by order (clamped to the last primary; falls back to its own index when\n // there are zero primaries). Primaries keep ApexCharts' own %-cycled ramp\n // colour, so after this `options.colors[i]` is the full paired-primary\n // colour for EVERY series — used directly by the bar fill/outline and the\n // line stroke. The compare fill is tinted separately (fill.opacity); only\n // the LEGEND swatch shows the lighter tint (legend.markers.fillColors).\n if (hasCompare) {\n const ramp = (options.colors ?? base.colors ?? []) as string[];\n const rampAt = (i: number) => ramp[i % Math.max(ramp.length, 1)];\n const primaryIdx = (effectiveSeries as ChartSeries[])\n .map((s, i) => (s.role === 'compare' ? -1 : i))\n .filter((i) => i >= 0);\n let seen = 0;\n options.colors = (effectiveSeries as ChartSeries[]).map((s, i) => {\n if (s.role !== 'compare') return rampAt(i);\n const pair = primaryIdx.length\n ? primaryIdx[Math.min(seen++, primaryIdx.length - 1)]\n : i;\n return rampAt(pair); // inherit the paired primary's colour\n });\n // Legend swatch: compare shows the lighter tint (a shade of its paired\n // primary), primaries show their own colour. Decoupled from the mark\n // colour so the swatch reads as \"lighter = compare\".\n const compareTints = (options.colors as string[]).map((c, i) =>\n compareFlags[i] ? resolveCompareTint(c) : c,\n );\n options.legend = {\n ...options.legend,\n markers: {\n ...(options.legend?.markers ?? {}),\n fillColors: compareTints,\n },\n };\n }\n\n if (isCategoricalType(effectiveType)) {\n // A horizontal bar makes ApexCharts swap axes: the numeric axis\n // becomes the x-axis and the categories move to the y-axis. The value\n // formatter must follow the numbers, so on a horizontal bar it lives\n // on `xaxis.labels` and the category y-axis keeps its default (string)\n // labels; every other categorical chart keeps the formatter on `yaxis`.\n const horizontalBar =\n effectiveType === 'bar' && orientation === 'horizontal';\n // The x formatter is sent as undefined too, or an update turning a bar\n // vertical would keep the number formatter on its categories.\n options.xaxis = {\n ...base.xaxis,\n categories: effectiveCategories ?? [],\n labels: {\n ...base.xaxis?.labels,\n formatter: horizontalBar\n ? (value: string | number) => formatValue(Number(value))\n : undefined,\n // A narrow chart thins crowded labels rather than turning them sideways.\n // Sent both ways, so a widened chart rotates. ApexCharts draws every\n // label and useApexXLabelSpacing thins them: its own test keeps two\n // labels that touch, or overlap when the second is wider.\n rotate: narrow ? 0 : APEX_LABEL_ROTATE,\n hideOverlappingLabels: false,\n },\n // The hover tooltip already heads with the category. ApexCharts' own\n // x-axis box repeats it below the axis, outside the chart's box.\n tooltip: { enabled: false },\n };\n options.yaxis = {\n ...base.yaxis,\n opposite: isRtl,\n ...(horizontalBar\n ? {}\n : { labels: { formatter: (value: number) => formatValue(value) } }),\n };\n // Step 2 (compare) — the non-colour cue is a round-DOTTED stroke on the\n // compare indices (dotted-vs-solid, greyscale/print-safe). It works on\n // bars too: unlike a fill hatch, a per-series bar stroke width + dash\n // renders a dotted OUTLINE in the paired-primary colour. Line/area keep\n // width 2; a bar's outline width is COMPARE_OUTLINE_WIDTH on compare\n // indices and 0 on primaries (solid, fill-only). `lineCap:'round'` turns\n // the 0-length dash into round dots. With no compare series,\n // withCompareKeys sends ApexCharts' default lineCap and dashArray.\n options.stroke = {\n curve,\n width:\n effectiveType === 'bar'\n ? hasCompare\n ? compareFlags.map((c) => (c ? COMPARE_OUTLINE_WIDTH : 0))\n : 0\n : 2,\n ...(hasCompare\n ? {\n lineCap: 'round' as const,\n // Runtime accepts a string dash; the published types say\n // `number` → one documented cast. `'0 6'` + round cap ⇒ dots.\n dashArray: compareFlags.map((c) =>\n c ? COMPARE_DOT_DASH : 0,\n ) as unknown as number[],\n }\n : {}),\n };\n options.dataLabels = { enabled: false };\n }\n\n if (effectiveType === 'radialBar') {\n // ApexCharts treats a radialBar series value as a 0–100 percent and\n // renders it verbatim in the ring centre. When the displayed value is\n // NOT a percentage (e.g. a BMI), the consumer scales the series to a\n // percent for the arc and supplies `radialValueFormatter` to print the\n // real value in the centre. Without this, the gauge would read \"56%\"\n // for a BMI of 22.4 — misleading. Otherwise the value is a percent in\n // the chart's locale. The centre name takes the foreground colour, not\n // its ring's, which fails contrast for some rings and themes.\n const ringValue = radialText(locale, radialValueFormatter);\n const basePlot = (base.plotOptions ?? {}) as NonNullable<\n ApexCharts.ApexOptions['plotOptions']\n >;\n const labels = basePlot.radialBar?.dataLabels;\n options.plotOptions = {\n ...basePlot,\n radialBar: {\n ...(basePlot.radialBar ?? {}),\n dataLabels: {\n ...(labels ?? {}),\n name: { ...(labels?.name ?? {}), color: base.chart?.foreColor },\n value: {\n ...(labels?.value ?? {}),\n formatter: (val: number) => ringValue(Number(val)),\n },\n },\n },\n };\n // ApexCharts draws no legend for a radialBar. With several rings the\n // centre names only the hovered one, and may have to hide that name, so\n // a legend names them all, each with its value: the centre shows a value\n // only under the pointer, out of reach of the keyboard and touch. The\n // value is its own line under the name and never shrinks\n // (apexcharts-theme.css); the name takes what room is left.\n const rings = Array.isArray(effectiveSeries) && effectiveSeries.length > 1;\n const dir = isRtl ? 'rtl' : 'ltr';\n options.legend = {\n ...options.legend,\n show: rings,\n ...(rings\n ? {\n formatter: (name: string, opts?: { seriesIndex: number }) => {\n const value = Number(\n (effectiveSeries as number[])[opts?.seriesIndex ?? 0],\n );\n return (\n `<span class=\"chart-legend-ring\" dir=\"${dir}\">` +\n `<span class=\"chart-legend-name\">${escapeHtml(String(name))}</span> ` +\n `<span class=\"chart-legend-value\">${escapeHtml(ringValue(value))}</span>` +\n `</span>`\n );\n },\n }\n : {}),\n };\n }\n\n // Horizontal bars for rankings; `bar` and `radialBar` never share a chart.\n // Sent as false too, or an update turning a bar vertical would keep an\n // earlier `true`.\n if (effectiveType === 'bar') {\n const basePlot = (base.plotOptions ?? {}) as NonNullable<\n ApexCharts.ApexOptions['plotOptions']\n >;\n options.plotOptions = {\n ...basePlot,\n bar: {\n ...(basePlot.bar ?? {}),\n horizontal: orientation === 'horizontal',\n },\n };\n }\n\n // Step 3 (fill) — the compare branches sit between the global `patterns`\n // branch and the area-gradient branch. Each is gated on hasCompare /\n // barCompare; a fill left unset here gets ApexCharts' default from\n // withCompareKeys.\n if (patterns) {\n // Colour-blind pattern mode. With a compare overlay the compare indices\n // drop the hatch and use a plain tinted solid fill (their dotted outline\n // / stroke from Step 2 is already the non-colour cue), so they read as a\n // lighter ghost of the primary; the primaries keep the cycled hatch.\n options.fill = {\n type: hasCompare\n ? compareFlags.map((c) => (c ? 'solid' : 'pattern'))\n : 'pattern',\n opacity: hasCompare\n ? compareFlags.map((c) =>\n c ? compareFillOpacity : effectiveType === 'area' ? 0.3 : 1,\n )\n : effectiveType === 'area'\n ? 0.3\n : 1,\n pattern: {\n style: [...PATTERN_STYLES],\n strokeWidth: 2,\n },\n };\n } else if (barCompare) {\n // Tinted solid fill: compare bars are their paired-primary hue at\n // `--chart-compare-fill-opacity`; primaries stay solid at full opacity.\n // The dotted outline (Step 2 stroke width) + open-bottom rewrite\n // (patchCompareBars, wired via chart.events below) supply the shape.\n options.fill = {\n type: 'solid',\n opacity: compareFlags.map((c) => (c ? compareFillOpacity : 1)),\n };\n } else if (effectiveType === 'area') {\n // Area gradient. With a compare overlay the compare fill drops to the\n // tint opacity so it sits under the dotted paired-primary stroke without\n // fighting the primary; primaries keep the default gradient. No grey —\n // the tint is a shade of the same (paired-primary) hue from Step 1.\n options.fill = hasCompare\n ? {\n type: 'gradient',\n opacity: compareFlags.map((c) => (c ? compareFillOpacity : 0.3)),\n }\n : {\n type: 'gradient',\n opacity: 0.3,\n };\n }\n\n // Open-at-the-baseline bar outline (progressive enhancement over the\n // native dotted 4-sided border). Attached ONLY for vertical, non-negative\n // compare bars; horizontal / negative bars keep the closed dotted outline.\n // Added inside this branch, and cleared by withCompareKeys, so a chart\n // without open-bottom bars never runs it. Re-fires on mount, update and\n // animation end: together they cover resize, theme and series changes.\n if (openBottomBars) {\n const compareRealIndexes = compareFlags\n .map((c, i) => (c ? i : -1))\n .filter((i) => i >= 0);\n const run = () => patchCompareBars(wrapperRef.current, compareRealIndexes);\n const raf = () =>\n typeof requestAnimationFrame === 'function'\n ? requestAnimationFrame(run)\n : run();\n options.chart = {\n ...options.chart,\n events: {\n ...(options.chart?.events ?? {}),\n mounted: () => raf(),\n updated: () => raf(),\n animationEnd: () => run(),\n },\n };\n }\n\n return withCompareKeys(options, effectiveType);\n}\n\n/**\n * ApexCharts merges an update into its config, so a key left out keeps its old\n * value. Every key a compare series sets is sent on every build: the builder's\n * per-series arrays, else ApexCharts' own defaults. Only axis types take one.\n */\nfunction withCompareKeys(\n options: ApexCharts.ApexOptions,\n type: ChartType,\n): ApexCharts.ApexOptions {\n if (!isCategoricalType(type)) return options;\n const events = options.chart?.events;\n return {\n ...options,\n colors: options.colors,\n chart: {\n ...options.chart,\n events: {\n ...events,\n mounted: events?.mounted,\n updated: events?.updated,\n animationEnd: events?.animationEnd,\n },\n },\n stroke: {\n ...options.stroke,\n lineCap: options.stroke?.lineCap ?? (type === 'bar' ? 'square' : 'butt'),\n dashArray: options.stroke?.dashArray ?? 0,\n },\n legend: {\n ...options.legend,\n markers: {\n ...options.legend?.markers,\n fillColors: options.legend?.markers?.fillColors,\n },\n },\n fill: options.fill ?? { type: 'solid', opacity: 0.85 },\n };\n}\n\nfunction isSliceType(type: ChartType): boolean {\n return SLICE_TYPES.includes(type);\n}\n\nfunction isCategoricalType(type: ChartType): boolean {\n return CATEGORICAL_TYPES.includes(type);\n}\n\n/** Coerce `series` into `ChartSeries[]` for shared logic (table, aria). */\nfunction normaliseSeries(\n series: ChartSeries[] | number[],\n type: ChartType,\n): ChartSeries[] {\n if (isSliceType(type)) {\n const nums = series as number[];\n return [\n {\n name: '',\n data: nums,\n },\n ];\n }\n return series as ChartSeries[];\n}\n\n/* ------------------------------------------------------------------ */\n/* Chart component */\n/* ------------------------------------------------------------------ */\n\nexport const Chart = forwardRef<ChartHandle, ChartProps>(\n (\n {\n title,\n id,\n type,\n series,\n categories,\n labels,\n height,\n width,\n patterns = false,\n stacked = false,\n orientation = 'vertical',\n curve = 'smooth',\n colors,\n toolbar = false,\n locale: localeProp,\n radialValueFormatter,\n valueFormatter,\n switchableTypes,\n onTypeChange,\n density,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation('ui');\n const rawId = useId();\n const chartId = useMemo(\n () => `chart-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const summaryId = `${chartId}-summary`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n // Also held as state: the wrapper remounts when the switcher turns on or\n // off, and the observers below must follow it to the new element.\n const [wrapperEl, setWrapperEl] = useState<HTMLDivElement | null>(null);\n const wrapperCallbackRef = useMemo(\n () => composeRefs(wrapperRef, setWrapperEl),\n [],\n );\n const liveWrapperRef = useMemo(() => ({ current: wrapperEl }), [wrapperEl]);\n const [containerWidth, setContainerWidth] = useState(0);\n // A `%` height sizes the whole Chart against its parent (see `height`);\n // the figure's measured height is then what ApexCharts may draw.\n const fillShare =\n typeof height === 'string' && height.trim().endsWith('%')\n ? height.trim()\n : undefined;\n const [fillHeight, setFillHeight] = useState(0);\n const fillsRef = useRef(false);\n fillsRef.current = fillShare !== undefined;\n // Measure before paint as a `%` height starts, so the first draw is the\n // real height and a switch from a number with an unchanged box is seen.\n useIsomorphicLayoutEffect(() => {\n if (fillShare && wrapperEl) {\n setFillHeight(Math.floor(wrapperEl.clientHeight));\n }\n }, [fillShare, wrapperEl]);\n\n // Anything focusable left in a layer `useApexChartSemantics` hides gets\n // tabindex -1.\n useNeutraliseHiddenFocus(liveWrapperRef);\n // A clipping parent (a Card) would cut off a tooltip Apex places\n // outside the chart.\n useKeepApexTooltipInside(liveWrapperRef);\n\n // A host's POSIX tag (it_IT.UTF-8) reads as BCP 47, else the UI language.\n const locale = canonicalLocale(\n localeProp ?? i18n.language ?? 'en',\n i18n.language,\n );\n\n /* ---- dev warning if title missing ------------------------------ */\n if (import.meta.env.DEV && !title) {\n console.warn(\n 'Chart: `title` prop is required. It drives aria-label and the screen-reader summary table.',\n );\n }\n\n /* ---- theme-reactive state -------------------------------------- */\n const [themeOptions, setThemeOptions] = useState<ApexChartsTheme>(() => {\n try {\n return getApexChartsTheme();\n } catch {\n return {};\n }\n });\n\n /* ---- MutationObserver: re-read theme on class change ------------ */\n useEffect(() => {\n if (typeof document === 'undefined') return undefined;\n let timer: ReturnType<typeof setTimeout>;\n const observer = new MutationObserver(() => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n try {\n setThemeOptions(getApexChartsTheme());\n } catch {\n /* no-op in non-browser environments */\n }\n }, 50);\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class'],\n });\n return () => {\n clearTimeout(timer);\n observer.disconnect();\n };\n }, []);\n\n /* ---- toolbar band ----------------------------------------------- */\n // The toolbar buttons are --min-target-size boxes under a focus-ring gap\n // (apexcharts-theme.css); this many px stay clear above the plot. Read\n // from <html> first so the first render is already right.\n const [toolbarBand, setToolbarBand] = useState(() =>\n typeof document === 'undefined'\n ? 0\n : toolbarBandOf(document.documentElement),\n );\n useEffect(() => {\n if (!wrapperEl || !toolbar) return undefined;\n // A narrow chart wraps the toolbar onto more rows: reserve what it takes.\n const sized = new ResizeObserver(() => measure());\n const measure = () => {\n const bar = wrapperEl.querySelector<HTMLElement>('.apexcharts-toolbar');\n if (bar) sized.observe(bar);\n setToolbarBand(\n Math.max(toolbarBandOf(wrapperEl), bar?.offsetHeight ?? 0),\n );\n };\n measure();\n // A theme class can change on any ancestor (a nested ThemeRoot), and\n // ApexCharts rebuilds the toolbar on every update.\n const themes = new MutationObserver(measure);\n for (\n let node = wrapperEl.parentElement;\n node;\n node = node.parentElement\n ) {\n themes.observe(node, { attributes: true, attributeFilter: ['class'] });\n }\n const rebuilds = new MutationObserver((records) => {\n const added = records.flatMap((record) => [...record.addedNodes]);\n if (\n added.some(\n (node) =>\n node instanceof Element &&\n (node.matches('.apexcharts-toolbar') ||\n node.querySelector('.apexcharts-toolbar')),\n )\n ) {\n measure();\n }\n });\n rebuilds.observe(wrapperEl, { childList: true, subtree: true });\n return () => {\n sized.disconnect();\n themes.disconnect();\n rebuilds.disconnect();\n };\n }, [wrapperEl, toolbar]);\n\n /* ---- ResizeObserver: track container width --------------------- */\n useEffect(() => {\n const el = wrapperEl;\n if (!el || typeof ResizeObserver === 'undefined') return undefined;\n const ro = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (!entry) return;\n setContainerWidth(Math.floor(entry.contentRect.width));\n // A filled figure's height is set by its parent, never by what\n // ApexCharts draws inside it, so this cannot feed back.\n if (fillsRef.current) {\n setFillHeight(Math.floor(entry.contentRect.height));\n }\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, [wrapperEl]);\n\n /* ---- type switcher ---------------------------------------------- */\n const switcherTypes = useMemo<SwitchableType[]>(() => {\n if (!switchableTypes || switchableTypes.length === 0) return [];\n const valid = switchableTypes.filter((entry): entry is SwitchableType =>\n SWITCHABLE_TYPES.includes(entry),\n );\n if (import.meta.env.DEV && valid.length !== switchableTypes.length) {\n console.warn(\n \"Chart: `switchableTypes` accepts 'line' | 'bar' | 'area' | 'pie' | 'donut' — other entries are ignored.\",\n );\n }\n if (!SWITCHABLE_TYPES.includes(type)) {\n if (import.meta.env.DEV && valid.length > 0) {\n console.warn(\n 'Chart: the type switcher is unavailable when `type` is \"radialBar\".',\n );\n }\n return [];\n }\n const withCurrent = valid.includes(type as SwitchableType)\n ? valid\n : [type as SwitchableType, ...valid];\n return [...new Set(withCurrent)];\n }, [switchableTypes, type]);\n const switcherEnabled = switcherTypes.length >= 2;\n\n const [pickedType, setPickedType] = useState<SwitchableType | null>(null);\n const effectiveType: ChartType =\n switcherEnabled && pickedType && switcherTypes.includes(pickedType)\n ? pickedType\n : type;\n\n // Hide the plot and hover aids; keep the legend and toolbar buttons\n // reachable. Pie and donut legend items select a slice, not hide it.\n useApexChartSemantics(\n wrapperEl,\n effectiveType !== 'pie' && effectiveType !== 'donut',\n );\n\n /* ---- data adaptation for the switcher --------------------------- */\n /* Axis and slice types read different `series` shapes. When the user */\n /* switches across that boundary the data adapts: each axis series */\n /* becomes one slice (its total across the categories), and slice */\n /* values become one axis series with `labels` as the categories. */\n /* Same-shape switches (line/bar/area, pie/donut) pass through as-is. */\n const declaredIsSlice = isSliceType(type);\n const effectiveIsSlice = isSliceType(effectiveType);\n // Series pushed through the handle, held in state because react-apexcharts\n // re-sends the props' series on every option or size update.\n const [pushed, setPushed] = useState<{\n base: ChartProps['series'];\n next: ChartProps['series'];\n } | null>(null);\n // A new `series` prop always wins and forgets the pushed data, so a host\n // that later passes an earlier array again sees that array, not data it\n // pushed while that array was last on screen (reset during render, the\n // React pattern for state derived from a prop).\n const [pushedFor, setPushedFor] = useState(series);\n if (pushedFor !== series) {\n setPushedFor(series);\n if (pushed) setPushed(null);\n }\n const liveSeries =\n pushed && pushed.base === series && pushedFor === series\n ? pushed.next\n : series;\n const seriesPropRef = useRef(series);\n seriesPropRef.current = series;\n const { effectiveSeries, effectiveCategories, effectiveLabels } = useMemo(\n () =>\n adaptSeries(\n liveSeries,\n categories,\n labels,\n declaredIsSlice,\n effectiveIsSlice,\n t('chart.table.value'),\n ),\n [liveSeries, categories, labels, declaredIsSlice, effectiveIsSlice, t],\n );\n // The same adaptation for the handle, with this render's inputs.\n const adapt = (next: ChartProps['series']) =>\n adaptSeries(\n next,\n categories,\n labels,\n declaredIsSlice,\n effectiveIsSlice,\n t('chart.table.value'),\n );\n const adaptRef = useRef(adapt);\n adaptRef.current = adapt;\n // The draw a pushed series started, so an export in the same turn waits.\n const pendingDraw = useRef<Promise<unknown>>(Promise.resolve());\n\n /* ---- imperative handle ----------------------------------------- */\n const agentHandle = useMemo<ChartHandle>(\n () => ({\n async dataURI(): Promise<string> {\n await pendingDraw.current;\n const instance = ApexCharts.getChartByID(chartId);\n if (!instance) return '';\n const result = await instance.dataURI();\n return (result as { imgURI: string }).imgURI;\n },\n updateSeries(next) {\n // React state keeps it for later renders. Draw it now as well, with\n // the options that view takes (compare styling, slice labels), so an\n // export in the same turn sees both.\n setPushed({ base: seriesPropRef.current, next });\n const instance = ApexCharts.getChartByID(chartId);\n if (!instance) return;\n const view = adaptRef.current(next);\n const inputs = { ...optionInputsRef.current, ...view };\n pendingDraw.current = instance\n .updateOptions(\n { ...buildChartOptions(inputs), series: view.effectiveSeries },\n false,\n true,\n )\n .catch(() => undefined);\n },\n setType(next: ChartType): boolean {\n if (!switcherEnabled) return false;\n if (!switcherTypes.includes(next as SwitchableType)) return false;\n setPickedType(next as SwitchableType);\n return true;\n },\n getTypeState() {\n return {\n declaredType: type,\n effectiveType,\n availableTypes: switcherEnabled\n ? ([...switcherTypes] as ChartType[])\n : [],\n };\n },\n }),\n [chartId, type, effectiveType, switcherEnabled, switcherTypes],\n );\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n useAgentRegistration(chartAgent, agentHandle, id);\n\n /* ---- RTL detection --------------------------------------------- */\n const isRtl =\n typeof document !== 'undefined' && document.documentElement.dir === 'rtl';\n\n /* ---- normalised series for sr-only table ----------------------- */\n const tableSeries = useMemo(\n () => normaliseSeries(effectiveSeries, effectiveType),\n [effectiveSeries, effectiveType],\n );\n\n /* ---- Intl formatter -------------------------------------------- */\n const numberFormatter = useMemo(\n () => new Intl.NumberFormat(locale),\n [locale],\n );\n\n /* ---- resolved value formatter ---------------------------------- */\n /* The consumer's `valueFormatter` (e.g. a currency formatter) wins */\n /* everywhere a data-point value is surfaced as text; otherwise we */\n /* fall back to the locale-aware grouped number. */\n const formatValue = useMemo(\n () =>\n valueFormatter ?? ((value: number) => numberFormatter.format(value)),\n [valueFormatter, numberFormatter],\n );\n\n /* ---- toolbar localisation -------------------------------------- */\n const toolbarLocale = useMemo(\n () => ({\n name: locale,\n options: {\n toolbar: {\n download: t('chart.toolbar.download'),\n // Names the button that opens the export menu (Apex: \"Menu\").\n menu: t('chart.toolbar.download'),\n selection: t('chart.toolbar.selection'),\n selectionZoom: t('chart.toolbar.selectionZoom'),\n zoomIn: t('chart.toolbar.zoomIn'),\n zoomOut: t('chart.toolbar.zoomOut'),\n pan: t('chart.toolbar.pan'),\n reset: t('chart.toolbar.reset'),\n exportToSVG: t('chart.toolbar.exportToSVG'),\n exportToPNG: t('chart.toolbar.exportToPNG'),\n exportToCSV: t('chart.toolbar.exportToCSV'),\n },\n },\n }),\n [locale, t],\n );\n\n /* ---- build ApexOptions ----------------------------------------- */\n const reducedMotion = usePrefersReducedMotion();\n\n const noDataText = t('chart.noData');\n // The chart's own width, so `width=\"50%\"` of a wide wrapper can be narrow.\n // ApexCharts draws into a full-width block in the measured wrapper.\n const chartWidth = drawnWidth(width, containerWidth);\n const narrow = chartWidth > 0 && chartWidth < NARROW_CHART_WIDTH;\n\n /* ---- resolved dimensions --------------------------------------- */\n const resolvedWidth =\n width ?? (containerWidth > 0 ? containerWidth : '100%');\n // A filled figure is never shorter than its CSS floor, so once measured\n // it is drawn at exactly its height.\n const resolvedHeight = fillShare\n ? fillHeight > 0\n ? fillHeight\n : MIN_FILL_HEIGHT\n : (height ?? 320);\n // A short chart's legend keeps to one row, faded where it hides items,\n // and its plot takes back ApexCharts' title allowance.\n const chartHeight = drawnHeight(resolvedHeight);\n const shortChart = chartHeight > 0 && chartHeight < SHORT_CHART_HEIGHT;\n useApexLegendScroll(wrapperEl, shortChart);\n useApexXLabelSpacing(wrapperEl);\n useApexRadialCentre(wrapperEl, effectiveType === 'radialBar', locale);\n // A formatter that ignores its value (the single-ring `() => '22.4'`)\n // prints one figure for every ring of several. Warned once per chart.\n const warnedFixedRef = useRef(false);\n useEffect(() => {\n if (!import.meta.env.DEV || effectiveType !== 'radialBar') return;\n if (warnedFixedRef.current) return;\n if (!radialValueFormatter || !Array.isArray(effectiveSeries)) return;\n const values = (effectiveSeries as number[]).map(Number);\n if (\n new Set(values).size > 1 &&\n new Set(values.map((value) => radialValueFormatter(value))).size === 1\n ) {\n warnedFixedRef.current = true;\n console.warn(\n 'Chart: radialValueFormatter returns the same text for every ring. With several rings it is called with each ring’s own value: format that value.',\n );\n }\n }, [effectiveType, radialValueFormatter, effectiveSeries]);\n\n const optionInputs = useMemo<ChartOptionInputs>(\n () => ({\n themeOptions,\n toolbarBand,\n chartId,\n toolbar,\n reducedMotion,\n toolbarLocale,\n locale,\n effectiveLabels,\n formatValue,\n noDataText,\n effectiveType,\n effectiveSeries,\n effectiveCategories,\n isRtl,\n patterns,\n stacked,\n orientation,\n curve,\n colors,\n radialValueFormatter,\n narrow,\n short: shortChart,\n wrapperRef,\n }),\n [\n themeOptions,\n toolbarBand,\n chartId,\n toolbar,\n reducedMotion,\n toolbarLocale,\n locale,\n effectiveLabels,\n formatValue,\n noDataText,\n effectiveType,\n effectiveSeries,\n effectiveCategories,\n isRtl,\n patterns,\n stacked,\n orientation,\n curve,\n colors,\n radialValueFormatter,\n narrow,\n shortChart,\n ],\n );\n const chartOptions = useMemo(\n () => buildChartOptions(optionInputs),\n [optionInputs],\n );\n // This render's inputs, for the handle to build options for pushed series.\n const optionInputsRef = useRef(optionInputs);\n optionInputsRef.current = optionInputs;\n\n /* ---- sr-only data table --------------------------------------- */\n const srTable = useMemo(() => {\n const columnLabels = isSliceType(effectiveType)\n ? (effectiveLabels ?? [])\n : (effectiveCategories ?? []);\n const rows = tableSeries;\n const cellText =\n effectiveType === 'radialBar'\n ? radialText(locale, radialValueFormatter)\n : formatValue;\n // `sr-only` goes on a wrapper: a table ignores its 1px size and overflow,\n // so on the table itself it grew to every header's width and scrolled.\n return (\n <div className=\"ds:sr-only\">\n <table id={summaryId}>\n <caption>{title}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{t('chart.table.series')}</th>\n {columnLabels.map((col, i) => (\n <th key={`${col}-${i}`} scope=\"col\">\n {col}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={`${row.name}-${rowIndex}`}>\n <th scope=\"row\">{row.name || t('chart.table.value')}</th>\n {row.data.map((value, colIndex) => (\n <td key={`${rowIndex}-${colIndex}`}>\n {/* For a radialBar gauge the series is a synthetic arc\n percent — announce the consumer's display value (e.g.\n the real BMI) instead of the raw fill so AT users get\n the same figure sighted users see in the ring. */}\n {cellText(value)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n }, [\n effectiveType,\n tableSeries,\n effectiveLabels,\n effectiveCategories,\n summaryId,\n title,\n t,\n formatValue,\n radialValueFormatter,\n locale,\n ]);\n\n /* ---- ApexCharts `series` prop shape ----------------------------- */\n const apexSeries = useMemo(() => {\n if (isSliceType(effectiveType)) {\n return effectiveSeries as number[];\n }\n return effectiveSeries as ChartSeries[];\n }, [effectiveSeries, effectiveType]);\n\n // Inline style permitted per 23-constraints §Runtime-computed dimensions:\n // a custom property setter; the block-size rule lives in the CVA classes.\n const fillStyle = fillShare\n ? ({\n ['--chart-fill-size' as unknown as keyof CSSProperties]: fillShare,\n } as CSSProperties)\n : undefined;\n\n /* A figure, not `role=\"img\"`, whose children are presentational and so may\n not hold the legend and toolbar buttons. `key={effectiveType}` remounts\n ApexCharts on a type switch: in-place axis↔slice changes are unreliable. */\n const chartRegion = (\n <div\n ref={wrapperCallbackRef}\n role=\"figure\"\n aria-label={title}\n aria-describedby={summaryId}\n data-legend-layout={shortChart ? 'row' : undefined}\n className={chartVariants({\n // Explicit height wins over the density min-height unless the\n // caller also asked for a density explicitly.\n // A `%` height takes its height from the parent, never a density.\n density: fillShare\n ? 'none'\n : (density ?? (height !== undefined ? 'none' : undefined)),\n className: [\n chartFillVariants({\n fill: fillShare ? (switcherEnabled ? 'rest' : 'root') : 'none',\n }),\n switcherEnabled ? undefined : className,\n ]\n .filter(Boolean)\n .join(' '),\n })}\n // eslint-disable-next-line react/forbid-dom-props -- the `%` height share\n style={switcherEnabled ? undefined : fillStyle}\n {...(switcherEnabled\n ? {}\n : { 'data-component': 'chart', 'data-component-id': id })}\n >\n {srTable}\n <ReactApexChart\n key={effectiveType}\n className={chartPlotVariants({ fill: fillShare !== undefined })}\n type={effectiveType}\n series={apexSeries as ApexCharts.ApexOptions['series']}\n options={chartOptions}\n width={resolvedWidth}\n height={resolvedHeight}\n />\n </div>\n );\n\n if (!switcherEnabled) return chartRegion;\n\n /* The switcher renders as a sibling above the figure, and the bounding\n `data-component` marker moves to this shared wrapper so the component\n boundary still encloses everything. */\n return (\n <div\n data-component=\"chart\"\n data-component-id={id}\n className={chartFrameVariants({\n fill: fillShare !== undefined,\n className,\n })}\n // eslint-disable-next-line react/forbid-dom-props -- the `%` height share\n style={fillStyle}\n >\n <div className=\"ds:mb-[var(--spacing-xs)] ds:flex ds:justify-end\">\n <IconButtonGroup\n role=\"radiogroup\"\n mode=\"toggle-single\"\n size=\"sm\"\n aria-label={t('chart.typeSwitcher.label')}\n value={effectiveType}\n onValueChange={(next) => {\n // Guard: keyboard paths can re-commit the current value; the\n // contract is \"called when the user picks a DIFFERENT type\".\n if (next === effectiveType) return;\n setPickedType(next as SwitchableType);\n onTypeChange?.(next as ChartType);\n }}\n >\n {switcherTypes.map((entry) => (\n <IconButton\n key={entry}\n value={entry}\n // Explicit — the default (submit) would post a surrounding\n // consumer <form> on click/Space.\n type=\"button\"\n icon={TYPE_SWITCHER_ICONS[entry]}\n aria-label={t(TYPE_SWITCHER_LABEL_KEYS[entry])}\n />\n ))}\n </IconButtonGroup>\n </div>\n {chartRegion}\n </div>\n );\n },\n);\n\nChart.displayName = 'Chart';\n\n/* ------------------------------------------------------------------ */\n/* Re-export internal helper for downstream theming (kept narrow). */\n/* ------------------------------------------------------------------ */\n\nexport { chartVariants };\n"],"names":["__iconNode","ChartArea","createLucideIcon","ChartColumn","ChartLine","ChartPie","Donut","CONTROL_LAYERS","setAttr","el","name","value","useApexChartSemantics","root","legendToggles","useEffect","apply","canvas","layer","toolbar","open","_a","item","shown","frame","onClick","event","rel","active","observer","ITEM","TEXT","ITEM_SIZE","VALUE_SIZE","VALUE","NAME","TAP_CLICK_MS","setFlag","on","px","style","property","useApexLegendScroll","enabled","legend","fromStartSeen","measure","fromStart","maxScroll","restore","sign","fit","view","items","inline","box","part","values","own","chrome","child","start","end","before","i","floors","floor","gap","needed","sum","each","whole","size","sized","fonts","refit","bind","current","rebuilt","pressed","pressFrame","pressTimer","onRow","unpress","press","lift","clicked","bringIn","row","left","right","reveal","target","settle","text","cut","full","inLegend","node","rebuilds","records","record","LABEL","GAP_EM","cornersOf","label","matrix","x","y","width","height","py","point","apart","a","b","shape","corner","next","nx","ny","length","project","points","p","pa","pb","useApexXLabelSpacing","space","labels","shapes","fits","step","inXAxis","redraws","SVG_NS","GROUP","HOLLOW","SIZE","FLOOR","STEP_PX","INSET_PX","SOURCE","LINE","CJK","NO_LINE_START","NO_LINE_END","segmenterFor","locale","splits","options","segmenter","parts","at","cjk","first","second","useApexRadialCentre","place","group","hollow","fromHole","fromLabels","toLabels","centre","radius","cx","cy","inside","top","bottom","dy","source","sizeOf","floorOf","valueSize","valueWidth","valuePitch","half","scale","gapFor","lines","pitchPerPx","chosen","nameStart","pairs","tries","sizes","pitch","widths","linesFit","valueTop","namePitch","line","span","inCentre","themeClasses","themes","chartAgent","handle","args","chartVariants","cva","chartFillVariants","chartPlotVariants","chartFrameVariants","PATTERN_STYLES","CATEGORICAL_TYPES","SLICE_TYPES","SWITCHABLE_TYPES","TYPE_SWITCHER_LABEL_KEYS","TYPE_SWITCHER_ICONS","COMPARE_OUTLINE_WIDTH","COMPARE_DOT_DASH","APEX_TITLE_MARGIN","APEX_TITLE_ALLOWANCE","APEX_LABEL_ROTATE","NARROW_CHART_WIDTH","SHORT_CHART_HEIGHT","MIN_FILL_HEIGHT","patchCompareBars","compareRealIndexes","g","ri","toolbarBandOf","styles","token","drawnWidth","into","radialText","radialValueFormatter","percent","drawnHeight","adaptSeries","series","categories","declaredIsSlice","effectiveIsSlice","valueName","rows","v","buildChartOptions","themeOptions","toolbarBand","chartId","reducedMotion","toolbarLocale","effectiveLabels","formatValue","noDataText","effectiveType","effectiveSeries","effectiveCategories","isRtl","patterns","stacked","orientation","curve","colors","narrow","short","wrapperRef","base","compareFlags","isCategoricalType","hasCompare","barCompare","compareHasNegative","openBottomBars","compareFillOpacity","getCompareFillOpacity","escapeHtml","opts","band","reclaim","ramp","rampAt","primaryIdx","s","seen","pair","compareTints","c","resolveCompareTint","_b","horizontalBar","_c","ringValue","basePlot","_d","_e","val","rings","dir","run","raf","_f","withCompareKeys","type","events","isSliceType","normaliseSeries","Chart","forwardRef","title","id","localeProp","valueFormatter","switchableTypes","onTypeChange","density","className","ref","t","i18n","useTranslation","rawId","useId","useMemo","summaryId","useRef","wrapperEl","setWrapperEl","useState","wrapperCallbackRef","composeRefs","liveWrapperRef","containerWidth","setContainerWidth","fillShare","fillHeight","setFillHeight","fillsRef","useIsomorphicLayoutEffect","useNeutraliseHiddenFocus","useKeepApexTooltipInside","canonicalLocale","setThemeOptions","getApexChartsTheme","timer","setToolbarBand","bar","ro","entries","entry","switcherTypes","valid","withCurrent","switcherEnabled","pickedType","setPickedType","pushed","setPushed","pushedFor","setPushedFor","liveSeries","seriesPropRef","adapt","adaptRef","pendingDraw","agentHandle","instance","ApexCharts","inputs","optionInputsRef","useImperativeHandle","useAgentRegistration","tableSeries","numberFormatter","usePrefersReducedMotion","chartWidth","resolvedWidth","resolvedHeight","chartHeight","shortChart","optionInputs","chartOptions","srTable","columnLabels","cellText","jsxs","jsx","col","rowIndex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