@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
@@ -0,0 +1,1079 @@
1
+ import { jsxs as d, jsx as a, Fragment as ve } from "react/jsx-runtime";
2
+ import { forwardRef as Pn, useId as ye, useRef as v, useImperativeHandle as kn, useState as T, useEffect as M, useMemo as L, useCallback as Xe } from "react";
3
+ import { c as be } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as xe } from "react-i18next";
5
+ import { u as Nn } from "./registry-DvAUVLHh.js";
6
+ import { g as Tn } from "./get-error-message-DbFUzuja.js";
7
+ import { SafeHtml as Cn } from "../safe-html/index.js";
8
+ import { A as O } from "./alert-C4WKViaS.js";
9
+ import { B as Mn } from "./badge-BUk4RjTS.js";
10
+ import { B as Oe } from "./button-DohK_Ak_.js";
11
+ import { C as In } from "./chat-container-CoOT7dzB.js";
12
+ import { C as En } from "./chat-input-BmvnuZqj.js";
13
+ import { C as An } from "./chat-message-B4TMeZ2m.js";
14
+ import { E as fe } from "./empty-state-DwJ5YNzz.js";
15
+ import { a as Dn } from "./file-upload-DQc0LsBM.js";
16
+ import { I as Rn } from "./info-tip-B3cn3fY2.js";
17
+ import { P as qe } from "./panel-header-CbtlTe85.js";
18
+ import { S as zn } from "./select-CIXKyUMw.js";
19
+ import { S as Ze } from "./skeleton-tTWJpvAq.js";
20
+ import { T as en } from "./timestamp-DPLDWdxA.js";
21
+ import { a as we } from "./whatsapp-button-XbozeDl_.js";
22
+ import { M as Je } from "./message-square-Bye4ATvx.js";
23
+ import { C as nn } from "./circle-alert-rGDZ73Wh.js";
24
+ import { T as an } from "./triangle-alert-CBnO6nq_.js";
25
+ import { M as _n } from "./megaphone-CzeTT9B3.js";
26
+ import { c as tn } from "./createLucideIcon-DhHxpK9K.js";
27
+ import { F as sn } from "./file-text-5yv6r2ls.js";
28
+ import { S as jn } from "./smartphone-C0rFF2if.js";
29
+ import { M as Ln } from "./mail-BqXVF2zH.js";
30
+ import { E as Fn } from "./external-link-CY6zAXXU.js";
31
+ /**
32
+ * @license lucide-react v1.22.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */
37
+ const $n = [
38
+ ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }],
39
+ ["path", { d: "M10 4v4", key: "pp8u80" }],
40
+ ["path", { d: "M2 8h20", key: "d11cs7" }],
41
+ ["path", { d: "M6 4v4", key: "1svtjw" }]
42
+ ], Bn = tn("app-window", $n);
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 Hn = [
50
+ ["rect", { width: "8", height: "8", x: "3", y: "3", rx: "2", key: "by2w9f" }],
51
+ ["path", { d: "M7 11v4a2 2 0 0 0 2 2h4", key: "xkn7yn" }],
52
+ ["rect", { width: "8", height: "8", x: "13", y: "13", rx: "2", key: "1cgmvn" }]
53
+ ], Kn = tn("workflow", Hn), Vn = `@£$¥èéùìòÇ
54
+ Øø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà`, Yn = "^{}\\[~]|€\f", Gn = " // ", Un = 612, Xn = 268;
55
+ function qn(e) {
56
+ let o = !0, i = 0;
57
+ for (const c of e)
58
+ if (Vn.includes(c)) i += 1;
59
+ else if (Yn.includes(c))
60
+ i += 2;
61
+ else {
62
+ o = !1;
63
+ break;
64
+ }
65
+ if (o) {
66
+ const c = i <= 160 ? 1 : Math.ceil(i / 153);
67
+ return {
68
+ chars: i,
69
+ parts: Math.max(1, c),
70
+ encoding: "gsm",
71
+ max: Un
72
+ };
73
+ }
74
+ let p = 0;
75
+ for (const c of e) p += (c.codePointAt(0) ?? 0) > 65535 ? 2 : 1;
76
+ const y = p <= 70 ? 1 : Math.ceil(p / 67);
77
+ return {
78
+ chars: p,
79
+ parts: Math.max(1, y),
80
+ encoding: "ucs2",
81
+ max: Xn
82
+ };
83
+ }
84
+ function ge(e, o) {
85
+ const i = o == null ? void 0 : o.trim(), p = i ? `${e}${Gn}${i}` : e, y = qn(p);
86
+ return { ...y, overLimit: y.chars > y.max };
87
+ }
88
+ const Zn = {
89
+ id: "communications-panel",
90
+ // 'submit' backs send_message and 'select_single' backs select_channel.
91
+ // mark_seen has no dedicated capability in the closed vocabulary.
92
+ capabilities: ["submit", "select_single"],
93
+ state: {
94
+ channel: {
95
+ type: "'app' | 'sms' | 'email' | null",
96
+ descriptionKey: "ui.agent.communicationsPanel.state.channel",
97
+ description: "The channel the composer will send by. Null when no channel can be used.",
98
+ read: (e) => e.getState().channel
99
+ },
100
+ messageCount: {
101
+ type: "number",
102
+ descriptionKey: "ui.agent.communicationsPanel.state.messageCount",
103
+ description: "How many messages the thread holds. A count only, never a message. Zero under privacy.",
104
+ read: (e) => e.getState().messageCount
105
+ },
106
+ unreadCount: {
107
+ type: "number",
108
+ descriptionKey: "ui.agent.communicationsPanel.state.unreadCount",
109
+ description: "How many incoming messages are new.",
110
+ read: (e) => e.getState().unreadCount
111
+ },
112
+ status: {
113
+ type: "'ready' | 'loading' | 'error'",
114
+ descriptionKey: "ui.agent.communicationsPanel.state.status",
115
+ description: "The state of the host's read of the thread.",
116
+ read: (e) => e.getState().status
117
+ },
118
+ limitReached: {
119
+ type: "boolean",
120
+ descriptionKey: "ui.agent.communicationsPanel.state.limitReached",
121
+ description: "Whether the daily send limit is reached. SMS and Email are then unavailable; App stays.",
122
+ read: (e) => e.getState().limitReached
123
+ },
124
+ privacy: {
125
+ type: "{ masked: true } | null",
126
+ descriptionKey: "ui.agent.communicationsPanel.state.privacy",
127
+ description: "Reads { masked: true } when privacy mode withholds the thread, else null.",
128
+ read: (e) => e.getState().privacy ? { masked: !0 } : null
129
+ }
130
+ },
131
+ actions: {
132
+ select_channel: {
133
+ safety: "write",
134
+ argsType: "{ channel: 'app' | 'sms' | 'email' }",
135
+ argsSchema: {
136
+ type: "object",
137
+ properties: {
138
+ channel: { type: "string", enum: ["app", "sms", "email"] }
139
+ },
140
+ required: ["channel"]
141
+ },
142
+ idempotent: !0,
143
+ errors: [
144
+ "The channel is not available for this patient, or the daily limit closed it.",
145
+ "The panel is read-only or privacy mode is on."
146
+ ],
147
+ descriptionKey: "ui.agent.communicationsPanel.actions.selectChannel",
148
+ description: "Choose the channel the composer sends by. Rejects when the channel is not available.",
149
+ examples: [{ args: { channel: "sms" }, note: "Switch to SMS." }],
150
+ invoke: (e, o) => e.selectChannel(o.channel)
151
+ },
152
+ mark_seen: {
153
+ safety: "write",
154
+ idempotent: !0,
155
+ openWorld: !0,
156
+ errors: [
157
+ "The panel is read-only or privacy mode is on.",
158
+ "The host refused to clear the unread flag."
159
+ ],
160
+ descriptionKey: "ui.agent.communicationsPanel.actions.markSeen",
161
+ description: "Tell the host the new incoming messages were seen. Settles with the host's answer.",
162
+ invoke: (e) => e.markSeen()
163
+ },
164
+ send_message: {
165
+ // A message to a patient is patient-identifiable. PHI.
166
+ safety: "phi",
167
+ argsType: "{ channel: 'app' | 'sms' | 'email'; body: string }",
168
+ argsSchema: {
169
+ type: "object",
170
+ properties: {
171
+ channel: { type: "string", enum: ["app", "sms", "email"] },
172
+ body: {
173
+ type: "string",
174
+ description: "Plain text. For SMS the sender name is added to the end."
175
+ }
176
+ },
177
+ required: ["channel", "body"]
178
+ },
179
+ openWorld: !0,
180
+ errors: [
181
+ "The channel is not available for this patient, or the daily limit closed it.",
182
+ "The message is empty, or an SMS is above the length cap.",
183
+ "The panel is read-only or privacy mode is on.",
184
+ "A send is already in progress.",
185
+ "The host refused the send. The panel keeps the draft and shows the host's message."
186
+ ],
187
+ descriptionKey: "ui.agent.communicationsPanel.actions.sendMessage",
188
+ description: "Send a message to the patient by App, SMS or Email. Settles with the host's answer; a refusal rejects.",
189
+ examples: [
190
+ {
191
+ args: { channel: "app", body: "See you on Tuesday." },
192
+ note: "Send a short App message."
193
+ }
194
+ ],
195
+ invoke: (e, o) => e.sendMessage(o)
196
+ }
197
+ },
198
+ domHooks: {
199
+ root: {
200
+ attr: "data-component",
201
+ value: "communications-panel",
202
+ description: "Marks the CommunicationsPanel region."
203
+ },
204
+ instanceId: {
205
+ attr: "data-component-id",
206
+ sourceProp: "id",
207
+ description: "Sourced from the id prop. Required to address a specific panel from the agent."
208
+ },
209
+ item: {
210
+ attr: "data-message-id",
211
+ description: "Stable message id on each rendered message. Also carries data-direction and data-channel. Never a name, number or text."
212
+ }
213
+ }
214
+ }, Qe = be(
215
+ "ds:flex ds:h-full ds:min-h-0 ds:min-w-0 ds:flex-col ds:bg-[color:var(--card)]"
216
+ ), ee = ["app", "sms", "email"], Jn = 50, ne = {
217
+ app: "communicationsPanel.channelApp",
218
+ sms: "communicationsPanel.channelSms",
219
+ email: "communicationsPanel.channelEmail",
220
+ whatsapp: "communicationsPanel.channelWhatsApp"
221
+ }, Qn = {
222
+ app: "communicationsPanel.appDisabled",
223
+ sms: "communicationsPanel.smsDisabled",
224
+ email: "communicationsPanel.emailDisabled"
225
+ }, Wn = {
226
+ sending: "communicationsPanel.statusSending",
227
+ awaiting: "communicationsPanel.statusAwaiting",
228
+ delivered: "communicationsPanel.statusDelivered",
229
+ "not-delivered": "communicationsPanel.statusNotDelivered",
230
+ "out-of-credit": "communicationsPanel.statusOutOfCredit"
231
+ }, On = {
232
+ "not-delivered": {
233
+ icon: /* @__PURE__ */ a(nn, { "aria-hidden": "true" }),
234
+ color: "ds:text-[color:var(--destructive)]"
235
+ },
236
+ "out-of-credit": {
237
+ icon: /* @__PURE__ */ a(an, { "aria-hidden": "true" }),
238
+ color: "ds:text-[color:var(--warning-foreground)]"
239
+ }
240
+ };
241
+ function ae({ channel: e }) {
242
+ return e === "sms" ? /* @__PURE__ */ a(jn, { "aria-hidden": "true" }) : e === "email" ? /* @__PURE__ */ a(Ln, { "aria-hidden": "true" }) : e === "whatsapp" ? /* @__PURE__ */ a(we, { "aria-hidden": "true" }) : /* @__PURE__ */ a(Bn, { "aria-hidden": "true" });
243
+ }
244
+ function ea(e) {
245
+ return typeof e == "object" && e !== null && "status" in e && e.status === 429;
246
+ }
247
+ function na(e) {
248
+ const o = new Date(e);
249
+ return Number.isNaN(o.getTime()) ? e : `${o.getFullYear()}-${o.getMonth() + 1}-${o.getDate()}`;
250
+ }
251
+ const aa = Pn(
252
+ ({
253
+ id: e,
254
+ title: o,
255
+ "aria-label": i,
256
+ nowIso: p,
257
+ locale: y,
258
+ messages: c,
259
+ status: u = "ready",
260
+ onRetry: S,
261
+ channels: P,
262
+ defaultChannel: f,
263
+ senderName: k,
264
+ limitReached: g = !1,
265
+ whatsApp: w,
266
+ privacy: l = !1,
267
+ readOnly: b = !1,
268
+ onSend: z,
269
+ onMessagesSeen: I,
270
+ onWriteError: H,
271
+ onEnableChannel: E,
272
+ onOpenWhatsApp: A,
273
+ onBuyWhatsApp: K,
274
+ onOpenProvenance: Se,
275
+ onOpenAttachment: Pe,
276
+ className: ke,
277
+ ...Ne
278
+ }, rn) => {
279
+ const { t: s, i18n: on } = xe("ui"), V = ye(), te = ye(), cn = `${te}-input`, Te = `${te}-reason`, Ce = `${te}-meter`, Me = o ?? s("communicationsPanel.title"), se = y ?? on.language, Y = v(null);
280
+ kn(rn, () => Y.current, []);
281
+ const [dn, Ie] = T(!1);
282
+ M(() => {
283
+ Ie(!1);
284
+ }, [g]);
285
+ const G = g || dn, _ = (n) => P[n].available && (n === "app" || !G), [ie, Ee] = T(f), U = w === "ready" && !!A || w === "off" && !!K, ln = !!w && (U || w !== "ready" && w !== "off"), re = ie === "whatsapp" ? void 0 : ie, j = re && _(re) ? re : f && _(f) ? f : ee.find(_), x = ie === "whatsapp" && U ? "whatsapp" : j ?? (U ? "whatsapp" : void 0), oe = ee.every((n) => !P[n].available), Ae = ee.filter(
286
+ (n) => !P[n].available
287
+ ), F = L(
288
+ () => [...c].sort(
289
+ (n, t) => new Date(n.createdAtIso).getTime() - new Date(t.createdAtIso).getTime()
290
+ ),
291
+ [c]
292
+ ), N = L(
293
+ () => c.filter((n) => n.isNew && n.direction === "in").map((n) => n.id),
294
+ [c]
295
+ ), [De, mn] = T(
296
+ () => /* @__PURE__ */ new Set()
297
+ );
298
+ M(() => {
299
+ l || N.length === 0 || mn((n) => N.every((t) => n.has(t)) ? n : /* @__PURE__ */ new Set([...n, ...N]));
300
+ }, [l, N]);
301
+ const X = v(z);
302
+ X.current = z;
303
+ const Re = v(I);
304
+ Re.current = I;
305
+ const D = v(H);
306
+ D.current = H;
307
+ const R = v(!0);
308
+ M(() => (R.current = !0, () => {
309
+ R.current = !1;
310
+ }), []);
311
+ const ce = v(/* @__PURE__ */ new Set()), q = Xe(async (n) => {
312
+ var h;
313
+ const t = Re.current;
314
+ if (!(!t || n.length === 0)) {
315
+ n.forEach((r) => ce.current.add(r));
316
+ try {
317
+ await t(n);
318
+ } catch (r) {
319
+ throw n.forEach((Sn) => ce.current.delete(Sn)), (h = D.current) == null || h.call(D, { kind: "mark-seen", error: r, shown: !1 }), r;
320
+ }
321
+ }
322
+ }, []);
323
+ M(() => {
324
+ if (l || b || u !== "ready") return;
325
+ const n = N.filter((t) => !ce.current.has(t));
326
+ n.length !== 0 && q(n).catch(() => {
327
+ });
328
+ }, [l, b, u, N, q]);
329
+ const [$, Z] = T(""), [ze, _e] = T(!1), J = v(!1), [je, de] = T(null), [un, Q] = T(!1), [hn, W] = T(!1);
330
+ M(() => {
331
+ l && (Z(""), de(null), Q(!1), W(!1));
332
+ }, [l]);
333
+ const le = Xe(
334
+ async (n) => {
335
+ var t, h;
336
+ if (!J.current) {
337
+ J.current = !0, _e(!0), de(null), Q(!1);
338
+ try {
339
+ await ((t = X.current) == null ? void 0 : t.call(X, n)), R.current && (Z((r) => r.trim() === n.body ? "" : r), Q(!0));
340
+ } catch (r) {
341
+ throw R.current && (ea(r) && Ie(!0), de(
342
+ Tn(r, s("communicationsPanel.sendFailed"))
343
+ )), (h = D.current) == null || h.call(D, {
344
+ kind: "send",
345
+ id: n.channel,
346
+ error: r,
347
+ shown: R.current
348
+ }), r;
349
+ } finally {
350
+ J.current = !1, R.current && _e(!1);
351
+ }
352
+ }
353
+ },
354
+ [s]
355
+ ), m = x === "sms" && $.trim() ? ge($.trim(), k) : null, C = !!(m != null && m.overLimit), me = !!m && !m.overLimit && m.chars >= m.max - Jn, pn = !$.trim(), fn = (n) => {
356
+ const t = n.trim();
357
+ if (x === "whatsapp") {
358
+ if (w === "ready") {
359
+ const h = $.trim();
360
+ Promise.resolve(A == null ? void 0 : A(t || void 0)).then(() => {
361
+ R.current && Z((r) => r.trim() === h ? "" : r);
362
+ }).catch(() => {
363
+ });
364
+ } else K == null || K();
365
+ return;
366
+ }
367
+ if (!(!j || !t || J.current)) {
368
+ if (j === "sms" && ge(t, k).overLimit) {
369
+ W(!0);
370
+ return;
371
+ }
372
+ le({ channel: j, body: t }).catch(() => {
373
+ });
374
+ }
375
+ }, ue = v({
376
+ channel: x === "whatsapp" ? void 0 : j,
377
+ messageCount: c.length,
378
+ unreadCount: N.length,
379
+ status: u,
380
+ limitReached: G,
381
+ privacy: l
382
+ });
383
+ ue.current = {
384
+ channel: x === "whatsapp" ? void 0 : j,
385
+ messageCount: l ? 0 : c.length,
386
+ unreadCount: l ? 0 : N.length,
387
+ status: u,
388
+ limitReached: G,
389
+ privacy: l
390
+ };
391
+ const Le = v({ readOnly: b, privacy: l });
392
+ Le.current = { readOnly: b, privacy: l };
393
+ const he = v(_);
394
+ he.current = _;
395
+ const Fe = v(N);
396
+ Fe.current = N;
397
+ const gn = L(() => {
398
+ const n = async () => {
399
+ const t = Le.current;
400
+ if (t.privacy)
401
+ throw new Error("Messages are hidden by privacy mode.");
402
+ if (t.readOnly) throw new Error("The panel is read-only.");
403
+ };
404
+ return {
405
+ getState: () => ({
406
+ ...ue.current,
407
+ channel: ue.current.channel ?? null
408
+ }),
409
+ selectChannel: async (t) => {
410
+ if (await n(), !he.current(t))
411
+ throw new Error(`The ${t} channel is not available.`);
412
+ Ee(t);
413
+ },
414
+ markSeen: async () => {
415
+ await n(), await q(Fe.current);
416
+ },
417
+ sendMessage: async (t) => {
418
+ if (await n(), !he.current(t.channel))
419
+ throw new Error(`The ${t.channel} channel is not available.`);
420
+ if (!t.body.trim()) throw new Error("The message is empty.");
421
+ if (t.channel === "sms" && ge(t.body.trim(), k).overLimit)
422
+ throw new Error("The message is too long.");
423
+ await le({
424
+ channel: t.channel,
425
+ body: t.body.trim()
426
+ });
427
+ }
428
+ };
429
+ }, [le, q, k]);
430
+ Nn(Zn, gn, e);
431
+ const $e = v(!1), pe = v(!1);
432
+ M(() => {
433
+ const n = Y.current;
434
+ if (!n) return;
435
+ const t = pe.current && (!document.activeElement || document.activeElement === document.body);
436
+ if ($e.current && !t || !t && !l && u !== "ready") return;
437
+ $e.current = !0;
438
+ const h = l || u !== "ready" ? null : n.querySelector("textarea") ?? n.querySelector("[data-comms-enable]");
439
+ if (h) {
440
+ h.focus({ preventScroll: !0 });
441
+ return;
442
+ }
443
+ const r = n.querySelector("h2");
444
+ r && (r.setAttribute("tabindex", "-1"), r.focus({ preventScroll: !0, focusVisible: !1 }));
445
+ }, [l, u]);
446
+ const Be = L(() => {
447
+ const n = new Date(p ?? Date.now()).getFullYear();
448
+ return (t) => ({
449
+ day: "numeric",
450
+ month: "long",
451
+ ...new Date(t).getFullYear() === n ? {} : { year: "numeric" }
452
+ });
453
+ }, [p]), vn = L(() => {
454
+ const n = [];
455
+ for (const t of F) {
456
+ const h = na(t.createdAtIso), r = n[n.length - 1];
457
+ r && r.key === h ? r.items.push(t) : n.push({ key: h, items: [t] });
458
+ }
459
+ return n.map(({ key: t, items: h }) => ({
460
+ id: `day-${t}`,
461
+ node: /* @__PURE__ */ d(
462
+ "div",
463
+ {
464
+ "data-comms-day-group": t,
465
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
466
+ children: [
467
+ /* @__PURE__ */ a(
468
+ "div",
469
+ {
470
+ "data-comms-day": t,
471
+ className: "ds:sticky ds:top-[calc(var(--spacing-md)*-1)] ds:z-10 ds:flex ds:justify-center ds:bg-[color:var(--background)] ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]",
472
+ children: /* @__PURE__ */ a(
473
+ en,
474
+ {
475
+ value: h[0].createdAtIso,
476
+ format: "absolute",
477
+ absoluteFormat: Be(h[0].createdAtIso),
478
+ locale: se
479
+ }
480
+ )
481
+ }
482
+ ),
483
+ h.map((r) => /* @__PURE__ */ a(
484
+ ta,
485
+ {
486
+ message: r,
487
+ lang: se,
488
+ showNew: !!r.isNew || De.has(r.id),
489
+ onOpenProvenance: Se,
490
+ onOpenAttachment: Pe
491
+ },
492
+ r.id
493
+ ))
494
+ ]
495
+ }
496
+ )
497
+ }));
498
+ }, [F, se, De, Be, Se, Pe]), He = u === "loading" ? s("communicationsPanel.loading") : ze ? s("communicationsPanel.sending") : un && pn ? s("communicationsPanel.sent") : C || hn ? s("communicationsPanel.smsTooLong", { max: (m == null ? void 0 : m.max) ?? 0 }) : "", [yn, wn] = T("");
499
+ M(() => {
500
+ wn(He);
501
+ }, [He]);
502
+ const Ke = v(null), Ve = !l && u !== "loading" && u !== "error" && F.length > 0;
503
+ M(() => {
504
+ var t;
505
+ if (!Ve) return;
506
+ const n = (t = Ke.current) == null ? void 0 : t.querySelector('[role="log"]');
507
+ n == null || n.scrollTo({ top: n.scrollHeight, behavior: "instant" });
508
+ }, [Ve]);
509
+ const Ye = {
510
+ onFocusCapture: () => {
511
+ pe.current = !0;
512
+ },
513
+ onBlurCapture: (n) => {
514
+ n.relatedTarget && (pe.current = !1);
515
+ }
516
+ };
517
+ if (l)
518
+ return /* @__PURE__ */ d(
519
+ "section",
520
+ {
521
+ ref: Y,
522
+ "data-component": "communications-panel",
523
+ "data-component-id": e,
524
+ "data-privacy": "masked",
525
+ "aria-labelledby": i ? void 0 : V,
526
+ "aria-label": i,
527
+ className: [Qe(), ke].filter(Boolean).join(" "),
528
+ ...Ye,
529
+ ...Ne,
530
+ children: [
531
+ /* @__PURE__ */ a(
532
+ qe,
533
+ {
534
+ title: Me,
535
+ icon: /* @__PURE__ */ a(Je, { "aria-hidden": "true" }),
536
+ headingId: i ? void 0 : V,
537
+ divider: !0
538
+ }
539
+ ),
540
+ /* @__PURE__ */ a("div", { className: "ds:p-[var(--spacing-md)]", children: /* @__PURE__ */ a(
541
+ fe,
542
+ {
543
+ variant: "first-use",
544
+ size: "sm",
545
+ title: s("communicationsPanel.privacyTitle"),
546
+ description: s("communicationsPanel.privacyDescription")
547
+ }
548
+ ) })
549
+ ]
550
+ }
551
+ );
552
+ const Ge = x && x !== "whatsapp" ? P[x].recipient : void 0, bn = [
553
+ ...ee.map((n) => ({
554
+ value: n,
555
+ label: s(ne[n]),
556
+ disabled: !_(n),
557
+ startAdornment: /* @__PURE__ */ a(ae, { channel: n })
558
+ })),
559
+ ...ln ? [
560
+ {
561
+ value: "whatsapp",
562
+ label: s(ne.whatsapp),
563
+ disabled: !U,
564
+ startAdornment: /* @__PURE__ */ a(ae, { channel: "whatsapp" })
565
+ }
566
+ ] : []
567
+ ], xn = [m ? Ce : void 0, C ? Te : void 0].filter(Boolean).join(" ") || void 0;
568
+ let B;
569
+ u === "loading" ? B = /* @__PURE__ */ a(
570
+ "div",
571
+ {
572
+ "data-comms-state": "loading",
573
+ className: "ds:flex ds:min-h-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-md)] ds:overflow-y-auto ds:p-[var(--spacing-md)]",
574
+ "aria-hidden": "true",
575
+ children: ["a", "b", "c"].map((n, t) => /* @__PURE__ */ d(
576
+ "div",
577
+ {
578
+ className: [
579
+ "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
580
+ t % 2 === 1 ? "ds:items-end" : "ds:items-start"
581
+ ].join(" "),
582
+ children: [
583
+ /* @__PURE__ */ a(
584
+ Ze,
585
+ {
586
+ variant: "rounded",
587
+ width: "70%",
588
+ height: "3rem",
589
+ stagger: t
590
+ }
591
+ ),
592
+ /* @__PURE__ */ a(Ze, { variant: "text", size: "sm", width: "30%", stagger: t })
593
+ ]
594
+ },
595
+ n
596
+ ))
597
+ }
598
+ ) : u === "error" ? B = /* @__PURE__ */ a(
599
+ "div",
600
+ {
601
+ "data-comms-state": "error",
602
+ className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)]",
603
+ children: /* @__PURE__ */ a(
604
+ fe,
605
+ {
606
+ variant: "error",
607
+ size: "sm",
608
+ title: s("communicationsPanel.errorTitle"),
609
+ primaryAction: S ? { label: s("communicationsPanel.retry"), onClick: S } : void 0
610
+ }
611
+ )
612
+ }
613
+ ) : F.length === 0 ? B = /* @__PURE__ */ a(
614
+ "div",
615
+ {
616
+ "data-comms-state": "empty",
617
+ className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)]",
618
+ children: /* @__PURE__ */ a(
619
+ fe,
620
+ {
621
+ variant: "first-use",
622
+ size: "sm",
623
+ title: s(oe ? "communicationsPanel.noChannelsTitle" : "communicationsPanel.emptyTitle"),
624
+ description: (
625
+ // The description tells the reader to send the first message
626
+ // below, and a read-only panel has no composer.
627
+ oe || b ? void 0 : s("communicationsPanel.emptyDescription")
628
+ )
629
+ }
630
+ )
631
+ }
632
+ ) : B = /* @__PURE__ */ a(
633
+ In,
634
+ {
635
+ ref: Ke,
636
+ messages: vn,
637
+ showScrollToLatest: !0,
638
+ logLabel: s("communicationsPanel.messagesLabel"),
639
+ className: "ds:min-h-0 ds:flex-1"
640
+ }
641
+ );
642
+ const Ue = w === "no-phone" ? s("communicationsPanel.whatsAppNoPhone") : w === "no-sms-phone" ? s("communicationsPanel.whatsAppNoSmsPhone") : null;
643
+ return /* @__PURE__ */ d(
644
+ "section",
645
+ {
646
+ ref: Y,
647
+ "data-component": "communications-panel",
648
+ "data-component-id": e,
649
+ "aria-labelledby": i ? void 0 : V,
650
+ "aria-label": i,
651
+ className: [Qe(), ke].filter(Boolean).join(" "),
652
+ ...Ye,
653
+ ...Ne,
654
+ children: [
655
+ /* @__PURE__ */ a(
656
+ qe,
657
+ {
658
+ title: Me,
659
+ icon: /* @__PURE__ */ a(Je, { "aria-hidden": "true" }),
660
+ headingId: i ? void 0 : V,
661
+ divider: !0
662
+ }
663
+ ),
664
+ /* @__PURE__ */ a("span", { role: "status", className: "ds:sr-only", children: yn }),
665
+ G && !b ? /* @__PURE__ */ a("div", { className: "ds:shrink-0 ds:px-[var(--spacing-md)] ds:pt-[var(--spacing-sm)]", children: /* @__PURE__ */ a(O, { variant: "warning", announce: "polite", "data-comms-limit": "", children: /* @__PURE__ */ a(O.Description, { children: s("communicationsPanel.limitReached") }) }) }) : null,
666
+ B,
667
+ !b && u === "ready" ? /* @__PURE__ */ d(
668
+ "div",
669
+ {
670
+ "data-comms-composer": "",
671
+ className: "ds:@container ds:flex ds:shrink-0 ds:flex-col ds:gap-[var(--spacing-sm)] ds:border-t ds:border-[color:var(--border)] ds:bg-[color:var(--card)] ds:p-[var(--spacing-md)]",
672
+ children: [
673
+ oe && F.length > 0 ? /* @__PURE__ */ a(
674
+ "p",
675
+ {
676
+ "data-comms-blocked": "",
677
+ className: "ds:m-0 type-body-sm ds:font-semibold ds:text-[color:var(--foreground)]",
678
+ children: s("communicationsPanel.noChannelsTitle")
679
+ }
680
+ ) : null,
681
+ Ae.length > 0 ? /* @__PURE__ */ a("ul", { className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-xs)] ds:p-0", children: Ae.map((n) => /* @__PURE__ */ d(
682
+ "li",
683
+ {
684
+ "data-comms-disabled": n,
685
+ className: "ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-sm)] ds:gap-y-[var(--spacing-xs)] type-meta ds:text-[color:var(--muted-foreground)]",
686
+ children: [
687
+ /* @__PURE__ */ d("span", { className: "ds:inline-flex ds:min-w-0 ds:flex-1 ds:items-center ds:gap-[var(--spacing-xs)]", children: [
688
+ /* @__PURE__ */ a("span", { className: "ds:inline-flex ds:shrink-0 ds:[&_svg]:size-4", children: /* @__PURE__ */ a(ae, { channel: n }) }),
689
+ /* @__PURE__ */ a("span", { className: "ds:[overflow-wrap:anywhere]", children: s(Qn[n]) })
690
+ ] }),
691
+ E ? /* @__PURE__ */ a(
692
+ Oe,
693
+ {
694
+ type: "button",
695
+ size: "sm",
696
+ intent: "outline",
697
+ "data-comms-enable": n,
698
+ onClick: () => E(n),
699
+ children: s("communicationsPanel.enableChannel", {
700
+ channel: s(ne[n])
701
+ })
702
+ }
703
+ ) : null
704
+ ]
705
+ },
706
+ n
707
+ )) }) : null,
708
+ x ? /* @__PURE__ */ d(ve, { children: [
709
+ je ? /* @__PURE__ */ a(O, { variant: "error", "data-comms-send-error": "", children: /* @__PURE__ */ a(O.Description, { children: je }) }) : null,
710
+ /* @__PURE__ */ a(
711
+ En,
712
+ {
713
+ id: cn,
714
+ value: $,
715
+ submitOnEnter: !1,
716
+ minRows: 2,
717
+ maxRows: 8,
718
+ submitDisabled: C || ze,
719
+ allowEmptySubmit: x === "whatsapp",
720
+ sendLabel: x === "whatsapp" ? s(w === "ready" ? "communicationsPanel.whatsApp" : "communicationsPanel.whatsAppBuy") : void 0,
721
+ sendIcon: x === "whatsapp" ? /* @__PURE__ */ a(we, { "aria-hidden": "true" }) : void 0,
722
+ "data-comms-composer-mode": x,
723
+ submitShortcut: !1,
724
+ label: s("communicationsPanel.composerLabel"),
725
+ hideLabel: !0,
726
+ placeholder: s("communicationsPanel.placeholder"),
727
+ "aria-describedby": xn,
728
+ "aria-invalid": C || void 0,
729
+ onChange: (n) => {
730
+ Z(n.target.value), Q(!1), W(!1);
731
+ },
732
+ onSubmit: fn,
733
+ toolbar: /* @__PURE__ */ d("div", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-sm)] ds:gap-y-[var(--spacing-xs)]", children: [
734
+ /* @__PURE__ */ d("div", { className: "ds:flex ds:min-w-0 ds:basis-full ds:items-center ds:gap-[var(--spacing-sm)]", children: [
735
+ /* @__PURE__ */ a("div", { className: "ds:w-32 ds:shrink-0", children: /* @__PURE__ */ a(
736
+ zn,
737
+ {
738
+ size: "md",
739
+ appearance: "plain",
740
+ value: x,
741
+ options: bn,
742
+ "aria-label": s("communicationsPanel.channelLabel"),
743
+ adornmentInTrigger: !0,
744
+ onValueChange: (n) => {
745
+ n && (Ee(n), W(!1));
746
+ }
747
+ }
748
+ ) }),
749
+ Ge ? /* @__PURE__ */ a(
750
+ "span",
751
+ {
752
+ dir: "auto",
753
+ className: "type-meta ds:min-w-0 ds:flex-1 ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere]",
754
+ children: s("communicationsPanel.toRecipient", {
755
+ recipient: Ge
756
+ })
757
+ }
758
+ ) : null
759
+ ] }),
760
+ m ? /* @__PURE__ */ d("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
761
+ /* @__PURE__ */ d(
762
+ "span",
763
+ {
764
+ id: Ce,
765
+ "data-comms-meter": C ? "over" : me ? "near" : "ok",
766
+ className: [
767
+ "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-meta ds:tabular-nums",
768
+ C ? "ds:text-[color:var(--destructive)]" : me ? "ds:text-[color:var(--warning-foreground)]" : "ds:text-[color:var(--muted-foreground)]"
769
+ ].join(" "),
770
+ children: [
771
+ C ? /* @__PURE__ */ a(
772
+ nn,
773
+ {
774
+ "aria-hidden": "true",
775
+ className: "ds:size-3.5 ds:shrink-0"
776
+ }
777
+ ) : me ? /* @__PURE__ */ a(
778
+ an,
779
+ {
780
+ "aria-hidden": "true",
781
+ className: "ds:size-3.5 ds:shrink-0"
782
+ }
783
+ ) : null,
784
+ s("communicationsPanel.smsCount", {
785
+ count: m.chars,
786
+ chars: m.chars,
787
+ parts: m.parts
788
+ })
789
+ ]
790
+ }
791
+ ),
792
+ /* @__PURE__ */ a(
793
+ Rn,
794
+ {
795
+ size: "sm",
796
+ side: "top",
797
+ align: "start",
798
+ content: s("communicationsPanel.senderNote", {
799
+ sender: k
800
+ })
801
+ }
802
+ )
803
+ ] }) : null
804
+ ] })
805
+ }
806
+ ),
807
+ C ? /* @__PURE__ */ a(
808
+ "p",
809
+ {
810
+ id: Te,
811
+ className: "ds:m-0 type-meta ds:text-[color:var(--destructive)]",
812
+ children: s("communicationsPanel.smsTooLong", {
813
+ max: (m == null ? void 0 : m.max) ?? 0
814
+ })
815
+ }
816
+ ) : null
817
+ ] }) : null,
818
+ Ue ? /* @__PURE__ */ d(
819
+ "p",
820
+ {
821
+ "data-comms-whatsapp": w,
822
+ className: "ds:m-0 ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-meta ds:text-[color:var(--muted-foreground)]",
823
+ children: [
824
+ /* @__PURE__ */ a(
825
+ we,
826
+ {
827
+ "aria-hidden": "true",
828
+ className: "ds:size-4 ds:shrink-0"
829
+ }
830
+ ),
831
+ Ue
832
+ ]
833
+ }
834
+ ) : null
835
+ ]
836
+ }
837
+ ) : null
838
+ ]
839
+ }
840
+ );
841
+ }
842
+ );
843
+ aa.displayName = "CommunicationsPanel";
844
+ function ta({
845
+ message: e,
846
+ lang: o,
847
+ showNew: i,
848
+ onOpenProvenance: p,
849
+ onOpenAttachment: y
850
+ }) {
851
+ const { t: c } = xe("ui"), u = ye(), S = c(ne[e.channel]), P = L(() => {
852
+ const E = new Date(e.createdAtIso);
853
+ return Number.isNaN(E.getTime()) ? "" : new Intl.DateTimeFormat(o, {
854
+ dateStyle: "medium",
855
+ timeStyle: "short"
856
+ }).format(E);
857
+ }, [e.createdAtIso, o]), f = e.direction === "out", k = c(
858
+ f ? "communicationsPanel.messageFromPractice" : "communicationsPanel.messageFromPatient",
859
+ { channel: S, time: P }
860
+ ), g = e.provenance, w = g ? g.kind === "document-share" ? c("communicationsPanel.provenanceDocument") : c(
861
+ g.kind === "campaign" ? "communicationsPanel.provenanceCampaign" : "communicationsPanel.provenanceWorkflow",
862
+ { name: g.name ?? "" }
863
+ ) : "", l = g ? g.kind === "campaign" ? /* @__PURE__ */ a(_n, { "aria-hidden": "true" }) : g.kind === "workflow" ? /* @__PURE__ */ a(Kn, { "aria-hidden": "true" }) : /* @__PURE__ */ a(sn, { "aria-hidden": "true" }) : null, b = f && e.channel === "sms" && e.smsStatus ? On[e.smsStatus] : void 0, z = "ds:inline-flex ds:max-w-full ds:items-center ds:gap-[var(--spacing-2xs)] ds:align-middle ds:[&_svg]:size-3.5 ds:[&_svg]:shrink-0", I = (E, A) => /* @__PURE__ */ a(
864
+ "span",
865
+ {
866
+ className: [
867
+ "ds:inline-flex ds:max-w-full ds:items-center ds:align-middle",
868
+ A === "channel" ? "" : "ds:whitespace-nowrap"
869
+ ].join(" "),
870
+ children: E
871
+ },
872
+ A
873
+ ), H = /* @__PURE__ */ d(
874
+ "p",
875
+ {
876
+ "data-comms-meta": "",
877
+ className: [
878
+ "ds:m-0 ds:flex ds:min-w-0 ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-sm)] ds:gap-y-[var(--spacing-2xs)] type-meta ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere]",
879
+ f ? "ds:justify-end ds:text-end" : "ds:justify-start ds:text-start"
880
+ ].join(" "),
881
+ children: [
882
+ /* @__PURE__ */ a(
883
+ en,
884
+ {
885
+ value: e.createdAtIso,
886
+ format: "absolute",
887
+ absoluteFormat: { hour: "2-digit", minute: "2-digit" },
888
+ locale: o,
889
+ dir: "ltr"
890
+ }
891
+ ),
892
+ I(
893
+ /* @__PURE__ */ d("span", { className: z, children: [
894
+ /* @__PURE__ */ a(ae, { channel: e.channel }),
895
+ e.recipient ? c("communicationsPanel.viaTo", {
896
+ channel: S,
897
+ recipient: e.recipient
898
+ }) : c("communicationsPanel.via", { channel: S })
899
+ ] }),
900
+ "channel"
901
+ ),
902
+ f && e.channel === "sms" && e.smsStatus ? I(
903
+ /* @__PURE__ */ d(
904
+ "span",
905
+ {
906
+ "data-sms-status": e.smsStatus,
907
+ className: [z, b == null ? void 0 : b.color].filter(Boolean).join(" "),
908
+ children: [
909
+ b ? b.icon : null,
910
+ c(Wn[e.smsStatus])
911
+ ]
912
+ }
913
+ ),
914
+ "status"
915
+ ) : null,
916
+ i ? I(
917
+ /* @__PURE__ */ a(Mn, { variant: "brand", size: "sm", "data-comms-new": "", children: c("communicationsPanel.newMessages") }),
918
+ "new"
919
+ ) : null,
920
+ g ? I(
921
+ p ? /* @__PURE__ */ a(
922
+ Oe,
923
+ {
924
+ type: "button",
925
+ size: "sm",
926
+ intent: "link",
927
+ startIcon: l,
928
+ "data-comms-provenance": g.kind,
929
+ onClick: () => p(g.kind, g.id),
930
+ children: w
931
+ }
932
+ ) : /* @__PURE__ */ d("span", { "data-comms-provenance": g.kind, className: z, children: [
933
+ l,
934
+ w
935
+ ] }),
936
+ "source"
937
+ ) : null
938
+ ]
939
+ }
940
+ );
941
+ return /* @__PURE__ */ a(
942
+ An,
943
+ {
944
+ role: f ? "user" : "assistant",
945
+ content: e.body,
946
+ "aria-label": k,
947
+ "data-message-id": e.id,
948
+ "data-direction": e.direction,
949
+ "data-channel": e.channel,
950
+ body: /* @__PURE__ */ d("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
951
+ e.attachment ? /* @__PURE__ */ a(
952
+ ra,
953
+ {
954
+ id: u,
955
+ out: f,
956
+ attachment: e.attachment,
957
+ onOpen: y ? () => y(e.attachment.id) : void 0
958
+ }
959
+ ) : null,
960
+ e.bodyHtml && e.channel !== "sms" ? /* @__PURE__ */ a(Cn, { html: e.bodyHtml, profile: "email" }) : e.body ? /* @__PURE__ */ a("span", { dir: "auto", className: "ds:whitespace-pre-wrap", children: e.body }) : null
961
+ ] }),
962
+ actions: H
963
+ }
964
+ );
965
+ }
966
+ const We = be(
967
+ [
968
+ "ds:flex ds:w-full ds:min-w-0 ds:items-center ds:gap-[var(--spacing-sm)] ds:text-start",
969
+ "ds:rounded-[var(--radius-sm)] ds:border-0",
970
+ "ds:p-[var(--spacing-sm)]"
971
+ ].join(" "),
972
+ {
973
+ variants: {
974
+ tone: {
975
+ // The focus ring is drawn on the bubble, not on the page. On a sent
976
+ // (primary) bubble `--ring` is the bubble colour (1.0:1, invisible in
977
+ // light and accessible, 1.08:1 in dark), so it takes
978
+ // `--primary-foreground`, which reaches 4.75:1 (light), 5.96:1
979
+ // (dark), 10.58:1 (light accessible) and 7.94:1 (dark accessible)
980
+ // against the bubble. A received bubble is a card: `--ring` stays.
981
+ sent: "ds:bg-[var(--card)] ds:text-[color:var(--card-foreground)] ds:focus-visible:outline-[color:var(--primary-foreground)]",
982
+ received: "ds:bg-muted ds:text-[color:var(--foreground)] ds:focus-visible:outline-[color:var(--ring)]"
983
+ },
984
+ interactive: {
985
+ true: [
986
+ "ds:min-h-[var(--min-target-size)] ds:cursor-pointer",
987
+ "ds:transition-[filter] ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
988
+ "ds:hover:brightness-95",
989
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
990
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
991
+ "ds:forced-colors:border ds:forced-colors:border-[ButtonText]"
992
+ ].join(" "),
993
+ false: ""
994
+ }
995
+ },
996
+ defaultVariants: { tone: "received", interactive: !1 }
997
+ }
998
+ ), sa = be(
999
+ "ds:inline-flex ds:size-10 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-[var(--radius-sm)] ds:text-[color:var(--primary)]",
1000
+ {
1001
+ variants: {
1002
+ tone: {
1003
+ sent: "ds:bg-muted",
1004
+ received: "ds:bg-[var(--card)]"
1005
+ }
1006
+ },
1007
+ defaultVariants: { tone: "received" }
1008
+ }
1009
+ );
1010
+ function ia(e) {
1011
+ const o = e.lastIndexOf(".");
1012
+ if (o <= 0 || o === e.length - 1) return;
1013
+ const i = e.slice(o + 1);
1014
+ return i.length <= 5 && /^[a-z0-9]+$/i.test(i) ? i.toUpperCase() : void 0;
1015
+ }
1016
+ function ra({
1017
+ id: e,
1018
+ out: o,
1019
+ attachment: i,
1020
+ onOpen: p
1021
+ }) {
1022
+ const { t: y, i18n: c } = xe("ui"), u = `${e}-name`, S = o ? "sent" : "received", P = i.typeLabel ?? ia(i.name), f = typeof i.sizeBytes == "number" && i.sizeBytes >= 0 ? Dn(i.sizeBytes, c.language, y) : void 0, k = /* @__PURE__ */ d(ve, { children: [
1023
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", className: sa({ tone: S }), children: /* @__PURE__ */ a(sn, { className: "ds:size-5" }) }),
1024
+ /* @__PURE__ */ d("span", { className: "ds:flex ds:min-w-0 ds:grow ds:flex-col", children: [
1025
+ /* @__PURE__ */ a(
1026
+ "span",
1027
+ {
1028
+ id: u,
1029
+ dir: "auto",
1030
+ title: i.name,
1031
+ className: "type-body-sm ds:line-clamp-2 ds:font-medium ds:[overflow-wrap:anywhere]",
1032
+ children: i.name
1033
+ }
1034
+ ),
1035
+ P || f ? /* @__PURE__ */ d("span", { className: "type-meta ds:text-[color:var(--muted-foreground)]", children: [
1036
+ P,
1037
+ P && f ? /* @__PURE__ */ d(ve, { children: [
1038
+ " ",
1039
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "·" }),
1040
+ " "
1041
+ ] }) : null,
1042
+ f ? /* @__PURE__ */ a("bdi", { dir: "ltr", children: f }) : null
1043
+ ] }) : null
1044
+ ] }),
1045
+ p ? /* @__PURE__ */ a(
1046
+ Fn,
1047
+ {
1048
+ "aria-hidden": "true",
1049
+ className: "ds:size-4 ds:shrink-0 ds:text-[color:var(--muted-foreground)]"
1050
+ }
1051
+ ) : null
1052
+ ] });
1053
+ return p ? /* @__PURE__ */ a(
1054
+ "button",
1055
+ {
1056
+ type: "button",
1057
+ "data-comms-attachment": i.id,
1058
+ "aria-label": y("communicationsPanel.openAttachment", {
1059
+ name: i.name
1060
+ }),
1061
+ onClick: p,
1062
+ className: We({ tone: S, interactive: !0 }),
1063
+ children: k
1064
+ }
1065
+ ) : /* @__PURE__ */ a(
1066
+ "span",
1067
+ {
1068
+ "data-comms-attachment": i.id,
1069
+ className: We({ tone: S, interactive: !1 }),
1070
+ children: k
1071
+ }
1072
+ );
1073
+ }
1074
+ export {
1075
+ aa as C,
1076
+ Zn as c,
1077
+ ge as s
1078
+ };
1079
+ //# sourceMappingURL=communications-panel-SQ-55e3V.js.map