@alfadocs/ui-kit-debug 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{actions-cell-renderer-ALEAGO3j.js → actions-cell-renderer-B2pw6iH8.js} +2 -2
- package/dist/_chunks/{actions-cell-renderer-ALEAGO3j.js.map → actions-cell-renderer-B2pw6iH8.js.map} +1 -1
- package/dist/_chunks/{anamnesis-summary-rows-F-cCmFAn.js → anamnesis-summary-rows-d44s_whc.js} +2 -2
- package/dist/_chunks/{anamnesis-summary-rows-F-cCmFAn.js.map → anamnesis-summary-rows-d44s_whc.js.map} +1 -1
- package/dist/_chunks/{antenatal-schedule-timeline-BjlF2rTz.js → antenatal-schedule-timeline-B1k8QkA6.js} +3 -3
- package/dist/_chunks/{antenatal-schedule-timeline-BjlF2rTz.js.map → antenatal-schedule-timeline-B1k8QkA6.js.map} +1 -1
- package/dist/_chunks/{appointment-card-BhcPJpXh.js → appointment-card-Dzr3GeVz.js} +73 -90
- package/dist/_chunks/appointment-card-Dzr3GeVz.js.map +1 -0
- package/dist/_chunks/{appointment-timeline-CMPvzlGZ.js → appointment-timeline-0mwtpErq.js} +3 -3
- package/dist/_chunks/{appointment-timeline-CMPvzlGZ.js.map → appointment-timeline-0mwtpErq.js.map} +1 -1
- package/dist/_chunks/{appointment-tray-3c_FLxXJ.js → appointment-tray-4FUu_5NX.js} +2 -2
- package/dist/_chunks/{appointment-tray-3c_FLxXJ.js.map → appointment-tray-4FUu_5NX.js.map} +1 -1
- package/dist/_chunks/armchair-BaLDW6Hz.js +23 -0
- package/dist/_chunks/armchair-BaLDW6Hz.js.map +1 -0
- package/dist/_chunks/{booking-CQMJUFG-.js → booking-DHkKcUIl.js} +4 -4
- package/dist/_chunks/{booking-CQMJUFG-.js.map → booking-DHkKcUIl.js.map} +1 -1
- package/dist/_chunks/{calendar-4dXTvsCz.js → calendar-B4Gnyu1C.js} +553 -437
- package/dist/_chunks/calendar-B4Gnyu1C.js.map +1 -0
- package/dist/_chunks/calendar-event-card-Bjdbik8G.js +425 -0
- package/dist/_chunks/calendar-event-card-Bjdbik8G.js.map +1 -0
- package/dist/_chunks/{care-plan-card-DQjVRDxO.js → care-plan-card-aDN4oem9.js} +3 -3
- package/dist/_chunks/{care-plan-card-DQjVRDxO.js.map → care-plan-card-aDN4oem9.js.map} +1 -1
- package/dist/_chunks/{care-plan-entry-card-CMpoeNkb.js → care-plan-entry-card-BEhANdBE.js} +2 -2
- package/dist/_chunks/{care-plan-entry-card-CMpoeNkb.js.map → care-plan-entry-card-BEhANdBE.js.map} +1 -1
- package/dist/_chunks/{care-plan-header-CxYoq23f.js → care-plan-header-CkpPyQqG.js} +2 -2
- package/dist/_chunks/{care-plan-header-CxYoq23f.js.map → care-plan-header-CkpPyQqG.js.map} +1 -1
- package/dist/_chunks/{color-picker-D-tUwxxT.js → color-picker-oZ6zYks8.js} +164 -151
- package/dist/_chunks/color-picker-oZ6zYks8.js.map +1 -0
- package/dist/_chunks/control-room-rail-Cj2iX9h_.js +337 -0
- package/dist/_chunks/control-room-rail-Cj2iX9h_.js.map +1 -0
- package/dist/_chunks/{cycle-calculator-DzgO1vzP.js → cycle-calculator-DmtYGhqq.js} +3 -3
- package/dist/_chunks/{cycle-calculator-DzgO1vzP.js.map → cycle-calculator-DmtYGhqq.js.map} +1 -1
- package/dist/_chunks/{date-picker-Bp64zk2p.js → date-picker-CepI_oI2.js} +77 -74
- package/dist/_chunks/date-picker-CepI_oI2.js.map +1 -0
- package/dist/_chunks/{date-picker-variants-pKAJfnWr.js → date-picker-variants-DfuooXEK.js} +7 -2
- package/dist/_chunks/{date-picker-variants-pKAJfnWr.js.map → date-picker-variants-DfuooXEK.js.map} +1 -1
- package/dist/_chunks/{date-range-picker-CDrZ8Zh0.js → date-range-picker-BD8P_rJq.js} +46 -45
- package/dist/_chunks/{date-range-picker-CDrZ8Zh0.js.map → date-range-picker-BD8P_rJq.js.map} +1 -1
- package/dist/_chunks/{date-time-picker-DVETwpzc.js → date-time-picker-3I2vVKGV.js} +2 -2
- package/dist/_chunks/{date-time-picker-DVETwpzc.js.map → date-time-picker-3I2vVKGV.js.map} +1 -1
- package/dist/_chunks/{due-date-calculator-wK8Tajzz.js → due-date-calculator-BF_Ikofx.js} +4 -4
- package/dist/_chunks/{due-date-calculator-wK8Tajzz.js.map → due-date-calculator-BF_Ikofx.js.map} +1 -1
- package/dist/_chunks/{entity-card-9_62gY7l.js → entity-card-DmrgYSEX.js} +4 -4
- package/dist/_chunks/{entity-card-9_62gY7l.js.map → entity-card-DmrgYSEX.js.map} +1 -1
- package/dist/_chunks/{file-manager-Cc_upjZX.js → file-manager-Crg5dKez.js} +2 -2
- package/dist/_chunks/{file-manager-Cc_upjZX.js.map → file-manager-Crg5dKez.js.map} +1 -1
- package/dist/_chunks/{gestational-age-calculator-C_uDAeP_.js → gestational-age-calculator-CxZelpu2.js} +5 -5
- package/dist/_chunks/{gestational-age-calculator-C_uDAeP_.js.map → gestational-age-calculator-CxZelpu2.js.map} +1 -1
- package/dist/_chunks/{hcg-doubling-BaXkJhT-.js → hcg-doubling-CpU7H5rQ.js} +3 -3
- package/dist/_chunks/{hcg-doubling-BaXkJhT-.js.map → hcg-doubling-CpU7H5rQ.js.map} +1 -1
- package/dist/_chunks/{link-cell-renderer-DH4JYpKU.js → link-cell-renderer-BZQtsuFz.js} +2 -2
- package/dist/_chunks/{link-cell-renderer-DH4JYpKU.js.map → link-cell-renderer-BZQtsuFz.js.map} +1 -1
- package/dist/_chunks/{notes-panel-DlnENphf.js → notes-panel-e9cJWVRg.js} +2 -2
- package/dist/_chunks/{notes-panel-DlnENphf.js.map → notes-panel-e9cJWVRg.js.map} +1 -1
- package/dist/_chunks/{operator-hero-CCDnIa1S.js → operator-hero-BnFv-Uef.js} +2 -2
- package/dist/_chunks/{operator-hero-CCDnIa1S.js.map → operator-hero-BnFv-Uef.js.map} +1 -1
- package/dist/_chunks/{parse-JqixfsU0.js → parse-MN9bGkrY.js} +2 -2
- package/dist/_chunks/{parse-JqixfsU0.js.map → parse-MN9bGkrY.js.map} +1 -1
- package/dist/_chunks/{patient-details-qnsqYBGQ.js → patient-details-xrqe13az.js} +160 -159
- package/dist/_chunks/patient-details-xrqe13az.js.map +1 -0
- package/dist/_chunks/{patient-table-DwshfVsQ.js → patient-table-ChXM2K7H.js} +11 -7
- package/dist/_chunks/patient-table-ChXM2K7H.js.map +1 -0
- package/dist/_chunks/{payment-automation-upsell-BBIG7NFL.js → payment-automation-upsell-DwQW2fRp.js} +52 -63
- package/dist/_chunks/payment-automation-upsell-DwQW2fRp.js.map +1 -0
- package/dist/_chunks/{payment-request-card-BjjBMdsp.js → payment-request-card-YVCcCZ25.js} +2 -2
- package/dist/_chunks/{payment-request-card-BjjBMdsp.js.map → payment-request-card-YVCcCZ25.js.map} +1 -1
- package/dist/_chunks/{pregnancy-dating-BVS_9YU2.js → pregnancy-dating-DtToyMyc.js} +5 -5
- package/dist/_chunks/{pregnancy-dating-BVS_9YU2.js.map → pregnancy-dating-DtToyMyc.js.map} +1 -1
- package/dist/_chunks/{radiograph-panel.agent-CiHwgISa.js → radiograph-panel.agent-C3trfWqB.js} +3 -3
- package/dist/_chunks/{radiograph-panel.agent-CiHwgISa.js.map → radiograph-panel.agent-C3trfWqB.js.map} +1 -1
- package/dist/_chunks/repeat-CvQa5rZt.js +17 -0
- package/dist/_chunks/repeat-CvQa5rZt.js.map +1 -0
- package/dist/_chunks/resource-chip-DYTG0IQQ.js +83 -0
- package/dist/_chunks/resource-chip-DYTG0IQQ.js.map +1 -0
- package/dist/_chunks/{rich-text-editor-DARnq_6N.js → rich-text-editor-BDfFtK4H.js} +2 -2
- package/dist/_chunks/{rich-text-editor-DARnq_6N.js.map → rich-text-editor-BDfFtK4H.js.map} +1 -1
- package/dist/_chunks/subDays-BLl3y3pd.js +8 -0
- package/dist/_chunks/{subDays-CAUv47M1.js.map → subDays-BLl3y3pd.js.map} +1 -1
- package/dist/agent-catalog.json +2 -2
- package/dist/components/_shared/date-picker-variants.d.ts.map +1 -1
- package/dist/components/appointment-card/index.js +2 -2
- package/dist/components/appointment-timeline/index.js +1 -1
- package/dist/components/booking/index.js +1 -1
- package/dist/components/calendar/calendar.agent.d.ts.map +1 -1
- package/dist/components/calendar/calendar.d.ts +138 -12
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.js +1 -1
- package/dist/components/calendar-event-card/calendar-event-card.d.ts +48 -11
- package/dist/components/calendar-event-card/calendar-event-card.d.ts.map +1 -1
- package/dist/components/calendar-event-card/index.js +1 -1
- package/dist/components/care-plan-card/index.js +1 -1
- package/dist/components/care-plan-entry-card/index.js +1 -1
- package/dist/components/care-plan-header/index.js +1 -1
- package/dist/components/color-picker/index.d.ts +1 -1
- package/dist/components/color-picker/index.d.ts.map +1 -1
- package/dist/components/color-picker/index.js +4 -3
- package/dist/components/color-picker/palettes.d.ts +10 -0
- package/dist/components/color-picker/palettes.d.ts.map +1 -1
- package/dist/components/control-room-rail/control-room-rail.d.ts +9 -0
- package/dist/components/control-room-rail/control-room-rail.d.ts.map +1 -1
- package/dist/components/control-room-rail/index.js +1 -1
- package/dist/components/cycle-calculator/index.js +1 -1
- package/dist/components/data-table/cell-renderers/actions-cell-renderer.d.ts.map +1 -1
- package/dist/components/data-table/index.js +2 -2
- package/dist/components/date-picker/date-picker.d.ts +11 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/date-range-picker/date-range-picker.d.ts.map +1 -1
- package/dist/components/date-range-picker/index.js +1 -1
- package/dist/components/date-time-picker/index.js +1 -1
- package/dist/components/due-date-calculator/index.js +2 -2
- package/dist/components/file-manager/index.js +1 -1
- package/dist/components/gestational-age-calculator/index.js +1 -1
- package/dist/components/hcg-doubling/index.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/operator-hero/index.js +1 -1
- package/dist/components/patient-details/index.js +1 -1
- package/dist/components/patient-details/patient-details.d.ts +8 -0
- package/dist/components/patient-details/patient-details.d.ts.map +1 -1
- package/dist/components/patient-table/columns.d.ts.map +1 -1
- package/dist/components/patient-table/index.js +1 -1
- package/dist/components/patient-table/patient-table.d.ts +5 -4
- package/dist/components/patient-table/patient-table.d.ts.map +1 -1
- package/dist/components/payment-card/index.js +1 -1
- package/dist/components/pregnancy-dating/index.js +1 -1
- package/dist/components/radiograph-panel/index.js +1 -1
- package/dist/components/resource-chip/index.d.ts +3 -0
- package/dist/components/resource-chip/index.d.ts.map +1 -0
- package/dist/components/resource-chip/index.js +5 -0
- package/dist/components/resource-chip/index.js.map +1 -0
- package/dist/components/resource-chip/resource-chip.d.ts +26 -0
- package/dist/components/resource-chip/resource-chip.d.ts.map +1 -0
- package/dist/components/rich-text-editor/index.js +1 -1
- package/dist/host-compat.css +7 -1
- package/dist/i18n/locales/ar.d.ts +4 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +4 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +4 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +4 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +4 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +4 -0
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +4 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +4 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +4 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +4 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +4 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +4 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +4 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +4 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +4 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +4 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +4 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +4 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +4 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +4 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +4 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +4 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +4 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +4 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +4 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +4 -0
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +4 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +4 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +4 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +4 -0
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +4 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +4 -0
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +4 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +4 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +4 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +4 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +961 -958
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +4 -0
- package/dist/locales/de.json +4 -0
- package/dist/locales/el.json +4 -0
- package/dist/locales/en.json +4 -0
- package/dist/locales/es.json +4 -0
- package/dist/locales/fr.json +4 -0
- package/dist/locales/hi.json +4 -0
- package/dist/locales/it.json +4 -0
- package/dist/locales/ja.json +4 -0
- package/dist/locales/nl.json +4 -0
- package/dist/locales/pl.json +4 -0
- package/dist/locales/pt.json +4 -0
- package/dist/locales/ro.json +4 -0
- package/dist/locales/ru.json +4 -0
- package/dist/locales/sq.json +4 -0
- package/dist/locales/sv.json +4 -0
- package/dist/locales/tr.json +4 -0
- package/dist/locales/zh.json +4 -0
- package/dist/patterns/anamnesis/index.js +1 -1
- package/dist/patterns/payment-automation-upsell/index.js +1 -1
- package/dist/tokens.css +41 -24
- package/package.json +5 -1
- package/dist/_chunks/appointment-card-BhcPJpXh.js.map +0 -1
- package/dist/_chunks/calendar-4dXTvsCz.js.map +0 -1
- package/dist/_chunks/calendar-event-card-C6qGtywL.js +0 -257
- package/dist/_chunks/calendar-event-card-C6qGtywL.js.map +0 -1
- package/dist/_chunks/color-picker-D-tUwxxT.js.map +0 -1
- package/dist/_chunks/control-room-rail-IH1eBjrK.js +0 -333
- package/dist/_chunks/control-room-rail-IH1eBjrK.js.map +0 -1
- package/dist/_chunks/date-picker-Bp64zk2p.js.map +0 -1
- package/dist/_chunks/patient-details-qnsqYBGQ.js.map +0 -1
- package/dist/_chunks/patient-table-DwshfVsQ.js.map +0 -1
- package/dist/_chunks/payment-automation-upsell-BBIG7NFL.js.map +0 -1
- package/dist/_chunks/subDays-CAUv47M1.js +0 -8
|
@@ -6,15 +6,15 @@ import { u as ue } from "./registry-DvAUVLHh.js";
|
|
|
6
6
|
import { R as d } from "./radio-TWf9Q-mp.js";
|
|
7
7
|
import { R as S } from "./radio-group-rXDJADzW.js";
|
|
8
8
|
import { F as k } from "./form-field-CahJzTxp.js";
|
|
9
|
-
import { D as _ } from "./date-picker-
|
|
9
|
+
import { D as _ } from "./date-picker-CepI_oI2.js";
|
|
10
10
|
import { S as me } from "./select-BW5ecXlX.js";
|
|
11
11
|
import { S as ge } from "./switch-OILsBLWo.js";
|
|
12
12
|
import { C as E } from "./card-DPmk26CL.js";
|
|
13
13
|
import { B as G } from "./badge-sTusUqZD.js";
|
|
14
14
|
import { I as pe } from "./insert-result-LCNTskNJ.js";
|
|
15
|
-
import { c as he, g as fe, e as ye, f as ve, A as be, h as Ae, i as De, G as Ce } from "./antenatal-schedule-timeline-
|
|
16
|
-
import { s as we } from "./subDays-
|
|
17
|
-
import { c as j } from "./date-picker-variants-
|
|
15
|
+
import { c as he, g as fe, e as ye, f as ve, A as be, h as Ae, i as De, G as Ce } from "./antenatal-schedule-timeline-B1k8QkA6.js";
|
|
16
|
+
import { s as we } from "./subDays-BLl3y3pd.js";
|
|
17
|
+
import { c as j } from "./date-picker-variants-DfuooXEK.js";
|
|
18
18
|
import { p as Se } from "./parseISO-fOGpHKXm.js";
|
|
19
19
|
import { f as ke } from "./format-4HNwNGrN.js";
|
|
20
20
|
const x = "Superseded by the `pregnancy-dating` adapter.", F = {
|
|
@@ -485,4 +485,4 @@ Re.displayName = "GestationalAgeCalculator";
|
|
|
485
485
|
export {
|
|
486
486
|
Re as G
|
|
487
487
|
};
|
|
488
|
-
//# sourceMappingURL=gestational-age-calculator-
|
|
488
|
+
//# sourceMappingURL=gestational-age-calculator-CxZelpu2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestational-age-calculator-C_uDAeP_.js","sources":["../../src/components/gestational-age-calculator/gestational-age-calculator.agent.ts","../../src/components/gestational-age-calculator/gestational-age-calculator.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — GestationalAgeCalculator. */\n/* */\n/* Clinical calculator: a known LMP or due date → current gestational */\n/* age, trimester and milestone dates (with an optional antenatal exam */\n/* schedule). The agent surface is the dating inputs plus the computed */\n/* gestational age / trimester / due date; the handle is the curated */\n/* `GestationalAgeCalculatorHandle` (the public `ref` stays the root */\n/* <div>, exactly as `slider.tsx` and `bmi-calculator.tsx` keep theirs). */\n/* */\n/* Dates cross the boundary as local-time `yyyy-MM-dd` strings, never */\n/* `Date` objects, so nothing shifts a day under JSON/UTC serialisation. */\n/* */\n/* DEPRECATED surface: this component is superseded by PregnancyDating, */\n/* which unifies dating + gestational age. Prefer the `pregnancy-dating` */\n/* adapter for new work — every action here is marked deprecated. */\n/* */\n/* PHI (§7): never exposes patient identity — the slots return the */\n/* operator's own structural dating inputs and the dates derived from */\n/* them. See `src/docs/26-agent-readiness.mdx`. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { GestationalAgeCalculatorHandle } from './gestational-age-calculator';\n\nconst DEPRECATED = 'Superseded by the `pregnancy-dating` adapter.';\n\n/** Shared JSON Schema fragment for a local calendar date. */\nconst isoDate = {\n type: 'string',\n pattern: '^\\\\d{4}-\\\\d{2}-\\\\d{2}$',\n} as const;\n\nexport const gestationalAgeCalculatorAgent: AgentAdapter<GestationalAgeCalculatorHandle> =\n {\n id: 'gestational-age-calculator',\n // set_value → the three `set_*` actions + the `inputs` state slot.\n capabilities: ['set_value'],\n state: {\n inputs: {\n type: \"{ method: 'lmp' | 'edd', referenceDate: string | null, asOfDate: string }\",\n descriptionKey: 'ui.agent.gestationalAgeCalculator.state.inputs',\n description:\n 'The dating inputs as entered — whether the reference date is a last period or a known due date, that date, and the evaluation date. Dates are `yyyy-MM-dd`. Read this to see which method a reference date will be interpreted under.',\n read: (handle) => handle.getInputs(),\n },\n result: {\n type: '{ gestationalAge: { weeks: number, days: number, totalDays: number } | null, trimester: string, dueDate: string } | null',\n descriptionKey: 'ui.agent.gestationalAgeCalculator.state.result',\n description:\n 'Computed gestational age in completed weeks + days as of the evaluation date, the trimester band (preconception / first / second / third / postterm), and the estimated delivery date. Null until a reference date is set.',\n read: (handle) => handle.getResult(),\n },\n },\n actions: {\n set_method: {\n // Drives the same local input state a user picks; nothing is persisted\n // to a record, and the choice is reversible in the same UI.\n safety: 'write',\n argsType: \"{ method: 'lmp' | 'edd' }\",\n argsSchema: {\n type: 'object',\n properties: {\n method: {\n enum: ['lmp', 'edd'],\n description:\n 'Whether the reference date is the last menstrual period or a known estimated delivery date.',\n },\n },\n required: ['method'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the method was applied.',\n },\n errors: ['Returns false for a method other than `lmp` or `edd`.'],\n descriptionKey: 'ui.agent.gestationalAgeCalculator.actions.setMethod',\n description:\n 'Choose how the reference date is read. The date is kept and re-interpreted under the new method, so set the method first — an EDD may be in the future, an LMP may not.',\n invoke: (handle, args: { method: 'lmp' | 'edd' }) =>\n handle.setMethod(args.method),\n },\n set_reference_date: {\n safety: 'write',\n argsType: '{ date: string | null }',\n argsSchema: {\n type: 'object',\n properties: {\n date: {\n oneOf: [\n {\n ...isoDate,\n description: 'Local calendar date, `yyyy-MM-dd`.',\n },\n { type: 'null' },\n ],\n description:\n 'The last period (not in the future) or the known due date, depending on the active method — or null to clear it.',\n },\n },\n required: ['date'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the date was applied.',\n },\n errors: [\n 'Returns false for an unparseable date, or for a future date under the `lmp` method — the on-screen DatePicker caps an LMP at today.',\n ],\n examples: [\n {\n args: { date: '2026-01-12' },\n note: 'Under the default LMP method, a last period starting 12 January.',\n },\n ],\n descriptionKey:\n 'ui.agent.gestationalAgeCalculator.actions.setReferenceDate',\n description:\n 'Set the dating anchor. This is the only required input — the result stays null without it.',\n invoke: (handle, args: { date: string | null }) =>\n handle.setReferenceDate(args.date),\n },\n set_as_of_date: {\n safety: 'write',\n argsType: '{ date: string }',\n argsSchema: {\n type: 'object',\n properties: {\n date: {\n ...isoDate,\n description:\n 'Date to evaluate gestational age and trimester against, `yyyy-MM-dd`. May be in the future to project forward.',\n },\n },\n required: ['date'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the date was applied.',\n },\n errors: ['Returns false for an unparseable date.'],\n examples: [\n {\n args: { date: '2026-09-15' },\n note: 'Project gestational age forward to an upcoming appointment.',\n },\n ],\n descriptionKey: 'ui.agent.gestationalAgeCalculator.actions.setAsOfDate',\n description:\n 'Set the date gestational age, trimester and the antenatal schedule are evaluated against. Defaults to today; the estimated delivery date itself does not depend on it.',\n invoke: (handle, args: { date: string }) =>\n handle.setAsOfDate(args.date),\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'gestational-age-calculator',\n description:\n 'Marks the GestationalAgeCalculator (current gestational age, trimester and milestones from LMP or due date).',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Also the registry key — without an `id` the instance does not register and the handle-driven actions/state are unreachable.',\n },\n },\n };\n","/* ------------------------------------------------------------------ */\n/* GestationalAgeCalculator — current gestational age, trimester and */\n/* milestone dates, from either a known LMP or a known due date. */\n/* */\n/* Reuses the shared `gestation` maths from due-date-calculator: GA day */\n/* 0 is the LMP; from an EDD we back out LMP = EDD − 280 days. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useRef, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { format, parseISO, subDays, isAfter } from 'date-fns';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { gestationalAgeCalculatorAgent } from './gestational-age-calculator.agent';\nimport { RadioGroup, Radio } from '../radio-group';\nimport { FormField } from '../form-field';\nimport { DatePicker } from '../date-picker';\nimport { Select } from '../select';\nimport { Switch } from '../switch';\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 Trimester,\n type GestationalAge,\n type Plurality,\n type Chorionicity,\n computeDueDate,\n gestationalMilestones,\n GESTATION_DAYS,\n TRIMESTER_BADGE_VARIANT,\n trimesterHighlightToken,\n} from '../_shared/obstetrics';\nimport {\n computeAntenatalSchedule,\n type AntenatalScheduleOptions,\n type GdmRisk,\n} from '../_shared/antenatal-schedule';\nimport {\n AntenatalScheduleTimeline,\n buildScheduleInsertFields,\n} from '../_shared/antenatal-schedule-timeline';\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/** Whether the entered date is the last period (`lmp`) or the due date (`edd`). */\nexport type GestationalAgeMethod = 'lmp' | 'edd';\n\nexport interface GestationalAgeResult {\n gestationalAge: GestationalAge | null;\n trimester: Trimester;\n dueDate: Date;\n}\n\n/* ------------------------------------------------------------------ */\n/* Agent boundary */\n/* */\n/* Dates cross the agent boundary as local-time `yyyy-MM-dd` strings, */\n/* never `Date` objects — a Date JSON-serialises to UTC and silently */\n/* shifts the day for anyone east or west of Greenwich. */\n/* ------------------------------------------------------------------ */\n\nconst toIsoDate = (d: Date): string => format(d, 'yyyy-MM-dd');\n\nconst fromIsoDate = (iso: string): Date | null => {\n const d = parseISO(iso);\n return Number.isNaN(d.getTime()) ? null : d;\n};\n\n/** The dating inputs as entered. */\nexport interface GestationalAgeInputsSnapshot {\n /** Whether the reference date is a last period or a due date. */\n method: GestationalAgeMethod;\n /** The reference date (`yyyy-MM-dd`), or null when unset. */\n referenceDate: string | null;\n /** The date gestational age and trimester are evaluated against. */\n asOfDate: string;\n}\n\n/** `GestationalAgeResult` projected onto the agent boundary — ISO dates. */\nexport interface GestationalAgeSnapshot {\n /** Gestational age as of the evaluation date; null before conception. */\n gestationalAge: { weeks: number; days: number; totalDays: number } | null;\n /** Trimester band as of the evaluation date. */\n trimester: Trimester;\n /** Estimated date of delivery, `yyyy-MM-dd`. */\n dueDate: string;\n}\n\n/**\n * Curated imperative handle for agent / external automation. Reads the dating\n * inputs and the computed gestational age, and drives the inputs the way a\n * user would. Never exposes patient identity — only structural dates and\n * numbers. Consumed by `gestational-age-calculator.agent.ts`; the public `ref`\n * stays the root DOM element.\n */\nexport interface GestationalAgeCalculatorHandle {\n /** The dating inputs as entered. */\n getInputs: () => GestationalAgeInputsSnapshot;\n /** Computed gestational age, trimester and due date, or null until a reference date is set. */\n getResult: () => GestationalAgeSnapshot | null;\n /** Switch between dating from a last period and dating from a known due date. */\n setMethod: (method: GestationalAgeMethod) => boolean;\n /** Set the reference date (`yyyy-MM-dd`); a last period may not be in the future. */\n setReferenceDate: (isoDate: string | null) => boolean;\n /** Set the date gestational age and trimester are evaluated against. */\n setAsOfDate: (isoDate: string) => boolean;\n}\n\nexport interface GestationalAgeCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Whether the input date is the last period (`lmp`) or the due date (`edd`). */\n defaultMethod?: GestationalAgeMethod;\n /** Pre-fill the reference date (e.g. a known LMP from the patient record). */\n defaultReferenceDate?: Date;\n /** Fires whenever a result can be computed (and `null` when it can't). */\n onResultChange?: (result: GestationalAgeResult | 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 /**\n * Append the antenatal exam schedule (the time-sensitive screening windows)\n * below the result, dated from the computed gestational start, and reveal the\n * plurality / chorionicity inputs that drive it.\n */\n showSchedule?: boolean;\n /** `showSchedule` only — initial number of babies. Defaults to `'singleton'`. */\n defaultPlurality?: Plurality;\n /** `showSchedule` only — initial chorionicity for multiples. Defaults to `'unknown'`. */\n defaultChorionicity?: Chorionicity;\n /** `showSchedule` only — initial Rh-negative state (surfaces anti-D). */\n defaultRhNegative?: boolean;\n /** `showSchedule` only — initial gestational-diabetes risk tier (surfaces OGTT). */\n defaultGdmRisk?: GdmRisk;\n /**\n * Passthrough options for the appended schedule (national `schedule`,\n * `includeOnIndication`, `birthGuideline`). `today`, `plurality`,\n * `chorionicity`, `rhNegative` and `gdmRisk` come from the component's own\n * inputs. Ignored unless `showSchedule` is set.\n */\n scheduleOptions?: Omit<\n AntenatalScheduleOptions,\n 'today' | 'plurality' | 'chorionicity' | 'rhNegative' | 'gdmRisk'\n >;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/**\n * @deprecated Superseded by `PregnancyDating`, which unifies the due-date and\n * gestational-age calculators (any anchor → both EDD and current GA) and adds a\n * manual ±days dating adjustment. This component will be removed in a future\n * release; migrate to `PregnancyDating` (`defaultMethod=\"edd\"` for the\n * date-back-from-EDD flow).\n */\nexport const GestationalAgeCalculator = forwardRef<\n HTMLDivElement,\n GestationalAgeCalculatorProps\n>(\n (\n {\n defaultMethod = 'lmp',\n defaultReferenceDate,\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n showSchedule = false,\n defaultPlurality = 'singleton',\n defaultChorionicity = 'unknown',\n defaultRhNegative = false,\n defaultGdmRisk,\n scheduleOptions,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [method, setMethod] = useState<GestationalAgeMethod>(defaultMethod);\n const [refDate, setRefDate] = useState<Date | undefined>(\n defaultReferenceDate,\n );\n // The date the result is evaluated against (\"as of\"); defaults to today but\n // can be a future appointment date to project the GA/schedule forward.\n const [asOfDate, setAsOfDate] = useState<Date>(() => new Date());\n // Real today — caps the dating-anchor input (an LMP can't be in the future).\n const today = useMemo(() => new Date(), []);\n const [plurality, setPlurality] = useState<Plurality>(defaultPlurality);\n const [chorionicity, setChorionicity] =\n useState<Chorionicity>(defaultChorionicity);\n const [rhNegative, setRhNegative] = useState<boolean>(defaultRhNegative);\n const [gdmRisk, setGdmRisk] = useState<GdmRisk | 'none'>(\n defaultGdmRisk ?? 'none',\n );\n\n const data = useMemo(() => {\n if (!refDate) return null;\n // Normalise to an LMP, then reuse the shared gestation maths.\n const lmp = method === 'lmp' ? refDate : subDays(refDate, GESTATION_DAYS);\n const r = computeDueDate({ method: 'lmp', date: lmp }, asOfDate);\n return {\n result: {\n gestationalAge: r.gestationalAge,\n trimester: r.trimester,\n dueDate: r.dueDate,\n } satisfies GestationalAgeResult,\n milestones: gestationalMilestones(r.gestationalStart),\n gestationalStart: r.gestationalStart,\n };\n }, [method, refDate, asOfDate]);\n\n const schedule = useMemo(() => {\n if (!showSchedule || !data) return null;\n return computeAntenatalSchedule(data.gestationalStart, {\n ...scheduleOptions,\n today: asOfDate,\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk: gdmRisk === 'none' ? undefined : gdmRisk,\n });\n }, [\n showSchedule,\n data,\n asOfDate,\n scheduleOptions,\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk,\n ]);\n\n const chorionicityOptions = useMemo(\n () =>\n (\n [\n 'unknown',\n 'dichorionic-diamniotic',\n 'monochorionic-diamniotic',\n 'monochorionic-monoamniotic',\n ] as const\n ).map((c) => ({\n value: c,\n label: t(`antenatalSchedule.chorionicity.${c}`),\n })),\n [t],\n );\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(data?.result ?? null);\n }, [data, onResultChange]);\n\n /* ── Agent handle ────────────────────────────────────────────────── */\n const liveRef = useRef({ method, refDate, asOfDate, data });\n liveRef.current = { method, refDate, asOfDate, data };\n\n const agentHandle = useMemo<GestationalAgeCalculatorHandle>(\n () => ({\n getInputs: () => {\n const live = liveRef.current;\n return {\n method: live.method,\n referenceDate: live.refDate ? toIsoDate(live.refDate) : null,\n asOfDate: toIsoDate(live.asOfDate),\n };\n },\n getResult: () => {\n const r = liveRef.current.data?.result;\n if (!r) return null;\n return {\n gestationalAge: r.gestationalAge ? { ...r.gestationalAge } : null,\n trimester: r.trimester,\n dueDate: toIsoDate(r.dueDate),\n };\n },\n setMethod: (next) => {\n if (next !== 'lmp' && next !== 'edd') return false;\n setMethod(next);\n return true;\n },\n setReferenceDate: (isoDate) => {\n if (isoDate === null) {\n setRefDate(undefined);\n return true;\n }\n const parsed = fromIsoDate(isoDate);\n if (!parsed) return false;\n // The DatePicker caps an LMP at today; a known EDD is in the future.\n if (liveRef.current.method === 'lmp' && isAfter(parsed, new Date())) {\n return false;\n }\n setRefDate(parsed);\n return true;\n },\n setAsOfDate: (isoDate) => {\n const parsed = fromIsoDate(isoDate);\n if (!parsed) return false;\n setAsOfDate(parsed);\n return true;\n },\n }),\n [],\n );\n useAgentRegistration(gestationalAgeCalculatorAgent, agentHandle, id);\n\n const gaText = (ga: GestationalAge | null): string =>\n ga\n ? t('gestationalAgeCalculator.gestation', {\n weeks: ga.weeks,\n days: ga.days,\n })\n : '—';\n\n return (\n <div\n ref={ref}\n data-component=\"gestational-age-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('gestationalAgeCalculator.method.label')}\n variant=\"horizontal\"\n value={method}\n onValueChange={(next) => setMethod(next as GestationalAgeMethod)}\n >\n <Radio label={t('gestationalAgeCalculator.method.lmp')} value=\"lmp\" />\n <Radio label={t('gestationalAgeCalculator.method.edd')} value=\"edd\" />\n </RadioGroup>\n\n <FormField\n label={t(\n method === 'lmp'\n ? 'gestationalAgeCalculator.lmpDate'\n : 'gestationalAgeCalculator.eddDate',\n )}\n >\n <DatePicker\n value={refDate}\n onChange={setRefDate}\n maxDate={method === 'lmp' ? today : undefined}\n />\n </FormField>\n\n <FormField\n label={t('gestationalAgeCalculator.asOfDate')}\n description={t('gestationalAgeCalculator.asOfDateHint')}\n >\n <DatePicker value={asOfDate} onChange={(d) => d && setAsOfDate(d)} />\n </FormField>\n\n {showSchedule ? (\n <>\n <RadioGroup\n label={t('antenatalSchedule.plurality.label')}\n variant=\"horizontal\"\n value={plurality}\n onValueChange={(next) => setPlurality(next as Plurality)}\n >\n <Radio\n label={t('antenatalSchedule.plurality.singleton')}\n value=\"singleton\"\n />\n <Radio\n label={t('antenatalSchedule.plurality.twin')}\n value=\"twin\"\n />\n <Radio\n label={t('antenatalSchedule.plurality.triplet')}\n value=\"triplet\"\n />\n </RadioGroup>\n\n {plurality !== 'singleton' ? (\n <FormField label={t('antenatalSchedule.chorionicity.label')}>\n <Select\n options={chorionicityOptions}\n value={chorionicity}\n onValueChange={(next) =>\n setChorionicity(next as Chorionicity)\n }\n />\n </FormField>\n ) : null}\n\n <Switch\n label={t('antenatalSchedule.rhNegative')}\n checked={rhNegative}\n onCheckedChange={setRhNegative}\n />\n\n <RadioGroup\n label={t('antenatalSchedule.gdmRisk.label')}\n variant=\"horizontal\"\n value={gdmRisk}\n onValueChange={(next) => setGdmRisk(next as GdmRisk | 'none')}\n >\n <Radio label={t('antenatalSchedule.gdmRisk.none')} value=\"none\" />\n <Radio\n label={t('antenatalSchedule.gdmRisk.medium')}\n value=\"medium\"\n />\n <Radio label={t('antenatalSchedule.gdmRisk.high')} value=\"high\" />\n </RadioGroup>\n </>\n ) : null}\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {data\n ? `${t('gestationalAgeCalculator.gestationLabel')}: ${gaText(\n data.result.gestationalAge,\n )}. ${t('gestationalAgeCalculator.trimesterLabel')}: ${t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n )}.`\n : ''}\n </p>\n\n {data ? (\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-2\">\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.trimesterLabel')}\n </dt>\n <dd>\n <Badge\n variant={TRIMESTER_BADGE_VARIANT[data.result.trimester]}\n size=\"lg\"\n >\n {t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n )}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.gestationLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {gaText(data.result.gestationalAge)}\n </dd>\n </div>\n </dl>\n\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.milestonesLabel')}\n </span>\n <ul className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n {data.milestones.map((m) => {\n const reached = isAfter(asOfDate, m.date);\n return (\n <li\n key={m.key}\n className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-md)]\"\n >\n <span className=\"type-body ds:text-foreground\">\n {t(`gestationalAgeCalculator.milestone.${m.key}`)}\n </span>\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span className=\"type-body ds:text-muted-foreground\">\n {dateFormatter.format(m.date)}\n </span>\n {reached ? (\n <Badge variant=\"success\">\n {t('gestationalAgeCalculator.reached')}\n </Badge>\n ) : null}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.empty')}\n </p>\n )}\n\n {schedule ? <AntenatalScheduleTimeline events={schedule} /> : null}\n\n {/* One result-action group for the whole result — sits after both the\n gestational-age card and the schedule, and its payload carries the\n schedule rows when shown (no per-card buttons). */}\n {data && (insertVariant === 'copy' || onInsert) ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.gestationalAge'),\n icon: 'baby',\n highlight: t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n ),\n // Chip shares the trimester's semantic token so the inserted PNG\n // chip matches the on-screen trimester badge — with the\n // contrast-safe orange override for the `--warning` third trimester.\n highlightToken: trimesterHighlightToken(data.result.trimester),\n brand: insertBrand,\n fields: [\n {\n // Gestational age is an elapsed duration → clock glyph.\n icon: 'clock',\n label: t('gestationalAgeCalculator.gestationLabel'),\n value: gaText(data.result.gestationalAge),\n },\n {\n // Trimester is a clinical-stage classification → tag.\n icon: 'tag',\n label: t('gestationalAgeCalculator.trimesterLabel'),\n value: t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n ),\n },\n // When the schedule is shown, the single Insert button carries\n // the exam windows too (no second button).\n ...(schedule\n ? buildScheduleInsertFields(schedule, t, (d) =>\n dateFormatter.format(d),\n )\n : []),\n ],\n }}\n />\n ) : null}\n </div>\n );\n },\n);\n\nGestationalAgeCalculator.displayName = 'GestationalAgeCalculator';\n"],"names":["DEPRECATED","isoDate","gestationalAgeCalculatorAgent","handle","args","rootVariants","cva","toIsoDate","d","format","fromIsoDate","iso","parseISO","GestationalAgeCalculator","forwardRef","defaultMethod","defaultReferenceDate","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","showSchedule","defaultPlurality","defaultChorionicity","defaultRhNegative","defaultGdmRisk","scheduleOptions","id","width","className","ref","i18n","useTranslation","method","setMethod","useState","refDate","setRefDate","asOfDate","setAsOfDate","today","useMemo","plurality","setPlurality","chorionicity","setChorionicity","rhNegative","setRhNegative","gdmRisk","setGdmRisk","data","lmp","subDays","GESTATION_DAYS","r","computeDueDate","gestationalMilestones","schedule","computeAntenatalSchedule","chorionicityOptions","c","dateFormatter","useEffect","liveRef","useRef","agentHandle","live","_a","next","parsed","isAfter","useAgentRegistration","gaText","ga","jsxs","RadioGroup","jsx","Radio","FormField","DatePicker","Fragment","Select","Switch","Card","Badge","TRIMESTER_BADGE_VARIANT","m","reached","AntenatalScheduleTimeline","InsertButton","trimesterHighlightToken","buildScheduleInsertFields"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,IAAa,iDAGbC,IAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AACX,GAEaC,KACX;AAAA,EACE,IAAI;AAAA;AAAA,EAEJ,cAAc,CAAC,WAAW;AAAA,EAC1B,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACC,MAAWA,EAAO,UAAA;AAAA,IAAU;AAAA,IAErC,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aACE;AAAA,MACF,MAAM,CAACA,MAAWA,EAAO,UAAA;AAAA,IAAU;AAAA,EACrC;AAAA,EAEF,SAAS;AAAA,IACP,YAAY;AAAA;AAAA;AAAA,MAGV,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;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,OAAOoD,EAAOtB,EAAK,OAAO,cAAc;AAAA,kBAAA;AAAA,kBAE1C;AAAA;AAAA,oBAEE,MAAM;AAAA,oBACN,OAAO,EAAE,yCAAyC;AAAA,oBAClD,OAAO;AAAA,sBACL,sCAAsCA,EAAK,OAAO,SAAS;AAAA,oBAAA;AAAA,kBAC7D;AAAA;AAAA;AAAA,kBAIF,GAAIO,IACAkC;AAAA,oBAA0BlC;AAAA,oBAAU;AAAA,oBAAG,CAACnD,MACtCuD,EAAc,OAAOvD,CAAC;AAAA,kBAAA,IAExB,CAAA;AAAA,gBAAC;AAAA,cACP;AAAA,YACF;AAAA,UAAA,IAEA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEAK,GAAyB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"gestational-age-calculator-CxZelpu2.js","sources":["../../src/components/gestational-age-calculator/gestational-age-calculator.agent.ts","../../src/components/gestational-age-calculator/gestational-age-calculator.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — GestationalAgeCalculator. */\n/* */\n/* Clinical calculator: a known LMP or due date → current gestational */\n/* age, trimester and milestone dates (with an optional antenatal exam */\n/* schedule). The agent surface is the dating inputs plus the computed */\n/* gestational age / trimester / due date; the handle is the curated */\n/* `GestationalAgeCalculatorHandle` (the public `ref` stays the root */\n/* <div>, exactly as `slider.tsx` and `bmi-calculator.tsx` keep theirs). */\n/* */\n/* Dates cross the boundary as local-time `yyyy-MM-dd` strings, never */\n/* `Date` objects, so nothing shifts a day under JSON/UTC serialisation. */\n/* */\n/* DEPRECATED surface: this component is superseded by PregnancyDating, */\n/* which unifies dating + gestational age. Prefer the `pregnancy-dating` */\n/* adapter for new work — every action here is marked deprecated. */\n/* */\n/* PHI (§7): never exposes patient identity — the slots return the */\n/* operator's own structural dating inputs and the dates derived from */\n/* them. See `src/docs/26-agent-readiness.mdx`. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { GestationalAgeCalculatorHandle } from './gestational-age-calculator';\n\nconst DEPRECATED = 'Superseded by the `pregnancy-dating` adapter.';\n\n/** Shared JSON Schema fragment for a local calendar date. */\nconst isoDate = {\n type: 'string',\n pattern: '^\\\\d{4}-\\\\d{2}-\\\\d{2}$',\n} as const;\n\nexport const gestationalAgeCalculatorAgent: AgentAdapter<GestationalAgeCalculatorHandle> =\n {\n id: 'gestational-age-calculator',\n // set_value → the three `set_*` actions + the `inputs` state slot.\n capabilities: ['set_value'],\n state: {\n inputs: {\n type: \"{ method: 'lmp' | 'edd', referenceDate: string | null, asOfDate: string }\",\n descriptionKey: 'ui.agent.gestationalAgeCalculator.state.inputs',\n description:\n 'The dating inputs as entered — whether the reference date is a last period or a known due date, that date, and the evaluation date. Dates are `yyyy-MM-dd`. Read this to see which method a reference date will be interpreted under.',\n read: (handle) => handle.getInputs(),\n },\n result: {\n type: '{ gestationalAge: { weeks: number, days: number, totalDays: number } | null, trimester: string, dueDate: string } | null',\n descriptionKey: 'ui.agent.gestationalAgeCalculator.state.result',\n description:\n 'Computed gestational age in completed weeks + days as of the evaluation date, the trimester band (preconception / first / second / third / postterm), and the estimated delivery date. Null until a reference date is set.',\n read: (handle) => handle.getResult(),\n },\n },\n actions: {\n set_method: {\n // Drives the same local input state a user picks; nothing is persisted\n // to a record, and the choice is reversible in the same UI.\n safety: 'write',\n argsType: \"{ method: 'lmp' | 'edd' }\",\n argsSchema: {\n type: 'object',\n properties: {\n method: {\n enum: ['lmp', 'edd'],\n description:\n 'Whether the reference date is the last menstrual period or a known estimated delivery date.',\n },\n },\n required: ['method'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the method was applied.',\n },\n errors: ['Returns false for a method other than `lmp` or `edd`.'],\n descriptionKey: 'ui.agent.gestationalAgeCalculator.actions.setMethod',\n description:\n 'Choose how the reference date is read. The date is kept and re-interpreted under the new method, so set the method first — an EDD may be in the future, an LMP may not.',\n invoke: (handle, args: { method: 'lmp' | 'edd' }) =>\n handle.setMethod(args.method),\n },\n set_reference_date: {\n safety: 'write',\n argsType: '{ date: string | null }',\n argsSchema: {\n type: 'object',\n properties: {\n date: {\n oneOf: [\n {\n ...isoDate,\n description: 'Local calendar date, `yyyy-MM-dd`.',\n },\n { type: 'null' },\n ],\n description:\n 'The last period (not in the future) or the known due date, depending on the active method — or null to clear it.',\n },\n },\n required: ['date'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the date was applied.',\n },\n errors: [\n 'Returns false for an unparseable date, or for a future date under the `lmp` method — the on-screen DatePicker caps an LMP at today.',\n ],\n examples: [\n {\n args: { date: '2026-01-12' },\n note: 'Under the default LMP method, a last period starting 12 January.',\n },\n ],\n descriptionKey:\n 'ui.agent.gestationalAgeCalculator.actions.setReferenceDate',\n description:\n 'Set the dating anchor. This is the only required input — the result stays null without it.',\n invoke: (handle, args: { date: string | null }) =>\n handle.setReferenceDate(args.date),\n },\n set_as_of_date: {\n safety: 'write',\n argsType: '{ date: string }',\n argsSchema: {\n type: 'object',\n properties: {\n date: {\n ...isoDate,\n description:\n 'Date to evaluate gestational age and trimester against, `yyyy-MM-dd`. May be in the future to project forward.',\n },\n },\n required: ['date'],\n additionalProperties: false,\n },\n idempotent: true,\n deprecated: DEPRECATED,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the date was applied.',\n },\n errors: ['Returns false for an unparseable date.'],\n examples: [\n {\n args: { date: '2026-09-15' },\n note: 'Project gestational age forward to an upcoming appointment.',\n },\n ],\n descriptionKey: 'ui.agent.gestationalAgeCalculator.actions.setAsOfDate',\n description:\n 'Set the date gestational age, trimester and the antenatal schedule are evaluated against. Defaults to today; the estimated delivery date itself does not depend on it.',\n invoke: (handle, args: { date: string }) =>\n handle.setAsOfDate(args.date),\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'gestational-age-calculator',\n description:\n 'Marks the GestationalAgeCalculator (current gestational age, trimester and milestones from LMP or due date).',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Also the registry key — without an `id` the instance does not register and the handle-driven actions/state are unreachable.',\n },\n },\n };\n","/* ------------------------------------------------------------------ */\n/* GestationalAgeCalculator — current gestational age, trimester and */\n/* milestone dates, from either a known LMP or a known due date. */\n/* */\n/* Reuses the shared `gestation` maths from due-date-calculator: GA day */\n/* 0 is the LMP; from an EDD we back out LMP = EDD − 280 days. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useRef, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { format, parseISO, subDays, isAfter } from 'date-fns';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { gestationalAgeCalculatorAgent } from './gestational-age-calculator.agent';\nimport { RadioGroup, Radio } from '../radio-group';\nimport { FormField } from '../form-field';\nimport { DatePicker } from '../date-picker';\nimport { Select } from '../select';\nimport { Switch } from '../switch';\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 Trimester,\n type GestationalAge,\n type Plurality,\n type Chorionicity,\n computeDueDate,\n gestationalMilestones,\n GESTATION_DAYS,\n TRIMESTER_BADGE_VARIANT,\n trimesterHighlightToken,\n} from '../_shared/obstetrics';\nimport {\n computeAntenatalSchedule,\n type AntenatalScheduleOptions,\n type GdmRisk,\n} from '../_shared/antenatal-schedule';\nimport {\n AntenatalScheduleTimeline,\n buildScheduleInsertFields,\n} from '../_shared/antenatal-schedule-timeline';\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/** Whether the entered date is the last period (`lmp`) or the due date (`edd`). */\nexport type GestationalAgeMethod = 'lmp' | 'edd';\n\nexport interface GestationalAgeResult {\n gestationalAge: GestationalAge | null;\n trimester: Trimester;\n dueDate: Date;\n}\n\n/* ------------------------------------------------------------------ */\n/* Agent boundary */\n/* */\n/* Dates cross the agent boundary as local-time `yyyy-MM-dd` strings, */\n/* never `Date` objects — a Date JSON-serialises to UTC and silently */\n/* shifts the day for anyone east or west of Greenwich. */\n/* ------------------------------------------------------------------ */\n\nconst toIsoDate = (d: Date): string => format(d, 'yyyy-MM-dd');\n\nconst fromIsoDate = (iso: string): Date | null => {\n const d = parseISO(iso);\n return Number.isNaN(d.getTime()) ? null : d;\n};\n\n/** The dating inputs as entered. */\nexport interface GestationalAgeInputsSnapshot {\n /** Whether the reference date is a last period or a due date. */\n method: GestationalAgeMethod;\n /** The reference date (`yyyy-MM-dd`), or null when unset. */\n referenceDate: string | null;\n /** The date gestational age and trimester are evaluated against. */\n asOfDate: string;\n}\n\n/** `GestationalAgeResult` projected onto the agent boundary — ISO dates. */\nexport interface GestationalAgeSnapshot {\n /** Gestational age as of the evaluation date; null before conception. */\n gestationalAge: { weeks: number; days: number; totalDays: number } | null;\n /** Trimester band as of the evaluation date. */\n trimester: Trimester;\n /** Estimated date of delivery, `yyyy-MM-dd`. */\n dueDate: string;\n}\n\n/**\n * Curated imperative handle for agent / external automation. Reads the dating\n * inputs and the computed gestational age, and drives the inputs the way a\n * user would. Never exposes patient identity — only structural dates and\n * numbers. Consumed by `gestational-age-calculator.agent.ts`; the public `ref`\n * stays the root DOM element.\n */\nexport interface GestationalAgeCalculatorHandle {\n /** The dating inputs as entered. */\n getInputs: () => GestationalAgeInputsSnapshot;\n /** Computed gestational age, trimester and due date, or null until a reference date is set. */\n getResult: () => GestationalAgeSnapshot | null;\n /** Switch between dating from a last period and dating from a known due date. */\n setMethod: (method: GestationalAgeMethod) => boolean;\n /** Set the reference date (`yyyy-MM-dd`); a last period may not be in the future. */\n setReferenceDate: (isoDate: string | null) => boolean;\n /** Set the date gestational age and trimester are evaluated against. */\n setAsOfDate: (isoDate: string) => boolean;\n}\n\nexport interface GestationalAgeCalculatorProps extends VariantProps<\n typeof rootVariants\n> {\n /** Whether the input date is the last period (`lmp`) or the due date (`edd`). */\n defaultMethod?: GestationalAgeMethod;\n /** Pre-fill the reference date (e.g. a known LMP from the patient record). */\n defaultReferenceDate?: Date;\n /** Fires whenever a result can be computed (and `null` when it can't). */\n onResultChange?: (result: GestationalAgeResult | 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 /**\n * Append the antenatal exam schedule (the time-sensitive screening windows)\n * below the result, dated from the computed gestational start, and reveal the\n * plurality / chorionicity inputs that drive it.\n */\n showSchedule?: boolean;\n /** `showSchedule` only — initial number of babies. Defaults to `'singleton'`. */\n defaultPlurality?: Plurality;\n /** `showSchedule` only — initial chorionicity for multiples. Defaults to `'unknown'`. */\n defaultChorionicity?: Chorionicity;\n /** `showSchedule` only — initial Rh-negative state (surfaces anti-D). */\n defaultRhNegative?: boolean;\n /** `showSchedule` only — initial gestational-diabetes risk tier (surfaces OGTT). */\n defaultGdmRisk?: GdmRisk;\n /**\n * Passthrough options for the appended schedule (national `schedule`,\n * `includeOnIndication`, `birthGuideline`). `today`, `plurality`,\n * `chorionicity`, `rhNegative` and `gdmRisk` come from the component's own\n * inputs. Ignored unless `showSchedule` is set.\n */\n scheduleOptions?: Omit<\n AntenatalScheduleOptions,\n 'today' | 'plurality' | 'chorionicity' | 'rhNegative' | 'gdmRisk'\n >;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/**\n * @deprecated Superseded by `PregnancyDating`, which unifies the due-date and\n * gestational-age calculators (any anchor → both EDD and current GA) and adds a\n * manual ±days dating adjustment. This component will be removed in a future\n * release; migrate to `PregnancyDating` (`defaultMethod=\"edd\"` for the\n * date-back-from-EDD flow).\n */\nexport const GestationalAgeCalculator = forwardRef<\n HTMLDivElement,\n GestationalAgeCalculatorProps\n>(\n (\n {\n defaultMethod = 'lmp',\n defaultReferenceDate,\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n showSchedule = false,\n defaultPlurality = 'singleton',\n defaultChorionicity = 'unknown',\n defaultRhNegative = false,\n defaultGdmRisk,\n scheduleOptions,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [method, setMethod] = useState<GestationalAgeMethod>(defaultMethod);\n const [refDate, setRefDate] = useState<Date | undefined>(\n defaultReferenceDate,\n );\n // The date the result is evaluated against (\"as of\"); defaults to today but\n // can be a future appointment date to project the GA/schedule forward.\n const [asOfDate, setAsOfDate] = useState<Date>(() => new Date());\n // Real today — caps the dating-anchor input (an LMP can't be in the future).\n const today = useMemo(() => new Date(), []);\n const [plurality, setPlurality] = useState<Plurality>(defaultPlurality);\n const [chorionicity, setChorionicity] =\n useState<Chorionicity>(defaultChorionicity);\n const [rhNegative, setRhNegative] = useState<boolean>(defaultRhNegative);\n const [gdmRisk, setGdmRisk] = useState<GdmRisk | 'none'>(\n defaultGdmRisk ?? 'none',\n );\n\n const data = useMemo(() => {\n if (!refDate) return null;\n // Normalise to an LMP, then reuse the shared gestation maths.\n const lmp = method === 'lmp' ? refDate : subDays(refDate, GESTATION_DAYS);\n const r = computeDueDate({ method: 'lmp', date: lmp }, asOfDate);\n return {\n result: {\n gestationalAge: r.gestationalAge,\n trimester: r.trimester,\n dueDate: r.dueDate,\n } satisfies GestationalAgeResult,\n milestones: gestationalMilestones(r.gestationalStart),\n gestationalStart: r.gestationalStart,\n };\n }, [method, refDate, asOfDate]);\n\n const schedule = useMemo(() => {\n if (!showSchedule || !data) return null;\n return computeAntenatalSchedule(data.gestationalStart, {\n ...scheduleOptions,\n today: asOfDate,\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk: gdmRisk === 'none' ? undefined : gdmRisk,\n });\n }, [\n showSchedule,\n data,\n asOfDate,\n scheduleOptions,\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk,\n ]);\n\n const chorionicityOptions = useMemo(\n () =>\n (\n [\n 'unknown',\n 'dichorionic-diamniotic',\n 'monochorionic-diamniotic',\n 'monochorionic-monoamniotic',\n ] as const\n ).map((c) => ({\n value: c,\n label: t(`antenatalSchedule.chorionicity.${c}`),\n })),\n [t],\n );\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(data?.result ?? null);\n }, [data, onResultChange]);\n\n /* ── Agent handle ────────────────────────────────────────────────── */\n const liveRef = useRef({ method, refDate, asOfDate, data });\n liveRef.current = { method, refDate, asOfDate, data };\n\n const agentHandle = useMemo<GestationalAgeCalculatorHandle>(\n () => ({\n getInputs: () => {\n const live = liveRef.current;\n return {\n method: live.method,\n referenceDate: live.refDate ? toIsoDate(live.refDate) : null,\n asOfDate: toIsoDate(live.asOfDate),\n };\n },\n getResult: () => {\n const r = liveRef.current.data?.result;\n if (!r) return null;\n return {\n gestationalAge: r.gestationalAge ? { ...r.gestationalAge } : null,\n trimester: r.trimester,\n dueDate: toIsoDate(r.dueDate),\n };\n },\n setMethod: (next) => {\n if (next !== 'lmp' && next !== 'edd') return false;\n setMethod(next);\n return true;\n },\n setReferenceDate: (isoDate) => {\n if (isoDate === null) {\n setRefDate(undefined);\n return true;\n }\n const parsed = fromIsoDate(isoDate);\n if (!parsed) return false;\n // The DatePicker caps an LMP at today; a known EDD is in the future.\n if (liveRef.current.method === 'lmp' && isAfter(parsed, new Date())) {\n return false;\n }\n setRefDate(parsed);\n return true;\n },\n setAsOfDate: (isoDate) => {\n const parsed = fromIsoDate(isoDate);\n if (!parsed) return false;\n setAsOfDate(parsed);\n return true;\n },\n }),\n [],\n );\n useAgentRegistration(gestationalAgeCalculatorAgent, agentHandle, id);\n\n const gaText = (ga: GestationalAge | null): string =>\n ga\n ? t('gestationalAgeCalculator.gestation', {\n weeks: ga.weeks,\n days: ga.days,\n })\n : '—';\n\n return (\n <div\n ref={ref}\n data-component=\"gestational-age-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('gestationalAgeCalculator.method.label')}\n variant=\"horizontal\"\n value={method}\n onValueChange={(next) => setMethod(next as GestationalAgeMethod)}\n >\n <Radio label={t('gestationalAgeCalculator.method.lmp')} value=\"lmp\" />\n <Radio label={t('gestationalAgeCalculator.method.edd')} value=\"edd\" />\n </RadioGroup>\n\n <FormField\n label={t(\n method === 'lmp'\n ? 'gestationalAgeCalculator.lmpDate'\n : 'gestationalAgeCalculator.eddDate',\n )}\n >\n <DatePicker\n value={refDate}\n onChange={setRefDate}\n maxDate={method === 'lmp' ? today : undefined}\n />\n </FormField>\n\n <FormField\n label={t('gestationalAgeCalculator.asOfDate')}\n description={t('gestationalAgeCalculator.asOfDateHint')}\n >\n <DatePicker value={asOfDate} onChange={(d) => d && setAsOfDate(d)} />\n </FormField>\n\n {showSchedule ? (\n <>\n <RadioGroup\n label={t('antenatalSchedule.plurality.label')}\n variant=\"horizontal\"\n value={plurality}\n onValueChange={(next) => setPlurality(next as Plurality)}\n >\n <Radio\n label={t('antenatalSchedule.plurality.singleton')}\n value=\"singleton\"\n />\n <Radio\n label={t('antenatalSchedule.plurality.twin')}\n value=\"twin\"\n />\n <Radio\n label={t('antenatalSchedule.plurality.triplet')}\n value=\"triplet\"\n />\n </RadioGroup>\n\n {plurality !== 'singleton' ? (\n <FormField label={t('antenatalSchedule.chorionicity.label')}>\n <Select\n options={chorionicityOptions}\n value={chorionicity}\n onValueChange={(next) =>\n setChorionicity(next as Chorionicity)\n }\n />\n </FormField>\n ) : null}\n\n <Switch\n label={t('antenatalSchedule.rhNegative')}\n checked={rhNegative}\n onCheckedChange={setRhNegative}\n />\n\n <RadioGroup\n label={t('antenatalSchedule.gdmRisk.label')}\n variant=\"horizontal\"\n value={gdmRisk}\n onValueChange={(next) => setGdmRisk(next as GdmRisk | 'none')}\n >\n <Radio label={t('antenatalSchedule.gdmRisk.none')} value=\"none\" />\n <Radio\n label={t('antenatalSchedule.gdmRisk.medium')}\n value=\"medium\"\n />\n <Radio label={t('antenatalSchedule.gdmRisk.high')} value=\"high\" />\n </RadioGroup>\n </>\n ) : null}\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {data\n ? `${t('gestationalAgeCalculator.gestationLabel')}: ${gaText(\n data.result.gestationalAge,\n )}. ${t('gestationalAgeCalculator.trimesterLabel')}: ${t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n )}.`\n : ''}\n </p>\n\n {data ? (\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-2\">\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.trimesterLabel')}\n </dt>\n <dd>\n <Badge\n variant={TRIMESTER_BADGE_VARIANT[data.result.trimester]}\n size=\"lg\"\n >\n {t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n )}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.gestationLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {gaText(data.result.gestationalAge)}\n </dd>\n </div>\n </dl>\n\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.milestonesLabel')}\n </span>\n <ul className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n {data.milestones.map((m) => {\n const reached = isAfter(asOfDate, m.date);\n return (\n <li\n key={m.key}\n className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-md)]\"\n >\n <span className=\"type-body ds:text-foreground\">\n {t(`gestationalAgeCalculator.milestone.${m.key}`)}\n </span>\n <span className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span className=\"type-body ds:text-muted-foreground\">\n {dateFormatter.format(m.date)}\n </span>\n {reached ? (\n <Badge variant=\"success\">\n {t('gestationalAgeCalculator.reached')}\n </Badge>\n ) : null}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('gestationalAgeCalculator.empty')}\n </p>\n )}\n\n {schedule ? <AntenatalScheduleTimeline events={schedule} /> : null}\n\n {/* One result-action group for the whole result — sits after both the\n gestational-age card and the schedule, and its payload carries the\n schedule rows when shown (no per-card buttons). */}\n {data && (insertVariant === 'copy' || onInsert) ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.gestationalAge'),\n icon: 'baby',\n highlight: t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n ),\n // Chip shares the trimester's semantic token so the inserted PNG\n // chip matches the on-screen trimester badge — with the\n // contrast-safe orange override for the `--warning` third trimester.\n highlightToken: trimesterHighlightToken(data.result.trimester),\n brand: insertBrand,\n fields: [\n {\n // Gestational age is an elapsed duration → clock glyph.\n icon: 'clock',\n label: t('gestationalAgeCalculator.gestationLabel'),\n value: gaText(data.result.gestationalAge),\n },\n {\n // Trimester is a clinical-stage classification → tag.\n icon: 'tag',\n label: t('gestationalAgeCalculator.trimesterLabel'),\n value: t(\n `gestationalAgeCalculator.trimester.${data.result.trimester}`,\n ),\n },\n // When the schedule is shown, the single Insert button carries\n // the exam windows too (no second button).\n ...(schedule\n ? buildScheduleInsertFields(schedule, t, (d) =>\n dateFormatter.format(d),\n )\n : []),\n ],\n }}\n />\n ) : null}\n </div>\n );\n },\n);\n\nGestationalAgeCalculator.displayName = 'GestationalAgeCalculator';\n"],"names":["DEPRECATED","isoDate","gestationalAgeCalculatorAgent","handle","args","rootVariants","cva","toIsoDate","d","format","fromIsoDate","iso","parseISO","GestationalAgeCalculator","forwardRef","defaultMethod","defaultReferenceDate","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","showSchedule","defaultPlurality","defaultChorionicity","defaultRhNegative","defaultGdmRisk","scheduleOptions","id","width","className","ref","i18n","useTranslation","method","setMethod","useState","refDate","setRefDate","asOfDate","setAsOfDate","today","useMemo","plurality","setPlurality","chorionicity","setChorionicity","rhNegative","setRhNegative","gdmRisk","setGdmRisk","data","lmp","subDays","GESTATION_DAYS","r","computeDueDate","gestationalMilestones","schedule","computeAntenatalSchedule","chorionicityOptions","c","dateFormatter","useEffect","liveRef","useRef","agentHandle","live","_a","next","parsed","isAfter","useAgentRegistration","gaText","ga","jsxs","RadioGroup","jsx","Radio","FormField","DatePicker","Fragment","Select","Switch","Card","Badge","TRIMESTER_BADGE_VARIANT","m","reached","AntenatalScheduleTimeline","InsertButton","trimesterHighlightToken","buildScheduleInsertFields"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,IAAa,iDAGbC,IAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AACX,GAEaC,KACX;AAAA,EACE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AkB,UAAUD,KACpC,gBAAA4D;AAAA,YAACa;AAAA,YAAA;AAAA,cACC,UAAAzE;AAAA,cACA,SAASC;AAAA,cACT,QAAAC;AAAA,cACA,SAAAC;AAAA,cACA,MAAM;AAAA,gBACJ,OAAO,EAAE,6BAA6B;AAAA,gBACtC,MAAM;AAAA,gBACN,WAAW;AAAA,kBACT,sCAAsC+B,EAAK,OAAO,SAAS;AAAA,gBAAA;AAAA;AAAA;AAAA;AAAA,gBAK7D,gBAAgBwC,GAAwBxC,EAAK,OAAO,SAAS;AAAA,gBAC7D,OAAO9B;AAAA,gBACP,QAAQ;AAAA,kBACN;AAAA;AAAA,oBAEE,MAAM;AAAA,oBACN,OAAO,EAAE,yCAAyC;AAAA,oBAClD,OAAOoD,EAAOtB,EAAK,OAAO,cAAc;AAAA,kBAAA;AAAA,kBAE1C;AAAA;AAAA,oBAEE,MAAM;AAAA,oBACN,OAAO,EAAE,yCAAyC;AAAA,oBAClD,OAAO;AAAA,sBACL,sCAAsCA,EAAK,OAAO,SAAS;AAAA,oBAAA;AAAA,kBAC7D;AAAA;AAAA;AAAA,kBAIF,GAAIO,IACAkC;AAAA,oBAA0BlC;AAAA,oBAAU;AAAA,oBAAG,CAACnD,MACtCuD,EAAc,OAAOvD,CAAC;AAAA,kBAAA,IAExB,CAAA;AAAA,gBAAC;AAAA,cACP;AAAA,YACF;AAAA,UAAA,IAEA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEAK,GAAyB,cAAc;"}
|
|
@@ -5,11 +5,11 @@ import { useTranslation as J } from "react-i18next";
|
|
|
5
5
|
import { u as Q } from "./registry-DvAUVLHh.js";
|
|
6
6
|
import { F as S } from "./form-field-CahJzTxp.js";
|
|
7
7
|
import { N as P } from "./number-input-Cgu2TtA8.js";
|
|
8
|
-
import { D as G } from "./date-time-picker-
|
|
8
|
+
import { D as G } from "./date-time-picker-3I2vVKGV.js";
|
|
9
9
|
import { C as B } from "./card-DPmk26CL.js";
|
|
10
10
|
import { B as X } from "./badge-sTusUqZD.js";
|
|
11
11
|
import { I as ee } from "./insert-result-LCNTskNJ.js";
|
|
12
|
-
import { c as te } from "./date-picker-variants-
|
|
12
|
+
import { c as te } from "./date-picker-variants-DfuooXEK.js";
|
|
13
13
|
import { p as ne } from "./parseISO-fOGpHKXm.js";
|
|
14
14
|
import { t as se, e as h } from "./format-4HNwNGrN.js";
|
|
15
15
|
function ae(e, l) {
|
|
@@ -309,4 +309,4 @@ export {
|
|
|
309
309
|
re as M,
|
|
310
310
|
oe as a
|
|
311
311
|
};
|
|
312
|
-
//# sourceMappingURL=hcg-doubling-
|
|
312
|
+
//# sourceMappingURL=hcg-doubling-CpU7H5rQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hcg-doubling-BaXkJhT-.js","sources":["../../node_modules/date-fns/formatISO.js","../../src/components/hcg-doubling/hcg-doubling.agent.ts","../../src/components/hcg-doubling/hcg.ts","../../src/components/hcg-doubling/hcg-doubling.tsx"],"sourcesContent":["import { addLeadingZeros } from \"./_lib/addLeadingZeros.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link formatISO} function options.\n */\n\n/**\n * @name formatISO\n * @category Common Helpers\n * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).\n *\n * @description\n * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.\n *\n * @param date - The original date\n * @param options - An object with options.\n *\n * @returns The formatted date string (in local time zone)\n *\n * @throws `date` must not be Invalid Date\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918T190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, date only:\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52Z'\n */\nexport function formatISO(date, options) {\n const date_ = toDate(date, options?.in);\n\n if (isNaN(+date_)) {\n throw new RangeError(\"Invalid time value\");\n }\n\n const format = options?.format ?? \"extended\";\n const representation = options?.representation ?? \"complete\";\n\n let result = \"\";\n let tzOffset = \"\";\n\n const dateDelimiter = format === \"extended\" ? \"-\" : \"\";\n const timeDelimiter = format === \"extended\" ? \":\" : \"\";\n\n // Representation is either 'date' or 'complete'\n if (representation !== \"time\") {\n const day = addLeadingZeros(date_.getDate(), 2);\n const month = addLeadingZeros(date_.getMonth() + 1, 2);\n const year = addLeadingZeros(date_.getFullYear(), 4);\n\n // yyyyMMdd or yyyy-MM-dd.\n result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;\n }\n\n // Representation is either 'time' or 'complete'\n if (representation !== \"date\") {\n // Add the timezone.\n const offset = date_.getTimezoneOffset();\n\n if (offset !== 0) {\n const absoluteOffset = Math.abs(offset);\n const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2);\n const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n const sign = offset < 0 ? \"+\" : \"-\";\n\n tzOffset = `${sign}${hourOffset}:${minuteOffset}`;\n } else {\n tzOffset = \"Z\";\n }\n\n const hour = addLeadingZeros(date_.getHours(), 2);\n const minute = addLeadingZeros(date_.getMinutes(), 2);\n const second = addLeadingZeros(date_.getSeconds(), 2);\n\n // If there's also date, separate it with time with 'T'\n const separator = result === \"\" ? \"\" : \"T\";\n\n // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.\n const time = [hour, minute, second].join(timeDelimiter);\n\n // HHmmss or HH:mm:ss.\n result = `${result}${separator}${time}${tzOffset}`;\n }\n\n return result;\n}\n\n// Fallback for modularized imports:\nexport default formatISO;\n","/* -------------------------------------------------------------------- */\n/* Agent adapter — HcgDoubling. */\n/* */\n/* Clinical calculator: two timed serum β-hCG values → doubling time, */\n/* 48-hour-normalised rise and a viability trend band. The agent surface */\n/* is the two timed samples plus the computed trend; the handle is the */\n/* curated `HcgDoublingHandle` (the public `ref` stays the root <div>, */\n/* exactly as `slider.tsx` and `bmi-calculator.tsx` keep theirs). */\n/* */\n/* Sample times cross the boundary as ISO-8601 strings WITH an offset, so */\n/* the interval between the two draws survives serialisation. */\n/* */\n/* PHI (§7): never exposes patient identity — the slots return the */\n/* operator's own structural lab figures and the numbers derived from */\n/* them. See `src/docs/26-agent-readiness.mdx`. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { HcgDoublingHandle } from './hcg-doubling';\n\n/** JSON Schema fragment for one optional β-hCG value, mIU/mL. */\nconst hcgValue = (label: string) => ({\n oneOf: [{ type: 'number', exclusiveMinimum: 0 }, { type: 'null' }],\n description: `${label} in mIU/mL, or null to clear it.`,\n});\n\n/** JSON Schema fragment for one optional sample time. */\nconst sampleTime = (label: string) => ({\n oneOf: [{ type: 'string', format: 'date-time' }, { type: 'null' }],\n description: `${label} as an ISO-8601 timestamp with offset (e.g. 2026-08-01T09:30:00+02:00), not in the future, or null to clear it.`,\n});\n\nexport const hcgDoublingAgent: AgentAdapter<HcgDoublingHandle> = {\n id: 'hcg-doubling',\n // set_value → the `set_samples` action + the `samples` state slot.\n capabilities: ['set_value'],\n state: {\n samples: {\n type: '{ hcg1: number | null, date1: string | null, hcg2: number | null, date2: string | null }',\n descriptionKey: 'ui.agent.hcgDoubling.state.samples',\n description:\n 'The two timed β-hCG samples as entered — value in mIU/mL plus the draw time as an ISO-8601 timestamp. Null where unset. Read this to see why a result is still null.',\n read: (handle) => handle.getSamples(),\n },\n result: {\n type: \"{ intervalHours: number, ratio: number, percentRise: number, twoDayRisePercent: number, doublingTimeHours: number | null, trend: 'rising-normal' | 'rising-slow' | 'plateau-falling' } | null\",\n descriptionKey: 'ui.agent.hcgDoubling.state.result',\n description:\n 'Computed doubling time in hours (null when not rising), the rise normalised to 48 hours, and the trend band against the minimal-rise benchmark. Null until both samples are set and the second is after the first.',\n read: (handle) => handle.getResult(),\n },\n },\n actions: {\n set_samples: {\n // Drives the same local input state a user types into; nothing is\n // persisted to a record, and every value is reversible in the same UI.\n safety: 'write',\n argsType:\n '{ hcg1?: number | null, date1?: string | null, hcg2?: number | null, date2?: string | null }',\n argsSchema: {\n type: 'object',\n properties: {\n hcg1: hcgValue('First β-hCG value'),\n date1: sampleTime('When the first sample was drawn'),\n hcg2: hcgValue('Second β-hCG value'),\n date2: sampleTime('When the second sample was drawn'),\n },\n additionalProperties: false,\n },\n idempotent: true,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the samples were applied.',\n },\n errors: [\n 'Returns false and writes nothing when a value is not positive, a timestamp is unparseable, or a timestamp is in the future — the payload applies all-or-nothing.',\n 'Applies cleanly but leaves `result` null when the second sample is not strictly after the first — the analysis needs a forward interval.',\n ],\n examples: [\n {\n args: {\n hcg1: 1200,\n date1: '2026-08-01T09:00:00+02:00',\n hcg2: 2500,\n date2: '2026-08-03T09:00:00+02:00',\n },\n note: 'A doubling over 48 hours → the rising-normal band.',\n },\n ],\n descriptionKey: 'ui.agent.hcgDoubling.actions.setSamples',\n description:\n 'Set any subset of the two timed β-hCG samples. Omitted keys are left unchanged; an explicit null clears one. All four are needed before a trend is computed.',\n invoke: (\n handle,\n args: {\n hcg1?: number | null;\n date1?: string | null;\n hcg2?: number | null;\n date2?: string | null;\n },\n ) => handle.setSamples(args),\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'hcg-doubling',\n description:\n 'Marks the HcgDoubling calculator (serum β-hCG doubling time from two timed values).',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Also the registry key — without an `id` the instance does not register and the handle-driven action/state are unreachable.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* Serum β-hCG doubling time — early-pregnancy viability. */\n/* */\n/* Pure, framework-free, unit-testable. From two timed β-hCG values it */\n/* derives the doubling time, the rise over the actual interval, and the */\n/* rise normalised to 48 hours (the standard comparison window). A */\n/* normal early intrauterine pregnancy rises at least ~35% over 48h */\n/* (Barnhart 2004); a plateau or fall is abnormal. */\n/* */\n/* Barnhart KT et al. \"Symptomatic patients with an early viable */\n/* intrauterine pregnancy.\" Obstet Gynecol 2004;104:50-5. */\n/* ------------------------------------------------------------------ */\n\nconst MS_PER_HOUR = 1000 * 60 * 60;\n/** Conservative minimal 48-hour rise for a potentially viable IUP, %. */\nexport const MINIMAL_48H_RISE_PERCENT = 35;\n\nexport interface HcgInput {\n /** First β-hCG value, mIU/mL. */\n hcg1: number;\n /** When the first sample was drawn. */\n date1: Date;\n /** Second β-hCG value, mIU/mL. */\n hcg2: number;\n /** When the second sample was drawn (must be after `date1`). */\n date2: Date;\n}\n\nexport type HcgTrend = 'rising-normal' | 'rising-slow' | 'plateau-falling';\n\nexport interface HcgResult {\n /** Hours between the two samples. */\n intervalHours: number;\n /** hcg2 / hcg1. */\n ratio: number;\n /** Rise over the actual interval, %. */\n percentRise: number;\n /** Rise normalised to a 48-hour window, % (comparable to the benchmark). */\n twoDayRisePercent: number;\n /** Doubling time in hours, or `null` when not rising. */\n doublingTimeHours: number | null;\n /** Trend band against the Barnhart minimal-rise benchmark. */\n trend: HcgTrend;\n}\n\n/**\n * Analyse a two-point β-hCG series. Returns `null` unless both values are\n * positive and the second sample is strictly after the first.\n */\nexport function analyseHcg(input: HcgInput): HcgResult | null {\n const { hcg1, hcg2, date1, date2 } = input;\n if (!(hcg1 > 0) || !(hcg2 > 0)) return null;\n\n const intervalHours = (date2.getTime() - date1.getTime()) / MS_PER_HOUR;\n if (!(intervalHours > 0)) return null;\n\n const ratio = hcg2 / hcg1;\n const percentRise = (ratio - 1) * 100;\n const twoDayRisePercent = (ratio ** (48 / intervalHours) - 1) * 100;\n const doublingTimeHours =\n ratio > 1 ? (intervalHours * Math.LN2) / Math.log(ratio) : null;\n\n const trend: HcgTrend =\n ratio <= 1\n ? 'plateau-falling'\n : twoDayRisePercent >= MINIMAL_48H_RISE_PERCENT\n ? 'rising-normal'\n : 'rising-slow';\n\n return {\n intervalHours,\n ratio,\n percentRise,\n twoDayRisePercent,\n doublingTimeHours,\n trend,\n };\n}\n","/* ------------------------------------------------------------------ */\n/* HcgDoubling — serum β-hCG doubling time from two timed values. */\n/* */\n/* Maths in `./hcg` (pure, tested). Two timepoints (value + datetime) */\n/* → doubling time, 48-hour-normalised rise and a viability trend band. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useRef, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { formatISO, isAfter, parseISO } from 'date-fns';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { hcgDoublingAgent } from './hcg-doubling.agent';\nimport { FormField } from '../form-field';\nimport { NumberInput } from '../number-input';\nimport { DateTimePicker } from '../date-time-picker';\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 { type HcgResult, type HcgTrend, analyseHcg } from './hcg';\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\nconst TREND_BADGE: Record<HcgTrend, 'success' | 'warning' | 'error'> = {\n 'rising-normal': 'success',\n 'rising-slow': 'warning',\n 'plateau-falling': 'error',\n};\nconst TREND_TOKEN: Record<HcgTrend, string> = {\n 'rising-normal': '--success',\n 'rising-slow': '--warning-readable',\n 'plateau-falling': '--destructive',\n};\n\n/* ------------------------------------------------------------------ */\n/* Agent boundary */\n/* */\n/* Sample times cross the boundary as ISO-8601 strings WITH an offset */\n/* (`2026-08-01T09:30:00+02:00`), never `Date` objects — the doubling */\n/* maths is a difference between two instants, so the offset has to */\n/* survive the trip. */\n/* ------------------------------------------------------------------ */\n\nconst toIsoDateTime = (d: Date): string => formatISO(d);\n\nconst fromIsoDateTime = (iso: string): Date | null => {\n const d = parseISO(iso);\n return Number.isNaN(d.getTime()) ? null : d;\n};\n\n/** A β-hCG figure is usable when it is a positive finite number, or cleared. */\nconst isHcgValue = (n: number | null | undefined): boolean =>\n n === null || n === undefined || (Number.isFinite(n) && n > 0);\n\n/** The two timed samples as entered. */\nexport interface HcgSamplesSnapshot {\n /** First β-hCG value, mIU/mL, or null. */\n hcg1: number | null;\n /** When the first sample was drawn, ISO-8601 with offset, or null. */\n date1: string | null;\n /** Second β-hCG value, mIU/mL, or null. */\n hcg2: number | null;\n /** When the second sample was drawn, ISO-8601 with offset, or null. */\n date2: string | null;\n}\n\n/**\n * Curated imperative handle for agent / external automation. Reads the two\n * timed samples and the computed trend, and writes the samples the way a user\n * would enter them. Never exposes patient identity — only structural lab\n * figures, sample times and the derived doubling numbers. Consumed by\n * `hcg-doubling.agent.ts`; the public `ref` stays the root DOM element.\n */\nexport interface HcgDoublingHandle {\n /** The two timed samples as entered, or null where unset. */\n getSamples: () => HcgSamplesSnapshot;\n /** Computed doubling time, 48-hour rise and trend band, or null. */\n getResult: () => HcgResult | null;\n /**\n * Set any subset of the two timed samples. Omitted keys are left unchanged;\n * an explicit `null` clears one. Applies all-or-nothing — returns false and\n * writes nothing if any value is unusable.\n */\n setSamples: (next: Partial<HcgSamplesSnapshot>) => boolean;\n}\n\nexport interface HcgDoublingProps extends VariantProps<typeof rootVariants> {\n /** Pre-fill the first sample's date/time (e.g. from the lab record). */\n defaultDate1?: Date;\n /** Pre-fill the second sample's date/time. */\n defaultDate2?: Date;\n /** Fires whenever both timed values resolve (and `null` when not). */\n onResultChange?: (result: HcgResult | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /** Which verb the result button performs. Defaults to `'insert'`. */\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 /** Brand wordmark printed in the inserted/copied result-card footer. */\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 HcgDoubling = forwardRef<HTMLDivElement, HcgDoublingProps>(\n (\n {\n defaultDate1,\n defaultDate2,\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 [hcg1, setHcg1] = useState<number | null>(null);\n const [date1, setDate1] = useState<Date | undefined>(defaultDate1);\n const [hcg2, setHcg2] = useState<number | null>(null);\n const [date2, setDate2] = useState<Date | undefined>(defaultDate2);\n\n const today = useMemo(() => new Date(), []);\n\n const result = useMemo(() => {\n if (hcg1 === null || hcg2 === null || !date1 || !date2) return null;\n return analyseHcg({ hcg1, date1, hcg2, date2 });\n }, [hcg1, date1, hcg2, date2]);\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n /* ── Agent handle ────────────────────────────────────────────────── */\n const liveRef = useRef({ hcg1, date1, hcg2, date2, result });\n liveRef.current = { hcg1, date1, hcg2, date2, result };\n\n const agentHandle = useMemo<HcgDoublingHandle>(\n () => ({\n getSamples: () => {\n const live = liveRef.current;\n return {\n hcg1: live.hcg1,\n date1: live.date1 ? toIsoDateTime(live.date1) : null,\n hcg2: live.hcg2,\n date2: live.date2 ? toIsoDateTime(live.date2) : null,\n };\n },\n getResult: () => liveRef.current.result,\n setSamples: (next) => {\n const now = new Date();\n const parsed: { date1?: Date | undefined; date2?: Date | undefined } =\n {};\n // Validate the whole payload before writing any of it, so a bad\n // value can't leave the form half-updated.\n for (const key of ['hcg1', 'hcg2'] as const) {\n if (key in next && !isHcgValue(next[key])) return false;\n }\n for (const key of ['date1', 'date2'] as const) {\n if (!(key in next)) continue;\n const iso = next[key];\n if (iso === null || iso === undefined) {\n parsed[key] = undefined;\n continue;\n }\n const d = fromIsoDateTime(iso);\n // The DateTimePickers cap at now; the handle honours the same bound.\n if (!d || isAfter(d, now)) return false;\n parsed[key] = d;\n }\n if ('hcg1' in next) setHcg1(next.hcg1 ?? null);\n if ('hcg2' in next) setHcg2(next.hcg2 ?? null);\n if ('date1' in next) setDate1(parsed.date1);\n if ('date2' in next) setDate2(parsed.date2);\n return true;\n },\n }),\n [],\n );\n useAgentRegistration(hcgDoublingAgent, agentHandle, id);\n\n const num = useMemo(\n () => new Intl.NumberFormat(i18n.language, { maximumFractionDigits: 0 }),\n [i18n.language],\n );\n\n const doublingText = (r: HcgResult): string =>\n r.doublingTimeHours === null\n ? '—'\n : t('hcgDoubling.hoursValue', {\n hours: num.format(r.doublingTimeHours),\n });\n const riseText = (r: HcgResult): string =>\n t('hcgDoubling.percentValue', { value: num.format(r.twoDayRisePercent) });\n\n return (\n <div\n ref={ref}\n data-component=\"hcg-doubling\"\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\n label={`${t('hcgDoubling.hcg1')} (${t('hcgDoubling.units')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n value={hcg1}\n onChange={setHcg1}\n />\n </FormField>\n <FormField label={t('hcgDoubling.date1')}>\n <DateTimePicker value={date1} onChange={setDate1} maxDate={today} />\n </FormField>\n <FormField\n label={`${t('hcgDoubling.hcg2')} (${t('hcgDoubling.units')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n value={hcg2}\n onChange={setHcg2}\n />\n </FormField>\n <FormField label={t('hcgDoubling.date2')}>\n <DateTimePicker value={date2} onChange={setDate2} maxDate={today} />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('hcgDoubling.doublingLabel')}: ${doublingText(result)}. ${t(\n `hcgDoubling.trend.${result.trend}`,\n )}.`\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-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.doublingLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {doublingText(result)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.riseLabel')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {riseText(result)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.trendLabel')}\n </dt>\n <dd>\n <Badge variant={TREND_BADGE[result.trend]} size=\"lg\">\n {t(`hcgDoubling.trend.${result.trend}`)}\n </Badge>\n </dd>\n </div>\n </dl>\n <p className=\"type-body-sm ds:text-muted-foreground\">\n {t('hcgDoubling.disclaimer')}\n </p>\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.hcg'),\n icon: 'activity',\n highlight: t(`hcgDoubling.trend.${result.trend}`),\n highlightToken: TREND_TOKEN[result.trend],\n brand: insertBrand,\n fields: [\n {\n icon: 'clock',\n label: t('hcgDoubling.doublingLabel'),\n value: doublingText(result),\n },\n {\n icon: 'trending-up',\n label: t('hcgDoubling.riseLabel'),\n value: riseText(result),\n },\n {\n icon: 'tag',\n label: t('hcgDoubling.trendLabel'),\n value: t(`hcgDoubling.trend.${result.trend}`),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('hcgDoubling.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nHcgDoubling.displayName = 'HcgDoubling';\n"],"names":["formatISO","date","options","date_","toDate","result","tzOffset","dateDelimiter","timeDelimiter","day","addLeadingZeros","month","offset","absoluteOffset","hourOffset","minuteOffset","hour","minute","second","separator","time","hcgValue","label","sampleTime","hcgDoublingAgent","handle","args","MS_PER_HOUR","MINIMAL_48H_RISE_PERCENT","analyseHcg","input","hcg1","hcg2","date1","date2","intervalHours","ratio","percentRise","twoDayRisePercent","doublingTimeHours","trend","rootVariants","cva","TREND_BADGE","TREND_TOKEN","toIsoDateTime","d","fromIsoDateTime","iso","parseISO","isHcgValue","n","HcgDoubling","forwardRef","defaultDate1","defaultDate2","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","i18n","useTranslation","setHcg1","useState","setDate1","setHcg2","setDate2","today","useMemo","useEffect","liveRef","useRef","agentHandle","live","next","now","parsed","key","isAfter","useAgentRegistration","num","doublingText","r","riseText","jsxs","jsx","FormField","NumberInput","DateTimePicker","Card","Badge","InsertButton"],"mappings":";;;;;;;;;;;;;;AA0CO,SAASA,GAAUC,GAAMC,GAAS;AACvC,QAAMC,IAAQC,GAAOH,GAAMC,KAAA,gBAAAA,EAAS,EAAE;AAEtC,MAAI,MAAM,CAACC,CAAK;AACd,UAAM,IAAI,WAAW,oBAAoB;AAM3C,MAAIE,IAAS,IACTC,IAAW;AAEf,QAAMC,IAAwC,KACxCC,IAAwC;AAGf;AAC7B,UAAMC,IAA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AAE,WAAU,yCACV,UAAA,EAAE,wBAAwB,GAC7B;AAAA,YACCqD,MAAkB,UAAUD,IAC3B,gBAAAkC;AAAA,cAACM;AAAA,cAAA;AAAA,gBACC,UAAAxC;AAAA,gBACA,SAASC;AAAA,gBACT,QAAAC;AAAA,gBACA,SAAAC;AAAA,gBACA,MAAM;AAAA,kBACJ,OAAO,EAAE,kBAAkB;AAAA,kBAC3B,MAAM;AAAA,kBACN,WAAW,EAAE,qBAAqBvD,EAAO,KAAK,EAAE;AAAA,kBAChD,gBAAgBuC,GAAYvC,EAAO,KAAK;AAAA,kBACxC,OAAOwD;AAAA,kBACP,QAAQ;AAAA,oBACN;AAAA,sBACE,MAAM;AAAA,sBACN,OAAO,EAAE,2BAA2B;AAAA,sBACpC,OAAO0B,EAAalF,CAAM;AAAA,oBAAA;AAAA,oBAE5B;AAAA,sBACE,MAAM;AAAA,sBACN,OAAO,EAAE,uBAAuB;AAAA,sBAChC,OAAOoF,EAASpF,CAAM;AAAA,oBAAA;AAAA,oBAExB;AAAA,sBACE,MAAM;AAAA,sBACN,OAAO,EAAE,wBAAwB;AAAA,sBACjC,OAAO,EAAE,qBAAqBA,EAAO,KAAK,EAAE;AAAA,oBAAA;AAAA,kBAC9C;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAsF,EAAC,KAAA,EAAE,WAAU,sCACV,UAAA,EAAE,mBAAmB,EAAA,CACxB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAvC,GAAY,cAAc;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"hcg-doubling-CpU7H5rQ.js","sources":["../../node_modules/date-fns/formatISO.js","../../src/components/hcg-doubling/hcg-doubling.agent.ts","../../src/components/hcg-doubling/hcg.ts","../../src/components/hcg-doubling/hcg-doubling.tsx"],"sourcesContent":["import { addLeadingZeros } from \"./_lib/addLeadingZeros.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link formatISO} function options.\n */\n\n/**\n * @name formatISO\n * @category Common Helpers\n * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).\n *\n * @description\n * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.\n *\n * @param date - The original date\n * @param options - An object with options.\n *\n * @returns The formatted date string (in local time zone)\n *\n * @throws `date` must not be Invalid Date\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918T190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, date only:\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):\n * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52Z'\n */\nexport function formatISO(date, options) {\n const date_ = toDate(date, options?.in);\n\n if (isNaN(+date_)) {\n throw new RangeError(\"Invalid time value\");\n }\n\n const format = options?.format ?? \"extended\";\n const representation = options?.representation ?? \"complete\";\n\n let result = \"\";\n let tzOffset = \"\";\n\n const dateDelimiter = format === \"extended\" ? \"-\" : \"\";\n const timeDelimiter = format === \"extended\" ? \":\" : \"\";\n\n // Representation is either 'date' or 'complete'\n if (representation !== \"time\") {\n const day = addLeadingZeros(date_.getDate(), 2);\n const month = addLeadingZeros(date_.getMonth() + 1, 2);\n const year = addLeadingZeros(date_.getFullYear(), 4);\n\n // yyyyMMdd or yyyy-MM-dd.\n result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;\n }\n\n // Representation is either 'time' or 'complete'\n if (representation !== \"date\") {\n // Add the timezone.\n const offset = date_.getTimezoneOffset();\n\n if (offset !== 0) {\n const absoluteOffset = Math.abs(offset);\n const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2);\n const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n const sign = offset < 0 ? \"+\" : \"-\";\n\n tzOffset = `${sign}${hourOffset}:${minuteOffset}`;\n } else {\n tzOffset = \"Z\";\n }\n\n const hour = addLeadingZeros(date_.getHours(), 2);\n const minute = addLeadingZeros(date_.getMinutes(), 2);\n const second = addLeadingZeros(date_.getSeconds(), 2);\n\n // If there's also date, separate it with time with 'T'\n const separator = result === \"\" ? \"\" : \"T\";\n\n // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.\n const time = [hour, minute, second].join(timeDelimiter);\n\n // HHmmss or HH:mm:ss.\n result = `${result}${separator}${time}${tzOffset}`;\n }\n\n return result;\n}\n\n// Fallback for modularized imports:\nexport default formatISO;\n","/* -------------------------------------------------------------------- */\n/* Agent adapter — HcgDoubling. */\n/* */\n/* Clinical calculator: two timed serum β-hCG values → doubling time, */\n/* 48-hour-normalised rise and a viability trend band. The agent surface */\n/* is the two timed samples plus the computed trend; the handle is the */\n/* curated `HcgDoublingHandle` (the public `ref` stays the root <div>, */\n/* exactly as `slider.tsx` and `bmi-calculator.tsx` keep theirs). */\n/* */\n/* Sample times cross the boundary as ISO-8601 strings WITH an offset, so */\n/* the interval between the two draws survives serialisation. */\n/* */\n/* PHI (§7): never exposes patient identity — the slots return the */\n/* operator's own structural lab figures and the numbers derived from */\n/* them. See `src/docs/26-agent-readiness.mdx`. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { HcgDoublingHandle } from './hcg-doubling';\n\n/** JSON Schema fragment for one optional β-hCG value, mIU/mL. */\nconst hcgValue = (label: string) => ({\n oneOf: [{ type: 'number', exclusiveMinimum: 0 }, { type: 'null' }],\n description: `${label} in mIU/mL, or null to clear it.`,\n});\n\n/** JSON Schema fragment for one optional sample time. */\nconst sampleTime = (label: string) => ({\n oneOf: [{ type: 'string', format: 'date-time' }, { type: 'null' }],\n description: `${label} as an ISO-8601 timestamp with offset (e.g. 2026-08-01T09:30:00+02:00), not in the future, or null to clear it.`,\n});\n\nexport const hcgDoublingAgent: AgentAdapter<HcgDoublingHandle> = {\n id: 'hcg-doubling',\n // set_value → the `set_samples` action + the `samples` state slot.\n capabilities: ['set_value'],\n state: {\n samples: {\n type: '{ hcg1: number | null, date1: string | null, hcg2: number | null, date2: string | null }',\n descriptionKey: 'ui.agent.hcgDoubling.state.samples',\n description:\n 'The two timed β-hCG samples as entered — value in mIU/mL plus the draw time as an ISO-8601 timestamp. Null where unset. Read this to see why a result is still null.',\n read: (handle) => handle.getSamples(),\n },\n result: {\n type: \"{ intervalHours: number, ratio: number, percentRise: number, twoDayRisePercent: number, doublingTimeHours: number | null, trend: 'rising-normal' | 'rising-slow' | 'plateau-falling' } | null\",\n descriptionKey: 'ui.agent.hcgDoubling.state.result',\n description:\n 'Computed doubling time in hours (null when not rising), the rise normalised to 48 hours, and the trend band against the minimal-rise benchmark. Null until both samples are set and the second is after the first.',\n read: (handle) => handle.getResult(),\n },\n },\n actions: {\n set_samples: {\n // Drives the same local input state a user types into; nothing is\n // persisted to a record, and every value is reversible in the same UI.\n safety: 'write',\n argsType:\n '{ hcg1?: number | null, date1?: string | null, hcg2?: number | null, date2?: string | null }',\n argsSchema: {\n type: 'object',\n properties: {\n hcg1: hcgValue('First β-hCG value'),\n date1: sampleTime('When the first sample was drawn'),\n hcg2: hcgValue('Second β-hCG value'),\n date2: sampleTime('When the second sample was drawn'),\n },\n additionalProperties: false,\n },\n idempotent: true,\n returns: 'boolean',\n returnsSchema: {\n type: 'boolean',\n description: 'True when the samples were applied.',\n },\n errors: [\n 'Returns false and writes nothing when a value is not positive, a timestamp is unparseable, or a timestamp is in the future — the payload applies all-or-nothing.',\n 'Applies cleanly but leaves `result` null when the second sample is not strictly after the first — the analysis needs a forward interval.',\n ],\n examples: [\n {\n args: {\n hcg1: 1200,\n date1: '2026-08-01T09:00:00+02:00',\n hcg2: 2500,\n date2: '2026-08-03T09:00:00+02:00',\n },\n note: 'A doubling over 48 hours → the rising-normal band.',\n },\n ],\n descriptionKey: 'ui.agent.hcgDoubling.actions.setSamples',\n description:\n 'Set any subset of the two timed β-hCG samples. Omitted keys are left unchanged; an explicit null clears one. All four are needed before a trend is computed.',\n invoke: (\n handle,\n args: {\n hcg1?: number | null;\n date1?: string | null;\n hcg2?: number | null;\n date2?: string | null;\n },\n ) => handle.setSamples(args),\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'hcg-doubling',\n description:\n 'Marks the HcgDoubling calculator (serum β-hCG doubling time from two timed values).',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Also the registry key — without an `id` the instance does not register and the handle-driven action/state are unreachable.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* Serum β-hCG doubling time — early-pregnancy viability. */\n/* */\n/* Pure, framework-free, unit-testable. From two timed β-hCG values it */\n/* derives the doubling time, the rise over the actual interval, and the */\n/* rise normalised to 48 hours (the standard comparison window). A */\n/* normal early intrauterine pregnancy rises at least ~35% over 48h */\n/* (Barnhart 2004); a plateau or fall is abnormal. */\n/* */\n/* Barnhart KT et al. \"Symptomatic patients with an early viable */\n/* intrauterine pregnancy.\" Obstet Gynecol 2004;104:50-5. */\n/* ------------------------------------------------------------------ */\n\nconst MS_PER_HOUR = 1000 * 60 * 60;\n/** Conservative minimal 48-hour rise for a potentially viable IUP, %. */\nexport const MINIMAL_48H_RISE_PERCENT = 35;\n\nexport interface HcgInput {\n /** First β-hCG value, mIU/mL. */\n hcg1: number;\n /** When the first sample was drawn. */\n date1: Date;\n /** Second β-hCG value, mIU/mL. */\n hcg2: number;\n /** When the second sample was drawn (must be after `date1`). */\n date2: Date;\n}\n\nexport type HcgTrend = 'rising-normal' | 'rising-slow' | 'plateau-falling';\n\nexport interface HcgResult {\n /** Hours between the two samples. */\n intervalHours: number;\n /** hcg2 / hcg1. */\n ratio: number;\n /** Rise over the actual interval, %. */\n percentRise: number;\n /** Rise normalised to a 48-hour window, % (comparable to the benchmark). */\n twoDayRisePercent: number;\n /** Doubling time in hours, or `null` when not rising. */\n doublingTimeHours: number | null;\n /** Trend band against the Barnhart minimal-rise benchmark. */\n trend: HcgTrend;\n}\n\n/**\n * Analyse a two-point β-hCG series. Returns `null` unless both values are\n * positive and the second sample is strictly after the first.\n */\nexport function analyseHcg(input: HcgInput): HcgResult | null {\n const { hcg1, hcg2, date1, date2 } = input;\n if (!(hcg1 > 0) || !(hcg2 > 0)) return null;\n\n const intervalHours = (date2.getTime() - date1.getTime()) / MS_PER_HOUR;\n if (!(intervalHours > 0)) return null;\n\n const ratio = hcg2 / hcg1;\n const percentRise = (ratio - 1) * 100;\n const twoDayRisePercent = (ratio ** (48 / intervalHours) - 1) * 100;\n const doublingTimeHours =\n ratio > 1 ? (intervalHours * Math.LN2) / Math.log(ratio) : null;\n\n const trend: HcgTrend =\n ratio <= 1\n ? 'plateau-falling'\n : twoDayRisePercent >= MINIMAL_48H_RISE_PERCENT\n ? 'rising-normal'\n : 'rising-slow';\n\n return {\n intervalHours,\n ratio,\n percentRise,\n twoDayRisePercent,\n doublingTimeHours,\n trend,\n };\n}\n","/* ------------------------------------------------------------------ */\n/* HcgDoubling — serum β-hCG doubling time from two timed values. */\n/* */\n/* Maths in `./hcg` (pure, tested). Two timepoints (value + datetime) */\n/* → doubling time, 48-hour-normalised rise and a viability trend band. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useRef, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { formatISO, isAfter, parseISO } from 'date-fns';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { hcgDoublingAgent } from './hcg-doubling.agent';\nimport { FormField } from '../form-field';\nimport { NumberInput } from '../number-input';\nimport { DateTimePicker } from '../date-time-picker';\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 { type HcgResult, type HcgTrend, analyseHcg } from './hcg';\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\nconst TREND_BADGE: Record<HcgTrend, 'success' | 'warning' | 'error'> = {\n 'rising-normal': 'success',\n 'rising-slow': 'warning',\n 'plateau-falling': 'error',\n};\nconst TREND_TOKEN: Record<HcgTrend, string> = {\n 'rising-normal': '--success',\n 'rising-slow': '--warning-readable',\n 'plateau-falling': '--destructive',\n};\n\n/* ------------------------------------------------------------------ */\n/* Agent boundary */\n/* */\n/* Sample times cross the boundary as ISO-8601 strings WITH an offset */\n/* (`2026-08-01T09:30:00+02:00`), never `Date` objects — the doubling */\n/* maths is a difference between two instants, so the offset has to */\n/* survive the trip. */\n/* ------------------------------------------------------------------ */\n\nconst toIsoDateTime = (d: Date): string => formatISO(d);\n\nconst fromIsoDateTime = (iso: string): Date | null => {\n const d = parseISO(iso);\n return Number.isNaN(d.getTime()) ? null : d;\n};\n\n/** A β-hCG figure is usable when it is a positive finite number, or cleared. */\nconst isHcgValue = (n: number | null | undefined): boolean =>\n n === null || n === undefined || (Number.isFinite(n) && n > 0);\n\n/** The two timed samples as entered. */\nexport interface HcgSamplesSnapshot {\n /** First β-hCG value, mIU/mL, or null. */\n hcg1: number | null;\n /** When the first sample was drawn, ISO-8601 with offset, or null. */\n date1: string | null;\n /** Second β-hCG value, mIU/mL, or null. */\n hcg2: number | null;\n /** When the second sample was drawn, ISO-8601 with offset, or null. */\n date2: string | null;\n}\n\n/**\n * Curated imperative handle for agent / external automation. Reads the two\n * timed samples and the computed trend, and writes the samples the way a user\n * would enter them. Never exposes patient identity — only structural lab\n * figures, sample times and the derived doubling numbers. Consumed by\n * `hcg-doubling.agent.ts`; the public `ref` stays the root DOM element.\n */\nexport interface HcgDoublingHandle {\n /** The two timed samples as entered, or null where unset. */\n getSamples: () => HcgSamplesSnapshot;\n /** Computed doubling time, 48-hour rise and trend band, or null. */\n getResult: () => HcgResult | null;\n /**\n * Set any subset of the two timed samples. Omitted keys are left unchanged;\n * an explicit `null` clears one. Applies all-or-nothing — returns false and\n * writes nothing if any value is unusable.\n */\n setSamples: (next: Partial<HcgSamplesSnapshot>) => boolean;\n}\n\nexport interface HcgDoublingProps extends VariantProps<typeof rootVariants> {\n /** Pre-fill the first sample's date/time (e.g. from the lab record). */\n defaultDate1?: Date;\n /** Pre-fill the second sample's date/time. */\n defaultDate2?: Date;\n /** Fires whenever both timed values resolve (and `null` when not). */\n onResultChange?: (result: HcgResult | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /** Which verb the result button performs. Defaults to `'insert'`. */\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 /** Brand wordmark printed in the inserted/copied result-card footer. */\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 HcgDoubling = forwardRef<HTMLDivElement, HcgDoublingProps>(\n (\n {\n defaultDate1,\n defaultDate2,\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 [hcg1, setHcg1] = useState<number | null>(null);\n const [date1, setDate1] = useState<Date | undefined>(defaultDate1);\n const [hcg2, setHcg2] = useState<number | null>(null);\n const [date2, setDate2] = useState<Date | undefined>(defaultDate2);\n\n const today = useMemo(() => new Date(), []);\n\n const result = useMemo(() => {\n if (hcg1 === null || hcg2 === null || !date1 || !date2) return null;\n return analyseHcg({ hcg1, date1, hcg2, date2 });\n }, [hcg1, date1, hcg2, date2]);\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n /* ── Agent handle ────────────────────────────────────────────────── */\n const liveRef = useRef({ hcg1, date1, hcg2, date2, result });\n liveRef.current = { hcg1, date1, hcg2, date2, result };\n\n const agentHandle = useMemo<HcgDoublingHandle>(\n () => ({\n getSamples: () => {\n const live = liveRef.current;\n return {\n hcg1: live.hcg1,\n date1: live.date1 ? toIsoDateTime(live.date1) : null,\n hcg2: live.hcg2,\n date2: live.date2 ? toIsoDateTime(live.date2) : null,\n };\n },\n getResult: () => liveRef.current.result,\n setSamples: (next) => {\n const now = new Date();\n const parsed: { date1?: Date | undefined; date2?: Date | undefined } =\n {};\n // Validate the whole payload before writing any of it, so a bad\n // value can't leave the form half-updated.\n for (const key of ['hcg1', 'hcg2'] as const) {\n if (key in next && !isHcgValue(next[key])) return false;\n }\n for (const key of ['date1', 'date2'] as const) {\n if (!(key in next)) continue;\n const iso = next[key];\n if (iso === null || iso === undefined) {\n parsed[key] = undefined;\n continue;\n }\n const d = fromIsoDateTime(iso);\n // The DateTimePickers cap at now; the handle honours the same bound.\n if (!d || isAfter(d, now)) return false;\n parsed[key] = d;\n }\n if ('hcg1' in next) setHcg1(next.hcg1 ?? null);\n if ('hcg2' in next) setHcg2(next.hcg2 ?? null);\n if ('date1' in next) setDate1(parsed.date1);\n if ('date2' in next) setDate2(parsed.date2);\n return true;\n },\n }),\n [],\n );\n useAgentRegistration(hcgDoublingAgent, agentHandle, id);\n\n const num = useMemo(\n () => new Intl.NumberFormat(i18n.language, { maximumFractionDigits: 0 }),\n [i18n.language],\n );\n\n const doublingText = (r: HcgResult): string =>\n r.doublingTimeHours === null\n ? '—'\n : t('hcgDoubling.hoursValue', {\n hours: num.format(r.doublingTimeHours),\n });\n const riseText = (r: HcgResult): string =>\n t('hcgDoubling.percentValue', { value: num.format(r.twoDayRisePercent) });\n\n return (\n <div\n ref={ref}\n data-component=\"hcg-doubling\"\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\n label={`${t('hcgDoubling.hcg1')} (${t('hcgDoubling.units')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n value={hcg1}\n onChange={setHcg1}\n />\n </FormField>\n <FormField label={t('hcgDoubling.date1')}>\n <DateTimePicker value={date1} onChange={setDate1} maxDate={today} />\n </FormField>\n <FormField\n label={`${t('hcgDoubling.hcg2')} (${t('hcgDoubling.units')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n value={hcg2}\n onChange={setHcg2}\n />\n </FormField>\n <FormField label={t('hcgDoubling.date2')}>\n <DateTimePicker value={date2} onChange={setDate2} maxDate={today} />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('hcgDoubling.doublingLabel')}: ${doublingText(result)}. ${t(\n `hcgDoubling.trend.${result.trend}`,\n )}.`\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-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.doublingLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {doublingText(result)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.riseLabel')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {riseText(result)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('hcgDoubling.trendLabel')}\n </dt>\n <dd>\n <Badge variant={TREND_BADGE[result.trend]} size=\"lg\">\n {t(`hcgDoubling.trend.${result.trend}`)}\n </Badge>\n </dd>\n </div>\n </dl>\n <p className=\"type-body-sm ds:text-muted-foreground\">\n {t('hcgDoubling.disclaimer')}\n </p>\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.hcg'),\n icon: 'activity',\n highlight: t(`hcgDoubling.trend.${result.trend}`),\n highlightToken: TREND_TOKEN[result.trend],\n brand: insertBrand,\n fields: [\n {\n icon: 'clock',\n label: t('hcgDoubling.doublingLabel'),\n value: doublingText(result),\n },\n {\n icon: 'trending-up',\n label: t('hcgDoubling.riseLabel'),\n value: riseText(result),\n },\n {\n icon: 'tag',\n label: t('hcgDoubling.trendLabel'),\n value: t(`hcgDoubling.trend.${result.trend}`),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('hcgDoubling.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nHcgDoubling.displayName = 'HcgDoubling';\n"],"names":["formatISO","date","options","date_","toDate","result","tzOffset","dateDelimiter","timeDelimiter","day","addLeadingZeros","month","offset","absoluteOffset","hourOffset","minuteOffset","hour","minute","second","separator","time","hcgValue","label","sampleTime","hcgDoublingAgent","handle","args","MS_PER_HOUR","MINIMAL_48H_RISE_PERCENT","analyseHcg","input","hcg1","hcg2","date1","date2","intervalHours","ratio","percentRise","twoDayRisePercent","doublingTimeHours","trend","rootVariants","cva","TREND_BADGE","TREND_TOKEN","toIsoDateTime","d","fromIsoDateTime","iso","parseISO","isHcgValue","n","HcgDoubling","forwardRef","defaultDate1","defaultDate2","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","i18n","useTranslation","setHcg1","useState","setDate1","setHcg2","setDate2","today","useMemo","useEffect","liveRef","useRef","agentHandle","live","next","now","parsed","key","isAfter","useAgentRegistration","num","doublingText","r","riseText","jsxs","jsx","FormField","NumberInput","DateTimePicker","Card","Badge","InsertButton"],"mappings":";;;;;;;;;;;;;;AA0CO,SAASA,GAAUC,GAAMC,GAAS;AACvC,QAAMC,IAAQC,GAAOH,GAAMC,KAAA,gBAAAA,EAAS,EAAE;AAEtC,MAAI,MAAM,CAACC,CAAK;AACd,UAAM,IAAI,WAAW,oBAAoB;AAM3C,MAAIE,IAAS,IACTC,IAAW;AAEf,QAAMC,IAAwC,KACxCC,IAAwC;AAGf;AAC7B,UAAMC,IAAMC,EAAgBP,EAAM,QAAO,GAAI,CAAC,GACxCQ,IAAQD,EAAgBP,EAAM,SAAQ,IAAK,GAAG,CAAC;AAIrD,IAAAE,IAAS,GAHIK,EAAgBP,EAAM,YAAW,GAAI,CAAC,CAGnC,GAAGI,CAAa,GAAGI,CAAK,GAAGJ,CAAa,GAAGE,CAAG;AAAA,EAChE;AAG+B;AAE7B,UAAMG,IAAST,EAAM,kBAAiB;AAEtC,QAAIS,MAAW,GAAG;AAChB,YAAMC,IAAiB,KAAK,IAAID,CAAM,GAChCE,IAAaJ,EAAgB,KAAK,MAAMG,IAAiB,EAAE,GAAG,CAAC,GAC/DE,IAAeL,EAAgBG,IAAiB,IAAI,CAAC;AAI3D,MAAAP,IAAW,GAFEM,IAAS,IAAI,MAAM,GAEd,GAAGE,CAAU,IAAIC,CAAY;AAAA,IACjD;AACE,MAAAT,IAAW;AAGb,UAAMU,IAAON,EAAgBP,EAAM,SAAQ,GAAI,CAAC,GAC1Cc,IAASP,EAAgBP,EAAM,WAAU,GAAI,CAAC,GAC9Ce,IAASR,EAAgBP,EAAM,WAAU,GAAI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;AAAA,sBACjC,OAAO,EAAE,qBAAqBA,EAAO,KAAK,EAAE;AAAA,oBAAA;AAAA,kBAC9C;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAsF,EAAC,KAAA,EAAE,WAAU,sCACV,UAAA,EAAE,mBAAmB,EAAA,CACxB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAvC,GAAY,cAAc;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as c, jsxs as O } from "react/jsx-runtime";
|
|
2
2
|
import { useState as k, useEffect as w, useCallback as U, useMemo as z, useRef as J } from "react";
|
|
3
3
|
import { useGridFilter as A } from "ag-grid-react";
|
|
4
|
-
import { D as H } from "./date-range-picker-
|
|
4
|
+
import { D as H } from "./date-range-picker-BD8P_rJq.js";
|
|
5
5
|
import { useTranslation as L } from "react-i18next";
|
|
6
6
|
import { C as Q } from "./checkbox-BuZ1u__2.js";
|
|
7
7
|
import { B as P } from "./button-nJaPh_HC.js";
|
|
@@ -769,4 +769,4 @@ export {
|
|
|
769
769
|
Ae as f,
|
|
770
770
|
qe as g
|
|
771
771
|
};
|
|
772
|
-
//# sourceMappingURL=link-cell-renderer-
|
|
772
|
+
//# sourceMappingURL=link-cell-renderer-BZQtsuFz.js.map
|