@alfadocs/ui-kit-debug 1.29.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/_chunks/{address-fields-CZ0pEdEI.js → address-fields-jFfjxOQR.js} +3 -3
  2. package/dist/_chunks/{address-fields-CZ0pEdEI.js.map → address-fields-jFfjxOQR.js.map} +1 -1
  3. package/dist/_chunks/{anamnesis-summary-rows-DwjqZgR5.js → anamnesis-summary-rows-DMO3MWSt.js} +2 -2
  4. package/dist/_chunks/{anamnesis-summary-rows-DwjqZgR5.js.map → anamnesis-summary-rows-DMO3MWSt.js.map} +1 -1
  5. package/dist/_chunks/{appointment-card-Dzr3GeVz.js → appointment-card-CvUFFEdS.js} +8 -6
  6. package/dist/_chunks/appointment-card-CvUFFEdS.js.map +1 -0
  7. package/dist/_chunks/{appointment-timeline-DhHwmHo1.js → appointment-timeline-DsMZY7U9.js} +2 -2
  8. package/dist/_chunks/{appointment-timeline-DhHwmHo1.js.map → appointment-timeline-DsMZY7U9.js.map} +1 -1
  9. package/dist/_chunks/{appointment-tray-4FUu_5NX.js → appointment-tray-Z2GaOIYQ.js} +2 -2
  10. package/dist/_chunks/{appointment-tray-4FUu_5NX.js.map → appointment-tray-Z2GaOIYQ.js.map} +1 -1
  11. package/dist/_chunks/{booking-AabCk7CI.js → booking-jGzRUETo.js} +2 -2
  12. package/dist/_chunks/{booking-AabCk7CI.js.map → booking-jGzRUETo.js.map} +1 -1
  13. package/dist/_chunks/{calendar-CI9MINcR.js → calendar-BNQKpxhE.js} +494 -438
  14. package/dist/_chunks/calendar-BNQKpxhE.js.map +1 -0
  15. package/dist/_chunks/{calendar-event-card-66CEEWU6.js → calendar-event-card-DSh-69HT.js} +130 -122
  16. package/dist/_chunks/calendar-event-card-DSh-69HT.js.map +1 -0
  17. package/dist/_chunks/calendar-workspace-Dy1jHBvG.js +9392 -0
  18. package/dist/_chunks/calendar-workspace-Dy1jHBvG.js.map +1 -0
  19. package/dist/_chunks/{clinical-note-card-BBgFd2nB.js → clinical-note-card-yCTR9DB6.js} +185 -188
  20. package/dist/_chunks/clinical-note-card-yCTR9DB6.js.map +1 -0
  21. package/dist/_chunks/{color-picker-CU303VjY.js → color-picker-Bl5f0iK1.js} +28 -25
  22. package/dist/_chunks/color-picker-Bl5f0iK1.js.map +1 -0
  23. package/dist/_chunks/{combobox-D7_NLE2Z.js → combobox-DnSdYssy.js} +216 -215
  24. package/dist/_chunks/combobox-DnSdYssy.js.map +1 -0
  25. package/dist/_chunks/{country-select-DzbPFktV.js → country-select-CfDNFG5c.js} +2 -2
  26. package/dist/_chunks/{country-select-DzbPFktV.js.map → country-select-CfDNFG5c.js.map} +1 -1
  27. package/dist/_chunks/{face-scheme-DA2vjqaM.js → face-scheme-l-CQyLs-.js} +2 -2
  28. package/dist/_chunks/{face-scheme-DA2vjqaM.js.map → face-scheme-l-CQyLs-.js.map} +1 -1
  29. package/dist/_chunks/notes-panel-am6e-Lwh.js +380 -0
  30. package/dist/_chunks/notes-panel-am6e-Lwh.js.map +1 -0
  31. package/dist/_chunks/{patient-details-DYAmq76G.js → patient-details-CdfursHt.js} +3 -3
  32. package/dist/_chunks/{patient-details-DYAmq76G.js.map → patient-details-CdfursHt.js.map} +1 -1
  33. package/dist/_chunks/{province-select-BBc7s7vR.js → province-select-BaUnkg4S.js} +2 -2
  34. package/dist/_chunks/{province-select-BBc7s7vR.js.map → province-select-BaUnkg4S.js.map} +1 -1
  35. package/dist/_chunks/{rich-text-editor-lSCiE0Zz.js → rich-text-editor-VJATL1Tk.js} +2 -2
  36. package/dist/_chunks/{rich-text-editor-lSCiE0Zz.js.map → rich-text-editor-VJATL1Tk.js.map} +1 -1
  37. package/dist/_chunks/{sparkline-BmGcEyZO.js → sparkline-Dx_sxK3J.js} +228 -198
  38. package/dist/_chunks/sparkline-Dx_sxK3J.js.map +1 -0
  39. package/dist/_chunks/{timeline-r-8IUoBS.js → timeline-u-2t9t_M.js} +37 -35
  40. package/dist/_chunks/timeline-u-2t9t_M.js.map +1 -0
  41. package/dist/_chunks/use-zoom-drilldown-qCX34w9I.js +210 -0
  42. package/dist/_chunks/use-zoom-drilldown-qCX34w9I.js.map +1 -0
  43. package/dist/agent-catalog.json +55 -11
  44. package/dist/agent-i18n/en.json +10 -8
  45. package/dist/components/_shared/get-error-message.d.ts +3 -0
  46. package/dist/components/_shared/get-error-message.d.ts.map +1 -0
  47. package/dist/components/address-fields/index.js +1 -1
  48. package/dist/components/appointment-card/appointment-card.d.ts.map +1 -1
  49. package/dist/components/appointment-card/index.js +2 -2
  50. package/dist/components/appointment-timeline/index.js +1 -1
  51. package/dist/components/booking/index.js +1 -1
  52. package/dist/components/calendar/calendar.d.ts +26 -2
  53. package/dist/components/calendar/calendar.d.ts.map +1 -1
  54. package/dist/components/calendar/index.js +1 -1
  55. package/dist/components/calendar-event-card/calendar-event-card.d.ts +9 -0
  56. package/dist/components/calendar-event-card/calendar-event-card.d.ts.map +1 -1
  57. package/dist/components/calendar-event-card/index.js +1 -1
  58. package/dist/components/clinical-note-card/clinical-note-card.d.ts +16 -1
  59. package/dist/components/clinical-note-card/clinical-note-card.d.ts.map +1 -1
  60. package/dist/components/clinical-note-card/index.js +1 -1
  61. package/dist/components/color-picker/color-utils.d.ts.map +1 -1
  62. package/dist/components/color-picker/index.js +1 -1
  63. package/dist/components/combobox/combobox.d.ts +5 -0
  64. package/dist/components/combobox/combobox.d.ts.map +1 -1
  65. package/dist/components/combobox/index.js +1 -1
  66. package/dist/components/country-select/index.js +1 -1
  67. package/dist/components/face-scheme/index.js +1 -1
  68. package/dist/components/index.d.ts +2 -2
  69. package/dist/components/index.d.ts.map +1 -1
  70. package/dist/components/notes-panel/index.d.ts +1 -1
  71. package/dist/components/notes-panel/index.d.ts.map +1 -1
  72. package/dist/components/notes-panel/index.js +1 -1
  73. package/dist/components/notes-panel/notes-panel.agent.d.ts.map +1 -1
  74. package/dist/components/notes-panel/notes-panel.d.ts +24 -5
  75. package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
  76. package/dist/components/patient-details/index.js +1 -1
  77. package/dist/components/province-select/index.js +1 -1
  78. package/dist/components/rich-text-editor/index.js +1 -1
  79. package/dist/components/sparkline/index.js +1 -1
  80. package/dist/components/sparkline/sparkline.agent.d.ts.map +1 -1
  81. package/dist/components/sparkline/sparkline.d.ts +6 -0
  82. package/dist/components/sparkline/sparkline.d.ts.map +1 -1
  83. package/dist/components/timeline/index.js +1 -1
  84. package/dist/components/timeline/timeline.d.ts +2 -0
  85. package/dist/components/timeline/timeline.d.ts.map +1 -1
  86. package/dist/hooks/index.d.ts +1 -0
  87. package/dist/hooks/index.d.ts.map +1 -1
  88. package/dist/hooks/index.js +56 -54
  89. package/dist/hooks/use-zoom-drilldown.d.ts +23 -0
  90. package/dist/hooks/use-zoom-drilldown.d.ts.map +1 -0
  91. package/dist/host-compat.css +10 -1
  92. package/dist/i18n/locales/ar.d.ts +50 -0
  93. package/dist/i18n/locales/ar.d.ts.map +1 -1
  94. package/dist/i18n/locales/ar.js +54 -4
  95. package/dist/i18n/locales/ar.js.map +1 -1
  96. package/dist/i18n/locales/de.d.ts +60 -10
  97. package/dist/i18n/locales/de.d.ts.map +1 -1
  98. package/dist/i18n/locales/de.js +64 -14
  99. package/dist/i18n/locales/de.js.map +1 -1
  100. package/dist/i18n/locales/el.d.ts +50 -0
  101. package/dist/i18n/locales/el.d.ts.map +1 -1
  102. package/dist/i18n/locales/el.js +54 -4
  103. package/dist/i18n/locales/el.js.map +1 -1
  104. package/dist/i18n/locales/en.d.ts +50 -0
  105. package/dist/i18n/locales/en.d.ts.map +1 -1
  106. package/dist/i18n/locales/en.js +54 -4
  107. package/dist/i18n/locales/en.js.map +1 -1
  108. package/dist/i18n/locales/es.d.ts +50 -0
  109. package/dist/i18n/locales/es.d.ts.map +1 -1
  110. package/dist/i18n/locales/es.js +54 -4
  111. package/dist/i18n/locales/es.js.map +1 -1
  112. package/dist/i18n/locales/fr.d.ts +50 -0
  113. package/dist/i18n/locales/fr.d.ts.map +1 -1
  114. package/dist/i18n/locales/fr.js +53 -3
  115. package/dist/i18n/locales/fr.js.map +1 -1
  116. package/dist/i18n/locales/hi.d.ts +50 -0
  117. package/dist/i18n/locales/hi.d.ts.map +1 -1
  118. package/dist/i18n/locales/hi.js +54 -4
  119. package/dist/i18n/locales/hi.js.map +1 -1
  120. package/dist/i18n/locales/it.d.ts +60 -10
  121. package/dist/i18n/locales/it.d.ts.map +1 -1
  122. package/dist/i18n/locales/it.js +64 -14
  123. package/dist/i18n/locales/it.js.map +1 -1
  124. package/dist/i18n/locales/ja.d.ts +50 -0
  125. package/dist/i18n/locales/ja.d.ts.map +1 -1
  126. package/dist/i18n/locales/ja.js +54 -4
  127. package/dist/i18n/locales/ja.js.map +1 -1
  128. package/dist/i18n/locales/nl.d.ts +50 -0
  129. package/dist/i18n/locales/nl.d.ts.map +1 -1
  130. package/dist/i18n/locales/nl.js +54 -4
  131. package/dist/i18n/locales/nl.js.map +1 -1
  132. package/dist/i18n/locales/pl.d.ts +50 -0
  133. package/dist/i18n/locales/pl.d.ts.map +1 -1
  134. package/dist/i18n/locales/pl.js +54 -4
  135. package/dist/i18n/locales/pl.js.map +1 -1
  136. package/dist/i18n/locales/pt.d.ts +50 -0
  137. package/dist/i18n/locales/pt.d.ts.map +1 -1
  138. package/dist/i18n/locales/pt.js +54 -4
  139. package/dist/i18n/locales/pt.js.map +1 -1
  140. package/dist/i18n/locales/ro.d.ts +50 -0
  141. package/dist/i18n/locales/ro.d.ts.map +1 -1
  142. package/dist/i18n/locales/ro.js +53 -3
  143. package/dist/i18n/locales/ro.js.map +1 -1
  144. package/dist/i18n/locales/ru.d.ts +50 -0
  145. package/dist/i18n/locales/ru.d.ts.map +1 -1
  146. package/dist/i18n/locales/ru.js +54 -4
  147. package/dist/i18n/locales/ru.js.map +1 -1
  148. package/dist/i18n/locales/sq.d.ts +50 -0
  149. package/dist/i18n/locales/sq.d.ts.map +1 -1
  150. package/dist/i18n/locales/sq.js +54 -4
  151. package/dist/i18n/locales/sq.js.map +1 -1
  152. package/dist/i18n/locales/sv.d.ts +50 -0
  153. package/dist/i18n/locales/sv.d.ts.map +1 -1
  154. package/dist/i18n/locales/sv.js +54 -4
  155. package/dist/i18n/locales/sv.js.map +1 -1
  156. package/dist/i18n/locales/tr.d.ts +50 -0
  157. package/dist/i18n/locales/tr.d.ts.map +1 -1
  158. package/dist/i18n/locales/tr.js +54 -4
  159. package/dist/i18n/locales/tr.js.map +1 -1
  160. package/dist/i18n/locales/zh.d.ts +50 -0
  161. package/dist/i18n/locales/zh.d.ts.map +1 -1
  162. package/dist/i18n/locales/zh.js +54 -4
  163. package/dist/i18n/locales/zh.js.map +1 -1
  164. package/dist/index.js +1073 -1070
  165. package/dist/locales/ar.json +54 -4
  166. package/dist/locales/de.json +64 -14
  167. package/dist/locales/el.json +54 -4
  168. package/dist/locales/en.json +54 -4
  169. package/dist/locales/es.json +54 -4
  170. package/dist/locales/fr.json +53 -3
  171. package/dist/locales/hi.json +54 -4
  172. package/dist/locales/it.json +64 -14
  173. package/dist/locales/ja.json +54 -4
  174. package/dist/locales/nl.json +54 -4
  175. package/dist/locales/pl.json +54 -4
  176. package/dist/locales/pt.json +54 -4
  177. package/dist/locales/ro.json +53 -3
  178. package/dist/locales/ru.json +54 -4
  179. package/dist/locales/sq.json +54 -4
  180. package/dist/locales/sv.json +54 -4
  181. package/dist/locales/tr.json +54 -4
  182. package/dist/locales/zh.json +54 -4
  183. package/dist/patterns/anamnesis/index.js +1 -1
  184. package/dist/patterns/calendar/calendar-appointment-details.d.ts +145 -0
  185. package/dist/patterns/calendar/calendar-appointment-details.d.ts.map +1 -0
  186. package/dist/patterns/calendar/calendar-appointment-details.sections.d.ts +32 -0
  187. package/dist/patterns/calendar/calendar-appointment-details.sections.d.ts.map +1 -0
  188. package/dist/patterns/calendar/calendar-editor-hydration.d.ts +59 -0
  189. package/dist/patterns/calendar/calendar-editor-hydration.d.ts.map +1 -0
  190. package/dist/patterns/calendar/calendar-notes-tool.d.ts +14 -0
  191. package/dist/patterns/calendar/calendar-notes-tool.d.ts.map +1 -0
  192. package/dist/patterns/calendar/calendar-patient-picker.d.ts +11 -0
  193. package/dist/patterns/calendar/calendar-patient-picker.d.ts.map +1 -0
  194. package/dist/patterns/calendar/calendar-series-scope-chooser.d.ts +18 -0
  195. package/dist/patterns/calendar/calendar-series-scope-chooser.d.ts.map +1 -0
  196. package/dist/patterns/calendar/calendar-workspace.d.ts +26 -1
  197. package/dist/patterns/calendar/calendar-workspace.d.ts.map +1 -1
  198. package/dist/patterns/calendar/calendar-workspace.model.d.ts +8 -5
  199. package/dist/patterns/calendar/calendar-workspace.model.d.ts.map +1 -1
  200. package/dist/patterns/calendar/calendar.data.d.ts +66 -1
  201. package/dist/patterns/calendar/calendar.data.d.ts.map +1 -1
  202. package/dist/patterns/calendar/calendar.host.d.ts +2 -0
  203. package/dist/patterns/calendar/calendar.host.d.ts.map +1 -1
  204. package/dist/patterns/calendar/calendar.journey.d.ts +42 -7
  205. package/dist/patterns/calendar/calendar.journey.d.ts.map +1 -1
  206. package/dist/patterns/calendar/calendar.model.d.ts +54 -5
  207. package/dist/patterns/calendar/calendar.model.d.ts.map +1 -1
  208. package/dist/patterns/calendar/calendar.sheets.d.ts +68 -15
  209. package/dist/patterns/calendar/calendar.sheets.d.ts.map +1 -1
  210. package/dist/patterns/calendar/calendar.surface.d.ts +12 -2
  211. package/dist/patterns/calendar/calendar.surface.d.ts.map +1 -1
  212. package/dist/patterns/calendar/calendar.types.d.ts +29 -1
  213. package/dist/patterns/calendar/calendar.types.d.ts.map +1 -1
  214. package/dist/patterns/calendar/index.d.ts +9 -6
  215. package/dist/patterns/calendar/index.d.ts.map +1 -1
  216. package/dist/patterns/calendar/index.js +15 -14
  217. package/dist/tokens.css +10 -2
  218. package/package.json +1 -1
  219. package/dist/_chunks/appointment-card-Dzr3GeVz.js.map +0 -1
  220. package/dist/_chunks/calendar-CI9MINcR.js.map +0 -1
  221. package/dist/_chunks/calendar-event-card-66CEEWU6.js.map +0 -1
  222. package/dist/_chunks/calendar-workspace-a84AHQwj.js +0 -7506
  223. package/dist/_chunks/calendar-workspace-a84AHQwj.js.map +0 -1
  224. package/dist/_chunks/clinical-note-card-BBgFd2nB.js.map +0 -1
  225. package/dist/_chunks/color-picker-CU303VjY.js.map +0 -1
  226. package/dist/_chunks/combobox-D7_NLE2Z.js.map +0 -1
  227. package/dist/_chunks/notes-panel-CTNpsByN.js +0 -353
  228. package/dist/_chunks/notes-panel-CTNpsByN.js.map +0 -1
  229. package/dist/_chunks/sparkline-BmGcEyZO.js.map +0 -1
  230. package/dist/_chunks/timeline-r-8IUoBS.js.map +0 -1
  231. package/dist/_chunks/use-signing-session-CyOZWinp.js +0 -147
  232. package/dist/_chunks/use-signing-session-CyOZWinp.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkline-Dx_sxK3J.js","sources":["../../src/components/sparkline/use-linear-trend.ts","../../src/components/sparkline/sparkline.agent.ts","../../src/components/sparkline/sparkline.tsx"],"sourcesContent":["export type TrendDirection = 'increasing' | 'decreasing' | 'steady';\n\nexport interface LinearTrendResult {\n slope: number;\n direction: TrendDirection;\n}\n\nexport function useLinearTrend(data: number[]): LinearTrendResult {\n if (data.length < 2) {\n return { slope: 0, direction: 'steady' };\n }\n\n const n = data.length;\n const xMean = (n - 1) / 2;\n const yMean = data.reduce((sum, y) => sum + y, 0) / n;\n\n let numerator = 0;\n let denominator = 0;\n\n for (let i = 0; i < n; i++) {\n const dx = i - xMean;\n numerator += dx * (data[i] - yMean);\n denominator += dx * dx;\n }\n\n const slope = denominator === 0 ? 0 : numerator / denominator;\n const range = Math.max(...data) - Math.min(...data);\n const threshold = 0.01 * (range || 1);\n\n const direction: TrendDirection =\n Math.abs(slope) < threshold\n ? 'steady'\n : slope > 0\n ? 'increasing'\n : 'decreasing';\n\n return { slope, direction };\n}\n","import type { AgentAdapter } from '../../agent/types';\nimport type { SparklineHandle } from './sparkline';\n\nexport const sparklineAgent: AgentAdapter<SparklineHandle> = {\n id: 'sparkline',\n capabilities: [],\n // `select_annotation` enforces two preconditions silently and\n // `update_series` writes straight into ApexCharts, bypassing React —\n // so nothing in the React tree reflects what is actually rendered.\n // These slots are the checkable form of both.\n //\n // A9 boundary: an annotation `id` is the host's opaque key, so it is\n // exposed; `SparklineAnnotation.label` is human-readable and could\n // name a clinical event, so it is not. The plotted values are\n // measurements in a clinical sparkline and are never exposed — only\n // their count. `trend` from `useLinearTrend` is deliberately left out\n // for the same reason (still derived from the plotted values); adding\n // it needs a DS-maintainer sign-off.\n state: {\n annotationIds: {\n type: 'string[]',\n descriptionKey: 'ui.agent.sparkline.state.annotationIds',\n description:\n 'Ids of the annotations currently drawn, in declaration order. The only ids `select_annotation` will accept — check against this before calling. Ids only, never annotation labels.',\n read: (handle) => handle.getAnnotationIds(),\n },\n selectable: {\n type: 'boolean',\n descriptionKey: 'ui.agent.sparkline.state.selectable',\n description:\n 'True when the host wired an annotation-select handler. False means every `select_annotation` call is a no-op, whatever id is passed.',\n read: (handle) => handle.isSelectable(),\n },\n pointCount: {\n type: 'number',\n descriptionKey: 'ui.agent.sparkline.state.pointCount',\n description:\n 'Number of positions in the currently rendered series, unmeasured gaps included — reflecting whichever applied last, the `data` prop or an `update_series` call. A count only; the plotted values are never exposed.',\n read: (handle) => handle.getPointCount(),\n },\n },\n actions: {\n update_series: {\n // Replacing the rendered series mutates what the chart displays — write,\n // not read.\n safety: 'write',\n argsType: '{ data: number[] }',\n argsSchema: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: { type: 'number' },\n description: 'The new data points to render.',\n },\n },\n required: ['data'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.sparkline.actions.updateSeries',\n description:\n 'Replace the sparkline data without remounting. Writes straight into ApexCharts, bypassing React — read the `pointCount` slot back rather than expecting the host tree to reflect it. Host-supplied point labels are not updated, so the tooltip title is hidden after this call.',\n errors: [\n 'Per-point tooltip titles are hidden after this call — the host point labels describe the previous series, not the one written.',\n ],\n invoke: (handle, args: { data: number[] }) => {\n handle.updateSeries(args.data);\n },\n },\n export_png: {\n // Pure getter — returns an image of the current chart, no state change.\n safety: 'read',\n returns: 'string',\n returnsSchema: {\n type: 'string',\n description: 'A PNG image of the sparkline encoded as a data URI.',\n },\n descriptionKey: 'ui.agent.sparkline.actions.exportPng',\n description: 'Return a PNG data URI of the sparkline.',\n invoke: (handle) => handle.dataURI(),\n },\n select_annotation: {\n // Routes the host somewhere — the same thing a pointer press on the\n // annotation's band does. Nothing in the chart changes, but the host's\n // surface does, so it is not a read.\n safety: 'write',\n argsType: '{ annotationId: string }',\n argsSchema: {\n type: 'object',\n properties: {\n annotationId: {\n type: 'string',\n description:\n \"The annotation's id, as carried by data-annotation-hit-id on the pressable band. The decorative drawn marker carries the same value as data-annotation-id, but is not selectable.\",\n },\n },\n required: ['annotationId'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.sparkline.actions.selectAnnotation',\n description:\n 'Select a drawn annotation, as pressing its band would. No-op unless the host wired onAnnotationSelect and the id names an annotation that is currently drawn — check the `selectable` and `annotationIds` slots first, since neither failure produces a signal.',\n errors: [\n 'Silently ignored when `selectable` is false — the host wired no annotation-select handler.',\n 'Silently ignored when the id is not in `annotationIds` — that annotation is not currently drawn.',\n ],\n invoke: (handle, args: { annotationId: string }) => {\n handle.selectAnnotation(args.annotationId);\n },\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'sparkline' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\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 { getApexChartsTheme } from '../../tokens/apexcharts-theme';\nimport { useNeutraliseHiddenFocus } from '../_shared/use-neutralize-hidden-focus';\nimport { markerPath, type MarkerShape } from '../annotation-marker';\nimport { useLinearTrend } from './use-linear-trend';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { sparklineAgent } from './sparkline.agent';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst sparklineVariants = cva('ds:relative ds:inline-block ds:w-full', {\n variants: {\n size: {\n xs: 'ds:h-6',\n sm: 'ds:h-8',\n md: 'ds:h-10',\n // Applied when an explicit `height` prop is given: the wrapper\n // grows with the svg instead of clipping at the size's fixed height.\n auto: '',\n },\n },\n defaultVariants: { size: 'md' },\n});\n\n/* Tone only TINTS the annotation — the shape is what distinguishes one\n * event from another (WCAG 1.4.1), matching AnnotationMarker's vocabulary. */\nconst annotationVariants = cva('', {\n variants: {\n tone: {\n neutral: 'ds:[--annotation-color:var(--muted-foreground)]',\n info: 'ds:[--annotation-color:var(--info)]',\n success: 'ds:[--annotation-color:var(--success)]',\n /* `--warning-readable`, not `--warning`: a 1.5px dashed line is a\n * non-text graphic (WCAG 1.4.11, 3:1), and yellow-500 is ~1.6:1 on a\n * light card. The token aliases back to `--warning` in dark. */\n warning: 'ds:[--annotation-color:var(--warning-readable)]',\n error: 'ds:[--annotation-color:var(--destructive)]',\n accent: 'ds:[--annotation-color:var(--accent)]',\n },\n },\n defaultVariants: { tone: 'neutral' },\n});\n\n/* A 24–40px sparkline cannot hold a 44px target, so the POINTER layer alone is\n * bled outward to reach it. The drawn layer is a separate div at `inset-y-0`;\n * nothing rendered moves.\n *\n * BOTH axes follow `--min-target-size`: the vertical bleed via the calc\n * variants below, and the JS band width by measuring the resolved token off\n * the wrapper (fallback 44). Under `.theme-accessible` (48px) the band\n * widens on both axes. `auto` (an explicit `height`) cannot be computed here\n * at all and inherits whatever the host set. */\nconst annotationHitVariants = cva(\n 'ds:pointer-events-none ds:absolute ds:inset-x-[2px]',\n {\n variants: {\n // Bleed to the target-size token, not a literal: (token − drawn)/−2 per\n // size, so `.theme-accessible` (48px) widens the band automatically —\n // the same calc idiom IconButton uses for its hit-area expansion.\n size: {\n xs: 'ds:inset-y-[calc((var(--min-target-size)-24px)/-2)]',\n sm: 'ds:inset-y-[calc((var(--min-target-size)-32px)/-2)]',\n md: 'ds:inset-y-[calc((var(--min-target-size)-40px)/-2)]',\n auto: 'ds:inset-y-0',\n },\n },\n defaultVariants: { size: 'md' },\n },\n);\n\n/* ------------------------------------------------------------------ */\n/* Constants */\n/* ------------------------------------------------------------------ */\n\nconst DIRECTION_ARROW = {\n increasing: '↑',\n decreasing: '↓',\n steady: '→',\n} as const;\n\nconst SIZE_HEIGHT: Record<'xs' | 'sm' | 'md', number> = {\n xs: 24,\n sm: 32,\n md: 40,\n};\n\n/** ApexCharts grid padding, in px. The plotted extent is the wrapper inset by\n * this on each edge, so the annotation overlay has to use the same number to\n * land its first/last position on the first/last data point. */\nconst PLOT_EDGE_PADDING = 2;\n\n/** Radius of an annotation's shape cap, in svg user units (= px here). Sized\n * against the SMALLEST sparkline it has to sit on (`xs`, 24px): a 5px cap is\n * ~a fifth of that height, still shape-legible, and no longer competes with\n * the series it annotates. */\nconst ANNOTATION_CAP_RADIUS = 2.5;\n\n/** FALLBACK pointer-band width, in px — the light/dark `--min-target-size`.\n * The live value is measured off the wrapper so `.theme-accessible` (48px)\n * widens the band; this constant only covers the tick before the first\n * measurement and non-browser environments. Wider than the token is never\n * allowed — a sparse set of annotations would turn the whole trend into a\n * click target. */\nconst ANNOTATION_HIT_WIDTH = 44;\n\ninterface AnnotationHitBand {\n annotation: SparklineAnnotation;\n x: number;\n width: number;\n}\n\n/**\n * The pointer bands for a set of annotations across a plot `plotWidth` px wide.\n * Pure — the geometry is the only part needing a measured width, and keeping it\n * out of the render is what makes it testable.\n *\n * Each annotation owns the strip from the midpoint of the gap behind it to the\n * midpoint of the gap ahead, clamped to the plot. Its band is 44px inside that\n * strip, centred on its line and slid inward where the strip's edge would cut\n * it — so a line on the first data point still gets a full band, and no band\n * reaches past the plot onto whatever sits beside the sparkline. Annotations\n * closer than 44px each keep half the gap: a press must mean exactly one.\n */\nfunction annotationHitBands(\n annotations: readonly SparklineAnnotation[],\n plotWidth: number,\n hitWidth: number = ANNOTATION_HIT_WIDTH,\n): AnnotationHitBand[] {\n const centred = annotations\n .map((annotation) => ({\n annotation,\n centre: clampFraction(annotation.position) * plotWidth,\n }))\n .sort((a, b) => a.centre - b.centre);\n\n return centred.map((entry, index) => {\n const before = centred[index - 1];\n const after = centred[index + 1];\n const from = before ? (before.centre + entry.centre) / 2 : 0;\n const to = after ? (entry.centre + after.centre) / 2 : plotWidth;\n const lower = Math.max(0, from);\n const upper = Math.min(plotWidth, to);\n const width = Math.min(hitWidth, Math.max(0, upper - lower));\n const x = Math.min(\n Math.max(entry.centre - width / 2, lower),\n upper - width,\n );\n return { annotation: entry.annotation, x, width };\n });\n}\n\nfunction clampFraction(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.min(1, Math.max(0, value));\n}\n\n/** The measurements in a series, gaps dropped. A `null` is an unmeasured\n * position, not a zero — it must not reach the min/max/trend maths. */\nfunction measured(data: readonly (number | null)[]): number[] {\n return data.filter((value): value is number => value != null);\n}\n\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window !== 'undefined' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport interface SparklineHandle {\n updateSeries: (data: (number | null)[]) => void;\n updateOptions: (opts: ApexCharts.ApexOptions) => void;\n dataURI: () => Promise<string>;\n /** Fire the host's annotation handler for `id`, as a pointer press on that\n * annotation's band would. No-op when the sparkline is not selectable, or\n * when `id` names no currently drawn annotation. */\n selectAnnotation: (id: string) => void;\n /* ---- read-back: the two preconditions `selectAnnotation` silently\n * enforces, plus the series length ------------------------------- */\n /** Ids of the annotations currently drawn — the only ids `selectAnnotation`\n * will accept. Ids only: an annotation's `label` is human-readable and could\n * name a clinical event, so it is never exposed. */\n getAnnotationIds: () => string[];\n /** True when the host wired `onAnnotationSelect`. False means every\n * `selectAnnotation` call is a no-op. */\n isSelectable: () => boolean;\n /** Number of positions in the currently rendered series, gaps included.\n * A count only — the plotted values are measurements and stay private. */\n getPointCount: () => number;\n}\n\n/** Semantic tint for an annotation. Decorative reinforcement of `shape` —\n * never the only channel carrying which event this is. */\nexport type SparklineAnnotationTone =\n | 'neutral'\n | 'info'\n | 'success'\n | 'warning'\n | 'error'\n | 'accent';\n\n/**\n * A vertical reference line dropped across the plot — the release-annotation\n * pattern: \"something happened here, look at what the line does around it\".\n *\n * `position` is a FRACTION of the plotted x extent, not an index: `0` is the\n * first data point, `1` the last, `0.5` exactly halfway between them. That is\n * what lets an event that falls BETWEEN two points be placed at all, and what\n * lets the same event land at the same x in a column of stacked sparklines —\n * the caller derives the fraction once, from a domain the whole column shares,\n * rather than per-series from a point count that differs row to row.\n */\nexport interface SparklineAnnotation {\n /** Stable key — also emitted as `data-annotation-id` for test/agent hooks. */\n id: string;\n /** Fraction of the plotted x extent: 0 = first point, 1 = last. Clamped. */\n position: number;\n /** Accessible label, already localised by the caller. Folded into the\n * sparkline's own `aria-label` — the line itself says nothing aloud. */\n label: string;\n /** Shape of the cap drawn at the top of the line. The accessible channel. */\n shape?: MarkerShape;\n tone?: SparklineAnnotationTone;\n}\n\nexport interface SparklineProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'children'>,\n VariantProps<typeof sparklineVariants> {\n /** Data points in plot order. `null` is an unmeasured position — it holds\n * the point's place on the x extent and draws a gap, so a series measured\n * at some positions and not others stays aligned with one that was measured\n * at all of them. */\n data: (number | null)[];\n /** Chart visual style */\n variant?: 'line' | 'bar' | 'area';\n /** Size preset */\n size?: 'xs' | 'sm' | 'md';\n /** Accessible label prefix, e.g. \"Revenue, 30 days\" */\n label?: string;\n /** Stroke / bar colour override — defaults to var(--primary) via bridge */\n color?: string;\n /** Show end-point dot with trend direction arrow */\n showEndpoint?: boolean;\n /**\n * Show Apex's hover tooltip with the data point value. Defaults to\n * `false` — sparklines are intentionally minimal — opt in when the\n * sparkline is large enough to be a primary metric surface (e.g.\n * dashboard widgets) and the user benefits from per-point readout.\n */\n showTooltip?: boolean;\n /** Series name shown in the tooltip, already localised. Defaults to\n * `label`, so the tooltip never falls back to Apex's \"series-1\". */\n seriesName?: string;\n /** Tooltip title per point, same order and length as `data` (gaps\n * included). Omitted = no tooltip title. Never drawn on an axis. */\n pointLabels?: readonly string[];\n /** Width override — defaults to 100% of container */\n width?: string | number;\n /** Height override — defaults to the size variant height */\n height?: string | number;\n /** Vertical reference lines dropped across the plot. Omitted = none, so\n * every existing consumer is unaffected. */\n annotations?: readonly SparklineAnnotation[];\n /**\n * Make the drawn annotations POINTER-selectable — a press anywhere in an\n * annotation's 44px band calls this with its `id`. Omitted (the default, and\n * what every consumer before 1.1.0 gets) leaves them decorative, which is\n * what a dashboard sparkline wants: a trend thumbnail should not be a click\n * target.\n *\n * NOT a keyboard route, and deliberately so. The sparkline is `role=\"img\"`,\n * whose descendants are not exposed to assistive technology at all, so a\n * focusable control drawn inside it would be a tab stop with no accessible\n * name. The host MUST therefore already offer a keyboard control that does\n * the same thing for the same annotation (WCAG 2.1.1) — this is a pointer\n * shortcut to that control, never the only way in.\n *\n * The band is delivered by the `size` variants only, and follows\n * `--min-target-size` on both axes (48px under `.theme-accessible`). Pass\n * an explicit `height` and the pointer layer falls back to the drawn\n * height, so `height={20}` yields a 20px-tall target — below even WCAG\n * 2.5.8.\n */\n onAnnotationSelect?: (annotationId: string) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Sparkline component */\n/* ------------------------------------------------------------------ */\n\nexport const Sparkline = forwardRef<SparklineHandle, SparklineProps>(\n (\n {\n id,\n data,\n variant = 'line',\n size = 'md',\n label,\n color,\n showEndpoint = false,\n showTooltip = false,\n seriesName,\n pointLabels,\n width,\n height,\n annotations,\n onAnnotationSelect,\n className,\n ...props\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const rawId = useId();\n const chartId = useMemo(\n () => `sparkline-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [containerWidth, setContainerWidth] = useState(0);\n const [hitWidth, setHitWidth] = useState(ANNOTATION_HIT_WIDTH);\n\n // Gaps are positions, not values: they hold the point's place on the x\n // extent but never reach the trend, the min/max, or the endpoint dot.\n const points = useMemo(() => measured(data), [data]);\n const { direction } = useLinearTrend(points);\n\n /* ---- accessible summary ---------------------------------------- */\n const ariaLabel = useMemo(() => {\n // The annotations are the only thing a vertical line in an SVG can say\n // aloud, so they ride the summary in every branch — including \"no data\",\n // where the marked events are all there is left to report.\n const marks =\n annotations && annotations.length > 0\n ? t('sparkline.annotations', {\n list: annotations.map((a) => a.label).join(', '),\n })\n : '';\n const withMarks = (summary: string) =>\n marks ? `${summary}. ${marks}` : summary;\n\n if (points.length === 0) {\n return withMarks(t('sparkline.noData', 'No data'));\n }\n const fmt = (n: number) => new Intl.NumberFormat(i18n.language).format(n);\n const dirText = t(`sparkline.direction.${direction}`);\n const nums = {\n min: fmt(Math.min(...points)),\n max: fmt(Math.max(...points)),\n current: fmt(points[points.length - 1]),\n direction: dirText,\n };\n if (label) {\n return withMarks(t('sparkline.summary', { label, ...nums }));\n }\n return withMarks(t('sparkline.summaryNoLabel', nums));\n }, [points, annotations, label, direction, i18n.language, t]);\n\n /* ---- theme-reactive state -------------------------------------- */\n const [themeOptions, setThemeOptions] = useState<ApexCharts.ApexOptions>(\n () => {\n try {\n return getApexChartsTheme();\n } catch {\n return {};\n }\n },\n );\n\n /* ---- MutationObserver: re-read theme on class change ----------- */\n useEffect(() => {\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 /* ---- ResizeObserver: track container width -------------------- */\n useEffect(() => {\n const el = wrapperRef.current;\n if (!el) return;\n const measureTarget = () => {\n // The resolved token off the wrapper: theme classes live above the\n // component, so the cascade answers for whichever theme applies.\n const raw = getComputedStyle(el).getPropertyValue('--min-target-size');\n const parsed = Number.parseFloat(raw);\n if (Number.isFinite(parsed) && parsed > 0) setHitWidth(parsed);\n };\n measureTarget();\n const ro = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setContainerWidth(Math.floor(entry.contentRect.width));\n measureTarget();\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n /* ApexCharts injects focusable canvases inside the `aria-hidden` */\n /* chart wrapper. Neutralise their tabindex so axe's */\n /* `aria-hidden-focus` rule passes. Shared hook — same fix in */\n /* `Chart` (full apex) and the calendar's mirror events. */\n useNeutraliseHiddenFocus(wrapperRef);\n\n /* ---- imperative handle ---------------------------------------- */\n // Through a ref so the handle keeps one identity across a host that\n // re-creates the callback on every render — the agent registry keys on it.\n const selectRef = useRef(onAnnotationSelect);\n useEffect(() => {\n selectRef.current = onAnnotationSelect;\n }, [onAnnotationSelect]);\n // Assigned during render, not in an effect: an agent may call before the\n // next commit, and routing the host to an annotation that is not drawn\n // opens a panel addressed to nothing.\n const drawnRef = useRef(annotations);\n drawnRef.current = annotations;\n // The `data` prop and `updateSeries` are two independent paths into\n // the rendered series — the latter writes straight into ApexCharts,\n // bypassing React — so track whichever applied last. Keyed on the\n // prop (not assigned every render) so an unrelated re-render does\n // not clobber a length an agent just set.\n // Read by `updateSeries`, which replaces the whole series. Never\n // undefined: Apex swaps an undefined name for \"series-1\", while an\n // empty one renders no name at all.\n const resolvedSeriesName = seriesName ?? label ?? '';\n const seriesNameRef = useRef(resolvedSeriesName);\n seriesNameRef.current = resolvedSeriesName;\n const pointCountRef = useRef(data.length);\n // Point labels and their slot map, read by the tooltip formatter through\n // a ref so a formatter Apex already holds never reads stale labels.\n const tooltipLabelsRef = useRef<{\n labels?: readonly string[];\n slotOf?: readonly number[];\n shown: boolean;\n }>({ shown: false });\n // Set by `updateSeries`: the host's labels describe the old series, so\n // the title stays hidden until the host passes new `data`.\n const labelsStaleRef = useRef(false);\n useEffect(() => {\n pointCountRef.current = data.length;\n if (!labelsStaleRef.current) return;\n labelsStaleRef.current = false;\n if (tooltipLabelsRef.current.shown) {\n ApexCharts.getChartByID(chartId)?.updateOptions({\n tooltip: { x: { show: true } },\n });\n }\n }, [data, chartId]);\n\n const agentHandle = useMemo<SparklineHandle>(\n () => ({\n updateSeries(newData: (number | null)[]) {\n const chart = ApexCharts.getChartByID(chartId);\n chart?.updateSeries([{ name: seriesNameRef.current, data: newData }]);\n pointCountRef.current = newData.length;\n if (tooltipLabelsRef.current.shown) {\n labelsStaleRef.current = true;\n chart?.updateOptions({ tooltip: { x: { show: false } } });\n }\n },\n updateOptions(opts: ApexCharts.ApexOptions) {\n ApexCharts.getChartByID(chartId)?.updateOptions(opts);\n },\n async dataURI(): Promise<string> {\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 selectAnnotation(annotationId: string) {\n const drawn = drawnRef.current?.some((a) => a.id === annotationId);\n if (!drawn) return;\n selectRef.current?.(annotationId);\n },\n // Read-back for the two preconditions `selectAnnotation` enforces\n // silently — without these an agent can check neither and gets no\n // signal from either failure.\n getAnnotationIds: () => (drawnRef.current ?? []).map((a) => a.id),\n isSelectable: () => selectRef.current != null,\n getPointCount: () => pointCountRef.current,\n }),\n [chartId],\n );\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n useAgentRegistration(sparklineAgent, agentHandle, id);\n\n /* ---- resolve color -------------------------------------------- */\n const resolvedColor = color ?? themeOptions.colors?.[0] ?? 'currentColor';\n\n /* ---- empty state ---------------------------------------------- */\n if (points.length === 0) {\n return (\n <div\n ref={wrapperRef}\n role=\"img\"\n aria-label={ariaLabel}\n dir=\"ltr\"\n className={sparklineVariants({\n size: height !== undefined ? 'auto' : size,\n className,\n })}\n data-component=\"sparkline\"\n data-component-id={id}\n {...props}\n />\n );\n }\n\n /* ---- chart config ---------------------------------------------- */\n const reducedMotion = prefersReducedMotion();\n\n // A gapped series is plotted as {x, y} pairs on a NUMERIC axis pinned to\n // the full slot count, not as an array with holes in it: ApexCharts draws\n // a line only between consecutive non-null points, so a lab measured at\n // slots 0, 4 and 8 would render as three isolated points and no trend at\n // all. Pairs keep each measurement at its own slot, connect across the\n // gap, and leave the extent — and so every annotation — unchanged.\n // Gapless data keeps the plain-array form, so every existing consumer\n // renders byte-identically.\n const gapped = data.length > points.length;\n const seriesData = gapped\n ? data.flatMap((y, x) => (y == null ? [] : [{ x, y }]))\n : points;\n\n // Apex hands the tooltip the index into the SERIES, whose gaps are\n // removed, so map it back to its slot in `data` before reading a label.\n const slotOf = gapped\n ? data.flatMap((y, slot) => (y == null ? [] : [slot]))\n : undefined;\n tooltipLabelsRef.current = {\n labels: pointLabels,\n slotOf,\n shown: showTooltip && pointLabels !== undefined,\n };\n const tooltip: ApexCharts.ApexOptions['tooltip'] = showTooltip\n ? {\n enabled: true,\n x: pointLabels\n ? {\n show: true,\n formatter: (_value, opts) => {\n const { labels, slotOf: slots } = tooltipLabelsRef.current;\n if (labelsStaleRef.current || !labels) return '';\n const index = opts?.dataPointIndex ?? -1;\n return labels[slots ? (slots[index] ?? -1) : index] ?? '';\n },\n }\n : // No labels: hide the title rather than show a raw index.\n { show: false },\n }\n : { enabled: false };\n\n const chartOptions: ApexCharts.ApexOptions = {\n ...themeOptions,\n chart: {\n ...themeOptions.chart,\n id: chartId,\n type: variant,\n sparkline: { enabled: true },\n toolbar: { show: false },\n animations: {\n enabled: !reducedMotion,\n // A gapped series is re-rendered as {x, y} pairs, and Apex's\n // update tween interpolates between the old and new paths point by\n // point. Across a width change the two have different lengths and\n // the tween emits `d=\"… NaN …\"` for a few frames. The finished\n // render is correct either way; switching the tween off keeps the\n // console clean.\n dynamicAnimation: { enabled: !reducedMotion && !gapped },\n },\n zoom: { enabled: false },\n parentHeightOffset: 0,\n },\n colors: [resolvedColor],\n stroke: {\n curve: 'smooth',\n width: variant === 'bar' ? 0 : 2,\n },\n fill: {\n opacity: variant === 'area' ? 0.15 : 1,\n },\n xaxis: {\n crosshairs: { show: false },\n // Pin the extent to the slot count so a gap at either end still holds\n // its place — otherwise the plot would rescale to the measurements\n // and the annotation fractions would no longer mean the same thing.\n ...(gapped\n ? { type: 'numeric' as const, min: 0, max: data.length - 1 }\n : {}),\n },\n tooltip,\n markers: showEndpoint\n ? {\n size: [0],\n discrete: [\n {\n // An index into the SERIES, whose holes have already been\n // removed — so this is the last MEASURED point, never a slot\n // the parameter was not measured at.\n seriesIndex: 0,\n dataPointIndex: seriesData.length - 1,\n fillColor: resolvedColor,\n strokeColor: resolvedColor,\n size: 4,\n },\n ],\n }\n : { size: 0 },\n grid: {\n ...themeOptions.grid,\n show: false,\n // ApexCharts grid.padding uses physical keys (not CSS logical properties).\n // The chart wrapper enforces dir=\"ltr\" so these always resolve correctly.\n padding: {\n top: PLOT_EDGE_PADDING,\n right: PLOT_EDGE_PADDING,\n bottom: PLOT_EDGE_PADDING,\n left: PLOT_EDGE_PADDING,\n },\n },\n };\n\n const resolvedWidth =\n width ?? (containerWidth > 0 ? containerWidth : '100%');\n const resolvedHeight = height ?? SIZE_HEIGHT[size ?? 'md'];\n\n // Positioned as a percentage of the overlay's own box rather than from a\n // measured width: the overlay is inset to the plot area, so a fraction is\n // exact at any size and cannot lag or disagree with the plot.\n const drawnAnnotations = annotations?.length ? annotations : undefined;\n\n // The plot box in px — the overlay is the wrapper inset by the grid padding\n // on each edge. Nothing is measured before the first ResizeObserver tick,\n // and a band with no width lies about where it is: no width, no bands.\n const plotWidth = containerWidth - PLOT_EDGE_PADDING * 2;\n const hitBands =\n onAnnotationSelect && drawnAnnotations && plotWidth > 0\n ? annotationHitBands(drawnAnnotations, plotWidth, hitWidth)\n : undefined;\n\n return (\n <div\n ref={wrapperRef}\n role=\"img\"\n aria-label={ariaLabel}\n dir=\"ltr\"\n className={sparklineVariants({\n size: height !== undefined ? 'auto' : size,\n className,\n })}\n data-component=\"sparkline\"\n data-component-id={id}\n {...props}\n >\n <ReactApexChart\n type={variant}\n series={[{ name: resolvedSeriesName, data: seriesData }]}\n options={chartOptions}\n width={resolvedWidth}\n height={resolvedHeight}\n aria-hidden=\"true\"\n />\n {drawnAnnotations && (\n /* Drawn over the plot rather than through ApexCharts' own xaxis\n annotations: a fraction of the measured extent is the one\n positioning rule that survives series of different lengths, which\n is what makes a column of sparklines share an x. */\n /* The inset lives on a div: an <svg> is a replaced element, so\n left+right do not size it and it would fall back to its intrinsic\n 300px. The div is the plot box; the svg fills it. The 2px MUST\n equal PLOT_EDGE_PADDING — Tailwind needs a static literal, so the\n two cannot share one source; change them together or the first and\n last annotation drift off the first and last data point. */\n <div className=\"ds:pointer-events-none ds:absolute ds:inset-y-0 ds:inset-x-[2px]\">\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n data-testid=\"sparkline-annotations\"\n className=\"ds:size-full\"\n >\n {drawnAnnotations.map((annotation) => {\n const fraction = clampFraction(annotation.position);\n return (\n /* A nested viewport placed at a percentage of the plot: the\n one positioning rule that needs no measurement, so a column\n of sparklines shares an x whatever their widths. */\n <svg\n key={annotation.id}\n x={`${fraction * 100}%`}\n y=\"0\"\n width=\"1\"\n height=\"100%\"\n overflow=\"visible\"\n data-annotation-id={annotation.id}\n data-annotation-position={fraction}\n className={annotationVariants({ tone: annotation.tone })}\n >\n <line\n x1={0}\n x2={0}\n y1={0}\n y2=\"100%\"\n /* 1px, more gap than dash: the line marks WHERE, the\n series is what is read, and at 1.5px the annotation\n was the louder of the two. */\n className=\"ds:[stroke:var(--annotation-color)] ds:[stroke-dasharray:2_3] ds:[stroke-width:1]\"\n />\n <path\n d={markerPath(\n annotation.shape ?? 'diamond',\n 0,\n ANNOTATION_CAP_RADIUS,\n ANNOTATION_CAP_RADIUS,\n )}\n className=\"ds:[fill:var(--annotation-color)]\"\n />\n </svg>\n );\n })}\n </svg>\n </div>\n )}\n {hitBands && onAnnotationSelect && (\n /* Sized in px, not percentages: the target size is a measurement,\n not a fraction of a box the reader can resize.\n `pointer-events-none` holds all the way down to the bands, so the\n only live pixels are the token-width each annotation owns. */\n <div\n className={annotationHitVariants({\n size: height !== undefined ? 'auto' : size,\n })}\n >\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n data-testid=\"sparkline-annotation-hits\"\n className=\"ds:size-full\"\n >\n {hitBands.map(({ annotation, x, width }) => (\n <g\n key={annotation.id}\n data-annotation-hit-id={annotation.id}\n onClick={() => onAnnotationSelect(annotation.id)}\n className={`ds:group ds:pointer-events-auto ds:cursor-pointer ${annotationVariants(\n { tone: annotation.tone },\n )}`}\n >\n {/* A native tooltip for the pointer that can act on it. The\n same labels already ride the wrapper's aria-label, and\n this svg is aria-hidden, so nothing is said twice. */}\n <title>\n {t('sparkline.annotationAction', {\n label: annotation.label,\n })}\n </title>\n {/* Target and hover affordance in one rect: it tints on\n hover so the reader sees which event the press means.\n Opacity does not affect hit-testing. */}\n <rect\n x={x}\n y={0}\n width={width}\n height=\"100%\"\n className=\"ds:[fill:var(--annotation-color)] ds:opacity-0 ds:transition-opacity ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none ds:group-hover:opacity-20\"\n />\n </g>\n ))}\n </svg>\n </div>\n )}\n {showEndpoint && (\n <span\n aria-hidden=\"true\"\n className=\"ds:pointer-events-none ds:absolute ds:end-0 ds:top-0 ds:text-[length:var(--font-size-xs)] ds:leading-none\"\n >\n {DIRECTION_ARROW[direction]}\n </span>\n )}\n </div>\n );\n },\n);\n\nSparkline.displayName = 'Sparkline';\n"],"names":["useLinearTrend","data","n","xMean","yMean","sum","y","numerator","denominator","i","dx","slope","threshold","direction","sparklineAgent","handle","args","sparklineVariants","cva","annotationVariants","annotationHitVariants","DIRECTION_ARROW","SIZE_HEIGHT","PLOT_EDGE_PADDING","ANNOTATION_CAP_RADIUS","ANNOTATION_HIT_WIDTH","annotationHitBands","annotations","plotWidth","hitWidth","centred","annotation","clampFraction","b","entry","index","before","after","from","to","lower","upper","width","x","value","measured","prefersReducedMotion","Sparkline","forwardRef","id","variant","size","label","color","showEndpoint","showTooltip","seriesName","pointLabels","height","onAnnotationSelect","className","props","ref","t","i18n","useTranslation","rawId","useId","chartId","useMemo","wrapperRef","useRef","containerWidth","setContainerWidth","useState","setHitWidth","points","ariaLabel","marks","a","withMarks","summary","fmt","dirText","nums","themeOptions","setThemeOptions","getApexChartsTheme","useEffect","timer","observer","el","measureTarget","raw","parsed","ro","entries","useNeutraliseHiddenFocus","selectRef","drawnRef","resolvedSeriesName","seriesNameRef","pointCountRef","tooltipLabelsRef","labelsStaleRef","_a","ApexCharts","agentHandle","newData","chart","opts","instance","annotationId","_b","useImperativeHandle","useAgentRegistration","resolvedColor","jsx","reducedMotion","gapped","seriesData","slotOf","slot","tooltip","_value","labels","slots","chartOptions","resolvedWidth","resolvedHeight","drawnAnnotations","hitBands","jsxs","ReactApexChart","fraction","markerPath"],"mappings":";;;;;;;;;AAOO,SAASA,GAAeC,GAAmC;AAChE,MAAIA,EAAK,SAAS;AAChB,WAAO,EAAE,OAAO,GAAG,WAAW,SAAA;AAGhC,QAAMC,IAAID,EAAK,QACTE,KAASD,IAAI,KAAK,GAClBE,IAAQH,EAAK,OAAO,CAACI,GAAKC,MAAMD,IAAMC,GAAG,CAAC,IAAIJ;AAEpD,MAAIK,IAAY,GACZC,IAAc;AAElB,WAASC,IAAI,GAAGA,IAAIP,GAAGO,KAAK;AAC1B,UAAMC,IAAKD,IAAIN;AACf,IAAAI,KAAaG,KAAMT,EAAKQ,CAAC,IAAIL,IAC7BI,KAAeE,IAAKA;AAAA,EACtB;AAEA,QAA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ET,UAAAc,GAAS,IAAI,CAAC,EAAE,YAAApG,GAAY,GAAAY,GAAG,OAAAD,QAC9B,gBAAA0F;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBAEC,0BAAwBrG,EAAW;AAAA,sBACnC,SAAS,MAAM4B,EAAmB5B,EAAW,EAAE;AAAA,sBAC/C,WAAW,qDAAqDZ;AAAA,wBAC9D,EAAE,MAAMY,EAAW,KAAA;AAAA,sBAAK,CACzB;AAAA,sBAKD,UAAA;AAAA,wBAAA,gBAAAsF,EAAC,SAAA,EACE,YAAE,8BAA8B;AAAA,0BAC/B,OAAOtF,EAAW;AAAA,wBAAA,CACnB,GACH;AAAA,wBAIA,gBAAAsF;AAAA,0BAAC;AAAA,0BAAA;AAAA,4BACC,GAAA1E;AAAA,4BACA,GAAG;AAAA,4BACH,OAAOD;AAAAA,4BACP,QAAO;AAAA,4BACP,WAAU;AAAA,0BAAA;AAAA,wBAAA;AAAA,sBACZ;AAAA,oBAAA;AAAA,oBAxBKX,EAAW;AAAA,kBAAA,CA0BnB;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,UAGHuB,KACC,gBAAA+D;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA,cAET,aAAgBxG,CAAS;AAAA,YAAA;AAAA,UAAA;AAAA,QAC5B;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAkC,GAAU,cAAc;"}
@@ -130,10 +130,10 @@ const K = {
130
130
  layout: t = "rail-start",
131
131
  order: r = "newest-first",
132
132
  className: s,
133
- children: i,
133
+ children: a,
134
134
  ...n
135
- }, a) => {
136
- const d = p(() => ({ layout: t, order: r }), [t, r]), o = w(null), [l, z] = V(null), h = w(null);
135
+ }, d) => {
136
+ const i = p(() => ({ layout: t, order: r }), [t, r]), o = w(null), [l, z] = V(null), h = w(null);
137
137
  h.current = l;
138
138
  const x = I((y) => {
139
139
  var T;
@@ -149,7 +149,7 @@ const K = {
149
149
  }),
150
150
  [x]
151
151
  );
152
- return O(a, () => o.current, []), B(K, R, n.id), /* @__PURE__ */ e(v.Provider, { value: d, children: /* @__PURE__ */ e(
152
+ return O(d, () => o.current, []), B(K, R, n.id), /* @__PURE__ */ e(v.Provider, { value: i, children: /* @__PURE__ */ e(
153
153
  "ol",
154
154
  {
155
155
  ref: o,
@@ -158,37 +158,37 @@ const K = {
158
158
  "data-selected-event": l ?? void 0,
159
159
  className: U({ layout: t, order: r, className: s }),
160
160
  ...n,
161
- children: i
161
+ children: a
162
162
  }
163
163
  ) });
164
164
  }
165
165
  );
166
166
  E.displayName = "Timeline";
167
167
  const S = m(
168
- ({ type: t = "neutral", eventId: r, className: s, children: i, ...n }, a) => {
169
- const { layout: d } = u(v), { t: o } = A(), l = p(() => ({ type: t }), [t]);
170
- return d === "alternating" ? /* @__PURE__ */ e(g.Provider, { value: l, children: /* @__PURE__ */ c(
168
+ ({ type: t = "neutral", eventId: r, className: s, children: a, ...n }, d) => {
169
+ const { layout: i } = u(v), { t: o } = A(), l = p(() => ({ type: t }), [t]);
170
+ return i === "alternating" ? /* @__PURE__ */ e(g.Provider, { value: l, children: /* @__PURE__ */ c(
171
171
  "li",
172
172
  {
173
- ref: a,
173
+ ref: d,
174
174
  "data-event-id": r,
175
175
  className: ["ds:contents", s].filter(Boolean).join(" "),
176
176
  ...n,
177
177
  children: [
178
178
  /* @__PURE__ */ e("span", { className: "ds:sr-only", children: o(`timeline.type.${t}`) }),
179
- i
179
+ a
180
180
  ]
181
181
  }
182
182
  ) }) : /* @__PURE__ */ e(g.Provider, { value: l, children: /* @__PURE__ */ c(
183
183
  "li",
184
184
  {
185
- ref: a,
185
+ ref: d,
186
186
  "data-event-id": r,
187
- className: W({ layout: d, className: s }),
187
+ className: W({ layout: i, className: s }),
188
188
  ...n,
189
189
  children: [
190
190
  /* @__PURE__ */ e("span", { className: "ds:sr-only", children: o(`timeline.type.${t}`) }),
191
- i
191
+ a
192
192
  ]
193
193
  }
194
194
  ) });
@@ -196,38 +196,38 @@ const S = m(
196
196
  );
197
197
  S.displayName = "Timeline.Event";
198
198
  const _ = m(
199
- ({ icon: t, className: r, ...s }, i) => {
200
- const { type: n } = u(g), { layout: a } = u(v), d = /* @__PURE__ */ e(
199
+ ({ icon: t, className: r, ...s }, a) => {
200
+ const { type: n } = u(g), { layout: d } = u(v), i = /* @__PURE__ */ e(
201
201
  "div",
202
202
  {
203
- ref: i,
203
+ ref: a,
204
204
  "aria-hidden": "true",
205
205
  className: Y({ type: n, className: r }),
206
206
  ...s,
207
207
  children: t ?? X[n]
208
208
  }
209
209
  );
210
- return a === "alternating" ? /* @__PURE__ */ c(
210
+ return d === "alternating" ? /* @__PURE__ */ c(
211
211
  "div",
212
212
  {
213
213
  "aria-hidden": "true",
214
214
  className: "ds:col-start-2 ds:flex ds:flex-col ds:items-center",
215
215
  children: [
216
216
  /* @__PURE__ */ e("div", { className: "ds:w-[var(--border-width-md)] ds:flex-1 ds:bg-[var(--border)] ds:first:hidden" }),
217
- d,
217
+ i,
218
218
  /* @__PURE__ */ e("div", { className: "ds:w-[var(--border-width-md)] ds:flex-1 ds:bg-[var(--border)]" })
219
219
  ]
220
220
  }
221
- ) : d;
221
+ ) : i;
222
222
  }
223
223
  );
224
224
  _.displayName = "Timeline.Dot";
225
225
  const j = m(
226
- ({ title: t, description: r, actor: s, children: i, className: n, ...a }, d) => {
226
+ ({ title: t, description: r, actor: s, children: a, className: n, ...d }, i) => {
227
227
  const { layout: o } = u(v), l = /* @__PURE__ */ e(
228
228
  "div",
229
229
  {
230
- ref: d,
230
+ ref: i,
231
231
  className: [
232
232
  "ds:flex-1 ds:min-w-0 ds:pb-[var(--spacing-md)]",
233
233
  // Wrap policy: `break-word` (not `anywhere`) preserves word-
@@ -240,7 +240,7 @@ const j = m(
240
240
  "ds:[&_*]:break-normal ds:[&_*]:[overflow-wrap:break-word]",
241
241
  n
242
242
  ].filter(Boolean).join(" "),
243
- ...a,
243
+ ...d,
244
244
  children: /* @__PURE__ */ e(N, { variant: "outlined", children: /* @__PURE__ */ c(N.Body, { children: [
245
245
  /* @__PURE__ */ e("p", { className: "type-label ds:text-[var(--foreground)]", children: t }),
246
246
  r && /* @__PURE__ */ e("p", { className: "ds:mt-[var(--spacing-xs)] type-body-sm ds:text-[var(--muted-foreground)]", children: r }),
@@ -248,7 +248,7 @@ const j = m(
248
248
  /* @__PURE__ */ e(P, { size: "xs", name: s.name, src: s.src }),
249
249
  /* @__PURE__ */ e("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: s.name })
250
250
  ] }),
251
- i
251
+ a
252
252
  ] }) })
253
253
  }
254
254
  );
@@ -259,24 +259,26 @@ j.displayName = "Timeline.Content";
259
259
  const G = 1440 * 60 * 1e3, k = m(
260
260
  ({
261
261
  date: t,
262
- relative: r = !0,
263
- format: s = { dateStyle: "medium", timeStyle: "short" },
264
- className: i,
265
- ...n
266
- }, a) => /* @__PURE__ */ e(
262
+ locale: r,
263
+ relative: s = !0,
264
+ format: a = { dateStyle: "medium", timeStyle: "short" },
265
+ className: n,
266
+ ...d
267
+ }, i) => /* @__PURE__ */ e(
267
268
  q,
268
269
  {
269
- ref: a,
270
+ ref: i,
270
271
  value: t,
271
- format: r ? "relative" : "absolute",
272
- relativeWindow: r ? G : void 0,
273
- absoluteFormat: s,
272
+ locale: r,
273
+ format: s ? "relative" : "absolute",
274
+ relativeWindow: s ? G : void 0,
275
+ absoluteFormat: a,
274
276
  className: [
275
277
  "ds:text-[var(--muted-foreground)]",
276
278
  "ds:[font-variant-numeric:var(--font-feature-tabular)]",
277
- i
279
+ n
278
280
  ].filter(Boolean).join(" "),
279
- ...n
281
+ ...d
280
282
  }
281
283
  )
282
284
  );
@@ -291,4 +293,4 @@ export {
291
293
  le as T,
292
294
  K as t
293
295
  };
294
- //# sourceMappingURL=timeline-r-8IUoBS.js.map
296
+ //# sourceMappingURL=timeline-u-2t9t_M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-u-2t9t_M.js","sources":["../../src/components/timeline/timeline.agent.ts","../../src/components/timeline/timeline.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — Timeline. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { TimelineHandle } from './timeline';\n\nexport const timelineAgent: AgentAdapter<TimelineHandle> = {\n id: 'timeline',\n // `select_event` persists `selectedEvent` state, so this is single-selection\n // (`select_single`), not a transient `pick`. See PRS §26 §4.\n capabilities: ['select_single'],\n state: {\n selectedEvent: {\n type: 'string | null',\n descriptionKey: 'ui.agent.timeline.state.selectedEvent',\n description: 'Opaque event id of the currently-active event, or null.',\n read: (handle) => handle.getSelectedEvent(),\n },\n },\n actions: {\n select_event: {\n safety: 'read',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.timeline.actions.selectEvent',\n description: 'Scroll the given event into view and mark it as selected.',\n invoke: (handle, args: { id: string }) => {\n handle.selectEvent(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'timeline',\n description: 'Marks the Timeline root.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n item: {\n attr: 'data-event-id',\n description:\n 'Opaque event id emitted on each Timeline.Event when the `eventId` prop is provided.',\n },\n },\n};\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type LiHTMLAttributes,\n type OlHTMLAttributes,\n type ReactNode,\n type TimeHTMLAttributes,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { TriangleAlert, Check, Circle, Info, X } from 'lucide-react';\nimport { Avatar } from '../avatar';\nimport { Card } from '../card';\nimport { Timestamp } from '../timestamp';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { timelineAgent } from './timeline.agent';\n\n// TODO: optional @tanstack/react-virtual integration for 500+ events\n\n/* ------------------------------------------------------------------ */\n/* Context */\n/* ------------------------------------------------------------------ */\n\ntype EventType = 'info' | 'success' | 'warning' | 'error' | 'neutral';\ntype Layout = 'rail-start' | 'rail-end' | 'alternating';\n\ninterface TimelineContextValue {\n layout: Layout;\n order: 'newest-first' | 'oldest-first';\n}\n\nconst TimelineContext = createContext<TimelineContextValue>({\n layout: 'rail-start',\n order: 'newest-first',\n});\n\ninterface TimelineEventContextValue {\n type: EventType;\n}\n\nconst TimelineEventContext = createContext<TimelineEventContextValue>({\n type: 'neutral',\n});\n\n/* ------------------------------------------------------------------ */\n/* CVA — root */\n/* ------------------------------------------------------------------ */\n\nconst timelineVariants = cva('ds:flex ds:flex-col', {\n variants: {\n layout: {\n 'rail-start': 'ds:ps-4',\n 'rail-end': 'ds:pe-4',\n alternating:\n 'ds:grid ds:grid-cols-[1fr_2rem_1fr] ds:gap-x-[var(--spacing-md)]',\n },\n order: {\n 'newest-first': 'ds:flex-col',\n 'oldest-first': 'ds:flex-col-reverse',\n },\n },\n defaultVariants: { layout: 'rail-start', order: 'newest-first' },\n});\n\n/* ------------------------------------------------------------------ */\n/* CVA — event item */\n/* ------------------------------------------------------------------ */\n\nconst eventVariants = cva(\n 'ds:relative ds:flex ds:gap-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n {\n variants: {\n layout: {\n 'rail-start': [\n 'ds:flex-row',\n // Rail: continuous border on the inline-start of the event list\n 'ds:before:absolute ds:before:top-8 ds:before:bottom-0',\n 'ds:before:border-inline-start-[2px] ds:before:border-[color:var(--border)]',\n 'ds:before:inset-inline-start-[-1rem]',\n 'ds:last:before:hidden',\n ].join(' '),\n 'rail-end': [\n 'ds:flex-row-reverse',\n 'ds:before:absolute ds:before:top-8 ds:before:bottom-0',\n 'ds:before:border-inline-end-[2px] ds:before:border-[color:var(--border)]',\n 'ds:before:inset-inline-end-[-1rem]',\n 'ds:last:before:hidden',\n ].join(' '),\n alternating: 'ds:contents',\n },\n },\n defaultVariants: { layout: 'rail-start' },\n },\n);\n\n/* ------------------------------------------------------------------ */\n/* CVA — dot */\n/* ------------------------------------------------------------------ */\n\nconst dotVariants = cva(\n [\n 'ds:relative ds:z-10 ds:flex ds:items-center ds:justify-center',\n 'ds:rounded-[var(--radius-full)] ds:shrink-0',\n 'ds:size-8',\n 'ds:ring-2 ds:ring-[var(--background)]',\n ].join(' '),\n {\n variants: {\n type: {\n info: 'ds:bg-[var(--info)] ds:text-[var(--info-solid-foreground)]',\n success:\n 'ds:bg-[var(--success)] ds:text-[var(--success-solid-foreground)]',\n warning:\n 'ds:bg-[var(--warning)] ds:text-[var(--warning-solid-foreground)]',\n error:\n 'ds:bg-[var(--destructive)] ds:text-[var(--destructive-foreground)]',\n neutral: 'ds:bg-[var(--muted)] ds:text-[var(--muted-foreground)]',\n },\n },\n defaultVariants: { type: 'neutral' },\n },\n);\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\nexport interface TimelineProps\n extends\n Omit<OlHTMLAttributes<HTMLOListElement>, 'color'>,\n VariantProps<typeof timelineVariants> {\n layout?: Layout;\n order?: 'newest-first' | 'oldest-first';\n children: ReactNode;\n className?: string;\n}\n\nexport interface TimelineEventProps extends LiHTMLAttributes<HTMLLIElement> {\n type?: EventType;\n /** Opaque event id — when set, the component emits `data-event-id` for agent addressing. */\n eventId?: string;\n children: ReactNode;\n className?: string;\n}\n\n/** Curated imperative handle for agent / external automation. */\nexport interface TimelineHandle {\n getSelectedEvent: () => string | null;\n selectEvent: (id: string) => void;\n}\n\nexport interface TimelineDotProps extends HTMLAttributes<HTMLDivElement> {\n icon?: ReactNode;\n className?: string;\n}\n\nexport interface TimelineContentProps extends HTMLAttributes<HTMLDivElement> {\n title: string;\n description?: string;\n actor?: { name: string; src?: string };\n children?: ReactNode;\n className?: string;\n}\n\nexport interface TimelineTimestampProps extends TimeHTMLAttributes<HTMLTimeElement> {\n date: Date | string;\n /** Overrides the active language for date and time formatting. */\n locale?: string;\n relative?: boolean;\n format?: Intl.DateTimeFormatOptions;\n className?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* Default icons per type */\n/* ------------------------------------------------------------------ */\n\nconst TYPE_ICONS: Record<EventType, ReactNode> = {\n info: <Info size={16} aria-hidden=\"true\" />,\n success: <Check size={16} aria-hidden=\"true\" />,\n warning: <TriangleAlert size={16} aria-hidden=\"true\" />,\n error: <X size={16} aria-hidden=\"true\" />,\n neutral: <Circle size={16} aria-hidden=\"true\" />,\n};\n\n/* ------------------------------------------------------------------ */\n/* Timeline root */\n/* ------------------------------------------------------------------ */\n\nconst TimelineRoot = forwardRef<HTMLOListElement, TimelineProps>(\n (\n {\n layout = 'rail-start',\n order = 'newest-first',\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = useMemo(() => ({ layout, order }), [layout, order]);\n const olRef = useRef<HTMLOListElement | null>(null);\n const [selectedEvent, setSelectedEvent] = useState<string | null>(null);\n const latestRef = useRef<string | null>(null);\n latestRef.current = selectedEvent;\n\n const selectEvent = useCallback((id: string) => {\n setSelectedEvent(id);\n const target = olRef.current?.querySelector(\n `[data-event-id=\"${id}\"]`,\n ) as HTMLElement | null;\n target?.scrollIntoView({ block: 'center', behavior: 'auto' });\n }, []);\n\n const agentHandle = useMemo<TimelineHandle>(\n () => ({\n getSelectedEvent: () => latestRef.current,\n selectEvent,\n }),\n [selectEvent],\n );\n useImperativeHandle(ref, () => olRef.current as HTMLOListElement, []);\n useAgentRegistration(timelineAgent, agentHandle, props.id);\n\n return (\n <TimelineContext.Provider value={ctx}>\n <ol\n ref={olRef}\n data-component=\"timeline\"\n data-component-id={props.id}\n data-selected-event={selectedEvent ?? undefined}\n className={timelineVariants({ layout, order, className })}\n {...props}\n >\n {children}\n </ol>\n </TimelineContext.Provider>\n );\n },\n);\nTimelineRoot.displayName = 'Timeline';\n\n/* ------------------------------------------------------------------ */\n/* Timeline.Event */\n/* ------------------------------------------------------------------ */\n\nconst TimelineEvent = forwardRef<HTMLLIElement, TimelineEventProps>(\n ({ type = 'neutral', eventId, className, children, ...props }, ref) => {\n const { layout } = useContext(TimelineContext);\n const { t } = useTranslation();\n\n const evtCtx = useMemo(() => ({ type }), [type]);\n\n if (layout === 'alternating') {\n // In alternating layout the <li> uses `contents` so its children\n // participate directly in the parent grid.\n return (\n <TimelineEventContext.Provider value={evtCtx}>\n <li\n ref={ref}\n data-event-id={eventId}\n className={['ds:contents', className].filter(Boolean).join(' ')}\n {...props}\n >\n {/* Visually-hidden type prefix for screen readers */}\n <span className=\"ds:sr-only\">{t(`timeline.type.${type}`)}</span>\n {children}\n </li>\n </TimelineEventContext.Provider>\n );\n }\n\n return (\n <TimelineEventContext.Provider value={evtCtx}>\n <li\n ref={ref}\n data-event-id={eventId}\n className={eventVariants({ layout, className })}\n {...props}\n >\n {/* Visually-hidden type prefix for screen readers */}\n <span className=\"ds:sr-only\">{t(`timeline.type.${type}`)}</span>\n {children}\n </li>\n </TimelineEventContext.Provider>\n );\n },\n);\nTimelineEvent.displayName = 'Timeline.Event';\n\n/* ------------------------------------------------------------------ */\n/* Timeline.Dot */\n/* ------------------------------------------------------------------ */\n\nconst TimelineDot = forwardRef<HTMLDivElement, TimelineDotProps>(\n ({ icon, className, ...props }, ref) => {\n const { type } = useContext(TimelineEventContext);\n const { layout } = useContext(TimelineContext);\n\n const dot = (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={dotVariants({ type, className })}\n {...props}\n >\n {icon ?? TYPE_ICONS[type]}\n </div>\n );\n\n if (layout === 'alternating') {\n // In alternating grid: col 2 (centre) for the dot with the rail line\n return (\n <div\n aria-hidden=\"true\"\n className=\"ds:col-start-2 ds:flex ds:flex-col ds:items-center\"\n >\n {/* Rail segment above the dot */}\n <div className=\"ds:w-[var(--border-width-md)] ds:flex-1 ds:bg-[var(--border)] ds:first:hidden\" />\n {dot}\n {/* Rail segment below the dot */}\n <div className=\"ds:w-[var(--border-width-md)] ds:flex-1 ds:bg-[var(--border)]\" />\n </div>\n );\n }\n\n return dot;\n },\n);\nTimelineDot.displayName = 'Timeline.Dot';\n\n/* ------------------------------------------------------------------ */\n/* Timeline.Content */\n/* ------------------------------------------------------------------ */\n\nconst TimelineContent = forwardRef<HTMLDivElement, TimelineContentProps>(\n ({ title, description, actor, children, className, ...props }, ref) => {\n const { layout } = useContext(TimelineContext);\n\n const inner = (\n <div\n ref={ref}\n className={[\n 'ds:flex-1 ds:min-w-0 ds:pb-[var(--spacing-md)]',\n // Wrap policy: `break-word` (not `anywhere`) preserves word-\n // boundary wrapping for natural-language titles / descriptions;\n // only genuinely unbreakable strings (URLs, hashes) break mid-\n // word when they would otherwise overflow. `anywhere` introduces\n // a soft-wrap opportunity at every character boundary, which\n // chopped Italian / German labels mid-word when an event card\n // sat in a narrow context.\n 'ds:[&_*]:break-normal ds:[&_*]:[overflow-wrap:break-word]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n {...props}\n >\n <Card variant=\"outlined\">\n <Card.Body>\n <p className=\"type-label ds:text-[var(--foreground)]\">{title}</p>\n {description && (\n <p className=\"ds:mt-[var(--spacing-xs)] type-body-sm ds:text-[var(--muted-foreground)]\">\n {description}\n </p>\n )}\n {actor && (\n <div className=\"ds:mt-[var(--spacing-sm)] ds:flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <Avatar size=\"xs\" name={actor.name} src={actor.src} />\n <span className=\"type-meta ds:text-[var(--muted-foreground)]\">\n {actor.name}\n </span>\n </div>\n )}\n {children}\n </Card.Body>\n </Card>\n </div>\n );\n\n if (layout === 'alternating') {\n // Alternating: odd events in col 1 (start), even events in col 3 (end).\n // We use CSS nth-child targeting via a wrapper that sets col placement.\n return (\n <div className=\"ds:col-span-1 ds:[li:nth-child(even)_&]:col-start-3 ds:[li:nth-child(odd)_&]:col-start-1\">\n {inner}\n </div>\n );\n }\n\n return inner;\n },\n);\nTimelineContent.displayName = 'Timeline.Content';\n\n/* ------------------------------------------------------------------ */\n/* Timeline.Timestamp — thin wrapper over the shared Timestamp */\n/* component. Keeps the existing API (`date`, `relative`, `format`) */\n/* for backward compatibility; adds tabular-nums because timeline */\n/* timestamps sit in a rail gutter and benefit from column-aligned */\n/* digits. */\n/* ------------------------------------------------------------------ */\n\nconst TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1000;\n\nconst TimelineTimestamp = forwardRef<HTMLTimeElement, TimelineTimestampProps>(\n (\n {\n date,\n locale,\n relative = true,\n format = { dateStyle: 'medium', timeStyle: 'short' },\n className,\n ...props\n },\n ref,\n ) => (\n <Timestamp\n ref={ref}\n value={date}\n locale={locale}\n format={relative ? 'relative' : 'absolute'}\n relativeWindow={relative ? TWENTY_FOUR_HOURS_MS : undefined}\n absoluteFormat={format}\n className={[\n 'ds:text-[var(--muted-foreground)]',\n 'ds:[font-variant-numeric:var(--font-feature-tabular)]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n {...props}\n />\n ),\n);\nTimelineTimestamp.displayName = 'Timeline.Timestamp';\n\n/* ------------------------------------------------------------------ */\n/* Compound export */\n/* ------------------------------------------------------------------ */\n\nexport const Timeline = Object.assign(TimelineRoot, {\n Event: TimelineEvent,\n Dot: TimelineDot,\n Content: TimelineContent,\n Timestamp: TimelineTimestamp,\n});\n"],"names":["timelineAgent","handle","args","TimelineContext","createContext","TimelineEventContext","timelineVariants","cva","eventVariants","dotVariants","TYPE_ICONS","jsx","Info","Check","TriangleAlert","X","Circle","TimelineRoot","forwardRef","layout","order","className","children","props","ref","ctx","useMemo","olRef","useRef","selectedEvent","setSelectedEvent","useState","latestRef","selectEvent","useCallback","id","target","_a","agentHandle","useImperativeHandle","useAgentRegistration","TimelineEvent","type","eventId","useContext","t","useTranslation","evtCtx","jsxs","TimelineDot","icon","dot","TimelineContent","title","description","actor","inner","Card","Avatar","TWENTY_FOUR_HOURS_MS","TimelineTimestamp","date","locale","relative","format","Timestamp","Timeline"],"mappings":";;;;;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gFACb,UAAA;AAAA,YAAA,gBAAArC,EAAC+C,GAAA,EAAO,MAAK,MAAK,MAAMH,EAAM,MAAM,KAAKA,EAAM,IAAA,CAAK;AAAA,YACpD,gBAAA5C,EAAC,QAAA,EAAK,WAAU,+CACb,YAAM,KAAA,CACT;AAAA,UAAA,GACF;AAAA,UAEDW;AAAA,QAAA,EAAA,CACH,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAIJ,WAAIH,MAAW,gBAIX,gBAAAR,EAAC,OAAA,EAAI,WAAU,4FACZ,UAAA6C,GACH,IAIGA;AAAA,EACT;AACF;AACAJ,EAAgB,cAAc;AAU9B,MAAMO,IAAuB,OAAU,KAAK,KAEtCC,IAAoB1C;AAAA,EACxB,CACE;AAAA,IACE,MAAA2C;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,QAAAC,IAAS,EAAE,WAAW,UAAU,WAAW,QAAA;AAAA,IAC3C,WAAA3C;AAAA,IACA,GAAGE;AAAA,EAAA,GAELC,MAEA,gBAAAb;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,KAAAzC;AAAA,MACA,OAAOqC;AAAA,MACP,QAAAC;AAAA,MACA,QAAQC,IAAW,aAAa;AAAA,MAChC,gBAAgBA,IAAWJ,IAAuB;AAAA,MAClD,gBAAgBK;AAAA,MAChB,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA3C;AAAA,MAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACV,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;AACAqC,EAAkB,cAAc;AAMzB,MAAMM,KAAW,OAAO,OAAOjD,GAAc;AAAA,EAClD,OAAOwB;AAAA,EACP,KAAKQ;AAAA,EACL,SAASG;AAAA,EACT,WAAWQ;AACb,CAAC;"}
@@ -0,0 +1,210 @@
1
+ import { useRef as I, useEffect as M, useState as F, useMemo as E, useCallback as s } from "react";
2
+ import { flushSync as R } from "react-dom";
3
+ function x(e) {
4
+ return e != null && e.current ? e.current : typeof document > "u" ? null : document;
5
+ }
6
+ function O(e, l) {
7
+ const c = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : (
8
+ // SSR / jsdom fallback — drop every character that's
9
+ // significant in a CSS attribute selector. Conservative but
10
+ // robust enough for the test environment.
11
+ e.replace(/["'\\[\]]/g, "")
12
+ ), d = `[data-error-anchor="${c}"], [name="${c}"], [name$="[${c}]"]`, u = Array.from(l.querySelectorAll(d));
13
+ return u.length === 0 ? null : u.find((p) => p.offsetParent !== null) ?? u[0];
14
+ }
15
+ function $(e, l, c = {}) {
16
+ const {
17
+ scope: d,
18
+ scrollOptions: u = { behavior: "smooth", block: "center" },
19
+ focus: a = !0,
20
+ skipInitialMount: p = !0
21
+ } = c, o = I(!1), f = I(null), i = l.find((h) => !!e[h]) ?? null;
22
+ M(() => {
23
+ if (p && !o.current) {
24
+ o.current = !0, f.current = i;
25
+ return;
26
+ }
27
+ if (!i) {
28
+ f.current = null;
29
+ return;
30
+ }
31
+ if (i === f.current || typeof window > "u") return;
32
+ const h = window.requestAnimationFrame(() => {
33
+ const g = x(d);
34
+ if (!g) return;
35
+ const t = O(i, g);
36
+ t && (t.scrollIntoView(u), a && t.focus({ preventScroll: !0 }), f.current = i);
37
+ });
38
+ return () => window.cancelAnimationFrame(h);
39
+ }, [i]);
40
+ }
41
+ function k(e, l = !1) {
42
+ const c = {};
43
+ for (const d of e)
44
+ c[d.id] = { signed: l ? !1 : !!d.signed };
45
+ return c;
46
+ }
47
+ function D(e) {
48
+ const [l, c] = F(
49
+ () => k(e)
50
+ ), [d, u] = F(null), [a, p] = F(
51
+ () => {
52
+ var n;
53
+ return ((n = e[0]) == null ? void 0 : n.id) ?? null;
54
+ }
55
+ ), o = E(
56
+ () => e.map((n) => {
57
+ const r = l[n.id];
58
+ return {
59
+ ...n,
60
+ signed: r ? r.signed : !!n.signed,
61
+ payload: r == null ? void 0 : r.payload
62
+ };
63
+ }),
64
+ [e, l]
65
+ ), f = E(
66
+ () => o.reduce((n, r) => r.signed ? n + 1 : n, 0),
67
+ [o]
68
+ ), i = o.length, h = i > 0 && f === i, g = s((n) => {
69
+ u(n);
70
+ }, []), t = s(() => {
71
+ u(null);
72
+ }, []), w = s((n, r) => {
73
+ c((m) => ({ ...m, [n]: { signed: !0, payload: r } })), u((m) => m === n ? null : m);
74
+ }, []), T = s(
75
+ (n) => {
76
+ var r;
77
+ return !!((r = l[n]) != null && r.signed);
78
+ },
79
+ [l]
80
+ ), S = s(() => {
81
+ var n;
82
+ c(k(e, !0)), u(null), p(((n = e[0]) == null ? void 0 : n.id) ?? null);
83
+ }, [e]), C = s(() => {
84
+ p((n) => {
85
+ const r = o.length;
86
+ if (r === 0) return null;
87
+ const m = n ? o.findIndex((y) => y.id === n) : -1;
88
+ return o[(m + 1 + r) % r].id;
89
+ });
90
+ }, [o]), v = s(() => {
91
+ p((n) => {
92
+ const r = o.length;
93
+ if (r === 0) return null;
94
+ const m = n ? o.findIndex((y) => y.id === n) : 0;
95
+ return o[(m - 1 + r) % r].id;
96
+ });
97
+ }, [o]), A = s(() => {
98
+ p((n) => {
99
+ const r = o.length;
100
+ if (r === 0) return n;
101
+ const m = n ? o.findIndex((y) => y.id === n) : -1;
102
+ for (let y = 1; y <= r; y += 1) {
103
+ const b = o[(m + y) % r];
104
+ if (!b.signed) return b.id;
105
+ }
106
+ return n;
107
+ });
108
+ }, [o]);
109
+ return E(
110
+ () => ({
111
+ fields: o,
112
+ signedCount: f,
113
+ total: i,
114
+ isComplete: h,
115
+ activeFieldId: d,
116
+ openField: g,
117
+ closeField: t,
118
+ markSigned: w,
119
+ isFieldSigned: T,
120
+ reset: S,
121
+ cursorFieldId: a,
122
+ goToNextField: C,
123
+ goToPreviousField: v,
124
+ goToNextUnsigned: A
125
+ }),
126
+ [
127
+ o,
128
+ f,
129
+ i,
130
+ h,
131
+ d,
132
+ g,
133
+ t,
134
+ w,
135
+ T,
136
+ S,
137
+ a,
138
+ C,
139
+ v,
140
+ A
141
+ ]
142
+ );
143
+ }
144
+ const q = "ds-zoom-drilldown", L = () => {
145
+ if (typeof document > "u") return null;
146
+ const e = document.querySelector("main");
147
+ return e ? e.querySelector("[data-radix-scroll-area-viewport]") ?? e.closest("[data-radix-scroll-area-viewport]") ?? e : null;
148
+ }, N = (e) => typeof e.startViewTransition == "function" && typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("view-transition-class", q);
149
+ function P(e = {}) {
150
+ const [l, c] = F(null), d = I(
151
+ null
152
+ ), u = I(e.getScrollContainer);
153
+ u.current = e.getScrollContainer;
154
+ const a = s(
155
+ () => (u.current ?? L)(),
156
+ []
157
+ ), p = s(() => {
158
+ const t = a();
159
+ return {
160
+ window: typeof window < "u" ? window.scrollY : 0,
161
+ container: t ? t.scrollTop : 0
162
+ };
163
+ }, [a]), o = s(() => {
164
+ const t = d.current;
165
+ if (!t) return;
166
+ d.current = null;
167
+ let w = 0;
168
+ const T = () => {
169
+ const S = a();
170
+ typeof window < "u" && window.scrollTo({ top: t.window }), S && (S.scrollTop = t.container), !((typeof window > "u" || Math.abs(window.scrollY - t.window) < 2) && (!S || Math.abs(S.scrollTop - t.container) < 2)) && w < 20 && (w += 1, requestAnimationFrame(T));
171
+ };
172
+ T();
173
+ }, [a]), f = s(() => {
174
+ const t = a();
175
+ typeof window < "u" && window.scrollTo({ top: 0 }), t && (t.scrollTop = 0);
176
+ }, [a]), i = s(
177
+ (t) => {
178
+ var v;
179
+ const w = document, T = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, S = t === null;
180
+ if (T || !N(w) || !w.startViewTransition) {
181
+ R(() => c(t)), S ? o() : f();
182
+ return;
183
+ }
184
+ const C = w.startViewTransition(() => {
185
+ R(() => c(t)), S || f();
186
+ });
187
+ S && ((v = C == null ? void 0 : C.finished) == null || v.then(o, o));
188
+ },
189
+ [o, f]
190
+ ), h = s(
191
+ (t) => {
192
+ d.current = p(), i(t);
193
+ },
194
+ [p, i]
195
+ ), g = s(() => i(null), [i]);
196
+ return M(() => {
197
+ if (l === null) return;
198
+ const t = (w) => {
199
+ w.key === "Escape" && !w.defaultPrevented && g();
200
+ };
201
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
202
+ }, [l, g]), { selected: l, open: h, close: g };
203
+ }
204
+ export {
205
+ q as Z,
206
+ D as a,
207
+ P as b,
208
+ $ as u
209
+ };
210
+ //# sourceMappingURL=use-zoom-drilldown-qCX34w9I.js.map