@alfadocs/ui-kit-debug 0.89.0 → 0.94.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 (217) hide show
  1. package/dist/_chunks/{antenatal-schedule-timeline-UiZQze4P.js → antenatal-schedule-timeline-BMMpi2lb.js} +17 -17
  2. package/dist/_chunks/{antenatal-schedule-timeline-UiZQze4P.js.map → antenatal-schedule-timeline-BMMpi2lb.js.map} +1 -1
  3. package/dist/_chunks/apexcharts-theme-fAQXLIMW.js +67 -0
  4. package/dist/_chunks/apexcharts-theme-fAQXLIMW.js.map +1 -0
  5. package/dist/_chunks/{appointment-timeline-CwpbQGC1.js → appointment-timeline-BB-c1LeR.js} +2 -2
  6. package/dist/_chunks/{appointment-timeline-CwpbQGC1.js.map → appointment-timeline-BB-c1LeR.js.map} +1 -1
  7. package/dist/_chunks/{ar-C9FRRqJs.js → ar-THMLfSoN.js} +22 -22
  8. package/dist/_chunks/{ar-C9FRRqJs.js.map → ar-THMLfSoN.js.map} +1 -1
  9. package/dist/_chunks/{booking-DEwmDprH.js → booking-BSpSMmJ2.js} +4 -4
  10. package/dist/_chunks/{booking-DEwmDprH.js.map → booking-BSpSMmJ2.js.map} +1 -1
  11. package/dist/_chunks/{chart-CNaLgvx4.js → chart-DqxVCm1I.js} +288 -257
  12. package/dist/_chunks/chart-DqxVCm1I.js.map +1 -0
  13. package/dist/_chunks/{cycle-calculator-DXSNIWFk.js → cycle-calculator-DNvvr0bP.js} +3 -3
  14. package/dist/_chunks/{cycle-calculator-DXSNIWFk.js.map → cycle-calculator-DNvvr0bP.js.map} +1 -1
  15. package/dist/_chunks/date-picker-BP_W6VtE.js +265 -0
  16. package/dist/_chunks/date-picker-BP_W6VtE.js.map +1 -0
  17. package/dist/_chunks/{date-picker-variants-D9B6hg15.js → date-picker-variants-eL6HjWvw.js} +966 -841
  18. package/dist/_chunks/{date-picker-variants-D9B6hg15.js.map → date-picker-variants-eL6HjWvw.js.map} +1 -1
  19. package/dist/_chunks/date-range-picker-Cfv4Sr63.js +832 -0
  20. package/dist/_chunks/date-range-picker-Cfv4Sr63.js.map +1 -0
  21. package/dist/_chunks/{date-time-picker-BU-j0qj4.js → date-time-picker-695QvBGj.js} +2 -2
  22. package/dist/_chunks/{date-time-picker-BU-j0qj4.js.map → date-time-picker-695QvBGj.js.map} +1 -1
  23. package/dist/_chunks/{de-C3_KZ6mR.js → de-DmZ-8rTN.js} +4 -4
  24. package/dist/_chunks/{de-C3_KZ6mR.js.map → de-DmZ-8rTN.js.map} +1 -1
  25. package/dist/_chunks/{due-date-calculator-BR_GuqHH.js → due-date-calculator-BEcdoy_E.js} +3 -3
  26. package/dist/_chunks/{due-date-calculator-BR_GuqHH.js.map → due-date-calculator-BEcdoy_E.js.map} +1 -1
  27. package/dist/_chunks/{el-v9xDKHgu.js → el-Bela9mxs.js} +6 -6
  28. package/dist/_chunks/{el-v9xDKHgu.js.map → el-Bela9mxs.js.map} +1 -1
  29. package/dist/_chunks/{es-Lgmjq9Rp.js → es-BNncHKex.js} +10 -10
  30. package/dist/_chunks/{es-Lgmjq9Rp.js.map → es-BNncHKex.js.map} +1 -1
  31. package/dist/_chunks/{fr-INS1OD7m.js → fr-CH8ADfhN.js} +12 -12
  32. package/dist/_chunks/{fr-INS1OD7m.js.map → fr-CH8ADfhN.js.map} +1 -1
  33. package/dist/_chunks/{gestational-age-calculator-DBIcxfjP.js → gestational-age-calculator-CuGkVqKp.js} +5 -5
  34. package/dist/_chunks/{gestational-age-calculator-DBIcxfjP.js.map → gestational-age-calculator-CuGkVqKp.js.map} +1 -1
  35. package/dist/_chunks/{hcg-doubling-BgCkds8R.js → hcg-doubling-fZ6qQN08.js} +2 -2
  36. package/dist/_chunks/{hcg-doubling-BgCkds8R.js.map → hcg-doubling-fZ6qQN08.js.map} +1 -1
  37. package/dist/_chunks/{hi-BUYtlosF.js → hi-Bppfxp8l.js} +16 -16
  38. package/dist/_chunks/{hi-BUYtlosF.js.map → hi-Bppfxp8l.js.map} +1 -1
  39. package/dist/_chunks/{isSameWeek-BUNsv4OO.js → isSameWeek-CK4HS9lH.js} +2 -2
  40. package/dist/_chunks/{isSameWeek-BUNsv4OO.js.map → isSameWeek-CK4HS9lH.js.map} +1 -1
  41. package/dist/_chunks/{it-VfsdUqeV.js → it-B4ySaRyK.js} +24 -24
  42. package/dist/_chunks/{it-VfsdUqeV.js.map → it-B4ySaRyK.js.map} +1 -1
  43. package/dist/_chunks/{ja-Dfk9qwzE.js → ja-CGF6Io9P.js} +12 -12
  44. package/dist/_chunks/{ja-Dfk9qwzE.js.map → ja-CGF6Io9P.js.map} +1 -1
  45. package/dist/_chunks/{link-cell-renderer-BzITwSXq.js → link-cell-renderer-_LDZhY4r.js} +214 -197
  46. package/dist/_chunks/link-cell-renderer-_LDZhY4r.js.map +1 -0
  47. package/dist/_chunks/{nl-Crxwg0IZ.js → nl-DuShqwuV.js} +12 -12
  48. package/dist/_chunks/{nl-Crxwg0IZ.js.map → nl-DuShqwuV.js.map} +1 -1
  49. package/dist/_chunks/parse-DvA97ro9.js +1601 -0
  50. package/dist/_chunks/parse-DvA97ro9.js.map +1 -0
  51. package/dist/_chunks/{patient-details-Dggsz-ki.js → patient-details-DrhlTrLf.js} +2 -2
  52. package/dist/_chunks/{patient-details-Dggsz-ki.js.map → patient-details-DrhlTrLf.js.map} +1 -1
  53. package/dist/_chunks/{patient-table-ps4byVwA.js → patient-table-CFM92QqU.js} +2 -2
  54. package/dist/_chunks/{patient-table-ps4byVwA.js.map → patient-table-CFM92QqU.js.map} +1 -1
  55. package/dist/_chunks/{pl-IdHtxWTl.js → pl-CKQwX9Fk.js} +22 -22
  56. package/dist/_chunks/{pl-IdHtxWTl.js.map → pl-CKQwX9Fk.js.map} +1 -1
  57. package/dist/_chunks/{pregnancy-dating-CvIRwWaG.js → pregnancy-dating-BdFl-rB1.js} +5 -5
  58. package/dist/_chunks/{pregnancy-dating-CvIRwWaG.js.map → pregnancy-dating-BdFl-rB1.js.map} +1 -1
  59. package/dist/_chunks/{pt-CY2m2bBz.js → pt-_njpXyOZ.js} +16 -16
  60. package/dist/_chunks/{pt-CY2m2bBz.js.map → pt-_njpXyOZ.js.map} +1 -1
  61. package/dist/_chunks/{radiograph-panel.agent-C93AXgtV.js → radiograph-panel.agent-DDnDGVpN.js} +3 -3
  62. package/dist/_chunks/{radiograph-panel.agent-C93AXgtV.js.map → radiograph-panel.agent-DDnDGVpN.js.map} +1 -1
  63. package/dist/_chunks/{ro-qoxLkXED.js → ro-3X6_4FcN.js} +14 -14
  64. package/dist/_chunks/{ro-qoxLkXED.js.map → ro-3X6_4FcN.js.map} +1 -1
  65. package/dist/_chunks/{ru-BVZlxoKf.js → ru-bAcgmnS-.js} +20 -20
  66. package/dist/_chunks/{ru-BVZlxoKf.js.map → ru-bAcgmnS-.js.map} +1 -1
  67. package/dist/_chunks/{sparkline-iOXYgvJe.js → sparkline-o6JH4O66.js} +2 -2
  68. package/dist/_chunks/{sparkline-iOXYgvJe.js.map → sparkline-o6JH4O66.js.map} +1 -1
  69. package/dist/_chunks/{sq--eT8hIiD.js → sq-jYFqr4Ga.js} +6 -6
  70. package/dist/_chunks/{sq--eT8hIiD.js.map → sq-jYFqr4Ga.js.map} +1 -1
  71. package/dist/_chunks/subDays-BcNi04uf.js +8 -0
  72. package/dist/_chunks/{subDays-fEHRx4hg.js.map → subDays-BcNi04uf.js.map} +1 -1
  73. package/dist/_chunks/{sv-BGNQ5gX6.js → sv-BSGEJ-8B.js} +10 -10
  74. package/dist/_chunks/{sv-BGNQ5gX6.js.map → sv-BSGEJ-8B.js.map} +1 -1
  75. package/dist/_chunks/{tr-B2NEu6Gy.js → tr-CTpgUtw6.js} +14 -14
  76. package/dist/_chunks/{tr-B2NEu6Gy.js.map → tr-CTpgUtw6.js.map} +1 -1
  77. package/dist/_chunks/{zh-CN-DClT1wDk.js → zh-CN-BgM0Io2O.js} +22 -22
  78. package/dist/_chunks/{zh-CN-DClT1wDk.js.map → zh-CN-BgM0Io2O.js.map} +1 -1
  79. package/dist/agent-catalog.json +101 -2
  80. package/dist/agent-i18n/en.json +8 -2
  81. package/dist/components/_shared/calendar-class-names.d.ts +5 -0
  82. package/dist/components/_shared/calendar-class-names.d.ts.map +1 -1
  83. package/dist/components/_shared/date-picker-variants.d.ts +23 -1
  84. package/dist/components/_shared/date-picker-variants.d.ts.map +1 -1
  85. package/dist/components/_shared/index.d.ts +2 -2
  86. package/dist/components/_shared/index.d.ts.map +1 -1
  87. package/dist/components/appointment-timeline/index.js +1 -1
  88. package/dist/components/booking/index.js +1 -1
  89. package/dist/components/chart/chart.agent.d.ts.map +1 -1
  90. package/dist/components/chart/chart.d.ts +20 -0
  91. package/dist/components/chart/chart.d.ts.map +1 -1
  92. package/dist/components/chart/index.js +1 -1
  93. package/dist/components/cycle-calculator/index.js +1 -1
  94. package/dist/components/data-table/filters/date-range-filter.d.ts +13 -0
  95. package/dist/components/data-table/filters/date-range-filter.d.ts.map +1 -1
  96. package/dist/components/data-table/index.js +1 -1
  97. package/dist/components/date-picker/date-picker.d.ts.map +1 -1
  98. package/dist/components/date-picker/index.js +1 -1
  99. package/dist/components/date-range-picker/date-range-picker.agent.d.ts.map +1 -1
  100. package/dist/components/date-range-picker/date-range-picker.d.ts +91 -1
  101. package/dist/components/date-range-picker/date-range-picker.d.ts.map +1 -1
  102. package/dist/components/date-range-picker/index.d.ts +1 -1
  103. package/dist/components/date-range-picker/index.d.ts.map +1 -1
  104. package/dist/components/date-range-picker/index.js +1 -1
  105. package/dist/components/date-time-picker/index.js +1 -1
  106. package/dist/components/due-date-calculator/index.js +2 -2
  107. package/dist/components/gestational-age-calculator/index.js +1 -1
  108. package/dist/components/hcg-doubling/index.js +1 -1
  109. package/dist/components/patient-details/index.js +1 -1
  110. package/dist/components/patient-table/index.js +1 -1
  111. package/dist/components/pregnancy-dating/index.js +1 -1
  112. package/dist/components/radiograph-panel/index.js +1 -1
  113. package/dist/components/sparkline/index.js +1 -1
  114. package/dist/i18n/locales/ar.d.ts +24 -0
  115. package/dist/i18n/locales/ar.d.ts.map +1 -1
  116. package/dist/i18n/locales/ar.js +24 -0
  117. package/dist/i18n/locales/ar.js.map +1 -1
  118. package/dist/i18n/locales/de.d.ts +24 -0
  119. package/dist/i18n/locales/de.d.ts.map +1 -1
  120. package/dist/i18n/locales/de.js +24 -0
  121. package/dist/i18n/locales/de.js.map +1 -1
  122. package/dist/i18n/locales/el.d.ts +24 -0
  123. package/dist/i18n/locales/el.d.ts.map +1 -1
  124. package/dist/i18n/locales/el.js +24 -0
  125. package/dist/i18n/locales/el.js.map +1 -1
  126. package/dist/i18n/locales/en.d.ts +24 -0
  127. package/dist/i18n/locales/en.d.ts.map +1 -1
  128. package/dist/i18n/locales/en.js +24 -0
  129. package/dist/i18n/locales/en.js.map +1 -1
  130. package/dist/i18n/locales/es.d.ts +24 -0
  131. package/dist/i18n/locales/es.d.ts.map +1 -1
  132. package/dist/i18n/locales/es.js +24 -0
  133. package/dist/i18n/locales/es.js.map +1 -1
  134. package/dist/i18n/locales/fr.d.ts +24 -0
  135. package/dist/i18n/locales/fr.d.ts.map +1 -1
  136. package/dist/i18n/locales/fr.js +24 -0
  137. package/dist/i18n/locales/fr.js.map +1 -1
  138. package/dist/i18n/locales/hi.d.ts +24 -0
  139. package/dist/i18n/locales/hi.d.ts.map +1 -1
  140. package/dist/i18n/locales/hi.js +24 -0
  141. package/dist/i18n/locales/hi.js.map +1 -1
  142. package/dist/i18n/locales/it.d.ts +24 -0
  143. package/dist/i18n/locales/it.d.ts.map +1 -1
  144. package/dist/i18n/locales/it.js +24 -0
  145. package/dist/i18n/locales/it.js.map +1 -1
  146. package/dist/i18n/locales/ja.d.ts +24 -0
  147. package/dist/i18n/locales/ja.d.ts.map +1 -1
  148. package/dist/i18n/locales/ja.js +24 -0
  149. package/dist/i18n/locales/ja.js.map +1 -1
  150. package/dist/i18n/locales/nl.d.ts +24 -0
  151. package/dist/i18n/locales/nl.d.ts.map +1 -1
  152. package/dist/i18n/locales/nl.js +24 -0
  153. package/dist/i18n/locales/nl.js.map +1 -1
  154. package/dist/i18n/locales/pl.d.ts +24 -0
  155. package/dist/i18n/locales/pl.d.ts.map +1 -1
  156. package/dist/i18n/locales/pl.js +24 -0
  157. package/dist/i18n/locales/pl.js.map +1 -1
  158. package/dist/i18n/locales/pt.d.ts +24 -0
  159. package/dist/i18n/locales/pt.d.ts.map +1 -1
  160. package/dist/i18n/locales/pt.js +24 -0
  161. package/dist/i18n/locales/pt.js.map +1 -1
  162. package/dist/i18n/locales/ro.d.ts +24 -0
  163. package/dist/i18n/locales/ro.d.ts.map +1 -1
  164. package/dist/i18n/locales/ro.js +24 -0
  165. package/dist/i18n/locales/ro.js.map +1 -1
  166. package/dist/i18n/locales/ru.d.ts +24 -0
  167. package/dist/i18n/locales/ru.d.ts.map +1 -1
  168. package/dist/i18n/locales/ru.js +24 -0
  169. package/dist/i18n/locales/ru.js.map +1 -1
  170. package/dist/i18n/locales/sq.d.ts +24 -0
  171. package/dist/i18n/locales/sq.d.ts.map +1 -1
  172. package/dist/i18n/locales/sq.js +24 -0
  173. package/dist/i18n/locales/sq.js.map +1 -1
  174. package/dist/i18n/locales/sv.d.ts +24 -0
  175. package/dist/i18n/locales/sv.d.ts.map +1 -1
  176. package/dist/i18n/locales/sv.js +24 -0
  177. package/dist/i18n/locales/sv.js.map +1 -1
  178. package/dist/i18n/locales/tr.d.ts +24 -0
  179. package/dist/i18n/locales/tr.d.ts.map +1 -1
  180. package/dist/i18n/locales/tr.js +24 -0
  181. package/dist/i18n/locales/tr.js.map +1 -1
  182. package/dist/i18n/locales/zh.d.ts +24 -0
  183. package/dist/i18n/locales/zh.d.ts.map +1 -1
  184. package/dist/i18n/locales/zh.js +24 -0
  185. package/dist/i18n/locales/zh.js.map +1 -1
  186. package/dist/index.js +17 -17
  187. package/dist/locales/ar.json +24 -0
  188. package/dist/locales/de.json +24 -0
  189. package/dist/locales/el.json +24 -0
  190. package/dist/locales/en.json +24 -0
  191. package/dist/locales/es.json +24 -0
  192. package/dist/locales/fr.json +24 -0
  193. package/dist/locales/hi.json +24 -0
  194. package/dist/locales/it.json +24 -0
  195. package/dist/locales/ja.json +24 -0
  196. package/dist/locales/nl.json +24 -0
  197. package/dist/locales/pl.json +24 -0
  198. package/dist/locales/pt.json +24 -0
  199. package/dist/locales/ro.json +24 -0
  200. package/dist/locales/ru.json +24 -0
  201. package/dist/locales/sq.json +24 -0
  202. package/dist/locales/sv.json +24 -0
  203. package/dist/locales/tr.json +24 -0
  204. package/dist/locales/zh.json +24 -0
  205. package/dist/tokens/apexcharts-theme.d.ts +36 -1
  206. package/dist/tokens/apexcharts-theme.d.ts.map +1 -1
  207. package/dist/tokens.css +1 -1
  208. package/package.json +1 -1
  209. package/dist/_chunks/apexcharts-theme-BJigns_V.js +0 -53
  210. package/dist/_chunks/apexcharts-theme-BJigns_V.js.map +0 -1
  211. package/dist/_chunks/chart-CNaLgvx4.js.map +0 -1
  212. package/dist/_chunks/date-picker-ffmyjvlI.js +0 -1845
  213. package/dist/_chunks/date-picker-ffmyjvlI.js.map +0 -1
  214. package/dist/_chunks/date-range-picker-DSOH50-f.js +0 -325
  215. package/dist/_chunks/date-range-picker-DSOH50-f.js.map +0 -1
  216. package/dist/_chunks/link-cell-renderer-BzITwSXq.js.map +0 -1
  217. package/dist/_chunks/subDays-fEHRx4hg.js +0 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-DqxVCm1I.js","sources":["../../node_modules/lucide-react/dist/esm/icons/chart-area.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-column.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-line.mjs","../../node_modules/lucide-react/dist/esm/icons/chart-pie.mjs","../../node_modules/lucide-react/dist/esm/icons/donut.mjs","../../src/components/chart/chart.agent.ts","../../src/components/chart/chart.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\n \"path\",\n {\n d: \"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z\",\n key: \"q0gr47\"\n }\n ]\n];\nconst ChartArea = createLucideIcon(\"chart-area\", __iconNode);\n\nexport { __iconNode, ChartArea as default };\n//# sourceMappingURL=chart-area.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\"path\", { d: \"M18 17V9\", key: \"2bz60n\" }],\n [\"path\", { d: \"M13 17V5\", key: \"1frdt8\" }],\n [\"path\", { d: \"M8 17v-3\", key: \"17ska0\" }]\n];\nconst ChartColumn = createLucideIcon(\"chart-column\", __iconNode);\n\nexport { __iconNode, ChartColumn as default };\n//# sourceMappingURL=chart-column.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M3 3v16a2 2 0 0 0 2 2h16\", key: \"c24i48\" }],\n [\"path\", { d: \"m19 9-5 5-4-4-3 3\", key: \"2osh9i\" }]\n];\nconst ChartLine = createLucideIcon(\"chart-line\", __iconNode);\n\nexport { __iconNode, ChartLine as default };\n//# sourceMappingURL=chart-line.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z\",\n key: \"pzmjnu\"\n }\n ],\n [\"path\", { d: \"M21.21 15.89A10 10 0 1 1 8 2.83\", key: \"k2fpak\" }]\n];\nconst ChartPie = createLucideIcon(\"chart-pie\", __iconNode);\n\nexport { __iconNode, ChartPie as default };\n//# sourceMappingURL=chart-pie.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3\",\n key: \"19sr3x\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"3\", key: \"1v7zrd\" }]\n];\nconst Donut = createLucideIcon(\"donut\", __iconNode);\n\nexport { __iconNode, Donut as default };\n//# sourceMappingURL=donut.mjs.map\n","import type { AgentAdapter } from '../../agent/types';\nimport type { ChartHandle } from './chart';\n\nexport const chartAgent: AgentAdapter<ChartHandle> = {\n id: 'chart',\n // view_change backs the opt-in type switcher (`switchableTypes` prop):\n // the same chart re-presented as line / bar / area / pie / donut.\n capabilities: ['view_change'],\n state: {\n declaredType: {\n type: \"'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar'\",\n descriptionKey: 'ui.agent.chart.state.declaredType',\n description:\n 'The consumer-declared chart type — the shape `update_series` expects.',\n read: (handle) => handle.getTypeState().declaredType,\n },\n effectiveType: {\n type: \"'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar'\",\n descriptionKey: 'ui.agent.chart.state.effectiveType',\n description:\n 'The type currently rendered — differs from declaredType after a type-switcher pick.',\n read: (handle) => handle.getTypeState().effectiveType,\n },\n availableTypes: {\n type: 'ChartType[]',\n descriptionKey: 'ui.agent.chart.state.availableTypes',\n description:\n 'Types the switcher offers. Empty when the chart has no type switcher.',\n read: (handle) => handle.getTypeState().availableTypes,\n },\n },\n actions: {\n change_view: {\n // Switching the presentation is a write (it changes what the user\n // sees) but is trivially reversible by switching back.\n safety: 'write',\n argsType: 'type',\n argsSchema: {\n type: 'object',\n properties: {\n type: {\n type: 'string',\n enum: ['line', 'bar', 'area', 'pie', 'donut'],\n description: 'The chart type to render.',\n },\n },\n required: ['type'],\n },\n returns: 'boolean (accepted)',\n returnsSchema: {\n type: 'boolean',\n description:\n 'True when the switch was applied; false when the chart has no type switcher or the type is not offered (check availableTypes first).',\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.changeView',\n description:\n 'Switch the rendered chart type via the type switcher. No-op (returns false) when the chart has no switcher or the type is not offered.',\n invoke: (handle, args: { type: string }) =>\n handle.setType(args.type as Parameters<ChartHandle['setType']>[0]),\n },\n update_series: {\n // Replacing the rendered series mutates what the chart displays — it\n // is a write, reversible by pushing the prior series back.\n safety: 'write',\n argsType: 'series',\n // `series` is `ChartSeries[]` (line/bar/area) OR `number[]`\n // (pie/donut/radialBar). Both shapes are accepted; the handle routes\n // by chart type internally.\n argsSchema: {\n type: 'object',\n properties: {\n series: {\n oneOf: [\n {\n type: 'array',\n description: 'Categorical series for line / bar / area charts.',\n items: {\n type: 'object',\n properties: {\n name: { type: 'string' },\n data: { type: 'array', items: { type: 'number' } },\n role: {\n type: 'string',\n enum: ['primary', 'compare'],\n description:\n \"Optional. 'compare' renders this series as a secondary, colour-blind-safe overlay (e.g. the previous period) — dashed grey for line/area, hatched grey for bar. Omit for a normal primary series.\",\n },\n },\n required: ['name', 'data'],\n },\n },\n {\n type: 'array',\n description: 'Flat values for pie / donut / radialBar charts.',\n items: { type: 'number' },\n },\n ],\n },\n },\n required: ['series'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.updateSeries',\n description:\n 'Replace the chart series without remounting. Pass the DECLARED type’s shape (see declaredType state) — when the user has switched the view cross-shape the values are converted to the rendered shape. The write targets the live instance only: a later type switch re-reads the original props and discards it.',\n invoke: (\n handle,\n args: { series: Parameters<ChartHandle['updateSeries']>[0] },\n ) => {\n handle.updateSeries(args.series);\n },\n },\n export_png: {\n safety: 'read',\n returns: 'string (PNG data URI)',\n returnsSchema: {\n type: 'string',\n description: 'A `data:image/png;base64,…` URI of the rendered chart.',\n },\n idempotent: true,\n descriptionKey: 'ui.agent.chart.actions.exportPng',\n description:\n 'Return a PNG data URI of the chart for export or screenshotting.',\n invoke: (handle) => handle.dataURI(),\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'chart' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* Chart — thin, typed wrapper over ApexCharts (react-apexcharts). */\n/* */\n/* - All chrome, colours, and fonts flow from */\n/* `src/tokens/apexcharts-theme.ts` — never hex literals in user */\n/* code. A MutationObserver on `<html class>` re-reads the bridge so */\n/* theme changes repaint without remount. */\n/* - A ResizeObserver on the wrapper keeps the chart responsive */\n/* without listening on `window.resize`. */\n/* - Accessibility: the wrapper carries `role=\"img\"` + `aria-label` */\n/* (required `title` prop) + `aria-describedby` pointing at a */\n/* visually-hidden `<table>` that mirrors series × categories. */\n/* - Colour-blind users: `patterns` prop flips `fill.type` to pattern */\n/* using ApexCharts' built-in pattern presets. */\n/* - Numbers format via `Intl.NumberFormat(locale)` — no hand-rolled */\n/* `toFixed()`. */\n/* ------------------------------------------------------------------ */\n\nimport {\n forwardRef,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport ReactApexChart from 'react-apexcharts';\nimport ApexCharts from 'apexcharts';\nimport {\n ChartArea,\n ChartColumn,\n ChartLine,\n ChartPie,\n Donut,\n} from 'lucide-react';\nimport {\n getApexChartsTheme,\n type ApexChartsTheme,\n} from '../../tokens/apexcharts-theme';\nimport { usePrefersReducedMotion } from '../../hooks';\nimport { useNeutraliseHiddenFocus } from '../_shared/use-neutralize-hidden-focus';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { chartAgent } from './chart.agent';\nimport { IconButton } from '../button/icon-button';\nimport { IconButtonGroup } from '../icon-button-group';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst chartVariants = cva('ds:relative ds:block ds:w-full', {\n variants: {\n density: {\n compact: 'ds:min-h-[var(--chart-min-height-compact)]',\n comfortable: 'ds:min-h-[var(--chart-min-height-comfortable)]',\n // Applied when an explicit `height` prop is given and no density was\n // requested: the wrapper must not exceed the caller's height (a 96px\n // KPI chart inside a card must not reserve 320px).\n none: '',\n },\n },\n defaultVariants: { density: 'comfortable' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type ChartType = 'line' | 'bar' | 'pie' | 'donut' | 'area' | 'radialBar';\n\nexport interface ChartSeries {\n name: string;\n data: number[];\n /**\n * Marks this series as a secondary \"compare\" overlay — e.g. the previous\n * period in a current-vs-previous financial view. Rendered visually\n * subordinate and colour-blind-safe, distinguished from primary series by\n * BOTH a non-colour cue AND a muted hue (never colour alone):\n * - line / area: DASHED stroke in a resolved neutral grey (the chart echo\n * of the calendar compare band's dashed block-end rule).\n * - bar: HATCHED (slantedLines) grey fill — bars have a zero-width stroke\n * and cannot dash, so the non-colour cue lives in the fill texture.\n * Only meaningful on axis types (line / area / bar); it is structurally\n * impossible on pie / donut / radialBar (their `series` is `number[]`, which\n * cannot carry this field), so the axis-only invariant is enforced by the\n * type system with no runtime guard. On an axis→slice type switch the compare\n * series are dropped from the slice (a previous-period total is not a slice of\n * the current whole; DEV warn). Omit (or `'primary'`) to render normally — a\n * chart with NO compare series emits byte-identical ApexCharts options to\n * before this field existed.\n * @default 'primary'\n */\n role?: 'primary' | 'compare';\n}\n\n/** Bar orientation. `'horizontal'` renders a ranking sideways. Default `'vertical'`. */\nexport type ChartOrientation = 'vertical' | 'horizontal';\n\n/** Line / area stroke interpolation. Default `'smooth'`. */\nexport type ChartCurve = 'smooth' | 'straight' | 'stepline';\n\nexport interface ChartProps extends VariantProps<typeof chartVariants> {\n /** Required — drives aria-label and sr-only table caption. */\n title: string;\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /** Chart visual type. */\n type: ChartType;\n /**\n * For `line` / `bar` / `area`: an array of `ChartSeries`.\n * For `pie` / `donut` / `radialBar`: an array of numbers matched to `labels`.\n */\n series: ChartSeries[] | number[];\n /** Category axis labels (line / bar / area). */\n categories?: string[];\n /** Slice labels (pie / donut / radialBar). */\n labels?: string[];\n /** Height override. Defaults to 320px. */\n height?: number | string;\n /** Width override. Defaults to 100% of container. */\n width?: number | string;\n /** Opt-in pattern fills for colour-blind users. */\n patterns?: boolean;\n /**\n * Stack multiple `bar` / `area` series into a composition-over-time view.\n * Maps to ApexCharts `chart.stacked`. Only applies to the axis types\n * (`line` / `bar` / `area`); slice types (`pie` / `donut` / `radialBar`)\n * have no axis to stack against and ignore it. Default `false` — an\n * unstacked chart emits no `chart.stacked` key and renders identically to\n * before this prop existed.\n */\n stacked?: boolean;\n /**\n * Orientation for the `bar` type. `'horizontal'` renders the bars sideways\n * (ApexCharts `plotOptions.bar.horizontal`) for ranking-style charts where\n * the category is a name and the value runs across the horizontal axis.\n * Still an axis chart — pass `series` as `ChartSeries[]` with `categories`.\n * Ignored for every non-`bar` type. Default `'vertical'`.\n */\n orientation?: ChartOrientation;\n /**\n * Stroke interpolation for `line` / `area` charts (ApexCharts\n * `stroke.curve`). `'straight'` avoids the overshoot a smoothed spline\n * introduces on spiky monthly financials — where a `'smooth'` curve can dip\n * visually below zero between two positive points. Inert on `bar` (stroke\n * width is 0) and ignored on slice types. Default `'smooth'` — existing\n * charts are unaffected.\n */\n curve?: ChartCurve;\n /**\n * Override the series colour ramp. Pass **already-resolved** colour strings\n * (e.g. the live value of `var(--success)` sampled by the consumer) — these\n * are handed straight to ApexCharts, which can't read CSS custom properties.\n * When omitted, the theme bridge's `colors` ramp from `apexcharts-theme.ts`\n * is used, so existing consumers are unaffected. Typical use: a single-arc\n * `radialBar` gauge (e.g. BMI) that must change hue with the value —\n * green in the healthy band, amber/red outside it.\n */\n colors?: string[];\n /** Show the ApexCharts toolbar. Defaults to false. */\n toolbar?: boolean;\n /** Locale override — defaults to the active i18next language. */\n locale?: string;\n /**\n * radialBar only. Formats the value printed in the ring centre. Use when the\n * gauge represents a non-percentage figure: pass the arc fill (0–100) as the\n * single `series` value and return the real figure here (e.g. `(_, ) => '22.4'`).\n * Ignored for every other chart type. Defaults to ApexCharts' `${value}%`.\n */\n radialValueFormatter?: (value: number) => string;\n /**\n * Formats the numeric value of each data point wherever it is surfaced as\n * text — the tooltip, the value (y) axis on categorical charts, and the\n * screen-reader summary table. Use it to append a unit or currency symbol,\n * e.g. `(v) => new Intl.NumberFormat(locale, { style: 'currency', currency:\n * 'EUR' }).format(v)`. Defaults to `Intl.NumberFormat(locale)` (grouped\n * number, no unit). Does not apply to a `radialBar` ring centre — use\n * `radialValueFormatter` for that.\n */\n valueFormatter?: (value: number) => string;\n /**\n * Opt-in type switcher. Pass two or more of `'line' | 'bar' | 'area' |\n * 'pie' | 'donut'` to render an icon radiogroup (an `IconButtonGroup`)\n * above the plot that lets the user flip the chart between those types.\n * `type` is the initial selection and is always offered; the user's pick\n * then sticks across re-renders (remount with a new `key` to reset it).\n * When the picked type reads the other data shape, the data adapts: axis\n * series collapse to one slice per series (that series' total) for `pie` /\n * `donut`, and slice values become a single-series axis chart with\n * `labels` as the categories. `radialBar` cannot participate — such\n * entries are ignored (DEV warning) and a `radialBar` chart never shows\n * the switcher.\n */\n switchableTypes?: ChartType[];\n /** Called when the user picks a different type via the switcher. */\n onTypeChange?: (type: ChartType) => void;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport interface ChartHandle {\n /** Returns a PNG data URI for the chart. */\n dataURI: () => Promise<string>;\n /**\n * Updates series without remounting. Always pass the DECLARED `type`'s\n * shape — while the user has switched the view across the axis/slice\n * boundary the values (and, for axis→slice, the slice labels) are\n * converted to the rendered shape; for slice→axis the categories stay\n * the `labels` prop, so keep the value count stable. The update writes\n * to the live ApexCharts instance only: a later type switch remounts\n * from the original props and discards it.\n */\n updateSeries: (next: ChartProps['series']) => void;\n /**\n * Switches the rendered type via the type switcher. Returns `false`\n * (no-op) when the switcher is not enabled or the type is not offered.\n */\n setType: (next: ChartType) => boolean;\n /** Declared vs rendered type plus the types the switcher offers ([] when disabled). */\n getTypeState: () => {\n declaredType: ChartType;\n effectiveType: ChartType;\n availableTypes: ChartType[];\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Constants */\n/* ------------------------------------------------------------------ */\n\nconst PATTERN_STYLES = [\n 'verticalLines',\n 'horizontalLines',\n 'slantedLines',\n 'squares',\n 'circles',\n] as const;\n\n/** Types where `categories` belong on an x-axis. */\nconst CATEGORICAL_TYPES: ReadonlyArray<ChartType> = ['line', 'bar', 'area'];\n\n/** Types where `series` is a flat `number[]` paired with `labels`. */\nconst SLICE_TYPES: ReadonlyArray<ChartType> = ['pie', 'donut', 'radialBar'];\n\n/** Types the switcher may offer. `radialBar` is excluded — its series are\n * synthetic arc percents that cannot be re-plotted on an axis or as slices. */\nconst SWITCHABLE_TYPES: ReadonlyArray<ChartType> = [\n 'line',\n 'bar',\n 'area',\n 'pie',\n 'donut',\n];\n\ntype SwitchableType = Exclude<ChartType, 'radialBar'>;\n\n/* Static key map (not template-built) so the i18n coverage tooling can see\n every key literally. */\nconst TYPE_SWITCHER_LABEL_KEYS: Record<SwitchableType, string> = {\n line: 'chart.typeSwitcher.line',\n bar: 'chart.typeSwitcher.bar',\n area: 'chart.typeSwitcher.area',\n pie: 'chart.typeSwitcher.pie',\n donut: 'chart.typeSwitcher.donut',\n};\n\nconst TYPE_SWITCHER_ICONS: Record<SwitchableType, React.ReactNode> = {\n line: <ChartLine />,\n bar: <ChartColumn />,\n area: <ChartArea />,\n pie: <ChartPie />,\n donut: <Donut />,\n};\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\nfunction isSliceType(type: ChartType): boolean {\n return SLICE_TYPES.includes(type);\n}\n\nfunction isCategoricalType(type: ChartType): boolean {\n return CATEGORICAL_TYPES.includes(type);\n}\n\n/** Coerce `series` into `ChartSeries[]` for shared logic (table, aria). */\nfunction normaliseSeries(\n series: ChartSeries[] | number[],\n type: ChartType,\n): ChartSeries[] {\n if (isSliceType(type)) {\n const nums = series as number[];\n return [\n {\n name: '',\n data: nums,\n },\n ];\n }\n return series as ChartSeries[];\n}\n\n/* ------------------------------------------------------------------ */\n/* Chart component */\n/* ------------------------------------------------------------------ */\n\nexport const Chart = forwardRef<ChartHandle, ChartProps>(\n (\n {\n title,\n id,\n type,\n series,\n categories,\n labels,\n height,\n width,\n patterns = false,\n stacked = false,\n orientation = 'vertical',\n curve = 'smooth',\n colors,\n toolbar = false,\n locale: localeProp,\n radialValueFormatter,\n valueFormatter,\n switchableTypes,\n onTypeChange,\n density,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const rawId = useId();\n const chartId = useMemo(\n () => `chart-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const summaryId = `${chartId}-summary`;\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [containerWidth, setContainerWidth] = useState(0);\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. Same hook used in Sparkline. */\n useNeutraliseHiddenFocus(wrapperRef);\n\n const locale = localeProp ?? i18n.language ?? 'en';\n\n /* ---- dev warning if title missing ------------------------------ */\n if (import.meta.env.DEV && !title) {\n console.warn(\n 'Chart: `title` prop is required. It drives aria-label and the screen-reader summary table.',\n );\n }\n\n /* ---- theme-reactive state -------------------------------------- */\n const [themeOptions, setThemeOptions] = useState<ApexChartsTheme>(() => {\n try {\n return getApexChartsTheme();\n } catch {\n return {};\n }\n });\n\n /* ---- MutationObserver: re-read theme on class change ------------ */\n useEffect(() => {\n if (typeof document === 'undefined') return undefined;\n let timer: ReturnType<typeof setTimeout>;\n const observer = new MutationObserver(() => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n try {\n setThemeOptions(getApexChartsTheme());\n } catch {\n /* no-op in non-browser environments */\n }\n }, 50);\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class'],\n });\n return () => {\n clearTimeout(timer);\n observer.disconnect();\n };\n }, []);\n\n /* ---- ResizeObserver: track container width --------------------- */\n useEffect(() => {\n const el = wrapperRef.current;\n if (!el || typeof ResizeObserver === 'undefined') return undefined;\n const ro = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setContainerWidth(Math.floor(entry.contentRect.width));\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n /* ---- type switcher ---------------------------------------------- */\n const switcherTypes = useMemo<SwitchableType[]>(() => {\n if (!switchableTypes || switchableTypes.length === 0) return [];\n const valid = switchableTypes.filter((entry): entry is SwitchableType =>\n SWITCHABLE_TYPES.includes(entry),\n );\n if (import.meta.env.DEV && valid.length !== switchableTypes.length) {\n console.warn(\n \"Chart: `switchableTypes` accepts 'line' | 'bar' | 'area' | 'pie' | 'donut' — other entries are ignored.\",\n );\n }\n if (!SWITCHABLE_TYPES.includes(type)) {\n if (import.meta.env.DEV && valid.length > 0) {\n console.warn(\n 'Chart: the type switcher is unavailable when `type` is \"radialBar\".',\n );\n }\n return [];\n }\n const withCurrent = valid.includes(type as SwitchableType)\n ? valid\n : [type as SwitchableType, ...valid];\n return [...new Set(withCurrent)];\n }, [switchableTypes, type]);\n const switcherEnabled = switcherTypes.length >= 2;\n\n const [pickedType, setPickedType] = useState<SwitchableType | null>(null);\n const effectiveType: ChartType =\n switcherEnabled && pickedType && switcherTypes.includes(pickedType)\n ? pickedType\n : type;\n\n /* ---- data adaptation for the switcher --------------------------- */\n /* Axis and slice types read different `series` shapes. When the user */\n /* switches across that boundary the data adapts: each axis series */\n /* becomes one slice (its total across the categories), and slice */\n /* values become one axis series with `labels` as the categories. */\n /* Same-shape switches (line/bar/area, pie/donut) pass through as-is. */\n const declaredIsSlice = isSliceType(type);\n const effectiveIsSlice = isSliceType(effectiveType);\n const { effectiveSeries, effectiveCategories, effectiveLabels } =\n useMemo(() => {\n if (declaredIsSlice === effectiveIsSlice) {\n return {\n effectiveSeries: series,\n effectiveCategories: categories,\n effectiveLabels: labels,\n };\n }\n if (!declaredIsSlice) {\n const allRows = series as ChartSeries[];\n // A previous-period total is not a slice of the current whole, so\n // compare overlays are dropped from the axis→slice collapse (their\n // grey \"prev\" slice would misread as part of the current mix). This\n // also makes compareFlags naturally [] on the slice side.\n const rows = allRows.filter((row) => row.role !== 'compare');\n if (import.meta.env.DEV && rows.length !== allRows.length) {\n console.warn(\n 'Chart: compare series are dropped on an axis→slice switch — a previous-period total is not a slice of the current whole.',\n );\n }\n const totals = rows.map((row) =>\n row.data.reduce((sum, v) => sum + v, 0),\n );\n if (import.meta.env.DEV && totals.some((v) => v < 0)) {\n console.warn(\n 'Chart: the axis→slice adaptation produced a negative series total — pie/donut cannot represent negative values. Offer only axis types in `switchableTypes` for delta-style data.',\n );\n }\n return {\n effectiveSeries: totals,\n effectiveCategories: undefined,\n effectiveLabels: rows.map((row) => row.name),\n };\n }\n const values = series as number[];\n return {\n effectiveSeries: [\n { name: t('chart.table.value'), data: values },\n ] as ChartSeries[],\n effectiveCategories: labels ?? [],\n effectiveLabels: undefined,\n };\n }, [series, categories, labels, declaredIsSlice, effectiveIsSlice, t]);\n\n /* ---- imperative handle ----------------------------------------- */\n const agentHandle = useMemo<ChartHandle>(\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 updateSeries(next) {\n const instance = ApexCharts.getChartByID(chartId);\n if (!instance) return;\n // Callers always pass the DECLARED type's shape. When the user has\n // switched the view across the axis/slice boundary, convert to what\n // the live instance actually renders (mirrors the render-time\n // adaptation) so the update never hits a mismatched instance.\n const declaredSlice = isSliceType(type);\n const renderedSlice = isSliceType(effectiveType);\n if (declaredSlice === renderedSlice) {\n if (declaredSlice) instance.updateSeries(next as number[]);\n else instance.updateSeries(next as ChartSeries[]);\n return;\n }\n if (!declaredSlice) {\n // Drop compare overlays from the collapse (mirrors the render-time\n // adaptation) so no stray \"prev\" slice appears.\n const rows = (next as ChartSeries[]).filter(\n (row) => row.role !== 'compare',\n );\n // Keep slice labels in step with the incoming series — without\n // this, a series-count or name change desyncs slices from the\n // labels captured at the last React render.\n instance.updateOptions(\n { labels: rows.map((row) => row.name) },\n false,\n true,\n );\n instance.updateSeries(\n rows.map((row) => row.data.reduce((sum, v) => sum + v, 0)),\n );\n return;\n }\n instance.updateSeries([\n { name: t('chart.table.value'), data: next as number[] },\n ]);\n },\n setType(next: ChartType): boolean {\n if (!switcherEnabled) return false;\n if (!switcherTypes.includes(next as SwitchableType)) return false;\n setPickedType(next as SwitchableType);\n return true;\n },\n getTypeState() {\n return {\n declaredType: type,\n effectiveType,\n availableTypes: switcherEnabled\n ? ([...switcherTypes] as ChartType[])\n : [],\n };\n },\n }),\n [chartId, type, effectiveType, t, switcherEnabled, switcherTypes],\n );\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n useAgentRegistration(chartAgent, agentHandle, id);\n\n /* ---- RTL detection --------------------------------------------- */\n const isRtl =\n typeof document !== 'undefined' && document.documentElement.dir === 'rtl';\n\n /* ---- normalised series for sr-only table ----------------------- */\n const tableSeries = useMemo(\n () => normaliseSeries(effectiveSeries, effectiveType),\n [effectiveSeries, effectiveType],\n );\n\n /* ---- Intl formatter -------------------------------------------- */\n const numberFormatter = useMemo(\n () => new Intl.NumberFormat(locale),\n [locale],\n );\n\n /* ---- resolved value formatter ---------------------------------- */\n /* The consumer's `valueFormatter` (e.g. a currency formatter) wins */\n /* everywhere a data-point value is surfaced as text; otherwise we */\n /* fall back to the locale-aware grouped number. */\n const formatValue = useMemo(\n () =>\n valueFormatter ?? ((value: number) => numberFormatter.format(value)),\n [valueFormatter, numberFormatter],\n );\n\n /* ---- toolbar localisation -------------------------------------- */\n const toolbarLocale = useMemo(\n () => ({\n name: locale,\n options: {\n toolbar: {\n download: t('chart.toolbar.download'),\n selection: t('chart.toolbar.selection'),\n selectionZoom: t('chart.toolbar.selectionZoom'),\n zoomIn: t('chart.toolbar.zoomIn'),\n zoomOut: t('chart.toolbar.zoomOut'),\n pan: t('chart.toolbar.pan'),\n reset: t('chart.toolbar.reset'),\n exportToSVG: t('chart.toolbar.exportToSVG'),\n exportToPNG: t('chart.toolbar.exportToPNG'),\n exportToCSV: t('chart.toolbar.exportToCSV'),\n },\n },\n }),\n [locale, t],\n );\n\n /* ---- build ApexOptions ----------------------------------------- */\n const reducedMotion = usePrefersReducedMotion();\n\n const chartOptions: ApexCharts.ApexOptions = useMemo(() => {\n // Split the resolved compare colours off the theme object BEFORE spread:\n // `compare` must never land in the ApexCharts options (that would break\n // the byte-identical guarantee for non-compare charts). `base` is exactly\n // today's theme shape, so `...base` emits the same keys as before.\n const { compare: compareColours, ...base } = themeOptions;\n const compareMark = compareColours?.mark ?? '';\n const compareWash = compareColours?.wash ?? '';\n\n // Per-series compare flags, derived at build time from the EFFECTIVE\n // series/type so the type switcher composes: only axis types carry the\n // `role` field (slice `series` is `number[]`), so a slice view yields [].\n const compareFlags =\n isCategoricalType(effectiveType) && Array.isArray(effectiveSeries)\n ? (effectiveSeries as ChartSeries[]).map((s) => s.role === 'compare')\n : [];\n const hasCompare = compareFlags.some(Boolean);\n const barCompare = hasCompare && effectiveType === 'bar';\n\n if (\n import.meta.env.DEV &&\n hasCompare &&\n stacked &&\n isCategoricalType(effectiveType)\n ) {\n console.warn(\n 'Chart: `stacked` with a compare series — a compare overlay is normally a grouped, not stacked, series. It will be stacked with the primaries.',\n );\n }\n\n const options: ApexCharts.ApexOptions = {\n ...base,\n chart: {\n ...base.chart,\n id: chartId,\n toolbar: { show: toolbar },\n zoom: { enabled: toolbar },\n animations: {\n enabled: !reducedMotion,\n dynamicAnimation: { enabled: !reducedMotion },\n },\n locales: [toolbarLocale],\n defaultLocale: locale,\n parentHeightOffset: 0,\n // Stacking is an axis-only concept — gate on the categorical types\n // so a slice/radial chart never receives it, and omit the key\n // entirely when unstacked so the default output is byte-identical.\n ...(stacked && isCategoricalType(effectiveType)\n ? { stacked: true }\n : {}),\n },\n // Only set `labels` when the effective type actually has them (slice\n // charts). Emitting `labels: undefined` crashes ApexCharts' bar\n // renderer — `parseDataAxisCharts` reads `labels.length` and throws\n // \"Cannot read properties of undefined (reading 'length')\", which\n // aborts the render and leaves a blank chart. Absent is safe; area /\n // line tolerate the undefined but bar does not, so never pass it.\n ...(effectiveLabels ? { labels: effectiveLabels } : {}),\n legend: {\n ...base.legend,\n position: 'bottom',\n // ApexCharts legend.horizontalAlign is a physical prop mapped internally\n // to the chart's own text flow. For RTL we flip via `yaxis.opposite`\n // and ApexCharts' own `direction: 'rtl'` handling; legend stays anchored\n // to the inline-start by asking for 'left' on LTR and 'right' on RTL.\n horizontalAlign: isRtl ? 'right' : 'left',\n fontFamily: 'inherit',\n },\n tooltip: {\n ...base.tooltip,\n y: {\n formatter: (value: number) => formatValue(value),\n },\n },\n noData: {\n text: t('chart.noData'),\n },\n };\n\n // Consumer-supplied, already-resolved colour ramp wins over the theme\n // bridge's `colors`. Ignored when absent so existing charts keep the\n // tokenised ramp. ApexCharts can't read `var(--…)`, so the consumer is\n // responsible for sampling the live token value before passing it in.\n if (colors && colors.length > 0) {\n options.colors = colors;\n }\n\n // Step 1 (compare) — expand whatever ramp ApexCharts would use to one\n // entry per series and swap the compare indices for the resolved neutral\n // grey `mark`. This preserves each primary's exact colour (including\n // ApexCharts' own %-cycling for the primary indices) and greys the\n // compare stroke / fill / area source AND its legend swatch at once.\n if (hasCompare) {\n const ramp = (options.colors ?? base.colors ?? []) as string[];\n options.colors = (effectiveSeries as ChartSeries[]).map((_, i) =>\n compareFlags[i] ? compareMark : ramp[i % Math.max(ramp.length, 1)],\n );\n }\n\n if (isCategoricalType(effectiveType)) {\n // A horizontal bar makes ApexCharts swap axes: the numeric axis\n // becomes the x-axis and the categories move to the y-axis. The value\n // formatter must follow the numbers, so on a horizontal bar it lives\n // on `xaxis.labels` and the category y-axis keeps its default (string)\n // labels; every other categorical chart keeps the formatter on `yaxis`.\n const horizontalBar =\n effectiveType === 'bar' && orientation === 'horizontal';\n options.xaxis = {\n ...base.xaxis,\n categories: effectiveCategories ?? [],\n ...(horizontalBar\n ? {\n labels: {\n formatter: (value: string | number) =>\n formatValue(Number(value)),\n },\n }\n : {}),\n };\n options.yaxis = {\n ...base.yaxis,\n opposite: isRtl,\n ...(horizontalBar\n ? {}\n : { labels: { formatter: (value: number) => formatValue(value) } }),\n };\n // Step 2 (compare) — the line / area non-colour cue is a dashed stroke\n // on the compare indices (bars have a zero-width stroke and can't dash,\n // so this is skipped for bar — the cue moves to the fill in Step 3).\n // Width stays 2 for legibility; the dash + grey carry secondariness.\n options.stroke = {\n curve,\n width: effectiveType === 'bar' ? 0 : 2,\n ...(hasCompare && effectiveType !== 'bar'\n ? { dashArray: compareFlags.map((c) => (c ? 6 : 0)) }\n : {}),\n };\n options.dataLabels = { enabled: false };\n }\n\n if (effectiveType === 'radialBar' && radialValueFormatter) {\n // ApexCharts treats a radialBar series value as a 0–100 percent and\n // renders it verbatim in the ring centre. When the displayed value is\n // NOT a percentage (e.g. a BMI), the consumer scales the series to a\n // percent for the arc and supplies `radialValueFormatter` to print the\n // real value in the centre. Without this, the gauge would read \"56%\"\n // for a BMI of 22.4 — misleading. Default behaviour is untouched.\n const basePlot = (base.plotOptions ?? {}) as NonNullable<\n ApexCharts.ApexOptions['plotOptions']\n >;\n options.plotOptions = {\n ...basePlot,\n radialBar: {\n ...(basePlot.radialBar ?? {}),\n dataLabels: {\n ...(basePlot.radialBar?.dataLabels ?? {}),\n value: {\n ...(basePlot.radialBar?.dataLabels?.value ?? {}),\n formatter: (val: number) => radialValueFormatter(Number(val)),\n },\n },\n },\n };\n }\n\n // Horizontal bars for rankings. `bar` and `radialBar` are mutually\n // exclusive effective types, so this never collides with the radialBar\n // plotOptions above. Absent (vertical) = the ApexCharts default, so the\n // key is only emitted when the consumer opts in.\n if (effectiveType === 'bar' && orientation === 'horizontal') {\n const basePlot = (base.plotOptions ?? {}) as NonNullable<\n ApexCharts.ApexOptions['plotOptions']\n >;\n options.plotOptions = {\n ...basePlot,\n bar: { ...(basePlot.bar ?? {}), horizontal: true },\n };\n }\n\n // Step 3 (fill) — the compare branches sit between the global `patterns`\n // branch and the area-gradient branch. Each is gated on hasCompare /\n // barCompare, so a chart with no compare series follows today's exact\n // paths and emits byte-identical fill.\n if (patterns) {\n // Global colour-blind pattern fills. With a compare overlay, pin the\n // compare indices to a single slanted hatch so they stay tellable apart\n // (grey colour from Step 1 + fixed hatch) while the primaries keep the\n // brand-hue style ApexCharts would have cycled for that index.\n options.fill = {\n type: 'pattern',\n opacity: effectiveType === 'area' ? 0.3 : 1,\n pattern: {\n style: hasCompare\n ? compareFlags.map((c, i) =>\n c\n ? 'slantedLines'\n : PATTERN_STYLES[i % PATTERN_STYLES.length],\n )\n : [...PATTERN_STYLES],\n strokeWidth: 2,\n },\n };\n } else if (barCompare) {\n // Bars can't dash, so the non-colour cue is the fill: compare bars get\n // a hatched (slantedLines) fill over the Step-1 grey base at full\n // opacity; primaries stay solid in their brand colour. Orientation is\n // independent — ApexCharts swaps axes, not the per-series fill mapping.\n options.fill = {\n type: compareFlags.map((c) => (c ? 'pattern' : 'solid')),\n pattern: {\n style: compareFlags.map((c) =>\n c ? 'slantedLines' : 'horizontalLines',\n ),\n strokeWidth: 2,\n },\n };\n } else if (effectiveType === 'area') {\n // Area gradient. With a compare overlay, lower the compare fill opacity\n // so its grey wash sits under the dashed grey stroke without fighting\n // the primary, and tint the compare gradient with the resolved\n // `--calendar-compare-fill` wash (primaries keep the default gradient).\n options.fill = hasCompare\n ? {\n type: 'gradient',\n opacity: compareFlags.map((c) => (c ? 0.15 : 0.3)),\n gradient: {\n gradientToColors: compareFlags.map((c) =>\n c ? compareWash : undefined,\n ) as string[],\n },\n }\n : {\n type: 'gradient',\n opacity: 0.3,\n };\n }\n\n return options;\n }, [\n themeOptions,\n chartId,\n toolbar,\n reducedMotion,\n toolbarLocale,\n locale,\n effectiveLabels,\n formatValue,\n t,\n effectiveType,\n effectiveSeries,\n effectiveCategories,\n isRtl,\n patterns,\n stacked,\n orientation,\n curve,\n colors,\n radialValueFormatter,\n ]);\n\n /* ---- resolved dimensions --------------------------------------- */\n const resolvedWidth =\n width ?? (containerWidth > 0 ? containerWidth : '100%');\n const resolvedHeight = height ?? 320;\n\n /* ---- sr-only data table --------------------------------------- */\n const srTable = useMemo(() => {\n const columnLabels = isSliceType(effectiveType)\n ? (effectiveLabels ?? [])\n : (effectiveCategories ?? []);\n const rows = tableSeries;\n return (\n <table id={summaryId} className=\"ds:sr-only\">\n <caption>{title}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{t('chart.table.series')}</th>\n {columnLabels.map((col, i) => (\n <th key={`${col}-${i}`} scope=\"col\">\n {col}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={`${row.name}-${rowIndex}`}>\n <th scope=\"row\">{row.name || t('chart.table.value')}</th>\n {row.data.map((value, colIndex) => (\n <td key={`${rowIndex}-${colIndex}`}>\n {/* For a radialBar gauge the series is a synthetic arc\n percent — announce the consumer's display value (e.g.\n the real BMI) instead of the raw fill so AT users get\n the same figure sighted users see in the ring. */}\n {effectiveType === 'radialBar' && radialValueFormatter\n ? radialValueFormatter(value)\n : formatValue(value)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n }, [\n effectiveType,\n tableSeries,\n effectiveLabels,\n effectiveCategories,\n summaryId,\n title,\n t,\n formatValue,\n radialValueFormatter,\n ]);\n\n /* ---- ApexCharts `series` prop shape ----------------------------- */\n const apexSeries = useMemo(() => {\n if (isSliceType(effectiveType)) {\n return effectiveSeries as number[];\n }\n return effectiveSeries as ChartSeries[];\n }, [effectiveSeries, effectiveType]);\n\n /* `key={effectiveType}` remounts ApexCharts on a switch: its in-place\n axis↔slice type transitions are unreliable (stale internal scales),\n and a clean mount is the documented-safe path. */\n const chartRegion = (\n <div\n ref={wrapperRef}\n role=\"img\"\n aria-label={title}\n aria-describedby={summaryId}\n className={chartVariants({\n // Explicit height wins over the density min-height unless the\n // caller also asked for a density explicitly.\n density: density ?? (height !== undefined ? 'none' : undefined),\n className: switcherEnabled ? undefined : className,\n })}\n {...(switcherEnabled\n ? {}\n : { 'data-component': 'chart', 'data-component-id': id })}\n >\n {srTable}\n <ReactApexChart\n key={effectiveType}\n type={effectiveType}\n series={apexSeries as ApexCharts.ApexOptions['series']}\n options={chartOptions}\n width={resolvedWidth}\n height={resolvedHeight}\n aria-hidden=\"true\"\n />\n </div>\n );\n\n if (!switcherEnabled) return chartRegion;\n\n /* The switcher cannot live inside the `role=\"img\"` region — that role\n makes the whole subtree presentational, which would strip the radios\n from the accessibility tree. It renders as a sibling above the plot,\n and the bounding `data-component` marker moves to this shared\n wrapper so the component boundary still encloses everything. */\n return (\n <div\n data-component=\"chart\"\n data-component-id={id}\n className={`ds:block ds:w-full ${className ?? ''}`.trim()}\n >\n <div className=\"ds:mb-[var(--spacing-xs)] ds:flex ds:justify-end\">\n <IconButtonGroup\n role=\"radiogroup\"\n mode=\"toggle-single\"\n size=\"sm\"\n aria-label={t('chart.typeSwitcher.label')}\n value={effectiveType}\n onValueChange={(next) => {\n // Guard: keyboard paths can re-commit the current value; the\n // contract is \"called when the user picks a DIFFERENT type\".\n if (next === effectiveType) return;\n setPickedType(next as SwitchableType);\n onTypeChange?.(next as ChartType);\n }}\n >\n {switcherTypes.map((entry) => (\n <IconButton\n key={entry}\n value={entry}\n // Explicit — the default (submit) would post a surrounding\n // consumer <form> on click/Space.\n type=\"button\"\n icon={TYPE_SWITCHER_ICONS[entry]}\n aria-label={t(TYPE_SWITCHER_LABEL_KEYS[entry])}\n />\n ))}\n </IconButtonGroup>\n </div>\n {chartRegion}\n </div>\n );\n },\n);\n\nChart.displayName = 'Chart';\n\n/* ------------------------------------------------------------------ */\n/* Re-export internal helper for downstream theming (kept narrow). */\n/* ------------------------------------------------------------------ */\n\nexport { chartVariants };\n"],"names":["__iconNode","ChartArea","createLucideIcon","ChartColumn","ChartLine","ChartPie","Donut","chartAgent","handle","args","chartVariants","cva","PATTERN_STYLES","CATEGORICAL_TYPES","SLICE_TYPES","SWITCHABLE_TYPES","TYPE_SWITCHER_LABEL_KEYS","TYPE_SWITCHER_ICONS","isSliceType","type","isCategoricalType","normaliseSeries","series","Chart","forwardRef","title","id","categories","labels","height","width","patterns","stacked","orientation","curve","colors","toolbar","localeProp","radialValueFormatter","valueFormatter","switchableTypes","onTypeChange","density","className","ref","t","i18n","useTranslation","rawId","useId","chartId","useMemo","summaryId","wrapperRef","useRef","containerWidth","setContainerWidth","useState","useNeutraliseHiddenFocus","locale","themeOptions","setThemeOptions","getApexChartsTheme","useEffect","timer","observer","el","ro","entries","entry","switcherTypes","valid","withCurrent","switcherEnabled","pickedType","setPickedType","effectiveType","declaredIsSlice","effectiveIsSlice","effectiveSeries","effectiveCategories","effectiveLabels","rows","row","sum","v","values","agentHandle","instance","ApexCharts","next","declaredSlice","renderedSlice","useImperativeHandle","useAgentRegistration","isRtl","tableSeries","numberFormatter","formatValue","value","toolbarLocale","reducedMotion","usePrefersReducedMotion","chartOptions","compareColours","base","compareMark","compareWash","compareFlags","s","hasCompare","barCompare","options","ramp","_","i","horizontalBar","c","basePlot","_a","_c","_b","val","resolvedWidth","resolvedHeight","srTable","columnLabels","jsx","jsxs","col","rowIndex","colIndex","apexSeries","chartRegion","ReactApexChart","IconButtonGroup","IconButton"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,4BAA4B,KAAK,SAAQ,CAAE;AAAA,EACzD;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AACA,GACMC,KAAYC,EAAiB,cAAcF,EAAU;ACnB3D;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,4BAA4B,KAAK,SAAQ,CAAE;AAAA,EACzD,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAC3C,GACMG,KAAcD,EAAiB,gBAAgBF,EAAU;ACf/D;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,GAAG,4BAA4B,KAAK,SAAQ,CAAE;AAAA,EACzD,CAAC,QAAQ,EAAE,GAAG,qBAAqB,KAAK,SAAQ,CAAE;AACpD,GACMI,KAAYF,EAAiB,cAAcF,EAAU;ACb3D;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE,CAAC,QAAQ,EAAE,GAAG,mCAAmC,KAAK,SAAQ,CAAE;AAClE,GACMK,KAAWH,EAAiB,aAAaF,E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AAqB/C,EAAA;AAAA,QAErD,UAAA;AAAA,UAAAmG;AAAA,UACD,gBAAAE;AAAA,YAACO;AAAA,YAAA;AAAA,cAEC,MAAM1D;AAAA,cACN,QAAQwD;AAAA,cACR,SAAS7B;AAAA,cACT,OAAOoB;AAAA,cACP,QAAQC;AAAA,cACR,eAAY;AAAA,YAAA;AAAA,YANPhD;AAAA,UAAA;AAAA,QAOP;AAAA,MAAA;AAAA,IAAA;AAIJ,WAAKH,IAQH,gBAAAuD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,kBAAe;AAAA,QACf,qBAAmBtG;AAAA,QACnB,WAAW,sBAAsBiB,KAAa,EAAE,GAAG,KAAA;AAAA,QAEnD,UAAA;AAAA,UAAA,gBAAAoF,EAAC,OAAA,EAAI,WAAU,oDACb,UAAA,gBAAAA;AAAA,YAACQ;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,MAAK;AAAA,cACL,MAAK;AAAA,cACL,cAAY1F,EAAE,0BAA0B;AAAA,cACxC,OAAO+B;AAAA,cACP,eAAe,CAACc,MAAS;AAGvB,gBAAIA,MAASd,MACbD,GAAce,CAAsB,GACpCjD,KAAA,QAAAA,EAAeiD;AAAA,cACjB;AAAA,cAEC,UAAApB,EAAc,IAAI,CAACD,MAClB,gBAAA0D;AAAA,gBAACS;AAAA,gBAAA;AAAA,kBAEC,OAAOnE;AAAA,kBAGP,MAAK;AAAA,kBACL,MAAMpD,GAAoBoD,CAAK;AAAA,kBAC/B,cAAYxB,EAAE7B,GAAyBqD,CAAK,CAAC;AAAA,gBAAA;AAAA,gBANxCA;AAAA,cAAA,CAQR;AAAA,YAAA;AAAA,UAAA,GAEL;AAAA,UACCgE;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,IAzCwBA;AAAA,EA4C/B;AACF;AAEA9G,GAAM,cAAc;","x_google_ignoreList":[0,1,2,3,4]}
@@ -3,12 +3,12 @@ import { forwardRef as A, useState as C, useMemo as N, useEffect as I } from "re
3
3
  import { c as S } from "./index-D2ZczOXr.js";
4
4
  import { useTranslation as k } from "react-i18next";
5
5
  import { F as L } from "./form-field-M5UpX65Z.js";
6
- import { D as z } from "./date-picker-ffmyjvlI.js";
6
+ import { D as z } from "./date-picker-BP_W6VtE.js";
7
7
  import { N as D } from "./number-input-DjWzmlEY.js";
8
8
  import { C as E } from "./card-DPmk26CL.js";
9
9
  import { B as P } from "./badge-DCOqV9mI.js";
10
10
  import { I as B } from "./insert-result-D074GtHX.js";
11
- import { a as i } from "./date-picker-variants-D9B6hg15.js";
11
+ import { a as i } from "./date-picker-variants-eL6HjWvw.js";
12
12
  import { C as G } from "./check-DrFSN__t.js";
13
13
  import { H as R } from "./heart--qCA4ffe.js";
14
14
  import { c as Y } from "./createLucideIcon-DhHxpK9K.js";
@@ -249,4 +249,4 @@ export {
249
249
  U as L,
250
250
  O as p
251
251
  };
252
- //# sourceMappingURL=cycle-calculator-DXSNIWFk.js.map
252
+ //# sourceMappingURL=cycle-calculator-DNvvr0bP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cycle-calculator-DXSNIWFk.js","sources":["../../node_modules/lucide-react/dist/esm/icons/droplet.mjs","../../src/components/cycle-calculator/cycle.ts","../../src/components/cycle-calculator/cycle-calculator.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z\",\n key: \"c7niix\"\n }\n ]\n];\nconst Droplet = createLucideIcon(\"droplet\", __iconNode);\n\nexport { __iconNode, Droplet as default };\n//# sourceMappingURL=droplet.mjs.map\n","/* ------------------------------------------------------------------ */\n/* Menstrual-cycle prediction — pure, framework-free, unit-testable. */\n/* */\n/* Uses the standard fixed-luteal-phase model: ovulation falls ~14 days */\n/* before the next period, so on a cycle of length L ovulation is day */\n/* (L − 14). The fertile window spans the 5 days before ovulation */\n/* (sperm survival) through 1 day after (oocyte viability). */\n/* ------------------------------------------------------------------ */\n\nimport { addDays } from 'date-fns';\n\n/** Standard menstrual-cycle length. */\nexport const DEFAULT_CYCLE_LENGTH = 28;\n/** Luteal phase is biologically near-constant at ~14 days. */\nexport const LUTEAL_PHASE_DAYS = 14;\n/** Sperm survive up to ~5 days before ovulation. */\nexport const FERTILE_DAYS_BEFORE = 5;\n/** The oocyte is viable ~1 day after ovulation. */\nexport const FERTILE_DAYS_AFTER = 1;\n\nexport interface CycleInput {\n /** First day of the most recent period. */\n lastPeriodStart: Date;\n /** Average cycle length in days. Defaults to 28. */\n cycleLength?: number;\n /** Period (bleed) length in days. Optional — used for the period range. */\n periodLength?: number;\n}\n\nexport interface DateRange {\n start: Date;\n end: Date;\n}\n\nexport interface CyclePrediction {\n /** Start date of the next period. */\n nextPeriod: Date;\n /** Estimated ovulation date. */\n ovulation: Date;\n /** Fertile window (5 days before ovulation → 1 day after). */\n fertileWindow: DateRange;\n /** Start dates of the next few periods (length = `occurrences`). */\n upcomingPeriods: Date[];\n /**\n * The current period's bleed range (first day → last day), or `null` when no\n * `periodLength` was given.\n */\n periodRange: DateRange | null;\n}\n\n/**\n * Predict ovulation, the fertile window and upcoming periods from the last\n * period's start date. `occurrences` controls how many future periods to\n * list (default 3).\n */\nexport function predictCycle(\n input: CycleInput,\n occurrences = 3,\n): CyclePrediction {\n const cycle = input.cycleLength ?? DEFAULT_CYCLE_LENGTH;\n const { lastPeriodStart } = input;\n\n const ovulation = addDays(lastPeriodStart, cycle - LUTEAL_PHASE_DAYS);\n const fertileWindow: DateRange = {\n start: addDays(ovulation, -FERTILE_DAYS_BEFORE),\n end: addDays(ovulation, FERTILE_DAYS_AFTER),\n };\n const nextPeriod = addDays(lastPeriodStart, cycle);\n const upcomingPeriods = Array.from({ length: occurrences }, (_, i) =>\n addDays(lastPeriodStart, cycle * (i + 1)),\n );\n const periodRange: DateRange | null =\n input.periodLength && input.periodLength > 0\n ? {\n start: lastPeriodStart,\n end: addDays(lastPeriodStart, input.periodLength - 1),\n }\n : null;\n\n return { nextPeriod, ovulation, fertileWindow, upcomingPeriods, periodRange };\n}\n","/* ------------------------------------------------------------------ */\n/* CycleCalculator — predict ovulation, fertile window and upcoming */\n/* periods from the last period's start date. */\n/* */\n/* Maths lives in `./cycle` (pure, separately tested). */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Heart, Check, Droplet } from 'lucide-react';\nimport { FormField } from '../form-field';\nimport { DatePicker } from '../date-picker';\nimport { NumberInput } from '../number-input';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport {\n InsertButton,\n type InsertPayload,\n type InsertVariant,\n type InsertMode,\n} from '../_shared/insert-result';\nimport {\n type CyclePrediction,\n predictCycle,\n DEFAULT_CYCLE_LENGTH,\n} from './cycle';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\n/**\n * DS token NAME backing the result-card chip — the fertile window is the\n * headline fertility datum, shown on screen with the `accent` Badge variant\n * (which fills `--accent`). The card chip reuses that token so the inserted\n * PNG chip matches the on-screen fertile-window badge.\n */\nconst HIGHLIGHT_TOKEN = '--accent';\n\nexport interface CycleCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Initial cycle length in days. Defaults to 28. */\n defaultCycleLength?: number;\n /** Fires whenever a prediction can be computed (and `null` when it can't). */\n onResultChange?: (result: CyclePrediction | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /**\n * Which verb the result button performs. Defaults to `'insert'`.\n * Use `'copy'` in an app-shell surface (no editor to insert into) — the\n * button writes the result to the clipboard as a multi-format `ClipboardItem`.\n */\n insertVariant?: InsertVariant;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /**\n * Brand wordmark printed in the inserted/copied result-card footer.\n * Omitted → no brand line (and no footer hairline); a string → that custom\n * brand; `false` → no brand line. Brand is opt-in.\n */\n insertBrand?: string | false;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const CycleCalculator = forwardRef<HTMLDivElement, CycleCalculatorProps>(\n (\n {\n defaultCycleLength = DEFAULT_CYCLE_LENGTH,\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [lastPeriod, setLastPeriod] = useState<Date | undefined>(undefined);\n const [cycleLength, setCycleLength] = useState<number | null>(\n defaultCycleLength,\n );\n const [periodLength, setPeriodLength] = useState<number | null>(null);\n\n const result = useMemo<CyclePrediction | null>(() => {\n if (!lastPeriod) return null;\n return predictCycle({\n lastPeriodStart: lastPeriod,\n cycleLength: cycleLength ?? DEFAULT_CYCLE_LENGTH,\n periodLength: periodLength ?? undefined,\n });\n }, [lastPeriod, cycleLength, periodLength]);\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const today = useMemo(() => new Date(), []);\n\n const fmt = (d: Date): string => dateFormatter.format(d);\n\n return (\n <div\n ref={ref}\n data-component=\"cycle-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <FormField label={t('cycleCalculator.lastPeriod')}>\n <DatePicker\n value={lastPeriod}\n onChange={setLastPeriod}\n maxDate={today}\n />\n </FormField>\n <FormField\n label={t('cycleCalculator.cycleLength')}\n description={t('cycleCalculator.cycleLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={20}\n max={45}\n value={cycleLength}\n onChange={setCycleLength}\n />\n </FormField>\n <FormField\n label={t('cycleCalculator.periodLength')}\n description={t('cycleCalculator.periodLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={1}\n max={14}\n value={periodLength}\n onChange={setPeriodLength}\n />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('cycleCalculator.ovulation')}: ${fmt(result.ovulation)}. ${t(\n 'cycleCalculator.nextPeriod',\n )}: ${fmt(result.nextPeriod)}.`\n : ''}\n </p>\n\n {result ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <dl className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.ovulation')}\n </dt>\n <dd>\n <Badge\n variant=\"success\"\n size=\"lg\"\n leading={<Check aria-hidden />}\n >\n {fmt(result.ovulation)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.fertileWindow')}\n </dt>\n <dd>\n <Badge\n variant=\"accent\"\n size=\"lg\"\n leading={<Heart aria-hidden />}\n >\n {fmt(result.fertileWindow.start)} –{' '}\n {fmt(result.fertileWindow.end)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.nextPeriod')}\n </dt>\n <dd>\n <Badge\n variant=\"error\"\n size=\"lg\"\n leading={<Droplet aria-hidden />}\n >\n {fmt(result.nextPeriod)}\n </Badge>\n </dd>\n </div>\n </dl>\n\n {result.periodRange ? (\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.periodRange')}\n </span>\n <span className=\"type-body ds:text-foreground\">\n {fmt(result.periodRange.start)} –{' '}\n {fmt(result.periodRange.end)}\n </span>\n </div>\n ) : null}\n\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.upcomingPeriods')}\n </span>\n <ul className=\"ds:flex ds:flex-wrap ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-2xs)]\">\n {result.upcomingPeriods.map((d) => (\n <li\n key={d.getTime()}\n className=\"type-body ds:text-foreground\"\n >\n {fmt(d)}\n </li>\n ))}\n </ul>\n </div>\n\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.cycle'),\n icon: 'heart',\n highlight: `${fmt(result.fertileWindow.start)} – ${fmt(\n result.fertileWindow.end,\n )}`,\n // Chip reuses the on-screen fertile-window badge's accent\n // token so the inserted PNG chip matches the screen.\n highlightToken: HIGHLIGHT_TOKEN,\n brand: insertBrand,\n fields: [\n {\n // Ovulation is a predicted date → calendar glyph (the\n // on-screen badge uses a Check tick, which ICON_GEOMETRY\n // does not carry, so the calendar reads the date meaning).\n icon: 'calendar',\n label: t('cycleCalculator.ovulation'),\n value: fmt(result.ovulation),\n },\n {\n // Fertile window → heart glyph, matching the on-screen\n // fertile-window badge's Heart icon.\n icon: 'heart',\n label: t('cycleCalculator.fertileWindow'),\n value: `${fmt(result.fertileWindow.start)} – ${fmt(\n result.fertileWindow.end,\n )}`,\n },\n {\n // Next period → droplets glyph, matching the on-screen\n // next-period badge's Droplet icon.\n icon: 'droplets',\n label: t('cycleCalculator.nextPeriod'),\n value: fmt(result.nextPeriod),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('cycleCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nCycleCalculator.displayName = 'CycleCalculator';\n"],"names":["__iconNode","Droplet","createLucideIcon","DEFAULT_CYCLE_LENGTH","LUTEAL_PHASE_DAYS","FERTILE_DAYS_AFTER","predictCycle","input","occurrences","cycle","lastPeriodStart","ovulation","addDays","fertileWindow","nextPeriod","upcomingPeriods","_","i","periodRange","rootVariants","cva","HIGHLIGHT_TOKEN","CycleCalculator","forwardRef","defaultCycleLength","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","i18n","useTranslation","lastPeriod","setLastPeriod","useState","cycleLength","setCycleLength","periodLength","setPeriodLength","result","useMemo","dateFormatter","useEffect","today","fmt","d","jsxs","jsx","FormField","DatePicker","NumberInput","Card","Badge","Check","Heart","InsertButton"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AACA,GACMC,IAAUC,EAAiB,WAAWF,CAAU,GCNzCG,IAAuB,IAEvBC,IAAoB,IAIpBC,IAAqB;AAqC3B,SAASC,EACdC,GACAC,IAAc,GACG;AACjB,QAAMC,IAAQF,EAAM,eAAeJ,GAC7B,EAAE,iBAAAO,MAAoBH,GAEtBI,IAAYC,EAAQF,GAAiBD,IAAQL,CAAiB,GAC9DS,IAA2B;AAAA,IAC/B,OAAOD,EAAQD,GA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C5B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA9B,EAAgB,cAAc;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"cycle-calculator-DNvvr0bP.js","sources":["../../node_modules/lucide-react/dist/esm/icons/droplet.mjs","../../src/components/cycle-calculator/cycle.ts","../../src/components/cycle-calculator/cycle-calculator.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z\",\n key: \"c7niix\"\n }\n ]\n];\nconst Droplet = createLucideIcon(\"droplet\", __iconNode);\n\nexport { __iconNode, Droplet as default };\n//# sourceMappingURL=droplet.mjs.map\n","/* ------------------------------------------------------------------ */\n/* Menstrual-cycle prediction — pure, framework-free, unit-testable. */\n/* */\n/* Uses the standard fixed-luteal-phase model: ovulation falls ~14 days */\n/* before the next period, so on a cycle of length L ovulation is day */\n/* (L − 14). The fertile window spans the 5 days before ovulation */\n/* (sperm survival) through 1 day after (oocyte viability). */\n/* ------------------------------------------------------------------ */\n\nimport { addDays } from 'date-fns';\n\n/** Standard menstrual-cycle length. */\nexport const DEFAULT_CYCLE_LENGTH = 28;\n/** Luteal phase is biologically near-constant at ~14 days. */\nexport const LUTEAL_PHASE_DAYS = 14;\n/** Sperm survive up to ~5 days before ovulation. */\nexport const FERTILE_DAYS_BEFORE = 5;\n/** The oocyte is viable ~1 day after ovulation. */\nexport const FERTILE_DAYS_AFTER = 1;\n\nexport interface CycleInput {\n /** First day of the most recent period. */\n lastPeriodStart: Date;\n /** Average cycle length in days. Defaults to 28. */\n cycleLength?: number;\n /** Period (bleed) length in days. Optional — used for the period range. */\n periodLength?: number;\n}\n\nexport interface DateRange {\n start: Date;\n end: Date;\n}\n\nexport interface CyclePrediction {\n /** Start date of the next period. */\n nextPeriod: Date;\n /** Estimated ovulation date. */\n ovulation: Date;\n /** Fertile window (5 days before ovulation → 1 day after). */\n fertileWindow: DateRange;\n /** Start dates of the next few periods (length = `occurrences`). */\n upcomingPeriods: Date[];\n /**\n * The current period's bleed range (first day → last day), or `null` when no\n * `periodLength` was given.\n */\n periodRange: DateRange | null;\n}\n\n/**\n * Predict ovulation, the fertile window and upcoming periods from the last\n * period's start date. `occurrences` controls how many future periods to\n * list (default 3).\n */\nexport function predictCycle(\n input: CycleInput,\n occurrences = 3,\n): CyclePrediction {\n const cycle = input.cycleLength ?? DEFAULT_CYCLE_LENGTH;\n const { lastPeriodStart } = input;\n\n const ovulation = addDays(lastPeriodStart, cycle - LUTEAL_PHASE_DAYS);\n const fertileWindow: DateRange = {\n start: addDays(ovulation, -FERTILE_DAYS_BEFORE),\n end: addDays(ovulation, FERTILE_DAYS_AFTER),\n };\n const nextPeriod = addDays(lastPeriodStart, cycle);\n const upcomingPeriods = Array.from({ length: occurrences }, (_, i) =>\n addDays(lastPeriodStart, cycle * (i + 1)),\n );\n const periodRange: DateRange | null =\n input.periodLength && input.periodLength > 0\n ? {\n start: lastPeriodStart,\n end: addDays(lastPeriodStart, input.periodLength - 1),\n }\n : null;\n\n return { nextPeriod, ovulation, fertileWindow, upcomingPeriods, periodRange };\n}\n","/* ------------------------------------------------------------------ */\n/* CycleCalculator — predict ovulation, fertile window and upcoming */\n/* periods from the last period's start date. */\n/* */\n/* Maths lives in `./cycle` (pure, separately tested). */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Heart, Check, Droplet } from 'lucide-react';\nimport { FormField } from '../form-field';\nimport { DatePicker } from '../date-picker';\nimport { NumberInput } from '../number-input';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport {\n InsertButton,\n type InsertPayload,\n type InsertVariant,\n type InsertMode,\n} from '../_shared/insert-result';\nimport {\n type CyclePrediction,\n predictCycle,\n DEFAULT_CYCLE_LENGTH,\n} from './cycle';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\n/**\n * DS token NAME backing the result-card chip — the fertile window is the\n * headline fertility datum, shown on screen with the `accent` Badge variant\n * (which fills `--accent`). The card chip reuses that token so the inserted\n * PNG chip matches the on-screen fertile-window badge.\n */\nconst HIGHLIGHT_TOKEN = '--accent';\n\nexport interface CycleCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Initial cycle length in days. Defaults to 28. */\n defaultCycleLength?: number;\n /** Fires whenever a prediction can be computed (and `null` when it can't). */\n onResultChange?: (result: CyclePrediction | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /**\n * Which verb the result button performs. Defaults to `'insert'`.\n * Use `'copy'` in an app-shell surface (no editor to insert into) — the\n * button writes the result to the clipboard as a multi-format `ClipboardItem`.\n */\n insertVariant?: InsertVariant;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /**\n * Brand wordmark printed in the inserted/copied result-card footer.\n * Omitted → no brand line (and no footer hairline); a string → that custom\n * brand; `false` → no brand line. Brand is opt-in.\n */\n insertBrand?: string | false;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const CycleCalculator = forwardRef<HTMLDivElement, CycleCalculatorProps>(\n (\n {\n defaultCycleLength = DEFAULT_CYCLE_LENGTH,\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [lastPeriod, setLastPeriod] = useState<Date | undefined>(undefined);\n const [cycleLength, setCycleLength] = useState<number | null>(\n defaultCycleLength,\n );\n const [periodLength, setPeriodLength] = useState<number | null>(null);\n\n const result = useMemo<CyclePrediction | null>(() => {\n if (!lastPeriod) return null;\n return predictCycle({\n lastPeriodStart: lastPeriod,\n cycleLength: cycleLength ?? DEFAULT_CYCLE_LENGTH,\n periodLength: periodLength ?? undefined,\n });\n }, [lastPeriod, cycleLength, periodLength]);\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const today = useMemo(() => new Date(), []);\n\n const fmt = (d: Date): string => dateFormatter.format(d);\n\n return (\n <div\n ref={ref}\n data-component=\"cycle-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <FormField label={t('cycleCalculator.lastPeriod')}>\n <DatePicker\n value={lastPeriod}\n onChange={setLastPeriod}\n maxDate={today}\n />\n </FormField>\n <FormField\n label={t('cycleCalculator.cycleLength')}\n description={t('cycleCalculator.cycleLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={20}\n max={45}\n value={cycleLength}\n onChange={setCycleLength}\n />\n </FormField>\n <FormField\n label={t('cycleCalculator.periodLength')}\n description={t('cycleCalculator.periodLengthHint')}\n >\n <NumberInput\n mode=\"integer\"\n min={1}\n max={14}\n value={periodLength}\n onChange={setPeriodLength}\n />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('cycleCalculator.ovulation')}: ${fmt(result.ovulation)}. ${t(\n 'cycleCalculator.nextPeriod',\n )}: ${fmt(result.nextPeriod)}.`\n : ''}\n </p>\n\n {result ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <dl className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.ovulation')}\n </dt>\n <dd>\n <Badge\n variant=\"success\"\n size=\"lg\"\n leading={<Check aria-hidden />}\n >\n {fmt(result.ovulation)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.fertileWindow')}\n </dt>\n <dd>\n <Badge\n variant=\"accent\"\n size=\"lg\"\n leading={<Heart aria-hidden />}\n >\n {fmt(result.fertileWindow.start)} –{' '}\n {fmt(result.fertileWindow.end)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.nextPeriod')}\n </dt>\n <dd>\n <Badge\n variant=\"error\"\n size=\"lg\"\n leading={<Droplet aria-hidden />}\n >\n {fmt(result.nextPeriod)}\n </Badge>\n </dd>\n </div>\n </dl>\n\n {result.periodRange ? (\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.periodRange')}\n </span>\n <span className=\"type-body ds:text-foreground\">\n {fmt(result.periodRange.start)} –{' '}\n {fmt(result.periodRange.end)}\n </span>\n </div>\n ) : null}\n\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('cycleCalculator.upcomingPeriods')}\n </span>\n <ul className=\"ds:flex ds:flex-wrap ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-2xs)]\">\n {result.upcomingPeriods.map((d) => (\n <li\n key={d.getTime()}\n className=\"type-body ds:text-foreground\"\n >\n {fmt(d)}\n </li>\n ))}\n </ul>\n </div>\n\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.cycle'),\n icon: 'heart',\n highlight: `${fmt(result.fertileWindow.start)} – ${fmt(\n result.fertileWindow.end,\n )}`,\n // Chip reuses the on-screen fertile-window badge's accent\n // token so the inserted PNG chip matches the screen.\n highlightToken: HIGHLIGHT_TOKEN,\n brand: insertBrand,\n fields: [\n {\n // Ovulation is a predicted date → calendar glyph (the\n // on-screen badge uses a Check tick, which ICON_GEOMETRY\n // does not carry, so the calendar reads the date meaning).\n icon: 'calendar',\n label: t('cycleCalculator.ovulation'),\n value: fmt(result.ovulation),\n },\n {\n // Fertile window → heart glyph, matching the on-screen\n // fertile-window badge's Heart icon.\n icon: 'heart',\n label: t('cycleCalculator.fertileWindow'),\n value: `${fmt(result.fertileWindow.start)} – ${fmt(\n result.fertileWindow.end,\n )}`,\n },\n {\n // Next period → droplets glyph, matching the on-screen\n // next-period badge's Droplet icon.\n icon: 'droplets',\n label: t('cycleCalculator.nextPeriod'),\n value: fmt(result.nextPeriod),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('cycleCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nCycleCalculator.displayName = 'CycleCalculator';\n"],"names":["__iconNode","Droplet","createLucideIcon","DEFAULT_CYCLE_LENGTH","LUTEAL_PHASE_DAYS","FERTILE_DAYS_AFTER","predictCycle","input","occurrences","cycle","lastPeriodStart","ovulation","addDays","fertileWindow","nextPeriod","upcomingPeriods","_","i","periodRange","rootVariants","cva","HIGHLIGHT_TOKEN","CycleCalculator","forwardRef","defaultCycleLength","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","i18n","useTranslation","lastPeriod","setLastPeriod","useState","cycleLength","setCycleLength","periodLength","setPeriodLength","result","useMemo","dateFormatter","useEffect","today","fmt","d","jsxs","jsx","FormField","DatePicker","NumberInput","Card","Badge","Check","Heart","InsertButton"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AACA,GACMC,IAAUC,EAAiB,WAAWF,CAAU,GCNzCG,IAAuB,IAEvBC,IAAoB,IAIpBC,IAAqB;AAqC3B,SAASC,EACdC,GACAC,IAAc,GACG;AACjB,QAAMC,IAAQF,EAAM,eAAeJ,GAC7B,EAAE,iBAAAO,MAAoBH,GAEtBI,IAAYC,EAAQF,GAAiBD,IAAQL,CAAiB,GAC9DS,IAA2B;AAAA,IAC/B,OAAOD,EAAQD,GAAW,EAAoB;AAAA,IAC9C,KAAKC,EAAQD,GAAWN,CAAkB;AAAA,EAAA,GAEtCS,IAAaF,EAAQF,GAAiBD,CAAK,GAC3CM,IAAkB,MAAM;AAAA,IAAK,EAAE,QAAQP,EAAA;AAAA,IAAe,CAACQ,GAAGC,MAC9DL,EAAQF,GAAiBD,KAASQ,IAAI,EAAE;AAAA,EAAA,GAEpCC,IACJX,EAAM,gBAAgBA,EAAM,eAAe,IACvC;AAAA,IACE,OAAOG;AAAA,IACP,KAAKE,EAAQF,GAAiBH,EAAM,eAAe,CAAC;AAAA,EAAA,IAEtD;AAEN,SAAO,EAAE,YAAAO,GAAY,WAAAH,GAAW,eAAAE,GAAe,iBAAAE,GAAiB,aAAAG,EAAA;AAClE;ACpDA,MAAMC,IAAeC,EAAI,kDAAkD;AAAA,EACzE,UAAU;AAAA,IACR,OAAO,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AA,kBAGD,gBAAgBvB;AAAA,kBAChB,OAAOS;AAAA,kBACP,QAAQ;AAAA,oBACN;AAAA;AAAA;AAAA;AAAA,sBAIE,MAAM;AAAA,sBACN,OAAO,EAAE,2BAA2B;AAAA,sBACpC,OAAOmB,EAAIL,EAAO,SAAS;AAAA,oBAAA;AAAA,oBAE7B;AAAA;AAAA;AAAA,sBAGE,MAAM;AAAA,sBACN,OAAO,EAAE,+BAA+B;AAAA,sBACxC,OAAO,GAAGK,EAAIL,EAAO,cAAc,KAAK,CAAC,MAAMK;AAAA,wBAC7CL,EAAO,cAAc;AAAA,sBAAA,CACtB;AAAA,oBAAA;AAAA,oBAEH;AAAA;AAAA;AAAA,sBAGE,MAAM;AAAA,sBACN,OAAO,EAAE,4BAA4B;AAAA,sBACrC,OAAOK,EAAIL,EAAO,UAAU;AAAA,oBAAA;AAAA,kBAC9B;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAQ,EAAC,KAAA,EAAE,WAAU,sCACV,UAAA,EAAE,uBAAuB,EAAA,CAC5B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA9B,EAAgB,cAAc;","x_google_ignoreList":[0]}
@@ -0,0 +1,265 @@
1
+ import { jsx as r, jsxs as v } from "react/jsx-runtime";
2
+ import { forwardRef as ae, useState as y, useRef as K, useEffect as re, useCallback as R, useMemo as ne, useImperativeHandle as se } from "react";
3
+ import { useTranslation as ie } from "react-i18next";
4
+ import * as k from "@radix-ui/react-popover";
5
+ import { u as oe } from "./use-controllable-state-BiY4xTzM.js";
6
+ import { u as de } from "./form-field-context-B3APVHKx.js";
7
+ import { u as ce } from "./registry-DvAUVLHh.js";
8
+ import { u as le, g as pe, f as T, b as ue, c as fe, i as me, t as he, d as ge, p as ve, D as ye, C as ke, e as be, h as Ce, j as De } from "./date-picker-variants-eL6HjWvw.js";
9
+ import { C as Pe } from "./calendar-days-BGWklvE-.js";
10
+ import { C as Se } from "./check-DrFSN__t.js";
11
+ import { p as xe } from "./parse-DvA97ro9.js";
12
+ import { i as we } from "./isSameDay-DUEiAT0G.js";
13
+ const Ie = {
14
+ id: "date-picker",
15
+ // Persisted single date (value state + set_date) → select_single + set_value,
16
+ // plus open/close of the calendar popover.
17
+ capabilities: ["select_single", "set_value", "open", "close"],
18
+ state: {
19
+ value: {
20
+ type: "iso-date",
21
+ descriptionKey: "ui.agent.datePicker.state.value",
22
+ description: "Currently-selected ISO date, or null.",
23
+ read: (a) => {
24
+ var c;
25
+ return ((c = a.getValue()) == null ? void 0 : c.toISOString()) ?? null;
26
+ }
27
+ },
28
+ isOpen: {
29
+ type: "boolean",
30
+ descriptionKey: "ui.agent.datePicker.state.isOpen",
31
+ description: "Whether the calendar popover is open.",
32
+ read: (a) => a.isOpen()
33
+ }
34
+ },
35
+ actions: {
36
+ set_date: {
37
+ safety: "write",
38
+ argsType: "{ date: string }",
39
+ argsSchema: {
40
+ type: "object",
41
+ properties: {
42
+ date: {
43
+ type: "string",
44
+ format: "date",
45
+ description: 'ISO date, e.g. "2026-06-23".'
46
+ }
47
+ },
48
+ required: ["date"]
49
+ },
50
+ idempotent: !0,
51
+ descriptionKey: "ui.agent.datePicker.actions.setDate",
52
+ description: "Select a specific date (ISO yyyy-mm-dd).",
53
+ examples: [{ args: { date: "2026-06-23" }, note: "Select 23 Jun 2026." }],
54
+ invoke: (a, c) => {
55
+ a.setValue(new Date(c.date));
56
+ }
57
+ },
58
+ clear: {
59
+ // Discards the selected date — loses the user's input.
60
+ safety: "destructive",
61
+ idempotent: !0,
62
+ descriptionKey: "ui.agent.datePicker.actions.clear",
63
+ description: "Clear the selected date.",
64
+ invoke: (a) => {
65
+ a.clear();
66
+ }
67
+ },
68
+ open: {
69
+ safety: "read",
70
+ idempotent: !0,
71
+ descriptionKey: "ui.agent.datePicker.actions.open",
72
+ description: "Open the calendar popover.",
73
+ invoke: (a) => {
74
+ a.open();
75
+ }
76
+ },
77
+ close: {
78
+ safety: "read",
79
+ idempotent: !0,
80
+ descriptionKey: "ui.agent.datePicker.actions.close",
81
+ description: "Close the calendar popover.",
82
+ invoke: (a) => {
83
+ a.close();
84
+ }
85
+ }
86
+ },
87
+ domHooks: {
88
+ root: {
89
+ attr: "data-component",
90
+ value: "date-picker",
91
+ description: "Marks the DatePicker wrapper."
92
+ },
93
+ instanceId: {
94
+ attr: "data-component-id",
95
+ sourceProp: "id",
96
+ description: "Sourced from the id prop."
97
+ }
98
+ }
99
+ }, Oe = ae(
100
+ ({
101
+ value: a,
102
+ defaultValue: c,
103
+ onChange: F,
104
+ minDate: m,
105
+ maxDate: h,
106
+ disabledDates: l,
107
+ weekStartsOn: M,
108
+ presets: b,
109
+ size: x = "md",
110
+ disabled: j,
111
+ placeholder: q,
112
+ className: B,
113
+ id: E
114
+ }, L) => {
115
+ const { t: w, i18n: I } = ie(), p = de(), C = E ?? p.id, O = p.disabled || j, _ = p.invalid ? "error" : "default", u = le(I.language), f = pe(I.language), H = q ?? w("inputs.datePicker.placeholder", "Select date"), [W, N] = oe({
116
+ value: a,
117
+ defaultValue: c,
118
+ onChange: F
119
+ }), n = W, [i, s] = y(!1), [J, D] = y(
120
+ n ? T(n, f, { locale: u }) : ""
121
+ ), [V, g] = y(!1), [z, P] = y(n ?? /* @__PURE__ */ new Date()), S = K(null);
122
+ re(() => {
123
+ n ? (D(T(n, f, { locale: u })), g(!1)) : D("");
124
+ }, [n, f, u]);
125
+ const G = ue(
126
+ m,
127
+ h,
128
+ l
129
+ ), Q = R(
130
+ (e) => m && fe(e, m) || h && me(e, h) ? !0 : Array.isArray(l) ? l.some(
131
+ (t) => t.toDateString() === e.toDateString()
132
+ ) : typeof l == "function" ? l(e) : !1,
133
+ [m, h, l]
134
+ ), o = R(
135
+ (e) => {
136
+ N(e);
137
+ },
138
+ [N]
139
+ ), U = (e) => {
140
+ const t = e.target.value;
141
+ if (D(t), t.length === 0) {
142
+ g(!1), o(void 0);
143
+ return;
144
+ }
145
+ const d = xe(t, f, /* @__PURE__ */ new Date(), { locale: u });
146
+ De(d) && !Q(d) ? (g(!1), o(d), P(d)) : t.length === f.length && g(!0);
147
+ }, X = (e) => {
148
+ e.key === "Enter" && i && (e.preventDefault(), s(!1)), e.key === "Escape" && i && (e.preventDefault(), s(!1)), e.key === "ArrowDown" && !i && (e.preventDefault(), s(!0));
149
+ }, Y = (e) => {
150
+ var t;
151
+ e && (o(e), s(!1), (t = S.current) == null || t.focus());
152
+ }, Z = (e) => {
153
+ var d;
154
+ const t = e.date();
155
+ o(t), P(t), s(!1), (d = S.current) == null || d.focus();
156
+ }, $ = (e) => n ? we(e.date(), n) : !1, ee = w("inputs.datePicker.gridLabel", "Calendar"), te = ne(
157
+ () => ({
158
+ getValue: () => n,
159
+ setValue: (e) => o(e),
160
+ clear: () => o(void 0),
161
+ isOpen: () => i,
162
+ open: () => s(!0),
163
+ close: () => s(!1)
164
+ }),
165
+ [n, o, i]
166
+ ), A = K(null);
167
+ return se(L, () => A.current, []), ce(Ie, te, C), /* @__PURE__ */ r(k.Root, { open: i, onOpenChange: s, children: /* @__PURE__ */ v(
168
+ "div",
169
+ {
170
+ ref: A,
171
+ className: B,
172
+ "data-component": "date-picker",
173
+ "data-component-id": C,
174
+ children: [
175
+ /* @__PURE__ */ v("div", { className: "ds:relative", children: [
176
+ /* @__PURE__ */ r(k.Trigger, { asChild: !0, disabled: O, children: /* @__PURE__ */ r(
177
+ "input",
178
+ {
179
+ ref: S,
180
+ id: C,
181
+ type: "text",
182
+ role: "combobox",
183
+ value: J,
184
+ placeholder: H,
185
+ disabled: O,
186
+ "aria-describedby": p.describedBy || void 0,
187
+ "aria-invalid": p.invalid || V || void 0,
188
+ "aria-required": p.required || void 0,
189
+ "aria-haspopup": "dialog",
190
+ "aria-expanded": i,
191
+ onChange: U,
192
+ onKeyDown: X,
193
+ onClick: () => !i && s(!0),
194
+ className: he({
195
+ size: x,
196
+ tone: V ? "error" : _
197
+ })
198
+ }
199
+ ) }),
200
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", className: ge({ size: x }), children: /* @__PURE__ */ r(Pe, {}) })
201
+ ] }),
202
+ /* @__PURE__ */ r(k.Portal, { children: /* @__PURE__ */ r(
203
+ k.Content,
204
+ {
205
+ sideOffset: 4,
206
+ align: "start",
207
+ className: Ce(),
208
+ onOpenAutoFocus: (e) => {
209
+ e.preventDefault();
210
+ },
211
+ children: /* @__PURE__ */ v("div", { className: "ds:flex ds:gap-[var(--spacing-md)]", children: [
212
+ b && b.length > 0 ? /* @__PURE__ */ r("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:min-w-[8rem] ds:border-e ds:border-border ds:pe-[var(--spacing-md)]", children: b.map((e) => {
213
+ const t = $(e);
214
+ return /* @__PURE__ */ v(
215
+ "button",
216
+ {
217
+ type: "button",
218
+ "aria-pressed": t,
219
+ onClick: () => Z(e),
220
+ className: ve({ active: t }),
221
+ children: [
222
+ /* @__PURE__ */ r("span", { className: "ds:min-w-0 ds:truncate", children: e.label }),
223
+ t ? /* @__PURE__ */ r(
224
+ Se,
225
+ {
226
+ "aria-hidden": "true",
227
+ className: "ds:size-4 ds:shrink-0 ds:text-primary"
228
+ }
229
+ ) : null
230
+ ]
231
+ },
232
+ e.label
233
+ );
234
+ }) }) : null,
235
+ /* @__PURE__ */ r("div", { role: "region", "aria-label": ee, children: /* @__PURE__ */ r(
236
+ ye,
237
+ {
238
+ mode: "single",
239
+ selected: n,
240
+ onSelect: Y,
241
+ month: z,
242
+ onMonthChange: P,
243
+ disabled: G,
244
+ weekStartsOn: M,
245
+ locale: u,
246
+ showOutsideDays: !0,
247
+ fixedWeeks: !0,
248
+ classNames: be,
249
+ components: { Chevron: ke }
250
+ }
251
+ ) })
252
+ ] })
253
+ }
254
+ ) })
255
+ ]
256
+ }
257
+ ) });
258
+ }
259
+ );
260
+ Oe.displayName = "DatePicker";
261
+ export {
262
+ Oe as D,
263
+ Ie as d
264
+ };
265
+ //# sourceMappingURL=date-picker-BP_W6VtE.js.map