@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
@@ -1,353 +0,0 @@
1
- import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as oe, useRef as a, useState as M, useId as le, useCallback as ce, useEffect as de, useImperativeHandle as ue, useMemo as pe } from "react";
3
- import { c as fe } from "./index-D2ZczOXr.js";
4
- import { useTranslation as me } from "react-i18next";
5
- import { u as ge } from "./registry-DvAUVLHh.js";
6
- import { C as he } from "./clinical-note-card-BBgFd2nB.js";
7
- import { R as ve } from "./rich-text-editor-lSCiE0Zz.js";
8
- import { T as be } from "./text-area-Bt3p7Pt0.js";
9
- import { B as ye } from "./button-nJaPh_HC.js";
10
- import { C as xe } from "./checkbox-BuZ1u__2.js";
11
- import { P as Pe } from "./panel-header-D313n_9-.js";
12
- import { N as Ce } from "./notebook-pen-CO7HoM-W.js";
13
- const Ne = {
14
- id: "notes-panel",
15
- // 'submit' backs add_note (compose + commit a note). pin / flag are toggles
16
- // with no dedicated capability in the closed vocabulary.
17
- capabilities: ["submit"],
18
- state: {
19
- notes: {
20
- type: "Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean }>",
21
- descriptionKey: "ui.agent.notesPanel.state.notes",
22
- description: "Timeline note ids + pinned / flagged / clinical flags. Never the note body or author (both PHI).",
23
- read: (n) => n.getNotes()
24
- },
25
- canAddClinical: {
26
- type: "boolean",
27
- descriptionKey: "ui.agent.notesPanel.state.canAddClinical",
28
- description: "Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).",
29
- read: (n) => n.canAddClinical()
30
- },
31
- currentNoteId: {
32
- type: "string | null",
33
- descriptionKey: "ui.agent.notesPanel.state.currentNoteId",
34
- description: "Id of the note the host has addressed — the one marked, scrolled to and focused. Null when none is. An id only, never note content.",
35
- read: (n) => n.getCurrentNoteId()
36
- }
37
- },
38
- actions: {
39
- add_note: {
40
- // Writes a clinical/admin note body — patient-identifiable content. PHI.
41
- safety: "phi",
42
- argsType: "{ content: string; clinical: boolean }",
43
- argsSchema: {
44
- type: "object",
45
- properties: {
46
- content: {
47
- type: "string",
48
- description: "Note body. Rich HTML for the rich composer, else plain text."
49
- },
50
- clinical: {
51
- type: "boolean",
52
- description: "Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed."
53
- }
54
- },
55
- required: ["content", "clinical"]
56
- },
57
- openWorld: !0,
58
- descriptionKey: "ui.agent.notesPanel.actions.addNote",
59
- description: "Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).",
60
- examples: [
61
- {
62
- args: { content: "Patient reported improvement.", clinical: !0 },
63
- note: "Add a clinical note."
64
- }
65
- ],
66
- invoke: (n, s) => {
67
- n.addNote(s);
68
- }
69
- },
70
- toggle_pin: {
71
- // Re-orders the timeline (pinned notes lead) — reversible view write.
72
- safety: "write",
73
- argsType: "{ id: string }",
74
- argsSchema: {
75
- type: "object",
76
- properties: { id: { type: "string" } },
77
- required: ["id"]
78
- },
79
- idempotent: !1,
80
- descriptionKey: "ui.agent.notesPanel.actions.togglePin",
81
- description: "Toggle the pinned state of the note with the given id.",
82
- invoke: (n, s) => {
83
- n.togglePin(s.id);
84
- }
85
- },
86
- toggle_flag: {
87
- safety: "write",
88
- argsType: "{ id: string }",
89
- argsSchema: {
90
- type: "object",
91
- properties: { id: { type: "string" } },
92
- required: ["id"]
93
- },
94
- idempotent: !1,
95
- descriptionKey: "ui.agent.notesPanel.actions.toggleFlag",
96
- description: "Toggle the flagged state of the note with the given id.",
97
- invoke: (n, s) => {
98
- n.toggleFlag(s.id);
99
- }
100
- }
101
- },
102
- domHooks: {
103
- root: {
104
- attr: "data-component",
105
- value: "notes-panel",
106
- description: "Marks the NotesPanel region."
107
- },
108
- instanceId: {
109
- attr: "data-component-id",
110
- sourceProp: "id",
111
- description: "Sourced from the id prop. Required to address a specific notes panel from the agent."
112
- }
113
- }
114
- }, we = fe(
115
- "ds:flex ds:flex-col ds:rounded-[var(--radius-md)] ds:border-s-2 ds:ps-[var(--spacing-sm)]",
116
- {
117
- variants: {
118
- current: {
119
- true: "ds:border-[color:var(--info)] ds:bg-[color:var(--info)]/10 ds:focus:outline-[length:var(--focus-ring-width)] ds:focus:outline-solid ds:focus:outline-[color:var(--ring)] ds:focus:outline-offset-[length:var(--focus-ring-offset)]",
120
- false: "ds:border-transparent"
121
- }
122
- },
123
- defaultVariants: { current: !1 }
124
- }
125
- );
126
- function z(n) {
127
- return n ? /<img\b/i.test(n) ? !0 : n.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").trim().length > 0 : !1;
128
- }
129
- const Me = oe(
130
- function({
131
- id: s,
132
- notes: x,
133
- onAddNote: l,
134
- currentNoteId: c,
135
- currentNoteKey: B,
136
- composer: f = "rich",
137
- editorToolbar: L = "standard",
138
- redactor: W,
139
- imageUploadUrl: E,
140
- showClinicalToggle: I = !0,
141
- canAddClinicalNote: m = !0,
142
- clinicalGatedReason: D,
143
- defaultClinical: P = !1,
144
- onRequestAiDraft: G,
145
- aiDraftFormat: Y,
146
- aiPrivacyNotice: F,
147
- onDictate: J,
148
- onProofread: O,
149
- onAutoFormat: Q,
150
- onTogglePin: g,
151
- onToggleFlag: h,
152
- noteActions: V,
153
- title: U,
154
- composerPlaceholder: X,
155
- addNoteLabel: Z,
156
- emptyState: $,
157
- className: ee,
158
- "aria-label": C,
159
- ...te
160
- }, ne) {
161
- const { t: o } = me(), N = a(null), [d, w] = M(""), [v, j] = M(P), ie = U ?? o("notesPanel.title", { defaultValue: "Notes" }), H = le(), q = X ?? o("notesPanel.placeholder", { defaultValue: "Add a note…" }), K = o("notesPanel.composerLabel", {
162
- defaultValue: "New note"
163
- }), re = f === "rich" ? z(d) : d.trim().length > 0, ae = ce(() => {
164
- var e, t;
165
- if (l) {
166
- if (f === "rich") {
167
- const i = ((e = N.current) == null ? void 0 : e.getHTML()) ?? d;
168
- if (!z(i)) return;
169
- l({ content: i, clinical: v }), (t = N.current) == null || t.clear();
170
- } else {
171
- const i = d.trim();
172
- if (!i) return;
173
- l({ content: i, clinical: v });
174
- }
175
- w(""), j(P);
176
- }
177
- }, [f, d, v, P, l]), T = [...x].sort(
178
- (e, t) => Number(t.pinned ?? !1) - Number(e.pinned ?? !1)
179
- ), R = a(null);
180
- de(() => {
181
- var e, t;
182
- c && ((e = R.current) == null || e.scrollIntoView({ block: "center" }), (t = R.current) == null || t.focus());
183
- }, [c, B]);
184
- const _ = a(x);
185
- _.current = x;
186
- const u = a(l);
187
- u.current = l;
188
- const b = a(g);
189
- b.current = g;
190
- const y = a(h);
191
- y.current = h;
192
- const k = a(m);
193
- k.current = m;
194
- const A = a(c);
195
- A.current = c;
196
- const S = a(null);
197
- ue(ne, () => S.current, []);
198
- const se = pe(
199
- () => ({
200
- // Ids + flags only — never the note body or author (both PHI).
201
- getNotes: () => _.current.map((e) => ({
202
- id: e.id,
203
- pinned: !!e.pinned,
204
- flagged: !!e.flagged,
205
- clinical: !!e.clinical
206
- })),
207
- canAddNote: () => !!u.current,
208
- canAddClinical: () => k.current,
209
- getCurrentNoteId: () => A.current ?? null,
210
- addNote: (e) => {
211
- var t;
212
- e.clinical && !k.current || (t = u.current) == null || t.call(u, e);
213
- },
214
- togglePin: (e) => {
215
- var t;
216
- return (t = b.current) == null ? void 0 : t.call(b, e);
217
- },
218
- toggleFlag: (e) => {
219
- var t;
220
- return (t = y.current) == null ? void 0 : t.call(y, e);
221
- }
222
- }),
223
- []
224
- );
225
- return ge(Ne, se, s), /* @__PURE__ */ p(
226
- "section",
227
- {
228
- ref: S,
229
- "data-component": "notes-panel",
230
- "data-component-id": s,
231
- "aria-labelledby": C ? void 0 : H,
232
- "aria-label": C,
233
- className: ["ds:flex ds:flex-col", ee].filter(Boolean).join(" "),
234
- ...te,
235
- children: [
236
- /* @__PURE__ */ r(
237
- Pe,
238
- {
239
- title: ie,
240
- icon: /* @__PURE__ */ r(Ce, { "aria-hidden": "true" }),
241
- headingId: C ? void 0 : H,
242
- sticky: !0,
243
- divider: !0
244
- }
245
- ),
246
- /* @__PURE__ */ p("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
247
- l ? /* @__PURE__ */ p("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
248
- f === "rich" ? /* @__PURE__ */ r(
249
- ve,
250
- {
251
- ref: N,
252
- ariaLabel: K,
253
- placeholder: q,
254
- toolbar: L,
255
- minHeight: "sm",
256
- redactor: W,
257
- imageUploadUrl: E,
258
- onChange: ({ html: e }) => w(e),
259
- onRequestAiDraft: G,
260
- aiDraftFormat: Y,
261
- aiPrivacyNotice: F,
262
- onDictate: J,
263
- onProofread: O,
264
- onAutoFormat: Q
265
- }
266
- ) : /* @__PURE__ */ r(
267
- be,
268
- {
269
- value: d,
270
- onChange: (e) => w(e.target.value),
271
- placeholder: q,
272
- autoResize: !0,
273
- minRows: 2,
274
- maxRows: 6,
275
- "aria-label": K
276
- }
277
- ),
278
- /* @__PURE__ */ p(
279
- "div",
280
- {
281
- className: [
282
- "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
283
- I ? "ds:justify-between" : "ds:justify-end"
284
- ].join(" "),
285
- children: [
286
- I ? /* @__PURE__ */ r(
287
- xe,
288
- {
289
- size: "sm",
290
- label: o("notesPanel.clinicalToggle", {
291
- defaultValue: "Clinical note"
292
- }),
293
- checked: v,
294
- onCheckedChange: (e) => j(e === !0),
295
- disabled: !m,
296
- disabledReason: m ? void 0 : D ?? o("notesPanel.clinicalGated", {
297
- defaultValue: "You do not have permission to write clinical notes."
298
- })
299
- }
300
- ) : null,
301
- /* @__PURE__ */ r(
302
- ye,
303
- {
304
- type: "button",
305
- size: "sm",
306
- onClick: ae,
307
- disabled: !re,
308
- children: Z ?? o("notesPanel.add", { defaultValue: "Add note" })
309
- }
310
- )
311
- ]
312
- }
313
- )
314
- ] }) : null,
315
- T.length > 0 ? /* @__PURE__ */ r("ul", { className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0", children: T.map((e, t) => {
316
- const i = c != null && e.id === c;
317
- return /* @__PURE__ */ p(
318
- "li",
319
- {
320
- ref: i ? R : void 0,
321
- tabIndex: i ? -1 : void 0,
322
- "aria-current": i ? "true" : void 0,
323
- className: we({ current: i }),
324
- children: [
325
- i ? /* @__PURE__ */ r("span", { className: "ds:sr-only", children: o("notesPanel.current", {
326
- defaultValue: "Current note"
327
- }) }) : null,
328
- /* @__PURE__ */ r(
329
- he,
330
- {
331
- surface: "elevated",
332
- truncate: !i,
333
- ...e,
334
- onTogglePin: g && e.id ? () => g(e.id) : void 0,
335
- onToggleFlag: h && e.id ? () => h(e.id) : void 0
336
- }
337
- ),
338
- V ? /* @__PURE__ */ r("div", { className: "ds:flex ds:justify-end ds:gap-[var(--spacing-2xs)] ds:pt-[var(--spacing-2xs)]", children: V(e) }) : null
339
- ]
340
- },
341
- e.id ?? t
342
- );
343
- }) }) : $ ?? /* @__PURE__ */ r("p", { className: "ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]", children: o("notesPanel.empty", { defaultValue: "No notes yet." }) })
344
- ] })
345
- ]
346
- }
347
- );
348
- }
349
- );
350
- export {
351
- Me as N
352
- };
353
- //# sourceMappingURL=notes-panel-CTNpsByN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notes-panel-CTNpsByN.js","sources":["../../src/components/notes-panel/notes-panel.agent.ts","../../src/components/notes-panel/notes-panel.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — NotesPanel. */\n/* */\n/* The Notes tool: a composer over a note timeline. The agent reads the */\n/* timeline STRUCTURE (note ids + pinned / flagged / clinical flags — */\n/* never the note body or author, both PHI), composes and commits a new */\n/* note, and toggles a note's pinned / flagged state. `add_note` carries */\n/* the `phi` safety class: a note body is patient-identifiable clinical */\n/* content, so the host gates it behind the same confirm-before-act as a */\n/* destructive write and never auto-confirms. A clinical submission also */\n/* requires the host's `practice_add_clinical_note` permission (the */\n/* handle drops it when the gate is closed). Host-owned per-note */\n/* `noteActions` (edit, delete…) sit outside this handle — an agent */\n/* reaches them through the host's own adapters. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { NotesPanelHandle } from './notes-panel';\n\nexport const notesPanelAgent: AgentAdapter<NotesPanelHandle> = {\n id: 'notes-panel',\n // 'submit' backs add_note (compose + commit a note). pin / flag are toggles\n // with no dedicated capability in the closed vocabulary.\n capabilities: ['submit'],\n state: {\n notes: {\n type: 'Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean }>',\n descriptionKey: 'ui.agent.notesPanel.state.notes',\n description:\n 'Timeline note ids + pinned / flagged / clinical flags. Never the note body or author (both PHI).',\n read: (handle) => handle.getNotes(),\n },\n canAddClinical: {\n type: 'boolean',\n descriptionKey: 'ui.agent.notesPanel.state.canAddClinical',\n description:\n 'Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).',\n read: (handle) => handle.canAddClinical(),\n },\n currentNoteId: {\n type: 'string | null',\n descriptionKey: 'ui.agent.notesPanel.state.currentNoteId',\n description:\n 'Id of the note the host has addressed — the one marked, scrolled to and focused. Null when none is. An id only, never note content.',\n read: (handle) => handle.getCurrentNoteId(),\n },\n },\n actions: {\n add_note: {\n // Writes a clinical/admin note body — patient-identifiable content. PHI.\n safety: 'phi',\n argsType: '{ content: string; clinical: boolean }',\n argsSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description:\n 'Note body. Rich HTML for the rich composer, else plain text.',\n },\n clinical: {\n type: 'boolean',\n description:\n 'Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed.',\n },\n },\n required: ['content', 'clinical'],\n },\n openWorld: true,\n descriptionKey: 'ui.agent.notesPanel.actions.addNote',\n description:\n 'Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).',\n examples: [\n {\n args: { content: 'Patient reported improvement.', clinical: true },\n note: 'Add a clinical note.',\n },\n ],\n invoke: (handle, args: { content: string; clinical: boolean }) => {\n handle.addNote(args);\n },\n },\n toggle_pin: {\n // Re-orders the timeline (pinned notes lead) — reversible view write.\n safety: 'write',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: false,\n descriptionKey: 'ui.agent.notesPanel.actions.togglePin',\n description: 'Toggle the pinned state of the note with the given id.',\n invoke: (handle, args: { id: string }) => {\n handle.togglePin(args.id);\n },\n },\n toggle_flag: {\n safety: 'write',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: false,\n descriptionKey: 'ui.agent.notesPanel.actions.toggleFlag',\n description: 'Toggle the flagged state of the note with the given id.',\n invoke: (handle, args: { id: string }) => {\n handle.toggleFlag(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'notes-panel',\n description: 'Marks the NotesPanel region.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Required to address a specific notes panel from the agent.',\n },\n },\n};\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { notesPanelAgent } from './notes-panel.agent';\nimport { ClinicalNoteCard } from '../clinical-note-card';\nimport type { ClinicalNoteCardProps } from '../clinical-note-card';\nimport { RichTextEditor } from '../rich-text-editor';\nimport type {\n RichTextEditorHandle,\n RichTextEditorProps,\n RichTextEditorToolbar,\n RedactorFactory,\n} from '../rich-text-editor';\nimport { TextArea } from '../text-area';\nimport { Button } from '../button';\nimport { Checkbox } from '../checkbox';\nimport { NotebookPen } from 'lucide-react';\nimport { PanelHeader } from '../panel-header';\n\n/* ------------------------------------------------------------------ */\n/* NotesPanel — the Notes tool for the Control Room rail. */\n/* */\n/* A composer over an elevated ClinicalNoteCard timeline. Drops */\n/* into a ControlRoomRail tool `panel`, the patient profile, or the */\n/* care-plan editor — anywhere notes about the open entity belong. */\n/* The composer is the kit RichTextEditor by default (degrades to a */\n/* textarea where Redactor is absent), carries a permission-gated */\n/* \"clinical note\" toggle, and forwards the editor's AI affordances. */\n/* The note attaches to whatever entity the host is showing — the */\n/* host owns the attachment; the panel only emits content + clinical. */\n/* Pinned notes lead; pin / flag are inline per-note toggles. */\n/* ------------------------------------------------------------------ */\n\n/**\n * One note in the panel — the data subset of `ClinicalNoteCard`.\n *\n * `aria-label` names the card for assistive tech. Set it whenever a row is not\n * a clinical note: the card's fallback name is \"Clinical note\", so an entry\n * that is something else (a dated event, an import) is announced as one.\n */\nexport type NotesPanelNote = Pick<\n ClinicalNoteCardProps,\n | 'id'\n | 'dateIso'\n | 'createdAtIso'\n | 'author'\n | 'clinical'\n | 'attachedTo'\n | 'content'\n | 'contentFormat'\n | 'pinned'\n | 'flagged'\n | 'aria-label'\n>;\n\n/**\n * Curated agent handle for NotesPanel. Reads the note timeline's STRUCTURE\n * (ids + pinned / flagged / clinical flags — never the note body or author,\n * both PHI) and drives the composer + per-note toggles. See\n * `notes-panel.agent.ts`.\n */\nexport interface NotesPanelHandle {\n /** Timeline snapshot — ids + flags only, never note content (PHI). */\n getNotes: () => Array<{\n id?: string;\n pinned: boolean;\n flagged: boolean;\n clinical: boolean;\n }>;\n /** Whether the composer is mounted (onAddNote is wired). */\n canAddNote: () => boolean;\n /** Whether clinical notes may be written (the permission gate). */\n canAddClinical: () => boolean;\n /** Id of the note the host has addressed, or null when none is. */\n getCurrentNoteId: () => string | null;\n /** Commit a new note with explicit content (mirrors the composer's submit). */\n addNote: (submission: NotesPanelSubmission) => void;\n /** Toggle a note's pinned state (mirrors onTogglePin). */\n togglePin: (id: string) => void;\n /** Toggle a note's flagged state (mirrors onToggleFlag). */\n toggleFlag: (id: string) => void;\n}\n\n/** Payload handed to `onAddNote` when the composer commits. */\nexport interface NotesPanelSubmission {\n /** The note body — rich HTML (`composer='rich'`) or plain text. */\n content: string;\n /** Whether the \"clinical note\" toggle was set. */\n clinical: boolean;\n}\n\nexport interface NotesPanelProps extends Omit<\n HTMLAttributes<HTMLElement>,\n 'title' | 'children'\n> {\n /**\n * Stable instance id. Surfaced on the root as `data-component-id` so an\n * agent / MCP UI bridge can address this specific notes panel.\n */\n id?: string;\n /** Notes to render, newest-first by convention. Pinned notes lead. */\n notes: NotesPanelNote[];\n /** Commit a new note. Omit to hide the composer (read-only timeline). */\n onAddNote?: (submission: NotesPanelSubmission) => void;\n /**\n * The note the reader ASKED for, addressed by id from somewhere else in the\n * record — a marker in a chart, a row in a grid, an agent. The panel marks\n * it, scrolls it to the middle of its own scroll region and moves focus to\n * it, and renders it unclamped so the thing that was asked for is readable\n * in full without a second click.\n *\n * Opening a panel is not the same as answering a question: a rail's\n * `setActiveTool` moves no focus and announces nothing, so a control whose\n * name promises \"in the notes panel\" produces no perceivable change for a\n * keyboard or screen-reader reader unless the panel lands them on the note.\n * That is what this prop is for; without it, a host has to reach into the\n * panel's DOM to do the same job.\n *\n * Marked on three channels, never colour alone (WCAG 1.4.1): a solid\n * inline-start bar the other notes do not have, a tinted gutter, and\n * `aria-current` plus a visually-hidden sentence naming the mark.\n *\n * Ids that match no note are ignored. To address the SAME note twice — the\n * reader pressing the same marker again after scrolling away — bump\n * `currentNoteKey` alongside it; this prop alone is a value, not a request.\n */\n currentNoteId?: string;\n /**\n * Bump on every address to re-scroll and re-focus the note in `currentNoteId`\n * even when the id has not changed.\n *\n * Addressing is a request, not a value: a reader who presses the same marker\n * a second time (having scrolled away, or having moved focus off the note) is\n * asking to be taken back, and a control whose name promises the notes panel\n * must do something perceivable every time it is pressed. Without this the\n * second press is inert — the panel is already showing that note, so nothing\n * re-runs. Hosts increment a counter in the same handler that opens the tool.\n */\n currentNoteKey?: string | number;\n\n /* ----- Composer ----- */\n /**\n * `'rich'` (default) mounts the kit `RichTextEditor` (Redactor; degrades to a\n * textarea where Redactor is absent). `'plain'` keeps a simple `TextArea` for\n * lightweight surfaces / deterministic tests.\n */\n composer?: 'rich' | 'plain';\n /** Toolbar preset for the rich composer. Defaults to `'standard'`. */\n editorToolbar?: RichTextEditorToolbar;\n /** Inject the Redactor factory for the rich composer (else `window.$R`). */\n redactor?: RedactorFactory;\n /** Consumer image-upload endpoint for the rich composer. */\n imageUploadUrl?: string;\n\n /* ----- Clinical flag (permission-gated) ----- */\n /** Show the \"clinical note\" toggle in the composer. Default `true`. */\n showClinicalToggle?: boolean;\n /**\n * Permission gate — when `false` the clinical toggle is disabled and shows\n * `clinicalGatedReason` on hover/focus. Mirrors platform's\n * `practice_add_clinical_note` permission. Default `true`.\n */\n canAddClinicalNote?: boolean;\n /** Tooltip shown when the clinical toggle is gated off. */\n clinicalGatedReason?: string;\n /** Initial state of the clinical toggle. Default `false`. */\n defaultClinical?: boolean;\n\n /* ----- AI assistance (forwarded to RichTextEditor) ----- */\n onRequestAiDraft?: RichTextEditorProps['onRequestAiDraft'];\n aiDraftFormat?: RichTextEditorProps['aiDraftFormat'];\n aiPrivacyNotice?: RichTextEditorProps['aiPrivacyNotice'];\n onDictate?: RichTextEditorProps['onDictate'];\n onProofread?: RichTextEditorProps['onProofread'];\n onAutoFormat?: RichTextEditorProps['onAutoFormat'];\n\n /* ----- Per-note actions ----- */\n /** Toggle a note's pinned state — renders an inline pin button per note. */\n onTogglePin?: (id: string) => void;\n /** Toggle a note's flagged state — renders an inline flag button per note. */\n onToggleFlag?: (id: string) => void;\n /**\n * Host-owned actions rendered under each note (edit, delete, share…),\n * aligned to the inline end. The host supplies labelled controls and owns\n * what they do — the panel stays a timeline and never edits a note itself.\n */\n noteActions?: (note: NotesPanelNote) => ReactNode;\n\n /* ----- Labels / chrome ----- */\n /** Panel heading. Defaults to the localised \"Notes\". */\n title?: string;\n /** Composer placeholder. */\n composerPlaceholder?: string;\n /** Save-button label. */\n addNoteLabel?: string;\n /** Rendered when there are no notes. */\n emptyState?: ReactNode;\n /** Accessible name for the panel region (defaults to `title`). */\n 'aria-label'?: string;\n}\n\n/* The timeline row. The addressed note wears a solid inline-start bar the\n others do not — a shape channel, so the mark is not colour alone. Every row\n reserves the bar's width in `transparent`, so marking one shifts nothing. */\nconst noteItemVariants = cva(\n 'ds:flex ds:flex-col ds:rounded-[var(--radius-md)] ds:border-s-2 ds:ps-[var(--spacing-sm)]',\n {\n variants: {\n current: {\n true: 'ds:border-[color:var(--info)] ds:bg-[color:var(--info)]/10 ds:focus:outline-[length:var(--focus-ring-width)] ds:focus:outline-solid ds:focus:outline-[color:var(--ring)] ds:focus:outline-offset-[length:var(--focus-ring-offset)]',\n false: 'ds:border-transparent',\n },\n },\n defaultVariants: { current: false },\n },\n);\n\n/** Strip tags / entities to test whether a rich draft holds real content. */\nfunction hasRichContent(html: string): boolean {\n if (!html) return false;\n if (/<img\\b/i.test(html)) return true;\n return (\n html\n .replace(/<[^>]*>/g, '')\n .replace(/&nbsp;/gi, ' ')\n .trim().length > 0\n );\n}\n\nexport const NotesPanel = forwardRef<HTMLElement, NotesPanelProps>(\n function NotesPanel(\n {\n id,\n notes,\n onAddNote,\n currentNoteId,\n currentNoteKey,\n composer = 'rich',\n editorToolbar = 'standard',\n redactor,\n imageUploadUrl,\n showClinicalToggle = true,\n canAddClinicalNote = true,\n clinicalGatedReason,\n defaultClinical = false,\n onRequestAiDraft,\n aiDraftFormat,\n aiPrivacyNotice,\n onDictate,\n onProofread,\n onAutoFormat,\n onTogglePin,\n onToggleFlag,\n noteActions,\n title,\n composerPlaceholder,\n addNoteLabel,\n emptyState,\n className,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref,\n ) {\n const { t } = useTranslation();\n const editorRef = useRef<RichTextEditorHandle>(null);\n const [draft, setDraft] = useState('');\n const [clinical, setClinical] = useState(defaultClinical);\n\n const heading = title ?? t('notesPanel.title', { defaultValue: 'Notes' });\n const headingId = useId();\n const placeholder =\n composerPlaceholder ??\n t('notesPanel.placeholder', { defaultValue: 'Add a note…' });\n const composerLabel = t('notesPanel.composerLabel', {\n defaultValue: 'New note',\n });\n\n // Live content check: plain reads the draft directly; rich strips the draft\n // (debounced) for the disabled state but commits from the editor handle.\n const hasContent =\n composer === 'rich' ? hasRichContent(draft) : draft.trim().length > 0;\n\n const commit = useCallback(() => {\n if (!onAddNote) return;\n if (composer === 'rich') {\n const html = editorRef.current?.getHTML() ?? draft;\n if (!hasRichContent(html)) return;\n onAddNote({ content: html, clinical });\n editorRef.current?.clear();\n } else {\n const text = draft.trim();\n if (!text) return;\n onAddNote({ content: text, clinical });\n }\n setDraft('');\n setClinical(defaultClinical);\n }, [composer, draft, clinical, defaultClinical, onAddNote]);\n\n // Pinned notes lead; order within each group is preserved.\n const ordered = [...notes].sort(\n (a, b) => Number(b.pinned ?? false) - Number(a.pinned ?? false),\n );\n\n /* ----- The addressed note (see `currentNoteId`) ----- */\n const currentItemRef = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (!currentNoteId) return;\n // `center`, not `nearest`: nearest parks the note flush against the edge\n // of the scroll region, which is the least readable place to land.\n currentItemRef.current?.scrollIntoView({ block: 'center' });\n currentItemRef.current?.focus();\n // `currentNoteKey` is in the deps so a REPEAT address of the same note\n // re-runs — see the prop doc. Addressing is a request, not a value.\n }, [currentNoteId, currentNoteKey]);\n\n /* ----- Agent handle (structural reads + composer / toggles) ----- */\n const notesRef = useRef(notes);\n notesRef.current = notes;\n const onAddNoteRef = useRef(onAddNote);\n onAddNoteRef.current = onAddNote;\n const onTogglePinRef = useRef(onTogglePin);\n onTogglePinRef.current = onTogglePin;\n const onToggleFlagRef = useRef(onToggleFlag);\n onToggleFlagRef.current = onToggleFlag;\n const canAddClinicalRef = useRef(canAddClinicalNote);\n canAddClinicalRef.current = canAddClinicalNote;\n const currentNoteIdRef = useRef(currentNoteId);\n currentNoteIdRef.current = currentNoteId;\n\n const rootRef = useRef<HTMLElement>(null);\n useImperativeHandle(ref, () => rootRef.current as HTMLElement, []);\n\n const handle = useMemo<NotesPanelHandle>(\n () => ({\n // Ids + flags only — never the note body or author (both PHI).\n getNotes: () =>\n notesRef.current.map((n) => ({\n id: n.id,\n pinned: !!n.pinned,\n flagged: !!n.flagged,\n clinical: !!n.clinical,\n })),\n canAddNote: () => !!onAddNoteRef.current,\n canAddClinical: () => canAddClinicalRef.current,\n getCurrentNoteId: () => currentNoteIdRef.current ?? null,\n addNote: (submission) => {\n // A clinical submission requires the permission gate to be open.\n if (submission.clinical && !canAddClinicalRef.current) return;\n onAddNoteRef.current?.(submission);\n },\n togglePin: (noteId) => onTogglePinRef.current?.(noteId),\n toggleFlag: (noteId) => onToggleFlagRef.current?.(noteId),\n }),\n [],\n );\n useAgentRegistration(notesPanelAgent, handle, id);\n\n return (\n <section\n ref={rootRef}\n data-component=\"notes-panel\"\n data-component-id={id}\n aria-labelledby={ariaLabel ? undefined : headingId}\n aria-label={ariaLabel}\n className={['ds:flex ds:flex-col', className].filter(Boolean).join(' ')}\n {...rest}\n >\n {/* Shared rail header — pins to the top of the panel's scroll region\n while the composer + note timeline scroll beneath it. The rail\n injects the favourite / close actions via PanelHeaderActionsProvider. */}\n <PanelHeader\n title={heading}\n icon={<NotebookPen aria-hidden=\"true\" />}\n headingId={ariaLabel ? undefined : headingId}\n sticky\n divider\n />\n\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]\">\n {onAddNote ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n {composer === 'rich' ? (\n <RichTextEditor\n ref={editorRef}\n ariaLabel={composerLabel}\n placeholder={placeholder}\n toolbar={editorToolbar}\n minHeight=\"sm\"\n redactor={redactor}\n imageUploadUrl={imageUploadUrl}\n onChange={({ html }) => setDraft(html)}\n onRequestAiDraft={onRequestAiDraft}\n aiDraftFormat={aiDraftFormat}\n aiPrivacyNotice={aiPrivacyNotice}\n onDictate={onDictate}\n onProofread={onProofread}\n onAutoFormat={onAutoFormat}\n />\n ) : (\n <TextArea\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={placeholder}\n autoResize\n minRows={2}\n maxRows={6}\n aria-label={composerLabel}\n />\n )}\n <div\n className={[\n 'ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]',\n showClinicalToggle ? 'ds:justify-between' : 'ds:justify-end',\n ].join(' ')}\n >\n {showClinicalToggle ? (\n <Checkbox\n size=\"sm\"\n label={t('notesPanel.clinicalToggle', {\n defaultValue: 'Clinical note',\n })}\n checked={clinical}\n onCheckedChange={(next) => setClinical(next === true)}\n disabled={!canAddClinicalNote}\n disabledReason={\n canAddClinicalNote\n ? undefined\n : (clinicalGatedReason ??\n t('notesPanel.clinicalGated', {\n defaultValue:\n 'You do not have permission to write clinical notes.',\n }))\n }\n />\n ) : null}\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={commit}\n disabled={!hasContent}\n >\n {addNoteLabel ??\n t('notesPanel.add', { defaultValue: 'Add note' })}\n </Button>\n </div>\n </div>\n ) : null}\n\n {ordered.length > 0 ? (\n <ul className=\"ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0\">\n {ordered.map((note, index) => {\n const isCurrent =\n currentNoteId != null && note.id === currentNoteId;\n return (\n <li\n key={note.id ?? index}\n ref={isCurrent ? currentItemRef : undefined}\n // Focus lands on the row, not inside the card, so the\n // sentence below and `aria-current` are read out before the\n // note — and the rail's own Escape still bubbles.\n tabIndex={isCurrent ? -1 : undefined}\n aria-current={isCurrent ? 'true' : undefined}\n className={noteItemVariants({ current: isCurrent })}\n >\n {isCurrent ? (\n <span className=\"ds:sr-only\">\n {t('notesPanel.current', {\n defaultValue: 'Current note',\n })}\n </span>\n ) : null}\n {/* Elevated card per note; the list gap (not a separator)\n spaces them. Bodies clamp to five lines with read-more —\n except the addressed one, which is what the reader came\n for and opens in full. */}\n <ClinicalNoteCard\n surface=\"elevated\"\n truncate={!isCurrent}\n {...note}\n onTogglePin={\n onTogglePin && note.id\n ? () => onTogglePin(note.id as string)\n : undefined\n }\n onToggleFlag={\n onToggleFlag && note.id\n ? () => onToggleFlag(note.id as string)\n : undefined\n }\n />\n {noteActions ? (\n <div className=\"ds:flex ds:justify-end ds:gap-[var(--spacing-2xs)] ds:pt-[var(--spacing-2xs)]\">\n {noteActions(note)}\n </div>\n ) : null}\n </li>\n );\n })}\n </ul>\n ) : (\n (emptyState ?? (\n <p className=\"ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]\">\n {t('notesPanel.empty', { defaultValue: 'No notes yet.' })}\n </p>\n ))\n )}\n </div>\n </section>\n );\n },\n);\n"],"names":["notesPanelAgent","handle","args","noteItemVariants","cva","hasRichContent","html","NotesPanel","forwardRef","id","notes","onAddNote","currentNoteId","currentNoteKey","composer","editorToolbar","redactor","imageUploadUrl","showClinicalToggle","canAddClinicalNote","clinicalGatedReason","defaultClinical","onRequestAiDraft","aiDraftFormat","aiPrivacyNotice","onDictate","onProofread","onAutoFormat","onTogglePin","onToggleFlag","noteActions","title","composerPlaceholder","addNoteLabel","emptyState","className","ariaLabel","rest","ref","t","useTranslation","editorRef","useRef","draft","setDraft","useState","clinical","setClinical","heading","headingId","useId","placeholder","composerLabel","hasContent","commit","useCallback","_a","_b","text","ordered","a","b","currentItemRef","useEffect","notesRef","onAddNoteRef","onTogglePinRef","onToggleFlagRef","canAddClinicalRef","currentNoteIdRef","rootRef","useImperativeHandle","useMemo","n","submission","noteId","useAgentRegistration","jsxs","jsx","PanelHeader","NotebookPen","RichTextEditor","TextArea","event","Checkbox","next","Button","note","index","isCurrent","ClinicalNoteCard"],"mappings":";;;;;;;;;;;;AAmBO,MAAMA,KAAkD;AAAA,EAC7D,IAAI;AAAA;AAAA;AAAA,EAGJ,cAAc,CAAC,QAAQ;AAAA,EACvB,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACC,MAAWA,EAAO,SAAA;AAAA,IAAS;AAAA,IAEpC,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACA,MAAWA,EAAO,eAAA;AAAA,IAAe;AAAA,IAE1C,eAAe;AAAA,MACb,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACA,MAAWA,EAAO,iBAAA;AAAA,IAAiB;AAAA,EAC5C;AAAA,EAEF,SAAS;AAAA,IACP,UAAU;AAAA;AAAA,MAER,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,SAAS;AAAA,YACP,MAAM;AAAA,YACN,aACE;AAAA,UAAA;AAAA,UAEJ,UAAU;AAAA,YACR,MAAM;AAAA,YACN,aACE;AAAA,UAAA;AAAA,QACJ;AAAA,QAEF,UAAU,CAAC,WAAW,UAAU;AAAA,MAAA;AAAA,MAElC,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,UAAU;AAAA,QACR;AAAA,UACE,MAA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E3D,KAAe2D,EAAK,KAChB,MAAM3D,EAAY2D,EAAK,EAAY,IACnC;AAAA,wBAEN,cACE1D,KAAgB0D,EAAK,KACjB,MAAM1D,EAAa0D,EAAK,EAAY,IACpC;AAAA,sBAAA;AAAA,oBAAA;AAAA,oBAGPzD,sBACE,OAAA,EAAI,WAAU,iFACZ,UAAAA,EAAYyD,CAAI,GACnB,IACE;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAvCCA,EAAK,MAAMC;AAAA,cAAA;AAAA,YA0CtB,CAAC,EAAA,CACH,IAECtD,uBACE,KAAA,EAAE,WAAU,+DACV,UAAAK,EAAE,oBAAoB,EAAE,cAAc,gBAAA,CAAiB,EAAA,CAC1D;AAAA,UAAA,EAAA,CAGN;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sparkline-BmGcEyZO.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.',\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 /** 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 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 const pointCountRef = useRef(data.length);\n useEffect(() => {\n pointCountRef.current = data.length;\n }, [data]);\n\n const agentHandle = useMemo<SparklineHandle>(\n () => ({\n updateSeries(newData: (number | null)[]) {\n ApexCharts.getChartByID(chartId)?.updateSeries([{ data: newData }]);\n pointCountRef.current = newData.length;\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 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: { enabled: showTooltip },\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={[{ 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","a","b","entry","index","before","after","from","to","lower","upper","width","x","value","measured","prefersReducedMotion","Sparkline","forwardRef","id","variant","size","label","color","showEndpoint","showTooltip","height","onAnnotationSelect","className","props","ref","t","i18n","useTranslation","rawId","useId","chartId","useMemo","wrapperRef","useRef","containerWidth","setContainerWidth","useState","setHitWidth","points","ariaLabel","marks","withMarks","summary","fmt","dirText","nums","themeOptions","setThemeOptions","getApexChartsTheme","useEffect","timer","observer","el","measureTarget","raw","parsed","ro","entries","useNeutraliseHiddenFocus","selectRef","drawnRef","pointCountRef","agentHandle","newData","_a","ApexCharts","opts","instance","annotationId","_b","useImperativeHandle","useAgentRegistration","resolvedColor","jsx","reducedMotion","gapped","seriesData","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,QAAMC,IAAQH,MAAgB,IAAI,IAAID,IAAYC,GAE5CI,IAAY,QADJ,KAAK,IAAI,GAAGX,CAAI,IAAI,KAAK,IAAI,GAAGA,CAAI,KACf,IAE7BY,IACJ,KAAK,IAAIF,CAAK,IAAIC,IACd,WACAD,IAAQ,IACN,eACA;AAER,SAAO,EAAE,OAAAA,GAAO,WAAAE,EAAA;AAClB;AClCO,MAAMC,KAAg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AA,sBAKD,UAAA;AAAA,wBAAA,gBAAA+E,EAAC,SAAA,EACE,YAAE,8BAA8B;AAAA,0BAC/B,OAAO/E,EAAW;AAAA,wBAAA,CACnB,GACH;AAAA,wBAIA,gBAAA+E;AAAA,0BAAC;AAAA,0BAAA;AAAA,4BACC,GAAAlE;AAAA,4BACA,GAAG;AAAA,4BACH,OAAOD;AAAAA,4BACP,QAAO;AAAA,4BACP,WAAU;AAAA,0BAAA;AAAA,wBAAA;AAAA,sBACZ;AAAA,oBAAA;AAAA,oBAxBKZ,EAAW;AAAA,kBAAA,CA0BnB;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,UAGHwB,KACC,gBAAAuD;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA,cAET,aAAgBjG,CAAS;AAAA,YAAA;AAAA,UAAA;AAAA,QAC5B;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAmC,GAAU,cAAc;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeline-r-8IUoBS.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 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 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 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","relative","format","Timestamp","Timeline"],"mappings":";;;;;;;;;;;;;AAOO,MAAMA,IAA8C;AAAA,EACzD,IAAI;AAAA;AAAA;AAAA,EAGJ,cAAc,CAAC,eAAe;AAAA,EAC9B,OAAO;AAAA,IACL,eAAe;AAAA,MACb,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,iBAAA;AAAA,IAAiB;AAAA,EAC5C;AAAA,EAEF,SAAS;AAAA,IACP,cAAc;AAAA,MACZ,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,IAAI,EAAE,MAAM,WAAS;AAAA,QACnC,UAAU,CAAC,IAAI;AAAA,MAAA;AAAA,MAEjB,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACA,GAAQC,MAAyB;AACxC,QAAAD,EAAO,YAAYC,EAAK,EAAE;AAAA,MAC5B;AAAA,IAAA;AAAA,EACF;AAAA,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