@alfadocs/ui-kit 1.148.0 → 1.149.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 (90) hide show
  1. package/dist/_chunks/{calendar-appointment-editor-dialog-Cz8F2H4M.js → calendar-appointment-editor-dialog-Dx9_KIWA.js} +5 -5
  2. package/dist/_chunks/{calendar-waiting-list-panel-C4T85b4q.js → calendar-waiting-list-panel-BKBHfBpn.js} +2 -2
  3. package/dist/_chunks/{calendar.sheets-DsgPdycU.js → calendar.sheets-lgAqJB34.js} +2 -2
  4. package/dist/_chunks/notes-panel-Cw06dLDm.js +1135 -0
  5. package/dist/_chunks/rich-text-editor-eGdYDPK2.js +4405 -0
  6. package/dist/_chunks/task-editor-4zFL10oM.js +1153 -0
  7. package/dist/_chunks/{tasks-panel-DufAoAxG.js → tasks-panel-BDPQPOP6.js} +475 -461
  8. package/dist/_chunks/{use-appointment-details-read-kYp-gfhb.js → use-appointment-details-read-Bl1DHXQ2.js} +568 -554
  9. package/dist/agent-catalog.json +9 -7
  10. package/dist/agent-i18n/en.json +4 -4
  11. package/dist/appointment-editor-panel/index.js +1 -1
  12. package/dist/aws-transcribe/index.js +287 -181
  13. package/dist/browser-support.js +1 -1
  14. package/dist/components/_shared/save-outcome.d.ts +23 -0
  15. package/dist/components/appointment-details-panel/index.js +1 -1
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/components/notes-panel/index.js +1 -1
  18. package/dist/components/rich-text-editor/help-me-write-overlay.d.ts +12 -1
  19. package/dist/components/rich-text-editor/index.js +1 -1
  20. package/dist/components/rich-text-editor/rich-text-editor.d.ts +5 -3
  21. package/dist/components/task-editor/index.js +1 -1
  22. package/dist/components/task-editor/use-task-editor-form.d.ts +7 -1
  23. package/dist/components/tasks-panel/index.js +1 -1
  24. package/dist/core.css +1 -1
  25. package/dist/find-free-slots-panel/index.js +1 -1
  26. package/dist/i18n/locales/ar.d.ts +1 -0
  27. package/dist/i18n/locales/ar.js +2 -1
  28. package/dist/i18n/locales/de.d.ts +1 -0
  29. package/dist/i18n/locales/de.js +2 -1
  30. package/dist/i18n/locales/el.d.ts +1 -0
  31. package/dist/i18n/locales/el.js +2 -1
  32. package/dist/i18n/locales/en.d.ts +1 -0
  33. package/dist/i18n/locales/en.js +2 -1
  34. package/dist/i18n/locales/es.d.ts +1 -0
  35. package/dist/i18n/locales/es.js +2 -1
  36. package/dist/i18n/locales/fr.d.ts +1 -0
  37. package/dist/i18n/locales/fr.js +2 -1
  38. package/dist/i18n/locales/hi.d.ts +1 -0
  39. package/dist/i18n/locales/hi.js +2 -1
  40. package/dist/i18n/locales/it.d.ts +1 -0
  41. package/dist/i18n/locales/it.js +2 -1
  42. package/dist/i18n/locales/ja.d.ts +1 -0
  43. package/dist/i18n/locales/ja.js +2 -1
  44. package/dist/i18n/locales/nl.d.ts +1 -0
  45. package/dist/i18n/locales/nl.js +2 -1
  46. package/dist/i18n/locales/pl.d.ts +1 -0
  47. package/dist/i18n/locales/pl.js +2 -1
  48. package/dist/i18n/locales/pt.d.ts +1 -0
  49. package/dist/i18n/locales/pt.js +2 -1
  50. package/dist/i18n/locales/ro.d.ts +1 -0
  51. package/dist/i18n/locales/ro.js +2 -1
  52. package/dist/i18n/locales/ru.d.ts +1 -0
  53. package/dist/i18n/locales/ru.js +2 -1
  54. package/dist/i18n/locales/sq.d.ts +1 -0
  55. package/dist/i18n/locales/sq.js +2 -1
  56. package/dist/i18n/locales/sv.d.ts +1 -0
  57. package/dist/i18n/locales/sv.js +2 -1
  58. package/dist/i18n/locales/tr.d.ts +1 -0
  59. package/dist/i18n/locales/tr.js +2 -1
  60. package/dist/i18n/locales/zh.d.ts +1 -0
  61. package/dist/i18n/locales/zh.js +2 -1
  62. package/dist/index.js +1407 -1403
  63. package/dist/locales/ar.json +2 -1
  64. package/dist/locales/de.json +2 -1
  65. package/dist/locales/el.json +2 -1
  66. package/dist/locales/en.json +2 -1
  67. package/dist/locales/es.json +2 -1
  68. package/dist/locales/fr.json +2 -1
  69. package/dist/locales/hi.json +2 -1
  70. package/dist/locales/it.json +2 -1
  71. package/dist/locales/ja.json +2 -1
  72. package/dist/locales/nl.json +2 -1
  73. package/dist/locales/pl.json +2 -1
  74. package/dist/locales/pt.json +2 -1
  75. package/dist/locales/ro.json +2 -1
  76. package/dist/locales/ru.json +2 -1
  77. package/dist/locales/sq.json +2 -1
  78. package/dist/locales/sv.json +2 -1
  79. package/dist/locales/tr.json +2 -1
  80. package/dist/locales/zh.json +2 -1
  81. package/dist/online-bookings-panel/index.js +1 -1
  82. package/dist/patterns/calendar/index.js +2 -2
  83. package/dist/save-outcome/index.js +20 -0
  84. package/dist/speech/aws-transcribe.d.ts +30 -6
  85. package/dist/tokens.css +1 -1
  86. package/dist/waiting-list-panel/index.js +2 -2
  87. package/package.json +5 -1
  88. package/dist/_chunks/notes-panel-BHMnLbEH.js +0 -1116
  89. package/dist/_chunks/rich-text-editor-BAcJq1PO.js +0 -4359
  90. package/dist/_chunks/task-editor-B9YpfwcW.js +0 -1095
