@riverbankcms/sdk 0.74.0 → 0.76.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 (145) hide show
  1. package/README.md +2 -0
  2. package/dist/{PreviewEditorSidebar-5XL7M3OM.mjs → PreviewEditorSidebar-X2HWXFOL.mjs} +172 -89
  3. package/dist/{PreviewEditorUI-ZDFRDJID.mjs → PreviewEditorUI-AQXIXPOH.mjs} +3 -3
  4. package/dist/SdkPreviewModeRuntime-ZQNDCASH.mjs +8 -0
  5. package/dist/_dts/api/src/bookingOperations.d.ts +12 -0
  6. package/dist/_dts/api/src/cache-tags.d.ts +22 -0
  7. package/dist/_dts/api/src/contentRuntime.d.ts +1 -0
  8. package/dist/_dts/api/src/endpoints.d.ts +24 -24
  9. package/dist/_dts/api/src/index.d.ts +1 -1
  10. package/dist/_dts/api/src/publicExperienceEndpoints.d.ts +13 -4
  11. package/dist/_dts/block-form/src/blockDraftSaveability.d.ts +4 -2
  12. package/dist/_dts/block-form/src/client/index.d.ts +1 -1
  13. package/dist/_dts/block-form/src/manifest/utils.d.ts +24 -0
  14. package/dist/_dts/blocks/src/client/booking-form.d.ts +2 -0
  15. package/dist/_dts/blocks/src/client/carousel.d.ts +1 -0
  16. package/dist/_dts/blocks/src/client/course-registration.d.ts +2 -0
  17. package/dist/_dts/blocks/src/client/events.d.ts +6 -0
  18. package/dist/_dts/blocks/src/client/form.d.ts +2 -0
  19. package/dist/_dts/blocks/src/client/header.d.ts +1 -0
  20. package/dist/_dts/blocks/src/client/location-map.d.ts +1 -0
  21. package/dist/_dts/blocks/src/client/newsletter-form.d.ts +2 -0
  22. package/dist/_dts/blocks/src/client/shop.d.ts +6 -0
  23. package/dist/_dts/blocks/src/contracts/proof-block-islands.d.ts +4 -4
  24. package/dist/_dts/blocks/src/lib/video.d.ts +2 -0
  25. package/dist/_dts/blocks/src/system/manifest/fieldValidation/index.d.ts +21 -1
  26. package/dist/_dts/blocks/src/system/runtime/components/registry.client.d.ts +7 -6
  27. package/dist/_dts/blocks/src/system/runtime/components/runtime-backed-blocks.d.ts +3 -3
  28. package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.headless.state.d.ts +3 -2
  29. package/dist/_dts/blocks/src/system/runtime/nodes/booking-form.interactive.d.ts +3 -27
  30. package/dist/_dts/blocks/src/system/runtime/nodes/booking-runtime-sources.d.ts +163 -0
  31. package/dist/_dts/blocks/src/system/runtime/nodes/event-registration.interactive.d.ts +5 -5
  32. package/dist/_dts/blocks/src/system/runtime/nodes/events/index.d.ts +3 -0
  33. package/dist/_dts/blocks/src/system/runtime/nodes/header-section.client.d.ts +1 -0
  34. package/dist/_dts/blocks/src/system/runtime/nodes/header-section.server.d.ts +1 -0
  35. package/dist/_dts/blocks/src/system/runtime/shared/components/BookingOptionCompactRow.d.ts +29 -0
  36. package/dist/_dts/blocks/src/system/runtime/shared/components/BookingOptionList.d.ts +13 -0
  37. package/dist/_dts/blocks/src/system/runtime/shared/components/index.d.ts +4 -0
  38. package/dist/_dts/blocks/src/system/runtime/shared/index.d.ts +4 -3
  39. package/dist/_dts/blocks/src/system/runtime/shared/utils/bookingRoute.d.ts +20 -0
  40. package/dist/_dts/blocks/src/system/runtime/shared/utils/index.d.ts +2 -1
  41. package/dist/_dts/blocks/src/system/types/link.d.ts +12 -0
  42. package/dist/_dts/content-editor/src/hooks/validateBlocksForPublish.d.ts +5 -0
  43. package/dist/_dts/editor-blocks/src/BlockEditor.d.ts +2 -0
  44. package/dist/_dts/editor-blocks/src/block-editor/BlockCard.d.ts +3 -1
  45. package/dist/_dts/editor-blocks/src/block-editor/BlockCardHeader.d.ts +3 -1
  46. package/dist/_dts/editor-blocks/src/block-editor/BlockSettingsModal.d.ts +5 -1
  47. package/dist/_dts/editor-blocks/src/block-editor/SortableBlockItem.d.ts +2 -0
  48. package/dist/_dts/editor-blocks/src/block-editor/actionControlMode.d.ts +2 -0
  49. package/dist/_dts/editor-blocks/src/index.d.ts +1 -1
  50. package/dist/_dts/preview-next/src/client/preview/SiteChromeEditableSurface.d.ts +12 -2
  51. package/dist/_dts/preview-next/src/client/preview/themeOverlay.d.ts +21 -3
  52. package/dist/_dts/sdk/src/components.d.ts +2 -2
  53. package/dist/_dts/sdk/src/public-api/contracts.d.ts +1 -0
  54. package/dist/_dts/sdk/src/rendering/index.d.ts +2 -2
  55. package/dist/_dts/sdk/src/rendering/islands/deferredVideoEmbeds.d.ts +2 -0
  56. package/dist/_dts/sdk/src/rendering/overrideResolution.d.ts +6 -0
  57. package/dist/_dts/sdk/src/rendering/overrides.d.ts +21 -1
  58. package/dist/_dts/sdk/src/rendering/server.d.ts +4 -0
  59. package/dist/_dts/sdk/src/version.d.ts +1 -1
  60. package/dist/_dts/theme-core/src/generated/containerResponsiveThemeCss.d.ts +1 -1
  61. package/dist/{chunk-2MIWNFJM.mjs → chunk-LYI7TEMH.mjs} +494 -171
  62. package/dist/{chunk-YY7K3QD2.mjs → chunk-Q4OLG66B.mjs} +9 -9
  63. package/dist/{chunk-CEQBBLMJ.mjs → chunk-TW2Y4RR5.mjs} +69 -14
  64. package/dist/{chunk-CBD47MTM.mjs → chunk-V5VORNEJ.mjs} +2 -2
  65. package/dist/{chunk-7RX72SK2.mjs → chunk-VX7B5VAC.mjs} +36 -25
  66. package/dist/{chunk-YRJKZEQ3.mjs → chunk-Z7JLNTJR.mjs} +1 -1
  67. package/dist/cli/index.mjs +3395 -3753
  68. package/dist/client/{accordion-ZZVXWV3N.mjs → accordion-2YHIBOZH.mjs} +1 -1
  69. package/dist/client/bookingForm-35IBDWAS.mjs +3012 -0
  70. package/dist/client/bookings.mjs +30 -21
  71. package/dist/client/{carousel-25WK2H7G.mjs → carousel-K6XG7NZQ.mjs} +3 -2
  72. package/dist/client/cart-HCFYUTTU.mjs +18 -0
  73. package/dist/client/checkout-J3U4XR7K.mjs +18 -0
  74. package/dist/client/chunk-3DCJ45Z2.mjs +36 -0
  75. package/dist/client/chunk-3PEDD5KJ.mjs +146 -0
  76. package/dist/client/{chunk-6VGXRE34.mjs → chunk-7UOSCYY4.mjs} +76 -29
  77. package/dist/client/chunk-BOIHIU7E.mjs +106 -0
  78. package/dist/client/chunk-F7LHOKEH.mjs +146 -0
  79. package/dist/client/chunk-FGUIVT2B.mjs +204 -0
  80. package/dist/client/chunk-I2MMZO53.mjs +6 -0
  81. package/dist/client/chunk-II7O4XN3.mjs +2206 -0
  82. package/dist/client/chunk-J227A3CQ.mjs +245 -0
  83. package/dist/client/chunk-JEZECJ3W.mjs +383 -0
  84. package/dist/client/chunk-M3L3KYYR.mjs +1181 -0
  85. package/dist/client/chunk-OJPZEZU2.mjs +31 -0
  86. package/dist/client/chunk-PFBX3IQL.mjs +1378 -0
  87. package/dist/client/chunk-RTZ3JKKX.mjs +178 -0
  88. package/dist/client/chunk-SNSWVZEP.mjs +5592 -0
  89. package/dist/client/chunk-TQ5MSPDX.mjs +74 -0
  90. package/dist/client/chunk-YLMKMCSJ.mjs +86 -0
  91. package/dist/client/client.mjs +54052 -54518
  92. package/dist/client/courseRegistration-ZBXS7VGI.mjs +1737 -0
  93. package/dist/client/{eventCalendar-X6GIPYFM.mjs → eventCalendar-EQQZHJBA.mjs} +13 -2
  94. package/dist/client/{eventCombined-EZUOPM3G.mjs → eventCombined-JCFTGBFQ.mjs} +13 -2
  95. package/dist/client/eventDetails-HLUTQSYY.mjs +25 -0
  96. package/dist/client/{eventListing-HEFGAETC.mjs → eventListing-FG4MICVB.mjs} +13 -2
  97. package/dist/client/{eventRegistration-3LCP2V3P.mjs → eventRegistration-GUEB7LBT.mjs} +13 -2
  98. package/dist/client/form-YQEW4YIT.mjs +300 -0
  99. package/dist/client/headerSection-GTR3TTRM.mjs +729 -0
  100. package/dist/client/hooks.mjs +49 -33
  101. package/dist/client/locationMap-SPC7VGUH.mjs +227 -0
  102. package/dist/client/newsletterForm-4IW5BLID.mjs +208 -0
  103. package/dist/client/productDetail-KP5H2WJO.mjs +18 -0
  104. package/dist/client/productList-3M3M72XZ.mjs +18 -0
  105. package/dist/client/rendering/client.mjs +15580 -16277
  106. package/dist/client/rendering/islands.mjs +98 -21
  107. package/dist/client/rendering.mjs +48730 -49191
  108. package/dist/client/shop-ACQKVGOM.mjs +20 -0
  109. package/dist/preview-next/before-render.mjs +37 -25
  110. package/dist/preview-next/chrome.css +1 -1
  111. package/dist/preview-next/client/runtime.mjs +5 -5
  112. package/dist/preview-next/editor-base.css +2 -148
  113. package/dist/preview-next/editor-chrome.css +179 -0
  114. package/dist/preview-next/middleware.mjs +37 -25
  115. package/dist/{sdk-runtime-OHNONZ5U.mjs → sdk-runtime-K7HNB4U2.mjs} +6 -6
  116. package/dist/server/components.mjs +1294 -1103
  117. package/dist/server/config-validation.mjs +49 -33
  118. package/dist/server/config.mjs +49 -33
  119. package/dist/server/data.mjs +49 -33
  120. package/dist/server/index.mjs +45 -33
  121. package/dist/server/next.mjs +1240 -1050
  122. package/dist/server/page-converter.mjs +12 -8
  123. package/dist/server/prebuild.mjs +1 -1
  124. package/dist/server/rendering/server.mjs +1389 -1104
  125. package/dist/server/rendering.mjs +1300 -1109
  126. package/dist/server/routing.mjs +49 -33
  127. package/dist/server/server.mjs +50 -34
  128. package/dist/server/theme-bridge.mjs +5 -0
  129. package/dist/styles/index.css +5 -0
  130. package/package.json +2 -1
  131. package/dist/SdkPreviewModeRuntime-CRYNDSPL.mjs +0 -8
  132. package/dist/client/bookingForm-4X77HKDS.mjs +0 -34
  133. package/dist/client/cart-JWD2VRFU.mjs +0 -11
  134. package/dist/client/checkout-V7KYGWL7.mjs +0 -11
  135. package/dist/client/chunk-5IYGMTUE.mjs +0 -18614
  136. package/dist/client/chunk-RKCFVIMS.mjs +0 -26
  137. package/dist/client/courseRegistration-O6ZPK4YT.mjs +0 -29
  138. package/dist/client/eventDetails-3WODIXET.mjs +0 -14
  139. package/dist/client/form-AKXQMY6Z.mjs +0 -85
  140. package/dist/client/headerSection-5KHCMU6B.mjs +0 -12
  141. package/dist/client/locationMap-7HIADW76.mjs +0 -14
  142. package/dist/client/newsletterForm-5N4YTMU3.mjs +0 -60
  143. package/dist/client/productDetail-IZUA7ZP3.mjs +0 -11
  144. package/dist/client/productList-KWIIJE6I.mjs +0 -11
  145. package/dist/client/shop-XZQFRQWZ.mjs +0 -13
