@alfadocs/ui-kit 1.76.0 → 1.77.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 (119) hide show
  1. package/dist/_chunks/{balance-badge-cell-B49xgL6H.js → balance-badge-cell-Dzd-Z_5W.js} +2 -2
  2. package/dist/_chunks/booking-Cz_QjIJe.js +4051 -0
  3. package/dist/_chunks/{breadcrumb-Boan-5n8.js → breadcrumb-Bn29NCnf.js} +8 -8
  4. package/dist/_chunks/{calendar-appointment-editor-dialog-B4My4eiB.js → calendar-appointment-editor-dialog-cvUpUjj-.js} +4 -4
  5. package/dist/_chunks/{control-room-rail-CKZ2nemY.js → control-room-rail-DcJpHbp4.js} +2 -2
  6. package/dist/_chunks/{data-table-DTKGWUQm.js → data-table-BlONA1rP.js} +2 -2
  7. package/dist/_chunks/{file-manager-Ct5QpZZI.js → file-manager-C9iJjDZt.js} +3 -3
  8. package/dist/_chunks/{header-settings-Coh1r41O.js → header-settings-BYpVmLip.js} +2 -2
  9. package/dist/_chunks/{heatmap-Ba9cgfSY.js → heatmap-C2Rg-SV_.js} +2 -2
  10. package/dist/_chunks/{marketplace-app-shell-Ck5NVJcO.js → marketplace-app-shell-mS7Q2-81.js} +3 -3
  11. package/dist/_chunks/{notes-panel-CxjMovCh.js → notes-panel-CZO1qsD-.js} +2 -2
  12. package/dist/_chunks/{otp-input-CGMu30_e.js → otp-input-BgEZi0py.js} +54 -53
  13. package/dist/_chunks/{practice-results-C5SJTgcd.js → practice-results-By2BZFCz.js} +732 -709
  14. package/dist/_chunks/{recaptcha-widget-CsvwlYTE.js → recaptcha-widget-iglUBIF3.js} +2 -2
  15. package/dist/_chunks/{registration-form-DeK2QiJu.js → registration-form-xORq2s4p.js} +3 -3
  16. package/dist/_chunks/signature-request-DjY-X62H.js +2448 -0
  17. package/dist/_chunks/{tasks-panel-Cmr0oMvc.js → tasks-panel-BkjtgjQ8.js} +2 -2
  18. package/dist/_chunks/{theme-toggle-DTrUzIBG.js → theme-toggle-DKpzb0-M.js} +2 -2
  19. package/dist/_chunks/{tool-rail-C_9lm0TC.js → tool-rail-Kup1b7xI.js} +2 -2
  20. package/dist/_chunks/use-theme-CYGyzFgZ.js +196 -0
  21. package/dist/agent-catalog.json +46 -10
  22. package/dist/agent-i18n/en.json +5 -4
  23. package/dist/components/booking/booking-types.d.ts +22 -1
  24. package/dist/components/booking/booking.d.ts +1 -1
  25. package/dist/components/booking/code-step.d.ts +6 -0
  26. package/dist/components/booking/index.d.ts +1 -1
  27. package/dist/components/booking/index.js +1 -1
  28. package/dist/components/booking/step-focus.d.ts +9 -0
  29. package/dist/components/booking/use-booking-payment.d.ts +6 -3
  30. package/dist/components/breadcrumb/index.js +1 -1
  31. package/dist/components/control-room-rail/index.js +1 -1
  32. package/dist/components/data-table/index.js +1 -1
  33. package/dist/components/file-manager/index.js +1 -1
  34. package/dist/components/header-settings/index.js +1 -1
  35. package/dist/components/heatmap/index.js +1 -1
  36. package/dist/components/index.d.ts +1 -1
  37. package/dist/components/notes-panel/index.js +1 -1
  38. package/dist/components/otp-input/index.js +1 -1
  39. package/dist/components/otp-input/otp-input.d.ts +1 -0
  40. package/dist/components/patient-table/index.js +1 -1
  41. package/dist/components/practice-results/index.js +1 -1
  42. package/dist/components/practice-results/practice-results.d.ts +1 -1
  43. package/dist/components/recaptcha-widget/index.js +1 -1
  44. package/dist/components/tasks-panel/index.js +1 -1
  45. package/dist/components/theme-toggle/index.js +1 -1
  46. package/dist/components/tool-rail/index.js +1 -1
  47. package/dist/hooks/index.d.ts +1 -1
  48. package/dist/hooks/index.js +88 -86
  49. package/dist/hooks/use-theme.d.ts +9 -0
  50. package/dist/host-compat.css +4 -1
  51. package/dist/i18n/locales/ar.d.ts +29 -0
  52. package/dist/i18n/locales/ar.js +30 -1
  53. package/dist/i18n/locales/de.d.ts +29 -0
  54. package/dist/i18n/locales/de.js +30 -1
  55. package/dist/i18n/locales/el.d.ts +29 -0
  56. package/dist/i18n/locales/el.js +30 -1
  57. package/dist/i18n/locales/en.d.ts +29 -0
  58. package/dist/i18n/locales/en.js +30 -1
  59. package/dist/i18n/locales/es.d.ts +29 -0
  60. package/dist/i18n/locales/es.js +30 -1
  61. package/dist/i18n/locales/fr.d.ts +29 -0
  62. package/dist/i18n/locales/fr.js +30 -1
  63. package/dist/i18n/locales/hi.d.ts +29 -0
  64. package/dist/i18n/locales/hi.js +30 -1
  65. package/dist/i18n/locales/it.d.ts +29 -0
  66. package/dist/i18n/locales/it.js +30 -1
  67. package/dist/i18n/locales/ja.d.ts +29 -0
  68. package/dist/i18n/locales/ja.js +30 -1
  69. package/dist/i18n/locales/nl.d.ts +29 -0
  70. package/dist/i18n/locales/nl.js +30 -1
  71. package/dist/i18n/locales/pl.d.ts +29 -0
  72. package/dist/i18n/locales/pl.js +30 -1
  73. package/dist/i18n/locales/pt.d.ts +29 -0
  74. package/dist/i18n/locales/pt.js +30 -1
  75. package/dist/i18n/locales/ro.d.ts +29 -0
  76. package/dist/i18n/locales/ro.js +30 -1
  77. package/dist/i18n/locales/ru.d.ts +29 -0
  78. package/dist/i18n/locales/ru.js +30 -1
  79. package/dist/i18n/locales/sq.d.ts +29 -0
  80. package/dist/i18n/locales/sq.js +30 -1
  81. package/dist/i18n/locales/sv.d.ts +29 -0
  82. package/dist/i18n/locales/sv.js +30 -1
  83. package/dist/i18n/locales/tr.d.ts +29 -0
  84. package/dist/i18n/locales/tr.js +30 -1
  85. package/dist/i18n/locales/zh.d.ts +29 -0
  86. package/dist/i18n/locales/zh.js +30 -1
  87. package/dist/index.js +1209 -1207
  88. package/dist/locales/ar.json +30 -1
  89. package/dist/locales/de.json +30 -1
  90. package/dist/locales/el.json +30 -1
  91. package/dist/locales/en.json +30 -1
  92. package/dist/locales/es.json +30 -1
  93. package/dist/locales/fr.json +30 -1
  94. package/dist/locales/hi.json +30 -1
  95. package/dist/locales/it.json +30 -1
  96. package/dist/locales/ja.json +30 -1
  97. package/dist/locales/nl.json +30 -1
  98. package/dist/locales/pl.json +30 -1
  99. package/dist/locales/pt.json +30 -1
  100. package/dist/locales/ro.json +30 -1
  101. package/dist/locales/ru.json +30 -1
  102. package/dist/locales/sq.json +30 -1
  103. package/dist/locales/sv.json +30 -1
  104. package/dist/locales/tr.json +30 -1
  105. package/dist/locales/zh.json +30 -1
  106. package/dist/patterns/calendar/index.js +1 -1
  107. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  108. package/dist/patterns/registration-form/index.js +1 -1
  109. package/dist/patterns/signature-request/channel-meta.d.ts +8 -2
  110. package/dist/patterns/signature-request/index.js +1 -1
  111. package/dist/patterns/signature-request/minor-patient.d.ts +41 -0
  112. package/dist/patterns/signature-request/required-documents.d.ts +4 -3
  113. package/dist/patterns/signature-request/signature-request.d.ts +62 -12
  114. package/dist/theme-boot.js +26 -0
  115. package/dist/tokens.css +1 -1
  116. package/package.json +4 -2
  117. package/dist/_chunks/booking-D2r19Lia.js +0 -3901
  118. package/dist/_chunks/signature-request-ldmXj2X6.js +0 -2221
  119. package/dist/_chunks/use-theme-CAuo6EYT.js +0 -159