@@ -0,0 +1,1153 @@
1
+ import { jsxs as b, jsx as n, Fragment as be } from "react/jsx-runtime";
2
+ import { useState as K, useRef as E, useEffect as Je, forwardRef as At, useId as Bt, useMemo as Oe } from "react";
3
+ import { c as gt } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as Ot } from "react-i18next";
5
+ import { A as C } from "./alert-C4WKViaS.js";
6
+ import { B as Le } from "./button-Dp4j9ygh.js";
7
+ import { I as ze } from "./icon-button-u9VMQn3x.js";
8
+ import { C as Ut } from "./combobox-BYl6mY4c.js";
9
+ import { D as X } from "./dialog-239Geb7Z.js";
10
+ import { D as Ft } from "./date-picker-CD-PBzXM.js";
11
+ import { F as B } from "./form-field-CyHfOVKF.js";
12
+ import { I as Pt } from "./icon-button-group-DEAx9M5v.js";
13
+ import { P as xt } from "./panel-header-CbtlTe85.js";
14
+ import { P as jt } from "./panel-subview-DjBwNV16.js";
15
+ import { R as Ue } from "./radio-BZQs6_36.js";
16
+ import { R as $t } from "./radio-group-ChIKyeSJ.js";
17
+ import { S as Mt } from "./scroll-area-CY5SLYNw.js";
18
+ import { S as Ge } from "./select-Bw5FvGJ7.js";
19
+ import { S as He } from "./skeleton-tTWJpvAq.js";
20
+ import { S as qt } from "./switch-DO6uC4HJ.js";
21
+ import { T as _t } from "./text-area-COMVJ1yE.js";
22
+ import { T as Fe } from "./text-input-B6iAgCr3.js";
23
+ import { T as Vt } from "./time-picker-DDr5vhwQ.js";
24
+ import { u as Wt } from "./registry-DvAUVLHh.js";
25
+ import { u as Kt } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
26
+ import { c as Lt } from "./compose-refs-C0k0tdqF.js";
27
+ import { E as zt, a as Gt } from "./compact-editor-fields-cP6yh7xv.js";
28
+ import { P as Ht } from "./patient-picker-Dm74jHIk.js";
29
+ import { b as Yt } from "./privacy-mask-zVh0ntm0.js";
30
+ import { isSaveOutcomeUnknownError as Pe, useSaveOutcomeUnknownMessage as Xt } from "../save-outcome/index.js";
31
+ import { g as Ye } from "./get-error-message-DbFUzuja.js";
32
+ import { h as Jt } from "./handled-rejection-C-6Dq0As.js";
33
+ import { L as Qt } from "./lock-ClAFG1gy.js";
34
+ import { X as Zt } from "./x-B5YnXwCz.js";
35
+ import { C as en } from "./circle-off-DuT9pVy2.js";
36
+ import { U as tn } from "./user-B12p7bVF.js";
37
+ import { B as nn } from "./building-2-D33bLCWL.js";
38
+ import { S as on } from "./stethoscope-sZXGC43m.js";
39
+ import { T as ct } from "./trash-2-uumy3fy1.js";
40
+ import { S as ut } from "./square-check-big-dj0o8yA3.js";
41
+ import { p as rn } from "./privacy-mask-text-B8YfzB7L.js";
42
+ import { L as an } from "./loader-circle-BECIU_8N.js";
43
+ import { S as sn } from "./save-Dn8uje3f.js";
44
+ const dn = {
45
+ id: "task-editor",
46
+ // set_value backs set_fields and set_done; submit backs save; dismiss
47
+ // backs cancel.
48
+ capabilities: ["set_value", "submit", "dismiss"],
49
+ state: {
50
+ status: {
51
+ type: "'loading' | 'ready' | 'error' | 'locked' | 'withheld'",
52
+ descriptionKey: "ui.agent.taskEditor.state.status",
53
+ 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'.",
54
+ read: (r) => r.getStatus()
55
+ },
56
+ draft: {
57
+ 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 }",
58
+ descriptionKey: "ui.agent.taskEditor.state.draft",
59
+ description: "The draft as Save would send it: ids and structure only, never the note body. done is the last value the host confirmed, or the value the reader chose when a Done save ended with SaveOutcomeUnknownError.",
60
+ read: (r) => r.getDraft()
61
+ },
62
+ canSave: {
63
+ type: "boolean",
64
+ descriptionKey: "ui.agent.taskEditor.state.canSave",
65
+ 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.",
66
+ read: (r) => r.canSave()
67
+ }
68
+ },
69
+ actions: {
70
+ set_fields: {
71
+ safety: "phi",
72
+ argsType: "{ dateIso?: string; note?: string; typeId?: string; assigneeId?: string | null; about?: 'nobody' | 'patient' | 'company' | 'operator'; patientId?: string; companyId?: string; operatorId?: string }",
73
+ argsSchema: {
74
+ type: "object",
75
+ properties: {
76
+ dateIso: { type: "string", format: "date-time" },
77
+ note: { type: "string" },
78
+ typeId: { type: "string" },
79
+ assigneeId: { type: ["string", "null"] },
80
+ about: {
81
+ type: "string",
82
+ enum: ["nobody", "patient", "company", "operator"]
83
+ },
84
+ patientId: { type: "string" },
85
+ companyId: { type: "string" },
86
+ operatorId: { type: "string" }
87
+ }
88
+ },
89
+ idempotent: !0,
90
+ errors: [
91
+ "An id the host lists, its patient search or the stored task do not resolve.",
92
+ "More than one of patientId, companyId and operatorId.",
93
+ "The form is not ready, is read-only or is withheld."
94
+ ],
95
+ descriptionKey: "ui.agent.taskEditor.actions.setFields",
96
+ 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.",
97
+ invoke: (r, u) => {
98
+ r.setFields(u);
99
+ }
100
+ },
101
+ save: {
102
+ safety: "phi",
103
+ // Reaches the host's data source; the result is the host's promise.
104
+ openWorld: !0,
105
+ descriptionKey: "ui.agent.taskEditor.actions.save",
106
+ description: "Save the task through the host. Resolves once the write lands and rejects with the host error, which the form also shows.",
107
+ invoke: (r) => r.save()
108
+ },
109
+ set_done: {
110
+ safety: "write",
111
+ argsType: "{ done: boolean }",
112
+ argsSchema: {
113
+ type: "object",
114
+ properties: { done: { type: "boolean" } },
115
+ required: ["done"]
116
+ },
117
+ openWorld: !0,
118
+ errors: [
119
+ "The form is not ready, is read-only or has no Done seam.",
120
+ "A save, a delete or another Done change is in flight.",
121
+ "The task was already saved or deleted in this session."
122
+ ],
123
+ descriptionKey: "ui.agent.taskEditor.actions.setDone",
124
+ description: "Mark an existing task done or not done through the host. A rejection rolls the switch back, except a SaveOutcomeUnknownError (the save hit its time limit), which keeps the chosen value and shows the neutral kit message.",
125
+ invoke: (r, u) => r.setDone(u.done)
126
+ },
127
+ delete: {
128
+ safety: "destructive",
129
+ idempotent: !0,
130
+ openWorld: !0,
131
+ descriptionKey: "ui.agent.taskEditor.actions.delete",
132
+ description: "Delete the task through the host, without the confirmation dialog. Resolves once the delete lands.",
133
+ invoke: (r) => r.deleteTask()
134
+ },
135
+ cancel: {
136
+ safety: "destructive",
137
+ errors: ["A save or delete is in flight: wait for it to settle."],
138
+ descriptionKey: "ui.agent.taskEditor.actions.cancel",
139
+ description: "Close the editor without saving. Anything typed since the last save is lost. Refused while a save or delete is in flight.",
140
+ invoke: (r) => {
141
+ r.cancel();
142
+ }
143
+ }
144
+ },
145
+ domHooks: {
146
+ root: {
147
+ attr: "data-component",
148
+ value: "task-editor",
149
+ 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."
150
+ },
151
+ instanceId: {
152
+ attr: "data-component-id",
153
+ sourceProp: "id",
154
+ description: "Sourced from the id prop, or generated. Addresses one editor from the agent. [data-component-id] reaches the footer actions in both variants."
155
+ }
156
+ }
157
+ }, T = "none", pt = {
158
+ showError: !1,
159
+ saving: !1,
160
+ saveError: void 0,
161
+ saveErrorUnknown: !1,
162
+ done: !1,
163
+ confirmedDone: !1,
164
+ donePending: !1,
165
+ doneError: void 0,
166
+ doneErrorUnknown: !1,
167
+ deleting: !1,
168
+ deleteError: void 0,
169
+ deleteErrorUnknown: !1,
170
+ confirmDeleteOpen: !1,
171
+ accepted: !1
172
+ };
173
+ function ln(r) {
174
+ return r.patientId ? "patient" : r.companyId ? "company" : r.operatorId ? "operator" : "nobody";
175
+ }
176
+ function Qe(r) {
177
+ return { hours: r.getHours(), minutes: r.getMinutes() };
178
+ }
179
+ function mt(r) {
180
+ const u = r ?? /* @__PURE__ */ new Date();
181
+ return {
182
+ date: u,
183
+ time: Qe(u),
184
+ note: "",
185
+ operatorId: T,
186
+ typeId: "",
187
+ assigneeId: T,
188
+ about: "nobody",
189
+ patientId: "",
190
+ companyId: ""
191
+ };
192
+ }
193
+ function cn(r) {
194
+ const u = new Date(r.dateIso);
195
+ return {
196
+ date: u,
197
+ time: Qe(u),
198
+ note: r.note,
199
+ /* `||`, not `??`: a host's '' is unset, like patient and company. */
200
+ operatorId: r.operatorId || T,
201
+ /* A stored type wins. With none, '' falls through to the first entry. */
202
+ typeId: r.typeId ?? "",
203
+ /* `||` too: '' would become a Select option with an empty value. */
204
+ assigneeId: r.assigneeId || T,
205
+ about: ln(r),
206
+ patientId: r.patientId ?? "",
207
+ companyId: r.companyId ?? ""
208
+ };
209
+ }
210
+ const un = [
211
+ ["patientId", "patient"],
212
+ ["companyId", "company"],
213
+ ["operatorId", "operator"]
214
+ ];
215
+ function pn({
216
+ mode: r,
217
+ taskId: u,
218
+ initialDate: S,
219
+ active: O,
220
+ taskTypes: $,
221
+ assignees: x,
222
+ companies: xe,
223
+ operators: L,
224
+ patients: ne,
225
+ searchedPatients: J,
226
+ resolvePatientLabel: z,
227
+ loadTask: G,
228
+ onCreateTask: H,
229
+ onUpdateTask: oe,
230
+ onDeleteTask: Y,
231
+ onSetTaskDone: re,
232
+ onSaved: M,
233
+ onDeleted: pe,
234
+ readOnly: q,
235
+ withheld: Ee,
236
+ maskPatient: je,
237
+ fallbackError: me,
238
+ unknownOutcomeMessage: ke
239
+ }) {
240
+ var ye;
241
+ const N = r === "edit", [$e, Me] = K(0), [Q, Se] = K(O);
242
+ Q !== O && (Se(O), O && Me((e) => e + 1));
243
+ const U = `${r}|${u ?? ""}|${$e}`, [p, ae] = K(
244
+ () => mt(S)
245
+ ), [F, fe] = K(pt), [o, De] = K(), g = (e) => fe((s) => ({ ...s, ...e })), ie = (e) => ae((s) => ({ ...s, ...e })), [se, _] = K(U);
246
+ se !== U && (_(U), ae(mt(S)), fe(pt), De(void 0));
247
+ const k = E({
248
+ subject: U,
249
+ saving: !1,
250
+ deleting: !1,
251
+ donePending: !1,
252
+ accepted: !1
253
+ });
254
+ k.current.subject !== U && (k.current = {
255
+ subject: U,
256
+ saving: !1,
257
+ deleting: !1,
258
+ donePending: !1,
259
+ accepted: !1
260
+ });
261
+ const de = E(!0);
262
+ Je(() => (de.current = !0, () => {
263
+ de.current = !1;
264
+ }), []);
265
+ const I = (e) => de.current && k.current === e, Z = E(G);
266
+ Z.current = G;
267
+ const d = !!G, [w, l] = K(0), [a, m] = K(null), he = E(a);
268
+ he.current = a;
269
+ const le = O && N && !!u && d && !Ee;
270
+ Je(() => {
271
+ const e = Z.current;
272
+ if (!le || !u || !e) return;
273
+ const s = k.current, h = he.current;
274
+ if ((h == null ? void 0 : h.subject) === s.subject && h.status === "ready")
275
+ return;
276
+ const c = new AbortController();
277
+ return Promise.resolve().then(
278
+ () => (
279
+ /* Cleaned up before this ran (StrictMode's replay, a quick re-run):
280
+ never call the host with a signal already aborted. */
281
+ c.signal.aborted ? Promise.reject(c.signal.reason) : e(u, { signal: c.signal })
282
+ )
283
+ ).then(
284
+ (f) => {
285
+ c.signal.aborted || !I(s) || (ae(cn(f)), g({ done: f.done, confirmedDone: f.done }), De(f), m({ subject: s.subject, status: "ready" }));
286
+ },
287
+ (f) => {
288
+ c.signal.aborted || !I(s) || m({
289
+ subject: s.subject,
290
+ status: "error",
291
+ message: Ye(f, me)
292
+ });
293
+ }
294
+ ), () => c.abort();
295
+ }, [le, U, w]);
296
+ const D = N ? !u || !d ? "locked" : Ee ? "withheld" : (a == null ? void 0 : a.subject) === U ? a.status : "loading" : "ready", P = () => {
297
+ D === "error" && (m(null), l((e) => e + 1));
298
+ }, ee = p.typeId || (((ye = $[0]) == null ? void 0 : ye.id) ?? ""), qe = p.about === "nobody" || p.about === "patient" && p.patientId !== "" || p.about === "company" && p.companyId !== "" || p.about === "operator" && p.operatorId !== T, te = !q && p.note.trim() !== "" && p.date !== void 0 && qe && /* Required whenever the host offers a list. */
299
+ ($.length === 0 || ee !== "") && !F.saving && !F.donePending, ce = N ? oe : H, ve = () => {
300
+ const { date: e, time: s } = p;
301
+ return e ? {
302
+ dateIso: new Date(
303
+ e.getFullYear(),
304
+ e.getMonth(),
305
+ e.getDate(),
306
+ s.hours,
307
+ s.minutes,
308
+ 0,
309
+ 0
310
+ ).toISOString(),
311
+ note: p.note.trim(),
312
+ /* Sent whatever the host's list says, including a value the list no
313
+ longer resolves: a real link must survive a Save that never
314
+ offered to change it. */
315
+ typeId: ee === "" ? void 0 : ee,
316
+ assigneeId: p.assigneeId === T ? void 0 : p.assigneeId,
317
+ /* ONE counterpart, decided by `about` alone: the platform refuses a
318
+ task carrying two. Never gated on a list being loaded, or a list
319
+ that empties mid-edit would unlink the task on Save. */
320
+ patientId: p.about === "patient" && p.patientId ? p.patientId : void 0,
321
+ companyId: p.about === "company" && p.companyId ? p.companyId : void 0,
322
+ operatorId: p.about === "operator" && p.operatorId !== T ? p.operatorId : void 0,
323
+ /* The last CONFIRMED value only, never an optimistic or rolled-back
324
+ toggle. */
325
+ done: F.confirmedDone
326
+ } : void 0;
327
+ }, ge = (e) => Pe(e) ? ke : Ye(e, me), y = (e) => Jt(new Error(`TaskEditor: ${e}`)), Ce = () => {
328
+ const e = k.current;
329
+ if (D !== "ready") return y(`cannot save while ${D}.`);
330
+ if (!ce) return y("the host gave no save seam.");
331
+ if (e.accepted) return y("this task was already saved.");
332
+ if (e.deleting) return y("a delete is in flight.");
333
+ if (e.saving || !te) return y("the task cannot be saved.");
334
+ const s = ve();
335
+ if (!s)
336
+ return g({ showError: !0 }), y("the task has no date.");
337
+ const h = u;
338
+ e.saving = !0, g({
339
+ saving: !0,
340
+ saveError: void 0,
341
+ saveErrorUnknown: !1
342
+ });
343
+ const c = (async () => {
344
+ try {
345
+ if (N)
346
+ await (oe == null ? void 0 : oe(h, s)), e.accepted = !0, I(e) && (g({ accepted: !0 }), M == null || M({
347
+ ...s,
348
+ id: h,
349
+ done: s.done ?? !1
350
+ }));
351
+ else {
352
+ const f = await (H == null ? void 0 : H(s));
353
+ e.accepted = !0, I(e) && (g({ accepted: !0 }), f && (M == null || M(f)));
354
+ }
355
+ } catch (f) {
356
+ throw I(e) && g({
357
+ saveError: ge(f),
358
+ saveErrorUnknown: Pe(f)
359
+ }), f;
360
+ } finally {
361
+ e.saving = !1, I(e) && g({ saving: !1 });
362
+ }
363
+ })();
364
+ return c.catch(() => {
365
+ }), c;
366
+ }, Te = (e) => {
367
+ const s = k.current;
368
+ if (D !== "ready")
369
+ return y(`cannot change Done while ${D}.`);
370
+ if (!N || !u || !re || q)
371
+ return y("the host gave no Done seam.");
372
+ if (s.donePending) return y("a Done change is already pending.");
373
+ if (s.saving || s.deleting)
374
+ return y("a save or delete is in flight.");
375
+ if (s.accepted)
376
+ return y("this task was already saved or deleted.");
377
+ if (e === F.done) return Promise.resolve();
378
+ const h = F.confirmedDone, c = u;
379
+ s.donePending = !0, g({
380
+ done: e,
381
+ donePending: !0,
382
+ doneError: void 0,
383
+ doneErrorUnknown: !1
384
+ });
385
+ const f = (async () => {
386
+ try {
387
+ await re(c, e), I(s) && g({ confirmedDone: e });
388
+ } catch (R) {
389
+ throw I(s) && Pe(R) ? g({
390
+ confirmedDone: e,
391
+ doneError: ke,
392
+ doneErrorUnknown: !0
393
+ }) : I(s) && g({
394
+ done: h,
395
+ doneError: Ye(R, me),
396
+ doneErrorUnknown: !1
397
+ }), R;
398
+ } finally {
399
+ s.donePending = !1, I(s) && g({ donePending: !1 });
400
+ }
401
+ })();
402
+ return f.catch(() => {
403
+ }), f;
404
+ }, Ne = () => {
405
+ const e = k.current;
406
+ if (D !== "ready") return y(`cannot delete while ${D}.`);
407
+ if (!N || !u || !Y || q)
408
+ return y("the host gave no delete seam.");
409
+ if (e.saving || e.accepted || e.deleting)
410
+ return y("the task cannot be deleted now.");
411
+ const s = u;
412
+ e.deleting = !0, g({
413
+ deleting: !0,
414
+ deleteError: void 0,
415
+ deleteErrorUnknown: !1
416
+ });
417
+ const h = (async () => {
418
+ try {
419
+ await Y(s), e.accepted = !0, I(e) && (g({ accepted: !0, confirmDeleteOpen: !1 }), pe == null || pe(s));
420
+ } catch (c) {
421
+ throw I(e) && g({
422
+ deleteError: ge(c),
423
+ deleteErrorUnknown: Pe(c)
424
+ }), c;
425
+ } finally {
426
+ e.deleting = !1, I(e) && g({ deleting: !1 });
427
+ }
428
+ })();
429
+ return h.catch(() => {
430
+ }), h;
431
+ }, j = (e, s, h) => (
432
+ /* '' is never an id, even when the stored record holds one. */
433
+ s !== "" && (s === h || e.some((c) => c.id === s))
434
+ ), Re = (e) => {
435
+ var f;
436
+ if (D !== "ready")
437
+ throw new Error(`TaskEditor: cannot set fields while ${D}.`);
438
+ if (q) throw new Error("TaskEditor: the task is read-only.");
439
+ const s = un.filter(([R]) => e[R] !== void 0);
440
+ if (s.length > 1)
441
+ throw new Error(
442
+ "TaskEditor: set at most one of patientId, companyId and operatorId."
443
+ );
444
+ const h = (f = s[0]) == null ? void 0 : f[1];
445
+ if (e.about !== void 0 && h && e.about !== h)
446
+ throw new Error(
447
+ `TaskEditor: about "${e.about}" does not match the ${h} id.`
448
+ );
449
+ if (e.typeId !== void 0 && !j($, e.typeId, o == null ? void 0 : o.typeId))
450
+ throw new Error(`TaskEditor: unknown typeId "${e.typeId}".`);
451
+ if (e.assigneeId !== void 0 && e.assigneeId !== null && !j(x, e.assigneeId, o == null ? void 0 : o.assigneeId))
452
+ throw new Error(`TaskEditor: unknown assigneeId "${e.assigneeId}".`);
453
+ if (e.companyId !== void 0 && !j(xe, e.companyId, o == null ? void 0 : o.companyId))
454
+ throw new Error(`TaskEditor: unknown companyId "${e.companyId}".`);
455
+ if (e.operatorId !== void 0 && !j(L, e.operatorId, o == null ? void 0 : o.operatorId))
456
+ throw new Error(`TaskEditor: unknown operatorId "${e.operatorId}".`);
457
+ if (e.patientId !== void 0) {
458
+ if (je)
459
+ throw new Error("TaskEditor: no patient can be set in privacy mode.");
460
+ if (!(j(ne, e.patientId, o == null ? void 0 : o.patientId) || J.has(e.patientId) || (z == null ? void 0 : z(e.patientId)) !== void 0))
461
+ throw new Error(`TaskEditor: unknown patientId "${e.patientId}".`);
462
+ }
463
+ const c = {};
464
+ if (e.dateIso !== void 0) {
465
+ const R = new Date(e.dateIso);
466
+ if (Number.isNaN(R.getTime()))
467
+ throw new Error(`TaskEditor: "${e.dateIso}" is not a date.`);
468
+ c.date = R, c.time = Qe(R);
469
+ }
470
+ e.note !== void 0 && (c.note = e.note), e.typeId !== void 0 && (c.typeId = e.typeId), e.assigneeId !== void 0 && (c.assigneeId = e.assigneeId ?? T), e.about !== void 0 && (c.about = e.about), e.patientId !== void 0 && (c.patientId = e.patientId, c.about = "patient"), e.companyId !== void 0 && (c.companyId = e.companyId, c.about = "company"), e.operatorId !== void 0 && (c.operatorId = e.operatorId, c.about = "operator"), ie(c);
471
+ }, Ae = () => {
472
+ const e = ve();
473
+ return {
474
+ mode: r,
475
+ dateIso: (e == null ? void 0 : e.dateIso) ?? null,
476
+ about: p.about,
477
+ patientId: (e == null ? void 0 : e.patientId) ?? null,
478
+ companyId: (e == null ? void 0 : e.companyId) ?? null,
479
+ operatorId: (e == null ? void 0 : e.operatorId) ?? null,
480
+ typeId: (e == null ? void 0 : e.typeId) ?? null,
481
+ assigneeId: (e == null ? void 0 : e.assigneeId) ?? null,
482
+ done: F.confirmedDone,
483
+ hasNote: p.note.trim() !== "",
484
+ noteLength: p.note.trim().length
485
+ };
486
+ };
487
+ return {
488
+ status: D,
489
+ loadError: (a == null ? void 0 : a.subject) === U ? a.message : void 0,
490
+ retry: P,
491
+ fields: p,
492
+ patchFields: ie,
493
+ stored: o,
494
+ chosenTypeId: ee,
495
+ canSave: te,
496
+ /** What the agent's `canSave` reports: the button's rule plus the
497
+ * status, the seam and a save that has not landed yet. */
498
+ agentCanSave: D === "ready" && !!ce && te && !F.accepted,
499
+ showSave: !q && !!ce,
500
+ showDelete: N && !q && !!Y && !!u,
501
+ showDone: N && !q && !!re,
502
+ ui: F,
503
+ patchUi: g,
504
+ /** True once a save or delete landed in this session. */
505
+ isAccepted: () => k.current.accepted,
506
+ /** A save or delete is in flight: closing now would lose its outcome. */
507
+ isBusy: () => k.current.saving || k.current.deleting,
508
+ submit: Ce,
509
+ setDone: Te,
510
+ remove: Ne,
511
+ applyPatch: Re,
512
+ draftState: Ae
513
+ };
514
+ }
515
+ const ft = gt("ds:flex ds:min-h-0 ds:flex-col", {
516
+ variants: {
517
+ /** The panel fills its box; the subview body sits in its scroll area. */
518
+ variant: {
519
+ /* Focusable from script only, as the subview section is: where focus
520
+ waits when a control takes itself away. */
521
+ panel: "ds:h-full ds:focus-visible:outline-none",
522
+ /* The states pad themselves, so the subview's ring inset is cancelled. */
523
+ subview: "ds:-m-[var(--panel-subview-inset)]"
524
+ }
525
+ },
526
+ defaultVariants: { variant: "panel" }
527
+ }), ht = gt(
528
+ `ds:m-0 ds:min-w-0 ds:border-0 ds:p-[var(--spacing-md)] ${Gt}`,
529
+ {
530
+ variants: {
531
+ /** 'form': the fields in a column. 'notice': the locked notice. */
532
+ layout: {
533
+ form: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
534
+ notice: "ds:flex-1"
535
+ }
536
+ },
537
+ defaultVariants: { layout: "form" }
538
+ }
539
+ ), i = (r) => `calendarWorkspace.taskEditor.${r}`, mn = (r, u, S) => S.includes(u) ? 1 : 0, we = [], Xe = (r, u) => Array.from(r.querySelectorAll("[data-task-id]")).filter(
540
+ (S) => !u.contains(S)
541
+ ), fn = 'button:not([disabled]), a[href], input:not([disabled]), [tabindex]:not([tabindex="-1"])', vt = (r, u) => {
542
+ if (!r) return [];
543
+ const S = Array.from(
544
+ r.querySelectorAll("[data-action]")
545
+ );
546
+ return [
547
+ ...S.filter((O) => u && O.dataset.action === u),
548
+ ...S.filter((O) => O.dataset.action === "open-task"),
549
+ ...Array.from(r.querySelectorAll(fn))
550
+ ];
551
+ }, hn = At(
552
+ ({
553
+ id: r,
554
+ mode: u,
555
+ taskId: S,
556
+ initialDate: O,
557
+ variant: $ = "panel",
558
+ open: x = !0,
559
+ onExited: xe,
560
+ taskTypes: L = we,
561
+ assignees: ne = we,
562
+ companies: J = we,
563
+ operators: z = we,
564
+ patients: G = we,
565
+ searchPatients: H,
566
+ patientLabel: oe,
567
+ resolvePatientLabel: Y,
568
+ companyLabel: re,
569
+ operatorLabel: M,
570
+ backLabel: pe,
571
+ loadTask: q,
572
+ onCreateTask: Ee,
573
+ onUpdateTask: je,
574
+ onDeleteTask: me,
575
+ onSetTaskDone: ke,
576
+ onCancel: N,
577
+ onSaved: $e,
578
+ onDeleted: Me,
579
+ readOnly: Q = !1,
580
+ privacy: Se = !1,
581
+ privacyMode: U = "notice",
582
+ onPrivacyOff: p,
583
+ className: ae,
584
+ ...F
585
+ }, fe) => {
586
+ const { t: o } = Ot("ui"), De = Xt(), g = Bt(), ie = r ?? g, se = u === "edit", _ = $ === "subview", k = !_ || x, de = Se && se && U === "notice", I = Se && !de, [Z] = K(() => /* @__PURE__ */ new Map()), d = pn({
587
+ mode: u,
588
+ taskId: S,
589
+ initialDate: O,
590
+ active: k,
591
+ taskTypes: L,
592
+ assignees: ne,
593
+ companies: J,
594
+ operators: z,
595
+ patients: G,
596
+ searchedPatients: Z,
597
+ resolvePatientLabel: Y,
598
+ loadTask: q,
599
+ onCreateTask: Ee,
600
+ onUpdateTask: je,
601
+ onDeleteTask: me,
602
+ onSetTaskDone: ke,
603
+ onSaved: $e,
604
+ onDeleted: Me,
605
+ readOnly: Q,
606
+ withheld: de,
607
+ maskPatient: I,
608
+ fallbackError: o("emptyState.error.title"),
609
+ unknownOutcomeMessage: De
610
+ }), { status: w, fields: l, ui: a, stored: m } = d, he = E(H);
611
+ he.current = H;
612
+ const le = !!H, D = Oe(
613
+ () => le ? async (t, v) => {
614
+ const A = await he.current(t, v);
615
+ for (const W of A)
616
+ Z.set(W.id, W.name);
617
+ return A;
618
+ } : void 0,
619
+ [le, Z]
620
+ ), P = E(d);
621
+ P.current = d;
622
+ const ee = E(N);
623
+ ee.current = N;
624
+ const qe = Oe(
625
+ () => ({
626
+ getStatus: () => P.current.status,
627
+ getDraft: () => P.current.draftState(),
628
+ canSave: () => P.current.agentCanSave,
629
+ setFields: (t) => P.current.applyPatch(t),
630
+ save: () => P.current.submit(),
631
+ setDone: (t) => P.current.setDone(t),
632
+ deleteTask: () => P.current.remove(),
633
+ cancel: () => {
634
+ if (P.current.isBusy())
635
+ throw new Error("TaskEditor: a save or delete is in flight.");
636
+ ee.current();
637
+ }
638
+ }),
639
+ []
640
+ );
641
+ Wt(dn, k ? qe : null, ie);
642
+ const te = E(null), ce = Oe(
643
+ () => Lt(fe, te),
644
+ [fe]
645
+ ), ve = E(null), ge = E(null), y = E(!1);
646
+ _ && x && !y.current && (ge.current = typeof document < "u" && document.activeElement instanceof HTMLElement ? document.activeElement : null), y.current = _ && x;
647
+ const Ce = E(x);
648
+ Ce.current = x;
649
+ const Te = E(S);
650
+ Te.current = se ? S : void 0, Je(() => {
651
+ var lt;
652
+ const t = te.current, v = t == null ? void 0 : t.parentElement;
653
+ if (!_ || !x || !t || !v) return;
654
+ const A = ge.current, W = A && v.contains(A) && !t.contains(A) ? A : null, Nt = Te.current, Ie = (W == null ? void 0 : W.closest("[data-task-id]")) ?? Xe(v, t).find((Be) => Be.dataset.taskId === Nt), it = Ie == null ? void 0 : Ie.dataset.taskId, st = (lt = W == null ? void 0 : W.closest("[data-action]")) == null ? void 0 : lt.dataset.action, dt = Ie ? Xe(v, t).indexOf(Ie) : -1;
655
+ return () => {
656
+ if (Ce.current && t.isConnected) return;
657
+ const Be = document.activeElement;
658
+ if (!v.isConnected || Be && Be !== document.body) return;
659
+ const Ke = Xe(v, t), Rt = [
660
+ ...vt(
661
+ Ke.find((ue) => it !== void 0 && ue.dataset.taskId === it),
662
+ st
663
+ ),
664
+ /* The row that took its place, or the last row when it was last. */
665
+ ...dt >= 0 ? vt(Ke[Math.min(dt, Ke.length - 1)], st) : [],
666
+ v.querySelector('[data-action="add-task"]'),
667
+ v.querySelector("[data-tasks-panel-region]")
668
+ ];
669
+ for (const ue of Rt)
670
+ if (!(!ue || t.contains(ue)) && (ue.focus(), document.activeElement === ue))
671
+ return;
672
+ };
673
+ }, [x, _]);
674
+ const Ne = E(null), j = E(!1), Re = (t) => () => {
675
+ j.current = !0, t();
676
+ };
677
+ Kt(() => {
678
+ var A;
679
+ if (!j.current) return;
680
+ const t = te.current, v = document.activeElement;
681
+ if (v && v !== document.body && v !== t) {
682
+ j.current = !1;
683
+ return;
684
+ }
685
+ w !== "loading" && (j.current = !1), (A = w === "error" ? Ne.current : t) == null || A.focus({
686
+ preventScroll: !0
687
+ });
688
+ }, [w]);
689
+ const Ae = o(i(se ? "editTitle" : "title")), ye = J.length > 0, e = z.length > 0, s = le || G.length > 0, h = Oe(
690
+ () => J.map((t) => ({ value: t.id, label: t.label })),
691
+ [J]
692
+ ), c = (t) => {
693
+ var v;
694
+ return (Y == null ? void 0 : Y(t)) ?? ((v = G.find((A) => A.id === t)) == null ? void 0 : v.name) ?? Z.get(t) ?? (t === (m == null ? void 0 : m.patientId) ? oe : void 0) ?? o("calendarWorkspace.details.patientNotLoaded");
695
+ }, f = (t) => t === (m == null ? void 0 : m.operatorId) && M ? M : o(i("operatorUnresolved"), { id: t }), R = [
696
+ { value: T, label: o(i("operatorNone")) },
697
+ ...z.map((t) => ({ value: t.id, label: t.label })),
698
+ /* An operator the roster no longer lists is still a real link, so it
699
+ stays pickable and survives a Save. */
700
+ ...l.operatorId !== T && !z.some((t) => t.id === l.operatorId) ? [
701
+ {
702
+ value: l.operatorId,
703
+ label: f(l.operatorId)
704
+ }
705
+ ] : []
706
+ ], yt = L.some((t) => t.custom) && L.some((t) => !t.custom), It = [
707
+ ...L.map((t) => ({
708
+ value: t.id,
709
+ label: t.label,
710
+ group: yt ? o(i(t.custom ? "typeGroupCustom" : "typeGroupStandard")) : void 0
711
+ })),
712
+ /* An id the list no longer resolves is still a real link: offered as
713
+ its own option so Save re-sends it. */
714
+ ...d.chosenTypeId && !L.some((t) => t.id === d.chosenTypeId) ? [
715
+ {
716
+ value: d.chosenTypeId,
717
+ label: o(i("typeUnresolved"), { id: d.chosenTypeId })
718
+ }
719
+ ] : []
720
+ ], bt = [
721
+ { value: T, label: o(i("assigneeNone")) },
722
+ ...ne.map((t) => ({ value: t.id, label: t.label })),
723
+ ...l.assigneeId !== T && !ne.some((t) => t.id === l.assigneeId) ? [
724
+ {
725
+ value: l.assigneeId,
726
+ label: o(i("assigneeUnresolved"), { id: l.assigneeId })
727
+ }
728
+ ] : []
729
+ ], V = l.about === "company" && l.companyId && !J.some((t) => t.id === l.companyId) ? l.companyId : void 0, wt = V && V === (m == null ? void 0 : m.companyId) && re ? re : o(i("companyUnresolved"), { id: V }), Ze = /* @__PURE__ */ b(C, { variant: "info", announce: "off", icon: /* @__PURE__ */ n(Qt, { "aria-hidden": "true" }), children: [
730
+ /* @__PURE__ */ n(C.Title, { as: "p", children: o("calendarWorkspace.details.readOnlyTitle") }),
731
+ /* @__PURE__ */ n(C.Description, { children: o(i("readOnlyBody")) })
732
+ ] }), _e = a.saving || a.deleting, et = () => {
733
+ d.isBusy() || N();
734
+ }, Et = /* @__PURE__ */ n(
735
+ ze,
736
+ {
737
+ size: "sm",
738
+ intent: "outline",
739
+ icon: /* @__PURE__ */ n(Zt, { "aria-hidden": "true" }),
740
+ "aria-label": o(i("cancel")),
741
+ tooltip: o(i("cancel")),
742
+ "data-action": "cancel-task",
743
+ disabled: _e,
744
+ onClick: et
745
+ }
746
+ ), Ve = a.saving || a.accepted, tt = (t) => /* @__PURE__ */ b(be, { children: [
747
+ t && d.showDelete ? /* @__PURE__ */ n(
748
+ ze,
749
+ {
750
+ ref: ve,
751
+ size: "sm",
752
+ intent: "destructiveOutline",
753
+ icon: /* @__PURE__ */ n(ct, { "aria-hidden": "true" }),
754
+ "aria-label": o(i("delete")),
755
+ tooltip: o(i("delete")),
756
+ "data-action": "delete-task",
757
+ disabled: _e || a.accepted,
758
+ onClick: () => d.patchUi({ confirmDeleteOpen: !0, deleteError: void 0 })
759
+ }
760
+ ) : null,
761
+ /* @__PURE__ */ b(
762
+ Pt,
763
+ {
764
+ role: "toolbar",
765
+ "aria-label": o(i("actionsLabel")),
766
+ className: "ds:ms-auto",
767
+ children: [
768
+ Et,
769
+ t && d.showSave ? /* @__PURE__ */ n(
770
+ ze,
771
+ {
772
+ size: "sm",
773
+ intent: "primary",
774
+ icon: a.saving ? /* @__PURE__ */ n(
775
+ an,
776
+ {
777
+ "aria-hidden": "true",
778
+ className: "ds:animate-spin ds:motion-reduce:animate-none"
779
+ }
780
+ ) : /* @__PURE__ */ n(sn, { "aria-hidden": "true" }),
781
+ "aria-label": o(i("save")),
782
+ tooltip: o(i("save")),
783
+ disabled: !Ve && !d.canSave,
784
+ "aria-disabled": Ve || void 0,
785
+ "aria-busy": a.saving || void 0,
786
+ "data-action": "save-task",
787
+ onClick: () => {
788
+ Ve || d.submit();
789
+ }
790
+ }
791
+ ) : null
792
+ ]
793
+ }
794
+ ),
795
+ t && d.showSave ? (
796
+ /* Out of flow, so it never moves the footer's two ends. */
797
+ /* @__PURE__ */ n("span", { role: "status", className: "ds:sr-only", children: a.saving ? o(i("saving")) : "" })
798
+ ) : null
799
+ ] }), kt = /* @__PURE__ */ b("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
800
+ /* @__PURE__ */ n("span", { role: "status", className: "ds:sr-only", children: o("common.loading") }),
801
+ /* @__PURE__ */ b(
802
+ "div",
803
+ {
804
+ "aria-hidden": "true",
805
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
806
+ children: [
807
+ /* @__PURE__ */ n(
808
+ He,
809
+ {
810
+ variant: "rounded",
811
+ height: "calc(var(--spacing-xl) + var(--spacing-sm))"
812
+ }
813
+ ),
814
+ /* @__PURE__ */ n(
815
+ He,
816
+ {
817
+ variant: "rounded",
818
+ height: "calc(var(--spacing-xl) * 3)",
819
+ stagger: 1
820
+ }
821
+ ),
822
+ /* @__PURE__ */ n(
823
+ He,
824
+ {
825
+ variant: "rounded",
826
+ height: "calc(var(--spacing-xl) + var(--spacing-sm))",
827
+ stagger: 2
828
+ }
829
+ )
830
+ ]
831
+ }
832
+ )
833
+ ] }), St = /* @__PURE__ */ b("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-[var(--spacing-md)]", children: [
834
+ /* @__PURE__ */ n(C, { variant: "error", children: /* @__PURE__ */ n(C.Description, { children: d.loadError }) }),
835
+ /* @__PURE__ */ n(
836
+ Le,
837
+ {
838
+ ref: Ne,
839
+ intent: "outline",
840
+ "data-action": "retry-load",
841
+ onClick: Re(d.retry),
842
+ children: o("emptyState.error.cta")
843
+ }
844
+ )
845
+ ] }), Dt = /* @__PURE__ */ n("fieldset", { disabled: !0, className: ht({ layout: "notice" }), children: Ze }), Ct = () => l.about !== "patient" ? null : I ? /* @__PURE__ */ n(B, { label: o(i("aboutPatient")), children: /* @__PURE__ */ n(Fe, { value: rn(), disabled: !0, readOnly: !0 }) }) : s ? /* @__PURE__ */ n(B, { label: o(i("aboutPatient")), children: /* @__PURE__ */ n(
846
+ Ht,
847
+ {
848
+ value: l.patientId,
849
+ onValueChange: (t) => d.patchFields({ patientId: t }),
850
+ patients: G,
851
+ searchPatients: D,
852
+ selectedLabel: l.patientId ? c(l.patientId) : void 0,
853
+ placeholder: o("calendarWorkspace.editor.patientSearch"),
854
+ disabled: Q
855
+ }
856
+ ) }) : l.patientId ? /* @__PURE__ */ n(B, { label: o(i("aboutPatient")), children: /* @__PURE__ */ n(Fe, { value: c(l.patientId), disabled: !0, readOnly: !0 }) }) : null, nt = /* @__PURE__ */ b("fieldset", { disabled: Q, className: ht(), children: [
857
+ Q ? Ze : null,
858
+ /* @__PURE__ */ n(B, { label: o(i("date")), children: /* @__PURE__ */ n(
859
+ Ft,
860
+ {
861
+ value: l.date,
862
+ onChange: (t) => d.patchFields({ date: t })
863
+ }
864
+ ) }),
865
+ /* @__PURE__ */ n(B, { label: o(i("time")), children: /* @__PURE__ */ n(
866
+ Vt,
867
+ {
868
+ value: l.time,
869
+ onChange: (t) => d.patchFields({ time: t })
870
+ }
871
+ ) }),
872
+ /* @__PURE__ */ n(
873
+ B,
874
+ {
875
+ label: o(i("note")),
876
+ required: !0,
877
+ error: a.showError && l.note.trim() === "" ? o(i("noteRequired")) : void 0,
878
+ children: /* @__PURE__ */ n(
879
+ _t,
880
+ {
881
+ value: l.note,
882
+ onChange: (t) => {
883
+ d.patchFields({ note: t.target.value }), d.patchUi({ showError: !1 });
884
+ },
885
+ minRows: 3,
886
+ autoResize: !0
887
+ }
888
+ )
889
+ }
890
+ ),
891
+ L.length > 0 ? /* @__PURE__ */ n(B, { label: o(i("type")), required: !0, children: /* @__PURE__ */ n(
892
+ Ge,
893
+ {
894
+ options: It,
895
+ value: d.chosenTypeId,
896
+ onValueChange: (t) => t && d.patchFields({ typeId: t })
897
+ }
898
+ ) }) : null,
899
+ ne.length > 0 ? /* @__PURE__ */ n(B, { label: o(i("assignee")), children: /* @__PURE__ */ n(
900
+ Ge,
901
+ {
902
+ options: bt,
903
+ value: l.assigneeId,
904
+ onValueChange: (t) => t && d.patchFields({ assigneeId: t })
905
+ }
906
+ ) }) : null,
907
+ /* @__PURE__ */ b(
908
+ $t,
909
+ {
910
+ label: o(i("about")),
911
+ variant: "segmented",
912
+ className: zt,
913
+ value: l.about,
914
+ onValueChange: (t) => d.patchFields({ about: t }),
915
+ children: [
916
+ /* @__PURE__ */ n(
917
+ Ue,
918
+ {
919
+ value: "nobody",
920
+ label: o(i("aboutNobody")),
921
+ icon: /* @__PURE__ */ n(en, { "aria-hidden": "true" })
922
+ }
923
+ ),
924
+ s || l.about === "patient" || m != null && m.patientId ? /* @__PURE__ */ n(
925
+ Ue,
926
+ {
927
+ value: "patient",
928
+ label: o(i("aboutPatient")),
929
+ icon: /* @__PURE__ */ n(tn, { "aria-hidden": "true" })
930
+ }
931
+ ) : null,
932
+ ye || l.about === "company" || m != null && m.companyId ? /* @__PURE__ */ n(
933
+ Ue,
934
+ {
935
+ value: "company",
936
+ label: o(i("aboutCompany")),
937
+ icon: /* @__PURE__ */ n(nn, { "aria-hidden": "true" })
938
+ }
939
+ ) : null,
940
+ e || l.about === "operator" || m != null && m.operatorId ? /* @__PURE__ */ n(
941
+ Ue,
942
+ {
943
+ value: "operator",
944
+ label: o(i("aboutOperator")),
945
+ icon: /* @__PURE__ */ n(on, { "aria-hidden": "true" })
946
+ }
947
+ ) : null
948
+ ]
949
+ }
950
+ ),
951
+ Ct(),
952
+ l.about === "company" ? /* @__PURE__ */ b(be, { children: [
953
+ V ? /* @__PURE__ */ n(B, { label: o(i("companyName")), children: /* @__PURE__ */ n(Fe, { value: wt, disabled: !0, readOnly: !0 }) }) : null,
954
+ ye ? /* @__PURE__ */ n(
955
+ B,
956
+ {
957
+ label: o(
958
+ i(V ? "companyReplace" : "companyName")
959
+ ),
960
+ children: /* @__PURE__ */ n(
961
+ Ut,
962
+ {
963
+ options: h,
964
+ value: V ? "" : l.companyId,
965
+ onValueChange: (t) => V ? t && d.patchFields({ companyId: t }) : d.patchFields({ companyId: t }),
966
+ clearable: !V && !Q,
967
+ filter: mn,
968
+ placeholder: o(i("companySearch")),
969
+ "aria-label": o(
970
+ i(V ? "companyReplace" : "companyName")
971
+ )
972
+ }
973
+ )
974
+ }
975
+ ) : null
976
+ ] }) : null,
977
+ l.about === "operator" ? e ? /* @__PURE__ */ n(B, { label: o(i("operator")), children: /* @__PURE__ */ n(
978
+ Ge,
979
+ {
980
+ options: R,
981
+ value: l.operatorId,
982
+ onValueChange: (t) => t && d.patchFields({ operatorId: t })
983
+ }
984
+ ) }) : l.operatorId !== T ? (
985
+ /* No roster to pick from: name the link read-only. */
986
+ /* @__PURE__ */ n(B, { label: o(i("operator")), children: /* @__PURE__ */ n(
987
+ Fe,
988
+ {
989
+ value: f(l.operatorId),
990
+ disabled: !0,
991
+ readOnly: !0
992
+ }
993
+ ) })
994
+ ) : null : null,
995
+ d.showDone ? /* @__PURE__ */ b(be, { children: [
996
+ /* @__PURE__ */ n(
997
+ qt,
998
+ {
999
+ label: o(i("done")),
1000
+ checked: a.done,
1001
+ disabled: _e || a.accepted,
1002
+ "aria-disabled": a.donePending || void 0,
1003
+ "aria-busy": a.donePending || void 0,
1004
+ className: "ds:aria-disabled:cursor-progress",
1005
+ onCheckedChange: (t) => {
1006
+ a.donePending || d.setDone(t);
1007
+ }
1008
+ }
1009
+ ),
1010
+ a.doneError ? /* @__PURE__ */ n(
1011
+ C,
1012
+ {
1013
+ variant: a.doneErrorUnknown ? "warning" : "error",
1014
+ announce: a.doneErrorUnknown ? "assertive" : void 0,
1015
+ children: /* @__PURE__ */ n(C.Description, { children: a.doneError })
1016
+ }
1017
+ ) : null
1018
+ ] }) : null,
1019
+ a.saveError ? /* @__PURE__ */ n(
1020
+ C,
1021
+ {
1022
+ variant: a.saveErrorUnknown ? "warning" : "error",
1023
+ announce: a.saveErrorUnknown ? "assertive" : void 0,
1024
+ children: /* @__PURE__ */ n(C.Description, { children: a.saveError })
1025
+ }
1026
+ ) : null,
1027
+ a.deleteError && !a.confirmDeleteOpen ? /* @__PURE__ */ n(
1028
+ C,
1029
+ {
1030
+ variant: a.deleteErrorUnknown ? "warning" : "error",
1031
+ announce: a.deleteErrorUnknown ? "assertive" : void 0,
1032
+ children: /* @__PURE__ */ n(C.Description, { children: a.deleteError })
1033
+ }
1034
+ ) : null
1035
+ ] }), ot = w === "loading" ? kt : w === "error" ? St : w === "locked" ? Dt : w === "withheld" ? /* @__PURE__ */ n(
1036
+ Yt,
1037
+ {
1038
+ onTurnOff: p ? Re(p) : void 0
1039
+ }
1040
+ ) : _ ? nt : /* @__PURE__ */ n(Mt, { orientation: "vertical", className: "ds:min-h-0 ds:flex-1", children: nt }), We = w === "ready" ? tt(!0) : w === "locked" || w === "withheld" ? tt(!1) : null, Tt = w === "ready" && d.showDelete, rt = se ? /* @__PURE__ */ n(
1041
+ X,
1042
+ {
1043
+ scope: "container",
1044
+ open: a.confirmDeleteOpen && k,
1045
+ onOpenChange: (t) => {
1046
+ a.deleting || d.patchUi(
1047
+ t ? { confirmDeleteOpen: !0 } : { confirmDeleteOpen: !1, deleteError: void 0 }
1048
+ );
1049
+ },
1050
+ children: /* @__PURE__ */ b(
1051
+ X.Content,
1052
+ {
1053
+ size: "sm",
1054
+ variant: "alert",
1055
+ onCloseAutoFocus: (t) => {
1056
+ var v;
1057
+ t.defaultPrevented || (t.preventDefault(), d.isAccepted() || (v = ve.current) == null || v.focus());
1058
+ },
1059
+ children: [
1060
+ /* @__PURE__ */ b(X.Header, { children: [
1061
+ /* @__PURE__ */ n(X.Title, { children: o(i("deleteConfirmTitle")) }),
1062
+ /* @__PURE__ */ n(X.Description, { children: o(i("deleteConfirmBody")) })
1063
+ ] }),
1064
+ a.deleteError ? /* @__PURE__ */ n(X.Body, { children: /* @__PURE__ */ n(
1065
+ C,
1066
+ {
1067
+ variant: a.deleteErrorUnknown ? "warning" : "error",
1068
+ announce: a.deleteErrorUnknown ? "assertive" : void 0,
1069
+ children: /* @__PURE__ */ n(C.Description, { children: a.deleteError })
1070
+ }
1071
+ ) }) : null,
1072
+ /* @__PURE__ */ b(X.Footer, { divider: !0, children: [
1073
+ /* @__PURE__ */ n(X.Close, { asChild: !0, children: /* @__PURE__ */ n(Le, { intent: "outline", "aria-disabled": a.deleting || void 0, children: o(i("deleteCancel")) }) }),
1074
+ /* @__PURE__ */ n(
1075
+ Le,
1076
+ {
1077
+ intent: "destructive",
1078
+ startIcon: /* @__PURE__ */ n(ct, { "aria-hidden": "true" }),
1079
+ "aria-disabled": a.deleting || void 0,
1080
+ "aria-busy": a.deleting || void 0,
1081
+ onClick: () => {
1082
+ a.deleting || d.remove();
1083
+ },
1084
+ children: o(i("deleteConfirm"))
1085
+ }
1086
+ )
1087
+ ] })
1088
+ ]
1089
+ }
1090
+ )
1091
+ }
1092
+ ) : null, at = {
1093
+ "data-component": "task-editor",
1094
+ "data-component-id": ie,
1095
+ "data-variant": $,
1096
+ "data-status": w
1097
+ };
1098
+ return _ ? /* @__PURE__ */ b(be, { children: [
1099
+ /* @__PURE__ */ n(
1100
+ jt,
1101
+ {
1102
+ ...F,
1103
+ "data-component-id": ie,
1104
+ "data-variant": $,
1105
+ "data-status": w,
1106
+ ref: ce,
1107
+ open: x,
1108
+ onBack: et,
1109
+ onExited: xe,
1110
+ title: Ae,
1111
+ icon: /* @__PURE__ */ n(ut, { "aria-hidden": "true" }),
1112
+ backLabel: pe ?? o(i("back")),
1113
+ footer: We,
1114
+ footerAlign: Tt ? "between" : "end",
1115
+ className: ae,
1116
+ children: /* @__PURE__ */ n("div", { ...at, className: ft({ variant: $ }), children: ot })
1117
+ }
1118
+ ),
1119
+ rt
1120
+ ] }) : /* @__PURE__ */ b(be, { children: [
1121
+ /* @__PURE__ */ b(
1122
+ "div",
1123
+ {
1124
+ tabIndex: -1,
1125
+ ...F,
1126
+ ...at,
1127
+ ref: ce,
1128
+ className: ft({ variant: $, className: ae }),
1129
+ children: [
1130
+ /* @__PURE__ */ n(
1131
+ xt,
1132
+ {
1133
+ title: Ae,
1134
+ icon: /* @__PURE__ */ n(ut, { "aria-hidden": "true" }),
1135
+ sticky: !0,
1136
+ divider: !0
1137
+ }
1138
+ ),
1139
+ ot,
1140
+ We ? /* @__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: We }) }) : null
1141
+ ]
1142
+ }
1143
+ ),
1144
+ rt
1145
+ ] });
1146
+ }
1147
+ );
1148
+ hn.displayName = "TaskEditor";
1149
+ export {
1150
+ hn as T,
1151
+ dn as t
1152
+ };
1153
+ //# sourceMappingURL=task-editor-4zFL10oM.js.map