@@ -0,0 +1,1181 @@
1
+ "use client";
2
+ import { createContext, useMemo, useContext } from 'react';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+
5
+ // ../blocks/src/system/runtime/api/context.tsx
6
+
7
+ // ../blocks/src/system/runtime/api/deduplication.ts
8
+ function createDeduplicationCache(options = {}) {
9
+ const { ttl = 100 } = options;
10
+ const cache = /* @__PURE__ */ new Map();
11
+ function getCacheKey(method, url, params) {
12
+ const paramsKey = params ? JSON.stringify(params) : "";
13
+ return `${method}:${url}:${paramsKey}`;
14
+ }
15
+ async function dedupe(key, fetcher) {
16
+ const now = Date.now();
17
+ const existing = cache.get(key);
18
+ if (existing) {
19
+ if (!existing.settled) {
20
+ return existing.promise;
21
+ }
22
+ if (existing.settledTime && now - existing.settledTime < ttl) {
23
+ return existing.promise;
24
+ }
25
+ }
26
+ const entry = {
27
+ promise: fetcher().finally(() => {
28
+ entry.settled = true;
29
+ entry.settledTime = Date.now();
30
+ setTimeout(() => {
31
+ const current = cache.get(key);
32
+ if (current?.promise === entry.promise) {
33
+ cache.delete(key);
34
+ }
35
+ }, ttl);
36
+ }),
37
+ startTime: now,
38
+ settled: false
39
+ };
40
+ cache.set(key, entry);
41
+ return entry.promise;
42
+ }
43
+ function clear() {
44
+ cache.clear();
45
+ }
46
+ function size() {
47
+ return cache.size;
48
+ }
49
+ return {
50
+ getCacheKey,
51
+ dedupe,
52
+ clear,
53
+ size
54
+ };
55
+ }
56
+
57
+ // ../blocks/src/system/runtime/api/requestBody.ts
58
+ function omitUndefinedOverrides(overrides) {
59
+ return Object.fromEntries(
60
+ Object.entries(overrides).filter(([, value]) => value !== void 0)
61
+ );
62
+ }
63
+ function withRequestOverrides(body, overrides) {
64
+ return {
65
+ ...body,
66
+ ...omitUndefinedOverrides(overrides)
67
+ };
68
+ }
69
+
70
+ // ../blocks/src/system/runtime/api/endpoints.ts
71
+ function buildPath(template, params) {
72
+ let path = template;
73
+ for (const [key, value] of Object.entries(params)) {
74
+ path = path.replace(`{${key}}`, encodeURIComponent(value));
75
+ }
76
+ return path;
77
+ }
78
+ function appendQuery(path, params) {
79
+ const searchParams = new URLSearchParams();
80
+ for (const [key, value] of Object.entries(params)) {
81
+ if (value !== void 0 && value !== null) {
82
+ searchParams.append(key, String(value));
83
+ }
84
+ }
85
+ const queryString = searchParams.toString();
86
+ if (!queryString) return path;
87
+ return `${path}?${queryString}`;
88
+ }
89
+ var FORMS = {
90
+ submit: {
91
+ path: "/forms/submit",
92
+ method: "POST"
93
+ },
94
+ get: {
95
+ path: "/public/forms/{formId}",
96
+ method: "GET"
97
+ }
98
+ };
99
+ var BOOKINGS = {
100
+ createAppointment: {
101
+ path: "/public/bookings/appointments",
102
+ method: "POST"
103
+ },
104
+ createAppointmentWithPackage: {
105
+ path: "/public/bookings/me/appointments",
106
+ method: "POST",
107
+ authScope: "portal"
108
+ },
109
+ getEligibleAppointmentPackages: {
110
+ path: "/public/bookings/me/appointments/packages",
111
+ method: "GET",
112
+ authScope: "portal"
113
+ },
114
+ appointmentStatus: {
115
+ path: "/public/sites/{siteId}/bookings/appointments/status",
116
+ method: "GET"
117
+ },
118
+ getAvailableSlots: {
119
+ path: "/public/bookings/availability/slots",
120
+ method: "GET"
121
+ },
122
+ getAvailableDates: {
123
+ path: "/public/bookings/availability/dates",
124
+ method: "GET"
125
+ },
126
+ getServices: {
127
+ path: "/public/bookings/services",
128
+ method: "GET"
129
+ },
130
+ getService: {
131
+ path: "/public/bookings/services/{serviceId}",
132
+ method: "GET"
133
+ },
134
+ getResources: {
135
+ path: "/public/bookings/resources/reference",
136
+ method: "GET"
137
+ }
138
+ };
139
+ var EVENTS = {
140
+ list: {
141
+ path: "/public/sites/{siteId}/events",
142
+ method: "GET"
143
+ },
144
+ filters: {
145
+ path: "/public/sites/{siteId}/events/filters",
146
+ method: "GET"
147
+ },
148
+ register: {
149
+ path: "/public/sites/{siteId}/events/register",
150
+ method: "POST",
151
+ authScope: "portal"
152
+ },
153
+ checkout: {
154
+ path: "/public/sites/{siteId}/events/checkout",
155
+ method: "POST"
156
+ },
157
+ checkEligibility: {
158
+ path: "/public/sites/{siteId}/events/check-eligibility",
159
+ method: "POST",
160
+ authScope: "portal"
161
+ },
162
+ registrationStatus: {
163
+ path: "/public/sites/{siteId}/events/registration-status",
164
+ method: "GET"
165
+ }
166
+ };
167
+ var COURSES = {
168
+ enroll: {
169
+ path: "/public/sites/{siteId}/courses/enroll",
170
+ method: "POST",
171
+ authScope: "portal"
172
+ },
173
+ checkout: {
174
+ path: "/public/sites/{siteId}/courses/checkout",
175
+ method: "POST",
176
+ authScope: "portal"
177
+ },
178
+ checkEligibility: {
179
+ path: "/public/sites/{siteId}/courses/check-eligibility",
180
+ method: "POST",
181
+ authScope: "portal"
182
+ },
183
+ waitlistClaimResolve: {
184
+ path: "/public/sites/{siteId}/waitlists/claim/resolve",
185
+ method: "POST",
186
+ authScope: "portal"
187
+ },
188
+ registrationStatus: {
189
+ path: "/public/sites/{siteId}/courses/registration-status",
190
+ method: "GET",
191
+ authScope: "portal"
192
+ }
193
+ };
194
+ var SHOP = {
195
+ listProducts: {
196
+ path: "/public/sites/{siteId}/products",
197
+ method: "GET"
198
+ },
199
+ checkout: {
200
+ path: "/public/sites/{siteId}/bookings/checkout",
201
+ method: "POST"
202
+ },
203
+ unifiedCheckout: {
204
+ path: "/public/sites/{siteId}/checkout",
205
+ method: "POST"
206
+ }
207
+ };
208
+ var GIFTING = {
209
+ offers: {
210
+ path: "/public/sites/{siteId}/gifting/offers",
211
+ method: "GET"
212
+ },
213
+ checkout: {
214
+ path: "/public/sites/{siteId}/gifting/checkout",
215
+ method: "POST"
216
+ },
217
+ claim: {
218
+ path: "/public/sites/{siteId}/gifting/claim",
219
+ method: "POST"
220
+ }
221
+ };
222
+ var DISCOUNTS = {
223
+ available: {
224
+ path: "/public/sites/{siteId}/bookings/discounts/available",
225
+ method: "POST"
226
+ }
227
+ };
228
+ var NEWSLETTER = {
229
+ subscribe: {
230
+ path: "/public/sites/{siteId}/newsletter/subscribe",
231
+ method: "POST"
232
+ }
233
+ };
234
+ var PORTAL = {
235
+ getProfile: {
236
+ path: "/portal/me",
237
+ method: "GET",
238
+ authScope: "portal",
239
+ skipPreviewStage: true
240
+ },
241
+ getCredit: {
242
+ path: "/portal/credit",
243
+ method: "GET",
244
+ authScope: "portal",
245
+ skipPreviewStage: true
246
+ },
247
+ getOrders: {
248
+ path: "/portal/orders",
249
+ method: "GET",
250
+ authScope: "portal",
251
+ skipPreviewStage: true
252
+ },
253
+ createOrderCheckout: {
254
+ path: "/portal/orders/{orderId}/checkout",
255
+ method: "POST",
256
+ authScope: "portal",
257
+ skipPreviewStage: true
258
+ },
259
+ getDigitalProducts: {
260
+ path: "/portal/digital-products",
261
+ method: "GET",
262
+ authScope: "portal",
263
+ skipPreviewStage: true
264
+ },
265
+ getDigitalProduct: {
266
+ path: "/portal/digital-products/{entitlementId}",
267
+ method: "GET",
268
+ authScope: "portal",
269
+ skipPreviewStage: true
270
+ },
271
+ resendDigitalProduct: {
272
+ path: "/portal/digital-products/{entitlementId}/resend",
273
+ method: "POST",
274
+ authScope: "portal",
275
+ skipPreviewStage: true
276
+ },
277
+ getDigitalProductDownloadUrl: {
278
+ path: "/portal/digital-products/{entitlementId}/files/{assetId}/download-url",
279
+ method: "GET",
280
+ authScope: "portal",
281
+ skipPreviewStage: true
282
+ },
283
+ updateProfile: {
284
+ path: "/portal/me",
285
+ method: "PATCH",
286
+ authScope: "portal",
287
+ skipPreviewStage: true
288
+ },
289
+ getPasses: {
290
+ path: "/portal/passes",
291
+ method: "GET",
292
+ authScope: "portal",
293
+ skipPreviewStage: true
294
+ },
295
+ getMemberships: {
296
+ path: "/portal/memberships",
297
+ method: "GET",
298
+ authScope: "portal",
299
+ skipPreviewStage: true
300
+ },
301
+ getEvents: {
302
+ path: "/portal/events",
303
+ method: "GET",
304
+ authScope: "portal",
305
+ skipPreviewStage: true
306
+ },
307
+ getEventTicket: {
308
+ path: "/portal/events/{registrationId}/ticket",
309
+ method: "GET",
310
+ authScope: "portal",
311
+ skipPreviewStage: true
312
+ },
313
+ getEventBookingQuestions: {
314
+ path: "/portal/events/{registrationId}/booking-questions",
315
+ method: "GET",
316
+ authScope: "portal",
317
+ skipPreviewStage: true
318
+ },
319
+ updateEventBookingQuestions: {
320
+ path: "/portal/events/{registrationId}/booking-questions",
321
+ method: "PUT",
322
+ authScope: "portal",
323
+ skipPreviewStage: true
324
+ },
325
+ getAppointments: {
326
+ path: "/portal/appointments",
327
+ method: "GET",
328
+ authScope: "portal",
329
+ skipPreviewStage: true
330
+ },
331
+ getAppointmentBookingQuestions: {
332
+ path: "/portal/appointments/{appointmentId}/booking-questions",
333
+ method: "GET",
334
+ authScope: "portal",
335
+ skipPreviewStage: true
336
+ },
337
+ updateAppointmentBookingQuestions: {
338
+ path: "/portal/appointments/{appointmentId}/booking-questions",
339
+ method: "PUT",
340
+ authScope: "portal",
341
+ skipPreviewStage: true
342
+ },
343
+ getCourses: {
344
+ path: "/portal/courses",
345
+ method: "GET",
346
+ authScope: "portal",
347
+ skipPreviewStage: true
348
+ },
349
+ getCourseBookingQuestions: {
350
+ path: "/portal/courses/{enrollmentId}/booking-questions",
351
+ method: "GET",
352
+ authScope: "portal",
353
+ skipPreviewStage: true
354
+ },
355
+ updateCourseBookingQuestions: {
356
+ path: "/portal/courses/{enrollmentId}/booking-questions",
357
+ method: "PUT",
358
+ authScope: "portal",
359
+ skipPreviewStage: true
360
+ },
361
+ cancelCourseEnrollment: {
362
+ path: "/portal/courses/{enrollmentId}/cancel",
363
+ method: "POST",
364
+ authScope: "portal",
365
+ skipPreviewStage: true
366
+ },
367
+ cancelAppointment: {
368
+ path: "/portal/appointments/{appointmentId}/cancel",
369
+ method: "POST",
370
+ authScope: "portal",
371
+ skipPreviewStage: true
372
+ },
373
+ rescheduleAppointment: {
374
+ path: "/portal/appointments/{appointmentId}/reschedule",
375
+ method: "POST",
376
+ authScope: "portal",
377
+ skipPreviewStage: true
378
+ },
379
+ cancelEventRegistration: {
380
+ path: "/portal/events/{registrationId}/cancel",
381
+ method: "POST",
382
+ authScope: "portal",
383
+ skipPreviewStage: true
384
+ },
385
+ getEventGuests: {
386
+ path: "/portal/events/{registrationId}/guests",
387
+ method: "GET",
388
+ authScope: "portal",
389
+ skipPreviewStage: true
390
+ },
391
+ updateEventGuests: {
392
+ path: "/portal/events/{registrationId}/guests",
393
+ method: "PUT",
394
+ authScope: "portal",
395
+ skipPreviewStage: true
396
+ },
397
+ transferEventRegistration: {
398
+ path: "/portal/events/{registrationId}/transfer",
399
+ method: "POST",
400
+ authScope: "portal",
401
+ skipPreviewStage: true
402
+ },
403
+ cancelMembershipAtPeriodEnd: {
404
+ path: "/portal/memberships/{customerMembershipId}/cancel",
405
+ method: "POST",
406
+ authScope: "portal",
407
+ skipPreviewStage: true
408
+ },
409
+ sendMagicLink: {
410
+ path: "/portal/auth/send-magic-link",
411
+ method: "POST",
412
+ authScope: "portal",
413
+ skipPreviewStage: true
414
+ },
415
+ logout: {
416
+ path: "/portal/auth/logout",
417
+ method: "POST",
418
+ authScope: "portal",
419
+ skipPreviewStage: true
420
+ }
421
+ };
422
+
423
+ // ../blocks/src/system/runtime/api/client.ts
424
+ function encodePublicProductCategorySelector(selector) {
425
+ if (!selector) {
426
+ return {};
427
+ }
428
+ switch (selector.kind) {
429
+ case "category":
430
+ return {
431
+ productCategoryScope: "category",
432
+ productCategoryId: selector.productCategoryId
433
+ };
434
+ case "current-category-page":
435
+ if (selector.productCategoryEntryId.trim().length === 0) {
436
+ return {};
437
+ }
438
+ return {
439
+ productCategoryScope: "current-category-page",
440
+ productCategoryEntryId: selector.productCategoryEntryId
441
+ };
442
+ }
443
+ }
444
+ var BlockApiError = class extends Error {
445
+ constructor(message, status, code) {
446
+ super(message);
447
+ this.status = status;
448
+ this.code = code;
449
+ this.name = "BlockApiError";
450
+ }
451
+ };
452
+ function isRecord(value) {
453
+ return typeof value === "object" && value !== null;
454
+ }
455
+ function isJsonResponseContentType(contentType) {
456
+ if (!contentType) return false;
457
+ const mimeType = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
458
+ return mimeType === "application/json" || mimeType.endsWith("+json");
459
+ }
460
+ function getResponseContentType(response) {
461
+ return response.headers.get("content-type");
462
+ }
463
+ async function parseJsonBody(response) {
464
+ const rawText = await response.text();
465
+ if (rawText.trim().length === 0) {
466
+ return { kind: "empty-body" };
467
+ }
468
+ try {
469
+ return { kind: "success", value: JSON.parse(rawText) };
470
+ } catch {
471
+ return { kind: "invalid-json" };
472
+ }
473
+ }
474
+ function getBlockApiErrorDetails(data) {
475
+ if (!isRecord(data)) {
476
+ return {};
477
+ }
478
+ const nestedError = isRecord(data.error) ? data.error : void 0;
479
+ const message = typeof nestedError?.message === "string" ? nestedError.message : typeof data.message === "string" ? data.message : void 0;
480
+ const code = typeof nestedError?.code === "string" ? nestedError.code : typeof data.code === "string" ? data.code : void 0;
481
+ return { message, code };
482
+ }
483
+ function buildUnexpectedJsonResponseMessage(parseResult) {
484
+ switch (parseResult.kind) {
485
+ case "empty-body":
486
+ return "Expected JSON response body but received an empty response";
487
+ case "invalid-json":
488
+ return "Expected JSON response but received invalid JSON";
489
+ }
490
+ }
491
+ async function extractErrorDetails(response) {
492
+ const contentType = getResponseContentType(response);
493
+ const fallbackMessage = `Request failed: ${response.statusText}`;
494
+ if (!isJsonResponseContentType(contentType)) {
495
+ return {
496
+ message: `${fallbackMessage} (received ${contentType ?? "unknown content type"})`
497
+ };
498
+ }
499
+ const parseResult = await parseJsonBody(response);
500
+ switch (parseResult.kind) {
501
+ case "success": {
502
+ const details = getBlockApiErrorDetails(parseResult.value);
503
+ return {
504
+ message: details.message ?? fallbackMessage,
505
+ code: details.code
506
+ };
507
+ }
508
+ case "invalid-json":
509
+ return {
510
+ message: `${fallbackMessage} (received invalid JSON)`
511
+ };
512
+ case "empty-body":
513
+ return {
514
+ message: `${fallbackMessage} (received an empty response)`
515
+ };
516
+ }
517
+ }
518
+ async function parseJsonApiResponse(response) {
519
+ if (response.status === 204 || response.status === 205) {
520
+ return void 0;
521
+ }
522
+ const contentType = getResponseContentType(response);
523
+ if (!isJsonResponseContentType(contentType)) {
524
+ throw new BlockApiError(
525
+ `Expected JSON response but received ${contentType ?? "unknown content type"}`,
526
+ response.status
527
+ );
528
+ }
529
+ const parseResult = await parseJsonBody(response);
530
+ if (parseResult.kind !== "success") {
531
+ throw new BlockApiError(
532
+ buildUnexpectedJsonResponseMessage(parseResult),
533
+ response.status
534
+ );
535
+ }
536
+ return parseResult.value;
537
+ }
538
+ function getAuthHeaders(auth) {
539
+ switch (auth.type) {
540
+ case "api-key":
541
+ return { Authorization: `Bearer ${auth.key}` };
542
+ case "bearer":
543
+ return { Authorization: `Bearer ${auth.token}` };
544
+ case "none":
545
+ return {};
546
+ }
547
+ }
548
+ function isApiSuccessResponse(json) {
549
+ return json !== null && typeof json === "object" && "success" in json && json.success === true && "data" in json;
550
+ }
551
+ function createBlockApi(config) {
552
+ const { baseUrl, auth, authOverrides, siteId, isPreview } = config;
553
+ const dedup = createDeduplicationCache({ ttl: 100 });
554
+ const shouldUsePreviewStageForNonPortalRequests = isPreview && auth.type !== "none";
555
+ function isPortalEndpoint(endpoint) {
556
+ return endpoint.skipPreviewStage === true;
557
+ }
558
+ function selectAuth(endpoint) {
559
+ if (endpoint.authScope === "portal" && authOverrides?.portal) {
560
+ return authOverrides.portal;
561
+ }
562
+ return auth;
563
+ }
564
+ async function request(endpoint, options) {
565
+ const { path, body, query, skipDedup = false } = options ?? {};
566
+ const resolvedPath = path ?? endpoint.path;
567
+ let url = `${baseUrl}${resolvedPath}`;
568
+ const selectedAuth = selectAuth(endpoint);
569
+ const queryParams = { ...query };
570
+ if (shouldUsePreviewStageForNonPortalRequests && !isPortalEndpoint(endpoint) && (queryParams.stage === void 0 || queryParams.stage === null)) {
571
+ queryParams.stage = "preview";
572
+ }
573
+ if (Object.keys(queryParams).length > 0) {
574
+ url = appendQuery(url, queryParams);
575
+ }
576
+ const authHeaders = getAuthHeaders(selectedAuth);
577
+ const headers = {
578
+ Accept: "application/json",
579
+ ...authHeaders
580
+ };
581
+ if (body !== void 0) {
582
+ headers["Content-Type"] = "application/json";
583
+ }
584
+ const fetchOptions = {
585
+ method: endpoint.method,
586
+ headers
587
+ };
588
+ if (body !== void 0) {
589
+ fetchOptions.body = JSON.stringify(body);
590
+ }
591
+ const doFetch = async () => {
592
+ const response = await fetch(url, fetchOptions);
593
+ if (!response.ok) {
594
+ const details = await extractErrorDetails(response);
595
+ throw new BlockApiError(details.message, response.status, details.code);
596
+ }
597
+ const json = await parseJsonApiResponse(response);
598
+ if (isApiSuccessResponse(json)) {
599
+ return json.data;
600
+ }
601
+ return json;
602
+ };
603
+ if (endpoint.method === "GET" && !skipDedup) {
604
+ const cacheKey = dedup.getCacheKey(endpoint.method, url, void 0);
605
+ return dedup.dedupe(cacheKey, doFetch);
606
+ }
607
+ return doFetch();
608
+ }
609
+ function requireSiteId() {
610
+ if (!siteId) {
611
+ throw new BlockApiError("siteId is required for this operation", 400);
612
+ }
613
+ return siteId;
614
+ }
615
+ return {
616
+ config,
617
+ // Forms
618
+ async submitForm(data) {
619
+ return request(FORMS.submit, { body: data });
620
+ },
621
+ async getForm(formId, formSiteId) {
622
+ const sid = formSiteId ?? siteId;
623
+ const path = buildPath(FORMS.get.path, { formId });
624
+ return request(FORMS.get, { path, query: sid ? { siteId: sid } : void 0 });
625
+ },
626
+ // Bookings
627
+ async submitBooking(data) {
628
+ return request(BOOKINGS.createAppointment, { body: data });
629
+ },
630
+ async submitBookingWithPackage(data) {
631
+ return request(BOOKINGS.createAppointmentWithPackage, { body: data });
632
+ },
633
+ async getEligibleAppointmentPackages(params) {
634
+ return request(BOOKINGS.getEligibleAppointmentPackages, {
635
+ query: { serviceId: params.serviceId }
636
+ });
637
+ },
638
+ async getAppointmentBookingStatus(params) {
639
+ const sid = requireSiteId();
640
+ const path = buildPath(BOOKINGS.appointmentStatus.path, { siteId: sid });
641
+ return request(BOOKINGS.appointmentStatus, {
642
+ path,
643
+ query: { sessionId: params.sessionId },
644
+ skipDedup: true
645
+ });
646
+ },
647
+ async getAvailableSlots(params) {
648
+ const sid = requireSiteId();
649
+ return request(BOOKINGS.getAvailableSlots, {
650
+ query: {
651
+ siteId: sid,
652
+ serviceId: params.serviceId,
653
+ startDate: params.startDate,
654
+ endDate: params.endDate,
655
+ timezone: params.timezone,
656
+ resourceId: params.resourceId
657
+ }
658
+ });
659
+ },
660
+ async getAvailableDates(params) {
661
+ const sid = requireSiteId();
662
+ return request(BOOKINGS.getAvailableDates, {
663
+ query: {
664
+ siteId: sid,
665
+ serviceId: params.serviceId,
666
+ startDate: params.startDate,
667
+ endDate: params.endDate,
668
+ timezone: params.timezone,
669
+ resourceId: params.resourceId
670
+ }
671
+ });
672
+ },
673
+ async getBookingServices(params) {
674
+ const sid = requireSiteId();
675
+ return request(BOOKINGS.getServices, {
676
+ query: {
677
+ siteId: sid,
678
+ ids: params?.ids?.join(",")
679
+ }
680
+ });
681
+ },
682
+ async getBookingService(serviceId) {
683
+ const sid = requireSiteId();
684
+ const path = buildPath(BOOKINGS.getService.path, { serviceId });
685
+ return request(BOOKINGS.getService, { path, query: { siteId: sid } });
686
+ },
687
+ async getBookingResources(params) {
688
+ const sid = requireSiteId();
689
+ return request(BOOKINGS.getResources, {
690
+ query: { siteId: sid, serviceId: params.serviceId }
691
+ });
692
+ },
693
+ // Events
694
+ async getPublicEvents(params) {
695
+ const sid = requireSiteId();
696
+ const path = buildPath(EVENTS.list.path, { siteId: sid });
697
+ return request(EVENTS.list, {
698
+ path,
699
+ query: {
700
+ from: params?.from,
701
+ to: params?.to,
702
+ afterStartsAt: params?.afterStartsAt,
703
+ afterId: params?.afterId,
704
+ limit: params?.limit,
705
+ stage: params?.stage,
706
+ kind: params?.kind,
707
+ eventSurface: params?.eventSurface,
708
+ eventPresets: params?.eventPresets,
709
+ scheduleScope: params?.scheduleScope,
710
+ categoryIds: params?.categoryIds,
711
+ venueId: params?.venueId,
712
+ staffMemberId: params?.staffMemberId,
713
+ entryId: params?.entryId,
714
+ seriesId: params?.seriesId,
715
+ includeOccurrenceId: params?.includeOccurrenceId,
716
+ detailLevel: params?.detailLevel
717
+ }
718
+ });
719
+ },
720
+ async getEventFilters(params) {
721
+ const sid = requireSiteId();
722
+ const path = buildPath(EVENTS.filters.path, { siteId: sid });
723
+ return request(EVENTS.filters, {
724
+ path,
725
+ query: {
726
+ categoryIds: params?.categoryIds,
727
+ venueId: params?.venueId,
728
+ staffMemberId: params?.staffMemberId,
729
+ kind: params?.kind,
730
+ eventSurface: params?.eventSurface,
731
+ eventPresets: params?.eventPresets,
732
+ scheduleScope: params?.scheduleScope
733
+ }
734
+ });
735
+ },
736
+ async registerForEvent(data) {
737
+ const sid = requireSiteId();
738
+ const path = buildPath(EVENTS.register.path, { siteId: sid });
739
+ return request(EVENTS.register, {
740
+ path,
741
+ body: withRequestOverrides(
742
+ data,
743
+ shouldUsePreviewStageForNonPortalRequests ? { stage: "preview" } : {}
744
+ )
745
+ });
746
+ },
747
+ async createEventCheckout(data) {
748
+ const sid = requireSiteId();
749
+ const path = buildPath(EVENTS.checkout.path, { siteId: sid });
750
+ return request(EVENTS.checkout, { path, body: data });
751
+ },
752
+ async checkEligibility(data) {
753
+ const sid = requireSiteId();
754
+ const path = buildPath(EVENTS.checkEligibility.path, { siteId: sid });
755
+ return request(EVENTS.checkEligibility, {
756
+ path,
757
+ body: data
758
+ });
759
+ },
760
+ async getEventRegistrationStatus(params) {
761
+ const sid = requireSiteId();
762
+ const path = buildPath(EVENTS.registrationStatus.path, { siteId: sid });
763
+ return request(EVENTS.registrationStatus, {
764
+ path,
765
+ query: { attendeeId: params.attendeeId },
766
+ skipDedup: true
767
+ // Always fetch fresh status
768
+ });
769
+ },
770
+ // Courses
771
+ async enrollInCourse(data) {
772
+ const sid = requireSiteId();
773
+ const path = buildPath(COURSES.enroll.path, { siteId: sid });
774
+ return request(COURSES.enroll, {
775
+ path,
776
+ body: withRequestOverrides(
777
+ data,
778
+ shouldUsePreviewStageForNonPortalRequests ? { stage: "preview" } : {}
779
+ )
780
+ });
781
+ },
782
+ async checkCourseEligibility(data) {
783
+ const sid = requireSiteId();
784
+ const path = buildPath(COURSES.checkEligibility.path, { siteId: sid });
785
+ return request(COURSES.checkEligibility, {
786
+ path,
787
+ body: data
788
+ });
789
+ },
790
+ async resolveWaitlistClaim(data) {
791
+ const sid = requireSiteId();
792
+ const path = buildPath(COURSES.waitlistClaimResolve.path, { siteId: sid });
793
+ return request(COURSES.waitlistClaimResolve, {
794
+ path,
795
+ body: {
796
+ claimToken: data.claimToken
797
+ }
798
+ });
799
+ },
800
+ async createCourseCheckout(data) {
801
+ const sid = requireSiteId();
802
+ const path = buildPath(COURSES.checkout.path, { siteId: sid });
803
+ return request(COURSES.checkout, {
804
+ path,
805
+ body: {
806
+ courseId: data.courseId,
807
+ ...data.pricingOptionId ? { pricingOptionId: data.pricingOptionId } : {},
808
+ email: data.email,
809
+ name: data.name,
810
+ phone: data.phone,
811
+ formData: data.formData,
812
+ altchaSolution: data.altchaSolution,
813
+ discountCode: data.discountCode,
814
+ successUrl: data.successUrl,
815
+ cancelUrl: data.cancelUrl,
816
+ claimToken: data.claimToken
817
+ }
818
+ });
819
+ },
820
+ async getCourseRegistrationStatus(params) {
821
+ const sid = requireSiteId();
822
+ const path = buildPath(COURSES.registrationStatus.path, { siteId: sid });
823
+ return request(COURSES.registrationStatus, {
824
+ path,
825
+ query: { sessionId: params.sessionId },
826
+ skipDedup: true
827
+ });
828
+ },
829
+ async getDiscountsAvailable(data) {
830
+ const sid = requireSiteId();
831
+ const path = buildPath(DISCOUNTS.available.path, { siteId: sid });
832
+ return request(DISCOUNTS.available, {
833
+ path,
834
+ body: { context: data.context, subtotalCents: data.subtotalCents }
835
+ });
836
+ },
837
+ // Shop
838
+ async getPublicProducts(params) {
839
+ const sid = requireSiteId();
840
+ const path = buildPath(SHOP.listProducts.path, { siteId: sid });
841
+ const query = encodePublicProductCategorySelector(params?.categorySelector);
842
+ return request(SHOP.listProducts, {
843
+ path,
844
+ query: Object.keys(query).length > 0 ? query : void 0
845
+ });
846
+ },
847
+ async createShopCheckout(data) {
848
+ const sid = requireSiteId();
849
+ const path = buildPath(SHOP.checkout.path, { siteId: sid });
850
+ return request(SHOP.checkout, {
851
+ path,
852
+ body: {
853
+ productType: data.productType,
854
+ productId: data.productId,
855
+ customerEmail: data.customerEmail,
856
+ customerName: data.customerName,
857
+ discountCode: data.discountCode,
858
+ successUrl: data.successUrl,
859
+ cancelUrl: data.cancelUrl,
860
+ confirmDuplicate: data.confirmDuplicate
861
+ }
862
+ });
863
+ },
864
+ async createUnifiedCheckout(data) {
865
+ const sid = requireSiteId();
866
+ const path = buildPath(SHOP.unifiedCheckout.path, { siteId: sid });
867
+ return request(SHOP.unifiedCheckout, {
868
+ path,
869
+ body: data
870
+ });
871
+ },
872
+ async getPublicGiftingOffers() {
873
+ const sid = requireSiteId();
874
+ const path = buildPath(GIFTING.offers.path, { siteId: sid });
875
+ return request(GIFTING.offers, { path });
876
+ },
877
+ async createGiftingCheckout(data) {
878
+ const sid = requireSiteId();
879
+ const path = buildPath(GIFTING.checkout.path, { siteId: sid });
880
+ return request(GIFTING.checkout, {
881
+ path,
882
+ body: data
883
+ });
884
+ },
885
+ async claimGiftCard(data) {
886
+ const sid = requireSiteId();
887
+ const path = buildPath(GIFTING.claim.path, { siteId: sid });
888
+ return request(GIFTING.claim, {
889
+ path,
890
+ body: data
891
+ });
892
+ },
893
+ // Newsletter
894
+ async subscribeNewsletter(data) {
895
+ const sid = requireSiteId();
896
+ const path = buildPath(NEWSLETTER.subscribe.path, { siteId: sid });
897
+ return request(NEWSLETTER.subscribe, {
898
+ path,
899
+ body: {
900
+ email: data.email,
901
+ firstName: data.firstName,
902
+ lastName: data.lastName,
903
+ name: data.name,
904
+ company: data.company,
905
+ phone: data.phone,
906
+ listId: data.listId,
907
+ tags: data.tags,
908
+ blockId: data.blockId,
909
+ meta: data.meta
910
+ }
911
+ });
912
+ },
913
+ // Portal
914
+ async getPortalProfile() {
915
+ return request(PORTAL.getProfile);
916
+ },
917
+ async getPortalCredit() {
918
+ const result = await request(PORTAL.getCredit);
919
+ return result.credit;
920
+ },
921
+ async getPortalOrders() {
922
+ const result = await request(PORTAL.getOrders);
923
+ return result.orders;
924
+ },
925
+ async createPortalOrderCheckout(orderId, data) {
926
+ const path = buildPath(PORTAL.createOrderCheckout.path, { orderId });
927
+ return request(PORTAL.createOrderCheckout, {
928
+ path,
929
+ body: data
930
+ });
931
+ },
932
+ async getPortalDigitalProducts() {
933
+ return request(PORTAL.getDigitalProducts);
934
+ },
935
+ async getPortalDigitalProduct(entitlementId) {
936
+ const path = buildPath(PORTAL.getDigitalProduct.path, { entitlementId });
937
+ return request(PORTAL.getDigitalProduct, { path });
938
+ },
939
+ async resendPortalDigitalProduct(entitlementId) {
940
+ const path = buildPath(PORTAL.resendDigitalProduct.path, { entitlementId });
941
+ await request(PORTAL.resendDigitalProduct, { path });
942
+ },
943
+ async getPortalDigitalProductDownloadUrl(entitlementId, assetId) {
944
+ const path = buildPath(PORTAL.getDigitalProductDownloadUrl.path, {
945
+ entitlementId,
946
+ assetId
947
+ });
948
+ return request(PORTAL.getDigitalProductDownloadUrl, {
949
+ path
950
+ });
951
+ },
952
+ async updatePortalProfile(data) {
953
+ const result = await request(PORTAL.updateProfile, {
954
+ body: data
955
+ });
956
+ return result.profile;
957
+ },
958
+ async getPortalPasses() {
959
+ const result = await request(PORTAL.getPasses);
960
+ return result.passes;
961
+ },
962
+ async getPortalMemberships() {
963
+ const result = await request(PORTAL.getMemberships);
964
+ return result.memberships;
965
+ },
966
+ async getPortalEvents(params) {
967
+ const result = await request(PORTAL.getEvents, {
968
+ query: params?.occurrenceId ? { occurrenceId: params.occurrenceId } : void 0
969
+ });
970
+ return result.registrations;
971
+ },
972
+ async getPortalEventTicket(registrationId) {
973
+ const path = buildPath(PORTAL.getEventTicket.path, { registrationId });
974
+ const result = await request(PORTAL.getEventTicket, { path });
975
+ return result.ticket;
976
+ },
977
+ async getPortalAppointments() {
978
+ const result = await request(PORTAL.getAppointments);
979
+ return result.appointments;
980
+ },
981
+ async getPortalAppointmentBookingQuestions(appointmentId) {
982
+ const path = buildPath(PORTAL.getAppointmentBookingQuestions.path, {
983
+ appointmentId
984
+ });
985
+ const result = await request(
986
+ PORTAL.getAppointmentBookingQuestions,
987
+ { path }
988
+ );
989
+ return result.task;
990
+ },
991
+ async updatePortalAppointmentBookingQuestions(appointmentId, data) {
992
+ const path = buildPath(PORTAL.updateAppointmentBookingQuestions.path, {
993
+ appointmentId
994
+ });
995
+ const result = await request(
996
+ PORTAL.updateAppointmentBookingQuestions,
997
+ { path, body: data }
998
+ );
999
+ return result.task;
1000
+ },
1001
+ async getPortalEventBookingQuestions(registrationId) {
1002
+ const path = buildPath(PORTAL.getEventBookingQuestions.path, {
1003
+ registrationId
1004
+ });
1005
+ const result = await request(
1006
+ PORTAL.getEventBookingQuestions,
1007
+ { path }
1008
+ );
1009
+ return result.task;
1010
+ },
1011
+ async updatePortalEventBookingQuestions(registrationId, data) {
1012
+ const path = buildPath(PORTAL.updateEventBookingQuestions.path, {
1013
+ registrationId
1014
+ });
1015
+ const result = await request(
1016
+ PORTAL.updateEventBookingQuestions,
1017
+ { path, body: data }
1018
+ );
1019
+ return result.task;
1020
+ },
1021
+ async getPortalCourses() {
1022
+ const result = await request(PORTAL.getCourses);
1023
+ return result.enrollments;
1024
+ },
1025
+ async getPortalCourseBookingQuestions(enrollmentId) {
1026
+ const path = buildPath(PORTAL.getCourseBookingQuestions.path, {
1027
+ enrollmentId
1028
+ });
1029
+ const result = await request(
1030
+ PORTAL.getCourseBookingQuestions,
1031
+ { path }
1032
+ );
1033
+ return result.task;
1034
+ },
1035
+ async updatePortalCourseBookingQuestions(enrollmentId, data) {
1036
+ const path = buildPath(PORTAL.updateCourseBookingQuestions.path, {
1037
+ enrollmentId
1038
+ });
1039
+ const result = await request(
1040
+ PORTAL.updateCourseBookingQuestions,
1041
+ { path, body: data }
1042
+ );
1043
+ return result.task;
1044
+ },
1045
+ async cancelCourseEnrollment(enrollmentId, options) {
1046
+ const path = buildPath(PORTAL.cancelCourseEnrollment.path, { enrollmentId });
1047
+ const result = await request(
1048
+ PORTAL.cancelCourseEnrollment,
1049
+ { path, body: options ?? {} }
1050
+ );
1051
+ return result.result;
1052
+ },
1053
+ async cancelAppointment(appointmentId, options) {
1054
+ const path = buildPath(PORTAL.cancelAppointment.path, { appointmentId });
1055
+ const result = await request(
1056
+ PORTAL.cancelAppointment,
1057
+ { path, body: options ?? {} }
1058
+ );
1059
+ return result.result;
1060
+ },
1061
+ async rescheduleAppointment(appointmentId, data) {
1062
+ const path = buildPath(PORTAL.rescheduleAppointment.path, { appointmentId });
1063
+ return request(PORTAL.rescheduleAppointment, {
1064
+ path,
1065
+ body: data
1066
+ });
1067
+ },
1068
+ async cancelEventRegistration(registrationId, options) {
1069
+ const path = buildPath(PORTAL.cancelEventRegistration.path, { registrationId });
1070
+ const result = await request(
1071
+ PORTAL.cancelEventRegistration,
1072
+ {
1073
+ path,
1074
+ body: options ?? {}
1075
+ }
1076
+ );
1077
+ return result.result;
1078
+ },
1079
+ async transferEventRegistration(registrationId, data) {
1080
+ const path = buildPath(PORTAL.transferEventRegistration.path, { registrationId });
1081
+ const result = await request(
1082
+ PORTAL.transferEventRegistration,
1083
+ { path, body: data }
1084
+ );
1085
+ return result.result;
1086
+ },
1087
+ async cancelMembershipAtPeriodEnd(customerMembershipId) {
1088
+ const path = buildPath(PORTAL.cancelMembershipAtPeriodEnd.path, { customerMembershipId });
1089
+ const result = await request(
1090
+ PORTAL.cancelMembershipAtPeriodEnd,
1091
+ { path, body: {} }
1092
+ );
1093
+ return result.result;
1094
+ },
1095
+ async getEventGuests(registrationId) {
1096
+ const path = buildPath(PORTAL.getEventGuests.path, { registrationId });
1097
+ const result = await request(PORTAL.getEventGuests, { path });
1098
+ return result.guests;
1099
+ },
1100
+ async updateEventGuests(registrationId, data) {
1101
+ const path = buildPath(PORTAL.updateEventGuests.path, { registrationId });
1102
+ const result = await request(PORTAL.updateEventGuests, {
1103
+ path,
1104
+ body: data
1105
+ });
1106
+ return result.guests;
1107
+ },
1108
+ async sendMagicLink(data) {
1109
+ const sid = requireSiteId();
1110
+ await request(PORTAL.sendMagicLink, {
1111
+ body: {
1112
+ siteId: sid,
1113
+ email: data.email,
1114
+ redirectUrl: data.redirectUrl
1115
+ }
1116
+ });
1117
+ },
1118
+ async logout() {
1119
+ await request(PORTAL.logout);
1120
+ }
1121
+ };
1122
+ }
1123
+ function getGlobalContext() {
1124
+ if (!globalThis.__RIVERBANK_BLOCK_API_CONTEXT__) {
1125
+ globalThis.__RIVERBANK_BLOCK_API_CONTEXT__ = createContext(null);
1126
+ }
1127
+ return globalThis.__RIVERBANK_BLOCK_API_CONTEXT__;
1128
+ }
1129
+ var BlockApiContext = getGlobalContext();
1130
+ function BlockApiProvider({
1131
+ client,
1132
+ config,
1133
+ children
1134
+ }) {
1135
+ const apiClient = useMemo(() => {
1136
+ if (client) return client;
1137
+ if (config) return createBlockApi(config);
1138
+ throw new Error("BlockApiProvider requires either client or config prop");
1139
+ }, [client, config]);
1140
+ return /* @__PURE__ */ jsx(BlockApiContext.Provider, { value: apiClient, children });
1141
+ }
1142
+ function useBlockApi() {
1143
+ const client = useContext(BlockApiContext);
1144
+ if (!client) {
1145
+ throw new Error(
1146
+ "useBlockApi must be used within a BlockApiProvider. Make sure your component is wrapped with <BlockApiProvider>."
1147
+ );
1148
+ }
1149
+ return client;
1150
+ }
1151
+ function joinClasses(...parts) {
1152
+ return parts.filter((part) => typeof part === "string" && part.length > 0).join(" ");
1153
+ }
1154
+ function FeedbackMessage({
1155
+ tone,
1156
+ children,
1157
+ className,
1158
+ title,
1159
+ titleClassName,
1160
+ bodyClassName,
1161
+ role = "status",
1162
+ live
1163
+ }) {
1164
+ const resolvedLive = live ?? (role === "alert" ? "assertive" : "polite");
1165
+ const shouldWrapBody = Boolean(title || bodyClassName);
1166
+ return /* @__PURE__ */ jsxs(
1167
+ "div",
1168
+ {
1169
+ className,
1170
+ "data-feedback-tone": tone,
1171
+ role,
1172
+ "aria-live": resolvedLive === "off" ? void 0 : resolvedLive,
1173
+ children: [
1174
+ title ? /* @__PURE__ */ jsx("p", { className: joinClasses(titleClassName), "data-feedback-title": true, children: title }) : null,
1175
+ shouldWrapBody ? /* @__PURE__ */ jsx("div", { className: joinClasses(bodyClassName), "data-feedback-body": true, children }) : children
1176
+ ]
1177
+ }
1178
+ );
1179
+ }
1180
+
1181
+ export { BlockApiError, BlockApiProvider, FeedbackMessage, useBlockApi };