@@ -0,0 +1,4051 @@
1
+ import { jsx as n, jsxs as v, Fragment as pe } from "react/jsx-runtime";
2
+ import { forwardRef as vn, useId as vt, useRef as F, useCallback as Ne, useState as Z, useEffect as K, useMemo as L, Fragment as Un, useImperativeHandle as Gn } from "react";
3
+ import { c as Dt } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as Q, Trans as bn } from "react-i18next";
5
+ import { u as Hn } from "./registry-DvAUVLHh.js";
6
+ import { A as te } from "./alert-9kEwDza3.js";
7
+ import { B as Ye } from "./button-DohK_Ak_.js";
8
+ import { C as ft } from "./checkbox-BjDv-r3o.js";
9
+ import { C as Jn } from "./checkbox-group-Cw2H5qaq.js";
10
+ import { R as Wn } from "./radio-BZQs6_36.js";
11
+ import { R as Yn } from "./radio-group-ChIKyeSJ.js";
12
+ import { D as Zn } from "./date-picker-CdhXlgVI.js";
13
+ import { E as Qn } from "./email-input-C7THAwh2.js";
14
+ import { F as Pe } from "./form-field-Ani72sVY.js";
15
+ import { P as Xn } from "./phone-input-C3NrD-nl.js";
16
+ import { T as es } from "./text-area-COMVJ1yE.js";
17
+ import { T as Lt } from "./text-input-CaG9ApoE.js";
18
+ import { A as ts } from "./address-fields-BUPRs3n-.js";
19
+ import { S as yn } from "./spinner-CoflYlEx.js";
20
+ import { a as zt } from "./format-price-BcFBa-WP.js";
21
+ import { C as ns } from "./credit-card-D9XZsHGA.js";
22
+ import { O as ss } from "./otp-input-BgEZi0py.js";
23
+ import { B as kn } from "./badge-BUk4RjTS.js";
24
+ import { I as cn } from "./icon-button-S8_weU3g.js";
25
+ import { S as jt } from "./select-4S-eYZUf.js";
26
+ import { C as tn } from "./combobox-vF9O-QoG.js";
27
+ import { M as nn } from "./multi-select-BOad3za9.js";
28
+ import { c as is } from "./option-row-Dc7BrbK8.js";
29
+ import { S as Kt } from "./skeleton-tTWJpvAq.js";
30
+ import { E as Sn } from "./empty-state-DwJ5YNzz.js";
31
+ import { S as rs } from "./stepper-accordion-DDTSOUHc.js";
32
+ import { S as os } from "./stepper-progress-D6H8wQiV.js";
33
+ import { S as as } from "./slot-grid-Bb13H9Rl.js";
34
+ import { p as Ie } from "./parseISO-DZZ5a-zK.js";
35
+ import { C as cs } from "./chevron-down-DWE7GSq9.js";
36
+ import { s as gt, f as qt, d as dn } from "./format--x5jypvH.js";
37
+ import { x as xn, a as ht, b as Yt, i as ds, s as At, m as ls, y as Rt } from "./date-picker-variants-Dt6UbonG.js";
38
+ import { s as us } from "./subDays-DKISP2nE.js";
39
+ import { C as ps } from "./chevron-left-B8cOyH-V.js";
40
+ import { C as ms } from "./chevron-right-I9AeSxH2.js";
41
+ import { c as De } from "./createLucideIcon-DhHxpK9K.js";
42
+ import { M as fs, S as gs } from "./sun-Bj9Mr553.js";
43
+ import { S as hs } from "./stethoscope-sZXGC43m.js";
44
+ import { H as vs } from "./heart-pulse-BCppJyN2.js";
45
+ import { E as bs } from "./eye-BjhN2nYf.js";
46
+ import { B as ys } from "./baby-Dku-Xvg9.js";
47
+ import { S as ks } from "./scan-line-CNseIHQ0.js";
48
+ import { A as Ss } from "./astroid-BN4f5VXU.js";
49
+ import { C as xs } from "./clipboard-check-BeAGxDVT.js";
50
+ /**
51
+ * @license lucide-react v1.22.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */
56
+ const Is = [
57
+ [
58
+ "path",
59
+ {
60
+ d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
61
+ key: "169zse"
62
+ }
63
+ ]
64
+ ], Ns = De("activity", Is);
65
+ /**
66
+ * @license lucide-react v1.22.0 - ISC
67
+ *
68
+ * This source code is licensed under the ISC license.
69
+ * See the LICENSE file in the root directory of this source tree.
70
+ */
71
+ const ws = [
72
+ [
73
+ "path",
74
+ {
75
+ d: "M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",
76
+ key: "w610uw"
77
+ }
78
+ ]
79
+ ], Cs = De("bone", ws);
80
+ /**
81
+ * @license lucide-react v1.22.0 - ISC
82
+ *
83
+ * This source code is licensed under the ISC license.
84
+ * See the LICENSE file in the root directory of this source tree.
85
+ */
86
+ const As = [
87
+ ["path", { d: "M12 18V5", key: "adv99a" }],
88
+ ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
89
+ ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
90
+ ["path", { d: "M17.997 5.125a4 4 0 0 1 2.526 5.77", key: "iwvgf7" }],
91
+ ["path", { d: "M18 18a4 4 0 0 0 2-7.464", key: "efp6ie" }],
92
+ ["path", { d: "M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517", key: "1gq6am" }],
93
+ ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
94
+ ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
95
+ ], Ts = De("brain", As);
96
+ /**
97
+ * @license lucide-react v1.22.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */
102
+ const Ds = [
103
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
104
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
105
+ ["path", { d: "M3 10h18", key: "8toen8" }],
106
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
107
+ ["path", { d: "M17 14h-6", key: "bkmgh3" }],
108
+ ["path", { d: "M13 18H7", key: "bb0bb7" }],
109
+ ["path", { d: "M7 14h.01", key: "1qa3f1" }],
110
+ ["path", { d: "M17 18h.01", key: "1bdyru" }]
111
+ ], Os = De("calendar-range", Ds);
112
+ /**
113
+ * @license lucide-react v1.22.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */
118
+ const Ms = [
119
+ ["path", { d: "M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0", key: "1dfaln" }],
120
+ ["path", { d: "M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4", key: "1qnva7" }]
121
+ ], Fs = De("ear", Ms);
122
+ /**
123
+ * @license lucide-react v1.22.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */
128
+ const Es = [
129
+ ["path", { d: "M6 18h8", key: "1borvv" }],
130
+ ["path", { d: "M3 22h18", key: "8prr45" }],
131
+ ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
132
+ ["path", { d: "M9 14h2", key: "197e7h" }],
133
+ ["path", { d: "M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z", key: "1bmzmy" }],
134
+ ["path", { d: "M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3", key: "1drr47" }]
135
+ ], Bs = De("microscope", Es);
136
+ /**
137
+ * @license lucide-react v1.22.0 - ISC
138
+ *
139
+ * This source code is licensed under the ISC license.
140
+ * See the LICENSE file in the root directory of this source tree.
141
+ */
142
+ const Ls = [
143
+ [
144
+ "path",
145
+ { d: "m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z", key: "wa1lgi" }
146
+ ],
147
+ ["path", { d: "m8.5 8.5 7 7", key: "rvfmvr" }]
148
+ ], Rs = De("pill", Ls);
149
+ /**
150
+ * @license lucide-react v1.22.0 - ISC
151
+ *
152
+ * This source code is licensed under the ISC license.
153
+ * See the LICENSE file in the root directory of this source tree.
154
+ */
155
+ const _s = [
156
+ ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
157
+ ["path", { d: "M8.12 8.12 12 12", key: "1alkpv" }],
158
+ ["path", { d: "M20 4 8.12 15.88", key: "xgtan2" }],
159
+ ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
160
+ ["path", { d: "M14.8 14.8 20 20", key: "ptml3r" }]
161
+ ], Ps = De("scissors", _s);
162
+ /**
163
+ * @license lucide-react v1.22.0 - ISC
164
+ *
165
+ * This source code is licensed under the ISC license.
166
+ * See the LICENSE file in the root directory of this source tree.
167
+ */
168
+ const Vs = [
169
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
170
+ ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
171
+ ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
172
+ ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
173
+ ], $s = De("smile", Vs);
174
+ /**
175
+ * @license lucide-react v1.22.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */
180
+ const qs = [
181
+ ["path", { d: "M12 10V2", key: "16sf7g" }],
182
+ ["path", { d: "m4.93 10.93 1.41 1.41", key: "2a7f42" }],
183
+ ["path", { d: "M2 18h2", key: "j10viu" }],
184
+ ["path", { d: "M20 18h2", key: "wocana" }],
185
+ ["path", { d: "m19.07 10.93-1.41 1.41", key: "15zs5n" }],
186
+ ["path", { d: "M22 22H2", key: "19qnx5" }],
187
+ ["path", { d: "m16 6-4 4-4-4", key: "6wukr" }],
188
+ ["path", { d: "M16 18a4 4 0 0 0-8 0", key: "1lzouq" }]
189
+ ], Ks = De("sunset", qs);
190
+ /**
191
+ * @license lucide-react v1.22.0 - ISC
192
+ *
193
+ * This source code is licensed under the ISC license.
194
+ * See the LICENSE file in the root directory of this source tree.
195
+ */
196
+ const zs = [
197
+ ["path", { d: "m18 2 4 4", key: "22kx64" }],
198
+ ["path", { d: "m17 7 3-3", key: "1w1zoj" }],
199
+ ["path", { d: "M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5", key: "1exhtz" }],
200
+ ["path", { d: "m9 11 4 4", key: "rovt3i" }],
201
+ ["path", { d: "m5 19-3 3", key: "59f2uf" }],
202
+ ["path", { d: "m14 4 6 6", key: "yqp9t2" }]
203
+ ], ln = De("syringe", zs);
204
+ function js(e, t, s) {
205
+ return xn(e, -1, s);
206
+ }
207
+ const Us = {
208
+ id: "booking",
209
+ // `view_change` removed (0.69): the layout `variant` is a fixed prop — the
210
+ // handle exposes only `getVariant` (state), no action mutates it. The flow's
211
+ // only navigation is step-to-step (`goto_step` → `navigate`).
212
+ capabilities: ["navigate"],
213
+ state: {
214
+ variant: {
215
+ type: "string",
216
+ descriptionKey: "ui.agent.booking.state.variant",
217
+ description: "Active variant — one of `inline-list`, `accordion`, `calendar`, `flexible`, `progress`.",
218
+ read: (e) => e.getVariant()
219
+ },
220
+ currentStep: {
221
+ type: "number",
222
+ descriptionKey: "ui.agent.booking.state.currentStep",
223
+ description: "The step the flow is on: 1 insurance, 2 specialty, 3 service, 4 provider, 5 date, 6 time, 7 patient details, payment or optional SMS code verification, 8 confirmation after all required steps succeed. Read this back after `goto_step` to see where the clamp landed.",
224
+ read: (e) => e.getCurrentStep()
225
+ }
226
+ },
227
+ actions: {
228
+ reset: {
229
+ // destructive: clears the whole in-progress booking value (patient
230
+ // identity, contact, slot choice) — irreversibly loses user input.
231
+ safety: "destructive",
232
+ idempotent: !0,
233
+ descriptionKey: "ui.agent.booking.actions.reset",
234
+ description: "Clear the booking value back to an empty state. Use to abandon an in-progress flow.",
235
+ errors: [
236
+ "Refused while a payment session is open (step 7): the consumer must cancel the hold first.",
237
+ "Refused while SMS code verification is pending (step 7): the submitted booking remains active. The host owns cancellation."
238
+ ],
239
+ invoke: (e) => {
240
+ e.reset();
241
+ }
242
+ },
243
+ goto_step: {
244
+ safety: "read",
245
+ argsType: "{ step: 1 | 2 | 3 | 4 | 5 | 6 | 7 }",
246
+ argsSchema: {
247
+ type: "object",
248
+ properties: {
249
+ step: {
250
+ type: "integer",
251
+ enum: [1, 2, 3, 4, 5, 6, 7],
252
+ description: "Target step (1-7)."
253
+ }
254
+ },
255
+ required: ["step"]
256
+ },
257
+ idempotent: !0,
258
+ descriptionKey: "ui.agent.booking.actions.gotoStep",
259
+ description: "Jump to the given step. A step that is hidden for this practice, or that sits ahead of the first incomplete step, clamps to that first incomplete step — read `currentStep` back to see where it landed.",
260
+ errors: [
261
+ "Navigation stays on step 7 while payment or SMS code verification is pending.",
262
+ "Requested step is not yet reachable — clamped to the first incomplete step.",
263
+ "Requested step is hidden for this practice (e.g. insurance outside Germany, or provider choice turned off) — clamped to the first incomplete step."
264
+ ],
265
+ examples: [{ args: { step: 1 }, note: "Return to the first step." }],
266
+ invoke: (e, t) => {
267
+ e.goToStep(t.step);
268
+ }
269
+ }
270
+ },
271
+ domHooks: {
272
+ root: {
273
+ attr: "data-component",
274
+ value: "booking",
275
+ description: 'Marks the Booking root region. The host prop hideEmail (boolean, default false) hides the email field, skips its validation and omits email from submission. Pair with confirmationChannels ["sms"] for SMS-only confirmation with no channel picker. The optional codeStep prop adds SMS verification after submission and payment; the step remains 7 until verification succeeds, then becomes 8. Patient contact details and verification codes are never exposed through this adapter.'
276
+ },
277
+ instanceId: {
278
+ attr: "data-component-id",
279
+ sourceProp: "id",
280
+ description: "Sourced from the id prop."
281
+ }
282
+ }
283
+ }, Xt = [
284
+ "email",
285
+ "whatsapp",
286
+ "sms"
287
+ ], Ee = "all", Gs = "de";
288
+ function Hs(e) {
289
+ const t = e.lockedOperatorId;
290
+ return [...t ? e.operatorsByService ? e.specialties.filter(
291
+ (i) => e.services.some(
292
+ (r) => {
293
+ var a;
294
+ return r.specialtyId === i.id && ((a = r.operatorIds) == null ? void 0 : a.includes(t));
295
+ }
296
+ )
297
+ ) : e.specialties.filter((i) => {
298
+ var r;
299
+ return (r = i.operatorIds) == null ? void 0 : r.includes(t);
300
+ }) : e.specialties].sort((i, r) => {
301
+ const a = i.sequenceNumber ?? Number.POSITIVE_INFINITY, d = r.sequenceNumber ?? Number.POSITIVE_INFINITY;
302
+ return a - d;
303
+ });
304
+ }
305
+ function Js(e) {
306
+ let t = e.services;
307
+ if (e.lockedOperatorId && (t = t.filter(
308
+ (i) => {
309
+ var r;
310
+ return (r = i.operatorIds) == null ? void 0 : r.includes(e.lockedOperatorId);
311
+ }
312
+ )), e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) {
313
+ const i = Ze(e.value);
314
+ i.length > 0 && (t = t.filter(
315
+ (r) => r.specialtyId !== void 0 && i.includes(r.specialtyId)
316
+ ));
317
+ }
318
+ return t;
319
+ }
320
+ function Ws(e) {
321
+ const t = e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties, s = $e(e.value);
322
+ if ((!t || e.operatorsByService) && s.length > 0)
323
+ return e.operators.filter(
324
+ (i) => {
325
+ var r;
326
+ return (r = i.appointmentBookingReasonIds) == null ? void 0 : r.some((a) => s.includes(a));
327
+ }
328
+ );
329
+ if (t) {
330
+ const i = Ze(e.value);
331
+ if (i.length > 0)
332
+ return e.operators.filter(
333
+ (r) => {
334
+ var a;
335
+ return (a = r.specialtyIds) == null ? void 0 : a.some((d) => i.includes(d));
336
+ }
337
+ );
338
+ }
339
+ return [];
340
+ }
341
+ function Ys(e, t) {
342
+ const s = e.country === Gs, i = !s || e.value.insuranceType !== void 0, a = (e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) && i, d = Ze(e.value).length > 0, p = !a || d, f = $e(e.value).length > 0, g = !p || f, h = t.operators, l = !!e.allowOperatorSelection && g && f && !e.lockedOperatorId && h.length > 1, o = g && f, b = (!o || e.value.date !== void 0) && e.value.date !== void 0, E = (!b || e.value.slotKey !== void 0) && e.value.slotKey !== void 0, I = f && h.length === 0;
343
+ return {
344
+ insurance: s,
345
+ specialty: a,
346
+ service: p,
347
+ operator: l,
348
+ date: o,
349
+ slot: b,
350
+ details: E,
351
+ onboardingIncomplete: I
352
+ };
353
+ }
354
+ function Zs(e, t) {
355
+ const s = [];
356
+ return t.insurance && s.push(1), t.specialty && s.push(2), s.push(3), t.operator && s.push(4), s.push(5), s.push(6), s.push(7), {
357
+ currentStep: s.find(
358
+ (r) => !Ve(r, e.value)
359
+ ) ?? 7,
360
+ visibleSteps: s
361
+ };
362
+ }
363
+ function Ve(e, t) {
364
+ switch (e) {
365
+ case 1:
366
+ return t.insuranceType !== void 0;
367
+ // 0.34.0: array-or-single — satisfied when EITHER form is present.
368
+ case 2:
369
+ return Ze(t).length > 0;
370
+ case 3:
371
+ return $e(t).length > 0;
372
+ // Always satisfied, like its gate: "no preference" is a valid answer,
373
+ // whether it is the `'all'` sentinel or an empty multi-select.
374
+ case 4:
375
+ return !0;
376
+ case 5:
377
+ return t.date !== void 0;
378
+ case 6:
379
+ return t.slotKey !== void 0;
380
+ // Details fulfilment is owned by the form's own validation.
381
+ case 7:
382
+ return !1;
383
+ }
384
+ }
385
+ function Qs(e) {
386
+ const t = {
387
+ specialties: Hs(e),
388
+ services: Js(e),
389
+ operators: Ws(e)
390
+ }, s = Ys(e, t), { currentStep: i, visibleSteps: r } = Zs(e, s);
391
+ let a;
392
+ if (e.value.date && e.value.slotKey) {
393
+ const g = e.availableSlots[e.value.date];
394
+ g && (a = g.find((h) => h.key === e.value.slotKey));
395
+ }
396
+ const d = $e(e.value), m = d.length > 0 ? e.services.find((g) => g.id === d[0]) : void 0, p = Ze(e.value).length > 0, f = d.length > 0 && e.value.date !== void 0 && e.value.slotKey !== void 0 && (!s.insurance || e.value.insuranceType !== void 0) && (!s.specialty || p);
397
+ return {
398
+ gates: s,
399
+ filtered: t,
400
+ currentStep: i,
401
+ totalSteps: r.length,
402
+ visibleSteps: r,
403
+ isReadyToSubmit: f,
404
+ durationMin: m == null ? void 0 : m.durationMin,
405
+ selectedSlot: a
406
+ };
407
+ }
408
+ function In(e, t) {
409
+ return {
410
+ ...e,
411
+ insuranceType: t,
412
+ specialtyId: void 0,
413
+ serviceId: void 0,
414
+ operatorId: void 0,
415
+ date: void 0,
416
+ slotKey: void 0,
417
+ details: void 0
418
+ };
419
+ }
420
+ function Nn(e, t) {
421
+ return {
422
+ ...e,
423
+ specialtyId: t,
424
+ specialtyIds: void 0,
425
+ serviceId: void 0,
426
+ serviceIds: void 0,
427
+ operatorId: void 0,
428
+ operatorIds: void 0,
429
+ date: void 0,
430
+ slotKey: void 0,
431
+ details: void 0
432
+ };
433
+ }
434
+ function wn(e, t) {
435
+ return {
436
+ ...e,
437
+ specialtyId: void 0,
438
+ specialtyIds: t,
439
+ serviceId: void 0,
440
+ serviceIds: void 0,
441
+ operatorId: void 0,
442
+ operatorIds: void 0,
443
+ date: void 0,
444
+ slotKey: void 0,
445
+ details: void 0
446
+ };
447
+ }
448
+ function Cn(e, t) {
449
+ return {
450
+ ...e,
451
+ serviceId: t,
452
+ serviceIds: void 0,
453
+ // Default the operator to the "All operators" sentinel so a patient
454
+ // who doesn't care about picking lands on a satisfied step 4 without
455
+ // any further input.
456
+ operatorId: t ? Ee : void 0,
457
+ operatorIds: void 0,
458
+ date: void 0,
459
+ slotKey: void 0,
460
+ details: void 0
461
+ };
462
+ }
463
+ function An(e, t) {
464
+ const s = !!t && t.length > 0;
465
+ return {
466
+ ...e,
467
+ serviceId: void 0,
468
+ serviceIds: t,
469
+ operatorId: s ? Ee : void 0,
470
+ operatorIds: void 0,
471
+ date: void 0,
472
+ slotKey: void 0,
473
+ details: void 0
474
+ };
475
+ }
476
+ function Tn(e, t) {
477
+ return {
478
+ ...e,
479
+ operatorId: t,
480
+ operatorIds: void 0,
481
+ date: void 0,
482
+ slotKey: void 0,
483
+ details: void 0
484
+ };
485
+ }
486
+ function Dn(e, t) {
487
+ return {
488
+ ...e,
489
+ operatorId: void 0,
490
+ operatorIds: t,
491
+ date: void 0,
492
+ slotKey: void 0,
493
+ details: void 0
494
+ };
495
+ }
496
+ function Ze(e) {
497
+ return e.specialtyIds && e.specialtyIds.length > 0 ? e.specialtyIds : e.specialtyId ? [e.specialtyId] : [];
498
+ }
499
+ function $e(e) {
500
+ return e.serviceIds && e.serviceIds.length > 0 ? e.serviceIds : e.serviceId ? [e.serviceId] : [];
501
+ }
502
+ function en(e) {
503
+ return e.operatorIds && e.operatorIds.length > 0 ? e.operatorIds : e.operatorId ? [e.operatorId] : [];
504
+ }
505
+ function Ut(e, t) {
506
+ return {
507
+ ...e,
508
+ date: t,
509
+ slotKey: void 0
510
+ // Keep details — date/slot changes shouldn't wipe the patient form
511
+ // since the user has already filled some fields.
512
+ };
513
+ }
514
+ function On(e, t) {
515
+ return {
516
+ ...e,
517
+ slotKey: t
518
+ };
519
+ }
520
+ function Xs(e, t) {
521
+ let s = e;
522
+ if (t.lockedOperatorId && s.operatorId !== t.lockedOperatorId && (s = { ...s, operatorId: t.lockedOperatorId }), (t.useSpecialties === void 0 ? t.specialties.length > 0 : t.useSpecialties) && t.specialties.length === 1 && s.specialtyId === void 0 && s.specialtyIds === void 0 && (s = { ...s, specialtyId: t.specialties[0].id }), t.autoSelectSingleService) {
523
+ const r = Ze(s), a = r.length > 0 ? t.services.filter(
524
+ (d) => d.specialtyId && r.includes(d.specialtyId)
525
+ ) : t.services;
526
+ a.length === 1 && s.serviceId === void 0 && s.serviceIds === void 0 && (s = { ...s, serviceId: a[0].id }, s.operatorId === void 0 && s.operatorIds === void 0 && (s = { ...s, operatorId: Ee }));
527
+ }
528
+ return s;
529
+ }
530
+ function Mn(e) {
531
+ if (e.operatorId && e.operatorId !== Ee)
532
+ return e.operatorId;
533
+ }
534
+ function ei(e) {
535
+ if (!e) return !1;
536
+ const t = e.trim();
537
+ return /^\+?\d[\d\s\-()]{6,}$/.test(t);
538
+ }
539
+ function sn(e) {
540
+ const t = e && e.length > 0 ? e : ["email"], s = new Set(t);
541
+ return Xt.filter((i) => s.has(i));
542
+ }
543
+ function ti(e, t, s) {
544
+ const i = sn(e), r = new Set(i);
545
+ if (s)
546
+ return Xt.filter(
547
+ (f) => s.includes(f) && r.has(f)
548
+ );
549
+ const a = [];
550
+ r.has("email") && a.push("email");
551
+ const d = ei(t), m = r.has("whatsapp");
552
+ m && d && a.push("whatsapp"), !m && r.has("sms") && a.push("sms");
553
+ const p = new Set(a);
554
+ return Xt.filter((f) => p.has(f));
555
+ }
556
+ const ni = /https?:\/\/(?:(?![.,;:!?'»›]https?:\/\/)[^\s<>"\u060C\u061B\u061F\u06D4\u2000-\u206F\u3000-\u303F\uFF00-\uFFEF])+/gi, si = /* @__PURE__ */ new Set([
557
+ ".",
558
+ ",",
559
+ ";",
560
+ ":",
561
+ "!",
562
+ "?",
563
+ "'",
564
+ "»",
565
+ "›"
566
+ ]), ii = { ")": "(", "]": "[", "}": "{" }, un = (e, t) => e.split(t).length - 1;
567
+ function ri(e) {
568
+ const t = {};
569
+ for (const [i, r] of Object.entries(ii))
570
+ t[i] = un(e, i) - un(e, r);
571
+ let s = e.length;
572
+ for (; s > 0; ) {
573
+ const i = e[s - 1];
574
+ if (si.has(i))
575
+ s -= 1;
576
+ else if (i in t && t[i] > 0)
577
+ t[i] -= 1, s -= 1;
578
+ else
579
+ break;
580
+ }
581
+ return e.slice(0, s);
582
+ }
583
+ const oi = /[\u0600-\u06FF\u3040-\u30FF\u3400-\u9FFF\uAC00-\uD7AF]/, ai = /[A-Za-z0-9]/;
584
+ function ci(e) {
585
+ const t = e.search(oi);
586
+ return t > 0 && ai.test(e[t - 1]) ? e.slice(0, t) : e;
587
+ }
588
+ function di(e) {
589
+ try {
590
+ const { protocol: t, hostname: s } = new URL(e);
591
+ return (t === "http:" || t === "https:") && s !== "";
592
+ } catch {
593
+ return !1;
594
+ }
595
+ }
596
+ function li(e) {
597
+ const t = [];
598
+ let s = 0;
599
+ const i = (r) => {
600
+ if (r === "") return;
601
+ const a = t[t.length - 1];
602
+ (a == null ? void 0 : a.kind) === "text" ? a.text += r : t.push({ kind: "text", text: r });
603
+ };
604
+ for (const r of e.matchAll(ni)) {
605
+ const a = r.index ?? 0, d = ri(ci(r[0]));
606
+ di(d) && (i(e.slice(s, a)), t.push({ kind: "link", text: d, href: d }), s = a + d.length);
607
+ }
608
+ return i(e.slice(s)), t;
609
+ }
610
+ const pn = 500, ui = /^[A-Z0-9]{16}$/, pi = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, mn = 300, Zt = "ds:rounded-[var(--radius-sm)] ds:underline ds:text-[var(--foreground)] ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]", _t = (e) => e && /^https?:\/\//i.test(e) ? e : void 0, mi = (e, t) => ({
611
+ street: (e == null ? void 0 : e.address.line1) ?? "",
612
+ city: (e == null ? void 0 : e.address.city) ?? "",
613
+ postcode: (e == null ? void 0 : e.address.postalCode) ?? "",
614
+ province: (e == null ? void 0 : e.address.state) ?? "",
615
+ // The practice's country only until the patient has an address at all.
616
+ country: (e ? e.address.country : t).toLowerCase(),
617
+ formatted: ""
618
+ }), fi = (e, t, s = null) => ({
619
+ name: t,
620
+ address: {
621
+ line1: e.street,
622
+ line2: s,
623
+ city: e.city,
624
+ state: e.province,
625
+ postalCode: e.postcode,
626
+ country: e.country.toUpperCase()
627
+ }
628
+ }), gi = Dt("ds:flex ds:flex-col ds:border", {
629
+ variants: {
630
+ noticeStyle: {
631
+ plain: "ds:gap-[var(--spacing-xs)] ds:rounded-[var(--radius-md)] ds:border-[var(--border)] ds:bg-[var(--muted)] ds:p-[var(--spacing-sm)]",
632
+ highlighted: "ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-lg)] ds:border-[color-mix(in_srgb,var(--primary)_30%,var(--border))] ds:bg-[color-mix(in_srgb,var(--primary)_8%,var(--card))] ds:p-[var(--spacing-md)]"
633
+ }
634
+ },
635
+ defaultVariants: { noticeStyle: "highlighted" }
636
+ }), hi = ["it", "ch", "de", "at", "fr", "sm"], H = {
637
+ country: "billing.country",
638
+ street: "billing.street",
639
+ city: "billing.city",
640
+ postcode: "billing.postcode",
641
+ province: "billing.province"
642
+ }, Fn = /^\d{5}$/, vi = (e) => {
643
+ if (!e) return !1;
644
+ const { line1: t, city: s, postalCode: i, country: r, state: a } = e.address;
645
+ return !t.trim() || !s.trim() || !i.trim() || !r.trim() ? !1 : r.toUpperCase() !== "IT" ? !0 : !!a.trim() && Fn.test(i.trim());
646
+ }, bi = (e, t) => {
647
+ var s;
648
+ return {
649
+ name: t,
650
+ address: {
651
+ line1: e.address.line1.trim(),
652
+ line2: ((s = e.address.line2) == null ? void 0 : s.trim()) || null,
653
+ city: e.address.city.trim(),
654
+ state: e.address.state.trim(),
655
+ postalCode: e.address.postalCode.trim(),
656
+ country: e.address.country.trim().toUpperCase()
657
+ }
658
+ };
659
+ }, Pt = { state: "idle" }, fn = [
660
+ "firstName",
661
+ "lastName",
662
+ "email",
663
+ "mobilePhone",
664
+ "codiceFiscale",
665
+ "dateOfBirth",
666
+ "insuranceNumber",
667
+ H.country,
668
+ H.street,
669
+ H.city,
670
+ H.postcode,
671
+ H.province
672
+ ], yi = /* @__PURE__ */ new Set(), rn = vn(
673
+ ({
674
+ value: e,
675
+ onChange: t,
676
+ onSubmit: s,
677
+ hideEmail: i = !1,
678
+ requireCodiceFiscale: r = !1,
679
+ requireDateOfBirth: a = !1,
680
+ requireInsuranceNumber: d = !1,
681
+ insuranceType: m,
682
+ showNote: p = !1,
683
+ showReturningPatientFlag: f = !1,
684
+ privacyPolicyUrl: g,
685
+ termsUrl: h,
686
+ practiceConsent: l,
687
+ payment: o,
688
+ paymentTermsUrl: y,
689
+ paymentBlocked: b = !1,
690
+ billingInDetails: S = !1,
691
+ paymentNoticeStyle: E = "highlighted",
692
+ criticalInformationToAccept: I,
693
+ validateCodiceFiscale: N,
694
+ validateInsuranceNumber: x,
695
+ submitting: M = !1,
696
+ summarySlot: T,
697
+ defaultPhoneCountry: O,
698
+ confirmationChannels: u,
699
+ defaultConfirmationChannels: w,
700
+ singleConfirmationChannel: D = !1,
701
+ submitError: z
702
+ }, U) => {
703
+ var wt, Ct, A, B, V;
704
+ const { t: k, i18n: _ } = Q("ui"), j = vt(), me = F(null), P = Ne(
705
+ (c) => {
706
+ me.current = c, typeof U == "function" ? U(c) : U && (U.current = c);
707
+ },
708
+ [U]
709
+ ), [J, ne] = Z(0);
710
+ K(() => {
711
+ var C;
712
+ if (J === 0) return;
713
+ const c = (C = me.current) == null ? void 0 : C.querySelectorAll(
714
+ '[aria-invalid="true"], [role="checkbox"][aria-required="true"][aria-checked="false"], [data-unanswered] [role="checkbox"]'
715
+ );
716
+ for (const W of c ?? [])
717
+ if (W.focus(), document.activeElement === W) return;
718
+ }, [J]);
719
+ const re = F(!1), [he, X] = Z(!1), [qe, ve] = Z(!1), fe = M || he, [se, be] = Z(Pt), [we, Oe] = Z(Pt), [oe, Me] = Z({}), ce = Ne(
720
+ (c) => Me((C) => ({ ...C, [c]: !0 })),
721
+ []
722
+ ), [Be, Ce] = Z(yi), ie = F(null), Ke = F(
723
+ null
724
+ );
725
+ K(
726
+ () => () => {
727
+ ie.current && clearTimeout(ie.current), Ke.current && clearTimeout(Ke.current);
728
+ },
729
+ []
730
+ );
731
+ const q = Ne(
732
+ (c) => {
733
+ ve(!1), t({ ...e, ...c });
734
+ },
735
+ [e, t]
736
+ ), Le = o ? JSON.stringify([
737
+ o.serviceId,
738
+ o.kind,
739
+ o.amountCents,
740
+ o.currencyCode,
741
+ y
742
+ ]) : void 0, [Qe, Ot] = Z(
743
+ () => e.paymentAccepted ? Le : void 0
744
+ ), it = F(Le), rt = !!(o && e.paymentAccepted && Qe === Le);
745
+ K(() => {
746
+ it.current !== Le && (it.current = Le, Ot(void 0), e.paymentAccepted !== void 0 && q({ paymentAccepted: o ? !1 : void 0 }));
747
+ }, [Le, o, q, e.paymentAccepted]);
748
+ const ot = typeof (l == null ? void 0 : l.label) == "string" && l.label.trim() !== "", Fe = l && ot ? JSON.stringify([
749
+ l.label,
750
+ l.url ?? null,
751
+ l.required
752
+ ]) : void 0, [de, Mt] = Z(
753
+ () => e.practiceConsentAccepted ? Fe : void 0
754
+ ), ge = F(Fe), ze = !!(Fe !== void 0 && e.practiceConsentAccepted && de === Fe);
755
+ K(() => {
756
+ ge.current !== Fe && (ge.current = Fe, Mt(void 0), e.practiceConsentAccepted !== void 0 && q({ practiceConsentAccepted: void 0 }));
757
+ }, [Fe, q, e.practiceConsentAccepted]);
758
+ const ye = o ? zt(o.amountCents, o.currencyCode, _.language) : "", je = _t(y), R = S && !!o && !b, ke = r, at = (O || "it").toLowerCase(), yt = !R || vi(e.billing), ae = mi(e.billing, at), Se = ae.country === "it", kt = F(null), Ue = F(
759
+ null
760
+ ), le = (wt = e.billing) == null ? void 0 : wt.address.line1.trim(), Xe = ((A = (Ct = e.billing) == null ? void 0 : Ct.address.line2) == null ? void 0 : A.trim()) || null;
761
+ K(() => {
762
+ var c;
763
+ le !== void 0 && Xe ? Ue.current = { street: le, line2: Xe } : (le === void 0 || le === ((c = Ue.current) == null ? void 0 : c.street)) && (Ue.current = null);
764
+ }, [le, Xe]);
765
+ const Ge = (c) => (
766
+ // Nothing for a block not shown, nor for a province outside Italy.
767
+ !R || !oe[H[c]] || c === "province" && !Se ? void 0 : ae[c].trim() ? (
768
+ // The one format the block itself checks: an Italian CAP.
769
+ c === "postcode" && Se && !Fn.test(ae.postcode.trim()) ? k("inputs.postalCode.invalid") : void 0
770
+ ) : k("booking.details.fieldRequired")
771
+ ), Ht = Ne(
772
+ () => Me(
773
+ (c) => c[H.province] ? c : {
774
+ ...c,
775
+ codiceFiscale: !0,
776
+ ...Object.fromEntries(
777
+ Object.values(H).map((C) => [C, !0])
778
+ )
779
+ }
780
+ ),
781
+ []
782
+ ), Re = L(
783
+ () => sn(u),
784
+ [u]
785
+ ), xe = !o && !b && Re.length >= 2, et = F(!1);
786
+ K(() => {
787
+ if (o || b) return;
788
+ if (!xe) {
789
+ e.confirmationChannels !== void 0 && q({ confirmationChannels: void 0 });
790
+ return;
791
+ }
792
+ if (e.confirmationChannels !== void 0) {
793
+ et.current = !0, D && e.confirmationChannels.length > 1 && q({
794
+ confirmationChannels: e.confirmationChannels.slice(0, 1)
795
+ });
796
+ return;
797
+ }
798
+ const c = D ? [
799
+ (w == null ? void 0 : w.find(
800
+ (C) => Re.includes(C)
801
+ )) ?? Re[0]
802
+ ] : ti(
803
+ Re,
804
+ e.mobilePhone,
805
+ w
806
+ );
807
+ et.current = !0, q({ confirmationChannels: c });
808
+ }, [
809
+ xe,
810
+ o,
811
+ b,
812
+ Re,
813
+ e.mobilePhone,
814
+ w,
815
+ D
816
+ ]);
817
+ const $ = L(
818
+ () => e.confirmationChannels ?? [],
819
+ [e.confirmationChannels]
820
+ ), Y = xe && $.length === 0, St = F(N), ct = F(x);
821
+ K(() => {
822
+ St.current = N, ct.current = x;
823
+ }, [N, x]);
824
+ const xt = !!N, It = !!x;
825
+ K(() => {
826
+ const c = e.codiceFiscale;
827
+ if (!ke || !xt || !c) {
828
+ be(Pt);
829
+ return;
830
+ }
831
+ if (!ui.test(c)) {
832
+ be({
833
+ state: "invalid",
834
+ hint: k("booking.details.codiceFiscale.invalidFormat")
835
+ });
836
+ return;
837
+ }
838
+ be({ state: "pending" });
839
+ let C = !0;
840
+ return ie.current && clearTimeout(ie.current), ie.current = setTimeout(async () => {
841
+ try {
842
+ const W = St.current;
843
+ if (!W) return;
844
+ const nt = await W(c);
845
+ C && be({
846
+ state: nt.valid ? "valid" : "invalid",
847
+ hint: nt.hint,
848
+ value: c
849
+ });
850
+ } catch {
851
+ C && be({
852
+ state: "invalid",
853
+ hint: k("booking.details.codiceFiscale.unavailable"),
854
+ value: c
855
+ });
856
+ }
857
+ }, mn), () => {
858
+ C = !1, ie.current && clearTimeout(ie.current);
859
+ };
860
+ }, [ke, xt, e.codiceFiscale, k]);
861
+ const He = d && m === "public";
862
+ K(() => {
863
+ const c = e.insuranceNumber;
864
+ if (!He || !It || !c) {
865
+ Oe(Pt);
866
+ return;
867
+ }
868
+ Oe({ state: "pending" }), Ke.current && clearTimeout(Ke.current), Ke.current = setTimeout(() => {
869
+ const C = ct.current;
870
+ C && C(c).then(
871
+ (W) => Oe(
872
+ W.valid ? { state: "valid" } : { state: "invalid", hint: W.hint }
873
+ )
874
+ ).catch(
875
+ () => Oe({
876
+ state: "invalid",
877
+ hint: k("booking.details.insuranceNumber.unavailable")
878
+ })
879
+ );
880
+ }, mn);
881
+ }, [He, It, e.insuranceNumber, k]);
882
+ const dt = L(
883
+ () => i || !!(e.email && pi.test(e.email)),
884
+ [i, e.email]
885
+ ), lt = L(
886
+ () => !!(e.mobilePhone && e.mobilePhone.length >= 6),
887
+ [e.mobilePhone]
888
+ ), tt = L(() => {
889
+ var c, C;
890
+ return !(!((c = e.firstName) != null && c.trim()) || !((C = e.lastName) != null && C.trim()) || !dt || !lt || ke && (se.state !== "valid" || se.value !== e.codiceFiscale) || !yt || a && !e.dateOfBirth || He && we.state !== "valid");
891
+ }, [
892
+ e.firstName,
893
+ e.lastName,
894
+ dt,
895
+ lt,
896
+ ke,
897
+ yt,
898
+ se.state,
899
+ se.value,
900
+ e.codiceFiscale,
901
+ a,
902
+ e.dateOfBirth,
903
+ He,
904
+ we.state
905
+ ]), ut = I != null && I.trim() ? I : void 0, _e = ut !== void 0, Ft = !_e || !!e.criticalInformationAccepted, Jt = !ot || !(l != null && l.required) || ze, Ae = !!(e.privacyConsent && e.termsConsent && Ft && Jt), Wt = !xe || $.length > 0, pt = tt && Ae && Wt && (!o || rt) && !b && !fe, mt = !pt && !fe && !b, Je = `${j}-submit-hint`, G = {
906
+ firstName: oe.firstName && !((B = e.firstName) != null && B.trim()) ? k("booking.details.firstName.required") : void 0,
907
+ lastName: oe.lastName && !((V = e.lastName) != null && V.trim()) ? k("booking.details.lastName.required") : void 0,
908
+ email: !i && oe.email && !dt ? k("booking.details.email.invalid") : void 0,
909
+ mobilePhone: oe.mobilePhone && !lt ? k("booking.details.mobilePhone.invalid") : void 0,
910
+ codiceFiscale: oe.codiceFiscale && se.state === "invalid" ? se.hint ?? k("booking.details.codiceFiscale.invalid") : oe.codiceFiscale && !e.codiceFiscale ? k("booking.details.fieldRequired") : void 0,
911
+ dateOfBirth: oe.dateOfBirth && !e.dateOfBirth ? k("booking.details.dateOfBirth.required") : void 0,
912
+ insuranceNumber: oe.insuranceNumber && we.state === "invalid" ? we.hint ?? k("booking.details.insuranceNumber.invalid") : void 0,
913
+ [H.country]: Ge("country"),
914
+ [H.street]: Ge("street"),
915
+ [H.city]: Ge("city"),
916
+ [H.postcode]: Ge("postcode"),
917
+ [H.province]: Ge("province")
918
+ }, We = fn.filter(
919
+ (c) => Be.has(c) && G[c] !== void 0
920
+ );
921
+ We.length !== Be.size && Ce(new Set(We));
922
+ const ue = (c) => !Be.has(c), Et = async (c) => {
923
+ if (c.preventDefault(), !fe && !re.current && !pt && Ce(
924
+ new Set(
925
+ fn.filter(
926
+ (W) => Be.has(W) || !G[W]
927
+ )
928
+ )
929
+ ), Me({
930
+ firstName: !0,
931
+ lastName: !0,
932
+ email: !i,
933
+ mobilePhone: !0,
934
+ codiceFiscale: !0,
935
+ dateOfBirth: !0,
936
+ insuranceNumber: !0,
937
+ ...Object.fromEntries(
938
+ Object.values(H).map((W) => [W, !0])
939
+ )
940
+ }), fe || re.current) return;
941
+ if (!pt) {
942
+ ne((W) => W + 1);
943
+ return;
944
+ }
945
+ const C = {
946
+ firstName: e.firstName.trim(),
947
+ lastName: e.lastName.trim(),
948
+ ...i ? {} : { email: e.email.trim() },
949
+ mobilePhone: e.mobilePhone,
950
+ privacyConsent: !0,
951
+ termsConsent: !0,
952
+ // Only present when the service carried text to accept — a
953
+ // reason without it leaves the key out of the payload entirely.
954
+ ..._e ? { criticalInformationAccepted: !0 } : {},
955
+ // Sent whenever the practice's box is shown, ticked or not, so the
956
+ // server can record the answer; left out when there is no box.
957
+ ...ot ? { practiceConsentAccepted: ze } : {},
958
+ ...o ? { paymentAccepted: !0 } : {},
959
+ codiceFiscale: e.codiceFiscale,
960
+ dateOfBirth: e.dateOfBirth,
961
+ insuranceNumber: e.insuranceNumber,
962
+ note: e.note,
963
+ returningPatient: e.returningPatient,
964
+ // Only include when the picker was visible; otherwise the single
965
+ // implicit channel is inferred backend-side from the practice
966
+ // config.
967
+ confirmationChannels: xe ? $ : void 0,
968
+ ...R && e.billing ? {
969
+ billing: bi(
970
+ e.billing,
971
+ `${e.firstName.trim()} ${e.lastName.trim()}`
972
+ )
973
+ } : {}
974
+ };
975
+ re.current = !0, X(!0), ve(!1);
976
+ try {
977
+ await s(C);
978
+ } catch {
979
+ ve(!0);
980
+ } finally {
981
+ re.current = !1, X(!1);
982
+ }
983
+ }, Bt = /* @__PURE__ */ n(
984
+ Pe,
985
+ {
986
+ label: k("booking.details.codiceFiscale.label"),
987
+ required: !0,
988
+ description: se.state === "pending" ? k("booking.details.codiceFiscale.checking") : k("booking.details.codiceFiscale.helper"),
989
+ error: G.codiceFiscale,
990
+ announceError: ue("codiceFiscale"),
991
+ children: /* @__PURE__ */ n(
992
+ Lt,
993
+ {
994
+ value: e.codiceFiscale ?? "",
995
+ maxLength: 16,
996
+ onChange: (c) => q({
997
+ codiceFiscale: c.target.value.slice(0, 16).toUpperCase()
998
+ }),
999
+ onBlur: () => ce("codiceFiscale")
1000
+ }
1001
+ )
1002
+ }
1003
+ ), Nt = (c, C) => {
1004
+ const W = _t(C);
1005
+ return W ? /* @__PURE__ */ n(
1006
+ bn,
1007
+ {
1008
+ ns: "ui",
1009
+ i18nKey: c,
1010
+ components: {
1011
+ // The `<Trans>` runtime injects link text from the i18n
1012
+ // string. The anchor renders empty at static-analysis time,
1013
+ // so `jsx-a11y/anchor-has-content` would false-flag — silence
1014
+ // it; the runtime content is the localised policy / terms
1015
+ // label.
1016
+ policyLink: (
1017
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
1018
+ /* @__PURE__ */ n(
1019
+ "a",
1020
+ {
1021
+ href: W,
1022
+ target: "_blank",
1023
+ rel: "noopener noreferrer",
1024
+ className: Zt
1025
+ }
1026
+ )
1027
+ )
1028
+ }
1029
+ }
1030
+ ) : k(c);
1031
+ };
1032
+ return /* @__PURE__ */ v(
1033
+ "form",
1034
+ {
1035
+ ref: P,
1036
+ id: j,
1037
+ noValidate: !0,
1038
+ onSubmit: Et,
1039
+ onFocus: (c) => {
1040
+ const C = kt.current;
1041
+ !C || !c.currentTarget.contains(c.target) || !C.contains(c.target) && C.compareDocumentPosition(c.target) & Node.DOCUMENT_POSITION_FOLLOWING && Ht();
1042
+ },
1043
+ "aria-busy": fe || void 0,
1044
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
1045
+ children: [
1046
+ T,
1047
+ /* @__PURE__ */ v("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
1048
+ /* @__PURE__ */ n(
1049
+ Pe,
1050
+ {
1051
+ label: k("booking.details.firstName.label"),
1052
+ required: !0,
1053
+ error: G.firstName,
1054
+ announceError: ue("firstName"),
1055
+ children: /* @__PURE__ */ n(
1056
+ Lt,
1057
+ {
1058
+ autoComplete: "given-name",
1059
+ value: e.firstName ?? "",
1060
+ onChange: (c) => q({ firstName: c.target.value }),
1061
+ onBlur: () => ce("firstName")
1062
+ }
1063
+ )
1064
+ }
1065
+ ),
1066
+ /* @__PURE__ */ n(
1067
+ Pe,
1068
+ {
1069
+ label: k("booking.details.lastName.label"),
1070
+ required: !0,
1071
+ error: G.lastName,
1072
+ announceError: ue("lastName"),
1073
+ children: /* @__PURE__ */ n(
1074
+ Lt,
1075
+ {
1076
+ autoComplete: "family-name",
1077
+ value: e.lastName ?? "",
1078
+ onChange: (c) => q({ lastName: c.target.value }),
1079
+ onBlur: () => ce("lastName")
1080
+ }
1081
+ )
1082
+ }
1083
+ )
1084
+ ] }),
1085
+ /* @__PURE__ */ v(
1086
+ "div",
1087
+ {
1088
+ className: `ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)]${i ? "" : " ds:sm:grid-cols-2"}`,
1089
+ children: [
1090
+ !i && /* @__PURE__ */ n(
1091
+ Pe,
1092
+ {
1093
+ label: k("booking.details.email.label"),
1094
+ required: !0,
1095
+ error: G.email,
1096
+ announceError: ue("email"),
1097
+ children: /* @__PURE__ */ n(
1098
+ Qn,
1099
+ {
1100
+ value: e.email ?? "",
1101
+ onChange: (c) => q({ email: c.target.value }),
1102
+ onBlur: () => ce("email")
1103
+ }
1104
+ )
1105
+ }
1106
+ ),
1107
+ /* @__PURE__ */ n(
1108
+ Pe,
1109
+ {
1110
+ label: k("booking.details.mobilePhone.label"),
1111
+ required: !0,
1112
+ error: G.mobilePhone,
1113
+ announceError: ue("mobilePhone"),
1114
+ children: /* @__PURE__ */ n(
1115
+ Xn,
1116
+ {
1117
+ value: e.mobilePhone ?? "",
1118
+ defaultCountry: O == null ? void 0 : O.toUpperCase(),
1119
+ onChange: (c) => {
1120
+ q({ mobilePhone: c }), ce("mobilePhone");
1121
+ }
1122
+ }
1123
+ )
1124
+ }
1125
+ )
1126
+ ]
1127
+ }
1128
+ ),
1129
+ ke && !R || a ? /* @__PURE__ */ v("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
1130
+ ke && !R ? Bt : null,
1131
+ a ? /* @__PURE__ */ n(
1132
+ Pe,
1133
+ {
1134
+ label: k("booking.details.dateOfBirth.label"),
1135
+ required: !0,
1136
+ error: G.dateOfBirth,
1137
+ announceError: ue("dateOfBirth"),
1138
+ children: /* @__PURE__ */ n(
1139
+ Zn,
1140
+ {
1141
+ value: e.dateOfBirth ? new Date(e.dateOfBirth) : void 0,
1142
+ onChange: (c) => {
1143
+ q({
1144
+ dateOfBirth: c ? c.toISOString().slice(0, 10) : void 0
1145
+ }), ce("dateOfBirth");
1146
+ }
1147
+ }
1148
+ )
1149
+ }
1150
+ ) : null
1151
+ ] }) : null,
1152
+ He ? /* @__PURE__ */ n(
1153
+ Pe,
1154
+ {
1155
+ label: k("booking.details.insuranceNumber.label"),
1156
+ required: !0,
1157
+ description: we.state === "pending" ? k("booking.details.insuranceNumber.checking") : void 0,
1158
+ error: G.insuranceNumber,
1159
+ announceError: ue("insuranceNumber"),
1160
+ children: /* @__PURE__ */ n(
1161
+ Lt,
1162
+ {
1163
+ value: e.insuranceNumber ?? "",
1164
+ onChange: (c) => q({ insuranceNumber: c.target.value }),
1165
+ onBlur: () => ce("insuranceNumber")
1166
+ }
1167
+ )
1168
+ }
1169
+ ) : null,
1170
+ R ? /* @__PURE__ */ v(
1171
+ "div",
1172
+ {
1173
+ ref: kt,
1174
+ "data-component": "booking-billing",
1175
+ role: "group",
1176
+ "aria-labelledby": `${j}-billing-heading`,
1177
+ "aria-describedby": `${j}-billing-intro`,
1178
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-md)] ds:border ds:border-[var(--border)] ds:p-[var(--spacing-sm)]",
1179
+ onBlur: (c) => {
1180
+ var W;
1181
+ const C = (W = c.target.closest("[data-address-field]")) == null ? void 0 : W.getAttribute("data-address-field");
1182
+ (C === "street" || C === "city" || C === "postcode") && ce(H[C]);
1183
+ },
1184
+ children: [
1185
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
1186
+ /* @__PURE__ */ n(
1187
+ "h3",
1188
+ {
1189
+ id: `${j}-billing-heading`,
1190
+ className: "type-label ds:m-0 ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]",
1191
+ children: k("booking.details.billing.heading")
1192
+ }
1193
+ ),
1194
+ /* @__PURE__ */ n(
1195
+ "p",
1196
+ {
1197
+ id: `${j}-billing-intro`,
1198
+ className: "type-body-sm ds:m-0 ds:text-[color:var(--muted-foreground)]",
1199
+ children: k("booking.details.billing.intro")
1200
+ }
1201
+ )
1202
+ ] }),
1203
+ ke ? Bt : null,
1204
+ /* @__PURE__ */ n(
1205
+ ts,
1206
+ {
1207
+ value: ae,
1208
+ onChange: (c) => {
1209
+ var C;
1210
+ return (
1211
+ // The name is set from the patient's own on submit.
1212
+ q({
1213
+ billing: fi(
1214
+ c,
1215
+ "",
1216
+ // A second line belongs to its street: it goes when the
1217
+ // patient writes another, and returns with the first.
1218
+ c.street.trim() === ((C = Ue.current) == null ? void 0 : C.street) ? Ue.current.line2 : null
1219
+ )
1220
+ })
1221
+ );
1222
+ },
1223
+ popularCountries: hi,
1224
+ layout: "grid",
1225
+ fields: Se ? void 0 : ["street", "city", "postcode"],
1226
+ required: Se ? ["country", "street", "city", "postcode", "province"] : ["country", "street", "city", "postcode"],
1227
+ errors: {
1228
+ country: G[H.country],
1229
+ street: G[H.street],
1230
+ city: G[H.city],
1231
+ postcode: G[H.postcode],
1232
+ province: G[H.province]
1233
+ },
1234
+ announceErrors: {
1235
+ country: ue(H.country),
1236
+ street: ue(H.street),
1237
+ city: ue(H.city),
1238
+ postcode: ue(H.postcode),
1239
+ province: ue(H.province)
1240
+ }
1241
+ }
1242
+ )
1243
+ ]
1244
+ }
1245
+ ) : null,
1246
+ p ? /* @__PURE__ */ n(
1247
+ Pe,
1248
+ {
1249
+ label: k("booking.details.note.label"),
1250
+ description: k("booking.details.note.helper", {
1251
+ max: pn
1252
+ }),
1253
+ children: /* @__PURE__ */ n(
1254
+ es,
1255
+ {
1256
+ value: e.note ?? "",
1257
+ maxLength: pn,
1258
+ rows: 3,
1259
+ onChange: (c) => q({ note: c.target.value })
1260
+ }
1261
+ )
1262
+ }
1263
+ ) : null,
1264
+ f ? /* @__PURE__ */ n(
1265
+ ft,
1266
+ {
1267
+ checked: !!e.returningPatient,
1268
+ onCheckedChange: (c) => q({ returningPatient: c === !0 }),
1269
+ label: k("booking.details.returningPatient.label")
1270
+ }
1271
+ ) : null,
1272
+ ut !== void 0 ? /* @__PURE__ */ v(
1273
+ "div",
1274
+ {
1275
+ "data-component": "booking-critical-information",
1276
+ role: "group",
1277
+ "aria-labelledby": `${j}-critical-information-heading`,
1278
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:rounded-[var(--radius-md)] ds:border ds:border-[var(--border)] ds:bg-[var(--muted)] ds:p-[var(--spacing-sm)]",
1279
+ children: [
1280
+ /* @__PURE__ */ n(
1281
+ "h3",
1282
+ {
1283
+ id: `${j}-critical-information-heading`,
1284
+ className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0",
1285
+ children: k("booking.details.criticalInformation.heading")
1286
+ }
1287
+ ),
1288
+ /* @__PURE__ */ n(
1289
+ "p",
1290
+ {
1291
+ dir: "auto",
1292
+ className: "type-body-sm ds:m-0 ds:whitespace-pre-wrap ds:break-words ds:text-[var(--foreground)]",
1293
+ children: li(ut).map(
1294
+ (c, C) => c.kind === "link" ? /* @__PURE__ */ n(
1295
+ "a",
1296
+ {
1297
+ href: c.href,
1298
+ target: "_blank",
1299
+ rel: "noopener noreferrer",
1300
+ dir: "ltr",
1301
+ className: Zt,
1302
+ children: c.text
1303
+ },
1304
+ C
1305
+ ) : /* @__PURE__ */ n(Un, { children: c.text }, C)
1306
+ )
1307
+ }
1308
+ ),
1309
+ /* @__PURE__ */ n(
1310
+ ft,
1311
+ {
1312
+ checked: !!e.criticalInformationAccepted,
1313
+ onCheckedChange: (c) => q({ criticalInformationAccepted: c === !0 }),
1314
+ "aria-required": !0,
1315
+ label: /* @__PURE__ */ v(pe, { children: [
1316
+ k("booking.details.criticalInformation.accept"),
1317
+ /* @__PURE__ */ n(
1318
+ "span",
1319
+ {
1320
+ "aria-hidden": "true",
1321
+ className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1322
+ children: "*"
1323
+ }
1324
+ )
1325
+ ] })
1326
+ }
1327
+ )
1328
+ ]
1329
+ }
1330
+ ) : null,
1331
+ o ? /* @__PURE__ */ v(
1332
+ "div",
1333
+ {
1334
+ "data-component": "booking-payment-notice",
1335
+ role: "group",
1336
+ "aria-labelledby": `${j}-payment-heading`,
1337
+ "data-notice-style": E,
1338
+ className: gi({
1339
+ noticeStyle: E
1340
+ }),
1341
+ children: [
1342
+ E === "highlighted" ? /* @__PURE__ */ v("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
1343
+ /* @__PURE__ */ n("span", { className: "ds:flex ds:size-9 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-full ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]", children: /* @__PURE__ */ n(ns, { "aria-hidden": "true", className: "ds:size-5" }) }),
1344
+ /* @__PURE__ */ n(
1345
+ "h3",
1346
+ {
1347
+ id: `${j}-payment-heading`,
1348
+ className: "type-title-item ds:m-0 ds:flex-1",
1349
+ children: k("booking.payment.noticeTitle")
1350
+ }
1351
+ ),
1352
+ /* @__PURE__ */ n(
1353
+ "span",
1354
+ {
1355
+ "aria-hidden": "true",
1356
+ className: "type-title-card ds:shrink-0 ds:text-[var(--foreground)]",
1357
+ children: ye
1358
+ }
1359
+ )
1360
+ ] }) : /* @__PURE__ */ n(
1361
+ "h3",
1362
+ {
1363
+ id: `${j}-payment-heading`,
1364
+ className: "type-label ds:m-0",
1365
+ children: k("booking.payment.noticeTitle")
1366
+ }
1367
+ ),
1368
+ /* @__PURE__ */ n("p", { className: "type-body-sm ds:m-0", children: k("booking.payment.noticeBody", { amount: ye }) }),
1369
+ je ? /* @__PURE__ */ n(
1370
+ "a",
1371
+ {
1372
+ href: je,
1373
+ target: "_blank",
1374
+ rel: "noopener noreferrer",
1375
+ className: "type-body-sm ds:inline-flex ds:items-center ds:self-start ds:min-h-[var(--min-target-size)] ds:rounded-[var(--radius-sm)] ds:underline ds:text-[var(--foreground)] ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1376
+ children: k("booking.payment.terms")
1377
+ }
1378
+ ) : null,
1379
+ /* @__PURE__ */ n(
1380
+ ft,
1381
+ {
1382
+ checked: rt,
1383
+ onCheckedChange: (c) => {
1384
+ Ot(
1385
+ c === !0 ? Le : void 0
1386
+ ), q({ paymentAccepted: c === !0 });
1387
+ },
1388
+ "aria-required": !0,
1389
+ label: /* @__PURE__ */ v(pe, { children: [
1390
+ k("booking.payment.accept", { amount: ye }),
1391
+ /* @__PURE__ */ n(
1392
+ "span",
1393
+ {
1394
+ "aria-hidden": "true",
1395
+ className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1396
+ children: "*"
1397
+ }
1398
+ )
1399
+ ] })
1400
+ }
1401
+ )
1402
+ ]
1403
+ }
1404
+ ) : null,
1405
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1406
+ /* @__PURE__ */ n(
1407
+ ft,
1408
+ {
1409
+ checked: !!e.privacyConsent,
1410
+ onCheckedChange: (c) => q({ privacyConsent: c === !0 }),
1411
+ "aria-required": !0,
1412
+ label: /* @__PURE__ */ v(pe, { children: [
1413
+ Nt(
1414
+ "booking.details.consent.privacy.label",
1415
+ g
1416
+ ),
1417
+ /* @__PURE__ */ n(
1418
+ "span",
1419
+ {
1420
+ "aria-hidden": "true",
1421
+ className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1422
+ children: "*"
1423
+ }
1424
+ )
1425
+ ] })
1426
+ }
1427
+ ),
1428
+ /* @__PURE__ */ n(
1429
+ ft,
1430
+ {
1431
+ checked: !!e.termsConsent,
1432
+ onCheckedChange: (c) => q({ termsConsent: c === !0 }),
1433
+ "aria-required": !0,
1434
+ label: /* @__PURE__ */ v(pe, { children: [
1435
+ Nt(
1436
+ "booking.details.consent.terms.label",
1437
+ h
1438
+ ),
1439
+ /* @__PURE__ */ n(
1440
+ "span",
1441
+ {
1442
+ "aria-hidden": "true",
1443
+ className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1444
+ children: "*"
1445
+ }
1446
+ )
1447
+ ] })
1448
+ }
1449
+ ),
1450
+ l && ot ? /* @__PURE__ */ n(
1451
+ ft,
1452
+ {
1453
+ checked: ze,
1454
+ onCheckedChange: (c) => {
1455
+ Mt(
1456
+ c === !0 ? Fe : void 0
1457
+ ), q({ practiceConsentAccepted: c === !0 });
1458
+ },
1459
+ "aria-required": l.required || void 0,
1460
+ label: /* @__PURE__ */ v(pe, { children: [
1461
+ _t(l.url) ? /* @__PURE__ */ n(
1462
+ "a",
1463
+ {
1464
+ dir: "auto",
1465
+ href: _t(l.url),
1466
+ target: "_blank",
1467
+ rel: "noopener noreferrer",
1468
+ className: Zt,
1469
+ children: l.label
1470
+ }
1471
+ ) : /* @__PURE__ */ n("span", { dir: "auto", children: l.label }),
1472
+ l.required ? /* @__PURE__ */ n(
1473
+ "span",
1474
+ {
1475
+ "aria-hidden": "true",
1476
+ className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1477
+ children: "*"
1478
+ }
1479
+ ) : null
1480
+ ] })
1481
+ }
1482
+ ) : null
1483
+ ] }),
1484
+ xe ? /* @__PURE__ */ n(
1485
+ "div",
1486
+ {
1487
+ "data-component": "booking-confirmation-channels",
1488
+ "data-unanswered": Y || void 0,
1489
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
1490
+ children: D ? /* @__PURE__ */ n(
1491
+ Yn,
1492
+ {
1493
+ variant: "horizontal",
1494
+ label: k("booking.confirmation.heading"),
1495
+ value: $[0] ?? "",
1496
+ onValueChange: (c) => q({
1497
+ confirmationChannels: [c]
1498
+ }),
1499
+ error: Y ? k("booking.confirmation.atLeastOne") : void 0,
1500
+ children: Re.map((c) => /* @__PURE__ */ n(
1501
+ Wn,
1502
+ {
1503
+ value: c,
1504
+ label: k(`booking.confirmation.channel.${c}`)
1505
+ },
1506
+ c
1507
+ ))
1508
+ }
1509
+ ) : /* @__PURE__ */ n(
1510
+ Jn,
1511
+ {
1512
+ label: k("booking.confirmation.heading"),
1513
+ helperText: k("booking.confirmation.helper"),
1514
+ value: $,
1515
+ onChange: (c) => q({
1516
+ confirmationChannels: c
1517
+ }),
1518
+ orientation: "vertical",
1519
+ options: Re.map((c) => ({
1520
+ value: c,
1521
+ label: k(`booking.confirmation.channel.${c}`)
1522
+ })),
1523
+ error: Y ? k("booking.confirmation.atLeastOne") : void 0
1524
+ }
1525
+ )
1526
+ }
1527
+ ) : null,
1528
+ z || qe || b ? /* @__PURE__ */ n(te, { variant: "error", children: /* @__PURE__ */ n(te.Description, { children: z ?? k(
1529
+ b ? "booking.payment.unavailable" : "booking.payment.submitFailed"
1530
+ ) }) }) : null,
1531
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1532
+ mt ? /* @__PURE__ */ n(
1533
+ "p",
1534
+ {
1535
+ id: Je,
1536
+ "data-slot": "submit-hint",
1537
+ className: "type-body-sm ds:m-0 ds:text-[var(--muted-foreground)]",
1538
+ children: k("booking.details.submitHint")
1539
+ }
1540
+ ) : null,
1541
+ /* @__PURE__ */ n(
1542
+ Ye,
1543
+ {
1544
+ intent: "primary",
1545
+ size: "md",
1546
+ type: "submit",
1547
+ disabled: fe || b,
1548
+ "aria-disabled": !pt || void 0,
1549
+ "aria-describedby": mt ? Je : void 0,
1550
+ startIcon: fe ? /* @__PURE__ */ n(yn, { variant: "pulse", size: "sm" }) : void 0,
1551
+ children: o ? k("booking.payment.submit", { amount: ye }) : k("booking.details.submit")
1552
+ }
1553
+ )
1554
+ ] })
1555
+ ]
1556
+ }
1557
+ );
1558
+ }
1559
+ );
1560
+ rn.displayName = "BookingDetailsForm";
1561
+ const Tt = [
1562
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1563
+ "ds:focus-visible:outline-solid",
1564
+ "ds:focus-visible:outline-[var(--ring)]",
1565
+ "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1566
+ "ds:forced-colors:focus-visible:outline-[CanvasText]"
1567
+ ].join(" ");
1568
+ function ki({
1569
+ length: e = 5,
1570
+ onVerify: t,
1571
+ onResend: s,
1572
+ resendSeconds: i = 60,
1573
+ phoneHint: r,
1574
+ onVerified: a
1575
+ }) {
1576
+ const { t: d, i18n: m } = Q("ui"), p = vt(), f = vt(), g = F(null), h = F(null), l = F(null), o = F(!1), y = F(!1), [b, S] = Z(null), [E, I] = Z(!1), [N, x] = Z(null), [M, T] = Z(
1577
+ null
1578
+ ), [O, u] = Z(0), w = Number.isFinite(i) ? Math.max(0, Math.ceil(i)) : 60, [D, z] = Z(
1579
+ () => Date.now() + w * 1e3
1580
+ ), [U, k] = Z(w), _ = N === "too-many-attempts";
1581
+ K(() => (o.current = !0, () => {
1582
+ o.current = !1;
1583
+ }), []), K(() => {
1584
+ var J;
1585
+ (J = h.current) == null || J.focus();
1586
+ }, [O]), K(() => {
1587
+ var re, he;
1588
+ if (b || !_ && M !== "resend") return;
1589
+ const J = document.activeElement, ne = (re = g.current) == null ? void 0 : re.closest("section");
1590
+ J && J !== document.body && !(ne != null && ne.contains(J)) || (l.current && !l.current.disabled ? l.current.focus() : (he = g.current) == null || he.focus());
1591
+ }, [b, _, M]), K(() => {
1592
+ if (U === 0) return;
1593
+ const J = setTimeout(() => {
1594
+ k(Math.max(0, Math.ceil((D - Date.now()) / 1e3)));
1595
+ }, 1e3);
1596
+ return () => clearTimeout(J);
1597
+ }, [D, U]);
1598
+ const j = async (J) => {
1599
+ if (!(y.current || _)) {
1600
+ y.current = !0, S("verify"), I(!1), x(null), T(null);
1601
+ try {
1602
+ const ne = await t(J);
1603
+ if (!o.current) return;
1604
+ ne.ok ? a() : (x(ne.reason), ne.reason !== "too-many-attempts" && u((re) => re + 1));
1605
+ } catch {
1606
+ if (!o.current) return;
1607
+ T("verify"), u((ne) => ne + 1);
1608
+ } finally {
1609
+ y.current = !1, o.current && S(null);
1610
+ }
1611
+ }
1612
+ }, me = async () => {
1613
+ if (!(y.current || Date.now() < D)) {
1614
+ y.current = !0, S("resend"), I(!1), T(null);
1615
+ try {
1616
+ if (await s(), !o.current) return;
1617
+ z(Date.now() + w * 1e3), k(w), x(null), I(!0), u((J) => J + 1);
1618
+ } catch {
1619
+ o.current && T("resend");
1620
+ } finally {
1621
+ y.current = !1, o.current && S(null);
1622
+ }
1623
+ }
1624
+ }, P = N === "wrong" ? d("booking.code.wrong") : N === "expired" ? d("booking.code.expired") : _ ? d("booking.code.tooManyAttempts") : void 0;
1625
+ return /* @__PURE__ */ v(
1626
+ "section",
1627
+ {
1628
+ "aria-labelledby": p,
1629
+ "data-component": "booking-code-step",
1630
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
1631
+ children: [
1632
+ /* @__PURE__ */ n(
1633
+ "h3",
1634
+ {
1635
+ ref: g,
1636
+ id: p,
1637
+ tabIndex: -1,
1638
+ className: `type-title-card ds:m-0 ${Tt}`,
1639
+ children: d("booking.code.heading")
1640
+ }
1641
+ ),
1642
+ /* @__PURE__ */ n("p", { id: f, className: "type-body ds:m-0", children: r ? /* @__PURE__ */ n(
1643
+ bn,
1644
+ {
1645
+ t: d,
1646
+ ns: "ui",
1647
+ i18nKey: "booking.code.instructionWithPhone",
1648
+ values: { phone: r },
1649
+ components: { phone: /* @__PURE__ */ n("bdi", {}) }
1650
+ }
1651
+ ) : d("booking.code.instruction") }),
1652
+ /* @__PURE__ */ n(Pe, { label: d("booking.code.label"), error: P, children: /* @__PURE__ */ n("div", { dir: "ltr", children: /* @__PURE__ */ n(
1653
+ ss,
1654
+ {
1655
+ ref: h,
1656
+ length: e,
1657
+ mode: "alphanumeric",
1658
+ "aria-describedby": f,
1659
+ disabled: !!b || _,
1660
+ onComplete: j
1661
+ },
1662
+ O
1663
+ ) }) }),
1664
+ M ? /* @__PURE__ */ n(te, { variant: "error", children: /* @__PURE__ */ n(te.Description, { children: d(M === "verify" ? "booking.code.verifyFailed" : "booking.code.resendFailed") }) }) : null,
1665
+ /* @__PURE__ */ n("p", { role: "status", className: "type-body ds:m-0", children: b === "verify" ? d("booking.code.verifying") : E ? d("booking.code.resent") : null }),
1666
+ /* @__PURE__ */ n(
1667
+ Ye,
1668
+ {
1669
+ ref: l,
1670
+ type: "button",
1671
+ intent: "secondary",
1672
+ className: "ds:self-start",
1673
+ disabled: U > 0 || !!b,
1674
+ loading: b === "resend",
1675
+ onClick: me,
1676
+ children: U > 0 ? d("booking.code.resendCountdown", {
1677
+ seconds: new Intl.NumberFormat(m.language).format(U)
1678
+ }) : d("booking.code.resend")
1679
+ }
1680
+ )
1681
+ ]
1682
+ }
1683
+ );
1684
+ }
1685
+ function En(e) {
1686
+ const t = e.payment;
1687
+ if (!t) return;
1688
+ const s = (t.currencyCode ?? "EUR").toUpperCase();
1689
+ if (!(!Number.isSafeInteger(t.amountCents) || t.amountCents <= 0 || !["full", "deposit"].includes(t.kind) || !/^[A-Z]{3}$/.test(s)))
1690
+ return {
1691
+ serviceId: e.id,
1692
+ kind: t.kind,
1693
+ amountCents: t.amountCents,
1694
+ currencyCode: s
1695
+ };
1696
+ }
1697
+ function Si(e) {
1698
+ var r;
1699
+ const t = (r = e.priceLabel) != null && r.trim() ? e.priceLabel : void 0, s = t ? { label: t } : void 0;
1700
+ if (!e.payment) return { price: s };
1701
+ const i = En(e);
1702
+ return i ? {
1703
+ price: s ?? (i.kind === "full" ? { amount: i } : void 0),
1704
+ payment: i
1705
+ } : { price: s, payment: "unavailable" };
1706
+ }
1707
+ function xi(e, t, s) {
1708
+ const i = e.filter(
1709
+ (a) => t.includes(a.id)
1710
+ ), r = (s == null ? void 0 : s.serviceId) ?? (t.length === 1 ? t[0] : void 0);
1711
+ if (r) {
1712
+ const a = i.find((m) => m.id === r);
1713
+ if (!a) return { blocked: !0 };
1714
+ const d = En(a);
1715
+ return { payment: d, blocked: !!(a.payment && !d) };
1716
+ }
1717
+ return { blocked: i.some((a) => !!a.payment) };
1718
+ }
1719
+ function Vt(e) {
1720
+ return e ? JSON.stringify([
1721
+ e.serviceId,
1722
+ e.kind,
1723
+ e.amountCents,
1724
+ e.currencyCode
1725
+ ]) : "";
1726
+ }
1727
+ function Ii({
1728
+ services: e,
1729
+ value: t,
1730
+ availableSlots: s,
1731
+ onSubmit: i,
1732
+ onChange: r,
1733
+ paymentState: a,
1734
+ submitting: d,
1735
+ paymentTermsUrl: m,
1736
+ renderPayment: p,
1737
+ codeStep: f
1738
+ }) {
1739
+ var ne, re, he;
1740
+ const g = JSON.stringify([
1741
+ t.insuranceType,
1742
+ t.specialtyId,
1743
+ t.specialtyIds,
1744
+ $e(t),
1745
+ t.operatorId,
1746
+ t.operatorIds,
1747
+ t.date,
1748
+ t.slotKey
1749
+ ]), h = F(
1750
+ void 0
1751
+ ), o = (t.date ? (ne = s[t.date]) == null ? void 0 : ne.find((X) => X.key === t.slotKey) : void 0) ?? (((re = h.current) == null ? void 0 : re.selection) === g ? h.current.slot : void 0), y = xi(
1752
+ e,
1753
+ $e(t),
1754
+ o
1755
+ ), b = y.blocked || !!(y.payment && !p), S = JSON.stringify([
1756
+ g,
1757
+ o == null ? void 0 : o.serviceId,
1758
+ Vt(y.payment),
1759
+ m,
1760
+ b
1761
+ ]), E = y.payment ? JSON.stringify([Vt(y.payment), m]) : "", I = F(void 0), N = !!((he = t.details) != null && he.paymentAccepted);
1762
+ K(() => {
1763
+ if (!N) I.current = void 0;
1764
+ else if (E) I.current === void 0 ? I.current = E : I.current !== E && (I.current = void 0, r({
1765
+ ...t,
1766
+ details: { ...t.details, paymentAccepted: !1 }
1767
+ }));
1768
+ else return;
1769
+ }, [N, E, r, t]);
1770
+ const x = F(S);
1771
+ x.current = S;
1772
+ const [M, T] = Z({ status: "idle" }), O = F(0), u = F(!1), w = F(!0), D = F(!1), z = F(void 0), U = F(S);
1773
+ K(() => (w.current = !0, () => {
1774
+ w.current = !1, O.current += 1;
1775
+ }), []);
1776
+ const k = M.status === "payment" || M.status === "code" || M.status === "success";
1777
+ K(() => {
1778
+ U.current === S || D.current || k || (U.current = S, O.current += 1, u.current = !1, T({ status: "idle" }));
1779
+ }, [S, k]);
1780
+ const _ = k || U.current === S ? M.session : void 0, j = L(
1781
+ () => _ && (a == null ? void 0 : a.sessionId) === _.id ? a : _ ? { sessionId: _.id, status: "ready" } : void 0,
1782
+ [_, a]
1783
+ );
1784
+ _ && j && "phase" in j && j.phase === "completion" && (z.current = _.id);
1785
+ const me = L(
1786
+ () => _ && z.current === _.id && j && j.status !== "paid" && (!("phase" in j) || j.phase !== "completion") ? {
1787
+ sessionId: _.id,
1788
+ status: "processing",
1789
+ phase: "completion"
1790
+ } : j,
1791
+ [_, j]
1792
+ );
1793
+ K(() => {
1794
+ !_ || !me || D.current || (me.status === "paid" ? (D.current = !0, T((X) => ({
1795
+ ...X,
1796
+ status: X.codeStep ? "code" : "success"
1797
+ }))) : me.status === "cancelled" && (O.current += 1, u.current = !1, h.current = void 0, r({
1798
+ ...t,
1799
+ details: { ...t.details, paymentAccepted: !1 }
1800
+ }), T({ status: "idle", cancelled: !0 })));
1801
+ }, [_, me, r, t]);
1802
+ const P = () => {
1803
+ O.current += 1, u.current = !1, D.current = !1, z.current = void 0, h.current = void 0, U.current = x.current, T({ status: "idle" });
1804
+ }, J = async (X) => {
1805
+ var Oe, oe, Me, ce, Be;
1806
+ if (!(o != null && o.available) || b || d || u.current || M.status === "payment" || D.current || y.payment && !X.paymentAccepted) return;
1807
+ u.current = !0;
1808
+ const qe = f ? { ...f } : void 0;
1809
+ h.current = { selection: g, slot: { ...o } };
1810
+ const ve = ++O.current, fe = S;
1811
+ U.current = fe;
1812
+ const se = {
1813
+ slot: { ...o, meta: o.meta ? { ...o.meta } : void 0 },
1814
+ value: {
1815
+ ...t,
1816
+ serviceIds: (Oe = t.serviceIds) == null ? void 0 : Oe.slice(),
1817
+ specialtyIds: (oe = t.specialtyIds) == null ? void 0 : oe.slice(),
1818
+ operatorIds: (Me = t.operatorIds) == null ? void 0 : Me.slice(),
1819
+ operatorId: Mn(t) ?? t.operatorId,
1820
+ details: { ...X }
1821
+ },
1822
+ details: {
1823
+ ...X,
1824
+ confirmationChannels: (ce = X.confirmationChannels) == null ? void 0 : ce.slice()
1825
+ },
1826
+ ...y.payment ? { payment: { ...y.payment } } : {}
1827
+ }, be = () => w.current && O.current === ve && x.current === fe;
1828
+ T({ status: "submitting" });
1829
+ let we = !1;
1830
+ try {
1831
+ const Ce = await i(se);
1832
+ if (!be()) return;
1833
+ if (se.payment) {
1834
+ const ie = Ce == null ? void 0 : Ce.paymentSession;
1835
+ if (!((Be = ie == null ? void 0 : ie.id) != null && Be.trim()) || Vt(ie.payment) !== Vt(se.payment)) {
1836
+ T({ status: "error" });
1837
+ return;
1838
+ }
1839
+ we = !0, T({
1840
+ status: "payment",
1841
+ snapshot: se,
1842
+ session: { id: ie.id, payment: { ...ie.payment } },
1843
+ codeStep: qe
1844
+ });
1845
+ } else Ce != null && Ce.paymentSession ? T({ status: "error" }) : (D.current = !0, T({
1846
+ status: qe ? "code" : "success",
1847
+ snapshot: se,
1848
+ codeStep: qe
1849
+ }));
1850
+ } catch {
1851
+ be() && T({ status: "error" });
1852
+ } finally {
1853
+ be() && !we && (u.current = !1);
1854
+ }
1855
+ };
1856
+ return {
1857
+ ...M,
1858
+ payment: y.payment,
1859
+ blocked: b,
1860
+ state: me,
1861
+ activeSession: _,
1862
+ submit: J,
1863
+ reset: P,
1864
+ completeCode: () => {
1865
+ T(
1866
+ (X) => X.status === "code" ? { ...X, status: "success", codeVerified: !0 } : X
1867
+ );
1868
+ }
1869
+ };
1870
+ }
1871
+ const Ni = Dt(
1872
+ "ds:flex ds:w-full ds:flex-col ds:text-[var(--foreground)]",
1873
+ {
1874
+ variants: {
1875
+ variant: {
1876
+ "inline-list": "ds:gap-[var(--spacing-md)]",
1877
+ accordion: "ds:gap-[var(--spacing-md)]",
1878
+ calendar: "ds:gap-[var(--spacing-md)]",
1879
+ flexible: "ds:gap-[var(--spacing-lg)]",
1880
+ progress: "ds:gap-[var(--spacing-sm)]"
1881
+ },
1882
+ // `surface="elevated"` matches `Card variant="elevated"` — same
1883
+ // tokens, same padding, same boundary behaviour — so consumers can
1884
+ // drop their own Card wraps without a double-card look. Default
1885
+ // `'flat'` preserves 0.30.x rendering.
1886
+ surface: {
1887
+ flat: "",
1888
+ elevated: [
1889
+ "ds:rounded-[var(--radius-lg)]",
1890
+ "ds:bg-[var(--card)] ds:text-[var(--card-foreground)]",
1891
+ "ds:border ds:border-[color:var(--card-border)]",
1892
+ "ds:shadow-[var(--shadow-card)]",
1893
+ "ds:p-[var(--spacing-md)]"
1894
+ ].join(" ")
1895
+ }
1896
+ },
1897
+ defaultVariants: { variant: "inline-list", surface: "flat" }
1898
+ }
1899
+ ), wi = [
1900
+ [
1901
+ /\b(estetic|aesthetic|botox|filler|mesoterap|chirurgia\s*plastic)/i,
1902
+ ln
1903
+ ],
1904
+ [/\b(cardio|ecg|elettrocardio|ecocardio|cuore|heart)/i, vs],
1905
+ [/\b(dent|odonto|tooth|teeth|pulizia|igien|smile)/i, $s],
1906
+ [/\b(oftalmo|ocul|ophthal|vision|occhi|eye)/i, bs],
1907
+ [/\b(otorin|udito|orecchi|hearing|ear)/i, Fs],
1908
+ [/\b(neuro|brain|cervello)/i, Ts],
1909
+ [/\b(pediatr|child|bambin)/i, ys],
1910
+ [/\b(ortop|ortho|osteo|skeleton|ossa|bone)/i, Cs],
1911
+ [/\b(lab|analis|test|sang|esami)/i, Bs],
1912
+ [/\b(farmaco|pharm|pillol|refill)/i, Rs],
1913
+ [/\b(chirurg|surg|intervent|operat)/i, Ps],
1914
+ [/\b(scan|rx|x-?ray|raggi|imag|radio|risonan|ecograf|ultras)/i, ks],
1915
+ [/\b(vacc|inject|inie|punto)/i, ln],
1916
+ [/\b(derma|skin|pelle)/i, Ss],
1917
+ [/\b(prima\s*visit|first\s*visit|consult|consulto|valutaz)/i, xs],
1918
+ [/\b(general|medicin|family|control|check[-\s]?up)/i, Ns]
1919
+ ];
1920
+ function Ci(e) {
1921
+ for (const [t, s] of wi)
1922
+ if (t.test(e)) return s;
1923
+ return null;
1924
+ }
1925
+ function Ai(e) {
1926
+ const t = Ci(e.label) ?? hs;
1927
+ return /* @__PURE__ */ n(t, { "aria-hidden": "true", className: "ds:size-5" });
1928
+ }
1929
+ function Bn() {
1930
+ const { t: e, i18n: t } = Q("ui");
1931
+ return (s) => {
1932
+ const i = Si(s), r = (d) => zt(d.amountCents, d.currencyCode, t.language), a = i.price ? "label" in i.price ? i.price.label : r(i.price.amount) : void 0;
1933
+ return i.payment === "unavailable" ? {
1934
+ price: a,
1935
+ payment: e("booking.payment.unavailable"),
1936
+ paymentTone: "error"
1937
+ } : {
1938
+ price: a,
1939
+ payment: i.payment ? e(`booking.payment.${i.payment.kind}`, {
1940
+ amount: r(i.payment)
1941
+ }) : void 0,
1942
+ paymentTone: "default"
1943
+ };
1944
+ };
1945
+ }
1946
+ function st(e) {
1947
+ return qt(e, "yyyy-MM-dd");
1948
+ }
1949
+ const Ti = [
1950
+ "ds:relative ds:flex ds:items-center ds:justify-center",
1951
+ "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]",
1952
+ "ds:rounded-[var(--radius-sm)]",
1953
+ "ds:text-[length:var(--font-size-sm)]",
1954
+ "ds:transition-colors ds:duration-[var(--animation-duration)]",
1955
+ "ds:motion-reduce:transition-none",
1956
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
1957
+ "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1958
+ "ds:forced-colors:focus-visible:outline-[CanvasText]"
1959
+ ].join(" "), Di = Dt(Ti, {
1960
+ variants: {
1961
+ state: {
1962
+ available: "ds:cursor-pointer ds:text-[var(--foreground)] ds:hover:bg-[var(--muted)]/30",
1963
+ unavailable: "ds:cursor-not-allowed ds:text-[var(--muted-foreground)]/60",
1964
+ selected: "ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)] ds:font-[var(--font-weight-semibold)]",
1965
+ outside: "ds:text-[var(--muted-foreground)]/40"
1966
+ }
1967
+ },
1968
+ defaultVariants: { state: "unavailable" }
1969
+ });
1970
+ function Oi({
1971
+ availableDates: e,
1972
+ selectedDate: t,
1973
+ onSelectDate: s,
1974
+ locale: i,
1975
+ loading: r
1976
+ }) {
1977
+ const { t: a } = Q("ui"), d = L(() => t ? At(Ie(t)) : e.length > 0 ? At(Ie(e[0])) : At(/* @__PURE__ */ new Date()), [t, e]), [m, p] = Z(d), [f, g] = Z(null), h = L(() => {
1978
+ const I = At(m), N = ls(m), x = I.getDay(), M = N.getDate(), T = [];
1979
+ for (let O = x; O > 0; O -= 1) {
1980
+ const u = new Date(I);
1981
+ u.setDate(I.getDate() - O), T.push(u);
1982
+ }
1983
+ for (let O = 0; O < M; O += 1) {
1984
+ const u = new Date(I);
1985
+ u.setDate(I.getDate() + O), T.push(u);
1986
+ }
1987
+ for (; T.length < 42; ) {
1988
+ const O = T[T.length - 1], u = new Date(O);
1989
+ u.setDate(O.getDate() + 1), T.push(u);
1990
+ }
1991
+ return T;
1992
+ }, [m]), l = L(() => {
1993
+ try {
1994
+ return new Intl.DateTimeFormat(i, {
1995
+ month: "long",
1996
+ year: "numeric"
1997
+ }).format(m);
1998
+ } catch {
1999
+ return qt(m, "MMMM yyyy");
2000
+ }
2001
+ }, [m, i]), o = L(() => {
2002
+ const I = new Date(2024, 0, 7);
2003
+ return Array.from({ length: 7 }, (N, x) => {
2004
+ const M = new Date(I);
2005
+ M.setDate(I.getDate() + x);
2006
+ try {
2007
+ return new Intl.DateTimeFormat(i, { weekday: "short" }).format(M);
2008
+ } catch {
2009
+ return qt(M, "EEE");
2010
+ }
2011
+ });
2012
+ }, [i]), y = L(() => new Set(e), [e]), b = Ne(
2013
+ (I) => y.has(st(I)),
2014
+ [y]
2015
+ ), S = L(() => {
2016
+ if (f) return f;
2017
+ if (t) return Ie(t);
2018
+ const I = h.find(
2019
+ (N) => Rt(N, m) && b(N)
2020
+ );
2021
+ return I || (h.find((N) => Rt(N, m)) ?? null);
2022
+ }, [f, t, h, m, b]), E = Ne(
2023
+ (I, N) => {
2024
+ let x = null;
2025
+ switch (I.key) {
2026
+ case "ArrowLeft":
2027
+ x = new Date(N), x.setDate(N.getDate() - 1);
2028
+ break;
2029
+ case "ArrowRight":
2030
+ x = new Date(N), x.setDate(N.getDate() + 1);
2031
+ break;
2032
+ case "ArrowUp":
2033
+ x = new Date(N), x.setDate(N.getDate() - 7);
2034
+ break;
2035
+ case "ArrowDown":
2036
+ x = new Date(N), x.setDate(N.getDate() + 7);
2037
+ break;
2038
+ case "Home":
2039
+ x = new Date(N), x.setDate(N.getDate() - N.getDay());
2040
+ break;
2041
+ case "End":
2042
+ x = new Date(N), x.setDate(N.getDate() + (6 - N.getDay()));
2043
+ break;
2044
+ case "Enter":
2045
+ case " ": {
2046
+ I.preventDefault(), b(N) && s(st(N));
2047
+ return;
2048
+ }
2049
+ default:
2050
+ return;
2051
+ }
2052
+ x && (I.preventDefault(), Rt(x, m) || p(At(x)), g(x));
2053
+ },
2054
+ [b, s, m]
2055
+ );
2056
+ return r ? /* @__PURE__ */ v(
2057
+ "div",
2058
+ {
2059
+ role: "status",
2060
+ "aria-live": "polite",
2061
+ "aria-label": a("common.loading"),
2062
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
2063
+ children: [
2064
+ /* @__PURE__ */ n(Kt, { variant: "text", width: "40%" }),
2065
+ /* @__PURE__ */ n("div", { className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]", children: Array.from({ length: 42 }, (I, N) => /* @__PURE__ */ n(Kt, { variant: "rounded", height: "2.5rem" }, `mg-skel-${N}`)) })
2066
+ ]
2067
+ }
2068
+ ) : /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2069
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
2070
+ /* @__PURE__ */ n(
2071
+ cn,
2072
+ {
2073
+ icon: /* @__PURE__ */ n(ps, {}),
2074
+ "aria-label": a("booking.previousMonth"),
2075
+ size: "sm",
2076
+ intent: "ghost",
2077
+ flipIconInRtl: !0,
2078
+ onClick: () => {
2079
+ p((I) => js(I)), g(null);
2080
+ }
2081
+ }
2082
+ ),
2083
+ /* @__PURE__ */ n(
2084
+ "span",
2085
+ {
2086
+ className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]",
2087
+ "aria-live": "polite",
2088
+ children: l
2089
+ }
2090
+ ),
2091
+ /* @__PURE__ */ n(
2092
+ cn,
2093
+ {
2094
+ icon: /* @__PURE__ */ n(ms, {}),
2095
+ "aria-label": a("booking.nextMonth"),
2096
+ size: "sm",
2097
+ intent: "ghost",
2098
+ flipIconInRtl: !0,
2099
+ onClick: () => {
2100
+ p((I) => xn(I, 1)), g(null);
2101
+ }
2102
+ }
2103
+ )
2104
+ ] }),
2105
+ /* @__PURE__ */ v(
2106
+ "div",
2107
+ {
2108
+ role: "grid",
2109
+ "aria-label": a("booking.monthGridLabel"),
2110
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
2111
+ children: [
2112
+ /* @__PURE__ */ n(
2113
+ "div",
2114
+ {
2115
+ role: "row",
2116
+ className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
2117
+ children: o.map((I, N) => /* @__PURE__ */ n(
2118
+ "div",
2119
+ {
2120
+ role: "columnheader",
2121
+ className: "type-meta ds:text-center ds:text-[var(--muted-foreground)] ds:font-[var(--font-weight-medium)]",
2122
+ children: I
2123
+ },
2124
+ `wd-${N}`
2125
+ ))
2126
+ }
2127
+ ),
2128
+ Array.from({ length: 6 }, (I, N) => /* @__PURE__ */ n(
2129
+ "div",
2130
+ {
2131
+ role: "row",
2132
+ className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
2133
+ children: h.slice(N * 7, N * 7 + 7).map((x, M) => {
2134
+ const T = N * 7 + M, O = Rt(x, m), u = O && b(x), w = t ? dn(x, Ie(t)) : !1, D = O ? w ? "selected" : u ? "available" : "unavailable" : "outside", z = S ? dn(S, x) : !1, U = (() => {
2135
+ try {
2136
+ return new Intl.DateTimeFormat(i, {
2137
+ dateStyle: "full"
2138
+ }).format(x);
2139
+ } catch {
2140
+ return qt(x, "PPP");
2141
+ }
2142
+ })();
2143
+ return /* @__PURE__ */ n(
2144
+ "button",
2145
+ {
2146
+ type: "button",
2147
+ role: "gridcell",
2148
+ "aria-label": U,
2149
+ "aria-selected": w || void 0,
2150
+ "aria-disabled": !u || void 0,
2151
+ tabIndex: z ? 0 : -1,
2152
+ disabled: !u,
2153
+ onClick: () => {
2154
+ u && s(st(x));
2155
+ },
2156
+ onKeyDown: (k) => E(k, x),
2157
+ className: Di({ state: D }),
2158
+ children: /* @__PURE__ */ n("span", { "aria-hidden": "true", children: x.getDate() })
2159
+ },
2160
+ `mg-cell-${T}`
2161
+ );
2162
+ })
2163
+ },
2164
+ `mg-row-${N}`
2165
+ ))
2166
+ ]
2167
+ }
2168
+ )
2169
+ ] });
2170
+ }
2171
+ const Mi = Dt(
2172
+ [
2173
+ "ds:relative ds:flex ds:w-full ds:items-center ds:gap-[var(--spacing-md)]",
2174
+ "ds:min-h-[var(--min-target-size)]",
2175
+ "ds:rounded-[var(--radius-md)]",
2176
+ "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
2177
+ "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]",
2178
+ "ds:text-start",
2179
+ "ds:transition-[background-color,box-shadow]",
2180
+ "ds:duration-[var(--animation-duration)]",
2181
+ "ds:motion-reduce:transition-none",
2182
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
2183
+ "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2184
+ "ds:forced-colors:[outline:1px_solid_CanvasText]",
2185
+ "ds:cursor-pointer"
2186
+ ].join(" "),
2187
+ {
2188
+ variants: {
2189
+ state: {
2190
+ idle: "ds:bg-[var(--card)] ds:shadow-[var(--shadow-sm)] ds:hover:shadow-[var(--shadow-md)]",
2191
+ selected: "ds:bg-[color-mix(in_srgb,var(--primary)_8%,var(--card))] ds:shadow-[var(--shadow-sm)]"
2192
+ }
2193
+ },
2194
+ defaultVariants: { state: "idle" }
2195
+ }
2196
+ );
2197
+ function Fi({
2198
+ services: e,
2199
+ selectedServiceId: t,
2200
+ onSelect: s,
2201
+ showDuration: i
2202
+ }) {
2203
+ const { t: r } = Q("ui"), a = Bn(), d = vt(), [m, p] = Z(() => {
2204
+ if (t) {
2205
+ const l = e.findIndex((o) => o.id === t);
2206
+ if (l >= 0) return l;
2207
+ }
2208
+ return 0;
2209
+ }), f = F(/* @__PURE__ */ new Map()), g = Ne((l) => {
2210
+ var o;
2211
+ (o = f.current.get(l)) == null || o.focus();
2212
+ }, []), h = Ne(
2213
+ (l, o, y) => {
2214
+ const b = e.length;
2215
+ if (b !== 0)
2216
+ switch (l.key) {
2217
+ case "ArrowDown":
2218
+ case "ArrowRight": {
2219
+ l.preventDefault();
2220
+ const S = (o + 1) % b;
2221
+ p(S), g(S);
2222
+ break;
2223
+ }
2224
+ case "ArrowUp":
2225
+ case "ArrowLeft": {
2226
+ l.preventDefault();
2227
+ const S = (o - 1 + b) % b;
2228
+ p(S), g(S);
2229
+ break;
2230
+ }
2231
+ case "Home": {
2232
+ l.preventDefault(), p(0), g(0);
2233
+ break;
2234
+ }
2235
+ case "End": {
2236
+ l.preventDefault();
2237
+ const S = b - 1;
2238
+ p(S), g(S);
2239
+ break;
2240
+ }
2241
+ case "Enter":
2242
+ case " ": {
2243
+ l.preventDefault(), s(y);
2244
+ break;
2245
+ }
2246
+ }
2247
+ },
2248
+ [e.length, g, s]
2249
+ );
2250
+ return e.length === 0 ? null : /* @__PURE__ */ n(
2251
+ "div",
2252
+ {
2253
+ role: "radiogroup",
2254
+ "aria-label": r("booking.serviceListLabel"),
2255
+ id: d,
2256
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
2257
+ children: e.map((l, o) => {
2258
+ const y = t === l.id, b = m === o, { price: S, payment: E, paymentTone: I } = a(l), N = S ? E ? r("booking.serviceCardLabelPayment", {
2259
+ label: l.label,
2260
+ price: S,
2261
+ payment: E
2262
+ }) : r("booking.serviceCardLabelPrice", {
2263
+ label: l.label,
2264
+ price: S
2265
+ }) : E ? r("booking.serviceCardLabelPaymentNoPrice", {
2266
+ label: l.label,
2267
+ payment: E
2268
+ }) : i ? r("booking.serviceCardLabel", {
2269
+ label: l.label,
2270
+ duration: l.durationMin
2271
+ }) : l.label, x = Ai(l);
2272
+ return /* @__PURE__ */ v(
2273
+ "button",
2274
+ {
2275
+ ref: (M) => {
2276
+ M ? f.current.set(o, M) : f.current.delete(o);
2277
+ },
2278
+ type: "button",
2279
+ role: "radio",
2280
+ "aria-checked": y,
2281
+ "aria-label": N,
2282
+ tabIndex: b ? 0 : -1,
2283
+ onClick: () => s(l.id),
2284
+ onFocus: () => p(o),
2285
+ onKeyDown: (M) => h(M, o, l.id),
2286
+ className: Mi({
2287
+ state: y ? "selected" : "idle"
2288
+ }),
2289
+ children: [
2290
+ /* @__PURE__ */ n(
2291
+ "span",
2292
+ {
2293
+ "aria-hidden": "true",
2294
+ className: "ds:flex ds:size-10 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-[var(--radius-sm)] ds:bg-[var(--primary)]/10 ds:text-[var(--primary)]",
2295
+ children: x
2296
+ }
2297
+ ),
2298
+ /* @__PURE__ */ v("span", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
2299
+ /* @__PURE__ */ n(
2300
+ "span",
2301
+ {
2302
+ dir: "auto",
2303
+ className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:break-words",
2304
+ children: l.label
2305
+ }
2306
+ ),
2307
+ E ? /* @__PURE__ */ n(
2308
+ "span",
2309
+ {
2310
+ className: is({ tone: I }),
2311
+ children: E
2312
+ }
2313
+ ) : S || !i ? null : /* @__PURE__ */ n("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: r("booking.serviceSummary", {
2314
+ minutes: l.durationMin
2315
+ }) })
2316
+ ] }),
2317
+ S ? /* @__PURE__ */ n(
2318
+ "span",
2319
+ {
2320
+ "aria-hidden": "true",
2321
+ className: "ds:inline-flex ds:shrink-0 ds:items-center ds:ms-auto",
2322
+ children: /* @__PURE__ */ n(kn, { variant: "accentSoft", size: "lg", children: S })
2323
+ }
2324
+ ) : null
2325
+ ]
2326
+ },
2327
+ l.id
2328
+ );
2329
+ })
2330
+ }
2331
+ );
2332
+ }
2333
+ const Ei = Dt(
2334
+ [
2335
+ "ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-2xs)]",
2336
+ "ds:min-h-[var(--min-target-size)]",
2337
+ "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
2338
+ "ds:pt-[var(--spacing-2xs)] ds:pb-[var(--spacing-2xs)]",
2339
+ "ds:rounded-[var(--radius-md)]",
2340
+ "ds:text-[length:var(--font-size-sm)] ds:font-[var(--font-weight-medium)]",
2341
+ "ds:transition-[background-color,color,box-shadow] ds:duration-[var(--animation-duration)]",
2342
+ "ds:motion-reduce:transition-none",
2343
+ "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
2344
+ "ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2345
+ "ds:disabled:cursor-not-allowed ds:disabled:opacity-50",
2346
+ "ds:forced-colors:[border:1px_solid_ButtonText] ds:forced-colors:text-[ButtonText]"
2347
+ ].join(" "),
2348
+ {
2349
+ variants: {
2350
+ state: {
2351
+ idle: "ds:bg-[color:var(--card)] ds:text-[color:var(--foreground)] ds:shadow-[var(--shadow-sm)] ds:hover:enabled:bg-[color:var(--muted)]/40 ds:hover:enabled:shadow-[var(--shadow-md)]",
2352
+ selected: "ds:bg-[color:var(--primary)] ds:text-[color:var(--primary-foreground)] ds:shadow-[var(--shadow-sm)]",
2353
+ unavailable: "ds:[outline:1px_dashed_color:var(--border)] ds:[outline-offset:-1px] ds:bg-transparent ds:text-[color:var(--muted-foreground)]"
2354
+ }
2355
+ },
2356
+ defaultVariants: { state: "idle" }
2357
+ }
2358
+ );
2359
+ function Bi(e) {
2360
+ const [t] = e.split(":").map((i) => parseInt(i, 10)), s = Number.isFinite(t) ? t : 0;
2361
+ return s < 12 ? "morning" : s < 17 ? "afternoon" : "evening";
2362
+ }
2363
+ const Li = {
2364
+ morning: gs,
2365
+ afternoon: Ks,
2366
+ evening: fs
2367
+ };
2368
+ function Ri({
2369
+ date: e,
2370
+ slots: t,
2371
+ selectedSlotKey: s,
2372
+ onSelect: i,
2373
+ loading: r,
2374
+ locale: a
2375
+ }) {
2376
+ const { t: d } = Q("ui"), m = L(() => {
2377
+ try {
2378
+ return new Intl.DateTimeFormat(a, {
2379
+ weekday: "long",
2380
+ day: "numeric",
2381
+ month: "long"
2382
+ }).format(Ie(e));
2383
+ } catch {
2384
+ return e;
2385
+ }
2386
+ }, [e, a]), p = L(() => {
2387
+ const h = {
2388
+ morning: [],
2389
+ afternoon: [],
2390
+ evening: []
2391
+ };
2392
+ for (const l of t)
2393
+ h[Bi(l.time)].push(l);
2394
+ return h;
2395
+ }, [t]), f = t.filter((h) => h.available).length, g = ["morning", "afternoon", "evening"];
2396
+ return r ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2397
+ /* @__PURE__ */ n(Kt, { variant: "text", width: "60%" }),
2398
+ [0, 1].map((h) => /* @__PURE__ */ n(
2399
+ "div",
2400
+ {
2401
+ className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)]",
2402
+ children: [0, 1, 2].map((l) => /* @__PURE__ */ n(Kt, { variant: "rounded", height: "44px" }, l))
2403
+ },
2404
+ h
2405
+ ))
2406
+ ] }) : f === 0 ? /* @__PURE__ */ n(Sn, { variant: "no-results", title: d("booking.noSlotsForDate") }) : /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2407
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:items-baseline ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
2408
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
2409
+ /* @__PURE__ */ n(
2410
+ Os,
2411
+ {
2412
+ "aria-hidden": "true",
2413
+ className: "ds:size-4 ds:text-[color:var(--accent)]"
2414
+ }
2415
+ ),
2416
+ /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: m })
2417
+ ] }),
2418
+ /* @__PURE__ */ n("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: d("booking.slotsAvailable", { count: f }) })
2419
+ ] }),
2420
+ g.map((h) => {
2421
+ const l = p[h];
2422
+ if (l.length === 0) return null;
2423
+ const o = Li[h];
2424
+ return /* @__PURE__ */ v(
2425
+ "div",
2426
+ {
2427
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
2428
+ children: [
2429
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]", children: [
2430
+ /* @__PURE__ */ n(o, { "aria-hidden": "true", className: "ds:size-3.5" }),
2431
+ /* @__PURE__ */ n("span", { className: "type-meta ds:font-[var(--font-weight-semibold)] ds:uppercase", children: d(`booking.timeOfDay.${h}`) })
2432
+ ] }),
2433
+ /* @__PURE__ */ n(
2434
+ "div",
2435
+ {
2436
+ role: "group",
2437
+ "aria-label": d(`booking.timeOfDay.${h}`),
2438
+ className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)] ds:sm:grid-cols-4",
2439
+ children: l.map((y) => {
2440
+ const b = y.key === s, S = y.available ? b ? "selected" : "idle" : "unavailable";
2441
+ return /* @__PURE__ */ n(
2442
+ "button",
2443
+ {
2444
+ type: "button",
2445
+ "data-slot-id": y.key,
2446
+ disabled: !y.available,
2447
+ "aria-pressed": b,
2448
+ "aria-label": d("booking.slotAvailableLabel", {
2449
+ time: y.time
2450
+ }),
2451
+ onClick: () => y.available && i(y),
2452
+ className: Ei({ state: S }),
2453
+ children: y.time
2454
+ },
2455
+ y.key
2456
+ );
2457
+ })
2458
+ }
2459
+ )
2460
+ ]
2461
+ },
2462
+ h
2463
+ );
2464
+ })
2465
+ ] });
2466
+ }
2467
+ const $t = 4;
2468
+ function _i({
2469
+ availableDates: e,
2470
+ availableSlots: t,
2471
+ value: s,
2472
+ onChange: i,
2473
+ onDateSelect: r,
2474
+ onWindowChange: a,
2475
+ loadingDates: d,
2476
+ loadingSlots: m,
2477
+ locale: p,
2478
+ agentIdBase: f
2479
+ }) {
2480
+ const g = L(() => gt(/* @__PURE__ */ new Date()), []), [h, l] = Z(() => {
2481
+ if (s.date) {
2482
+ const u = gt(Ie(s.date));
2483
+ if (!ht(g, u)) return u;
2484
+ }
2485
+ if (e.length > 0) {
2486
+ const u = gt(Ie(e[0]));
2487
+ if (ht(u, g)) return u;
2488
+ }
2489
+ return g;
2490
+ }), o = L(
2491
+ () => Yt(h, $t - 1),
2492
+ [h]
2493
+ ), y = L(() => Array.from({ length: $t }, (u, w) => {
2494
+ const D = Yt(h, w), z = st(D), k = (t[z] ?? []).map((_) => ({
2495
+ id: _.key,
2496
+ // SlotGrid formats `start` as a time via Intl.DateTimeFormat —
2497
+ // compose a full ISO from the column's date + the slot's HH:mm
2498
+ // so the locale-formatter has a real timestamp to work with.
2499
+ start: `${z}T${_.time}:00`,
2500
+ available: _.available
2501
+ }));
2502
+ return { date: z, slots: k };
2503
+ }), [h, t]), b = ht(h, g), S = !0, E = Ne(() => {
2504
+ l((u) => {
2505
+ const w = us(u, $t);
2506
+ return ht(g, w) ? g : w;
2507
+ });
2508
+ }, [g]), I = Ne(() => {
2509
+ l((u) => Yt(u, $t));
2510
+ }, []);
2511
+ K(() => {
2512
+ if (e.length === 0) return;
2513
+ const u = gt(Ie(e[0]));
2514
+ !ht(u, g) || e.some((D) => {
2515
+ const z = gt(Ie(D));
2516
+ return !ht(z, o) && !ds(z, h);
2517
+ }) || l(u);
2518
+ }, [e]), K(() => {
2519
+ a == null || a(st(h), st(o));
2520
+ }, [h, o, a]);
2521
+ const N = Ne(
2522
+ (u, w) => {
2523
+ const D = typeof w.date == "string" ? w.date : st(w.date);
2524
+ i({
2525
+ ...On(Ut(s, D), u.id)
2526
+ }), r == null || r(D);
2527
+ },
2528
+ [i, r, s]
2529
+ ), x = d || m ? "loading" : "default", M = y.some((u) => u.slots.length > 0), T = e[0];
2530
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2531
+ x !== "loading" && !M && !!T ? /* @__PURE__ */ n(
2532
+ on,
2533
+ {
2534
+ nextAvailableDate: T,
2535
+ onJump: () => l(gt(Ie(T))),
2536
+ locale: p
2537
+ }
2538
+ ) : null,
2539
+ /* @__PURE__ */ n(
2540
+ as,
2541
+ {
2542
+ id: f ? `${f}-slots` : void 0,
2543
+ days: y,
2544
+ state: x,
2545
+ selectedSlotId: s.slotKey,
2546
+ maxInitialSlotsPerDay: 6,
2547
+ locale: p,
2548
+ hasPrevious: b,
2549
+ hasNext: S,
2550
+ onSlotSelect: N,
2551
+ onPreviousDays: E,
2552
+ onNextDays: I
2553
+ }
2554
+ )
2555
+ ] });
2556
+ }
2557
+ function Ln(e) {
2558
+ const {
2559
+ inputs: t,
2560
+ value: s,
2561
+ onChange: i,
2562
+ onDateSelect: r,
2563
+ onWindowChange: a,
2564
+ loadingDates: d,
2565
+ loadingSlots: m,
2566
+ locale: p,
2567
+ datePickerStyle: f,
2568
+ agentIdBase: g
2569
+ } = e;
2570
+ return f === "four-day-grid" ? /* @__PURE__ */ n(
2571
+ _i,
2572
+ {
2573
+ availableDates: t.availableDates,
2574
+ availableSlots: t.availableSlots,
2575
+ value: s,
2576
+ onChange: i,
2577
+ onDateSelect: r,
2578
+ onWindowChange: a,
2579
+ loadingDates: d,
2580
+ loadingSlots: m,
2581
+ locale: p,
2582
+ agentIdBase: g
2583
+ }
2584
+ ) : /* @__PURE__ */ n(
2585
+ Oi,
2586
+ {
2587
+ availableDates: t.availableDates,
2588
+ selectedDate: s.date,
2589
+ onSelectDate: (h) => {
2590
+ i(Ut(s, h)), r == null || r(h);
2591
+ },
2592
+ locale: p,
2593
+ loading: d ?? m
2594
+ }
2595
+ );
2596
+ }
2597
+ function Rn(e) {
2598
+ const { inputs: t, value: s, onChange: i, loadingSlots: r, locale: a, datePickerStyle: d } = e;
2599
+ return d === "four-day-grid" || !s.date ? null : /* @__PURE__ */ n(
2600
+ Ri,
2601
+ {
2602
+ date: s.date,
2603
+ slots: t.availableSlots[s.date] ?? [],
2604
+ selectedSlotKey: s.slotKey,
2605
+ onSelect: (m) => i(On(s, m.key)),
2606
+ loading: r,
2607
+ locale: a
2608
+ }
2609
+ );
2610
+ }
2611
+ function _n({ value: e, onChange: t }) {
2612
+ const { t: s } = Q("ui"), i = [
2613
+ { value: "private", label: s("booking.insurance.private") },
2614
+ { value: "public", label: s("booking.insurance.public") }
2615
+ ];
2616
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2617
+ /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: s("booking.insurance.heading") }),
2618
+ /* @__PURE__ */ n(
2619
+ jt,
2620
+ {
2621
+ options: i,
2622
+ value: e ?? "",
2623
+ onValueChange: (r) => {
2624
+ (r === "private" || r === "public") && t(r);
2625
+ },
2626
+ placeholder: s("booking.insurance.placeholder"),
2627
+ "aria-label": s("booking.insurance.heading")
2628
+ }
2629
+ )
2630
+ ] });
2631
+ }
2632
+ function Pn({
2633
+ specialties: e,
2634
+ value: t,
2635
+ valueIds: s,
2636
+ onChange: i,
2637
+ onChangeIds: r,
2638
+ pickerStyle: a = "select"
2639
+ }) {
2640
+ const { t: d } = Q("ui"), m = e.map((f) => ({
2641
+ value: f.id,
2642
+ label: f.label,
2643
+ dir: "auto"
2644
+ })), p = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: d("booking.specialty.heading") });
2645
+ return a === "multi-select" && r ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2646
+ p,
2647
+ /* @__PURE__ */ n(
2648
+ nn,
2649
+ {
2650
+ options: m,
2651
+ value: s ?? [],
2652
+ onChange: r,
2653
+ placeholder: d("booking.specialty.placeholder"),
2654
+ "aria-label": d("booking.specialty.heading"),
2655
+ allowClear: !0
2656
+ }
2657
+ )
2658
+ ] }) : a === "combobox" ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2659
+ p,
2660
+ /* @__PURE__ */ n(
2661
+ tn,
2662
+ {
2663
+ options: m,
2664
+ value: t ?? "",
2665
+ onValueChange: (f) => i(f === "" ? "" : f),
2666
+ placeholder: d("booking.specialty.placeholder"),
2667
+ "aria-label": d("booking.specialty.heading"),
2668
+ clearable: !0
2669
+ }
2670
+ )
2671
+ ] }) : /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2672
+ p,
2673
+ /* @__PURE__ */ n(
2674
+ jt,
2675
+ {
2676
+ options: m,
2677
+ value: t ?? "",
2678
+ onValueChange: (f) => i(f),
2679
+ placeholder: d("booking.specialty.placeholder"),
2680
+ "aria-label": d("booking.specialty.heading")
2681
+ }
2682
+ )
2683
+ ] });
2684
+ }
2685
+ function Vn({
2686
+ services: e,
2687
+ value: t,
2688
+ valueIds: s,
2689
+ onChange: i,
2690
+ onChangeIds: r,
2691
+ pickerStyle: a,
2692
+ compact: d,
2693
+ showDuration: m
2694
+ }) {
2695
+ const { t: p } = Q("ui"), f = Bn(), g = a ?? (d ? "select" : "cards"), h = e.map((o) => {
2696
+ const { price: y, payment: b, paymentTone: S } = f(o);
2697
+ return {
2698
+ value: o.id,
2699
+ // The practice's service name leads the label, so it decides the
2700
+ // direction, even when the kit's duration is appended after it.
2701
+ dir: "auto",
2702
+ label: y || b || !m ? o.label : `${o.label} · ${p("booking.serviceSummary", {
2703
+ minutes: o.durationMin
2704
+ })}`,
2705
+ ...y ? {
2706
+ endContent: /* @__PURE__ */ n(kn, { variant: "accentSoft", size: "lg", children: y })
2707
+ } : {},
2708
+ ...b ? { description: b, descriptionTone: S } : {}
2709
+ };
2710
+ }), l = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: p("booking.service.heading") });
2711
+ return g === "multi-select" && r ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2712
+ l,
2713
+ /* @__PURE__ */ n(
2714
+ nn,
2715
+ {
2716
+ options: h,
2717
+ value: s ?? [],
2718
+ onChange: r,
2719
+ placeholder: p("booking.service.placeholder"),
2720
+ "aria-label": p("booking.service.heading"),
2721
+ allowClear: !0,
2722
+ wrapOptionLabels: !0
2723
+ }
2724
+ )
2725
+ ] }) : g === "combobox" ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2726
+ l,
2727
+ /* @__PURE__ */ n(
2728
+ tn,
2729
+ {
2730
+ options: h,
2731
+ value: t ?? "",
2732
+ onValueChange: (o) => i(o === "" ? "" : o),
2733
+ placeholder: p("booking.service.placeholder"),
2734
+ "aria-label": p("booking.service.heading"),
2735
+ clearable: !0,
2736
+ wrapOptionLabels: !0
2737
+ }
2738
+ )
2739
+ ] }) : g === "select" ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2740
+ l,
2741
+ /* @__PURE__ */ n(
2742
+ jt,
2743
+ {
2744
+ options: h,
2745
+ value: t ?? "",
2746
+ onValueChange: (o) => i(o),
2747
+ placeholder: p("booking.service.placeholder"),
2748
+ "aria-label": p("booking.service.heading"),
2749
+ showDescriptions: !0,
2750
+ descriptionInName: !0,
2751
+ wrapOptionLabels: !0
2752
+ }
2753
+ )
2754
+ ] }) : /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2755
+ l,
2756
+ /* @__PURE__ */ n(
2757
+ Fi,
2758
+ {
2759
+ services: e,
2760
+ selectedServiceId: t,
2761
+ onSelect: i,
2762
+ showDuration: m
2763
+ }
2764
+ )
2765
+ ] });
2766
+ }
2767
+ function $n({
2768
+ operators: e,
2769
+ value: t,
2770
+ valueIds: s,
2771
+ onChange: i,
2772
+ onChangeIds: r,
2773
+ pickerStyle: a = "select"
2774
+ }) {
2775
+ const { t: d } = Q("ui"), m = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: d("booking.operator.heading") });
2776
+ if (a === "multi-select" && r) {
2777
+ const f = e.map((g) => ({
2778
+ value: g.id,
2779
+ label: g.name,
2780
+ dir: "auto"
2781
+ }));
2782
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2783
+ m,
2784
+ /* @__PURE__ */ n(
2785
+ nn,
2786
+ {
2787
+ options: f,
2788
+ value: s ?? [],
2789
+ onChange: r,
2790
+ placeholder: d("booking.operator.all"),
2791
+ "aria-label": d("booking.operator.heading"),
2792
+ allowClear: !0
2793
+ }
2794
+ )
2795
+ ] });
2796
+ }
2797
+ const p = [
2798
+ { value: Ee, label: d("booking.operator.all") },
2799
+ ...e.map(
2800
+ (f) => ({ value: f.id, label: f.name, dir: "auto" })
2801
+ )
2802
+ ];
2803
+ return a === "combobox" ? /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2804
+ m,
2805
+ /* @__PURE__ */ n(
2806
+ tn,
2807
+ {
2808
+ options: p,
2809
+ value: t ?? Ee,
2810
+ onValueChange: (f) => i(f === "" ? Ee : f),
2811
+ placeholder: d("booking.operator.placeholder"),
2812
+ "aria-label": d("booking.operator.heading"),
2813
+ clearable: !0
2814
+ }
2815
+ )
2816
+ ] }) : /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2817
+ m,
2818
+ /* @__PURE__ */ n(
2819
+ jt,
2820
+ {
2821
+ options: p,
2822
+ value: t ?? Ee,
2823
+ onValueChange: (f) => i(f),
2824
+ placeholder: d("booking.operator.placeholder"),
2825
+ "aria-label": d("booking.operator.heading")
2826
+ }
2827
+ )
2828
+ ] });
2829
+ }
2830
+ function qn({
2831
+ customSlot: e
2832
+ }) {
2833
+ const { t } = Q("ui");
2834
+ return e ? /* @__PURE__ */ n(pe, { children: e }) : /* @__PURE__ */ v(te, { variant: "warning", children: [
2835
+ /* @__PURE__ */ n(te.Title, { as: "h4", children: t("booking.onboardingIncomplete.title") }),
2836
+ /* @__PURE__ */ n(te.Description, { children: t("booking.onboardingIncomplete.description") })
2837
+ ] });
2838
+ }
2839
+ function on({
2840
+ nextAvailableDate: e,
2841
+ onJump: t,
2842
+ locale: s
2843
+ }) {
2844
+ const { t: i } = Q("ui"), r = L(() => {
2845
+ try {
2846
+ return new Intl.DateTimeFormat(s, { dateStyle: "long" }).format(
2847
+ Ie(e)
2848
+ );
2849
+ } catch {
2850
+ return e;
2851
+ }
2852
+ }, [e, s]);
2853
+ return /* @__PURE__ */ v(te, { variant: "info", children: [
2854
+ /* @__PURE__ */ n(te.Description, { children: i("booking.nextAvailable.description", { date: r }) }),
2855
+ /* @__PURE__ */ n(te.Action, { children: /* @__PURE__ */ n(Ye, { intent: "secondary", size: "sm", onClick: t, children: i("booking.nextAvailable.cta") }) })
2856
+ ] });
2857
+ }
2858
+ function Pi({
2859
+ codeVerified: e = !1,
2860
+ payment: t,
2861
+ confirmationChannels: s,
2862
+ snapshot: i,
2863
+ operators: r,
2864
+ specialties: a,
2865
+ services: d,
2866
+ locale: m,
2867
+ mode: p,
2868
+ showModify: f,
2869
+ onReset: g,
2870
+ onModify: h,
2871
+ focusWasLost: l
2872
+ }) {
2873
+ const { t: o } = Q("ui"), y = F(null);
2874
+ K(() => {
2875
+ const u = y.current, w = document.activeElement, D = u == null ? void 0 : u.closest('[data-component="booking"]');
2876
+ !t && !e || !u || (w && (D != null && D.contains(w)) || l()) && u.focus();
2877
+ }, []);
2878
+ const b = sn(s), E = (i.details.confirmationChannels ?? (b.length === 1 ? b : ["email"])).map(
2879
+ (u) => o(`booking.confirmation.channel.${u}`)
2880
+ ), I = t ? zt(t.amountCents, t.currencyCode, m) : "", N = t ? o(
2881
+ p === "demo" ? "booking.payment.paidDemo" : "booking.payment.paidBody",
2882
+ { amount: I }
2883
+ ) : e ? o(p === "demo" ? "booking.code.confirmedDemo" : "booking.code.confirmedBody") : p === "demo" ? o("booking.success.descriptionDemo") : E.length > 1 ? o("booking.success.descriptionMultiple", {
2884
+ channels: E.join(" · ")
2885
+ }) : o("booking.success.descriptionSingle", {
2886
+ channel: E[0]
2887
+ }), x = L(() => {
2888
+ if (i.date)
2889
+ try {
2890
+ return new Intl.DateTimeFormat(m, {
2891
+ weekday: "long",
2892
+ day: "numeric",
2893
+ month: "long"
2894
+ }).format(Ie(i.date));
2895
+ } catch {
2896
+ return i.date;
2897
+ }
2898
+ }, [i.date, m]), M = L(() => {
2899
+ const w = (i.operatorIds && i.operatorIds.length > 0 ? i.operatorIds : i.operatorId ? [i.operatorId] : []).filter((D) => D !== Ee).map((D) => {
2900
+ var z;
2901
+ return (z = r.find((U) => U.id === D)) == null ? void 0 : z.name;
2902
+ }).filter((D) => D !== void 0);
2903
+ if (w.length === 0) return [];
2904
+ try {
2905
+ return new Intl.ListFormat(m === "en" ? "en-GB" : m, {
2906
+ style: "long",
2907
+ type: "conjunction"
2908
+ }).formatToParts(w);
2909
+ } catch {
2910
+ return w.flatMap((D, z) => [
2911
+ ...z > 0 ? [{ type: "literal", value: ", " }] : [],
2912
+ { type: "element", value: D }
2913
+ ]);
2914
+ }
2915
+ }, [i.operatorIds, i.operatorId, r, m]), T = i.specialtyId ? a.find((u) => u.id === i.specialtyId) : void 0, O = i.serviceId ? d.find((u) => u.id === i.serviceId) : void 0;
2916
+ return /* @__PURE__ */ v(
2917
+ "div",
2918
+ {
2919
+ "data-component": "booking-success",
2920
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
2921
+ children: [
2922
+ /* @__PURE__ */ v(te, { variant: "success", children: [
2923
+ /* @__PURE__ */ n(
2924
+ te.Title,
2925
+ {
2926
+ as: "h3",
2927
+ ref: y,
2928
+ tabIndex: t || e ? -1 : void 0,
2929
+ className: t || e ? Tt : void 0,
2930
+ children: o(
2931
+ t ? p === "demo" ? "booking.payment.paidDemoTitle" : "booking.payment.paidTitle" : e ? "booking.code.confirmedHeading" : "booking.success.heading"
2932
+ )
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ n(te.Description, { children: N })
2936
+ ] }),
2937
+ /* @__PURE__ */ n("div", { className: "ds:rounded-[var(--radius-md)] ds:bg-[var(--secondary)] ds:p-[var(--spacing-md)]", children: /* @__PURE__ */ v("dl", { className: "ds:grid ds:grid-cols-[auto_minmax(0,1fr)] ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)] ds:m-0", children: [
2938
+ t && p !== "demo" ? /* @__PURE__ */ v(pe, { children: [
2939
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.payment.summaryPaid") }),
2940
+ /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: I })
2941
+ ] }) : null,
2942
+ T ? /* @__PURE__ */ v(pe, { children: [
2943
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summarySpecialty") }),
2944
+ /* @__PURE__ */ n(
2945
+ "dd",
2946
+ {
2947
+ dir: "auto",
2948
+ className: "type-body ds:m-0 ds:text-[var(--foreground)]",
2949
+ children: T.label
2950
+ }
2951
+ )
2952
+ ] }) : null,
2953
+ O ? /* @__PURE__ */ v(pe, { children: [
2954
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryService") }),
2955
+ /* @__PURE__ */ n(
2956
+ "dd",
2957
+ {
2958
+ dir: "auto",
2959
+ className: "type-body ds:m-0 ds:text-[var(--foreground)]",
2960
+ children: O.label
2961
+ }
2962
+ )
2963
+ ] }) : null,
2964
+ x ? /* @__PURE__ */ v(pe, { children: [
2965
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryDate") }),
2966
+ /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: x })
2967
+ ] }) : null,
2968
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryTime") }),
2969
+ /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: i.slot.time }),
2970
+ M.length > 0 ? /* @__PURE__ */ v(pe, { children: [
2971
+ /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryProvider") }),
2972
+ /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: M.map(
2973
+ (u, w) => u.type === "element" ? /* @__PURE__ */ n("bdi", { children: u.value }, w) : u.value
2974
+ ) })
2975
+ ] }) : null
2976
+ ] }) }),
2977
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
2978
+ /* @__PURE__ */ n(Ye, { intent: "secondary", size: "md", onClick: g, children: o("booking.success.bookAnother") }),
2979
+ f ? /* @__PURE__ */ n(Ye, { intent: "ghost", size: "md", onClick: h, children: o("booking.success.modifyBooking") }) : null
2980
+ ] })
2981
+ ]
2982
+ }
2983
+ );
2984
+ }
2985
+ function Kn({ customSlot: e }) {
2986
+ const { t } = Q("ui");
2987
+ return e ? /* @__PURE__ */ n(pe, { children: e }) : /* @__PURE__ */ n(
2988
+ Sn,
2989
+ {
2990
+ variant: "no-results",
2991
+ title: t("booking.emptyServices.title"),
2992
+ description: t("booking.emptyServices.description")
2993
+ }
2994
+ );
2995
+ }
2996
+ const zn = "data-booking-step-active", Vi = `[${zn}]`;
2997
+ function ee({
2998
+ step: e,
2999
+ active: t,
3000
+ className: s,
3001
+ id: i,
3002
+ children: r
3003
+ }) {
3004
+ return /* @__PURE__ */ n(
3005
+ "div",
3006
+ {
3007
+ id: i,
3008
+ "data-booking-step": String(e),
3009
+ ...t ? { [zn]: "" } : null,
3010
+ tabIndex: -1,
3011
+ className: s ? `${s} ${Tt}` : Tt,
3012
+ children: r
3013
+ }
3014
+ );
3015
+ }
3016
+ function an(e, t) {
3017
+ return t === "four-day-grid" ? e.filter((s) => s !== 6) : e;
3018
+ }
3019
+ function $i(e) {
3020
+ const {
3021
+ cascade: t,
3022
+ inputs: s,
3023
+ value: i,
3024
+ onChange: r,
3025
+ onSubmit: a,
3026
+ emptyServicesSlot: d,
3027
+ onboardingIncompleteSlot: m,
3028
+ loadingDates: p,
3029
+ loadingSlots: f,
3030
+ onDateSelect: g,
3031
+ onWindowChange: h,
3032
+ datePickerStyle: l,
3033
+ specialtyPickerStyle: o,
3034
+ servicePickerStyle: y,
3035
+ showServiceDuration: b,
3036
+ operatorPickerStyle: S,
3037
+ submitting: E,
3038
+ locale: I,
3039
+ detailsProps: N,
3040
+ agentIdBase: x,
3041
+ activeStep: M
3042
+ } = e, { t: T } = Q("ui"), O = bt(M, l), u = (w, D) => ({
3043
+ step: w,
3044
+ active: w === O,
3045
+ className: D
3046
+ });
3047
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3048
+ t.gates.insurance ? /* @__PURE__ */ n(ee, { ...u(1), children: /* @__PURE__ */ n(
3049
+ _n,
3050
+ {
3051
+ value: i.insuranceType,
3052
+ onChange: (w) => r(In(i, w))
3053
+ }
3054
+ ) }) : null,
3055
+ t.gates.specialty ? /* @__PURE__ */ n(ee, { ...u(2), children: /* @__PURE__ */ n(
3056
+ Pn,
3057
+ {
3058
+ specialties: t.filtered.specialties,
3059
+ value: i.specialtyId,
3060
+ valueIds: i.specialtyIds,
3061
+ onChange: (w) => r(Nn(i, w)),
3062
+ onChangeIds: (w) => r(wn(i, w)),
3063
+ pickerStyle: o
3064
+ }
3065
+ ) }) : null,
3066
+ t.gates.service ? /* @__PURE__ */ n(ee, { ...u(3), children: t.filtered.services.length === 0 ? /* @__PURE__ */ n(Kn, { customSlot: d }) : /* @__PURE__ */ n(
3067
+ Vn,
3068
+ {
3069
+ services: t.filtered.services,
3070
+ value: i.serviceId,
3071
+ valueIds: i.serviceIds,
3072
+ onChange: (w) => r(Cn(i, w)),
3073
+ onChangeIds: (w) => r(An(i, w)),
3074
+ pickerStyle: y,
3075
+ showDuration: b
3076
+ }
3077
+ ) }) : null,
3078
+ t.gates.onboardingIncomplete ? /* @__PURE__ */ n(qn, { customSlot: m }) : null,
3079
+ t.gates.operator ? /* @__PURE__ */ n(ee, { ...u(4), children: /* @__PURE__ */ n(
3080
+ $n,
3081
+ {
3082
+ operators: t.filtered.operators,
3083
+ value: i.operatorId,
3084
+ valueIds: i.operatorIds,
3085
+ onChange: (w) => r(Tn(i, w)),
3086
+ onChangeIds: (w) => r(Dn(i, w)),
3087
+ pickerStyle: S
3088
+ }
3089
+ ) }) : null,
3090
+ t.gates.date ? /* @__PURE__ */ v(
3091
+ ee,
3092
+ {
3093
+ ...u(5, "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"),
3094
+ children: [
3095
+ /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: T("booking.date.heading") }),
3096
+ s.availableDates.length === 0 && s.nextAvailableDate ? /* @__PURE__ */ n(
3097
+ on,
3098
+ {
3099
+ nextAvailableDate: s.nextAvailableDate,
3100
+ onJump: () => r(Ut(i, s.nextAvailableDate)),
3101
+ locale: I
3102
+ }
3103
+ ) : Ln({
3104
+ inputs: s,
3105
+ value: i,
3106
+ onChange: r,
3107
+ onDateSelect: g,
3108
+ onWindowChange: h,
3109
+ loadingDates: p,
3110
+ loadingSlots: f,
3111
+ locale: I,
3112
+ datePickerStyle: l,
3113
+ agentIdBase: x
3114
+ })
3115
+ ]
3116
+ }
3117
+ ) : null,
3118
+ t.gates.slot && i.date && l === "month-calendar" ? /* @__PURE__ */ v(
3119
+ ee,
3120
+ {
3121
+ ...u(6, "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"),
3122
+ children: [
3123
+ /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: T("booking.slot.heading") }),
3124
+ Rn({
3125
+ inputs: s,
3126
+ value: i,
3127
+ onChange: r,
3128
+ loadingSlots: f,
3129
+ locale: I,
3130
+ datePickerStyle: l
3131
+ })
3132
+ ]
3133
+ }
3134
+ ) : null,
3135
+ t.gates.details && t.selectedSlot ? /* @__PURE__ */ n(ee, { ...u(7), children: /* @__PURE__ */ n(
3136
+ rn,
3137
+ {
3138
+ ...N,
3139
+ value: i.details ?? {},
3140
+ onChange: (w) => r({ ...i, details: w }),
3141
+ onSubmit: a,
3142
+ submitting: E,
3143
+ defaultPhoneCountry: e.policy.country
3144
+ }
3145
+ ) }) : null
3146
+ ] });
3147
+ }
3148
+ function Te(e, t, s = {}) {
3149
+ const {
3150
+ cascade: i,
3151
+ inputs: r,
3152
+ value: a,
3153
+ onChange: d,
3154
+ onSubmit: m,
3155
+ emptyServicesSlot: p,
3156
+ onboardingIncompleteSlot: f,
3157
+ loadingDates: g,
3158
+ loadingSlots: h,
3159
+ onDateSelect: l,
3160
+ onWindowChange: o,
3161
+ datePickerStyle: y,
3162
+ specialtyPickerStyle: b,
3163
+ servicePickerStyle: S,
3164
+ showServiceDuration: E,
3165
+ operatorPickerStyle: I,
3166
+ submitting: N,
3167
+ locale: x,
3168
+ detailsProps: M,
3169
+ policy: T,
3170
+ agentIdBase: O
3171
+ } = t;
3172
+ switch (e) {
3173
+ case 1:
3174
+ return /* @__PURE__ */ n(
3175
+ _n,
3176
+ {
3177
+ value: a.insuranceType,
3178
+ onChange: (u) => d(In(a, u))
3179
+ }
3180
+ );
3181
+ case 2:
3182
+ return /* @__PURE__ */ n(
3183
+ Pn,
3184
+ {
3185
+ specialties: i.filtered.specialties,
3186
+ value: a.specialtyId,
3187
+ valueIds: a.specialtyIds,
3188
+ onChange: (u) => d(Nn(a, u)),
3189
+ onChangeIds: (u) => d(wn(a, u)),
3190
+ pickerStyle: b
3191
+ }
3192
+ );
3193
+ case 3:
3194
+ return i.filtered.services.length === 0 ? /* @__PURE__ */ n(Kn, { customSlot: p }) : i.gates.onboardingIncomplete ? /* @__PURE__ */ n(qn, { customSlot: f }) : /* @__PURE__ */ n(
3195
+ Vn,
3196
+ {
3197
+ services: i.filtered.services,
3198
+ value: a.serviceId,
3199
+ valueIds: a.serviceIds,
3200
+ onChange: (u) => d(Cn(a, u)),
3201
+ onChangeIds: (u) => d(An(a, u)),
3202
+ pickerStyle: S,
3203
+ compact: s.compactService,
3204
+ showDuration: E
3205
+ }
3206
+ );
3207
+ case 4:
3208
+ return /* @__PURE__ */ n(
3209
+ $n,
3210
+ {
3211
+ operators: i.filtered.operators,
3212
+ value: a.operatorId,
3213
+ valueIds: a.operatorIds,
3214
+ onChange: (u) => d(Tn(a, u)),
3215
+ onChangeIds: (u) => d(Dn(a, u)),
3216
+ pickerStyle: I
3217
+ }
3218
+ );
3219
+ case 5:
3220
+ return r.availableDates.length === 0 && r.nextAvailableDate ? /* @__PURE__ */ n(
3221
+ on,
3222
+ {
3223
+ nextAvailableDate: r.nextAvailableDate,
3224
+ onJump: () => d(Ut(a, r.nextAvailableDate)),
3225
+ locale: x
3226
+ }
3227
+ ) : Ln({
3228
+ inputs: r,
3229
+ value: a,
3230
+ onChange: d,
3231
+ onDateSelect: l,
3232
+ onWindowChange: o,
3233
+ loadingDates: g,
3234
+ loadingSlots: h,
3235
+ locale: x,
3236
+ datePickerStyle: y,
3237
+ agentIdBase: O
3238
+ });
3239
+ case 6:
3240
+ return Rn({
3241
+ inputs: r,
3242
+ value: a,
3243
+ onChange: d,
3244
+ loadingSlots: h,
3245
+ locale: x,
3246
+ datePickerStyle: y
3247
+ });
3248
+ case 7:
3249
+ return i.selectedSlot ? /* @__PURE__ */ n(
3250
+ rn,
3251
+ {
3252
+ ...M,
3253
+ value: a.details ?? {},
3254
+ onChange: (u) => d({ ...a, details: u }),
3255
+ onSubmit: m,
3256
+ submitting: N,
3257
+ defaultPhoneCountry: T.country
3258
+ }
3259
+ ) : null;
3260
+ /* c8 ignore next 2 */
3261
+ default:
3262
+ return null;
3263
+ }
3264
+ }
3265
+ function Gt() {
3266
+ const { t: e } = Q("ui");
3267
+ return L(
3268
+ () => ({
3269
+ 1: e("booking.insurance.heading"),
3270
+ 2: e("booking.specialty.heading"),
3271
+ 3: e("booking.service.heading"),
3272
+ 4: e("booking.operator.heading"),
3273
+ 5: e("booking.date.heading"),
3274
+ 6: e("booking.slot.heading"),
3275
+ 7: e("booking.details.heading")
3276
+ }),
3277
+ [e]
3278
+ );
3279
+ }
3280
+ function bt(e, t) {
3281
+ return t === "four-day-grid" && e === 6 ? 5 : e;
3282
+ }
3283
+ function qi(e) {
3284
+ const { cascade: t, value: s, activeStep: i, setActiveStep: r, datePickerStyle: a } = e, d = Gt(), { t: m } = Q("ui"), p = m("booking.operator.all"), f = L(
3285
+ () => an(t.visibleSteps, a),
3286
+ [t.visibleSteps, a]
3287
+ ), g = bt(i, a), h = Math.max(0, f.indexOf(g)), l = L(
3288
+ () => f.map((o) => ({
3289
+ label: d[o],
3290
+ summary: jn(o, s, t, p),
3291
+ status: Ki(o, s, t),
3292
+ content: /* @__PURE__ */ n(ee, { step: o, active: o === g, children: Te(o, e, { compactService: !0 }) })
3293
+ })),
3294
+ [
3295
+ f,
3296
+ s,
3297
+ d,
3298
+ t,
3299
+ e,
3300
+ g,
3301
+ p
3302
+ ]
3303
+ );
3304
+ return /* @__PURE__ */ n(
3305
+ rs,
3306
+ {
3307
+ activeStep: h,
3308
+ steps: l,
3309
+ onStepChange: (o) => {
3310
+ const y = f[o];
3311
+ y && r(y);
3312
+ }
3313
+ }
3314
+ );
3315
+ }
3316
+ function Ki(e, t, s) {
3317
+ return Ve(e, t) && e < s.currentStep ? "completed" : e <= s.currentStep ? "unlocked" : void 0;
3318
+ }
3319
+ function gn(e, t) {
3320
+ return e !== 4 ? Ve(e, t) : t.operatorIds && t.operatorIds.length > 0 ? !0 : Mn(t) !== void 0;
3321
+ }
3322
+ function Qt(e, t) {
3323
+ const s = e.map((i) => {
3324
+ var r;
3325
+ return (r = t.find((a) => a.id === i)) == null ? void 0 : r.label;
3326
+ }).filter((i) => i !== void 0);
3327
+ return s.length > 0 ? s.join(", ") : void 0;
3328
+ }
3329
+ function jn(e, t, s, i) {
3330
+ var r;
3331
+ if (Ve(e, t))
3332
+ switch (e) {
3333
+ case 1:
3334
+ return t.insuranceType;
3335
+ case 2:
3336
+ return Qt(
3337
+ Ze(t),
3338
+ s.filtered.specialties
3339
+ );
3340
+ case 3:
3341
+ return Qt($e(t), s.filtered.services);
3342
+ case 4: {
3343
+ const d = en(t).filter((p) => p !== Ee), m = Qt(
3344
+ d,
3345
+ s.filtered.operators.map((p) => ({
3346
+ id: p.id,
3347
+ label: p.name
3348
+ }))
3349
+ );
3350
+ return m !== void 0 ? m : d.length === 0 ? i : void 0;
3351
+ }
3352
+ case 5:
3353
+ return t.date;
3354
+ case 6:
3355
+ return (r = s.selectedSlot) == null ? void 0 : r.time;
3356
+ case 7:
3357
+ return;
3358
+ }
3359
+ }
3360
+ function zi(e) {
3361
+ const { cascade: t, value: s, activeStep: i, setActiveStep: r } = e, { t: a } = Q("ui"), d = Gt(), m = a("booking.operator.all"), p = `${vt()}-filter`, f = bt(i, e.datePickerStyle), g = t.visibleSteps.filter(
3362
+ (o) => o === 1 || o === 2 || o === 3 || o === 4
3363
+ ), h = g.some(
3364
+ (o) => !Ve(o, s)
3365
+ ), l = g.some(
3366
+ (o) => o === i
3367
+ ) ? i : g.find((o) => !Ve(o, s));
3368
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3369
+ g.length > 0 ? /* @__PURE__ */ n(
3370
+ "div",
3371
+ {
3372
+ role: "group",
3373
+ "aria-label": a("booking.filtersLabel"),
3374
+ className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
3375
+ children: g.map((o) => {
3376
+ const y = jn(
3377
+ o,
3378
+ s,
3379
+ t,
3380
+ m
3381
+ ), b = o === l, S = Ve(o, s);
3382
+ return /* @__PURE__ */ n(
3383
+ Ye,
3384
+ {
3385
+ intent: b ? "primary" : "outline",
3386
+ size: "sm",
3387
+ endIcon: /* @__PURE__ */ n(
3388
+ cs,
3389
+ {
3390
+ "aria-hidden": "true",
3391
+ className: b ? "ds:rotate-180" : void 0
3392
+ }
3393
+ ),
3394
+ "aria-expanded": S ? b : void 0,
3395
+ "aria-controls": S && b ? p : void 0,
3396
+ "aria-current": !S && b ? "step" : void 0,
3397
+ onClick: () => r(
3398
+ S && b ? t.currentStep : o
3399
+ ),
3400
+ children: y ? /* @__PURE__ */ v(pe, { children: [
3401
+ d[o],
3402
+ ": ",
3403
+ y
3404
+ ] }) : d[o]
3405
+ },
3406
+ `csc-${o}`
3407
+ );
3408
+ })
3409
+ }
3410
+ ) : null,
3411
+ l !== void 0 ? /* @__PURE__ */ n(
3412
+ ee,
3413
+ {
3414
+ step: l,
3415
+ active: l === f,
3416
+ id: p,
3417
+ children: Te(l, e, { compactService: !0 })
3418
+ }
3419
+ ) : null,
3420
+ !h && t.gates.date ? (
3421
+ // four-day-grid embeds slots inline with the day strip — the
3422
+ // historic 2-col date|slot split collapses to a single column
3423
+ // so the picker spans the full width instead of orphaning an
3424
+ // empty right cell.
3425
+ e.datePickerStyle === "four-day-grid" ? /* @__PURE__ */ n(ee, { step: 5, active: f === 5, children: Te(5, e) }) : /* @__PURE__ */ v("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:md:grid-cols-2", children: [
3426
+ /* @__PURE__ */ n(
3427
+ ee,
3428
+ {
3429
+ step: 5,
3430
+ active: f === 5,
3431
+ className: "ds:min-w-0",
3432
+ children: Te(5, e)
3433
+ }
3434
+ ),
3435
+ s.date ? /* @__PURE__ */ n(
3436
+ ee,
3437
+ {
3438
+ step: 6,
3439
+ active: f === 6,
3440
+ className: "ds:min-w-0",
3441
+ children: Te(6, e)
3442
+ }
3443
+ ) : /* @__PURE__ */ n("div", { className: "ds:min-w-0" })
3444
+ ] })
3445
+ ) : null,
3446
+ t.gates.details ? /* @__PURE__ */ n(ee, { step: 7, active: f === 7, children: Te(7, e) }) : null
3447
+ ] });
3448
+ }
3449
+ function ji(e) {
3450
+ const { cascade: t, datePickerStyle: s, activeStep: i } = e, r = bt(i, s), a = t.visibleSteps.filter(
3451
+ (m) => m === 1 || m === 2 || m === 3 || m === 4
3452
+ );
3453
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3454
+ /* @__PURE__ */ v(
3455
+ "div",
3456
+ {
3457
+ className: s === "four-day-grid" ? "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]" : "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:md:grid-cols-2",
3458
+ children: [
3459
+ /* @__PURE__ */ n("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: a.map((m) => /* @__PURE__ */ n(ee, { step: m, active: m === r, children: Te(m, e, { compactService: !0 }) }, `fbf-${m}`)) }),
3460
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3461
+ t.gates.date ? /* @__PURE__ */ n(ee, { step: 5, active: r === 5, children: Te(5, e) }) : null,
3462
+ t.gates.slot && e.value.date && s === "month-calendar" ? /* @__PURE__ */ n(ee, { step: 6, active: r === 6, children: Te(6, e) }) : null
3463
+ ] })
3464
+ ]
3465
+ }
3466
+ ),
3467
+ t.gates.details ? /* @__PURE__ */ n(ee, { step: 7, active: r === 7, children: Te(7, e) }) : null
3468
+ ] });
3469
+ }
3470
+ function Ui(e) {
3471
+ const { cascade: t, value: s, activeStep: i, setActiveStep: r, datePickerStyle: a } = e, { t: d } = Q("ui"), m = Gt(), p = L(
3472
+ () => an(t.visibleSteps, a),
3473
+ [t.visibleSteps, a]
3474
+ ), f = bt(i, a), g = Math.max(0, p.indexOf(f)), h = p.length, l = L(
3475
+ () => p.map((S) => ({ label: m[S] })),
3476
+ [p, m]
3477
+ ), o = g > 0, y = f === 5 && a === "four-day-grid", b = g < h - 1 && Ve(f, s) && (!y || Ve(6, s));
3478
+ return /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3479
+ /* @__PURE__ */ n(os, { activeStep: g, steps: l }),
3480
+ /* @__PURE__ */ n(ee, { step: f, active: !0, children: Te(f, e, { compactService: !0 }) }),
3481
+ /* @__PURE__ */ v("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
3482
+ /* @__PURE__ */ n(
3483
+ Ye,
3484
+ {
3485
+ intent: "ghost",
3486
+ size: "md",
3487
+ disabled: !o,
3488
+ onClick: () => {
3489
+ const S = p[g - 1];
3490
+ S && r(S);
3491
+ },
3492
+ children: d("booking.actions.back")
3493
+ }
3494
+ ),
3495
+ f < 7 ? /* @__PURE__ */ n(
3496
+ Ye,
3497
+ {
3498
+ intent: "primary",
3499
+ size: "md",
3500
+ disabled: !b,
3501
+ onClick: () => {
3502
+ const S = p[g + 1];
3503
+ S && r(S);
3504
+ },
3505
+ children: d("booking.actions.next")
3506
+ }
3507
+ ) : null
3508
+ ] })
3509
+ ] });
3510
+ }
3511
+ const Gi = [], Hi = [];
3512
+ function hn() {
3513
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
3514
+ }
3515
+ const Ji = vn(
3516
+ ({
3517
+ variant: e = "inline-list",
3518
+ country: t,
3519
+ // No default — the cascade engine treats `undefined` as "auto-on
3520
+ // when `specialties` has items" so consumers who pass specialty
3521
+ // data without the explicit flag still get the step.
3522
+ useSpecialties: s,
3523
+ allowOperatorSelection: i = !1,
3524
+ lockedOperatorId: r,
3525
+ operatorsByService: a = !1,
3526
+ autoSelectSingleService: d = !1,
3527
+ specialties: m,
3528
+ services: p,
3529
+ operators: f,
3530
+ availableDates: g,
3531
+ availableSlots: h,
3532
+ nextAvailableDate: l,
3533
+ hideEmail: o = !1,
3534
+ requireCodiceFiscale: y,
3535
+ requireDateOfBirth: b,
3536
+ requireInsuranceNumber: S,
3537
+ billingInDetails: E = !1,
3538
+ paymentNoticeStyle: I = "highlighted",
3539
+ showNote: N,
3540
+ showReturningPatientFlag: x,
3541
+ privacyPolicyUrl: M,
3542
+ termsUrl: T,
3543
+ practiceConsent: O,
3544
+ paymentTermsUrl: u,
3545
+ paymentState: w,
3546
+ renderPayment: D,
3547
+ renderPaymentCompletion: z,
3548
+ validateCodiceFiscale: U,
3549
+ validateInsuranceNumber: k,
3550
+ confirmationChannels: _,
3551
+ defaultConfirmationChannels: j,
3552
+ singleConfirmationChannel: me,
3553
+ value: P,
3554
+ onChange: J,
3555
+ onSubmit: ne,
3556
+ codeStep: re,
3557
+ onStepChange: he,
3558
+ onDateSelect: X,
3559
+ onWindowChange: qe,
3560
+ datePickerStyle: ve = "month-calendar",
3561
+ specialtyPickerStyle: fe,
3562
+ servicePickerStyle: se,
3563
+ showServiceDuration: be = !0,
3564
+ operatorPickerStyle: we,
3565
+ loadingDates: Oe,
3566
+ loadingSlots: oe,
3567
+ submitting: Me,
3568
+ submitError: ce,
3569
+ mode: Be = "live",
3570
+ showModifyOnSuccess: Ce = !0,
3571
+ surface: ie = "flat",
3572
+ emptyServicesSlot: Ke,
3573
+ onboardingIncompleteSlot: q,
3574
+ "aria-label": Le,
3575
+ id: Qe,
3576
+ className: Ot,
3577
+ onFocus: it,
3578
+ onBlur: rt,
3579
+ ...ot
3580
+ }, Fe) => {
3581
+ var Nt, wt, Ct;
3582
+ const { t: de, i18n: Mt } = Q("ui"), ge = e ?? "inline-list", ze = Mt.language ?? "en", ye = m ?? Gi, je = f ?? Hi;
3583
+ K(() => {
3584
+ const A = Xs(P, {
3585
+ useSpecialties: s,
3586
+ lockedOperatorId: r,
3587
+ autoSelectSingleService: d,
3588
+ specialties: ye,
3589
+ services: p
3590
+ });
3591
+ (A.specialtyId !== P.specialtyId || A.operatorId !== P.operatorId || A.serviceId !== P.serviceId) && J(A);
3592
+ }, [
3593
+ r,
3594
+ s,
3595
+ d,
3596
+ ye,
3597
+ p
3598
+ ]);
3599
+ const R = L(
3600
+ () => Qs({
3601
+ country: t,
3602
+ useSpecialties: s,
3603
+ allowOperatorSelection: i,
3604
+ lockedOperatorId: r,
3605
+ operatorsByService: a,
3606
+ specialties: ye,
3607
+ services: p,
3608
+ operators: je,
3609
+ availableSlots: h,
3610
+ value: P
3611
+ }),
3612
+ [
3613
+ t,
3614
+ s,
3615
+ i,
3616
+ r,
3617
+ a,
3618
+ d,
3619
+ ye,
3620
+ p,
3621
+ je,
3622
+ g,
3623
+ h,
3624
+ P
3625
+ ]
3626
+ ), ke = L(
3627
+ () => [
3628
+ JSON.stringify(P.insuranceType),
3629
+ JSON.stringify(Ze(P)),
3630
+ JSON.stringify($e(P)),
3631
+ JSON.stringify(en(P)),
3632
+ JSON.stringify(P.date),
3633
+ JSON.stringify(P.slotKey)
3634
+ ],
3635
+ [P]
3636
+ ), at = ge === "progress", yt = Ne(
3637
+ (A) => {
3638
+ if (A === 4 && R.visibleSteps.includes(4) && en(P).length === 0)
3639
+ return Math.min(4, R.currentStep);
3640
+ if (!at) return R.currentStep;
3641
+ const B = R.visibleSteps.find(
3642
+ (V) => V > A && !gn(V, P)
3643
+ );
3644
+ return B === void 0 ? R.currentStep : Math.min(B, R.currentStep);
3645
+ },
3646
+ [at, R.visibleSteps, R.currentStep, P]
3647
+ ), [ae, Se] = Z(
3648
+ R.currentStep
3649
+ ), kt = F(ke), Ue = F(R.visibleSteps);
3650
+ K(() => {
3651
+ const A = kt.current, B = Ue.current;
3652
+ kt.current = ke, Ue.current = R.visibleSteps;
3653
+ const V = ke.findIndex(
3654
+ (C, W) => C !== A[W]
3655
+ );
3656
+ if (V !== -1) {
3657
+ Se(yt(V + 1));
3658
+ return;
3659
+ }
3660
+ const c = at ? R.visibleSteps.find(
3661
+ (C) => C < ae && !B.includes(C) && !gn(C, P)
3662
+ ) : void 0;
3663
+ if (c !== void 0) {
3664
+ Se(c);
3665
+ return;
3666
+ }
3667
+ R.visibleSteps.includes(ae) || Se(R.currentStep);
3668
+ }, [
3669
+ ke,
3670
+ yt,
3671
+ at,
3672
+ R.currentStep,
3673
+ R.visibleSteps,
3674
+ ae,
3675
+ P
3676
+ ]);
3677
+ const le = F(null), Xe = L(
3678
+ () => an(R.visibleSteps, ve),
3679
+ [R.visibleSteps, ve]
3680
+ ), Ge = Gt(), [Ht, Re] = Z(""), xe = F(null), et = F(null);
3681
+ K(() => {
3682
+ const A = bt(ae, ve);
3683
+ if (et.current === null) {
3684
+ et.current = A;
3685
+ return;
3686
+ }
3687
+ if (et.current === A) return;
3688
+ et.current = A;
3689
+ const B = Xe.indexOf(A);
3690
+ Re(
3691
+ B === -1 ? "" : de("booking.stepAnnouncement", {
3692
+ current: B + 1,
3693
+ total: Xe.length,
3694
+ label: Ge[A]
3695
+ })
3696
+ );
3697
+ const V = xe.current;
3698
+ if (!V || V.isConnected) return;
3699
+ const c = le.current;
3700
+ if (!c) return;
3701
+ const C = document.activeElement;
3702
+ if (!(C === null || C === document.body || !c.contains(C))) return;
3703
+ const nt = c.querySelector(Vi) ?? c;
3704
+ if (nt.focus({ preventScroll: !0 }), typeof nt.scrollIntoView == "function")
3705
+ try {
3706
+ nt.scrollIntoView({
3707
+ behavior: hn() ? "auto" : "smooth",
3708
+ block: "nearest"
3709
+ });
3710
+ } catch {
3711
+ nt.scrollIntoView();
3712
+ }
3713
+ }, [ae, ve, Xe, Ge, de]);
3714
+ const $ = Ii({
3715
+ services: p,
3716
+ value: P,
3717
+ availableSlots: h,
3718
+ onSubmit: ne,
3719
+ onChange: J,
3720
+ paymentState: w,
3721
+ submitting: Me,
3722
+ paymentTermsUrl: u,
3723
+ renderPayment: D,
3724
+ codeStep: re
3725
+ }), Y = $.status, St = $.submit, ct = F($.reset);
3726
+ ct.current = $.reset;
3727
+ const xt = vt(), It = F(null), He = F(null), dt = ((Nt = $.state) == null ? void 0 : Nt.status) === "failed", lt = $.state && "phase" in $.state && $.state.phase === "completion";
3728
+ K(() => {
3729
+ var A, B;
3730
+ if (Y === "payment") {
3731
+ const V = document.activeElement;
3732
+ (!lt || !V || V === document.body || !((A = le.current) != null && A.contains(V))) && ((B = It.current) == null || B.focus());
3733
+ }
3734
+ }, [Y, lt]), K(() => {
3735
+ var A;
3736
+ Y === "payment" && dt && ((A = He.current) == null || A.focus());
3737
+ }, [Y, dt]), Gn(Fe, () => le.current, []);
3738
+ const tt = Y === "success" ? 8 : Y === "payment" || Y === "code" ? 7 : R.currentStep, ut = F(null);
3739
+ K(() => {
3740
+ if (tt !== ut.current && (ut.current = tt, he == null || he(tt), tt === 8 && le.current))
3741
+ try {
3742
+ le.current.scrollIntoView({
3743
+ behavior: hn() ? "auto" : "smooth",
3744
+ block: "start"
3745
+ });
3746
+ } catch {
3747
+ le.current.scrollIntoView();
3748
+ }
3749
+ }, [tt, he]);
3750
+ const _e = F({ activeStep: ae, cascade: R, submitState: Y });
3751
+ K(() => {
3752
+ _e.current = { activeStep: ae, cascade: R, submitState: Y };
3753
+ }, [ae, R, Y]);
3754
+ const Ft = L(
3755
+ () => ({
3756
+ getVariant: () => ge,
3757
+ getCurrentStep: () => {
3758
+ const A = _e.current;
3759
+ return A.submitState === "success" ? 8 : A.submitState === "payment" || A.submitState === "code" ? 7 : A.activeStep;
3760
+ },
3761
+ reset: () => {
3762
+ _e.current.submitState === "payment" || _e.current.submitState === "code" || (J({}), ct.current(), Se(1));
3763
+ },
3764
+ goToStep: (A) => {
3765
+ const B = _e.current, V = B.cascade.visibleSteps.includes(A), c = B.cascade.currentStep, C = B.submitState === "payment" || B.submitState === "code" ? 7 : !V || A > c ? c : A;
3766
+ _e.current = { ...B, activeStep: C }, Se(C);
3767
+ }
3768
+ }),
3769
+ [ge, J]
3770
+ );
3771
+ Hn(Us, Ft, Qe);
3772
+ const Jt = Le ?? de("booking.regionLabel"), Ae = $.snapshot, Wt = Y === "success" && Ae ? /* @__PURE__ */ n(
3773
+ Pi,
3774
+ {
3775
+ codeVerified: $.codeVerified,
3776
+ payment: Ae.payment,
3777
+ confirmationChannels: _,
3778
+ snapshot: {
3779
+ ...Ae.value,
3780
+ slot: Ae.slot,
3781
+ details: Ae.details,
3782
+ serviceId: ((wt = Ae.payment) == null ? void 0 : wt.serviceId) ?? Ae.slot.serviceId ?? Ae.value.serviceId
3783
+ },
3784
+ operators: je,
3785
+ specialties: ye,
3786
+ services: p,
3787
+ locale: ze,
3788
+ mode: Be,
3789
+ showModify: Ce && !Ae.payment && !$.codeVerified,
3790
+ onReset: () => Ft.reset(),
3791
+ focusWasLost: () => {
3792
+ const A = xe.current, B = document.activeElement;
3793
+ return !!(A && !A.isConnected) && (!B || B === document.body);
3794
+ },
3795
+ onModify: () => {
3796
+ ct.current(), Se(7);
3797
+ }
3798
+ }
3799
+ ) : null, pt = Y === "code" && $.codeStep ? /* @__PURE__ */ n(
3800
+ ki,
3801
+ {
3802
+ ...$.codeStep,
3803
+ ...re,
3804
+ onVerified: $.completeCode
3805
+ }
3806
+ ) : null, mt = $.activeSession, Je = $.state, G = mt && Je ? {
3807
+ session: mt,
3808
+ payment: mt.payment,
3809
+ state: Je,
3810
+ billing: (Ct = $.snapshot) == null ? void 0 : Ct.details.billing
3811
+ } : void 0, We = Je && "phase" in Je && Je.phase === "completion", ue = Y === "payment" && G ? /* @__PURE__ */ v(
3812
+ "section",
3813
+ {
3814
+ "aria-labelledby": xt,
3815
+ "data-component": "booking-payment",
3816
+ "data-payment-status": G.state.status,
3817
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
3818
+ children: [
3819
+ /* @__PURE__ */ n(
3820
+ "h3",
3821
+ {
3822
+ ref: It,
3823
+ id: xt,
3824
+ tabIndex: -1,
3825
+ className: "type-title-card ds:m-0",
3826
+ children: de(
3827
+ We ? "booking.payment.confirming" : "booking.payment.heading"
3828
+ )
3829
+ }
3830
+ ),
3831
+ We ? null : /* @__PURE__ */ n("p", { className: "type-body ds:m-0", children: de("booking.payment.noticeBody", {
3832
+ amount: zt(
3833
+ G.payment.amountCents,
3834
+ G.payment.currencyCode,
3835
+ ze
3836
+ )
3837
+ }) }),
3838
+ /* @__PURE__ */ n(
3839
+ "p",
3840
+ {
3841
+ role: "status",
3842
+ className: G.state.status === "processing" ? "type-body ds:m-0 ds:flex ds:items-center ds:gap-[var(--spacing-sm)]" : "ds:sr-only",
3843
+ children: G.state.status === "processing" ? /* @__PURE__ */ v(pe, { children: [
3844
+ /* @__PURE__ */ n(yn, { variant: "pulse", size: "lg", "aria-hidden": "true" }),
3845
+ /* @__PURE__ */ n("span", { children: de(
3846
+ We ? "booking.payment.confirming" : "booking.payment.processing"
3847
+ ) })
3848
+ ] }) : null
3849
+ }
3850
+ ),
3851
+ G.state.status === "failed" ? /* @__PURE__ */ n(
3852
+ te,
3853
+ {
3854
+ ref: He,
3855
+ variant: "error",
3856
+ tabIndex: -1,
3857
+ className: Tt,
3858
+ children: /* @__PURE__ */ n(te.Description, { children: G.state.error ?? de(
3859
+ We ? "booking.payment.completionFailed" : "booking.payment.failed"
3860
+ ) })
3861
+ }
3862
+ ) : null,
3863
+ We ? z == null ? void 0 : z(G) : D == null ? void 0 : D(G)
3864
+ ]
3865
+ }
3866
+ ) : null, Et = L(() => {
3867
+ const A = new Set($e(P)), B = p.filter((V) => A.has(V.id)).map((V) => {
3868
+ var c;
3869
+ return {
3870
+ label: V.label,
3871
+ text: ((c = V.criticalInformationToAccept) == null ? void 0 : c.trim()) ?? ""
3872
+ };
3873
+ }).filter((V) => V.text.length > 0);
3874
+ if (B.length !== 0)
3875
+ return B.length === 1 ? B[0].text : B.map((V) => `${V.label}: ${V.text}`).join(`
3876
+
3877
+ `);
3878
+ }, [p, P]), Bt = L(() => {
3879
+ if (Y === "success" || Y === "payment" || Y === "code")
3880
+ return null;
3881
+ const A = ge === "accordion" ? qi : ge === "calendar" ? zi : ge === "flexible" ? ji : ge === "progress" ? Ui : $i, B = {
3882
+ cascade: R,
3883
+ inputs: {
3884
+ specialties: ye,
3885
+ services: p,
3886
+ operators: je,
3887
+ availableDates: g,
3888
+ availableSlots: h,
3889
+ nextAvailableDate: l
3890
+ },
3891
+ value: P,
3892
+ onChange: J,
3893
+ onSubmit: St,
3894
+ policy: { country: t, lockedOperatorId: r },
3895
+ detailsProps: {
3896
+ hideEmail: o,
3897
+ requireCodiceFiscale: y,
3898
+ requireDateOfBirth: b,
3899
+ requireInsuranceNumber: S,
3900
+ insuranceType: P.insuranceType,
3901
+ showNote: N,
3902
+ showReturningPatientFlag: x,
3903
+ privacyPolicyUrl: M,
3904
+ termsUrl: T,
3905
+ practiceConsent: O,
3906
+ criticalInformationToAccept: Et,
3907
+ payment: $.payment,
3908
+ paymentTermsUrl: u,
3909
+ paymentBlocked: $.blocked,
3910
+ billingInDetails: E,
3911
+ paymentNoticeStyle: I,
3912
+ validateCodiceFiscale: U,
3913
+ validateInsuranceNumber: k,
3914
+ confirmationChannels: _,
3915
+ defaultConfirmationChannels: j,
3916
+ singleConfirmationChannel: me,
3917
+ submitError: ce ?? (Y === "error" ? de("booking.payment.submitFailed") : void 0)
3918
+ },
3919
+ emptyServicesSlot: Ke,
3920
+ onboardingIncompleteSlot: q,
3921
+ loadingDates: Oe,
3922
+ loadingSlots: oe,
3923
+ onDateSelect: X,
3924
+ onWindowChange: qe,
3925
+ datePickerStyle: ve,
3926
+ specialtyPickerStyle: fe,
3927
+ servicePickerStyle: se,
3928
+ showServiceDuration: be,
3929
+ operatorPickerStyle: we,
3930
+ submitting: Me || Y === "submitting",
3931
+ locale: ze,
3932
+ activeStep: ae,
3933
+ setActiveStep: Se,
3934
+ agentIdBase: Qe
3935
+ };
3936
+ return /* @__PURE__ */ n(A, { ...B });
3937
+ }, [
3938
+ Y,
3939
+ $.payment,
3940
+ $.blocked,
3941
+ u,
3942
+ de,
3943
+ ge,
3944
+ R,
3945
+ ye,
3946
+ p,
3947
+ je,
3948
+ g,
3949
+ h,
3950
+ l,
3951
+ P,
3952
+ J,
3953
+ St,
3954
+ t,
3955
+ r,
3956
+ o,
3957
+ y,
3958
+ b,
3959
+ S,
3960
+ E,
3961
+ I,
3962
+ ce,
3963
+ N,
3964
+ x,
3965
+ M,
3966
+ T,
3967
+ O,
3968
+ Et,
3969
+ U,
3970
+ k,
3971
+ _,
3972
+ j,
3973
+ me,
3974
+ Ke,
3975
+ q,
3976
+ Oe,
3977
+ oe,
3978
+ X,
3979
+ qe,
3980
+ ve,
3981
+ fe,
3982
+ se,
3983
+ be,
3984
+ we,
3985
+ Me,
3986
+ ze,
3987
+ ae,
3988
+ Qe
3989
+ ]);
3990
+ return /* @__PURE__ */ v(
3991
+ "div",
3992
+ {
3993
+ ref: le,
3994
+ role: "region",
3995
+ "aria-label": Jt,
3996
+ id: Qe,
3997
+ "data-component": "booking",
3998
+ "data-component-id": Qe,
3999
+ "data-variant": ge,
4000
+ className: Ni({
4001
+ variant: ge,
4002
+ surface: ie,
4003
+ className: Ot
4004
+ }),
4005
+ tabIndex: -1,
4006
+ onFocus: (A) => {
4007
+ xe.current = A.target, it == null || it(A);
4008
+ },
4009
+ onBlur: (A) => {
4010
+ const B = A.target;
4011
+ window.setTimeout(() => {
4012
+ var c;
4013
+ const V = document.activeElement;
4014
+ xe.current === B && B.isConnected && !(V && ((c = le.current) != null && c.contains(V))) && (xe.current = null);
4015
+ }), rt == null || rt(A);
4016
+ },
4017
+ ...ot,
4018
+ children: [
4019
+ /* @__PURE__ */ n("div", { role: "status", className: "ds:sr-only", children: Ht }),
4020
+ /* @__PURE__ */ v(
4021
+ "div",
4022
+ {
4023
+ className: [
4024
+ "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
4025
+ "ds:rounded-[var(--radius-md)]",
4026
+ "ds:bg-[color-mix(in_srgb,var(--primary)_35%,var(--background))]",
4027
+ "ds:bg-[image:var(--gradient-hero-brand)]",
4028
+ "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
4029
+ "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]"
4030
+ ].join(" "),
4031
+ children: [
4032
+ /* @__PURE__ */ n("h2", { className: "type-title-card ds:text-[var(--foreground)] ds:m-0", children: de("booking.regionLabel") }),
4033
+ /* @__PURE__ */ n("p", { className: "type-body-sm ds:text-[var(--foreground)] ds:m-0", children: de("booking.headingSubtitle") })
4034
+ ]
4035
+ }
4036
+ ),
4037
+ $.cancelled ? /* @__PURE__ */ n(te, { variant: "info", children: /* @__PURE__ */ n(te.Description, { children: de("booking.payment.cancelled") }) }) : null,
4038
+ Wt ?? pt ?? ue ?? Bt
4039
+ ]
4040
+ }
4041
+ );
4042
+ }
4043
+ );
4044
+ Ji.displayName = "Booking";
4045
+ export {
4046
+ Ji as B,
4047
+ Xt as C,
4048
+ Ee as O,
4049
+ Us as b
4050
+ };
4051
+ //# sourceMappingURL=booking-Cz_QjIJe.js.map