@alfadocs/ui-kit 1.135.0 → 1.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/_chunks/{ai-prompt-input-JIPbrTF3.js → ai-prompt-input-CVNeusoW.js} +2 -2
  2. package/dist/_chunks/ai-summary-panel-BhCo2vZF.js +1045 -0
  3. package/dist/_chunks/{alia-sidebar-CtwhdASP.js → alia-sidebar-CVBlKur9.js} +3 -3
  4. package/dist/_chunks/{anamnesis-summary-rows-CCNmkq55.js → anamnesis-summary-rows-Dr2V1Rtf.js} +3 -3
  5. package/dist/_chunks/appointment-details-panel.history-DrIMDQYf.js +314 -0
  6. package/dist/_chunks/appointment-details-panel.identity-C20Y9xNC.js +223 -0
  7. package/dist/_chunks/{audio-recorder-CsnM_WDy.js → audio-recorder-BOF5YYoC.js} +2 -2
  8. package/dist/_chunks/{balance-badge-cell-DTiMdnCZ.js → balance-badge-cell-BSB02Bwo.js} +4 -4
  9. package/dist/_chunks/{bill-line-table-DHKb_O7c.js → bill-line-table-By-YL2ms.js} +2 -2
  10. package/dist/_chunks/{bishop-score-CKztphVz.js → bishop-score-DWGESRP9.js} +2 -2
  11. package/dist/_chunks/calendar-appointment-editor-dialog-D0n_bVsT.js +5518 -0
  12. package/dist/_chunks/calendar-editor-discard-host-1UfmMOEb.js +1336 -0
  13. package/dist/_chunks/calendar-editor-guard-9fShhNIA.js +31 -0
  14. package/dist/_chunks/calendar-waiting-list-panel-Ckd6tSeu.js +981 -0
  15. package/dist/_chunks/calendar-workspace.model-DrOoxY1b.js +1557 -0
  16. package/dist/_chunks/calendar.sheets-Datc0-IT.js +4585 -0
  17. package/dist/_chunks/call-status-chip-pajxN5eZ.js +180 -0
  18. package/dist/_chunks/calls-panel-BIfatK90.js +1094 -0
  19. package/dist/_chunks/{chat-input-CX4dxBq7.js → chat-input-BmvnuZqj.js} +114 -109
  20. package/dist/_chunks/{chat-message-CfIyXrxA.js → chat-message-B4TMeZ2m.js} +35 -30
  21. package/dist/_chunks/circle-x-W8Enq3i4.js +16 -0
  22. package/dist/_chunks/color-picker-CC8ZfntU.js +582 -0
  23. package/dist/_chunks/communications-panel-SQ-55e3V.js +1079 -0
  24. package/dist/_chunks/{data-grid-B2oaI7Lt.js → data-grid-CxKz8flO.js} +2 -2
  25. package/dist/_chunks/{data-table-FTV3uRjX.js → data-table-_tgj0C_T.js} +2 -2
  26. package/dist/_chunks/{default-tabs-DbebYO04.js → default-tabs-oDWQzbN7.js} +3 -3
  27. package/dist/_chunks/{document-preview-DLVIrOYV.js → document-preview-CirR3C_m.js} +3 -3
  28. package/dist/_chunks/entity-summary-CPUHzyil.js +297 -0
  29. package/dist/_chunks/{file-manager-Bzr5NK1t.js → file-manager-CEi4z2i0.js} +2 -2
  30. package/dist/_chunks/{fiscal-code-input-BBvU7sAo.js → fiscal-code-input-DZlpaMGg.js} +2 -2
  31. package/dist/_chunks/{gestational-age-calculator-mB6brTlp.js → gestational-age-calculator-CHbpC4vL.js} +2 -2
  32. package/dist/_chunks/{heatmap-C5gJin_F.js → heatmap-_546qI2V.js} +2 -2
  33. package/dist/_chunks/{iban-input-DuTwKok5.js → iban-input-CdSLRzQN.js} +2 -2
  34. package/dist/_chunks/{invoice-upload-list-B5aMffTy.js → invoice-upload-list-CQI9MUl6.js} +3 -3
  35. package/dist/_chunks/{kit-extensions-DUaIYyMD.js → kit-extensions-BNBf4m8O.js} +3 -3
  36. package/dist/_chunks/{link-cell-renderer-D3JLPURZ.js → link-cell-renderer-Xx5T8u5Q.js} +3 -3
  37. package/dist/_chunks/list-todo-KWvUhmT_.js +33 -0
  38. package/dist/_chunks/{muscle-scheme-BGJD62op.js → muscle-scheme-D_rSyGDj.js} +2 -2
  39. package/dist/_chunks/{notes-panel-BvjAo4RQ.js → notes-panel-DsEKNtsw.js} +2 -2
  40. package/dist/_chunks/{optical-prescription-Da_r8pMr.js → optical-prescription-DaSbsh4p.js} +2 -2
  41. package/dist/_chunks/palettes-CKVXYTzo.js +172 -0
  42. package/dist/_chunks/{patient-account-settings-B2XbN_Fe.js → patient-account-settings-COybehKx.js} +3 -3
  43. package/dist/_chunks/{patient-card-DTh3QTyS.js → patient-card-Cpr8iD19.js} +4 -4
  44. package/dist/_chunks/{patient-check-in-resume-B7NY-6KI.js → patient-check-in-resume-DZnyYDKH.js} +40 -40
  45. package/dist/_chunks/{patient-details-DBtEITfE.js → patient-details-Dv7EiTCo.js} +2 -2
  46. package/dist/_chunks/{patient-field-row-a5d4QijH.js → patient-field-row-DuHWGlLz.js} +3 -3
  47. package/dist/_chunks/patient-picker-BZJuOgMw.js +173 -0
  48. package/dist/_chunks/{patient-sign-in-pin-CDBqV254.js → patient-sign-in-pin-DmMBwWet.js} +2 -2
  49. package/dist/_chunks/{patient-sign-in-steps-C2JSqlok.js → patient-sign-in-steps-BKcxNkdY.js} +37 -59
  50. package/dist/_chunks/{patient-summary-card-Bl2NknPe.js → patient-summary-card-D-cDzOim.js} +2 -2
  51. package/dist/_chunks/phone-off-DQSTLz4l.js +28 -0
  52. package/dist/_chunks/{portal-details-DCIiGkHA.js → portal-details-DdzvroYP.js} +2 -2
  53. package/dist/_chunks/{portal-documents-DJOH8pZx.js → portal-documents-CNmoYWFc.js} +3 -3
  54. package/dist/_chunks/{pregnancy-dating-BNI32qNw.js → pregnancy-dating-lJbzai73.js} +2 -2
  55. package/dist/_chunks/{privacy-mask-C19dJFMk.js → privacy-mask-C2ZLKrMh.js} +5 -5
  56. package/dist/_chunks/{registration-form-DS3RuKHu.js → registration-form-CuLiTA52.js} +2 -2
  57. package/dist/_chunks/{reserved.agent-DOzOBUW7.js → reserved.agent-CabZHFJC.js} +2 -2
  58. package/dist/_chunks/{rich-text-editor-DjHL1b3E.js → rich-text-editor-C48omVjq.js} +2 -2
  59. package/dist/_chunks/{select-uESzXTX6.js → select-CIXKyUMw.js} +172 -149
  60. package/dist/_chunks/{session-countdown-DOx1IBUB.js → session-countdown-StcyUU5O.js} +56 -66
  61. package/dist/_chunks/{signature-request-CHsM_iWi.js → signature-request-vJDSHZld.js} +2 -2
  62. package/dist/_chunks/{tabs-CRIDBLP7.js → tabs-Czkmw5ou.js} +2 -2
  63. package/dist/_chunks/task-editor-wKbFbGqW.js +1093 -0
  64. package/dist/_chunks/{tasks-panel-6EzdnwT8.js → tasks-panel-DbtJS4QI.js} +2 -2
  65. package/dist/_chunks/{toolbar-CfdoJzMV.js → toolbar-DjG-cpD_.js} +2 -2
  66. package/dist/_chunks/{unit-converter-YKlHyUC2.js → unit-converter-CUAUTu2B.js} +2 -2
  67. package/dist/_chunks/use-appointment-details-read-jGkJalX8.js +1966 -0
  68. package/dist/_chunks/{voice-control-panel-Be_c0CQ0.js → voice-control-panel-Cp4vs1iy.js} +2 -2
  69. package/dist/agent-catalog.json +282 -6
  70. package/dist/agent-i18n/en.json +26 -4
  71. package/dist/appointment-editor-panel/index.js +100 -0
  72. package/dist/booking-tools-data/index.js +82 -0
  73. package/dist/browser-support.js +1 -1
  74. package/dist/calendar-action-buttons/index.js +178 -0
  75. package/dist/components/ai-prompt-input/index.js +1 -1
  76. package/dist/components/ai-summary-panel/ai-summary-panel.d.ts +68 -5
  77. package/dist/components/ai-summary-panel/index.d.ts +1 -1
  78. package/dist/components/ai-summary-panel/index.js +1 -1
  79. package/dist/components/ai-summary-panel/summary-markdown.d.ts +15 -0
  80. package/dist/components/appointment-details-panel/index.js +6 -5
  81. package/dist/components/audio-recorder/index.js +1 -1
  82. package/dist/components/bill-line-table/index.js +1 -1
  83. package/dist/components/bill-table/index.js +1 -1
  84. package/dist/components/bishop-score/index.js +1 -1
  85. package/dist/components/booking/index.js +1 -1
  86. package/dist/components/call-status-chip/call-status-chip.d.ts +30 -0
  87. package/dist/components/call-status-chip/index.d.ts +3 -0
  88. package/dist/components/call-status-chip/index.js +5 -0
  89. package/dist/components/calls-panel/calls-panel.agent.d.ts +4 -0
  90. package/dist/components/calls-panel/calls-panel.d.ts +153 -0
  91. package/dist/components/calls-panel/index.d.ts +4 -0
  92. package/dist/components/calls-panel/index.js +6 -0
  93. package/dist/components/chat-input/chat-input.d.ts +17 -0
  94. package/dist/components/chat-input/index.js +1 -1
  95. package/dist/components/chat-message/index.js +1 -1
  96. package/dist/components/color-picker/index.js +5 -4
  97. package/dist/components/communications-panel/communications-panel.d.ts +15 -3
  98. package/dist/components/communications-panel/index.js +1 -1
  99. package/dist/components/data-grid/index.js +2 -2
  100. package/dist/components/data-table/index.js +2 -2
  101. package/dist/components/document-preview/index.js +1 -1
  102. package/dist/components/entity-summary/entity-summary.d.ts +29 -1
  103. package/dist/components/entity-summary/index.js +1 -1
  104. package/dist/components/file-manager/index.js +1 -1
  105. package/dist/components/fiscal-code-input/index.js +1 -1
  106. package/dist/components/gestational-age-calculator/index.js +1 -1
  107. package/dist/components/heatmap/index.js +1 -1
  108. package/dist/components/iban-input/index.js +1 -1
  109. package/dist/components/index.d.ts +2 -0
  110. package/dist/components/invoice-upload-list/index.js +1 -1
  111. package/dist/components/muscle-scheme/index.js +1 -1
  112. package/dist/components/notes-panel/index.js +1 -1
  113. package/dist/components/optical-prescription/index.js +1 -1
  114. package/dist/components/patient-details/index.js +1 -1
  115. package/dist/components/patient-summary-card/index.js +1 -1
  116. package/dist/components/patient-table/index.js +1 -1
  117. package/dist/components/pregnancy-dating/index.js +1 -1
  118. package/dist/components/rich-text-editor/index.js +2 -2
  119. package/dist/components/select/index.js +1 -1
  120. package/dist/components/select/select.d.ts +8 -0
  121. package/dist/components/session-countdown/index.js +1 -1
  122. package/dist/components/skeleton-scheme/index.js +1 -1
  123. package/dist/components/tabs/index.js +1 -1
  124. package/dist/components/task-editor/index.js +1 -1
  125. package/dist/components/tasks-panel/index.js +1 -1
  126. package/dist/components/unit-converter/index.js +1 -1
  127. package/dist/components/voice-control-panel/index.js +1 -1
  128. package/dist/core.css +1 -1
  129. package/dist/find-free-slots-panel/index.js +58 -0
  130. package/dist/host-compat.css +4 -1
  131. package/dist/i18n/locales/ar.d.ts +72 -3
  132. package/dist/i18n/locales/ar.js +74 -5
  133. package/dist/i18n/locales/de.d.ts +72 -3
  134. package/dist/i18n/locales/de.js +74 -5
  135. package/dist/i18n/locales/el.d.ts +72 -3
  136. package/dist/i18n/locales/el.js +74 -5
  137. package/dist/i18n/locales/en.d.ts +72 -3
  138. package/dist/i18n/locales/en.js +73 -4
  139. package/dist/i18n/locales/es.d.ts +72 -3
  140. package/dist/i18n/locales/es.js +74 -5
  141. package/dist/i18n/locales/fr.d.ts +72 -3
  142. package/dist/i18n/locales/fr.js +74 -5
  143. package/dist/i18n/locales/hi.d.ts +72 -3
  144. package/dist/i18n/locales/hi.js +74 -5
  145. package/dist/i18n/locales/it.d.ts +83 -14
  146. package/dist/i18n/locales/it.js +84 -15
  147. package/dist/i18n/locales/ja.d.ts +72 -3
  148. package/dist/i18n/locales/ja.js +74 -5
  149. package/dist/i18n/locales/nl.d.ts +72 -3
  150. package/dist/i18n/locales/nl.js +74 -5
  151. package/dist/i18n/locales/pl.d.ts +72 -3
  152. package/dist/i18n/locales/pl.js +74 -5
  153. package/dist/i18n/locales/pt.d.ts +72 -3
  154. package/dist/i18n/locales/pt.js +74 -5
  155. package/dist/i18n/locales/ro.d.ts +72 -3
  156. package/dist/i18n/locales/ro.js +74 -5
  157. package/dist/i18n/locales/ru.d.ts +72 -3
  158. package/dist/i18n/locales/ru.js +74 -5
  159. package/dist/i18n/locales/sq.d.ts +72 -3
  160. package/dist/i18n/locales/sq.js +74 -5
  161. package/dist/i18n/locales/sv.d.ts +72 -3
  162. package/dist/i18n/locales/sv.js +74 -5
  163. package/dist/i18n/locales/tr.d.ts +72 -3
  164. package/dist/i18n/locales/tr.js +74 -5
  165. package/dist/i18n/locales/zh.d.ts +72 -3
  166. package/dist/i18n/locales/zh.js +74 -5
  167. package/dist/index.js +1329 -1318
  168. package/dist/locales/ar.json +74 -5
  169. package/dist/locales/de.json +74 -5
  170. package/dist/locales/el.json +74 -5
  171. package/dist/locales/en.json +73 -4
  172. package/dist/locales/es.json +74 -5
  173. package/dist/locales/fr.json +74 -5
  174. package/dist/locales/hi.json +74 -5
  175. package/dist/locales/it.json +84 -15
  176. package/dist/locales/ja.json +74 -5
  177. package/dist/locales/nl.json +74 -5
  178. package/dist/locales/pl.json +74 -5
  179. package/dist/locales/pt.json +74 -5
  180. package/dist/locales/ro.json +74 -5
  181. package/dist/locales/ru.json +74 -5
  182. package/dist/locales/sq.json +74 -5
  183. package/dist/locales/sv.json +74 -5
  184. package/dist/locales/tr.json +74 -5
  185. package/dist/locales/zh.json +74 -5
  186. package/dist/online-bookings-panel/index.js +69 -0
  187. package/dist/patterns/alia-assistant/index.js +1 -1
  188. package/dist/patterns/anamnesis/index.js +1 -1
  189. package/dist/patterns/calendar/booking-tools/appointment-editor-panel.d.ts +46 -0
  190. package/dist/patterns/calendar/booking-tools/booking-tools-data.d.ts +48 -0
  191. package/dist/patterns/calendar/booking-tools/calendar-action-buttons.d.ts +55 -0
  192. package/dist/patterns/calendar/booking-tools/find-free-slots-panel.d.ts +35 -0
  193. package/dist/patterns/calendar/booking-tools/online-bookings-panel.d.ts +61 -0
  194. package/dist/patterns/calendar/booking-tools/waiting-list-panel.d.ts +58 -0
  195. package/dist/patterns/calendar/calendar-editor-discard-host.d.ts +20 -0
  196. package/dist/patterns/calendar/calendar-print-sheet.d.ts +16 -0
  197. package/dist/patterns/calendar/calendar-workspace.model.d.ts +7 -0
  198. package/dist/patterns/calendar/calendar.model.d.ts +9 -0
  199. package/dist/patterns/calendar/calendar.sheets.d.ts +59 -17
  200. package/dist/patterns/calendar/index.js +24 -20
  201. package/dist/patterns/patient-account-settings/index.js +1 -1
  202. package/dist/patterns/patient-check-in/index.js +1 -1
  203. package/dist/patterns/patient-portal/index.js +2 -2
  204. package/dist/patterns/patient-sign-in/index.js +2 -2
  205. package/dist/patterns/registration-form/index.js +1 -1
  206. package/dist/patterns/signature-request/index.js +1 -1
  207. package/dist/tokens.css +1 -1
  208. package/dist/waiting-list-panel/index.js +158 -0
  209. package/package.json +35 -2
  210. package/dist/_chunks/ai-summary-panel-B70S2lgC.js +0 -455
  211. package/dist/_chunks/calendar-appointment-editor-dialog-I5PfWudy.js +0 -13773
  212. package/dist/_chunks/color-picker-AcaWuKah.js +0 -745
  213. package/dist/_chunks/communications-panel-BKPHCiMB.js +0 -973
  214. package/dist/_chunks/entity-summary-CpNk6ybN.js +0 -266
  215. package/dist/_chunks/task-editor-DvwqPfFR.js +0 -1257
  216. package/dist/_chunks/use-appointment-details-read-6_OmOwUs.js +0 -2476
