@wix/bookings 1.0.1754 → 1.0.1756
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.
- package/_sdk-exports/context-booking-checkout/runtime.d.ts +791 -143
- package/_sdk-exports/context-booking-checkout/runtime.js +3 -2
- package/_sdk-exports/context-categories/runtime.d.ts +164 -2
- package/_sdk-exports/context-categories/runtime.js +2 -1
- package/_sdk-exports/context-locations/runtime.d.ts +186 -2
- package/_sdk-exports/context-locations/runtime.js +2 -1
- package/_sdk-exports/context-service/runtime.d.ts +1540 -144
- package/_sdk-exports/context-service/runtime.js +3 -2
- package/_sdk-exports/context-service-addons/runtime.d.ts +215 -13
- package/_sdk-exports/context-service-addons/runtime.js +2 -1
- package/_sdk-exports/context-services/runtime.d.ts +371 -77
- package/_sdk-exports/context-services/runtime.js +3 -2
- package/_sdk-exports/context-time-slots/runtime.d.ts +854 -72
- package/_sdk-exports/context-time-slots/runtime.js +3 -2
- package/build/cjs/context-booking-checkout.d.ts +791 -143
- package/build/cjs/context-booking-checkout.js +1759 -1640
- package/build/cjs/context-booking-checkout.js.map +1 -1
- package/build/cjs/context-categories.d.ts +164 -2
- package/build/cjs/context-categories.js +116 -114
- package/build/cjs/context-categories.js.map +1 -1
- package/build/cjs/context-locations.d.ts +186 -2
- package/build/cjs/context-locations.js +126 -124
- package/build/cjs/context-locations.js.map +1 -1
- package/build/cjs/context-service-addons.d.ts +215 -13
- package/build/cjs/context-service-addons.js +323 -321
- package/build/cjs/context-service-addons.js.map +1 -1
- package/build/cjs/context-service.d.ts +1540 -144
- package/build/cjs/context-service.js +1622 -1616
- package/build/cjs/context-service.js.map +1 -1
- package/build/cjs/context-services.d.ts +371 -77
- package/build/cjs/context-services.js +460 -458
- package/build/cjs/context-services.js.map +1 -1
- package/build/cjs/context-time-slots.d.ts +854 -72
- package/build/cjs/context-time-slots.js +1033 -1000
- package/build/cjs/context-time-slots.js.map +1 -1
- package/build/es/context-booking-checkout.d.mts +791 -143
- package/build/es/context-booking-checkout.mjs +1778 -1650
- package/build/es/context-booking-checkout.mjs.map +1 -1
- package/build/es/context-categories.d.mts +164 -2
- package/build/es/context-categories.mjs +116 -114
- package/build/es/context-categories.mjs.map +1 -1
- package/build/es/context-locations.d.mts +186 -2
- package/build/es/context-locations.mjs +126 -124
- package/build/es/context-locations.mjs.map +1 -1
- package/build/es/context-service-addons.d.mts +215 -13
- package/build/es/context-service-addons.mjs +323 -321
- package/build/es/context-service-addons.mjs.map +1 -1
- package/build/es/context-service.d.mts +1540 -144
- package/build/es/context-service.mjs +1622 -1616
- package/build/es/context-service.mjs.map +1 -1
- package/build/es/context-services.d.mts +371 -77
- package/build/es/context-services.mjs +460 -458
- package/build/es/context-services.mjs.map +1 -1
- package/build/es/context-time-slots.d.mts +854 -72
- package/build/es/context-time-slots.mjs +1033 -1000
- package/build/es/context-time-slots.mjs.map +1 -1
- package/build/internal/cjs/context-booking-checkout.d.ts +791 -143
- package/build/internal/cjs/context-categories.d.ts +164 -2
- package/build/internal/cjs/context-locations.d.ts +186 -2
- package/build/internal/cjs/context-service-addons.d.ts +215 -13
- package/build/internal/cjs/context-service.d.ts +1540 -144
- package/build/internal/cjs/context-services.d.ts +371 -77
- package/build/internal/cjs/context-time-slots.d.ts +854 -72
- package/build/internal/es/context-booking-checkout.d.mts +791 -143
- package/build/internal/es/context-categories.d.mts +164 -2
- package/build/internal/es/context-locations.d.mts +186 -2
- package/build/internal/es/context-service-addons.d.mts +215 -13
- package/build/internal/es/context-service.d.mts +1540 -144
- package/build/internal/es/context-services.d.mts +371 -77
- package/build/internal/es/context-time-slots.d.mts +854 -72
- package/package.json +5 -5
|
@@ -65,7 +65,7 @@ declare global {
|
|
|
65
65
|
interface SDKTypeMode {}
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-
|
|
68
|
+
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-p5eQUd5f.d.mts
|
|
69
69
|
interface V2Category {
|
|
70
70
|
/**
|
|
71
71
|
* Category ID.
|
|
@@ -101,22 +101,178 @@ interface CategoriesPickerFilter {
|
|
|
101
101
|
//#region src/extensions/contexts/categories-context/categories-context.d.ts
|
|
102
102
|
/** A service category as shown in a category list, with its selected state. */
|
|
103
103
|
interface CategoryItem {
|
|
104
|
+
/**
|
|
105
|
+
* Category ID. Pass it to `selectCategory()` to select the category.
|
|
106
|
+
*
|
|
107
|
+
* `null` when the category has no ID. A category with no ID can't be selected, because passing
|
|
108
|
+
* `null` to `selectCategory()` clears the selection. Leave these items out of a category filter.
|
|
109
|
+
*/
|
|
104
110
|
categoryId: string | null;
|
|
111
|
+
/**
|
|
112
|
+
* Category name.
|
|
113
|
+
*
|
|
114
|
+
* `null` when the category has no name.
|
|
115
|
+
*/
|
|
105
116
|
categoryName: string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the category is selected, meaning its ID is in the page URL's `category` query
|
|
119
|
+
* parameter.
|
|
120
|
+
*/
|
|
106
121
|
isSelected: boolean;
|
|
107
122
|
}
|
|
108
123
|
/** The business service categories, the selected category, the loading and error state, and the actions to change or reload them. */
|
|
109
124
|
interface CategoriesContextValue {
|
|
125
|
+
/**
|
|
126
|
+
* Service categories, sorted by their sort order. Each category holds its details, such as its
|
|
127
|
+
* ID, name, and sort order. To manage categories, use the
|
|
128
|
+
* [Categories V2
|
|
129
|
+
* API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/introduction).
|
|
130
|
+
*
|
|
131
|
+
* Holds only the categories that have bookable services. When the Data Source's settings pick
|
|
132
|
+
* categories, it holds only the picked categories.
|
|
133
|
+
*
|
|
134
|
+
* Empty while the categories load, and when they fail to load.
|
|
135
|
+
*
|
|
136
|
+
* Don't change the array or its items, for example by sorting the array in place. Every
|
|
137
|
+
* component that uses the context gets the same array.
|
|
138
|
+
*/
|
|
110
139
|
categories: Category[];
|
|
140
|
+
/**
|
|
141
|
+
* Service categories as list items, each with its ID, name, and whether it's selected. Use them
|
|
142
|
+
* to render a list of categories that site visitors select from.
|
|
143
|
+
*
|
|
144
|
+
* Holds the same categories as `categories`, in the same order.
|
|
145
|
+
*/
|
|
111
146
|
categoryItems: CategoryItem[];
|
|
147
|
+
/**
|
|
148
|
+
* ID of the selected category, from the page URL's `category` query parameter.
|
|
149
|
+
*
|
|
150
|
+
* It already holds the URL's category while the categories load, before `categories` fills. It
|
|
151
|
+
* can hold an ID that isn't in `categories`, such as an ID from an outdated link.
|
|
152
|
+
* `selectedCategory` is then `null`.
|
|
153
|
+
*
|
|
154
|
+
* `null` when no category is selected.
|
|
155
|
+
*/
|
|
112
156
|
selectedCategoryId: string | null;
|
|
157
|
+
/**
|
|
158
|
+
* Position of the selected category in `categories`, starting at `0`.
|
|
159
|
+
*
|
|
160
|
+
* `-1` when no category is selected, when `selectedCategoryId` isn't in `categories`, and while
|
|
161
|
+
* the categories load.
|
|
162
|
+
*/
|
|
113
163
|
selectedCategoryIndex: number;
|
|
164
|
+
/**
|
|
165
|
+
* Selected category, with its details, such as its ID, name, and sort order.
|
|
166
|
+
*
|
|
167
|
+
* `null` when no category is selected, when `selectedCategoryId` isn't in `categories`, and
|
|
168
|
+
* while the categories load.
|
|
169
|
+
*/
|
|
114
170
|
selectedCategory: Category | null;
|
|
171
|
+
/**
|
|
172
|
+
* Name of the selected category.
|
|
173
|
+
*
|
|
174
|
+
* `null` when `selectedCategory` is `null`, or when the category has no name.
|
|
175
|
+
*/
|
|
115
176
|
selectedCategoryName: string | null;
|
|
177
|
+
/**
|
|
178
|
+
* Whether `categories` holds multiple categories with an ID. Use it to hide a category filter
|
|
179
|
+
* when there's nothing to choose between.
|
|
180
|
+
*
|
|
181
|
+
* `false` while the categories load, and when they fail to load.
|
|
182
|
+
*/
|
|
116
183
|
hasMultipleCategories: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Whether the categories are loading. It's `true` during the first load, and while `refetch()`
|
|
186
|
+
* reloads them.
|
|
187
|
+
*
|
|
188
|
+
* While it's `true`, `categories` and `categoryItems` are empty, and `selectCategory()` does
|
|
189
|
+
* nothing.
|
|
190
|
+
*/
|
|
117
191
|
isLoading: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Whether the categories failed to load.
|
|
194
|
+
*
|
|
195
|
+
* When it's `true`, `categories` and `categoryItems` are empty. To try again, call `refetch()`.
|
|
196
|
+
*
|
|
197
|
+
* It's also `true`, with the same empty values, after a component under the context fails to
|
|
198
|
+
* render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
|
|
199
|
+
* `selectCategory()` does nothing.
|
|
200
|
+
*/
|
|
118
201
|
hasError: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Reloads the service categories.
|
|
204
|
+
*
|
|
205
|
+
* While they reload, `isLoading` is `true`, and `categories` and `categoryItems` are empty. The
|
|
206
|
+
* selected category doesn't change.
|
|
207
|
+
*
|
|
208
|
+
* Use it to try again after the categories fail to load, when `hasError` is `true`. It doesn't
|
|
209
|
+
* clear `hasError` when a component under the context failed to render.
|
|
210
|
+
*
|
|
211
|
+
* @example Retry loading the categories after a failure
|
|
212
|
+
* ```tsx
|
|
213
|
+
* import { useCategoriesContext } from '@wix/bookings/context/categories';
|
|
214
|
+
*
|
|
215
|
+
* function CategoriesErrorMessage() {
|
|
216
|
+
* const { hasError, refetch } = useCategoriesContext();
|
|
217
|
+
*
|
|
218
|
+
* if (!hasError) {
|
|
219
|
+
* return null;
|
|
220
|
+
* }
|
|
221
|
+
*
|
|
222
|
+
* return (
|
|
223
|
+
* <p>
|
|
224
|
+
* We couldn't load the service categories.{' '}
|
|
225
|
+
* <button onClick={() => refetch()}>Try again</button>
|
|
226
|
+
* </p>
|
|
227
|
+
* );
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
119
231
|
refetch: () => void;
|
|
232
|
+
/**
|
|
233
|
+
* Selects a category, or clears the selection.
|
|
234
|
+
*
|
|
235
|
+
* Selecting a category sets the page URL's `category` query parameter, which updates
|
|
236
|
+
* `selectedCategoryId` and the other properties about the selected category. When it changes
|
|
237
|
+
* the selection, `selectCategory()`:
|
|
238
|
+
* - Adds an entry to the browser history, so the browser's Back button returns to the previous
|
|
239
|
+
* selection.
|
|
240
|
+
* - Removes the URL's `page` query parameter, so a list of services on the page starts again
|
|
241
|
+
* from its first page.
|
|
242
|
+
* - Keeps the page's scroll position.
|
|
243
|
+
*
|
|
244
|
+
* It doesn't check that the ID is in `categories`.
|
|
245
|
+
*
|
|
246
|
+
* Does nothing while `isLoading` is `true`.
|
|
247
|
+
*
|
|
248
|
+
* @param categoryId - ID of the category to select. Pass `null` to clear the selection, such as
|
|
249
|
+
* for an "All services" option.
|
|
250
|
+
*
|
|
251
|
+
* @example Select a category from a dropdown
|
|
252
|
+
* ```tsx
|
|
253
|
+
* import { useCategoriesContext } from '@wix/bookings/context/categories';
|
|
254
|
+
*
|
|
255
|
+
* function CategoryDropdown() {
|
|
256
|
+
* const { categoryItems, selectedCategoryId, selectCategory } = useCategoriesContext();
|
|
257
|
+
*
|
|
258
|
+
* return (
|
|
259
|
+
* <select
|
|
260
|
+
* value={selectedCategoryId ?? ''}
|
|
261
|
+
* onChange={(event) => selectCategory(event.target.value || null)}
|
|
262
|
+
* >
|
|
263
|
+
* <option value="">All services</option>
|
|
264
|
+
* {categoryItems
|
|
265
|
+
* .filter((item) => item.categoryId)
|
|
266
|
+
* .map((item) => (
|
|
267
|
+
* <option key={item.categoryId} value={item.categoryId ?? ''}>
|
|
268
|
+
* {item.categoryName}
|
|
269
|
+
* </option>
|
|
270
|
+
* ))}
|
|
271
|
+
* </select>
|
|
272
|
+
* );
|
|
273
|
+
* }
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
120
276
|
selectCategory: (categoryId: string | null) => void;
|
|
121
277
|
}
|
|
122
278
|
/** Props accepted by {@link CategoriesContextProvider}. */
|
|
@@ -131,7 +287,13 @@ interface CategoriesContextProviderProps {
|
|
|
131
287
|
}
|
|
132
288
|
declare const categoriesContext: React.Context<CategoriesContextValue | null>;
|
|
133
289
|
declare const CATEGORIES_CONTEXT_MISSING_PROVIDER_ERROR = "useCategoriesContext must be used within CategoriesContextProvider";
|
|
134
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* The `useCategoriesContext()` hook provides access to the business's service categories and the
|
|
292
|
+
* category a site visitor selected. Use it to show the categories and let site visitors select one
|
|
293
|
+
* to filter the services on the page.
|
|
294
|
+
*
|
|
295
|
+
* It throws an error where the context isn't available.
|
|
296
|
+
*/
|
|
135
297
|
declare function useCategoriesContext(): CategoriesContextValue;
|
|
136
298
|
/** Loads the business service categories and tracks the selected category in the page URL. */
|
|
137
299
|
declare function CategoriesContextProvider({
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{Component as e,Suspense as t,createContext as n,useCallback as r,useContext as i,useEffect as a,useMemo as o,useRef as s,useState as c,useSyncExternalStore as l}from"react";import{useGetService as u,useService as d}from"@wix/services-manager-react";import{jsx as f}from"react/jsx-runtime";var p={};function m(e,t=!1,n=e=>e){return()=>({__type:`event-definition`,type:e,isDomainEvent:t,transformations:n})}var h=e=>{switch(e){case`get`:case`GET`:return`GET`;case`post`:case`POST`:return`POST`;case`put`:case`PUT`:return`PUT`;case`delete`:case`DELETE`:return`DELETE`;case`patch`:case`PATCH`:return`PATCH`;case`head`:case`HEAD`:return`HEAD`;case`options`:case`OPTIONS`:return`OPTIONS`;default:throw Error(`Unknown method: ${e}`)}},g=e=>t=>async n=>{let r,i=t=>{if(r=e(n)(t),r.url===void 0)throw Error(`Url was not successfully created for this request, please reach out to support channels for assistance.`);let{method:i,url:a,params:o}=r;return{...r,method:h(i),url:a,data:r.data,params:o}};try{let e=await t.request(i);if(r===void 0)throw Error(`Request options were not created for this request, please reach out to support channels for assistance.`);let n=Array.isArray(r.transformResponse)?r.transformResponse:[r.transformResponse],a=e.data;return n.forEach(t=>{t&&(a=t(e.data,e.headers))}),a}catch(e){throw typeof e==`object`&&e&&`response`in e&&typeof e.response==`object`&&e.response!==null&&`data`in e.response?e.response.data:e}},_=e=>e.__isAmbassador?!0:!!e().__isAmbassador,v=`__metadata`,y=`edge.wixapis.com`,b=class extends Error{message;response;constructor(e,t){super(e),this.message=e,this.response=t}async details(){let e=await this.response.json();return x(this.response.status,e?.message,e?.details,{requestId:this.response.headers.get(`X-Wix-Request-Id`),details:e})}},x=(e,t,n,r)=>({details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t,requestId:r?.requestId}),S=e=>e?.method&&[`post`,`put`,`patch`].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":`application/json`}:{},C=e=>e&&typeof e==`object`&&!Array.isArray(e),ee=e=>e.__type===`host`;function te(e,t){return e.create(t)}var ne=`x-wix-bi-gateway`;function re(e,t,n){return{[ne]:ie({environment:`js-sdk${n?`-${n}`:``}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function ie(e){return Object.entries(e).filter(([e,t])=>!!t).map(([e,t])=>`${e}=${t}`).join(`,`)}function ae(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}var oe={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function w(e){return ue(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var se=/([\p{Ll}\d])(\p{Lu})/gu,ce=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,T=`$1\0$2`,le=/[^\p{L}\d]+/giu;function ue(e){let t=e.trim();t=t.replace(se,T).replace(ce,T),t=t.replace(le,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var de=e=>`validationError`in(e.response?.data?.details??{}),fe=e=>`applicationError`in(e.response?.data?.details??{}),pe=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function me(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(de(e))return he(e,t,n);if(fe(e))return ge(e);if(pe(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:w(n),data:{}},requestId:e.requestId};return E(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return _e(e)}var he=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=ve(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return E(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},E=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),ge=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??w(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return E(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},_e=e=>E(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:w(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),ve=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:ye(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,ye(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},ye=(e,t)=>{let n=be(e);return n==null?e:e.replace(`$[${n}]`,t[n])},be=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function xe(e,t,n,r,i,a,o,s,c,l,u){return ae(()=>e({request:async e=>{let i=e({host:s?.HTTPHost||`www.wixapis.com`}),a=i;a.method===`GET`&&a.fallback?.length&&(a.params?.toString().length??0)>4e3&&(a=i.fallback[0]);let o=s?.HTTPHost??`www.wixapis.com`,u=`https://${l?y:o}${a.url}`;a.params&&a.params.toString()&&(u+=`?${a.params.toString()}`);try{let e=re(i,t,c),o={method:a.method,...a.data&&{body:JSON.stringify(a.data)},headers:{...e}},s=await n(u,o);if(s.status!==200){let e=null;try{e=await s.json()}catch{}let t=Ce(s.status,e?.message??s.statusText,e?.details,{requestId:s.headers.get(`X-Wix-Request-Id`),details:e}),n=me(t);throw r?.handleError(n,{requestOptions:{url:a.url,method:a.method,entityFqdn:i.entityFqdn,methodFqn:i.methodFqn}}),t}let l=await s.json();return{data:a.migrationOptions?.optInTransformResponse&&a.transformResponse?Array.isArray(a.transformResponse)?a.transformResponse[0](l):a.transformResponse(l):l,headers:s.headers,status:s.status,statusText:s.statusText}}catch(e){throw e.message?.includes(`fetch is not defined`)&&console.error(`Node.js v18+ is required`),e}},fetchWithAuth:n,wixAPIFetch:i,getActiveToken:a,getAuthHeaders:o},{validateRequestSchema:u}))}var Se=class extends Error{response;requestId;constructor(e){super(),this.response=e.response,this.requestId=e.requestId}},Ce=(e,t,n,r)=>new Se({response:{data:{details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t},status:e},requestId:r?.requestId}),we=`.`;function Te(e,t,n){if(e==null)throw Error(`Cannot set value on null or undefined`);let r=D(t),i=e;for(let e=0;e<r.length;e++){let t=r[e];if(e===r.length-1){i[t]=n;break}let a=r[e+1];(!(t in i)||i[t]==null||typeof i[t]!=`object`||i[t]===null)&&(i[t]=typeof a==`number`?[]:{}),i=i[t]}return e}function D(e){return Array.isArray(e)?e:e.split(we).map(e=>Ee(e)?Number(e):e)}function Ee(e){return/^\d+$/.test(e)}function De(e){let t={};for(let[n,r]of Object.entries(e))Oe(n)||Te(t,D(n),r);return t}function Oe(e){return e===`__proto__`||e===`constructor`||e===`prototype`}var ke=class{BRACKET_PATTERN=/\[(\d+)\]/g;NUMERIC_PATTERN=/^\d+$/;ESCAPED_DOT_PATTERN=/\\\./g;ESCAPED_LEFT_BRACKET_PATTERN=/\\\[/g;ESCAPED_RIGHT_BRACKET_PATTERN=/\\\]/g;SPLIT_PATTERN=/\.|\[(\d+)\]/g;DOT_BEFORE_BRACKET_PATTERN=/\.\[/g;ESCAPED_DOT_PLACEHOLDER=`__DOT__`;ESCAPED_RIGHT_BRACKET_PLACEHOLDER=`__RB__`;ESCAPED_LEFT_BRACKET_PLACEHOLDER=`__LB__`;modifiedFields;cleanedModifiedFields;constructor(e){this.modifiedFields=e}replaceEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PATTERN,this.ESCAPED_DOT_PLACEHOLDER).replace(this.ESCAPED_LEFT_BRACKET_PATTERN,this.ESCAPED_LEFT_BRACKET_PLACEHOLDER).replace(this.ESCAPED_RIGHT_BRACKET_PATTERN,this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER)}restoreEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PLACEHOLDER,`\\.`).replace(this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER,`\\]`).replace(this.ESCAPED_LEFT_BRACKET_PLACEHOLDER,`\\[`)}unflatten(){return this.cleanedModifiedFields=Object.fromEntries(Object.entries(this.modifiedFields).map(([e,t])=>[this.replaceEscapedCharacters(this.bracketToDotNotation(e)),t])),De(this.cleanedModifiedFields)}flatten(e){let t={};for(let n of Object.keys(this.cleanedModifiedFields)){let r=this.splitPath(n),i=this.navigatePath(e,r);t={...t,...i}}return Object.fromEntries(Object.entries(t).map(([e,t])=>[this.restoreEscapedCharacters(e),t]))}splitPath(e){let t=[],n=0,r=Array.from(e.matchAll(this.SPLIT_PATTERN));for(let i of r)i.index>n&&t.push(e.substring(n,i.index)),i[1]&&t.push(i[1]),n=i.index+i[0].length;return n<e.length&&t.push(e.substring(n)),t}navigatePath(e,t){let n=e,r=[],i=e=>{if(!Array.isArray(n))throw Error(`Expected array at path ${this.buildPathString(r)}, but got ${typeof n}`);r.push(`[${e}]`),n=n[parseInt(e,10)]},a=(e,t)=>{let i=e in oe?oe[e]:void 0;if(i&&i in t){r.push(i),n=t[i];return}let a=Ne(e);if(a&&a in t){r.push(a),n=t[a];return}throw Error(`Cannot find key '${e}' or its transformations at path ${this.buildPathString(r)}`)},o=(e,t)=>{r.push(e),n=t[e]};for(let e of t){if(this.NUMERIC_PATTERN.test(e)){i(e);continue}if(typeof n!=`object`||!n)throw Error(`Cannot access property '${e}' on ${typeof n} at path ${this.buildPathString(r)}`);let t=n;if(e in n){o(e,t);continue}a(e,t)}return{[this.buildPathString(r)]:n}}buildPathString(e){return e.join(`.`).replace(this.DOT_BEFORE_BRACKET_PATTERN,`[`)}bracketToDotNotation(e){return e.replace(this.BRACKET_PATTERN,(t,n,r)=>r>0&&e[r-1]===`\\`?t:`.`+n)}};function Ae(e,t){let n=e?.modifiedFields;if(!n)return null;let r=je(n);if(!r)return null;let{unflattenedModifiedFields:i,modifiedFieldsManipulator:a}=r;e={...e,modifiedFields:i};let o=t(e),s=o?.modifiedFields;if(!s)return null;let c=Me(s,a);return c===null?null:(o.modifiedFields=c,o)}function je(e){if(typeof e==`object`&&e&&!Array.isArray(e))try{let t=new ke(e);return{unflattenedModifiedFields:t.unflatten(),modifiedFieldsManipulator:t}}catch{return null}return null}function Me(e,t){if(typeof e==`object`&&e&&!Array.isArray(e))try{return t.flatten(e)}catch{return null}return null}function Ne(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^./,e=>e.toLowerCase())}function O(){return{emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n<i;n++)r[n](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(e=>t!==e)}}}}var Pe=e=>e.__type===`event-definition`;function Fe(e,t,n,r){let i;if(e.isDomainEvent){let{deletedEvent:e,actionEvent:t,createdEvent:a,updatedEvent:o,...s}=n,c={...r,...s};i=e?e?.deletedEntity?{entity:e?.deletedEntity,metadata:c}:{metadata:c}:t?{data:t.body,metadata:c}:o?{entity:o.currentEntity,metadata:c,...o.modifiedFields?{modifiedFields:o.modifiedFields}:{}}:{entity:a?.entity,metadata:c}}else i={data:n,metadata:r};let a=e.transformations??(e=>e),o=i,s=i;if(s.modifiedFields){let e=s.modifiedFields;if(typeof e==`object`&&e&&!Array.isArray(e)){o=structuredClone(i);let e=Ae(s,a);if(e)return t(e)}}return t(a(o))}function Ie(e){let t=new Map,n=O();return{initModule(e){return r=>{let i=t.get(e.type)??[];i.push({eventDefinition:e,handler:r}),t.set(e.type,i),n.emit(`registered`,e)}},client:{...n,getRegisteredEvents:()=>t,async process(e,n={expectedEvents:[]}){let{eventType:r,identity:i,instanceId:a,payload:o,accountInfo:s}=await this.parseJWT(e),c=[...n.expectedEvents,...Array.from(t.keys()).map(e=>({type:e}))];if(c.length>0&&!c.some(({type:e})=>e===r))throw Error(`Unexpected event type: ${r}. Expected one of: ${c.map(e=>e.type).join(`, `)}`);let l=t.get(r)??[];return await Promise.all(l.map(({eventDefinition:e,handler:t})=>Fe(e,t,o,{instanceId:a,identity:i,accountInfo:s}))),{instanceId:a,eventType:r,payload:o,identity:i,accountInfo:s}},async processRequest(e,t){let n=await e.text();return this.process(n,t)},async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`string`)throw Error(`Unexpected type of JWT data: expected string, got ${typeof r.data}`);let a=JSON.parse(r.data),o=a.eventType,s=a.accountInfo,c=a.instanceId,l=a.identity?JSON.parse(a.identity):void 0;return{instanceId:c,eventType:o,payload:JSON.parse(a.data),identity:l,accountInfo:s}},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async executeHandlers(e){let n=Array.from(t.keys()).map(e=>({type:e}));if(n.length>0&&!n.some(({type:t})=>t===e.eventType))throw Error(`Unexpected event type: ${e.eventType}. Expected one of: ${n.map(e=>e.type).join(`, `)}`);let r=t.get(e.eventType)??[];await Promise.all(r.map(({eventDefinition:t,handler:n})=>Fe(t,n,e.payload,{instanceId:e.instanceId,identity:e.identity})))},apps:{AppInstalled:m(`AppInstalled`)(),AppRemoved:m(`AppRemoved`)()}}}}var Le=e=>e.__type===`service-plugin-definition`;function Re(e){let t=new Map,n=O();return{initModule(e){return r=>{let i=t.get(e.componentType.toLowerCase())??[];i.push({servicePluginDefinition:e,implementation:r}),t.set(e.componentType.toLowerCase(),i),n.emit(`registered`,e)}},client:{...n,getRegisteredServicePlugins:()=>t,async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t,!0);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`object`||r.data===null||!(`metadata`in r.data)||typeof r.data.metadata!=`object`||r.data.metadata===null||!(`appExtensionType`in r.data.metadata)||typeof r.data.metadata.appExtensionType!=`string`)throw Error(`Unexpected JWT data: expected object with metadata.appExtensionType string`);return r.data},async process(e){let t=await this.parseJWT(e.body);return this.executeHandler(t,e.url)},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async processRequest(e){let t=await this.parseRequest(e);return this.processParsedRequest(t,e.url)},async processParsedRequest(e,t){try{let n=await this.executeHandler(e,t);return Response.json(n)}catch(e){if(e.errorType===`SPI`&&e.applicationCode&&e.httpCode)return Response.json({applicationError:{code:e.applicationCode,data:e.data}},{status:e.httpCode});throw e}},async executeHandler(e,n){let r=e.metadata.appExtensionType.toLowerCase(),i=t.get(r)??[];if(i.length===0)throw Error(`No service plugin implementations found for component type ${r}`);if(i.length>1)throw Error(`Multiple service plugin implementations found for component type ${r}. This is currently not supported`);let{implementation:a,servicePluginDefinition:o}=i[0],s=o.methods.find(e=>n.endsWith(e.primaryHttpMappingPath));if(!s)throw Error(`Unexpect request: request url did not match any method: `+n);let c=a[s.name];if(!c)throw Error(`Got request for service plugin method ${s.name} but no implementation was provided. Available methods: ${Object.keys(a).join(`, `)}`);return s.transformations.toREST(await c(s.transformations.fromREST(e)))}}}}var k=`X-Wix-Consistent`;function ze(e){let t=e.headers||{Authorization:``},n={getAuthHeaders:e=>Promise.resolve({headers:{}})},r=e.auth,i=typeof r==`function`?r:()=>r??n,a=()=>i().getAuthHeaders(e.host),o=()=>e.fetch??fetch,s=async(n,r)=>{let i=o(),s=await a(),c={...r?.headers??{},...s.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[k]:t[k]}:{}},l=e.host?.getErrorHandler?.();try{if(typeof n==`string`||n instanceof URL){let e=await i(n,{...r,headers:c});l?.handleError(e,{requestOptions:{url:n.toString(),method:r?.method}});let a=A(e);return a&&(t[k]=a),e}{for(let[e,t]of Object.entries(c))typeof t==`string`&&n.headers.set(e,t);let e=await i(n,r);l?.handleError(e,{requestOptions:{url:n.url,method:r?.method}});let a=A(e);return a&&(t[k]=a),e}}catch(e){throw l?.handleError(e,{requestOptions:{url:typeof n==`string`||n instanceof URL?n.toString():n.url,method:r?.method}}),e}},{client:c,initModule:l}=Re(i),{client:u,initModule:d}=Ie(i),f=async(n,r)=>{let i=o(),s=await a(),c=S(r),l=await i(n,{...r,headers:{...c,...t,...s?.headers,...r?.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[k]:t[k]}:{}}}),u=A(l);return u&&(t[k]=u),l},m=(t,n)=>{if(Pe(t))return d(t);if(Le(t))return l(t);if(ee(t)&&e.host)return te(t,e.host);if(typeof t==`function`){if(`__type`in t&&t.__type===`wix_spi_error`)return t;let r=e.host?.apiBaseUrl??`www.wixapis.com`,o=e.useCDN===void 0?i().shouldUseCDN:e.useCDN;return xe(ae(()=>_(t))?g(t):t,n??{},f,e.host?.getErrorHandler?.(),(e,t)=>{let n=new URL(e,`https://${r}`);return n.host=r,n.protocol=`https`,f(n.toString(),t)},i().getActiveToken,async()=>a(),{HTTPHost:r},e.host?.name,o,e.validateRequestSchema)}return C(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,m(n,t[v])])):t},h=e=>{for(let n in e)t[n]=e[n]};return{...e.modules?m(e.modules):{},get auth(){let t=i();return t.getAuthHeaders=t.getAuthHeaders.bind(void 0,e.host),t},setHeaders:h,use:m,enableContext(e,t={elevated:!1}){e===`global`?globalThis.__wix_context__==null?t.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:t.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:t.elevated?p.elevatedClient=this:p.client=this},fetch:(t,n)=>{let r=e.host?.apiBaseUrl??`www.wixapis.com`,i=new URL(t,`https://${r}`);return i.host=r,i.protocol=`https`,f(i.toString(),n)},fetchWithAuth:s,async graphql(t,n,r={apiVersion:`alpha`}){let i=e?.host?.apiBaseUrl??`www.wixapis.com`,a=await f(`https://${i}/graphql/${r.apiVersion}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:t,variables:n})});if(a.status!==200)throw new b(`GraphQL request failed with status ${a.status}`,a);let{data:o,errors:s}=await a.json();return{data:o??{},errors:s}},webhooks:u,servicePlugins:c}}function A(e){return e.headers?.get(`X-Wix-Consistent`)??e.headers?.get(`x-wix-consistent`)}var Be={_id:`id`,_createdDate:`createdDate`,_updatedDate:`updatedDate`},Ve={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function He(e,t){return e?.split(`.`).map(e=>t?.[e]??e).join(`.`)}var j=`sort.fieldName`;function Ue(e,t,n){return(e===j||e.endsWith(`.${j}`))&&typeof t==`string`?He(t,n):t}function M(e,t,n){let r=e=>n.includes(e),i=(e,n)=>{if(Array.isArray(e))e.forEach(e=>{i(e,n)});else if(typeof e==`object`&&e){let a=e;Object.keys(a).forEach(e=>{let o=n===``?e:`${n}.${e}`;if(r(o))return;let s=We(e,t);s!==e&&!(s in a)&&(a[s]=a[e],delete a[e]),a[s]=Ue(o,a[s],t),i(a[s],o)})}};return i(e,``),e}function We(e,t){let n;return n=e.includes(`.`)?e.split(`.`).map(e=>t[e]??e).join(`.`):t[e]??e,n}function Ge(e,t=[]){return M(e,Be,t)}function Ke(e,t=[]){return M(e,Ve,t)}function N(e){return Xe(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var qe=/([\p{Ll}\d])(\p{Lu})/gu,Je=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,P=`$1\0$2`,Ye=/[^\p{L}\d]+/giu;function Xe(e){let t=e.trim();t=t.replace(qe,P).replace(Je,P),t=t.replace(Ye,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var Ze=e=>`validationError`in(e.response?.data?.details??{}),Qe=e=>`applicationError`in(e.response?.data?.details??{}),$e=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function et(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(Ze(e))return tt(e,t,n);if(Qe(e))return nt(e);if($e(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:N(n),data:{}},requestId:e.requestId};return F(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return rt(e)}var tt=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=it(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return F(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},F=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),nt=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??N(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return F(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},rt=e=>F(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:N(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),it=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:at(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,at(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},at=(e,t)=>{let n=ot(e);return n==null?e:e.replace(`$[${n}]`,t[n])},ot=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function st(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return I(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw Error(`An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules`);return I(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return I(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function I(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function ct(e,t){return((...n)=>{let r=st();return r?r.initWixModules(e,t).apply(void 0,n):e.apply(void 0,n)})}function lt(e,t=!1){return ct(e,t)}function ut(e){let t=Ct(xt(e.host),e.domainToMappings);return Mt(kt(e.protoPath,e.data||{}),t)}var dt=[`wix.com`,`editorx.com`],ft=`_`,pt=`*.`,mt=RegExp(`\\.(${dt.join(`|`)})$`),ht=[`42.wixprod.net`,`uw2-edt-1.wixprod.net`,`virginia-edt.wixprod.net`],gt={"payments.base44.com":`manage.wix.com`,"create.editorx.com":`editor.editorx.com`},_t=`dev.wix-code.com`,vt=/{(.*)}/,yt=RegExp(`\\.(${ht.join(`|`)})$`),bt=RegExp(`.*\\.${_t}$`);function xt(e){return St(e).replace(mt,`._base_domain_`).replace(yt,`._api_base_domain_`).replace(bt,`*.dev.wix-code.com`)}function St(e){return gt[e]??e}function Ct(e,t){let n=t[e];if(n)return n;let r=wt(e,t)??Tt(e,t);if(!r){if(Dt(e)){let e=t[Ot];if(e)return e}let n=t[ft];if(n)return n}return r??[]}function wt(e,t){return Object.entries(t).find(([t])=>{let[,...n]=e.split(`.`);return n.join(`.`)===t})?.[1]}function Tt(e,t){let[n]=Object.entries(t).filter(([t])=>Et(e,t)).sort(([e],[t])=>t.length-e.length);if(!n)return;let[,r]=n;return r}function Et(e,t){if(!t.startsWith(pt))return!1;let n=t.slice(1);return e.length>n.length&&e.endsWith(n)}function Dt(e){return!!e.match(/\._base_domain_$/)}var Ot=`www._base_domain_`;function kt(e,t){return e.split(`/`).map(e=>At(e,t)).join(`/`)}function At(e,t){let n=e.match(vt)||[],r=n[1];return r?jt(t,r,e,e.replace(n[0],``)):e}function jt(e,t,n,r){let i=e;for(let e of t.split(`.`)){if(!i)return n;i=i[e]}return`${i}${r}`}function Mt(e,t){let n=t?.find(t=>e.startsWith(t.destPath));return n?n.srcPath+e.slice(n.destPath.length):e}var Nt=`x-wix-linguist`,Pt=`00000000-0000-0000-0000-000000000000`,Ft=`false`,It=()=>{let e=L(`language`),t=L(`locale`);if(e)return{[Nt]:[e,t||e,Ft,Pt].join(`|`)}};function Lt(){let e=null,t=null;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var L=e=>typeof window<`u`?window.commonConfig?.[e]:void 0,Rt=({createHost:e})=>({__type:`host`,create:e=>({}),host:t=>{let{applicationId:n,componentId:r}=t??{},i=typeof window<`u`?window.wixEmbedsAPI:void 0,a=e(t),o=Bt();return{...a,apiBaseUrl:o,getMonitoringClient:i?.getMonitoringClientFunction?.(n,r),essentials:{language:L(`language`),locale:L(`locale`),get passThroughHeaders(){return It()}}}},auth:e=>{let t=typeof window<`u`?window.wixEmbedsAPI:void 0;!e&&zt()&&(e=t?.getAccessTokenFunction?.());let n=!1,{resolve:r,promise:i}=Lt();return{getAuthHeaders:async()=>{if(!e&&n&&(e=await i),!e)throw Error(`Failed to resolve auth token`);return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(n=!0,e=>{r(e)})}}});function zt(){return typeof document<`u`&&document.currentScript?.tagName===`SCRIPT`}function Bt(){let e=(typeof window<`u`?window.wixEmbedsAPI:void 0)?.getExternalBaseUrl?.();if(!e)return;let t=new URL(e);return t?.pathname&&t.pathname!==`/`?`${t.hostname}${t.pathname}`:t.hostname}var Vt=({clientSdk:e,applicationId:t})=>({invoke:async({namespace:n,method:r,args:i})=>{if(!e)throw Error(`Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction`);return e.invoke({namespace:n,method:r,args:i,applicationId:t,accessToken:`accessToken`})},getAccessToken:()=>{throw Error(`Not implemented`)},observeState:()=>({disconnect:()=>{}})}),R=Rt({createHost:function(e){let t=(typeof $wixContext<`u`?$wixContext.clientSdk:void 0)??e?.clientSdk??(typeof window<`u`?window?.clientSdk:void 0),{applicationId:n}=e||{};if(!n)throw Error(`"createHost" was called without a required field "applicationId"`);return{channel:Vt({clientSdk:t,applicationId:n}),close:()=>{}}}}),Ht=((e,t)=>{let n=R.host({applicationId:e,componentId:t}),r=R.auth();return ze({auth:r,host:n}).enableContext(`module`),r.getAccessTokenInjector()})(`13d21c63-b5ec-5912-8397-c3a5ddb27a97`);function Ut(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return z(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw Error(`An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules`);return z(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return z(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function z(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function Wt(e,t){return{...e,...Object.fromEntries(t.map(t=>[t,(...n)=>{let r=Ut();if(!r)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return r.initWixModules(e)[t].apply(void 0,n)}]))}}function Gt(e){return Wt({__type:`host`,create:t=>Object.entries(e).reduce((e,[n,r])=>({...e,[n]:r(t)}),{})},Object.keys(e))}var Kt=class{constructor(e){this.message=e,this.captureException=()=>{console.error(this.message)},this.captureMessage=()=>{console.error(this.message)},this.startSpan=(e,t)=>(console.error(this.message),t(void 0)),this.startSpanManual=()=>(console.error(this.message),{end:()=>{},fail:()=>{}}),this.endSpanManual=()=>{console.error(this.message)},this.addBreadcrumb=()=>{console.error(this.message)}}},qt=e=>new Kt(e),Jt=Gt({getMonitoringClient:e=>()=>e.getMonitoringClient?e.getMonitoringClient():qt(`Host monitoring client is not available on the current host. Make sure to use an updated version of the host initialization package.`)}),B={service:`service`,services:`services`,categories:`categories`,locations:`locations`,sessions:`sessions`,timeSlots:`time-slots`,serviceAddOns:`service-addons`,bookingsSettings:`bookings-settings`,serviceCta:`service-cta`,preferences:`preferences`,bookingSummary:`booking-summary`,bookingCheckout:`booking-checkout`,formValues:`form-values`,paymentOptions:`payment-options`,seo:`seo`,warmup:`warmup`,reschedule:`reschedule`};function V(e){try{let t=Jt.getMonitoringClient?.();return t&&typeof t[e]==`function`?t:null}catch{return null}}function H(e,{feature:t,action:n,level:r=`error`,contexts:i}){let a=V(`captureException`);if(!a)return;let o=e instanceof Error?e:Error(String(e));a.captureException(o,{level:r,tags:{feature:t,action:n},...i?{contexts:i}:{}})}function Yt(e,{feature:t,tags:n},r){let i=V(`startSpanManual`);if(!i)return r;let a=i.startSpanManual({name:e,tags:{feature:t,...n}});return r.then(()=>a.end(),e=>a.fail(e)),r}var Xt=class extends e{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){H(e,{feature:this.props.feature??`service`,action:`render`,contexts:{react:{componentStack:t.componentStack}}})}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Zt(e){let t=e;if(t.__state||(t.__state={status:`pending`},t.then(e=>{t.__state={status:`fulfilled`,value:e}},e=>{t.__state={status:`rejected`,reason:e}})),t.__state.status===`fulfilled`)return t.__state.value;throw t.__state.status===`rejected`?t.__state.reason:t}function U(e){let t=Promise.resolve(e);return t.__state={status:`fulfilled`,value:e},t}var W=new WeakMap;function Qt(e,t,n){let r=W.get(e);r||(r=new WeakMap,W.set(e,r));let i=r.get(t);i||(i=new WeakMap,r.set(t,i));let a=i.get(n);if(!a){let r=e;a=r.__state?.status===`fulfilled`?U(t(r.__state.value)):r.__state?.status===`rejected`?U(n(r.__state.reason)):e.then(t,n),i.set(n,a)}return a}function G(e){return e}var $t=G(`@wix/site-service-url`),K=`appSectionParams`;function q(e){let t=e.searchParams.get(K);if(t===null)return e;let n=new URL(e);n.searchParams.delete(K);for(let[e,r]of Object.entries(en(t)))typeof r==`string`&&!n.searchParams.has(e)&&n.searchParams.set(e,r);return n}function en(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}var J=`bookings-uou:url-change`,Y=e=>{let t=new URL(e);return t.searchParams.sort(),t.href};function tn(e,{disableScrollToTop:t,skipHistory:n}={}){let r=globalThis.window;if(!r?.history)return;let i=new URL(r.location.href);if(Y(i)===Y(e))return;let a={scrollY:r.scrollY};if(n)r.history.replaceState(a,``,e.href);else{r.history.replaceState(a,``,i.href);try{r.history.pushState(t?a:null,``,e.href)}catch{return}}r.dispatchEvent(new Event(J))}function nn(e){let t=globalThis.window;return t?(t.addEventListener(J,e),t.addEventListener(`popstate`,e),()=>{t.removeEventListener(J,e),t.removeEventListener(`popstate`,e)}):()=>{}}var rn=e=>{try{return decodeURIComponent(e)}catch{return e}};function an(e,t){let n=t?new URL(t).pathname:`/`;return`./${rn(new URL(e).pathname.replace(n,``).replace(/^\/|\/$/g,``))}`}function X(){let e=d($t),t=r(()=>e.currentUrl,[e]),n=l(nn,t,t),i=o(()=>q(new URL(n)),[n]),a=e.siteUrl.replace(/\/$/,``);return{pathname:i.pathname,search:i.search,searchParams:i.searchParams,href:i.href,getParsedUrl:()=>q(new URL(e.currentUrl)),getRelativeUrl:()=>an(e.currentUrl,a),getExternalBaseUrl:()=>a,pushUrl:tn}}var Z={category:`category`,location:`location`,page:`page`,blob:`b`,resource:`resource`,referral:`referral`,timezone:`timezone`,bookingId:`bookingId`,token:`token`,rescheduleRedirectUrl:`rescheduleRedirectUrl`},on=G(`@wix/site-service-warmup-data`);function sn(){try{return u()}catch{return null}}function cn(e){try{return e?e(on):null}catch{return null}}function ln(){let e=cn(sn()),t=typeof window>`u`;return{scope:e??void 0,get:async n=>{if(t||!e)return null;try{return await e.get(n)}catch(e){return H(e,{feature:B.warmup,action:`read`,level:`warning`,contexts:{warmup:{key:n}}}),null}},set:(n,r)=>{if(t&&e)try{e.set(n,r)}catch{}}}}var un=`bookings-uou`;function dn(){return`${un}:categories:all`}var fn=5e3,pn=100,mn=`wix-warmup-data`,Q=null;function hn(e){if(typeof document<`u`)try{let t=document.getElementById(mn)?.textContent;return t?(Q?.text!==t&&(Q={text:t,data:JSON.parse(t).builderComponentsWarmupData??{}}),Q.data[e]??void 0):void 0}catch{return}}var gn=()=>({promises:new Map,invalidatedWarmup:new Set}),_n=gn(),vn=new WeakMap,yn=new WeakMap;function bn(e){if(!e)return _n;let t=vn.get(e);return t||(t=gn(),vn.set(e,t)),t}function xn({key:e,warmupData:t,fetchData:n,refresh:r=!1}){if(e===null)return n();if(typeof window>`u`){let r=()=>n().then(n=>(t.set(e,n),n)),{scope:i}=t;if(!i)return r();let a=yn.get(i);a||(a=new Map,yn.set(i,a));let o=a.get(e);if(o)return o;let s=r();return a.set(e,s),s.catch(()=>a.delete(e)),s}let i=bn(t.scope),a=Date.now();for(let[e,t]of i.promises)t.expiresAt<=a&&i.promises.delete(e);let o=i.promises.get(e);if(o&&!r)return o.promise;r&&i.invalidatedWarmup.add(e);let s=!i.invalidatedWarmup.has(e);if(s){let t=hn(e);if(t!==void 0){let n=U(t);return i.promises.set(e,{promise:n,expiresAt:a+fn}),n}}let c=(async()=>{if(s){let n=await t.get(e);if(n!=null)return n}return n()})();i.promises.size>=pn&&i.promises.delete(i.promises.keys().next().value);let l={promise:c,expiresAt:1/0};return i.promises.set(e,l),c.then(()=>{l.expiresAt=Date.now()+fn},()=>{i.promises.get(e)===l&&i.promises.delete(e)}),c}function Sn(e){return ut(Object.assign(e,{domainToMappings:{"*.dev.wix-code.com":[{srcPath:`/_api/services-2`,destPath:``},{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www.wixapis.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`},{srcPath:`/bookings/services/v2/bulk/services`,destPath:`/v2/bulk/services`}],"manage._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"editor._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"blocks._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"create.editorx":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],_:[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"bo._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wixbo.ai":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wix-bo.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"editor.wixapps.net":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"api._api_base_domain_":[{srcPath:`/services-2`,destPath:``}]}}))}var Cn=`@wix/auto_sdk_bookings_services`;function wn(e){function t({host:t}){return{entityFqdn:`wix.bookings.services.v2.service`,method:`POST`,methodFqn:`wix.bookings.services.v2.ServicesService.QueryCategories`,packageName:Cn,migrationOptions:{optInTransformResponse:!0},url:Sn({protoPath:`/v2/services/categories/query`,data:e,host:t}),data:e}}return t}async function Tn(e){let{httpClient:t,sideEffects:n}=arguments[1],r=wn(Ge({filter:e?.filter}));n?.onSiteCall?.();try{let e=await t.request(r);return n?.onSuccess?.(e),Ke(e.data)}catch(e){let t=et(e,{spreadPathsToArguments:{},explicitPathsToArguments:{filter:`$[0].filter`},singleArgumentUnchanged:!1},[`options`]);throw n?.onError?.(e),t}}function En(e){return t=>Tn(t,{httpClient:e})}var Dn=lt(En);async function On(){return[...(await Dn({filter:{services:{}}})).categories??[]].sort((e,t)=>(e.sortOrder??0)-(t.sortOrder??0))}function kn({isLoading:e,hasError:t,refetch:n,children:r}){let{searchParams:i}=X(),a={categories:[],categoryItems:[],selectedCategoryId:i.get(Z.category),selectedCategoryIndex:-1,selectedCategory:null,selectedCategoryName:null,hasMultipleCategories:!1,isLoading:e,hasError:t,refetch:n,selectCategory:()=>{}};return f($.Provider,{value:a,children:r})}function An({refetch:e,children:t}){return f(kn,{isLoading:!0,hasError:!1,refetch:e,children:t})}function jn({refetch:e,children:t}){return f(kn,{isLoading:!1,hasError:!0,refetch:e,children:t})}function Mn(e){let t=e?.$in??(e?.$eq==null?[]:[e.$eq]);return[...new Set(t.filter(e=>typeof e==`string`&&e!==``))].sort().join(`,`)}function Nn(e){return e?e.split(`,`):null}var Pn=G(`@wix/site-service-business-logger`);function Fn(e){return{evid:32,src:16,endpoint:``,params:e}}var In=function(e){return e.BOOK_ONLINE=`bookingsBookOnline`,e.SERVICE_PAGE=`bookingsServicePage`,e.CALENDAR_PAGE=`bookingsCalendar`,e.FORM_PAGE=`bookingsForm`,e}({}),Ln={SERVICES:`services_context`,SERVICE:`service_context`,TIME_SLOTS:`time_slots_context`,BOOKING_CHECKOUT:`booking_checkout_context`,CATEGORIES:`categories_context`,LOCATIONS:`locations_context`,SERVICE_ADD_ONS:`service_addons_context`,PREFERENCES:`preferences_context`};In.BOOK_ONLINE;var Rn=`new_bookings_server`,zn=e=>{let{reportBi:t}=d(Pn);return r(n=>{t({widget_name:e,bookingsPlatform:Rn,is_over_editor:!1,...n.params,src:n.src,evid:n.evid},{endpoint:n.endpoint})},[t,e])},Bn=(e,t=!0)=>{let n=zn(e),{getParsedUrl:r}=X(),i=s(!1);a(()=>{t&&!i.current&&(i.current=!0,n(Fn({referralInfo:r().searchParams.get(Z.referral)??void 0})))},[t,n,r])},$=n(null),Vn=`useCategoriesContext must be used within CategoriesContextProvider`;function Hn(){let e=i($);if(!e)throw Error(Vn);return e}function Un(e,t){return{categoryId:e._id??null,categoryName:e.name??null,isSelected:e._id!=null&&e._id===t}}var Wn=e=>({categories:e,hasError:!1}),Gn=()=>({categories:[],hasError:!0});function Kn({categoriesPromise:e,initialCategoryId:t,categoryIdsKey:n,refetch:i,children:c}){let{categories:l,hasError:u}=Zt(e),d=o(()=>{let e=Nn(n);return e?l.filter(t=>t._id&&e.includes(t._id)):l},[l,n]),{pathname:p,searchParams:m,pushUrl:h,getExternalBaseUrl:g}=X(),_=m.get(Z.category),v=r(e=>{let t=new URLSearchParams(m);e?t.set(Z.category,e):t.delete(Z.category),t.delete(Z.page);let n=t.toString(),r=n?`${p}?${n}`:p;h(new URL(r,`${g()}/`),{disableScrollToTop:!0,skipHistory:!1})},[p,m,h,g]),y=s(!1);a(()=>{y.current||(y.current=!0,t&&!m.get(Z.category)&&v(t))},[t,m,v]);let b=d.findIndex(e=>e._id===_),x=d.find(e=>e._id===_)??null,S=d.filter(e=>e._id).length>1,C=o(()=>({categories:d,categoryItems:d.map(e=>Un(e,_)),selectedCategoryId:_,selectedCategoryIndex:b,selectedCategory:x,selectedCategoryName:x?.name??null,hasMultipleCategories:S,isLoading:!1,hasError:u,refetch:i,selectCategory:v}),[d,_,b,x,S,u,i,v]);return f($.Provider,{value:C,children:c})}function qn({initialCategoryId:e,categoriesPicker:n,refreshSignal:i=0,children:a}){Bn(Ln.CATEGORIES);let s=ln(),l=Mn(n?.categoryId),[u,d]=c(0),p=o(()=>Qt(xn({key:dn(),refresh:u!==0||i!==0,warmupData:s,fetchData:()=>Yt(`categories-context-load`,{feature:B.categories},On())}),Wn,Gn),[u,i]),m=r(()=>d(e=>e+1),[]);return f(Xt,{fallback:f(jn,{refetch:m,children:a}),feature:B.categories,children:f(t,{fallback:f(An,{refetch:m,children:a}),children:f(Kn,{categoriesPromise:p,initialCategoryId:e,categoryIdsKey:l,refetch:m,children:a})})})}var Jn=Ht;export{Vn as CATEGORIES_CONTEXT_MISSING_PROVIDER_ERROR,$ as categoriesContext,qn as default,Jn as injectAccessTokenGetter,Hn as useCategoriesContext};
|
|
1
|
+
import{Component as e,Suspense as t,createContext as n,useCallback as r,useContext as i,useEffect as a,useMemo as o,useRef as s,useState as c,useSyncExternalStore as l}from"react";import{useGetService as u,useService as d}from"@wix/services-manager-react";import{jsx as f}from"react/jsx-runtime";var p={};function m(e,t=!1,n=e=>e){return()=>({__type:`event-definition`,type:e,isDomainEvent:t,transformations:n})}var h=e=>{switch(e){case`get`:case`GET`:return`GET`;case`post`:case`POST`:return`POST`;case`put`:case`PUT`:return`PUT`;case`delete`:case`DELETE`:return`DELETE`;case`patch`:case`PATCH`:return`PATCH`;case`head`:case`HEAD`:return`HEAD`;case`options`:case`OPTIONS`:return`OPTIONS`;default:throw Error(`Unknown method: ${e}`)}},g=e=>t=>async n=>{let r,i=t=>{if(r=e(n)(t),r.url===void 0)throw Error(`Url was not successfully created for this request, please reach out to support channels for assistance.`);let{method:i,url:a,params:o}=r;return{...r,method:h(i),url:a,data:r.data,params:o}};try{let e=await t.request(i);if(r===void 0)throw Error(`Request options were not created for this request, please reach out to support channels for assistance.`);let n=Array.isArray(r.transformResponse)?r.transformResponse:[r.transformResponse],a=e.data;return n.forEach(t=>{t&&(a=t(e.data,e.headers))}),a}catch(e){throw typeof e==`object`&&e&&`response`in e&&typeof e.response==`object`&&e.response!==null&&`data`in e.response?e.response.data:e}},_=e=>e.__isAmbassador?!0:!!e().__isAmbassador,v=`__metadata`,y=`edge.wixapis.com`,b=class extends Error{message;response;constructor(e,t){super(e),this.message=e,this.response=t}async details(){let e=await this.response.json();return x(this.response.status,e?.message,e?.details,{requestId:this.response.headers.get(`X-Wix-Request-Id`),details:e})}},x=(e,t,n,r)=>({details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t,requestId:r?.requestId}),S=e=>e?.method&&[`post`,`put`,`patch`].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":`application/json`}:{},C=e=>e&&typeof e==`object`&&!Array.isArray(e),ee=e=>e.__type===`host`;function te(e,t){return e.create(t)}var ne=`x-wix-bi-gateway`;function re(e,t,n){return{[ne]:ie({environment:`js-sdk${n?`-${n}`:``}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function ie(e){return Object.entries(e).filter(([e,t])=>!!t).map(([e,t])=>`${e}=${t}`).join(`,`)}function ae(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}var oe={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function w(e){return ue(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var se=/([\p{Ll}\d])(\p{Lu})/gu,ce=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,T=`$1\0$2`,le=/[^\p{L}\d]+/giu;function ue(e){let t=e.trim();t=t.replace(se,T).replace(ce,T),t=t.replace(le,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var de=e=>`validationError`in(e.response?.data?.details??{}),fe=e=>`applicationError`in(e.response?.data?.details??{}),pe=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function me(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(de(e))return he(e,t,n);if(fe(e))return ge(e);if(pe(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:w(n),data:{}},requestId:e.requestId};return E(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return _e(e)}var he=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=ve(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return E(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},E=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),ge=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??w(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return E(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},_e=e=>E(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:w(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),ve=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:ye(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,ye(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},ye=(e,t)=>{let n=be(e);return n==null?e:e.replace(`$[${n}]`,t[n])},be=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function xe(e,t,n,r,i,a,o,s,c,l,u){return ae(()=>e({request:async e=>{let i=e({host:s?.HTTPHost||`www.wixapis.com`}),a=i;a.method===`GET`&&a.fallback?.length&&(a.params?.toString().length??0)>4e3&&(a=i.fallback[0]);let o=s?.HTTPHost??`www.wixapis.com`,u=`https://${l?y:o}${a.url}`;a.params&&a.params.toString()&&(u+=`?${a.params.toString()}`);try{let e=re(i,t,c),o={method:a.method,...a.data&&{body:JSON.stringify(a.data)},headers:{...e}},s=await n(u,o);if(s.status!==200){let e=null;try{e=await s.json()}catch{}let t=Ce(s.status,e?.message??s.statusText,e?.details,{requestId:s.headers.get(`X-Wix-Request-Id`),details:e}),n=me(t);throw r?.handleError(n,{requestOptions:{url:a.url,method:a.method,entityFqdn:i.entityFqdn,methodFqn:i.methodFqn}}),t}let l=await s.json();return{data:a.migrationOptions?.optInTransformResponse&&a.transformResponse?Array.isArray(a.transformResponse)?a.transformResponse[0](l):a.transformResponse(l):l,headers:s.headers,status:s.status,statusText:s.statusText}}catch(e){throw e.message?.includes(`fetch is not defined`)&&console.error(`Node.js v18+ is required`),e}},fetchWithAuth:n,wixAPIFetch:i,getActiveToken:a,getAuthHeaders:o},{validateRequestSchema:u}))}var Se=class extends Error{response;requestId;constructor(e){super(),this.response=e.response,this.requestId=e.requestId}},Ce=(e,t,n,r)=>new Se({response:{data:{details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t},status:e},requestId:r?.requestId}),we=`.`;function Te(e,t,n){if(e==null)throw Error(`Cannot set value on null or undefined`);let r=D(t),i=e;for(let e=0;e<r.length;e++){let t=r[e];if(e===r.length-1){i[t]=n;break}let a=r[e+1];(!(t in i)||i[t]==null||typeof i[t]!=`object`||i[t]===null)&&(i[t]=typeof a==`number`?[]:{}),i=i[t]}return e}function D(e){return Array.isArray(e)?e:e.split(we).map(e=>Ee(e)?Number(e):e)}function Ee(e){return/^\d+$/.test(e)}function De(e){let t={};for(let[n,r]of Object.entries(e))Oe(n)||Te(t,D(n),r);return t}function Oe(e){return e===`__proto__`||e===`constructor`||e===`prototype`}var ke=class{BRACKET_PATTERN=/\[(\d+)\]/g;NUMERIC_PATTERN=/^\d+$/;ESCAPED_DOT_PATTERN=/\\\./g;ESCAPED_LEFT_BRACKET_PATTERN=/\\\[/g;ESCAPED_RIGHT_BRACKET_PATTERN=/\\\]/g;SPLIT_PATTERN=/\.|\[(\d+)\]/g;DOT_BEFORE_BRACKET_PATTERN=/\.\[/g;ESCAPED_DOT_PLACEHOLDER=`__DOT__`;ESCAPED_RIGHT_BRACKET_PLACEHOLDER=`__RB__`;ESCAPED_LEFT_BRACKET_PLACEHOLDER=`__LB__`;modifiedFields;cleanedModifiedFields;constructor(e){this.modifiedFields=e}replaceEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PATTERN,this.ESCAPED_DOT_PLACEHOLDER).replace(this.ESCAPED_LEFT_BRACKET_PATTERN,this.ESCAPED_LEFT_BRACKET_PLACEHOLDER).replace(this.ESCAPED_RIGHT_BRACKET_PATTERN,this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER)}restoreEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PLACEHOLDER,`\\.`).replace(this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER,`\\]`).replace(this.ESCAPED_LEFT_BRACKET_PLACEHOLDER,`\\[`)}unflatten(){return this.cleanedModifiedFields=Object.fromEntries(Object.entries(this.modifiedFields).map(([e,t])=>[this.replaceEscapedCharacters(this.bracketToDotNotation(e)),t])),De(this.cleanedModifiedFields)}flatten(e){let t={};for(let n of Object.keys(this.cleanedModifiedFields)){let r=this.splitPath(n),i=this.navigatePath(e,r);t={...t,...i}}return Object.fromEntries(Object.entries(t).map(([e,t])=>[this.restoreEscapedCharacters(e),t]))}splitPath(e){let t=[],n=0,r=Array.from(e.matchAll(this.SPLIT_PATTERN));for(let i of r)i.index>n&&t.push(e.substring(n,i.index)),i[1]&&t.push(i[1]),n=i.index+i[0].length;return n<e.length&&t.push(e.substring(n)),t}navigatePath(e,t){let n=e,r=[],i=e=>{if(!Array.isArray(n))throw Error(`Expected array at path ${this.buildPathString(r)}, but got ${typeof n}`);r.push(`[${e}]`),n=n[parseInt(e,10)]},a=(e,t)=>{let i=e in oe?oe[e]:void 0;if(i&&i in t){r.push(i),n=t[i];return}let a=Ne(e);if(a&&a in t){r.push(a),n=t[a];return}throw Error(`Cannot find key '${e}' or its transformations at path ${this.buildPathString(r)}`)},o=(e,t)=>{r.push(e),n=t[e]};for(let e of t){if(this.NUMERIC_PATTERN.test(e)){i(e);continue}if(typeof n!=`object`||!n)throw Error(`Cannot access property '${e}' on ${typeof n} at path ${this.buildPathString(r)}`);let t=n;if(e in n){o(e,t);continue}a(e,t)}return{[this.buildPathString(r)]:n}}buildPathString(e){return e.join(`.`).replace(this.DOT_BEFORE_BRACKET_PATTERN,`[`)}bracketToDotNotation(e){return e.replace(this.BRACKET_PATTERN,(t,n,r)=>r>0&&e[r-1]===`\\`?t:`.`+n)}};function Ae(e,t){let n=e?.modifiedFields;if(!n)return null;let r=je(n);if(!r)return null;let{unflattenedModifiedFields:i,modifiedFieldsManipulator:a}=r;e={...e,modifiedFields:i};let o=t(e),s=o?.modifiedFields;if(!s)return null;let c=Me(s,a);return c===null?null:(o.modifiedFields=c,o)}function je(e){if(typeof e==`object`&&e&&!Array.isArray(e))try{let t=new ke(e);return{unflattenedModifiedFields:t.unflatten(),modifiedFieldsManipulator:t}}catch{return null}return null}function Me(e,t){if(typeof e==`object`&&e&&!Array.isArray(e))try{return t.flatten(e)}catch{return null}return null}function Ne(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^./,e=>e.toLowerCase())}function O(){return{emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n<i;n++)r[n](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(e=>t!==e)}}}}var Pe=e=>e.__type===`event-definition`;function Fe(e,t,n,r){let i;if(e.isDomainEvent){let{deletedEvent:e,actionEvent:t,createdEvent:a,updatedEvent:o,...s}=n,c={...r,...s};i=e?e?.deletedEntity?{entity:e?.deletedEntity,metadata:c}:{metadata:c}:t?{data:t.body,metadata:c}:o?{entity:o.currentEntity,metadata:c,...o.modifiedFields?{modifiedFields:o.modifiedFields}:{}}:{entity:a?.entity,metadata:c}}else i={data:n,metadata:r};let a=e.transformations??(e=>e),o=i,s=i;if(s.modifiedFields){let e=s.modifiedFields;if(typeof e==`object`&&e&&!Array.isArray(e)){o=structuredClone(i);let e=Ae(s,a);if(e)return t(e)}}return t(a(o))}function Ie(e){let t=new Map,n=O();return{initModule(e){return r=>{let i=t.get(e.type)??[];i.push({eventDefinition:e,handler:r}),t.set(e.type,i),n.emit(`registered`,e)}},client:{...n,getRegisteredEvents:()=>t,async process(e,n={expectedEvents:[]}){let{eventType:r,identity:i,instanceId:a,payload:o,accountInfo:s}=await this.parseJWT(e),c=[...n.expectedEvents,...Array.from(t.keys()).map(e=>({type:e}))];if(c.length>0&&!c.some(({type:e})=>e===r))throw Error(`Unexpected event type: ${r}. Expected one of: ${c.map(e=>e.type).join(`, `)}`);let l=t.get(r)??[];return await Promise.all(l.map(({eventDefinition:e,handler:t})=>Fe(e,t,o,{instanceId:a,identity:i,accountInfo:s}))),{instanceId:a,eventType:r,payload:o,identity:i,accountInfo:s}},async processRequest(e,t){let n=await e.text();return this.process(n,t)},async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`string`)throw Error(`Unexpected type of JWT data: expected string, got ${typeof r.data}`);let a=JSON.parse(r.data),o=a.eventType,s=a.accountInfo,c=a.instanceId,l=a.identity?JSON.parse(a.identity):void 0;return{instanceId:c,eventType:o,payload:JSON.parse(a.data),identity:l,accountInfo:s}},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async executeHandlers(e){let n=Array.from(t.keys()).map(e=>({type:e}));if(n.length>0&&!n.some(({type:t})=>t===e.eventType))throw Error(`Unexpected event type: ${e.eventType}. Expected one of: ${n.map(e=>e.type).join(`, `)}`);let r=t.get(e.eventType)??[];await Promise.all(r.map(({eventDefinition:t,handler:n})=>Fe(t,n,e.payload,{instanceId:e.instanceId,identity:e.identity})))},apps:{AppInstalled:m(`AppInstalled`)(),AppRemoved:m(`AppRemoved`)()}}}}var Le=e=>e.__type===`service-plugin-definition`;function Re(e){let t=new Map,n=O();return{initModule(e){return r=>{let i=t.get(e.componentType.toLowerCase())??[];i.push({servicePluginDefinition:e,implementation:r}),t.set(e.componentType.toLowerCase(),i),n.emit(`registered`,e)}},client:{...n,getRegisteredServicePlugins:()=>t,async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t,!0);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`object`||r.data===null||!(`metadata`in r.data)||typeof r.data.metadata!=`object`||r.data.metadata===null||!(`appExtensionType`in r.data.metadata)||typeof r.data.metadata.appExtensionType!=`string`)throw Error(`Unexpected JWT data: expected object with metadata.appExtensionType string`);return r.data},async process(e){let t=await this.parseJWT(e.body);return this.executeHandler(t,e.url)},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async processRequest(e){let t=await this.parseRequest(e);return this.processParsedRequest(t,e.url)},async processParsedRequest(e,t){try{let n=await this.executeHandler(e,t);return Response.json(n)}catch(e){if(e.errorType===`SPI`&&e.applicationCode&&e.httpCode)return Response.json({applicationError:{code:e.applicationCode,data:e.data}},{status:e.httpCode});throw e}},async executeHandler(e,n){let r=e.metadata.appExtensionType.toLowerCase(),i=t.get(r)??[];if(i.length===0)throw Error(`No service plugin implementations found for component type ${r}`);if(i.length>1)throw Error(`Multiple service plugin implementations found for component type ${r}. This is currently not supported`);let{implementation:a,servicePluginDefinition:o}=i[0],s=o.methods.find(e=>n.endsWith(e.primaryHttpMappingPath));if(!s)throw Error(`Unexpect request: request url did not match any method: `+n);let c=a[s.name];if(!c)throw Error(`Got request for service plugin method ${s.name} but no implementation was provided. Available methods: ${Object.keys(a).join(`, `)}`);return s.transformations.toREST(await c(s.transformations.fromREST(e)))}}}}var k=`X-Wix-Consistent`;function ze(e){let t=e.headers||{Authorization:``},n={getAuthHeaders:e=>Promise.resolve({headers:{}})},r=e.auth,i=typeof r==`function`?r:()=>r??n,a=()=>i().getAuthHeaders(e.host),o=()=>e.fetch??fetch,s=async(n,r)=>{let i=o(),s=await a(),c={...r?.headers??{},...s.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[k]:t[k]}:{}},l=e.host?.getErrorHandler?.();try{if(typeof n==`string`||n instanceof URL){let e=await i(n,{...r,headers:c});l?.handleError(e,{requestOptions:{url:n.toString(),method:r?.method}});let a=A(e);return a&&(t[k]=a),e}{for(let[e,t]of Object.entries(c))typeof t==`string`&&n.headers.set(e,t);let e=await i(n,r);l?.handleError(e,{requestOptions:{url:n.url,method:r?.method}});let a=A(e);return a&&(t[k]=a),e}}catch(e){throw l?.handleError(e,{requestOptions:{url:typeof n==`string`||n instanceof URL?n.toString():n.url,method:r?.method}}),e}},{client:c,initModule:l}=Re(i),{client:u,initModule:d}=Ie(i),f=async(n,r)=>{let i=o(),s=await a(),c=S(r),l=await i(n,{...r,headers:{...c,...t,...s?.headers,...r?.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[k]:t[k]}:{}}}),u=A(l);return u&&(t[k]=u),l},m=(t,n)=>{if(Pe(t))return d(t);if(Le(t))return l(t);if(ee(t)&&e.host)return te(t,e.host);if(typeof t==`function`){if(`__type`in t&&t.__type===`wix_spi_error`)return t;let r=e.host?.apiBaseUrl??`www.wixapis.com`,o=e.useCDN===void 0?i().shouldUseCDN:e.useCDN;return xe(ae(()=>_(t))?g(t):t,n??{},f,e.host?.getErrorHandler?.(),(e,t)=>{let n=new URL(e,`https://${r}`);return n.host=r,n.protocol=`https`,f(n.toString(),t)},i().getActiveToken,async()=>a(),{HTTPHost:r},e.host?.name,o,e.validateRequestSchema)}return C(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,m(n,t[v])])):t},h=e=>{for(let n in e)t[n]=e[n]};return{...e.modules?m(e.modules):{},get auth(){let t=i();return t.getAuthHeaders=t.getAuthHeaders.bind(void 0,e.host),t},setHeaders:h,use:m,enableContext(e,t={elevated:!1}){e===`global`?globalThis.__wix_context__==null?t.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:t.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:t.elevated?p.elevatedClient=this:p.client=this},fetch:(t,n)=>{let r=e.host?.apiBaseUrl??`www.wixapis.com`,i=new URL(t,`https://${r}`);return i.host=r,i.protocol=`https`,f(i.toString(),n)},fetchWithAuth:s,async graphql(t,n,r={apiVersion:`alpha`}){let i=e?.host?.apiBaseUrl??`www.wixapis.com`,a=await f(`https://${i}/graphql/${r.apiVersion}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:t,variables:n})});if(a.status!==200)throw new b(`GraphQL request failed with status ${a.status}`,a);let{data:o,errors:s}=await a.json();return{data:o??{},errors:s}},webhooks:u,servicePlugins:c}}function A(e){return e.headers?.get(`X-Wix-Consistent`)??e.headers?.get(`x-wix-consistent`)}var Be={_id:`id`,_createdDate:`createdDate`,_updatedDate:`updatedDate`},Ve={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function He(e,t){return e?.split(`.`).map(e=>t?.[e]??e).join(`.`)}var j=`sort.fieldName`;function Ue(e,t,n){return(e===j||e.endsWith(`.${j}`))&&typeof t==`string`?He(t,n):t}function M(e,t,n){let r=e=>n.includes(e),i=(e,n)=>{if(Array.isArray(e))e.forEach(e=>{i(e,n)});else if(typeof e==`object`&&e){let a=e;Object.keys(a).forEach(e=>{let o=n===``?e:`${n}.${e}`;if(r(o))return;let s=We(e,t);s!==e&&!(s in a)&&(a[s]=a[e],delete a[e]),a[s]=Ue(o,a[s],t),i(a[s],o)})}};return i(e,``),e}function We(e,t){let n;return n=e.includes(`.`)?e.split(`.`).map(e=>t[e]??e).join(`.`):t[e]??e,n}function Ge(e,t=[]){return M(e,Be,t)}function Ke(e,t=[]){return M(e,Ve,t)}function N(e){return Xe(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var qe=/([\p{Ll}\d])(\p{Lu})/gu,Je=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,P=`$1\0$2`,Ye=/[^\p{L}\d]+/giu;function Xe(e){let t=e.trim();t=t.replace(qe,P).replace(Je,P),t=t.replace(Ye,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var Ze=e=>`validationError`in(e.response?.data?.details??{}),Qe=e=>`applicationError`in(e.response?.data?.details??{}),$e=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function et(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(Ze(e))return tt(e,t,n);if(Qe(e))return nt(e);if($e(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:N(n),data:{}},requestId:e.requestId};return F(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return rt(e)}var tt=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=it(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return F(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},F=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),nt=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??N(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return F(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},rt=e=>F(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:N(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),it=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:at(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,at(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},at=(e,t)=>{let n=ot(e);return n==null?e:e.replace(`$[${n}]`,t[n])},ot=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function st(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return I(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw Error(`An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules`);return I(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return I(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function I(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function ct(e,t){return((...n)=>{let r=st();return r?r.initWixModules(e,t).apply(void 0,n):e.apply(void 0,n)})}function lt(e,t=!1){return ct(e,t)}function ut(e){let t=Ct(xt(e.host),e.domainToMappings);return Mt(kt(e.protoPath,e.data||{}),t)}var dt=[`wix.com`,`editorx.com`],ft=`_`,pt=`*.`,mt=RegExp(`\\.(${dt.join(`|`)})$`),ht=[`42.wixprod.net`,`uw2-edt-1.wixprod.net`,`virginia-edt.wixprod.net`],gt={"payments.base44.com":`manage.wix.com`,"create.editorx.com":`editor.editorx.com`},_t=`dev.wix-code.com`,vt=/{(.*)}/,yt=RegExp(`\\.(${ht.join(`|`)})$`),bt=RegExp(`.*\\.${_t}$`);function xt(e){return St(e).replace(mt,`._base_domain_`).replace(yt,`._api_base_domain_`).replace(bt,`*.dev.wix-code.com`)}function St(e){return gt[e]??e}function Ct(e,t){let n=t[e];if(n)return n;let r=wt(e,t)??Tt(e,t);if(!r){if(Dt(e)){let e=t[Ot];if(e)return e}let n=t[ft];if(n)return n}return r??[]}function wt(e,t){return Object.entries(t).find(([t])=>{let[,...n]=e.split(`.`);return n.join(`.`)===t})?.[1]}function Tt(e,t){let[n]=Object.entries(t).filter(([t])=>Et(e,t)).sort(([e],[t])=>t.length-e.length);if(!n)return;let[,r]=n;return r}function Et(e,t){if(!t.startsWith(pt))return!1;let n=t.slice(1);return e.length>n.length&&e.endsWith(n)}function Dt(e){return!!e.match(/\._base_domain_$/)}var Ot=`www._base_domain_`;function kt(e,t){return e.split(`/`).map(e=>At(e,t)).join(`/`)}function At(e,t){let n=e.match(vt)||[],r=n[1];return r?jt(t,r,e,e.replace(n[0],``)):e}function jt(e,t,n,r){let i=e;for(let e of t.split(`.`)){if(!i)return n;i=i[e]}return`${i}${r}`}function Mt(e,t){let n=t?.find(t=>e.startsWith(t.destPath));return n?n.srcPath+e.slice(n.destPath.length):e}var Nt=`x-wix-linguist`,Pt=`00000000-0000-0000-0000-000000000000`,Ft=`false`,It=()=>{let e=L(`language`),t=L(`locale`);if(e)return{[Nt]:[e,t||e,Ft,Pt].join(`|`)}};function Lt(){let e=null,t=null;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var Rt=()=>(typeof window<`u`?window.commonConfig:void 0)??globalThis.commonConfig,L=e=>Rt()?.[e],zt=({createHost:e})=>({__type:`host`,create:e=>({}),host:t=>{let{applicationId:n,componentId:r}=t??{},i=typeof window<`u`?window.wixEmbedsAPI:void 0,a=e(t),o=Vt();return{...a,apiBaseUrl:o,getMonitoringClient:i?.getMonitoringClientFunction?.(n,r),essentials:{language:L(`language`),locale:L(`locale`),get passThroughHeaders(){return It()}}}},auth:e=>{let t=typeof window<`u`?window.wixEmbedsAPI:void 0;!e&&Bt()&&(e=t?.getAccessTokenFunction?.());let n=!1,{resolve:r,promise:i}=Lt();return{getAuthHeaders:async()=>{if(!e&&n&&(e=await i),!e)throw Error(`Failed to resolve auth token`);return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(n=!0,e=>{r(e)})}}});function Bt(){return typeof document<`u`&&document.currentScript?.tagName===`SCRIPT`}function Vt(){let e=(typeof window<`u`?window.wixEmbedsAPI:void 0)?.getExternalBaseUrl?.();if(!e)return;let t=new URL(e);return t?.pathname&&t.pathname!==`/`?`${t.hostname}${t.pathname}`:t.hostname}var Ht=({clientSdk:e,applicationId:t})=>({invoke:async({namespace:n,method:r,args:i})=>{if(!e)throw Error(`Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction`);return e.invoke({namespace:n,method:r,args:i,applicationId:t,accessToken:`accessToken`})},getAccessToken:()=>{throw Error(`Not implemented`)},observeState:()=>({disconnect:()=>{}})}),R=zt({createHost:function(e){let t=(typeof $wixContext<`u`?$wixContext.clientSdk:void 0)??e?.clientSdk??(typeof window<`u`?window?.clientSdk:void 0),{applicationId:n}=e||{};if(!n)throw Error(`"createHost" was called without a required field "applicationId"`);return{channel:Ht({clientSdk:t,applicationId:n}),close:()=>{}}}}),Ut=(e,t)=>{let n=R.host({applicationId:e,componentId:t}),r=R.auth();return ze({auth:r,host:n}).enableContext(`module`),r.getAccessTokenInjector()},Wt=e=>Ut(`13d21c63-b5ec-5912-8397-c3a5ddb27a97`,e);function Gt(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return z(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw Error(`An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules`);return z(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return z(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function z(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function Kt(e,t){return{...e,...Object.fromEntries(t.map(t=>[t,(...n)=>{let r=Gt();if(!r)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return r.initWixModules(e)[t].apply(void 0,n)}]))}}function qt(e){return Kt({__type:`host`,create:t=>Object.entries(e).reduce((e,[n,r])=>({...e,[n]:r(t)}),{})},Object.keys(e))}var Jt=class{constructor(e){this.message=e,this.captureException=()=>{console.error(this.message)},this.captureMessage=()=>{console.error(this.message)},this.startSpan=(e,t)=>(console.error(this.message),t(void 0)),this.startSpanManual=()=>(console.error(this.message),{end:()=>{},fail:()=>{}}),this.endSpanManual=()=>{console.error(this.message)},this.addBreadcrumb=()=>{console.error(this.message)}}},Yt=e=>new Jt(e),Xt=qt({getMonitoringClient:e=>()=>e.getMonitoringClient?e.getMonitoringClient():Yt(`Host monitoring client is not available on the current host. Make sure to use an updated version of the host initialization package.`)}),B={service:`service`,services:`services`,categories:`categories`,locations:`locations`,sessions:`sessions`,timeSlots:`time-slots`,serviceAddOns:`service-addons`,bookingsSettings:`bookings-settings`,serviceCta:`service-cta`,preferences:`preferences`,bookingSummary:`booking-summary`,bookingCheckout:`booking-checkout`,formValues:`form-values`,paymentOptions:`payment-options`,seo:`seo`,warmup:`warmup`,reschedule:`reschedule`};function V(e){try{let t=Xt.getMonitoringClient?.();return t&&typeof t[e]==`function`?t:null}catch{return null}}function H(e,{feature:t,action:n,level:r=`error`,contexts:i}){let a=V(`captureException`);if(!a)return;let o=e instanceof Error?e:Error(String(e));a.captureException(o,{level:r,tags:{feature:t,action:n},...i?{contexts:i}:{}})}function Zt(e,{feature:t,tags:n},r){let i=V(`startSpanManual`);if(!i)return r;let a=i.startSpanManual({name:e,tags:{feature:t,...n}});return r.then(()=>a.end(),e=>a.fail(e)),r}var Qt=class extends e{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){H(e,{feature:this.props.feature??`service`,action:`render`,contexts:{react:{componentStack:t.componentStack}}})}render(){return this.state.hasError?this.props.fallback:this.props.children}};function $t(e){let t=e;if(t.__state||(t.__state={status:`pending`},t.then(e=>{t.__state={status:`fulfilled`,value:e}},e=>{t.__state={status:`rejected`,reason:e}})),t.__state.status===`fulfilled`)return t.__state.value;throw t.__state.status===`rejected`?t.__state.reason:t}function U(e){let t=Promise.resolve(e);return t.__state={status:`fulfilled`,value:e},t}var W=new WeakMap;function en(e,t,n){let r=W.get(e);r||(r=new WeakMap,W.set(e,r));let i=r.get(t);i||(i=new WeakMap,r.set(t,i));let a=i.get(n);if(!a){let r=e;a=r.__state?.status===`fulfilled`?U(t(r.__state.value)):r.__state?.status===`rejected`?U(n(r.__state.reason)):e.then(t,n),i.set(n,a)}return a}function G(e){return e}var tn=G(`@wix/site-service-url`),K=`appSectionParams`;function q(e){let t=e.searchParams.get(K);if(t===null)return e;let n=new URL(e);n.searchParams.delete(K);for(let[e,r]of Object.entries(nn(t)))typeof r==`string`&&!n.searchParams.has(e)&&n.searchParams.set(e,r);return n}function nn(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}var J=`bookings-uou:url-change`,Y=e=>{let t=new URL(e);return t.searchParams.sort(),t.href};function rn(e,{disableScrollToTop:t,skipHistory:n}={}){let r=globalThis.window;if(!r?.history)return;let i=new URL(r.location.href);if(Y(i)===Y(e))return;let a={scrollY:r.scrollY};if(n)r.history.replaceState(a,``,e.href);else{r.history.replaceState(a,``,i.href);try{r.history.pushState(t?a:null,``,e.href)}catch{return}}r.dispatchEvent(new Event(J))}function an(e){let t=globalThis.window;return t?(t.addEventListener(J,e),t.addEventListener(`popstate`,e),()=>{t.removeEventListener(J,e),t.removeEventListener(`popstate`,e)}):()=>{}}var on=e=>{try{return decodeURIComponent(e)}catch{return e}};function sn(e,t){let n=t?new URL(t).pathname:`/`;return`./${on(new URL(e).pathname.replace(n,``).replace(/^\/|\/$/g,``))}`}function X(){let e=d(tn),t=r(()=>e.currentUrl,[e]),n=l(an,t,t),i=o(()=>q(new URL(n)),[n]),a=e.siteUrl.replace(/\/$/,``);return{pathname:i.pathname,search:i.search,searchParams:i.searchParams,href:i.href,getParsedUrl:()=>q(new URL(e.currentUrl)),getRelativeUrl:()=>sn(e.currentUrl,a),getExternalBaseUrl:()=>a,pushUrl:rn}}var Z={category:`category`,location:`location`,page:`page`,blob:`b`,resource:`resource`,referral:`referral`,timezone:`timezone`,bookingId:`bookingId`,token:`token`,rescheduleRedirectUrl:`rescheduleRedirectUrl`},cn=G(`@wix/site-service-warmup-data`);function ln(){try{return u()}catch{return null}}function un(e){try{return e?e(cn):null}catch{return null}}function dn(){let e=un(ln()),t=typeof window>`u`;return{scope:e??void 0,get:async n=>{if(t||!e)return null;try{return await e.get(n)}catch(e){return H(e,{feature:B.warmup,action:`read`,level:`warning`,contexts:{warmup:{key:n}}}),null}},set:(n,r)=>{if(t&&e)try{e.set(n,r)}catch{}}}}var fn=`bookings-uou`;function pn(){return`${fn}:categories:all`}var mn=5e3,hn=100,gn=`wix-warmup-data`,Q=null;function _n(e){if(typeof document<`u`)try{let t=document.getElementById(gn)?.textContent;return t?(Q?.text!==t&&(Q={text:t,data:JSON.parse(t).builderComponentsWarmupData??{}}),Q.data[e]??void 0):void 0}catch{return}}var vn=()=>({promises:new Map,invalidatedWarmup:new Set}),yn=vn(),bn=new WeakMap,xn=new WeakMap;function Sn(e){if(!e)return yn;let t=bn.get(e);return t||(t=vn(),bn.set(e,t)),t}function Cn({key:e,warmupData:t,fetchData:n,refresh:r=!1}){if(e===null)return n();if(typeof window>`u`){let r=()=>n().then(n=>(t.set(e,n),n)),{scope:i}=t;if(!i)return r();let a=xn.get(i);a||(a=new Map,xn.set(i,a));let o=a.get(e);if(o)return o;let s=r();return a.set(e,s),s.catch(()=>a.delete(e)),s}let i=Sn(t.scope),a=Date.now();for(let[e,t]of i.promises)t.expiresAt<=a&&i.promises.delete(e);let o=i.promises.get(e);if(o&&!r)return o.promise;r&&i.invalidatedWarmup.add(e);let s=!i.invalidatedWarmup.has(e);if(s){let t=_n(e);if(t!==void 0){let n=U(t);return i.promises.set(e,{promise:n,expiresAt:a+mn}),n}}let c=(async()=>{if(s){let n=await t.get(e);if(n!=null)return n}return n()})();i.promises.size>=hn&&i.promises.delete(i.promises.keys().next().value);let l={promise:c,expiresAt:1/0};return i.promises.set(e,l),c.then(()=>{l.expiresAt=Date.now()+mn},()=>{i.promises.get(e)===l&&i.promises.delete(e)}),c}function wn(e){return ut(Object.assign(e,{domainToMappings:{"*.dev.wix-code.com":[{srcPath:`/_api/services-2`,destPath:``},{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www.wixapis.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`},{srcPath:`/bookings/services/v2/bulk/services`,destPath:`/v2/bulk/services`}],"manage._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"editor._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"blocks._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"create.editorx":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],_:[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"bo._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wixbo.ai":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wix-bo.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"editor.wixapps.net":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"api._api_base_domain_":[{srcPath:`/services-2`,destPath:``}]}}))}var Tn=`@wix/auto_sdk_bookings_services`;function En(e){function t({host:t}){return{entityFqdn:`wix.bookings.services.v2.service`,method:`POST`,methodFqn:`wix.bookings.services.v2.ServicesService.QueryCategories`,packageName:Tn,migrationOptions:{optInTransformResponse:!0},url:wn({protoPath:`/v2/services/categories/query`,data:e,host:t}),data:e}}return t}async function Dn(e){let{httpClient:t,sideEffects:n}=arguments[1],r=En(Ge({filter:e?.filter}));n?.onSiteCall?.();try{let e=await t.request(r);return n?.onSuccess?.(e),Ke(e.data)}catch(e){let t=et(e,{spreadPathsToArguments:{},explicitPathsToArguments:{filter:`$[0].filter`},singleArgumentUnchanged:!1},[`options`]);throw n?.onError?.(e),t}}function On(e){return t=>Dn(t,{httpClient:e})}var kn=lt(On);async function An(){return[...(await kn({filter:{services:{}}})).categories??[]].sort((e,t)=>(e.sortOrder??0)-(t.sortOrder??0))}function jn({isLoading:e,hasError:t,refetch:n,children:r}){let{searchParams:i}=X(),a={categories:[],categoryItems:[],selectedCategoryId:i.get(Z.category),selectedCategoryIndex:-1,selectedCategory:null,selectedCategoryName:null,hasMultipleCategories:!1,isLoading:e,hasError:t,refetch:n,selectCategory:()=>{}};return f($.Provider,{value:a,children:r})}function Mn({refetch:e,children:t}){return f(jn,{isLoading:!0,hasError:!1,refetch:e,children:t})}function Nn({refetch:e,children:t}){return f(jn,{isLoading:!1,hasError:!0,refetch:e,children:t})}function Pn(e){let t=e?.$in??(e?.$eq==null?[]:[e.$eq]);return[...new Set(t.filter(e=>typeof e==`string`&&e!==``))].sort().join(`,`)}function Fn(e){return e?e.split(`,`):null}var In=G(`@wix/site-service-business-logger`);function Ln(e){return{evid:32,src:16,endpoint:``,params:e}}var Rn=function(e){return e.BOOK_ONLINE=`bookingsBookOnline`,e.SERVICE_PAGE=`bookingsServicePage`,e.CALENDAR_PAGE=`bookingsCalendar`,e.FORM_PAGE=`bookingsForm`,e}({}),zn={SERVICES:`services_context`,SERVICE:`service_context`,TIME_SLOTS:`time_slots_context`,BOOKING_CHECKOUT:`booking_checkout_context`,CATEGORIES:`categories_context`,LOCATIONS:`locations_context`,SERVICE_ADD_ONS:`service_addons_context`,PREFERENCES:`preferences_context`};Rn.BOOK_ONLINE;var Bn=`new_bookings_server`,Vn=e=>{let{reportBi:t}=d(In);return r(n=>{t({widget_name:e,bookingsPlatform:Bn,is_over_editor:!1,...n.params,src:n.src,evid:n.evid},{endpoint:n.endpoint})},[t,e])},Hn=(e,t=!0)=>{let n=Vn(e),{getParsedUrl:r}=X(),i=s(!1);a(()=>{t&&!i.current&&(i.current=!0,n(Ln({referralInfo:r().searchParams.get(Z.referral)??void 0})))},[t,n,r])},$=n(null),Un=`useCategoriesContext must be used within CategoriesContextProvider`;function Wn(){let e=i($);if(!e)throw Error(Un);return e}function Gn(e,t){return{categoryId:e._id??null,categoryName:e.name??null,isSelected:e._id!=null&&e._id===t}}var Kn=e=>({categories:e,hasError:!1}),qn=()=>({categories:[],hasError:!0});function Jn({categoriesPromise:e,initialCategoryId:t,categoryIdsKey:n,refetch:i,children:c}){let{categories:l,hasError:u}=$t(e),d=o(()=>{let e=Fn(n);return e?l.filter(t=>t._id&&e.includes(t._id)):l},[l,n]),{pathname:p,searchParams:m,pushUrl:h,getExternalBaseUrl:g}=X(),_=m.get(Z.category),v=r(e=>{let t=new URLSearchParams(m);e?t.set(Z.category,e):t.delete(Z.category),t.delete(Z.page);let n=t.toString(),r=n?`${p}?${n}`:p;h(new URL(r,`${g()}/`),{disableScrollToTop:!0,skipHistory:!1})},[p,m,h,g]),y=s(!1);a(()=>{y.current||(y.current=!0,t&&!m.get(Z.category)&&v(t))},[t,m,v]);let b=d.findIndex(e=>e._id===_),x=d.find(e=>e._id===_)??null,S=d.filter(e=>e._id).length>1,C=o(()=>({categories:d,categoryItems:d.map(e=>Gn(e,_)),selectedCategoryId:_,selectedCategoryIndex:b,selectedCategory:x,selectedCategoryName:x?.name??null,hasMultipleCategories:S,isLoading:!1,hasError:u,refetch:i,selectCategory:v}),[d,_,b,x,S,u,i,v]);return f($.Provider,{value:C,children:c})}function Yn({initialCategoryId:e,categoriesPicker:n,refreshSignal:i=0,children:a}){Hn(zn.CATEGORIES);let s=dn(),l=Pn(n?.categoryId),[u,d]=c(0),p=o(()=>en(Cn({key:pn(),refresh:u!==0||i!==0,warmupData:s,fetchData:()=>Zt(`categories-context-load`,{feature:B.categories},An())}),Kn,qn),[u,i]),m=r(()=>d(e=>e+1),[]);return f(Qt,{fallback:f(Nn,{refetch:m,children:a}),feature:B.categories,children:f(t,{fallback:f(Mn,{refetch:m,children:a}),children:f(Jn,{categoriesPromise:p,initialCategoryId:e,categoryIdsKey:l,refetch:m,children:a})})})}var Xn=Wt(`73a358c8-c2c8-4342-bf64-9079e92178fc`);export{Un as CATEGORIES_CONTEXT_MISSING_PROVIDER_ERROR,$ as categoriesContext,Yn as default,Xn as injectAccessTokenGetter,Wn as useCategoriesContext};
|
|
2
|
+
//# sourceMappingURL=context-provider-73a358c8-c2c8-4342-bf64-9079e92178fc-BCGbhLxX.js.map
|
|
@@ -65,7 +65,7 @@ declare global {
|
|
|
65
65
|
interface SDKTypeMode {}
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-
|
|
68
|
+
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-p5eQUd5f.d.mts
|
|
69
69
|
interface V2Location extends V2LocationOptionsOneOf {
|
|
70
70
|
/** Information about business locations. Required when `type` is `BUSINESS`. */
|
|
71
71
|
business?: BusinessLocationOptions;
|
|
@@ -244,23 +244,200 @@ type BusinessLocation = V2Location;
|
|
|
244
244
|
//#region src/extensions/contexts/locations-context/locations-context.d.ts
|
|
245
245
|
/** A business location as shown in a location list, with its selected state. */
|
|
246
246
|
interface LocationItem {
|
|
247
|
+
/**
|
|
248
|
+
* ID of the business location. Pass it to `selectLocation()` to select the location. To get or
|
|
249
|
+
* update the location's details, use the
|
|
250
|
+
* [Locations
|
|
251
|
+
* API](https://dev.wix.com/docs/api-reference/business-management/locations/introduction).
|
|
252
|
+
*
|
|
253
|
+
* `null` when the location has no ID.
|
|
254
|
+
*/
|
|
247
255
|
locationId: string | null;
|
|
256
|
+
/**
|
|
257
|
+
* Name of the business location.
|
|
258
|
+
*
|
|
259
|
+
* `null` when the location has no name.
|
|
260
|
+
*/
|
|
248
261
|
locationName: string | null;
|
|
262
|
+
/**
|
|
263
|
+
* Whether this is the selected location, the one whose ID is `selectedLocationId`.
|
|
264
|
+
*
|
|
265
|
+
* Always `false` when `locationId` is `null`.
|
|
266
|
+
*/
|
|
249
267
|
isSelected: boolean;
|
|
250
268
|
}
|
|
251
269
|
/** The bookable business locations, whether services also run at other locations, the selected location, the loading and error state, and the actions to change or reload them. */
|
|
252
270
|
interface LocationsContextValue {
|
|
271
|
+
/**
|
|
272
|
+
* Business locations where the site's visible Wix Bookings services take place, sorted by name.
|
|
273
|
+
*
|
|
274
|
+
* Each item is a service location object from the
|
|
275
|
+
* [Services V2
|
|
276
|
+
* API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction).
|
|
277
|
+
* Its `business` field holds the location's ID and name. To render a list of the locations, use
|
|
278
|
+
* `locationItems`, which holds the same locations in the same order.
|
|
279
|
+
*
|
|
280
|
+
* Empty while `isLoading` is `true`, and when the locations fail to load.
|
|
281
|
+
*/
|
|
253
282
|
locations: BusinessLocation[];
|
|
283
|
+
/**
|
|
284
|
+
* Locations to list, an item for each location in `locations`, in the same order.
|
|
285
|
+
*
|
|
286
|
+
* Empty while `isLoading` is `true`, and when the locations fail to load.
|
|
287
|
+
*/
|
|
254
288
|
locationItems: LocationItem[];
|
|
289
|
+
/**
|
|
290
|
+
* ID of the selected location, from the `location` query parameter in the page URL.
|
|
291
|
+
*
|
|
292
|
+
* When the page opens with the parameter, it's set right away, even while `isLoading` is
|
|
293
|
+
* `true`. It changes after each call to `selectLocation()`. It isn't checked against
|
|
294
|
+
* `locations`, so it can be an ID that matches no location. It's `'OTHER_LOCATIONS'` when the
|
|
295
|
+
* services at custom addresses or at customers' locations are selected, as `hasOtherLocations`
|
|
296
|
+
* describes.
|
|
297
|
+
*
|
|
298
|
+
* `null` when no location is selected.
|
|
299
|
+
*/
|
|
255
300
|
selectedLocationId: string | null;
|
|
301
|
+
/**
|
|
302
|
+
* Index in `locations` of the selected location.
|
|
303
|
+
*
|
|
304
|
+
* `-1` when no location in `locations` is selected. For example, when no location is selected,
|
|
305
|
+
* when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
|
|
306
|
+
*/
|
|
256
307
|
selectedLocationIndex: number;
|
|
308
|
+
/**
|
|
309
|
+
* Item in `locations` whose ID is `selectedLocationId`.
|
|
310
|
+
*
|
|
311
|
+
* `null` when no location in `locations` is selected. For example, when no location is
|
|
312
|
+
* selected, when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
|
|
313
|
+
*/
|
|
257
314
|
selectedLocation: BusinessLocation | null;
|
|
315
|
+
/**
|
|
316
|
+
* Name of the selected location.
|
|
317
|
+
*
|
|
318
|
+
* `null` when `selectedLocation` is `null`, or when the location has no name.
|
|
319
|
+
*/
|
|
258
320
|
selectedLocationName: string | null;
|
|
321
|
+
/**
|
|
322
|
+
* Whether any of the site's visible Wix Bookings services takes place at a custom address or at
|
|
323
|
+
* the customer's location.
|
|
324
|
+
*
|
|
325
|
+
* Use it to offer an option for those services beside the business locations. To select that
|
|
326
|
+
* option, pass `'OTHER_LOCATIONS'` to `selectLocation()`.
|
|
327
|
+
*
|
|
328
|
+
* `false` while `isLoading` is `true`, and when the locations fail to load.
|
|
329
|
+
*/
|
|
259
330
|
hasOtherLocations: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Whether site visitors have more than 1 location to choose from.
|
|
333
|
+
*
|
|
334
|
+
* `true` when there are at least 2 choices: each location in `locations` that has an ID, plus
|
|
335
|
+
* 1 more when `hasOtherLocations` is `true`. Use it to hide a location filter that has
|
|
336
|
+
* nothing to filter.
|
|
337
|
+
*
|
|
338
|
+
* `false` while `isLoading` is `true`, and when the locations fail to load.
|
|
339
|
+
*/
|
|
260
340
|
hasMultipleLocations: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Whether the locations are loading.
|
|
343
|
+
*
|
|
344
|
+
* `true` while the locations load when the page opens, and while `refetch()` loads them again.
|
|
345
|
+
* Meanwhile, `locations` and `locationItems` are empty, the values that depend on them are
|
|
346
|
+
* `null`, `false`, or `-1`, and `selectLocation()` does nothing. `selectedLocationId` already
|
|
347
|
+
* holds the location from the page URL.
|
|
348
|
+
*/
|
|
261
349
|
isLoading: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Whether the locations failed to load.
|
|
352
|
+
*
|
|
353
|
+
* When it's `true`, `isLoading` is `false`, `locations` and `locationItems` are empty, and
|
|
354
|
+
* `hasOtherLocations` and `hasMultipleLocations` are `false`. To try again, call `refetch()`.
|
|
355
|
+
*
|
|
356
|
+
* It's also `true`, with the same empty values, after a component under the context fails to
|
|
357
|
+
* render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
|
|
358
|
+
* `selectLocation()` does nothing.
|
|
359
|
+
*/
|
|
262
360
|
hasError: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Loads the locations again.
|
|
363
|
+
*
|
|
364
|
+
* While they load, `isLoading` is `true`, `locations` and `locationItems` are empty, and
|
|
365
|
+
* `selectLocation()` does nothing. The selected location stays the same, because it's kept in
|
|
366
|
+
* the page URL.
|
|
367
|
+
*
|
|
368
|
+
* Use it to try again after the locations fail to load, when `hasError` is `true`. It doesn't
|
|
369
|
+
* clear `hasError` when a component under the context failed to render.
|
|
370
|
+
*
|
|
371
|
+
* @example Try again after the locations fail to load
|
|
372
|
+
* ```tsx
|
|
373
|
+
* import { useLocationsContext } from '@wix/bookings/context/locations';
|
|
374
|
+
*
|
|
375
|
+
* function LocationsErrorMessage() {
|
|
376
|
+
* const { hasError, refetch } = useLocationsContext();
|
|
377
|
+
*
|
|
378
|
+
* if (!hasError) {
|
|
379
|
+
* return null;
|
|
380
|
+
* }
|
|
381
|
+
*
|
|
382
|
+
* return (
|
|
383
|
+
* <p>
|
|
384
|
+
* Locations couldn't load.
|
|
385
|
+
* <button onClick={() => refetch()}>Try again</button>
|
|
386
|
+
* </p>
|
|
387
|
+
* );
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
263
391
|
refetch: () => void;
|
|
392
|
+
/**
|
|
393
|
+
* Selects a location, or clears the selection.
|
|
394
|
+
*
|
|
395
|
+
* It sets the `location` query parameter in the page URL and keeps the URL's other parameters,
|
|
396
|
+
* except `page`, which it removes so a paged list starts again from its first page. It adds an
|
|
397
|
+
* entry to the browser history and doesn't scroll to the top of the page. `selectedLocationId`
|
|
398
|
+
* and the other selection values then update. A Services context on the same page reads the
|
|
399
|
+
* same parameter, so it lists the services at the new selection.
|
|
400
|
+
*
|
|
401
|
+
* Does nothing while `isLoading` is `true`, or after a component under the context fails to
|
|
402
|
+
* render.
|
|
403
|
+
*
|
|
404
|
+
* @param locationId - ID of the location to select, such as an item's `locationId` from
|
|
405
|
+
* `locationItems`. It isn't checked against `locations`.
|
|
406
|
+
*
|
|
407
|
+
* To select the services at a custom address or at the customer's location, pass
|
|
408
|
+
* `'OTHER_LOCATIONS'`. Offer that option only when `hasOtherLocations` is `true`.
|
|
409
|
+
*
|
|
410
|
+
* To clear the selection, pass `null` or an empty string. Either removes the `location`
|
|
411
|
+
* parameter.
|
|
412
|
+
*
|
|
413
|
+
* @example Choose a location from a dropdown
|
|
414
|
+
* ```tsx
|
|
415
|
+
* import { useLocationsContext } from '@wix/bookings/context/locations';
|
|
416
|
+
*
|
|
417
|
+
* function LocationDropdown() {
|
|
418
|
+
* const { locationItems, selectedLocationId, hasOtherLocations, isLoading, selectLocation } =
|
|
419
|
+
* useLocationsContext();
|
|
420
|
+
*
|
|
421
|
+
* return (
|
|
422
|
+
* <select
|
|
423
|
+
* value={selectedLocationId ?? ''}
|
|
424
|
+
* disabled={isLoading}
|
|
425
|
+
* onChange={(event) => selectLocation(event.target.value || null)}
|
|
426
|
+
* >
|
|
427
|
+
* <option value="">All locations</option>
|
|
428
|
+
* {locationItems.map(({ locationId, locationName }) =>
|
|
429
|
+
* locationId ? (
|
|
430
|
+
* <option key={locationId} value={locationId}>
|
|
431
|
+
* {locationName ?? locationId}
|
|
432
|
+
* </option>
|
|
433
|
+
* ) : null,
|
|
434
|
+
* )}
|
|
435
|
+
* {hasOtherLocations && <option value="OTHER_LOCATIONS">Other locations</option>}
|
|
436
|
+
* </select>
|
|
437
|
+
* );
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
264
441
|
selectLocation: (locationId: string | null) => void;
|
|
265
442
|
}
|
|
266
443
|
/** Props accepted by {@link LocationsContextProvider}. */
|
|
@@ -271,7 +448,14 @@ interface LocationsContextProviderProps {
|
|
|
271
448
|
}
|
|
272
449
|
declare const locationsContext: React.Context<LocationsContextValue | null>;
|
|
273
450
|
declare const LOCATIONS_CONTEXT_MISSING_PROVIDER_ERROR = "useLocationsContext must be used within LocationsContextProvider";
|
|
274
|
-
/**
|
|
451
|
+
/**
|
|
452
|
+
* The `useLocationsContext()` hook provides access to the business locations where the site's Wix
|
|
453
|
+
* Bookings services take place, and to the location a site visitor selected. Use it to list the
|
|
454
|
+
* locations, let site visitors select a location to filter services by, and show the list's loading
|
|
455
|
+
* and error states.
|
|
456
|
+
*
|
|
457
|
+
* It throws an error where the context isn't available.
|
|
458
|
+
*/
|
|
275
459
|
declare function useLocationsContext(): LocationsContextValue;
|
|
276
460
|
/** Loads the business locations that host bookable services, checks for services at other locations, and tracks the selected location in the page URL. */
|
|
277
461
|
declare function LocationsContextProvider({
|