@@ -1,1257 +0,0 @@
1
- import { jsx as n, jsxs as k, Fragment as Ne } from "react/jsx-runtime";
2
- import { useState as V, useRef as S, useEffect as qe, forwardRef as xt, useId as At, useMemo as Oe } from "react";
3
- import { c as ht } from "./index-D2ZczOXr.js";
4
- import { useTranslation as gt } from "react-i18next";
5
- import { A as q } from "./alert-C4WKViaS.js";
6
- import { B as Te } from "./button-DohK_Ak_.js";
7
- import { I as We } from "./icon-button-S8_weU3g.js";
8
- import { C as Qe } from "./combobox-BBCVQS-S.js";
9
- import { D as de } from "./dialog-CVTxyR0v.js";
10
- import { D as Ft } from "./date-picker-BmVBVpVu.js";
11
- import { F as H } from "./form-field-CyHfOVKF.js";
12
- import { I as Pt } from "./icon-button-group-SmkdVCNx.js";
13
- import { P as Ot } from "./panel-header-CbtlTe85.js";
14
- import { P as jt } from "./panel-subview-DCyvn-49.js";
15
- import { R as je } from "./radio-BZQs6_36.js";
16
- import { R as Mt } from "./radio-group-ChIKyeSJ.js";
17
- import { S as $t } from "./scroll-area-CY5SLYNw.js";
18
- import { S as Ke } from "./select-uESzXTX6.js";
19
- import { S as He } from "./skeleton-tTWJpvAq.js";
20
- import { S as qt } from "./switch-DO6uC4HJ.js";
21
- import { T as Vt } from "./text-area-COMVJ1yE.js";
22
- import { T as Me } from "./text-input-B6iAgCr3.js";
23
- import { T as _t } from "./time-picker-DDr5vhwQ.js";
24
- import { u as zt } from "./registry-DvAUVLHh.js";
25
- import { u as Lt } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
26
- import { c as Ut } from "./compose-refs-C0k0tdqF.js";
27
- import { E as Wt, a as Kt } from "./compact-editor-fields-cP6yh7xv.js";
28
- import { n as Ht } from "./normalize-diacritics-BNGbFNlJ.js";
29
- import { a as Gt } from "./privacy-mask-C19dJFMk.js";
30
- import { g as $e } from "./get-error-message-DbFUzuja.js";
31
- import { h as Qt } from "./handled-rejection-C-6Dq0As.js";
32
- import { L as Yt } from "./lock-ClAFG1gy.js";
33
- import { X as Xt } from "./x-B5YnXwCz.js";
34
- import { C as Jt } from "./circle-off-DuT9pVy2.js";
35
- import { U as Zt } from "./user-B12p7bVF.js";
36
- import { B as en } from "./building-2-D33bLCWL.js";
37
- import { S as tn } from "./stethoscope-sZXGC43m.js";
38
- import { T as dt } from "./trash-2-uumy3fy1.js";
39
- import { S as ct } from "./square-check-big-dj0o8yA3.js";
40
- import { p as nn } from "./privacy-mask-text-B8YfzB7L.js";
41
- import { L as on } from "./loader-circle-BECIU_8N.js";
42
- import { c as rn } from "./createLucideIcon-DhHxpK9K.js";
43
- /**
44
- * @license lucide-react v1.22.0 - ISC
45
- *
46
- * This source code is licensed under the ISC license.
47
- * See the LICENSE file in the root directory of this source tree.
48
- */
49
- const an = [
50
- [
51
- "path",
52
- {
53
- d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
54
- key: "1c8476"
55
- }
56
- ],
57
- ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
58
- ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
59
- ], sn = rn("save", an);
60
- function vt({
61
- action: o,
62
- typedRef: s
63
- }) {
64
- return /* @__PURE__ */ n(
65
- Te,
66
- {
67
- type: "button",
68
- size: "sm",
69
- intent: "outline",
70
- className: "ds:self-start",
71
- loading: o.loading,
72
- "data-action": "create-patient",
73
- onClick: () => o.onCreate(s.current),
74
- children: o.label
75
- }
76
- );
77
- }
78
- function dn({
79
- patients: o = [],
80
- searchPatients: s,
81
- ...v
82
- }) {
83
- return s ? /* @__PURE__ */ n(ln, { ...v, searchPatients: s }) : /* @__PURE__ */ n(cn, { ...v, patients: o });
84
- }
85
- function cn({
86
- value: o,
87
- onValueChange: s,
88
- patients: v,
89
- selectedLabel: D,
90
- placeholder: O,
91
- size: R,
92
- disabled: G,
93
- createAction: T
94
- }) {
95
- const A = S(""), z = /* @__PURE__ */ n(
96
- Qe,
97
- {
98
- value: o,
99
- onValueChange: s,
100
- onQueryChange: (w) => {
101
- A.current = w;
102
- },
103
- options: [
104
- ...o && !v.some((w) => w.id === o) ? [{ value: o, label: D ?? "" }] : [],
105
- ...v.map((w) => ({ value: w.id, label: w.name }))
106
- ],
107
- placeholder: O,
108
- size: R,
109
- disabled: G,
110
- clearable: !0
111
- }
112
- );
113
- return T ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
114
- z,
115
- o || G ? null : /* @__PURE__ */ n(vt, { action: T, typedRef: A })
116
- ] }) : z;
117
- }
118
- function ln({
119
- value: o,
120
- onValueChange: s,
121
- selectedLabel: v,
122
- placeholder: D,
123
- size: O,
124
- disabled: R,
125
- searchPatients: G,
126
- createAction: T
127
- }) {
128
- const { t: A } = gt("ui"), [z, w] = V(""), [J, Z] = V(0), [Q, ee] = V(), [j, M] = V(), re = S(null), L = S(""), U = z.trim();
129
- qe(() => {
130
- if (!U) return;
131
- const m = new AbortController(), f = { query: U, source: G };
132
- M({ ...f, status: "loading", patients: [] });
133
- const u = setTimeout(() => {
134
- Promise.resolve().then(() => G(U, { signal: m.signal })).then(
135
- (ie) => {
136
- m.signal.aborted || M({ ...f, status: "ready", patients: ie });
137
- },
138
- () => {
139
- m.signal.aborted || M({ ...f, status: "error", patients: [] });
140
- }
141
- );
142
- }, 250);
143
- return () => {
144
- clearTimeout(u), m.abort();
145
- };
146
- }, [U, G, J]);
147
- const pe = (j == null ? void 0 : j.query) === U && j.source === G, F = U ? pe ? j.status : "loading" : "idle", N = pe && F === "ready" ? j.patients : [], ae = F === "loading" ? A("inputs.search.loading") : F === "error" ? A("emptyState.error.description") : F === "idle" ? D : N.length === 0 ? A("inputs.combobox.empty") : "", we = !!T && !o && !R, me = N.map((m) => ({
148
- value: m.id,
149
- label: m.name
150
- }));
151
- return o && !N.some((m) => m.id === o) && me.push({
152
- value: o,
153
- label: (Q == null ? void 0 : Q.id) === o ? Q.name : v ?? ""
154
- }), /* @__PURE__ */ k(
155
- "div",
156
- {
157
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
158
- "data-component": "patient-picker",
159
- "data-status": F,
160
- children: [
161
- /* @__PURE__ */ n(
162
- Qe,
163
- {
164
- ref: re,
165
- options: me,
166
- value: o,
167
- onValueChange: (m) => {
168
- ee(
169
- (f) => N.find((u) => u.id === m) ?? ((f == null ? void 0 : f.id) === m ? f : void 0)
170
- ), s(m);
171
- },
172
- onQueryChange: (m) => {
173
- L.current = m, w(m);
174
- },
175
- onOpenChange: (m) => {
176
- !m && F !== "error" && w("");
177
- },
178
- filter: (m) => !U || N.some((f) => Ht(f.id) === m) ? 1 : 0,
179
- size: O,
180
- disabled: R,
181
- placeholder: D,
182
- emptyMessage: ae || void 0,
183
- clearable: !0
184
- }
185
- ),
186
- /* @__PURE__ */ n("p", { role: "status", className: "type-body-sm ds:text-muted-foreground", children: ae }),
187
- we && T ? /* @__PURE__ */ n(vt, { action: T, typedRef: L }) : null,
188
- F === "error" ? /* @__PURE__ */ n(
189
- Te,
190
- {
191
- size: "sm",
192
- intent: "ghost",
193
- onClick: () => {
194
- var m;
195
- Z((f) => f + 1), (m = re.current) == null || m.focus();
196
- },
197
- children: A("emptyState.error.cta")
198
- }
199
- ) : null
200
- ]
201
- }
202
- );
203
- }
204
- const un = {
205
- id: "task-editor",
206
- // set_value backs set_fields and set_done; submit backs save; dismiss
207
- // backs cancel.
208
- capabilities: ["set_value", "submit", "dismiss"],
209
- state: {
210
- status: {
211
- type: "'loading' | 'ready' | 'error' | 'locked' | 'withheld'",
212
- descriptionKey: "ui.agent.taskEditor.state.status",
213
- description: "Where the form is: loading the task, ready, failed to load, locked (edit mode with nothing to load) or withheld behind the privacy notice. Writes need 'ready'.",
214
- read: (o) => o.getStatus()
215
- },
216
- draft: {
217
- type: "{ mode: string; dateIso: string | null; about: string; patientId: string | null; companyId: string | null; operatorId: string | null; typeId: string | null; assigneeId: string | null; done: boolean; hasNote: boolean; noteLength: number }",
218
- descriptionKey: "ui.agent.taskEditor.state.draft",
219
- description: "The draft as Save would send it: ids and structure only, never the note body. done is the last value the host confirmed.",
220
- read: (o) => o.getDraft()
221
- },
222
- canSave: {
223
- type: "boolean",
224
- descriptionKey: "ui.agent.taskEditor.state.canSave",
225
- description: "Whether save would reach the host now: the form is ready, the note is filled, a chosen counterpart has an id and no write is pending.",
226
- read: (o) => o.canSave()
227
- }
228
- },
229
- actions: {
230
- set_fields: {
231
- safety: "phi",
232
- argsType: "{ dateIso?: string; note?: string; typeId?: string; assigneeId?: string | null; about?: 'nobody' | 'patient' | 'company' | 'operator'; patientId?: string; companyId?: string; operatorId?: string }",
233
- argsSchema: {
234
- type: "object",
235
- properties: {
236
- dateIso: { type: "string", format: "date-time" },
237
- note: { type: "string" },
238
- typeId: { type: "string" },
239
- assigneeId: { type: ["string", "null"] },
240
- about: {
241
- type: "string",
242
- enum: ["nobody", "patient", "company", "operator"]
243
- },
244
- patientId: { type: "string" },
245
- companyId: { type: "string" },
246
- operatorId: { type: "string" }
247
- }
248
- },
249
- idempotent: !0,
250
- errors: [
251
- "An id the host lists, its patient search or the stored task do not resolve.",
252
- "More than one of patientId, companyId and operatorId.",
253
- "The form is not ready, is read-only or is withheld."
254
- ],
255
- descriptionKey: "ui.agent.taskEditor.actions.setFields",
256
- description: "Set draft fields. Ids must come from the host lists, a patient the host search returned, or equal the stored one. At most one counterpart per call, and it selects its branch; assigneeId null is nobody. Nothing is saved.",
257
- invoke: (o, s) => {
258
- o.setFields(s);
259
- }
260
- },
261
- save: {
262
- safety: "phi",
263
- // Reaches the host's data source; the result is the host's promise.
264
- openWorld: !0,
265
- descriptionKey: "ui.agent.taskEditor.actions.save",
266
- description: "Save the task through the host. Resolves once the write lands and rejects with the host error, which the form also shows.",
267
- invoke: (o) => o.save()
268
- },
269
- set_done: {
270
- safety: "write",
271
- argsType: "{ done: boolean }",
272
- argsSchema: {
273
- type: "object",
274
- properties: { done: { type: "boolean" } },
275
- required: ["done"]
276
- },
277
- openWorld: !0,
278
- errors: [
279
- "The form is not ready, is read-only or has no Done seam.",
280
- "A save, a delete or another Done change is in flight.",
281
- "The task was already saved or deleted in this session."
282
- ],
283
- descriptionKey: "ui.agent.taskEditor.actions.setDone",
284
- description: "Mark an existing task done or not done through the host. A rejection rolls the switch back.",
285
- invoke: (o, s) => o.setDone(s.done)
286
- },
287
- delete: {
288
- safety: "destructive",
289
- idempotent: !0,
290
- openWorld: !0,
291
- descriptionKey: "ui.agent.taskEditor.actions.delete",
292
- description: "Delete the task through the host, without the confirmation dialog. Resolves once the delete lands.",
293
- invoke: (o) => o.deleteTask()
294
- },
295
- cancel: {
296
- safety: "destructive",
297
- errors: ["A save or delete is in flight: wait for it to settle."],
298
- descriptionKey: "ui.agent.taskEditor.actions.cancel",
299
- description: "Close the editor without saving. Anything typed since the last save is lost. Refused while a save or delete is in flight.",
300
- invoke: (o) => {
301
- o.cancel();
302
- }
303
- }
304
- },
305
- domHooks: {
306
- root: {
307
- attr: "data-component",
308
- value: "task-editor",
309
- description: "Marks the TaskEditor body. It also carries data-variant and data-status. In the subview variant it sits inside the panel-subview section, which repeats data-component-id, data-variant and data-status and holds the heading and footer."
310
- },
311
- instanceId: {
312
- attr: "data-component-id",
313
- sourceProp: "id",
314
- description: "Sourced from the id prop, or generated. Addresses one editor from the agent. [data-component-id] reaches the footer actions in both variants."
315
- }
316
- }
317
- }, _ = "none", lt = {
318
- showError: !1,
319
- saving: !1,
320
- saveError: void 0,
321
- done: !1,
322
- confirmedDone: !1,
323
- donePending: !1,
324
- doneError: void 0,
325
- deleting: !1,
326
- deleteError: void 0,
327
- confirmDeleteOpen: !1,
328
- accepted: !1
329
- };
330
- function pn(o) {
331
- return o.patientId ? "patient" : o.companyId ? "company" : o.operatorId ? "operator" : "nobody";
332
- }
333
- function Ye(o) {
334
- return { hours: o.getHours(), minutes: o.getMinutes() };
335
- }
336
- function ut(o) {
337
- const s = o ?? /* @__PURE__ */ new Date();
338
- return {
339
- date: s,
340
- time: Ye(s),
341
- note: "",
342
- operatorId: _,
343
- typeId: "",
344
- assigneeId: _,
345
- about: "nobody",
346
- patientId: "",
347
- companyId: ""
348
- };
349
- }
350
- function mn(o) {
351
- const s = new Date(o.dateIso);
352
- return {
353
- date: s,
354
- time: Ye(s),
355
- note: o.note,
356
- /* `||`, not `??`: a host's '' is unset, like patient and company. */
357
- operatorId: o.operatorId || _,
358
- /* A stored type wins. With none, '' falls through to the first entry. */
359
- typeId: o.typeId ?? "",
360
- /* `||` too: '' would become a Select option with an empty value. */
361
- assigneeId: o.assigneeId || _,
362
- about: pn(o),
363
- patientId: o.patientId ?? "",
364
- companyId: o.companyId ?? ""
365
- };
366
- }
367
- const fn = [
368
- ["patientId", "patient"],
369
- ["companyId", "company"],
370
- ["operatorId", "operator"]
371
- ];
372
- function hn({
373
- mode: o,
374
- taskId: s,
375
- initialDate: v,
376
- active: D,
377
- taskTypes: O,
378
- assignees: R,
379
- companies: G,
380
- operators: T,
381
- patients: A,
382
- searchedPatients: z,
383
- resolvePatientLabel: w,
384
- loadTask: J,
385
- onCreateTask: Z,
386
- onUpdateTask: Q,
387
- onDeleteTask: ee,
388
- onSetTaskDone: j,
389
- onSaved: M,
390
- onDeleted: re,
391
- readOnly: L,
392
- withheld: U,
393
- maskPatient: pe,
394
- fallbackError: F
395
- }) {
396
- var Ce;
397
- const N = o === "edit", [ae, we] = V(0), [me, m] = V(D);
398
- me !== D && (m(D), D && we((e) => e + 1));
399
- const f = `${o}|${s ?? ""}|${ae}`, [u, ie] = V(
400
- () => ut(v)
401
- ), [Y, Ee] = V(lt), [I, r] = V(), E = (e) => Ee((i) => ({ ...i, ...e })), fe = (e) => ie((i) => ({ ...i, ...e })), [he, te] = V(f);
402
- he !== f && (te(f), ie(ut(v)), Ee(lt), r(void 0));
403
- const P = S({
404
- subject: f,
405
- saving: !1,
406
- deleting: !1,
407
- donePending: !1,
408
- accepted: !1
409
- });
410
- P.current.subject !== f && (P.current = {
411
- subject: f,
412
- saving: !1,
413
- deleting: !1,
414
- donePending: !1,
415
- accepted: !1
416
- });
417
- const ge = S(!0);
418
- qe(() => (ge.current = !0, () => {
419
- ge.current = !1;
420
- }), []);
421
- const B = (e) => ge.current && P.current === e, ce = S(J);
422
- ce.current = J;
423
- const c = !!J, [x, l] = V(0), [d, h] = V(null), ke = S(d);
424
- ke.current = d;
425
- const ve = D && N && !!s && c && !U;
426
- qe(() => {
427
- const e = ce.current;
428
- if (!ve || !s || !e) return;
429
- const i = P.current, g = ke.current;
430
- if ((g == null ? void 0 : g.subject) === i.subject && g.status === "ready")
431
- return;
432
- const p = new AbortController();
433
- return Promise.resolve().then(
434
- () => (
435
- /* Cleaned up before this ran (StrictMode's replay, a quick re-run):
436
- never call the host with a signal already aborted. */
437
- p.signal.aborted ? Promise.reject(p.signal.reason) : e(s, { signal: p.signal })
438
- )
439
- ).then(
440
- (y) => {
441
- p.signal.aborted || !B(i) || (ie(mn(y)), E({ done: y.done, confirmedDone: y.done }), r(y), h({ subject: i.subject, status: "ready" }));
442
- },
443
- (y) => {
444
- p.signal.aborted || !B(i) || h({
445
- subject: i.subject,
446
- status: "error",
447
- message: $e(y, F)
448
- });
449
- }
450
- ), () => p.abort();
451
- }, [ve, f, x]);
452
- const $ = N ? !s || !c ? "locked" : U ? "withheld" : (d == null ? void 0 : d.subject) === f ? d.status : "loading" : "ready", X = () => {
453
- $ === "error" && (h(null), l((e) => e + 1));
454
- }, le = u.typeId || (((Ce = O[0]) == null ? void 0 : Ce.id) ?? ""), Ve = u.about === "nobody" || u.about === "patient" && u.patientId !== "" || u.about === "company" && u.companyId !== "" || u.about === "operator" && u.operatorId !== _, ue = !L && u.note.trim() !== "" && u.date !== void 0 && Ve && /* Required whenever the host offers a list. */
455
- (O.length === 0 || le !== "") && !Y.saving && !Y.donePending, ye = N ? Q : Z, Se = () => {
456
- const { date: e, time: i } = u;
457
- return e ? {
458
- dateIso: new Date(
459
- e.getFullYear(),
460
- e.getMonth(),
461
- e.getDate(),
462
- i.hours,
463
- i.minutes,
464
- 0,
465
- 0
466
- ).toISOString(),
467
- note: u.note.trim(),
468
- /* Sent whatever the host's list says, including a value the list no
469
- longer resolves: a real link must survive a Save that never
470
- offered to change it. */
471
- typeId: le === "" ? void 0 : le,
472
- assigneeId: u.assigneeId === _ ? void 0 : u.assigneeId,
473
- /* ONE counterpart, decided by `about` alone: the platform refuses a
474
- task carrying two. Never gated on a list being loaded, or a list
475
- that empties mid-edit would unlink the task on Save. */
476
- patientId: u.about === "patient" && u.patientId ? u.patientId : void 0,
477
- companyId: u.about === "company" && u.companyId ? u.companyId : void 0,
478
- operatorId: u.about === "operator" && u.operatorId !== _ ? u.operatorId : void 0,
479
- /* The last CONFIRMED value only, never an optimistic or rolled-back
480
- toggle. */
481
- done: Y.confirmedDone
482
- } : void 0;
483
- }, C = (e) => Qt(new Error(`TaskEditor: ${e}`)), Be = () => {
484
- const e = P.current;
485
- if ($ !== "ready") return C(`cannot save while ${$}.`);
486
- if (!ye) return C("the host gave no save seam.");
487
- if (e.accepted) return C("this task was already saved.");
488
- if (e.deleting) return C("a delete is in flight.");
489
- if (e.saving || !ue) return C("the task cannot be saved.");
490
- const i = Se();
491
- if (!i)
492
- return E({ showError: !0 }), C("the task has no date.");
493
- const g = s;
494
- e.saving = !0, E({ saving: !0, saveError: void 0 });
495
- const p = (async () => {
496
- try {
497
- if (N)
498
- await (Q == null ? void 0 : Q(g, i)), e.accepted = !0, B(e) && (E({ accepted: !0 }), M == null || M({
499
- ...i,
500
- id: g,
501
- done: i.done ?? !1
502
- }));
503
- else {
504
- const y = await (Z == null ? void 0 : Z(i));
505
- e.accepted = !0, B(e) && (E({ accepted: !0 }), y && (M == null || M(y)));
506
- }
507
- } catch (y) {
508
- throw B(e) && E({ saveError: $e(y, F) }), y;
509
- } finally {
510
- e.saving = !1, B(e) && E({ saving: !1 });
511
- }
512
- })();
513
- return p.catch(() => {
514
- }), p;
515
- }, xe = (e) => {
516
- const i = P.current;
517
- if ($ !== "ready")
518
- return C(`cannot change Done while ${$}.`);
519
- if (!N || !s || !j || L)
520
- return C("the host gave no Done seam.");
521
- if (i.donePending) return C("a Done change is already pending.");
522
- if (i.saving || i.deleting)
523
- return C("a save or delete is in flight.");
524
- if (i.accepted)
525
- return C("this task was already saved or deleted.");
526
- if (e === Y.done) return Promise.resolve();
527
- const g = Y.confirmedDone, p = s;
528
- i.donePending = !0, E({ done: e, donePending: !0, doneError: void 0 });
529
- const y = (async () => {
530
- try {
531
- await j(p, e), B(i) && E({ confirmedDone: e });
532
- } catch (W) {
533
- throw B(i) && E({
534
- done: g,
535
- doneError: $e(W, F)
536
- }), W;
537
- } finally {
538
- i.donePending = !1, B(i) && E({ donePending: !1 });
539
- }
540
- })();
541
- return y.catch(() => {
542
- }), y;
543
- }, Ae = () => {
544
- const e = P.current;
545
- if ($ !== "ready") return C(`cannot delete while ${$}.`);
546
- if (!N || !s || !ee || L)
547
- return C("the host gave no delete seam.");
548
- if (e.saving || e.accepted || e.deleting)
549
- return C("the task cannot be deleted now.");
550
- const i = s;
551
- e.deleting = !0, E({ deleting: !0, deleteError: void 0 });
552
- const g = (async () => {
553
- try {
554
- await ee(i), e.accepted = !0, B(e) && (E({ accepted: !0, confirmDeleteOpen: !1 }), re == null || re(i));
555
- } catch (p) {
556
- throw B(e) && E({ deleteError: $e(p, F) }), p;
557
- } finally {
558
- e.deleting = !1, B(e) && E({ deleting: !1 });
559
- }
560
- })();
561
- return g.catch(() => {
562
- }), g;
563
- }, se = (e, i, g) => (
564
- /* '' is never an id, even when the stored record holds one. */
565
- i !== "" && (i === g || e.some((p) => p.id === i))
566
- ), be = (e) => {
567
- var y;
568
- if ($ !== "ready")
569
- throw new Error(`TaskEditor: cannot set fields while ${$}.`);
570
- if (L) throw new Error("TaskEditor: the task is read-only.");
571
- const i = fn.filter(([W]) => e[W] !== void 0);
572
- if (i.length > 1)
573
- throw new Error(
574
- "TaskEditor: set at most one of patientId, companyId and operatorId."
575
- );
576
- const g = (y = i[0]) == null ? void 0 : y[1];
577
- if (e.about !== void 0 && g && e.about !== g)
578
- throw new Error(
579
- `TaskEditor: about "${e.about}" does not match the ${g} id.`
580
- );
581
- if (e.typeId !== void 0 && !se(O, e.typeId, I == null ? void 0 : I.typeId))
582
- throw new Error(`TaskEditor: unknown typeId "${e.typeId}".`);
583
- if (e.assigneeId !== void 0 && e.assigneeId !== null && !se(R, e.assigneeId, I == null ? void 0 : I.assigneeId))
584
- throw new Error(`TaskEditor: unknown assigneeId "${e.assigneeId}".`);
585
- if (e.companyId !== void 0 && !se(G, e.companyId, I == null ? void 0 : I.companyId))
586
- throw new Error(`TaskEditor: unknown companyId "${e.companyId}".`);
587
- if (e.operatorId !== void 0 && !se(T, e.operatorId, I == null ? void 0 : I.operatorId))
588
- throw new Error(`TaskEditor: unknown operatorId "${e.operatorId}".`);
589
- if (e.patientId !== void 0) {
590
- if (pe)
591
- throw new Error("TaskEditor: no patient can be set in privacy mode.");
592
- if (!(se(A, e.patientId, I == null ? void 0 : I.patientId) || z.has(e.patientId) || (w == null ? void 0 : w(e.patientId)) !== void 0))
593
- throw new Error(`TaskEditor: unknown patientId "${e.patientId}".`);
594
- }
595
- const p = {};
596
- if (e.dateIso !== void 0) {
597
- const W = new Date(e.dateIso);
598
- if (Number.isNaN(W.getTime()))
599
- throw new Error(`TaskEditor: "${e.dateIso}" is not a date.`);
600
- p.date = W, p.time = Ye(W);
601
- }
602
- e.note !== void 0 && (p.note = e.note), e.typeId !== void 0 && (p.typeId = e.typeId), e.assigneeId !== void 0 && (p.assigneeId = e.assigneeId ?? _), e.about !== void 0 && (p.about = e.about), e.patientId !== void 0 && (p.patientId = e.patientId, p.about = "patient"), e.companyId !== void 0 && (p.companyId = e.companyId, p.about = "company"), e.operatorId !== void 0 && (p.operatorId = e.operatorId, p.about = "operator"), fe(p);
603
- }, Fe = () => {
604
- const e = Se();
605
- return {
606
- mode: o,
607
- dateIso: (e == null ? void 0 : e.dateIso) ?? null,
608
- about: u.about,
609
- patientId: (e == null ? void 0 : e.patientId) ?? null,
610
- companyId: (e == null ? void 0 : e.companyId) ?? null,
611
- operatorId: (e == null ? void 0 : e.operatorId) ?? null,
612
- typeId: (e == null ? void 0 : e.typeId) ?? null,
613
- assigneeId: (e == null ? void 0 : e.assigneeId) ?? null,
614
- done: Y.confirmedDone,
615
- hasNote: u.note.trim() !== "",
616
- noteLength: u.note.trim().length
617
- };
618
- };
619
- return {
620
- status: $,
621
- loadError: (d == null ? void 0 : d.subject) === f ? d.message : void 0,
622
- retry: X,
623
- fields: u,
624
- patchFields: fe,
625
- stored: I,
626
- chosenTypeId: le,
627
- canSave: ue,
628
- /** What the agent's `canSave` reports: the button's rule plus the
629
- * status, the seam and a save that has not landed yet. */
630
- agentCanSave: $ === "ready" && !!ye && ue && !Y.accepted,
631
- showSave: !L && !!ye,
632
- showDelete: N && !L && !!ee && !!s,
633
- showDone: N && !L && !!j,
634
- ui: Y,
635
- patchUi: E,
636
- /** True once a save or delete landed in this session. */
637
- isAccepted: () => P.current.accepted,
638
- /** A save or delete is in flight: closing now would lose its outcome. */
639
- isBusy: () => P.current.saving || P.current.deleting,
640
- submit: Be,
641
- setDone: xe,
642
- remove: Ae,
643
- applyPatch: be,
644
- draftState: Fe
645
- };
646
- }
647
- const pt = ht("ds:flex ds:min-h-0 ds:flex-col", {
648
- variants: {
649
- /** The panel fills its box; the subview body sits in its scroll area. */
650
- variant: {
651
- /* Focusable from script only, as the subview section is: where focus
652
- waits when a control takes itself away. */
653
- panel: "ds:h-full ds:focus-visible:outline-none",
654
- /* The states pad themselves, so the subview's ring inset is cancelled. */
655
- subview: "ds:-m-[var(--panel-subview-inset)]"
656
- }
657
- },
658
- defaultVariants: { variant: "panel" }
659
- }), mt = ht(
660
- `ds:m-0 ds:min-w-0 ds:border-0 ds:p-[var(--spacing-md)] ${Kt}`,
661
- {
662
- variants: {
663
- /** 'form': the fields in a column. 'notice': the locked notice. */
664
- layout: {
665
- form: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
666
- notice: "ds:flex-1"
667
- }
668
- },
669
- defaultVariants: { layout: "form" }
670
- }
671
- ), a = (o) => `calendarWorkspace.taskEditor.${o}`, gn = (o, s, v) => v.includes(s) ? 1 : 0, Re = [], Ge = (o, s) => Array.from(o.querySelectorAll("[data-task-id]")).filter(
672
- (v) => !s.contains(v)
673
- ), vn = 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])', ft = (o, s) => {
674
- if (!o) return [];
675
- const v = Array.from(
676
- o.querySelectorAll("[data-action]")
677
- );
678
- return [
679
- ...v.filter((D) => s && D.dataset.action === s),
680
- ...v.filter((D) => D.dataset.action === "open-task"),
681
- ...Array.from(o.querySelectorAll(vn))
682
- ];
683
- }, yn = xt(
684
- ({
685
- id: o,
686
- mode: s,
687
- taskId: v,
688
- initialDate: D,
689
- variant: O = "panel",
690
- open: R = !0,
691
- onExited: G,
692
- taskTypes: T = Re,
693
- assignees: A = Re,
694
- companies: z = Re,
695
- operators: w = Re,
696
- patients: J = Re,
697
- searchPatients: Z,
698
- patientLabel: Q,
699
- resolvePatientLabel: ee,
700
- companyLabel: j,
701
- operatorLabel: M,
702
- backLabel: re,
703
- loadTask: L,
704
- onCreateTask: U,
705
- onUpdateTask: pe,
706
- onDeleteTask: F,
707
- onSetTaskDone: N,
708
- onCancel: ae,
709
- onSaved: we,
710
- onDeleted: me,
711
- readOnly: m = !1,
712
- privacy: f = !1,
713
- privacyMode: u = "notice",
714
- onPrivacyOff: ie,
715
- className: Y,
716
- ...Ee
717
- }, I) => {
718
- const { t: r } = gt("ui"), E = At(), fe = o ?? E, he = s === "edit", te = O === "subview", P = !te || R, ge = f && he && u === "notice", B = f && !ge, [ce] = V(() => /* @__PURE__ */ new Map()), c = hn({
719
- mode: s,
720
- taskId: v,
721
- initialDate: D,
722
- active: P,
723
- taskTypes: T,
724
- assignees: A,
725
- companies: z,
726
- operators: w,
727
- patients: J,
728
- searchedPatients: ce,
729
- resolvePatientLabel: ee,
730
- loadTask: L,
731
- onCreateTask: U,
732
- onUpdateTask: pe,
733
- onDeleteTask: F,
734
- onSetTaskDone: N,
735
- onSaved: we,
736
- onDeleted: me,
737
- readOnly: m,
738
- withheld: ge,
739
- maskPatient: B,
740
- fallbackError: r("emptyState.error.title")
741
- }), { status: x, fields: l, ui: d, stored: h } = c, ke = S(Z);
742
- ke.current = Z;
743
- const ve = !!Z, $ = Oe(
744
- () => ve ? async (t, b) => {
745
- const K = await ke.current(t, b);
746
- for (const oe of K)
747
- ce.set(oe.id, oe.name);
748
- return K;
749
- } : void 0,
750
- [ve, ce]
751
- ), X = S(c);
752
- X.current = c;
753
- const le = S(ae);
754
- le.current = ae;
755
- const Ve = Oe(
756
- () => ({
757
- getStatus: () => X.current.status,
758
- getDraft: () => X.current.draftState(),
759
- canSave: () => X.current.agentCanSave,
760
- setFields: (t) => X.current.applyPatch(t),
761
- save: () => X.current.submit(),
762
- setDone: (t) => X.current.setDone(t),
763
- deleteTask: () => X.current.remove(),
764
- cancel: () => {
765
- if (X.current.isBusy())
766
- throw new Error("TaskEditor: a save or delete is in flight.");
767
- le.current();
768
- }
769
- }),
770
- []
771
- );
772
- zt(un, P ? Ve : null, fe);
773
- const ue = S(null), ye = Oe(
774
- () => Ut(I, ue),
775
- [I]
776
- ), Se = S(null), C = S(null), Be = S(!1);
777
- te && R && !Be.current && (C.current = typeof document < "u" && document.activeElement instanceof HTMLElement ? document.activeElement : null), Be.current = te && R;
778
- const xe = S(R);
779
- xe.current = R;
780
- const Ae = S(v);
781
- Ae.current = he ? v : void 0, qe(() => {
782
- var st;
783
- const t = ue.current, b = t == null ? void 0 : t.parentElement;
784
- if (!te || !R || !t || !b) return;
785
- const K = C.current, oe = K && b.contains(K) && !t.contains(K) ? K : null, Tt = Ae.current, De = (oe == null ? void 0 : oe.closest("[data-task-id]")) ?? Ge(b, t).find((Pe) => Pe.dataset.taskId === Tt), rt = De == null ? void 0 : De.dataset.taskId, at = (st = oe == null ? void 0 : oe.closest("[data-action]")) == null ? void 0 : st.dataset.action, it = De ? Ge(b, t).indexOf(De) : -1;
786
- return () => {
787
- if (xe.current && t.isConnected) return;
788
- const Pe = document.activeElement;
789
- if (!b.isConnected || Pe && Pe !== document.body) return;
790
- const Ue = Ge(b, t), Bt = [
791
- ...ft(
792
- Ue.find((Ie) => rt !== void 0 && Ie.dataset.taskId === rt),
793
- at
794
- ),
795
- /* The row that took its place, or the last row when it was last. */
796
- ...it >= 0 ? ft(Ue[Math.min(it, Ue.length - 1)], at) : [],
797
- b.querySelector('[data-action="add-task"]'),
798
- b.querySelector("[data-tasks-panel-region]")
799
- ];
800
- for (const Ie of Bt)
801
- if (!(!Ie || t.contains(Ie)) && (Ie.focus(), document.activeElement === Ie))
802
- return;
803
- };
804
- }, [R, te]);
805
- const se = S(null), be = S(!1), Fe = (t) => () => {
806
- be.current = !0, t();
807
- };
808
- Lt(() => {
809
- var K;
810
- if (!be.current) return;
811
- const t = ue.current, b = document.activeElement;
812
- if (b && b !== document.body && b !== t) {
813
- be.current = !1;
814
- return;
815
- }
816
- x !== "loading" && (be.current = !1), (K = x === "error" ? se.current : t) == null || K.focus({
817
- preventScroll: !0
818
- });
819
- }, [x]);
820
- const Ce = r(a(he ? "editTitle" : "title")), e = z.length > 0, i = w.length > 0, g = ve || J.length > 0, p = Oe(
821
- () => z.map((t) => ({ value: t.id, label: t.label })),
822
- [z]
823
- ), y = (t) => {
824
- var b;
825
- return (ee == null ? void 0 : ee(t)) ?? ((b = J.find((K) => K.id === t)) == null ? void 0 : b.name) ?? ce.get(t) ?? (t === (h == null ? void 0 : h.patientId) ? Q : void 0) ?? r("calendarWorkspace.details.patientNotLoaded");
826
- }, W = (t) => t === (h == null ? void 0 : h.operatorId) && M ? M : r(a("operatorUnresolved"), { id: t }), yt = [
827
- { value: _, label: r(a("operatorNone")) },
828
- ...w.map((t) => ({ value: t.id, label: t.label })),
829
- /* An operator the roster no longer lists is still a real link, so it
830
- stays pickable and survives a Save. */
831
- ...l.operatorId !== _ && !w.some((t) => t.id === l.operatorId) ? [
832
- {
833
- value: l.operatorId,
834
- label: W(l.operatorId)
835
- }
836
- ] : []
837
- ], bt = T.some((t) => t.custom) && T.some((t) => !t.custom), It = [
838
- ...T.map((t) => ({
839
- value: t.id,
840
- label: t.label,
841
- group: bt ? r(a(t.custom ? "typeGroupCustom" : "typeGroupStandard")) : void 0
842
- })),
843
- /* An id the list no longer resolves is still a real link: offered as
844
- its own option so Save re-sends it. */
845
- ...c.chosenTypeId && !T.some((t) => t.id === c.chosenTypeId) ? [
846
- {
847
- value: c.chosenTypeId,
848
- label: r(a("typeUnresolved"), { id: c.chosenTypeId })
849
- }
850
- ] : []
851
- ], wt = [
852
- { value: _, label: r(a("assigneeNone")) },
853
- ...A.map((t) => ({ value: t.id, label: t.label })),
854
- ...l.assigneeId !== _ && !A.some((t) => t.id === l.assigneeId) ? [
855
- {
856
- value: l.assigneeId,
857
- label: r(a("assigneeUnresolved"), { id: l.assigneeId })
858
- }
859
- ] : []
860
- ], ne = l.about === "company" && l.companyId && !z.some((t) => t.id === l.companyId) ? l.companyId : void 0, Et = ne && ne === (h == null ? void 0 : h.companyId) && j ? j : r(a("companyUnresolved"), { id: ne }), Xe = /* @__PURE__ */ k(q, { variant: "info", announce: "off", icon: /* @__PURE__ */ n(Yt, { "aria-hidden": "true" }), children: [
861
- /* @__PURE__ */ n(q.Title, { as: "p", children: r("calendarWorkspace.details.readOnlyTitle") }),
862
- /* @__PURE__ */ n(q.Description, { children: r(a("readOnlyBody")) })
863
- ] }), _e = d.saving || d.deleting, Je = () => {
864
- c.isBusy() || ae();
865
- }, kt = /* @__PURE__ */ n(
866
- We,
867
- {
868
- size: "sm",
869
- intent: "outline",
870
- icon: /* @__PURE__ */ n(Xt, { "aria-hidden": "true" }),
871
- "aria-label": r(a("cancel")),
872
- tooltip: r(a("cancel")),
873
- "data-action": "cancel-task",
874
- disabled: _e,
875
- onClick: Je
876
- }
877
- ), ze = d.saving || d.accepted, Ze = (t) => /* @__PURE__ */ k(Ne, { children: [
878
- t && c.showDelete ? /* @__PURE__ */ n(
879
- We,
880
- {
881
- ref: Se,
882
- size: "sm",
883
- intent: "destructiveOutline",
884
- icon: /* @__PURE__ */ n(dt, { "aria-hidden": "true" }),
885
- "aria-label": r(a("delete")),
886
- tooltip: r(a("delete")),
887
- "data-action": "delete-task",
888
- disabled: _e || d.accepted,
889
- onClick: () => c.patchUi({ confirmDeleteOpen: !0, deleteError: void 0 })
890
- }
891
- ) : null,
892
- /* @__PURE__ */ k(
893
- Pt,
894
- {
895
- role: "toolbar",
896
- "aria-label": r(a("actionsLabel")),
897
- className: "ds:ms-auto",
898
- children: [
899
- kt,
900
- t && c.showSave ? /* @__PURE__ */ n(
901
- We,
902
- {
903
- size: "sm",
904
- intent: "primary",
905
- icon: d.saving ? /* @__PURE__ */ n(
906
- on,
907
- {
908
- "aria-hidden": "true",
909
- className: "ds:animate-spin ds:motion-reduce:animate-none"
910
- }
911
- ) : /* @__PURE__ */ n(sn, { "aria-hidden": "true" }),
912
- "aria-label": r(a("save")),
913
- tooltip: r(a("save")),
914
- disabled: !ze && !c.canSave,
915
- "aria-disabled": ze || void 0,
916
- "aria-busy": d.saving || void 0,
917
- "data-action": "save-task",
918
- onClick: () => {
919
- ze || c.submit();
920
- }
921
- }
922
- ) : null
923
- ]
924
- }
925
- ),
926
- t && c.showSave ? (
927
- /* Out of flow, so it never moves the footer's two ends. */
928
- /* @__PURE__ */ n("span", { role: "status", className: "ds:sr-only", children: d.saving ? r(a("saving")) : "" })
929
- ) : null
930
- ] }), St = /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
931
- /* @__PURE__ */ n("span", { role: "status", className: "ds:sr-only", children: r("common.loading") }),
932
- /* @__PURE__ */ k(
933
- "div",
934
- {
935
- "aria-hidden": "true",
936
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
937
- children: [
938
- /* @__PURE__ */ n(
939
- He,
940
- {
941
- variant: "rounded",
942
- height: "calc(var(--spacing-xl) + var(--spacing-sm))"
943
- }
944
- ),
945
- /* @__PURE__ */ n(
946
- He,
947
- {
948
- variant: "rounded",
949
- height: "calc(var(--spacing-xl) * 3)",
950
- stagger: 1
951
- }
952
- ),
953
- /* @__PURE__ */ n(
954
- He,
955
- {
956
- variant: "rounded",
957
- height: "calc(var(--spacing-xl) + var(--spacing-sm))",
958
- stagger: 2
959
- }
960
- )
961
- ]
962
- }
963
- )
964
- ] }), Ct = /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]", children: [
965
- /* @__PURE__ */ n(q, { variant: "error", children: /* @__PURE__ */ n(q.Description, { children: c.loadError }) }),
966
- /* @__PURE__ */ n(
967
- Te,
968
- {
969
- ref: se,
970
- intent: "outline",
971
- "data-action": "retry-load",
972
- onClick: Fe(c.retry),
973
- children: r("emptyState.error.cta")
974
- }
975
- )
976
- ] }), Dt = /* @__PURE__ */ n("fieldset", { disabled: !0, className: mt({ layout: "notice" }), children: Xe }), Nt = () => l.about !== "patient" ? null : B ? /* @__PURE__ */ n(H, { label: r(a("aboutPatient")), children: /* @__PURE__ */ n(Me, { value: nn(), disabled: !0, readOnly: !0 }) }) : g ? /* @__PURE__ */ n(H, { label: r(a("aboutPatient")), children: /* @__PURE__ */ n(
977
- dn,
978
- {
979
- value: l.patientId,
980
- onValueChange: (t) => c.patchFields({ patientId: t }),
981
- patients: J,
982
- searchPatients: $,
983
- selectedLabel: l.patientId ? y(l.patientId) : void 0,
984
- placeholder: r("calendarWorkspace.editor.patientSearch"),
985
- disabled: m
986
- }
987
- ) }) : l.patientId ? /* @__PURE__ */ n(H, { label: r(a("aboutPatient")), children: /* @__PURE__ */ n(Me, { value: y(l.patientId), disabled: !0, readOnly: !0 }) }) : null, et = /* @__PURE__ */ k("fieldset", { disabled: m, className: mt(), children: [
988
- m ? Xe : null,
989
- /* @__PURE__ */ n(H, { label: r(a("date")), children: /* @__PURE__ */ n(
990
- Ft,
991
- {
992
- value: l.date,
993
- onChange: (t) => c.patchFields({ date: t })
994
- }
995
- ) }),
996
- /* @__PURE__ */ n(H, { label: r(a("time")), children: /* @__PURE__ */ n(
997
- _t,
998
- {
999
- value: l.time,
1000
- onChange: (t) => c.patchFields({ time: t })
1001
- }
1002
- ) }),
1003
- /* @__PURE__ */ n(
1004
- H,
1005
- {
1006
- label: r(a("note")),
1007
- required: !0,
1008
- error: d.showError && l.note.trim() === "" ? r(a("noteRequired")) : void 0,
1009
- children: /* @__PURE__ */ n(
1010
- Vt,
1011
- {
1012
- value: l.note,
1013
- onChange: (t) => {
1014
- c.patchFields({ note: t.target.value }), c.patchUi({ showError: !1 });
1015
- },
1016
- minRows: 3,
1017
- autoResize: !0
1018
- }
1019
- )
1020
- }
1021
- ),
1022
- T.length > 0 ? /* @__PURE__ */ n(H, { label: r(a("type")), required: !0, children: /* @__PURE__ */ n(
1023
- Ke,
1024
- {
1025
- options: It,
1026
- value: c.chosenTypeId,
1027
- onValueChange: (t) => t && c.patchFields({ typeId: t })
1028
- }
1029
- ) }) : null,
1030
- A.length > 0 ? /* @__PURE__ */ n(H, { label: r(a("assignee")), children: /* @__PURE__ */ n(
1031
- Ke,
1032
- {
1033
- options: wt,
1034
- value: l.assigneeId,
1035
- onValueChange: (t) => t && c.patchFields({ assigneeId: t })
1036
- }
1037
- ) }) : null,
1038
- /* @__PURE__ */ k(
1039
- Mt,
1040
- {
1041
- label: r(a("about")),
1042
- variant: "segmented",
1043
- className: Wt,
1044
- value: l.about,
1045
- onValueChange: (t) => c.patchFields({ about: t }),
1046
- children: [
1047
- /* @__PURE__ */ n(
1048
- je,
1049
- {
1050
- value: "nobody",
1051
- label: r(a("aboutNobody")),
1052
- icon: /* @__PURE__ */ n(Jt, { "aria-hidden": "true" })
1053
- }
1054
- ),
1055
- g || l.about === "patient" || h != null && h.patientId ? /* @__PURE__ */ n(
1056
- je,
1057
- {
1058
- value: "patient",
1059
- label: r(a("aboutPatient")),
1060
- icon: /* @__PURE__ */ n(Zt, { "aria-hidden": "true" })
1061
- }
1062
- ) : null,
1063
- e || l.about === "company" || h != null && h.companyId ? /* @__PURE__ */ n(
1064
- je,
1065
- {
1066
- value: "company",
1067
- label: r(a("aboutCompany")),
1068
- icon: /* @__PURE__ */ n(en, { "aria-hidden": "true" })
1069
- }
1070
- ) : null,
1071
- i || l.about === "operator" || h != null && h.operatorId ? /* @__PURE__ */ n(
1072
- je,
1073
- {
1074
- value: "operator",
1075
- label: r(a("aboutOperator")),
1076
- icon: /* @__PURE__ */ n(tn, { "aria-hidden": "true" })
1077
- }
1078
- ) : null
1079
- ]
1080
- }
1081
- ),
1082
- Nt(),
1083
- l.about === "company" ? /* @__PURE__ */ k(Ne, { children: [
1084
- ne ? /* @__PURE__ */ n(H, { label: r(a("companyName")), children: /* @__PURE__ */ n(Me, { value: Et, disabled: !0, readOnly: !0 }) }) : null,
1085
- e ? /* @__PURE__ */ n(
1086
- H,
1087
- {
1088
- label: r(
1089
- a(ne ? "companyReplace" : "companyName")
1090
- ),
1091
- children: /* @__PURE__ */ n(
1092
- Qe,
1093
- {
1094
- options: p,
1095
- value: ne ? "" : l.companyId,
1096
- onValueChange: (t) => ne ? t && c.patchFields({ companyId: t }) : c.patchFields({ companyId: t }),
1097
- clearable: !ne && !m,
1098
- filter: gn,
1099
- placeholder: r(a("companySearch")),
1100
- "aria-label": r(
1101
- a(ne ? "companyReplace" : "companyName")
1102
- )
1103
- }
1104
- )
1105
- }
1106
- ) : null
1107
- ] }) : null,
1108
- l.about === "operator" ? i ? /* @__PURE__ */ n(H, { label: r(a("operator")), children: /* @__PURE__ */ n(
1109
- Ke,
1110
- {
1111
- options: yt,
1112
- value: l.operatorId,
1113
- onValueChange: (t) => t && c.patchFields({ operatorId: t })
1114
- }
1115
- ) }) : l.operatorId !== _ ? (
1116
- /* No roster to pick from: name the link read-only. */
1117
- /* @__PURE__ */ n(H, { label: r(a("operator")), children: /* @__PURE__ */ n(
1118
- Me,
1119
- {
1120
- value: W(l.operatorId),
1121
- disabled: !0,
1122
- readOnly: !0
1123
- }
1124
- ) })
1125
- ) : null : null,
1126
- c.showDone ? /* @__PURE__ */ k(Ne, { children: [
1127
- /* @__PURE__ */ n(
1128
- qt,
1129
- {
1130
- label: r(a("done")),
1131
- checked: d.done,
1132
- disabled: _e || d.accepted,
1133
- "aria-disabled": d.donePending || void 0,
1134
- "aria-busy": d.donePending || void 0,
1135
- className: "ds:aria-disabled:cursor-progress",
1136
- onCheckedChange: (t) => {
1137
- d.donePending || c.setDone(t);
1138
- }
1139
- }
1140
- ),
1141
- d.doneError ? /* @__PURE__ */ n(q, { variant: "error", children: /* @__PURE__ */ n(q.Description, { children: d.doneError }) }) : null
1142
- ] }) : null,
1143
- d.saveError ? /* @__PURE__ */ n(q, { variant: "error", children: /* @__PURE__ */ n(q.Description, { children: d.saveError }) }) : null,
1144
- d.deleteError && !d.confirmDeleteOpen ? /* @__PURE__ */ n(q, { variant: "error", children: /* @__PURE__ */ n(q.Description, { children: d.deleteError }) }) : null
1145
- ] }), tt = x === "loading" ? St : x === "error" ? Ct : x === "locked" ? Dt : x === "withheld" ? /* @__PURE__ */ n(
1146
- Gt,
1147
- {
1148
- onTurnOff: ie ? Fe(ie) : void 0
1149
- }
1150
- ) : te ? et : /* @__PURE__ */ n($t, { orientation: "vertical", className: "ds:min-h-0 ds:flex-1", children: et }), Le = x === "ready" ? Ze(!0) : x === "locked" || x === "withheld" ? Ze(!1) : null, Rt = x === "ready" && c.showDelete, nt = he ? /* @__PURE__ */ n(
1151
- de,
1152
- {
1153
- open: d.confirmDeleteOpen && P,
1154
- onOpenChange: (t) => {
1155
- d.deleting || c.patchUi(
1156
- t ? { confirmDeleteOpen: !0 } : { confirmDeleteOpen: !1, deleteError: void 0 }
1157
- );
1158
- },
1159
- children: /* @__PURE__ */ k(
1160
- de.Content,
1161
- {
1162
- size: "sm",
1163
- variant: "alert",
1164
- onCloseAutoFocus: (t) => {
1165
- var b;
1166
- t.preventDefault(), c.isAccepted() || (b = Se.current) == null || b.focus();
1167
- },
1168
- children: [
1169
- /* @__PURE__ */ k(de.Header, { children: [
1170
- /* @__PURE__ */ n(de.Title, { children: r(a("deleteConfirmTitle")) }),
1171
- /* @__PURE__ */ n(de.Description, { children: r(a("deleteConfirmBody")) })
1172
- ] }),
1173
- d.deleteError ? /* @__PURE__ */ n(de.Body, { children: /* @__PURE__ */ n(q, { variant: "error", children: /* @__PURE__ */ n(q.Description, { children: d.deleteError }) }) }) : null,
1174
- /* @__PURE__ */ k(de.Footer, { divider: !0, children: [
1175
- /* @__PURE__ */ n(de.Close, { asChild: !0, children: /* @__PURE__ */ n(Te, { intent: "outline", "aria-disabled": d.deleting || void 0, children: r(a("deleteCancel")) }) }),
1176
- /* @__PURE__ */ n(
1177
- Te,
1178
- {
1179
- intent: "destructive",
1180
- startIcon: /* @__PURE__ */ n(dt, { "aria-hidden": "true" }),
1181
- "aria-disabled": d.deleting || void 0,
1182
- "aria-busy": d.deleting || void 0,
1183
- onClick: () => {
1184
- d.deleting || c.remove();
1185
- },
1186
- children: r(a("deleteConfirm"))
1187
- }
1188
- )
1189
- ] })
1190
- ]
1191
- }
1192
- )
1193
- }
1194
- ) : null, ot = {
1195
- "data-component": "task-editor",
1196
- "data-component-id": fe,
1197
- "data-variant": O,
1198
- "data-status": x
1199
- };
1200
- return te ? /* @__PURE__ */ k(Ne, { children: [
1201
- /* @__PURE__ */ n(
1202
- jt,
1203
- {
1204
- ...Ee,
1205
- "data-component-id": fe,
1206
- "data-variant": O,
1207
- "data-status": x,
1208
- ref: ye,
1209
- open: R,
1210
- onBack: Je,
1211
- onExited: G,
1212
- title: Ce,
1213
- icon: /* @__PURE__ */ n(ct, { "aria-hidden": "true" }),
1214
- backLabel: re ?? r(a("back")),
1215
- footer: Le,
1216
- footerAlign: Rt ? "between" : "end",
1217
- className: Y,
1218
- children: /* @__PURE__ */ n("div", { ...ot, className: pt({ variant: O }), children: tt })
1219
- }
1220
- ),
1221
- nt
1222
- ] }) : /* @__PURE__ */ k(Ne, { children: [
1223
- /* @__PURE__ */ k(
1224
- "div",
1225
- {
1226
- tabIndex: -1,
1227
- ...Ee,
1228
- ...ot,
1229
- ref: ye,
1230
- className: pt({ variant: O, className: Y }),
1231
- children: [
1232
- /* @__PURE__ */ n(
1233
- Ot,
1234
- {
1235
- title: Ce,
1236
- icon: /* @__PURE__ */ n(ct, { "aria-hidden": "true" }),
1237
- sticky: !0,
1238
- divider: !0
1239
- }
1240
- ),
1241
- tt,
1242
- Le ? /* @__PURE__ */ n("div", { className: "ds:relative ds:z-[var(--z-sticky)] ds:shrink-0 ds:border-t ds:border-[color:var(--border)] ds:bg-[var(--background)]", children: /* @__PURE__ */ n("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]", children: Le }) }) : null
1243
- ]
1244
- }
1245
- ),
1246
- nt
1247
- ] });
1248
- }
1249
- );
1250
- yn.displayName = "TaskEditor";
1251
- export {
1252
- dn as P,
1253
- sn as S,
1254
- yn as T,
1255
- un as t
1256
- };
1257
- //# sourceMappingURL=task-editor-DvwqPfFR.js.map