@suiteop/storefront 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +74 -0
- package/dist/astro-content-model.cjs +17 -0
- package/dist/astro-content-model.d.cts +4 -0
- package/dist/astro-content-model.d.ts +4 -0
- package/dist/astro-content-model.js +10 -0
- package/dist/astro.cjs +3 -1
- package/dist/astro.d.cts +38 -17
- package/dist/astro.d.ts +38 -17
- package/dist/astro.js +2 -2
- package/dist/checkout.cjs +3 -3
- package/dist/checkout.js +2 -2
- package/dist/chunk-2U6L33AT.cjs +19 -0
- package/dist/chunk-4GZBXKBU.cjs +18 -0
- package/dist/chunk-GJSCEBSU.js +5 -0
- package/dist/chunk-HLGSWF4I.js +9 -0
- package/dist/{chunk-YFTWGF3L.js → chunk-HMLBMNGA.js} +1 -1
- package/dist/chunk-KKJCPKPY.js +8 -0
- package/dist/chunk-PYVUDQSQ.js +3 -0
- package/dist/chunk-USOISC2R.cjs +17 -0
- package/dist/{chunk-RDREYP27.cjs → chunk-VV2UNVQ2.cjs} +2 -2
- package/dist/chunk-ZHFZ6II2.cjs +16 -0
- package/dist/chunk-ZI2PG7LS.js +6 -0
- package/dist/chunk-ZLAOY6IF.cjs +9 -0
- package/dist/{errors-y-BiaVAk.d.cts → client-DER7y1WE.d.cts} +98 -147
- package/dist/{errors-Bp_jmXbA.d.ts → client-goQnVoLP.d.ts} +98 -147
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/config.cjs +6 -2
- package/dist/config.d.cts +33 -1
- package/dist/config.d.ts +33 -1
- package/dist/config.js +3 -2
- package/dist/content.cjs +37 -0
- package/dist/content.d.cts +254 -0
- package/dist/content.d.ts +254 -0
- package/dist/content.js +4 -0
- package/dist/errors-B2eCo5Cz.d.cts +151 -0
- package/dist/errors-D-dULpp1.d.ts +151 -0
- package/dist/index.cjs +21 -20
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -3
- package/dist/react.cjs +6 -5
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +5 -4
- package/package.json +22 -2
- package/dist/chunk-AIQUVZEI.cjs +0 -8
- package/dist/chunk-GIIXCS6X.cjs +0 -18
- package/dist/chunk-LIBKUMJV.js +0 -8
- package/dist/chunk-SK5TD73J.js +0 -3
- package/dist/chunk-UACP7BZ7.js +0 -6
- package/dist/chunk-XIAAWHAY.cjs +0 -17
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { B as BookingResult, v as StorefrontQuote } from './client-goQnVoLP.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const storefrontClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
name: z.ZodLiteral<"page_view">;
|
|
6
|
+
eventId: z.ZodUUID;
|
|
7
|
+
ts: z.ZodNumber;
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
name: z.ZodLiteral<"view_search_results">;
|
|
12
|
+
checkIn: z.ZodOptional<z.ZodISODate>;
|
|
13
|
+
checkOut: z.ZodOptional<z.ZodISODate>;
|
|
14
|
+
guests: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
locationId: z.ZodOptional<z.ZodUUID>;
|
|
16
|
+
eventId: z.ZodUUID;
|
|
17
|
+
ts: z.ZodNumber;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
name: z.ZodLiteral<"view_item_list">;
|
|
22
|
+
listName: z.ZodString;
|
|
23
|
+
itemCount: z.ZodNumber;
|
|
24
|
+
eventId: z.ZodUUID;
|
|
25
|
+
ts: z.ZodNumber;
|
|
26
|
+
path: z.ZodString;
|
|
27
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
name: z.ZodLiteral<"view_item">;
|
|
30
|
+
listingId: z.ZodUUID;
|
|
31
|
+
eventId: z.ZodUUID;
|
|
32
|
+
ts: z.ZodNumber;
|
|
33
|
+
path: z.ZodString;
|
|
34
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
name: z.ZodLiteral<"view_quote">;
|
|
37
|
+
listingId: z.ZodUUID;
|
|
38
|
+
valueMinor: z.ZodNumber;
|
|
39
|
+
currency: z.ZodString;
|
|
40
|
+
nights: z.ZodNumber;
|
|
41
|
+
eventId: z.ZodUUID;
|
|
42
|
+
ts: z.ZodNumber;
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
+
name: z.ZodLiteral<"begin_checkout">;
|
|
47
|
+
checkoutSessionId: z.ZodUUID;
|
|
48
|
+
eventId: z.ZodUUID;
|
|
49
|
+
ts: z.ZodNumber;
|
|
50
|
+
path: z.ZodString;
|
|
51
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
name: z.ZodLiteral<"add_payment_info">;
|
|
54
|
+
checkoutSessionId: z.ZodUUID;
|
|
55
|
+
eventId: z.ZodUUID;
|
|
56
|
+
ts: z.ZodNumber;
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
name: z.ZodLiteral<"generate_lead">;
|
|
61
|
+
formId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
eventId: z.ZodUUID;
|
|
63
|
+
ts: z.ZodNumber;
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
name: z.ZodLiteral<"sign_up">;
|
|
68
|
+
method: z.ZodLiteral<"newsletter">;
|
|
69
|
+
eventId: z.ZodUUID;
|
|
70
|
+
ts: z.ZodNumber;
|
|
71
|
+
path: z.ZodString;
|
|
72
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>], "name">;
|
|
74
|
+
type StorefrontClientEvent = z.infer<typeof storefrontClientEventSchema>;
|
|
75
|
+
|
|
76
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
77
|
+
type TrackEvent = DistributiveOmit<StorefrontClientEvent, 'eventId' | 'ts' | 'path' | 'referrerHost'>;
|
|
78
|
+
type AnalyticsReporter = (err: unknown) => void;
|
|
79
|
+
interface AnalyticsOptions {
|
|
80
|
+
publishableKey: string;
|
|
81
|
+
report?: AnalyticsReporter;
|
|
82
|
+
}
|
|
83
|
+
interface StorefrontAnalytics {
|
|
84
|
+
track(event: TrackEvent): void;
|
|
85
|
+
pageView(): void;
|
|
86
|
+
flush(opts?: {
|
|
87
|
+
beacon?: boolean;
|
|
88
|
+
}): void;
|
|
89
|
+
dispose(): void;
|
|
90
|
+
}
|
|
91
|
+
declare function trackPurchasePixel(booking: Pick<BookingResult, 'bookingRequestId'> & {
|
|
92
|
+
totalMinor?: number | null;
|
|
93
|
+
currency?: string | null;
|
|
94
|
+
}): void;
|
|
95
|
+
declare function createAnalytics(opts: AnalyticsOptions): StorefrontAnalytics;
|
|
96
|
+
declare function analyticsFor(publishableKey: string): StorefrontAnalytics;
|
|
97
|
+
|
|
98
|
+
declare const STOREFRONT_ERROR_CODES: readonly ["wrong_region", "origin_not_allowed", "origin_required", "site_archived", "not_bookable", "quote_invalid", "quote_expired", "price_changed", "currency_unsupported", "payment_declined", "session_expired", "rate_limited", "contact_not_configured", "payment_account_unavailable", "idempotency_key_required", "idempotency_key_reused", "payment_mode_unsupported", "payment_not_authorized", "payment_method_required", "site_not_published", "preview_read_only", "bookings_closed", "extras_invalid", "UNAUTHORIZED", "VALIDATION_ERROR", "NOT_FOUND", "site_not_found", "upstream_timeout", "timeout", "network", "invalid_response", "internal_error", "checkout_unavailable"];
|
|
99
|
+
type StorefrontErrorCode = (typeof STOREFRONT_ERROR_CODES)[number];
|
|
100
|
+
type StorefrontRegion = 'us' | 'eu' | 'apac';
|
|
101
|
+
interface StorefrontErrorInit {
|
|
102
|
+
status: number;
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
type?: string;
|
|
106
|
+
requestId?: string | null;
|
|
107
|
+
details?: Record<string, unknown>;
|
|
108
|
+
cause?: unknown;
|
|
109
|
+
}
|
|
110
|
+
declare class StorefrontError extends Error {
|
|
111
|
+
name: string;
|
|
112
|
+
readonly status: number;
|
|
113
|
+
readonly type: string;
|
|
114
|
+
readonly code: StorefrontErrorCode | (string & {});
|
|
115
|
+
readonly requestId: string | null;
|
|
116
|
+
readonly details: Record<string, unknown>;
|
|
117
|
+
constructor(init: StorefrontErrorInit);
|
|
118
|
+
}
|
|
119
|
+
declare class PriceChangedError extends StorefrontError {
|
|
120
|
+
name: string;
|
|
121
|
+
readonly quote: StorefrontQuote | null;
|
|
122
|
+
readonly requiresNewSession: boolean;
|
|
123
|
+
constructor(init: StorefrontErrorInit);
|
|
124
|
+
}
|
|
125
|
+
declare class WrongRegionError extends StorefrontError {
|
|
126
|
+
name: string;
|
|
127
|
+
readonly region: StorefrontRegion | null;
|
|
128
|
+
readonly baseUrl: string | null;
|
|
129
|
+
constructor(init: StorefrontErrorInit);
|
|
130
|
+
}
|
|
131
|
+
declare class RateLimitedError extends StorefrontError {
|
|
132
|
+
name: string;
|
|
133
|
+
readonly retryAfterSec: number | null;
|
|
134
|
+
readonly scope: 'key' | 'ip' | 'pms' | null;
|
|
135
|
+
constructor(init: StorefrontErrorInit & {
|
|
136
|
+
retryAfterSec: number | null;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
declare class StorefrontTimeoutError extends StorefrontError {
|
|
140
|
+
name: string;
|
|
141
|
+
constructor(timeoutMs: number, requestId?: string | null);
|
|
142
|
+
}
|
|
143
|
+
declare class StorefrontNetworkError extends StorefrontError {
|
|
144
|
+
name: string;
|
|
145
|
+
constructor(cause: unknown);
|
|
146
|
+
}
|
|
147
|
+
declare class StorefrontConfigError extends Error {
|
|
148
|
+
name: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { type AnalyticsOptions as A, PriceChangedError as P, RateLimitedError as R, type StorefrontRegion as S, type TrackEvent as T, WrongRegionError as W, type AnalyticsReporter as a, STOREFRONT_ERROR_CODES as b, type StorefrontAnalytics as c, StorefrontConfigError as d, StorefrontError as e, type StorefrontErrorCode as f, type StorefrontErrorInit as g, StorefrontNetworkError as h, StorefrontTimeoutError as i, analyticsFor as j, createAnalytics as k, trackPurchasePixel as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var chunk2U6L33AT_cjs = require('./chunk-2U6L33AT.cjs');
|
|
4
|
+
require('./chunk-ZLAOY6IF.cjs');
|
|
5
|
+
require('./chunk-4GZBXKBU.cjs');
|
|
6
|
+
var chunkUSOISC2R_cjs = require('./chunk-USOISC2R.cjs');
|
|
5
7
|
require('./chunk-LVFRVNT3.cjs');
|
|
6
|
-
require('./chunk-AIQUVZEI.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
Object.defineProperty(exports, "SDK_VERSION", {
|
|
11
12
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk2U6L33AT_cjs.SDK_VERSION; }
|
|
13
14
|
});
|
|
14
15
|
Object.defineProperty(exports, "STOREFRONT_API_PATH", {
|
|
15
16
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk2U6L33AT_cjs.STOREFRONT_API_PATH; }
|
|
17
18
|
});
|
|
18
19
|
Object.defineProperty(exports, "STOREFRONT_API_VERSION", {
|
|
19
20
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk2U6L33AT_cjs.STOREFRONT_API_VERSION; }
|
|
21
22
|
});
|
|
22
23
|
Object.defineProperty(exports, "analyticsFor", {
|
|
23
24
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk2U6L33AT_cjs.analyticsFor; }
|
|
25
26
|
});
|
|
26
27
|
Object.defineProperty(exports, "createAnalytics", {
|
|
27
28
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk2U6L33AT_cjs.createAnalytics; }
|
|
29
30
|
});
|
|
30
31
|
Object.defineProperty(exports, "createStorefrontClient", {
|
|
31
32
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunk2U6L33AT_cjs.createStorefrontClient; }
|
|
33
34
|
});
|
|
34
35
|
Object.defineProperty(exports, "getAttribution", {
|
|
35
36
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunk2U6L33AT_cjs.getAttribution; }
|
|
37
38
|
});
|
|
38
39
|
Object.defineProperty(exports, "parsePublishableKey", {
|
|
39
40
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunk2U6L33AT_cjs.parsePublishableKey; }
|
|
41
42
|
});
|
|
42
43
|
Object.defineProperty(exports, "trackPurchasePixel", {
|
|
43
44
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunk2U6L33AT_cjs.trackPurchasePixel; }
|
|
45
46
|
});
|
|
46
47
|
Object.defineProperty(exports, "PriceChangedError", {
|
|
47
48
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkUSOISC2R_cjs.PriceChangedError; }
|
|
49
50
|
});
|
|
50
51
|
Object.defineProperty(exports, "RateLimitedError", {
|
|
51
52
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkUSOISC2R_cjs.RateLimitedError; }
|
|
53
54
|
});
|
|
54
55
|
Object.defineProperty(exports, "STOREFRONT_ERROR_CODES", {
|
|
55
56
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkUSOISC2R_cjs.STOREFRONT_ERROR_CODES; }
|
|
57
58
|
});
|
|
58
59
|
Object.defineProperty(exports, "StorefrontConfigError", {
|
|
59
60
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkUSOISC2R_cjs.StorefrontConfigError; }
|
|
61
62
|
});
|
|
62
63
|
Object.defineProperty(exports, "StorefrontError", {
|
|
63
64
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkUSOISC2R_cjs.StorefrontError; }
|
|
65
66
|
});
|
|
66
67
|
Object.defineProperty(exports, "StorefrontNetworkError", {
|
|
67
68
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
69
|
+
get: function () { return chunkUSOISC2R_cjs.StorefrontNetworkError; }
|
|
69
70
|
});
|
|
70
71
|
Object.defineProperty(exports, "StorefrontTimeoutError", {
|
|
71
72
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
73
|
+
get: function () { return chunkUSOISC2R_cjs.StorefrontTimeoutError; }
|
|
73
74
|
});
|
|
74
75
|
Object.defineProperty(exports, "WrongRegionError", {
|
|
75
76
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkUSOISC2R_cjs.WrongRegionError; }
|
|
77
78
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { S as StorefrontRegion } from './errors-
|
|
2
|
-
export { A as AnalyticsOptions, a as AnalyticsReporter,
|
|
1
|
+
import { S as StorefrontRegion } from './errors-B2eCo5Cz.cjs';
|
|
2
|
+
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-B2eCo5Cz.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontImage, r as StorefrontListing, s as StorefrontListingSummary, t as StorefrontListingsQuery, u as StorefrontLocation, v as StorefrontQuote, w as StorefrontQuoteInput, x as StorefrontRatePlanQuote, y as StorefrontReview, z as StorefrontReviewsQuery, A as StorefrontSite, D as createStorefrontClient } from './client-DER7y1WE.cjs';
|
|
4
5
|
export { S as StorefrontAvailability, a as StorefrontCalendar, b as StorefrontCalendarDay, c as StorefrontCalendarQuery, d as StorefrontStay, e as StorefrontUnavailableReason } from './availability-CnzmxuV3.cjs';
|
|
5
6
|
|
|
6
7
|
declare const attributionTouchSchema: z.ZodObject<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { S as StorefrontRegion } from './errors-
|
|
2
|
-
export { A as AnalyticsOptions, a as AnalyticsReporter,
|
|
1
|
+
import { S as StorefrontRegion } from './errors-D-dULpp1.js';
|
|
2
|
+
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-D-dULpp1.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontImage, r as StorefrontListing, s as StorefrontListingSummary, t as StorefrontListingsQuery, u as StorefrontLocation, v as StorefrontQuote, w as StorefrontQuoteInput, x as StorefrontRatePlanQuote, y as StorefrontReview, z as StorefrontReviewsQuery, A as StorefrontSite, D as createStorefrontClient } from './client-goQnVoLP.js';
|
|
4
5
|
export { S as StorefrontAvailability, a as StorefrontCalendar, b as StorefrontCalendarDay, c as StorefrontCalendarQuery, d as StorefrontStay, e as StorefrontUnavailableReason } from './availability-CnzmxuV3.js';
|
|
5
6
|
|
|
6
7
|
declare const attributionTouchSchema: z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { SDK_VERSION, STOREFRONT_API_PATH, STOREFRONT_API_VERSION, analyticsFor, createAnalytics, createStorefrontClient, getAttribution, parsePublishableKey, trackPurchasePixel } from './chunk-
|
|
2
|
-
|
|
1
|
+
export { SDK_VERSION, STOREFRONT_API_PATH, STOREFRONT_API_VERSION, analyticsFor, createAnalytics, createStorefrontClient, getAttribution, parsePublishableKey, trackPurchasePixel } from './chunk-HLGSWF4I.js';
|
|
2
|
+
import './chunk-PYVUDQSQ.js';
|
|
3
|
+
import './chunk-GJSCEBSU.js';
|
|
4
|
+
export { PriceChangedError, RateLimitedError, STOREFRONT_ERROR_CODES, StorefrontConfigError, StorefrontError, StorefrontNetworkError, StorefrontTimeoutError, WrongRegionError } from './chunk-ZI2PG7LS.js';
|
|
3
5
|
import './chunk-6NFURJXI.js';
|
|
4
|
-
import './chunk-SK5TD73J.js';
|
package/dist/react.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
3
|
+
var chunk2U6L33AT_cjs = require('./chunk-2U6L33AT.cjs');
|
|
4
|
+
var chunkVV2UNVQ2_cjs = require('./chunk-VV2UNVQ2.cjs');
|
|
5
|
+
require('./chunk-ZLAOY6IF.cjs');
|
|
6
|
+
require('./chunk-4GZBXKBU.cjs');
|
|
7
|
+
var chunkUSOISC2R_cjs = require('./chunk-USOISC2R.cjs');
|
|
6
8
|
require('./chunk-LVFRVNT3.cjs');
|
|
7
|
-
require('./chunk-AIQUVZEI.cjs');
|
|
8
9
|
var react = require('react');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
11
|
|
|
11
|
-
var SuiteOpContext=react.createContext(null);var ASTRO_PAGE_LOAD="astro:page-load";function SuiteOpProvider({client,children}){const value=react.useMemo(()=>({client,requests:new Map,analytics:
|
|
12
|
+
var SuiteOpContext=react.createContext(null);var ASTRO_PAGE_LOAD="astro:page-load";function SuiteOpProvider({client,children}){const value=react.useMemo(()=>({client,requests:new Map,analytics:chunk2U6L33AT_cjs.analyticsFor(client.publishableKey)}),[client]);const{analytics}=value;react.useEffect(()=>{const onPageLoad=()=>analytics.pageView();onPageLoad();document.addEventListener(ASTRO_PAGE_LOAD,onPageLoad);return ()=>document.removeEventListener(ASTRO_PAGE_LOAD,onPageLoad)},[analytics]);return jsxRuntime.jsx(SuiteOpContext.Provider,{value,children})}function useTrack(){const{analytics}=useSuiteOpContext("useTrack");return analytics.track}function useSuiteOpContext(hookName){const value=react.useContext(SuiteOpContext);if(!value)throw new chunkUSOISC2R_cjs.StorefrontConfigError(`${hookName} must be used inside <SuiteOpProvider>`);return value}function useStorefrontClient(){return useSuiteOpContext("useStorefrontClient").client}var SHARED_TTL_MS=3e4;function toStorefrontError(err){if(err instanceof chunkUSOISC2R_cjs.StorefrontError)return err;return new chunkUSOISC2R_cjs.StorefrontError({status:0,code:"internal_error",message:err instanceof Error?err.message:"Unexpected error",cause:err})}function acquire(requests,key,run){const now=Date.now();for(const[k,entry2]of requests){if(entry2.refs===0&&entry2.settledAt!==null&&now-entry2.settledAt>=SHARED_TTL_MS){requests.delete(k);}}const cached=requests.get(key);if(cached&&(cached.settledAt===null||now-cached.settledAt<SHARED_TTL_MS)){cached.refs+=1;return cached}const controller=new AbortController;const entry={promise:Promise.resolve(),controller,refs:1,settledAt:null};entry.promise=run({signal:controller.signal}).then(data=>{entry.settledAt=Date.now();return data},err=>{if(requests.get(key)===entry)requests.delete(key);throw err});requests.set(key,entry);return entry}function release(requests,key,entry){entry.refs-=1;queueMicrotask(()=>{if(entry.refs>0||entry.settledAt!==null)return;entry.controller.abort();if(requests.get(key)===entry)requests.delete(key);});}function useSharedRead(hookName,key,run){const{requests}=useSuiteOpContext(hookName);const[current,setCurrent]=react.useState(null);const runRef=react.useRef(run);runRef.current=run;react.useEffect(()=>{if(key===null)return;let active=true;const entry=acquire(requests,key,opts=>runRef.current(opts));entry.promise.then(data=>{if(active)setCurrent({key,state:{status:"success",data}});},err=>{if(active&&!entry.controller.signal.aborted){setCurrent({key,state:{status:"error",error:toStorefrontError(err)}});}});return ()=>{active=false;release(requests,key,entry);}},[requests,key]);if(key===null)return {status:"idle"};return current?.key===key?current.state:{status:"loading"}}function useListing(id){const{client}=useSuiteOpContext("useListing");return useSharedRead("useListing",id===null?null:`listing:${id}`,opts=>client.listings.get(id,opts))}function useAvailability(listingId,stay){const{client}=useSuiteOpContext("useAvailability");const key=listingId===null||stay===null?null:`availability:${JSON.stringify([listingId,stay.checkIn,stay.checkOut,stay.guests])}`;return useSharedRead("useAvailability",key,opts=>client.availability.get(listingId,stay,opts))}function useMutationState(){const[state,setState]=react.useState({status:"idle"});const seq=react.useRef(0);const track=react.useCallback(async(work,onError)=>{const mine=++seq.current;setState({status:"loading"});try{const data=await work();if(mine===seq.current)setState({status:"success",data});return data}catch(err){if(mine===seq.current){onError?.(err);setState({status:"error",error:toStorefrontError(err)});}throw err}},[]);return {state,track}}function useQuote(){const{client}=useSuiteOpContext("useQuote");const{state,track}=useMutationState();const quote=react.useCallback(input=>track(()=>client.quotes.create(input)),[client,track]);return {quote,state}}function useCheckoutSession(){const{client}=useSuiteOpContext("useCheckoutSession");const{state,track}=useMutationState();const[priceChanged,setPriceChanged]=react.useState(null);const create=react.useCallback((input,opts)=>{setPriceChanged(null);return track(()=>client.checkoutSessions.create(input,opts),err=>{if(err instanceof chunkUSOISC2R_cjs.PriceChangedError)setPriceChanged(err.quote);})},[client,track]);return {create,session:state,priceChanged}}var EVENTS={"suiteop-checkout:ready":h=>h.onReady?.(),"suiteop-checkout:confirmed":(h,detail)=>h.onComplete(detail),"suiteop-checkout:pending":(h,detail)=>h.onPending?.(detail),"suiteop-checkout:error":(h,detail)=>{const error=detail;if(error.code==="price_changed"&&h.onPriceChanged)h.onPriceChanged();else h.onError?.(error);}};function SuiteOpCheckout(props){const client=useStorefrontClient();const ref=react.useRef(null);const handlers=react.useRef(props);handlers.current=props;react.useEffect(()=>{let active=true;chunkVV2UNVQ2_cjs.loadCheckout({origin:props.checkoutOrigin}).catch(err=>{if(!active)return;const code=err instanceof chunkUSOISC2R_cjs.StorefrontError?err.code:"checkout_unavailable";handlers.current.onError?.({code,requiresNewSession:false});});return ()=>{active=false;}},[props.checkoutOrigin]);react.useEffect(()=>{const element=ref.current;if(!element)return;const listeners=Object.entries(EVENTS).map(([type,handle])=>{const listener=event=>handle(handlers.current,event.detail);element.addEventListener(type,listener);return [type,listener]});return ()=>{for(const[type,listener]of listeners)element.removeEventListener(type,listener);}},[]);const apiBase=client.baseUrl.endsWith(chunk2U6L33AT_cjs.STOREFRONT_API_PATH)?client.baseUrl.slice(0,-chunk2U6L33AT_cjs.STOREFRONT_API_PATH.length):client.baseUrl;return react.createElement("suiteop-checkout",{ref,class:props.className,"session-id":props.checkoutSessionId,"quote-ref":props.quoteRef,"idempotency-key":props.idempotencyKey,"api-base":apiBase,"publishable-key":client.publishableKey,locale:props.locale})}
|
|
12
13
|
|
|
13
14
|
exports.SuiteOpCheckout = SuiteOpCheckout;
|
|
14
15
|
exports.SuiteOpProvider = SuiteOpProvider;
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { d as StorefrontStay, S as StorefrontAvailability } from './availability-CnzmxuV3.cjs';
|
|
2
|
-
import {
|
|
2
|
+
import { e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, v as StorefrontQuote, r as StorefrontListing, w as StorefrontQuoteInput, j as StorefrontClient, B as BookingResult } from './client-DER7y1WE.cjs';
|
|
3
|
+
import { e as StorefrontError, T as TrackEvent } from './errors-B2eCo5Cz.cjs';
|
|
3
4
|
import * as react from 'react';
|
|
4
5
|
import { ReactNode, JSX } from 'react';
|
|
5
6
|
import 'zod';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { d as StorefrontStay, S as StorefrontAvailability } from './availability-CnzmxuV3.js';
|
|
2
|
-
import {
|
|
2
|
+
import { e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, v as StorefrontQuote, r as StorefrontListing, w as StorefrontQuoteInput, j as StorefrontClient, B as BookingResult } from './client-goQnVoLP.js';
|
|
3
|
+
import { e as StorefrontError, T as TrackEvent } from './errors-D-dULpp1.js';
|
|
3
4
|
import * as react from 'react';
|
|
4
5
|
import { ReactNode, JSX } from 'react';
|
|
5
6
|
import 'zod';
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { analyticsFor, STOREFRONT_API_PATH } from './chunk-
|
|
2
|
-
import { loadCheckout } from './chunk-
|
|
3
|
-
import
|
|
1
|
+
import { analyticsFor, STOREFRONT_API_PATH } from './chunk-HLGSWF4I.js';
|
|
2
|
+
import { loadCheckout } from './chunk-HMLBMNGA.js';
|
|
3
|
+
import './chunk-PYVUDQSQ.js';
|
|
4
|
+
import './chunk-GJSCEBSU.js';
|
|
5
|
+
import { StorefrontConfigError, PriceChangedError, StorefrontError } from './chunk-ZI2PG7LS.js';
|
|
4
6
|
import './chunk-6NFURJXI.js';
|
|
5
|
-
import './chunk-SK5TD73J.js';
|
|
6
7
|
import { createContext, useMemo, useEffect, useContext, useCallback, useState, useRef, createElement } from 'react';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suiteop/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Typed client, React hooks and headless components for the SuiteOp Storefront API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://developer.suiteop.com",
|
|
@@ -73,6 +73,26 @@
|
|
|
73
73
|
"default": "./dist/astro.cjs"
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
+
"./astro/content-model": {
|
|
77
|
+
"import": {
|
|
78
|
+
"types": "./dist/astro-content-model.d.ts",
|
|
79
|
+
"default": "./dist/astro-content-model.js"
|
|
80
|
+
},
|
|
81
|
+
"require": {
|
|
82
|
+
"types": "./dist/astro-content-model.d.cts",
|
|
83
|
+
"default": "./dist/astro-content-model.cjs"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"./content": {
|
|
87
|
+
"import": {
|
|
88
|
+
"types": "./dist/content.d.ts",
|
|
89
|
+
"default": "./dist/content.js"
|
|
90
|
+
},
|
|
91
|
+
"require": {
|
|
92
|
+
"types": "./dist/content.d.cts",
|
|
93
|
+
"default": "./dist/content.cjs"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
76
96
|
"./package.json": "./package.json"
|
|
77
97
|
},
|
|
78
98
|
"files": [
|
|
@@ -84,7 +104,7 @@
|
|
|
84
104
|
"access": "public"
|
|
85
105
|
},
|
|
86
106
|
"dependencies": {
|
|
87
|
-
"zod": "^4.
|
|
107
|
+
"zod": "^4.6.5"
|
|
88
108
|
},
|
|
89
109
|
"peerDependencies": {
|
|
90
110
|
"react": ">=18 <20"
|
package/dist/chunk-AIQUVZEI.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var REGIONS=["us","eu","apac"];var BE_BOOKING_REQUEST_STATUSES=["inquiry","processing","confirmed","failed","expired","pending_pms_sync","pending_payment","authorized","reserved","cancelled"];var STOREFRONT_KEY_ENVIRONMENTS=["live","test"];var GOOGLE_FONTS=["inter","montserrat","poppins","raleway","nunito","work_sans","mulish","barlow","jost","bitter","archivo","public_sans","gantari","anybody","lato","playfair_display","karla","reddit_sans","overpass","roboto","open_sans","merriweather","outfit"];
|
|
4
|
-
|
|
5
|
-
exports.BE_BOOKING_REQUEST_STATUSES = BE_BOOKING_REQUEST_STATUSES;
|
|
6
|
-
exports.GOOGLE_FONTS = GOOGLE_FONTS;
|
|
7
|
-
exports.REGIONS = REGIONS;
|
|
8
|
-
exports.STOREFRONT_KEY_ENVIRONMENTS = STOREFRONT_KEY_ENVIRONMENTS;
|
package/dist/chunk-GIIXCS6X.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkXIAAWHAY_cjs = require('./chunk-XIAAWHAY.cjs');
|
|
4
|
-
var chunkLVFRVNT3_cjs = require('./chunk-LVFRVNT3.cjs');
|
|
5
|
-
var chunkAIQUVZEI_cjs = require('./chunk-AIQUVZEI.cjs');
|
|
6
|
-
var zod = require('zod');
|
|
7
|
-
|
|
8
|
-
var STOREFRONT_CHANNELS=["ai_assistant","paid_search","paid_social","organic_search","organic_social","email","referral","direct"];var AI_ASSISTANT_HOSTS={"chatgpt.com":"chatgpt","chat.openai.com":"chatgpt","perplexity.ai":"perplexity","gemini.google.com":"gemini","copilot.microsoft.com":"copilot","claude.ai":"claude"};var AI_ASSISTANT_SOURCES={"chatgpt.com":"chatgpt",perplexity:"perplexity","perplexity.ai":"perplexity",gemini:"gemini",copilot:"copilot","claude.ai":"claude"};var PAID_CLICKS=["google","microsoft","meta"];var PAID_MEDIUMS=new Set(["cpc","ppc","paid","paidsearch","sem"]);var EMAIL_RE=/newsletter|mailchimp|klaviyo/;var SEARCH_SUFFIXES=["bing.com","duckduckgo.com","search.yahoo.com","baidu.com","ecosia.org","search.brave.com"];var SEARCH_ANY_TLD_RE=/^(?:www\.)?(?:google|yandex)\.[a-z]{2,3}(?:\.[a-z]{2})?$/;var SOCIAL_SUFFIXES=["facebook.com","instagram.com","t.co","x.com","twitter.com","linkedin.com","tiktok.com","youtube.com","reddit.com"];var SOCIAL_ANY_TLD_RE=/(?:^|\.)pinterest\.[a-z]{2,3}(?:\.[a-z]{2})?$/;var SOCIAL_SOURCES=new Set(["facebook","fb","instagram","ig","meta","twitter","x","linkedin","pinterest","tiktok","youtube","reddit"]);var clean=value=>{const v=value?.trim().toLowerCase();return v?v:null};var hostOf=value=>clean(value)?.replace(/\.$/,"")??null;var hostMatches=(host,suffix)=>host===suffix||host.endsWith(`.${suffix}`);var bareHost=host=>host.replace(/^www\./,"");function aiLabel(host,source){if(host){const suffix=Object.keys(AI_ASSISTANT_HOSTS).find(s=>hostMatches(host,s));if(suffix)return AI_ASSISTANT_HOSTS[suffix]}return source&&Object.hasOwn(AI_ASSISTANT_SOURCES,source)?AI_ASSISTANT_SOURCES[source]:null}var isSearchHost=host=>SEARCH_ANY_TLD_RE.test(host)||SEARCH_SUFFIXES.some(s=>hostMatches(host,s));var isSocialHost=host=>SOCIAL_ANY_TLD_RE.test(host)||SOCIAL_SUFFIXES.some(s=>hostMatches(host,s));function paidClickOf(t){const medium=clean(t.utmMedium);if(t.fbclid&&medium!==null&&PAID_MEDIUMS.has(medium))return "meta";if(t.gclid||t.gbraid||t.wbraid)return "google";if(t.msclkid)return "microsoft";if(t.fbclid)return "meta";return t.paidClick??null}function classifyChannel(t){const source=clean(t.utmSource);const medium=clean(t.utmMedium);const site=bareHost(hostOf(t.siteHost)??"");const ref=hostOf(t.referrerHost);const external=ref&&bareHost(ref)!==site?ref:null;const result=(channel,label=null)=>({channel,source:label??source??external,medium});const socialSource=source!==null&&(SOCIAL_SOURCES.has(source)||isSocialHost(source))||!!(external&&isSocialHost(external));const paidMedium=medium!==null&&PAID_MEDIUMS.has(medium);const searchClick=t.gclid||t.gbraid||t.wbraid||t.msclkid||t.paidClick==="google"||t.paidClick==="microsoft";const metaClick=t.fbclid||t.paidClick==="meta";if(searchClick||paidMedium){return result(socialSource||metaClick&&paidMedium?"paid_social":"paid_search")}if(medium==="email"||EMAIL_RE.test(source??"")||EMAIL_RE.test(medium??"")){return result("email")}const ai=aiLabel(external,source);if(ai)return result("ai_assistant",ai);if(external&&isSearchHost(external))return result("organic_search");if(socialSource||metaClick)return result("organic_social");const anyUtm=[source,medium,t.utmCampaign,t.utmTerm,t.utmContent].some(v=>clean(v??null));if(!external&&!anyUtm)return result("direct");return result("referral")}var consentStateSchema=zod.z.object({analytics:zod.z.boolean(),ads:zod.z.boolean(),source:zod.z.enum(["default","user"]),region:zod.z.enum(["restricted","other"]),decidedAt:zod.z.iso.datetime().max(40).nullable()});function isSafePrivacyUrl(value){if([...value].some(ch=>/\s/.test(ch)||ch.charCodeAt(0)<32))return false;if(value.startsWith("/"))return !value.startsWith("//")&&!value.startsWith("/\\");if(!value.startsWith("https://")||!URL.canParse(value))return false;const url=new URL(value);return url.hostname!==""&&url.username===""&&url.password===""}var STOREFRONT_CONSENT_MODES=["regional","strict"];var modeField=zod.z.enum(STOREFRONT_CONSENT_MODES);var privacyPolicyUrlField=zod.z.string().trim().max(2048,"validation.storefront.privacy_policy_url_invalid").refine(isSafePrivacyUrl,"validation.storefront.privacy_policy_url_invalid").nullable();zod.z.object({mode:modeField.default("regional"),privacyPolicyUrl:privacyPolicyUrlField.default(null)});zod.z.object({siteId:zod.z.uuid(),consentSettings:zod.z.object({mode:modeField.optional(),privacyPolicyUrl:privacyPolicyUrlField.optional()})});var ACTIVE_RESERVATION_STATUSES=["confirmed","reserved","awaiting_payment"];new Set(ACTIVE_RESERVATION_STATUSES);var SCHEDULABLE_RESERVATION_STATUSES=[...ACTIVE_RESERVATION_STATUSES,"blocked"];new Set(SCHEDULABLE_RESERVATION_STATUSES);var VOLATILE_SYNC_STATUSES=["pending","pending_deletion","failed_deletion"];new Set(VOLATILE_SYNC_STATUSES);var CURRENCIES=["usd","eur","aud","gbp","cad","chf","cny","jpy","nzd","nok","mxn","thb","bgn","aed","inr","rub","brl","zar","sgd","hkd","xcd","xof","clp","dkk","try","bnd","xcg","shp","fkp","idr","ron","czk"];var ZERO_DECIMAL_CURRENCY_CODES=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","vnd","vuv","xaf","xof","xpf"]);new Set(CURRENCIES.filter(code=>ZERO_DECIMAL_CURRENCY_CODES.has(code)));var LIVE_PAYMENT_INTENT_STATUS_LIST=["succeeded","processing","requires_capture","refunded","disputed","reversed"];new Set(LIVE_PAYMENT_INTENT_STATUS_LIST);var BE_SITE_EXPERIMENT_VARIANTS=["a","b"];var ACTIVE_MIGRATION_RUN_STATUSES=["running","writing","finalizing","rolling_back"];new Set(ACTIVE_MIGRATION_RUN_STATUSES.filter(status=>status!=="rolling_back"));var experimentVariantSchema=zod.z.enum(BE_SITE_EXPERIMENT_VARIANTS);var experimentAssignmentSchema=zod.z.object({id:zod.z.uuid(),variant:experimentVariantSchema});zod.z.object({siteId:zod.z.uuid()});zod.z.object({siteId:zod.z.uuid(),deploymentBId:zod.z.uuid("validation.storefront.experiment_variant_required"),splitBPercent:zod.z.number("validation.storefront.experiment_split_range").int("validation.storefront.experiment_split_range").min(1,"validation.storefront.experiment_split_range").max(99,"validation.storefront.experiment_split_range")});zod.z.object({id:zod.z.uuid(),winner:experimentVariantSchema.nullable()});zod.z.object({id:zod.z.uuid()});var clickId=zod.z.string().min(1).max(512).regex(/^[\w.\-~]+$/);var storable=value=>!value.includes("\0")&&!/\p{Surrogate}/u.test(value);var utm=zod.z.string().max(150).refine(storable).nullable();var attributionTouchSchema=zod.z.object({ts:zod.z.iso.datetime().max(40),landingPath:zod.z.string().max(512).regex(/^\/[^?#]*$/).refine(storable),referrerHost:zod.z.string().max(253).regex(/^[a-z0-9.-]+$/).nullable(),utmSource:utm,utmMedium:utm,utmCampaign:utm,utmTerm:utm,utmContent:utm,gclid:clickId.nullable(),gbraid:clickId.nullable(),wbraid:clickId.nullable(),fbclid:clickId.nullable(),msclkid:clickId.nullable(),paidClick:zod.z.enum(PAID_CLICKS).nullable().default(null)});var attributionIdsSchema=zod.z.object({gaClientId:zod.z.string().max(64).regex(/^\d+\.\d+$/).nullable(),gaSessionId:zod.z.string().max(32).regex(/^\d+$/).nullable(),fbp:zod.z.string().max(128).regex(/^fb\.\d\.\d+\.\d+$/).nullable(),fbc:zod.z.string().max(600).regex(/^fb\.\d\.\d+\.[\w-]+$/).nullable()});var storefrontAttributionInputSchema=zod.z.object({first:attributionTouchSchema.nullable(),last:attributionTouchSchema.nullable(),ids:attributionIdsSchema,consent:consentStateSchema,experiment:experimentAssignmentSchema.optional()});var STORED_ATTRIBUTION_CHANNELS=[...STOREFRONT_CHANNELS,"ai_agent_mcp"];storefrontAttributionInputSchema.extend({firstChannel:zod.z.enum(STORED_ATTRIBUTION_CHANNELS).nullable(),lastChannel:zod.z.enum(STORED_ATTRIBUTION_CHANNELS),userAgent:zod.z.string().max(512).nullable(),capturedAt:zod.z.iso.datetime()});function withoutClickIds(touch){return {...touch,gclid:null,gbraid:null,wbraid:null,fbclid:null,msclkid:null,paidClick:paidClickOf(touch)}}var emailField=zod.z.string().trim().toLowerCase().pipe(zod.z.email("validation.email_invalid"));zod.z.string().trim().min(1,"validation.email_required").pipe(emailField);var trimmedEmailField=zod.z.string().trim().pipe(zod.z.email("validation.email_invalid"));var requiredTrimmedEmailField=zod.z.string().trim().min(1,"validation.email_required").pipe(trimmedEmailField);zod.z.string().nullish().transform((raw,ctx)=>{if(raw===void 0)return void 0;const trimmed=(raw??"").trim().toLowerCase();if(!trimmed)return null;if(!zod.z.email().safeParse(trimmed).success){ctx.addIssue({code:"custom",message:"validation.email_invalid"});return zod.z.NEVER}return trimmed});var amountMinor=zod.z.number().int().positive();var currency=zod.z.string().length(3);var chargedByHost=zod.z.literal("host");var checkoutMountDescriptorKnownSchema=zod.z.discriminatedUnion("provider",[zod.z.object({provider:zod.z.literal("stripe"),publishableKey:zod.z.string().min(1),stripeAccountId:zod.z.string().nullable(),clientSecret:zod.z.string().min(1),amountMinor,currency}),zod.z.object({provider:zod.z.literal("juspay"),publishableKey:zod.z.string().min(1),providerBaseUrl:zod.z.url(),clientSecret:zod.z.string().min(1),profileId:zod.z.string().min(1),amountMinor,currency}),zod.z.object({provider:zod.z.literal("guesty_pay"),guestyPartnerId:zod.z.string().min(1),paymentProviderId:zod.z.string().min(1),externalListingId:zod.z.string().min(1),pmsQuoteId:zod.z.string().nullable(),amountMinor,currency,chargedBy:chargedByHost.optional()}),zod.z.object({provider:zod.z.literal("pms_stripe"),publishableKey:zod.z.string().min(1),stripeAccountId:zod.z.string().min(1),clientSecret:zod.z.string().min(1),amountMinor,currency,chargedBy:chargedByHost})]);var KNOWN_MOUNT_PROVIDERS=["stripe","juspay","guesty_pay","pms_stripe"];var checkoutMountDescriptorSchema=zod.z.union([checkoutMountDescriptorKnownSchema,zod.z.object({provider:zod.z.string().refine(p=>!KNOWN_MOUNT_PROVIDERS.includes(p))}).loose()]);zod.z.enum(chunkAIQUVZEI_cjs.BE_BOOKING_REQUEST_STATUSES);var bookingRequestStatusResponseSchema=chunkLVFRVNT3_cjs.openEnum(chunkAIQUVZEI_cjs.BE_BOOKING_REQUEST_STATUSES);var checkoutSessionQuoteSchema=zod.z.object({listingId:zod.z.uuid(),checkIn:zod.z.iso.date(),checkOut:zod.z.iso.date(),guests:zod.z.number().int().positive(),ratePlanId:zod.z.string(),totalMinor:zod.z.number().int(),currency:zod.z.string().length(3)});zod.z.object({quoteRef:zod.z.string().min(1).max(4096),ratePlanId:zod.z.string().min(1).max(200).optional(),attribution:zod.z.custom().optional()});var checkoutSessionSchema=zod.z.object({id:zod.z.uuid(),status:bookingRequestStatusResponseSchema,quote:checkoutSessionQuoteSchema,mount:checkoutMountDescriptorSchema.nullable(),chargedBy:chargedByHost.optional(),guestSaved:zod.z.literal(true).optional(),expiresAt:zod.z.iso.datetime()});var storefrontGuestInputSchema=zod.z.object({firstName:zod.z.string().trim().min(1,"validation.first_name_required").max(100),lastName:zod.z.string().trim().min(1,"validation.last_name_required").max(100),email:requiredTrimmedEmailField,phone:zod.z.string().trim().min(1,"validation.phone_required").max(40)});var storefrontConsentsSchema=zod.z.object({emailMarketing:zod.z.boolean().default(false),smsMarketing:zod.z.boolean().default(false)}).default({emailMarketing:false,smsMarketing:false});var confirmCheckoutSessionInputSchema=zod.z.object({quoteRef:zod.z.string().min(1).max(4096),guest:storefrontGuestInputSchema,consents:storefrontConsentsSchema,paymentMethodId:zod.z.string().min(1).max(255).optional(),language:zod.z.string().max(35).optional().catch(void 0)});confirmCheckoutSessionInputSchema.pick({quoteRef:true,guest:true,consents:true,language:true});zod.z.object({saved:zod.z.boolean()});var bookingResultSchema=zod.z.object({bookingRequestId:zod.z.uuid(),confirmationToken:zod.z.string(),status:bookingRequestStatusResponseSchema,confirmationCode:zod.z.string().nullable()});var storefrontBookingSchema=zod.z.object({id:zod.z.uuid(),status:bookingRequestStatusResponseSchema,propertyId:zod.z.uuid().nullable(),checkIn:zod.z.iso.date().nullable(),checkOut:zod.z.iso.date().nullable(),guestCount:zod.z.number().int().nullable(),guestFirstName:zod.z.string().nullable(),totalMinor:zod.z.number().int().nullable(),currency:zod.z.string().nullable(),confirmationCode:zod.z.string().nullable()});zod.z.uuid();var storefrontSiteSchema=zod.z.object({id:zod.z.uuid(),name:zod.z.string(),slug:zod.z.string(),isActive:zod.z.boolean(),enableWebChat:zod.z.boolean(),mapEmbedHost:zod.z.string().nullable(),countryCode:zod.z.string().nullish()});var storefrontListingSummarySchema=zod.z.object({id:zod.z.uuid(),buildingId:zod.z.uuid(),sortOrder:zod.z.number().int(),name:zod.z.string(),coverImageUrl:zod.z.string().nullable(),city:zod.z.string().nullable(),state:zod.z.string().nullable(),bedroomCount:zod.z.number().int().nullable(),bathroomCount:zod.z.number().nullable(),maxGuests:zod.z.number().int().nullable(),averageRating:zod.z.number().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),bookable:zod.z.boolean()});var storefrontListingSchema=storefrontListingSummarySchema.extend({buildingSlug:zod.z.string(),buildingAddress:zod.z.unknown(),description:zod.z.string().nullable(),amenities:zod.z.array(zod.z.string()),pictures:zod.z.unknown(),rooms:zod.z.unknown(),houseRules:zod.z.string().nullable(),checkInTime:zod.z.string().nullable(),checkOutTime:zod.z.string().nullable(),beds:zod.z.number().nullable(),fromPriceMinor:zod.z.number().int().nonnegative().nullish(),currency:zod.z.string().nullish(),countryCode:zod.z.string().nullish()});zod.z.object({location:zod.z.string().trim().min(1).max(200).optional(),building:zod.z.uuid().optional(),limit:zod.z.coerce.number().int().min(1).max(100).default(50),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0)});var storefrontBuildingSchema=zod.z.object({id:zod.z.uuid(),locationId:zod.z.uuid().nullable(),nameId:zod.z.uuid().nullable(),descriptionId:zod.z.uuid().nullable(),slug:zod.z.string(),imageId:zod.z.uuid().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),address:zod.z.unknown()});var storefrontLocationSchema=zod.z.object({id:zod.z.uuid(),type:zod.z.string(),parentId:zod.z.uuid().nullable(),nameId:zod.z.uuid().nullable(),slug:zod.z.string().nullable(),imageId:zod.z.uuid().nullable(),latitude:zod.z.number().nullable(),longitude:zod.z.number().nullable(),address:zod.z.unknown(),sortOrder:zod.z.number().int()});var storefrontReviewSchema=zod.z.object({id:zod.z.uuid(),listingId:zod.z.uuid().nullable(),reviewedAt:zod.z.string().nullable(),rating:zod.z.number().nullable(),publicReview:zod.z.string(),source:zod.z.string().nullable()});zod.z.object({listingId:zod.z.uuid().optional(),limit:zod.z.coerce.number().int().min(1).max(100).default(20),offset:zod.z.coerce.number().int().min(0).max(1e4).default(0)});zod.z.object({name:zod.z.string().trim().min(1,"validation.name_required").max(200,"validation.name_max_length"),email:requiredTrimmedEmailField,subject:zod.z.string().trim().min(1,"validation.title_required").max(300,"validation.title_max_length"),message:zod.z.string().trim().min(10,"validation.message_min_length").max(1e4,"validation.message_max_length")});var storefrontContactResultSchema=zod.z.object({sent:zod.z.literal(true)});zod.z.enum(chunkAIQUVZEI_cjs.STOREFRONT_KEY_ENVIRONMENTS);var STOREFRONT_KEY_RE=new RegExp(`^pk_(${chunkAIQUVZEI_cjs.STOREFRONT_KEY_ENVIRONMENTS.join("|")})_(${chunkAIQUVZEI_cjs.REGIONS.join("|")})_[0-9A-Za-z]{24}$`);function parseStorefrontKey(token){const match=STOREFRONT_KEY_RE.exec(token);if(!match)return null;return {environment:match[1],region:match[2]}}var ORIGIN_HOST_RE=/^(?:[a-z0-9-]+\.)*[a-z0-9-]+$|^\[[0-9a-f:.]+\]$/;function parseUrl(value){try{return new URL(value)}catch{return null}}zod.z.string().refine(value=>{const url=parseUrl(value);if(!url)return false;return (url.protocol==="https:"||url.protocol==="http:")&&url.origin===value&&ORIGIN_HOST_RE.test(url.hostname)},"validation.storefront.origin_invalid");var CLIENT_CONVERSION_EVENT_NAMES=["begin_checkout","generate_lead","sign_up"];var STOREFRONT_EVENT_PATH_MAX=512;var base={eventId:zod.z.uuid(),ts:zod.z.number().int(),path:zod.z.string().max(STOREFRONT_EVENT_PATH_MAX),referrerHost:zod.z.string().max(253).nullable()};var currency2=zod.z.string().length(3).regex(/^[a-z]{3}$/);var storefrontClientEventSchema=zod.z.discriminatedUnion("name",[zod.z.object({...base,name:zod.z.literal("page_view")}),zod.z.object({...base,name:zod.z.literal("view_search_results"),checkIn:chunkLVFRVNT3_cjs.storefrontDateSchema.optional(),checkOut:chunkLVFRVNT3_cjs.storefrontDateSchema.optional(),guests:zod.z.number().int().min(1).max(50).optional(),locationId:zod.z.uuid().optional()}),zod.z.object({...base,name:zod.z.literal("view_item_list"),listName:zod.z.string().max(64),itemCount:zod.z.number().int().min(0).max(500)}),zod.z.object({...base,name:zod.z.literal("view_item"),listingId:zod.z.uuid()}),zod.z.object({...base,name:zod.z.literal("view_quote"),listingId:zod.z.uuid(),valueMinor:zod.z.number().int().nonnegative(),currency:currency2,nights:zod.z.number().int().min(1).max(365)}),zod.z.object({...base,name:zod.z.literal("begin_checkout"),checkoutSessionId:zod.z.uuid()}),zod.z.object({...base,name:zod.z.literal("add_payment_info"),checkoutSessionId:zod.z.uuid()}),zod.z.object({...base,name:zod.z.literal("generate_lead"),formId:zod.z.string().max(64).optional()}),zod.z.object({...base,name:zod.z.literal("sign_up"),method:zod.z.literal("newsletter")})]);var STOREFRONT_EVENT_BATCH_MAX=20;zod.z.object({events:zod.z.array(storefrontClientEventSchema).min(1).max(STOREFRONT_EVENT_BATCH_MAX)});zod.z.object({events:zod.z.array(zod.z.object({eventId:zod.z.uuid(),name:zod.z.enum(CLIENT_CONVERSION_EVENT_NAMES),occurredAt:zod.z.iso.datetime(),pageUrl:zod.z.url({protocol:/^https?$/}).max(2048),checkoutSessionId:zod.z.uuid().nullable(),userAgent:zod.z.string().max(512).nullable(),attribution:storefrontAttributionInputSchema.nullable()})).min(1).max(STOREFRONT_EVENT_BATCH_MAX)});var EXPERIMENT_COOKIE="__so_exp";var COOKIE_RE=/(?:^|;\s*)__so_exp=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.(a|b)(?:\s*;|\s*$)/;function readExperimentCookie(cookies){const match=COOKIE_RE.exec(cookies??"");return match?{id:match[1],variant:match[2]}:null}var ATTRIBUTION_COOKIE="so_attr";var ATTRIBUTION_COOKIE_MAX_AGE_SECONDS=90*24*60*60;var COOKIE_SCOPE="Path=/; SameSite=Lax; Secure";var ATTRIBUTION_COOKIE_ATTRIBUTES=`Max-Age=${ATTRIBUTION_COOKIE_MAX_AGE_SECONDS}; ${COOKIE_SCOPE}`;var ATTRIBUTION_COOKIE_MAX_BYTES=3584;var attributionCookieSchema=zod.z.object({first:attributionTouchSchema.nullable(),last:attributionTouchSchema.nullable()});function toBase64Url(text){let binary="";for(const byte of new TextEncoder().encode(text))binary+=String.fromCharCode(byte);return btoa(binary).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function fromBase64Url(value){const binary=atob(value.replace(/-/g,"+").replace(/_/g,"/"));return new TextDecoder().decode(Uint8Array.from(binary,ch=>ch.charCodeAt(0)))}function encodeAttributionCookie(value){const encoded=toBase64Url(JSON.stringify(value));return encoded.length>ATTRIBUTION_COOKIE_MAX_BYTES?null:encoded}function serializeAttributionCookie(value){const encoded=encodeAttributionCookie(value);return encoded===null?null:`${ATTRIBUTION_COOKIE}=${encoded}; ${ATTRIBUTION_COOKIE_ATTRIBUTES}`}function decodeAttributionCookie(value){if(!value)return null;return attributionCookieSchema.parse(JSON.parse(fromBase64Url(value)))}function expiredAttributionCookies(cookies,consent){const revoked=[...consent.analytics?[]:[ATTRIBUTION_COOKIE,EXPERIMENT_COOKIE],...consent.ads?[]:["_fbc","_fbp"]];return revoked.filter(name=>readCookie(cookies,name)!==null).map(name=>`${name}=; Max-Age=0; ${COOKIE_SCOPE}`)}function strippedAttributionCookie(held){const clicked=t=>t!==null&&[t.gclid,t.gbraid,t.wbraid,t.fbclid,t.msclkid].some(id=>id!==null);if(!held||!(clicked(held.first)||clicked(held.last)))return null;return serializeAttributionCookie({first:held.first&&withoutClickIds(held.first),last:held.last&&withoutClickIds(held.last)})??`${ATTRIBUTION_COOKIE}=; Max-Age=0; ${COOKIE_SCOPE}`}function readCookie(header,name){if(!header)return null;for(const part of header.split(";")){const eq=part.indexOf("=");if(eq!==-1&&part.slice(0,eq).trim()===name)return part.slice(eq+1).trim()}return null}var MalformedCookieError=class extends Error{constructor(name){super(`${name} is malformed`);this.name="MalformedAttributionError";}};var NO_IDS={gaClientId:null,gaSessionId:null,fbp:null,fbc:null};function matchCookie(cookies,name,re,report){const value=name?readCookie(cookies,name):null;if(!value)return null;const match=re.exec(value);if(!match){report(new MalformedCookieError(name),name);return null}return match.slice(1).filter(Boolean).join(".")}function browserIdsFromCookies(cookies,consent,report){const sessionCookie=cookies.split(";").map(part=>part.split("=")[0].trim()).find(name=>name.startsWith("_ga_"))??null;const ga=consent.analytics;const ads=consent.ads;const ids={gaClientId:ga?matchCookie(cookies,"_ga",/^GA\d\.\d+\.(\d+)\.(\d+)$/,report):null,gaSessionId:ga?matchCookie(cookies,sessionCookie,/^(?:GS1\.\d+\.(\d+)\.|GS2\.\d+\.s(\d+)(?:\$|$))/,report):null,fbp:ads?matchCookie(cookies,"_fbp",/^(fb\.\d\.\d+\.\d+)$/,report):null,fbc:ads?matchCookie(cookies,"_fbc",/^(fb\.\d\.\d+\.[\w-]+)$/,report):null};const parsed=attributionIdsSchema.safeParse(ids);if(parsed.success)return parsed.data;report(parsed.error,"ids");return NO_IDS}var isDirect=touch=>classifyChannel({...touch,siteHost:globalThis.location?.hostname??""}).channel==="direct";var TOUCH_ELEMENT_ID="__suiteop_touch";var CONSENT_EVENT="suiteop:consent";var DENIED={analytics:false,ads:false,source:"default",region:"restricted",decidedAt:null};var defaultReport=(err,where)=>{console.warn(`[suiteop] ignored malformed attribution input (${where})`,err);};function pageConsent(){const read=globalThis.__suiteop?.consent?.get;const parsed=consentStateSchema.safeParse(typeof read==="function"?read():null);return parsed.success?parsed.data:DENIED}function pageTouch(report){const text=document.getElementById(TOUCH_ELEMENT_ID)?.textContent;if(!text)return null;try{return attributionTouchSchema.parse(JSON.parse(text))}catch(err){report(err,TOUCH_ELEMENT_ID);return null}}function storedCookie(cookies,report){try{return decodeAttributionCookie(readCookie(cookies,ATTRIBUTION_COOKIE))}catch(err){report(err,ATTRIBUTION_COOKIE);return null}}function getAttribution(opts={}){if(typeof document==="undefined")return null;const report=opts.report??defaultReport;const cookies=document.cookie;const consent=pageConsent();const stored=consent.analytics?storedCookie(cookies,report):null;const touch=pageTouch(report);const pageIsLast=touch!==null&&!(stored?.last&&(isDirect(touch)||Date.parse(stored.last.ts)>Date.parse(touch.ts)));const experiment=consent.analytics?readExperimentCookie(cookies):null;return {first:stored?.first??touch,last:pageIsLast?touch:stored?.last??null,ids:browserIdsFromCookies(cookies,consent,report),consent,...experiment?{experiment}:{}}}function watchAttributionConsent(opts={}){if(typeof window==="undefined")return ()=>{};const report=opts.report??defaultReport;const persist=consent=>{if(readCookie(document.cookie,ATTRIBUTION_COOKIE))return;const touch=pageTouch(report);if(!touch)return;const kept=consent.ads?touch:withoutClickIds(touch);const cookie=serializeAttributionCookie({first:kept,last:kept});if(cookie)document.cookie=cookie;};const withdraw=consent=>{for(const cookie of expiredAttributionCookies(document.cookie,consent)){document.cookie=cookie;}if(consent.analytics&&!consent.ads){const stripped=strippedAttributionCookie(storedCookie(document.cookie,report));if(stripped)document.cookie=stripped;}};const initial=pageConsent();let analytics=initial.analytics;if(initial.source==="user")withdraw(initial);if(analytics)persist(initial);const onConsent=event=>{const next=consentStateSchema.safeParse(event.detail);if(!next.success)return;const granted=!analytics&&next.data.analytics;analytics=next.data.analytics;withdraw(next.data);if(granted)persist(next.data);};window.addEventListener(CONSENT_EVENT,onConsent);return ()=>window.removeEventListener(CONSENT_EVENT,onConsent)}var EVENTS_ENDPOINT="/_suiteop/events";var FLUSH_INTERVAL_MS=2e3;var FLUSH_AT_EVENTS=10;var defaultReport2=err=>{console.warn("[suiteop] storefront events could not be sent",err);};function hostOf2(url){try{return new URL(url).hostname||null}catch{return null}}var META_EVENTS={begin_checkout:"InitiateCheckout",generate_lead:"Lead",sign_up:"CompleteRegistration",view_item:"ViewContent",view_search_results:"Search",add_payment_info:"AddPaymentInfo"};var GTAG_SKIP=new Set(["page_view","purchase"]);function mirrorToTags(event){const w=window;if(typeof w.gtag!=="function"&&typeof w.fbq!=="function")return;const consent=pageConsent();const{name,eventId,ts:_ts,path:_path,referrerHost:_ref,...params}=event;if(consent.analytics&&typeof w.gtag==="function"&&!GTAG_SKIP.has(name)){w.gtag("event",name,params);}const metaName=META_EVENTS[name];if(consent.ads&&typeof w.fbq==="function"&&metaName){w.fbq("track",metaName,{},{eventID:eventId});}}function trackPurchasePixel(booking){if(typeof window==="undefined")return;const fbq=window.fbq;if(typeof fbq!=="function"||!pageConsent().ads)return;const amount=typeof booking.totalMinor==="number"&&booking.currency?{value:booking.totalMinor/100,currency:booking.currency.toUpperCase()}:{};fbq("track","Purchase",amount,{eventID:booking.bookingRequestId});}var NOOP={track(){},pageView(){},flush(){},dispose(){}};function createAnalytics(opts){if(typeof window==="undefined")return NOOP;const report=opts.report??defaultReport2;const url=`${EVENTS_ENDPOINT}?key=${encodeURIComponent(opts.publishableKey)}`;let queue=[];let timer=null;let landing=true;let lastViewedHref=null;let disabled=false;let reported=false;const fail=err=>{if(reported)return;reported=true;report(err);};const send=(events,beacon)=>{const body=JSON.stringify({events});if(beacon&&typeof navigator.sendBeacon==="function"&&navigator.sendBeacon(url,body)){return}fetch(url,{method:"POST",body,keepalive:true,credentials:"same-origin",headers:{"content-type":"application/json"}}).then(response=>{if(response.status===404)disabled=true;else if(!response.ok)fail(new Error(`storefront events answered ${response.status}`));}).catch(fail);};const flush=({beacon=false}={})=>{if(timer)clearTimeout(timer);timer=null;if(disabled||queue.length===0)return;const pending=queue;queue=[];for(let i=0;i<pending.length;i+=STOREFRONT_EVENT_BATCH_MAX){send(pending.slice(i,i+STOREFRONT_EVENT_BATCH_MAX),beacon);}};const enqueue=(event,referrerHost)=>{const full={...event,eventId:crypto.randomUUID(),ts:Date.now(),path:location.pathname.slice(0,STOREFRONT_EVENT_PATH_MAX),referrerHost};try{mirrorToTags(full);}catch(err){fail(err);}if(disabled)return;queue.push(full);if(queue.length>=FLUSH_AT_EVENTS)flush();else timer??=setTimeout(()=>flush(),FLUSH_INTERVAL_MS);};const pageView=()=>{if(location.href===lastViewedHref)return;lastViewedHref=location.href;const referrerHost=landing?hostOf2(document.referrer):location.hostname;landing=false;enqueue({name:"page_view"},referrerHost);};const onPageHide=()=>flush({beacon:true});const onPageShow=event=>{if(!event.persisted)return;lastViewedHref=null;pageView();};window.addEventListener("pagehide",onPageHide);window.addEventListener("pageshow",onPageShow);return {track:event=>enqueue(event,location.hostname),pageView,flush,dispose:()=>{flush({beacon:true});window.removeEventListener("pagehide",onPageHide);window.removeEventListener("pageshow",onPageShow);}}}var shared=new Map;function analyticsFor(publishableKey){let instance=shared.get(publishableKey);if(!instance){instance=createAnalytics({publishableKey});if(instance!==NOOP)shared.set(publishableKey,instance);}return instance}function parsePublishableKey(key){if(typeof key==="string"&&key.trim().startsWith("sk_")){throw new chunkXIAAWHAY_cjs.StorefrontConfigError("A SuiteOp secret key (sk_\u2026) was passed as the publishable key. Secret keys must never be used in a browser or shipped in site code \u2014 revoke it now, then use a publishable key (pk_live_\u2026 / pk_test_\u2026) from the site settings.")}const parsed=typeof key==="string"?parseStorefrontKey(key.trim()):null;if(!parsed){throw new chunkXIAAWHAY_cjs.StorefrontConfigError("Invalid SuiteOp publishable key: expected pk_{live|test}_{us|eu|apac}_ followed by 24 letters or digits.")}return parsed}function defaultApiOrigin({environment,region}){return environment==="live"?`https://api-${region}.suiteop.com`:`https://api-${region}-staging.suiteop.com`}var SDK_VERSION="0.1.1";var STOREFRONT_API_VERSION="2026-09-27";var GET_RETRY_JITTER_MS=300;function buildUrl(base2,spec){const params=new URLSearchParams;for(const[key,value]of Object.entries(spec.query??{})){if(value!==void 0&&value!==null)params.set(key,String(value));}const search=params.toString();return `${base2}${spec.path}${search?`?${search}`:""}`}function sleep(ms,signal){return new Promise((resolve,reject)=>{if(signal?.aborted)return reject(signal.reason);const onAbort=()=>{clearTimeout(timer);reject(signal?.reason);};const timer=setTimeout(()=>{signal?.removeEventListener("abort",onAbort);resolve();},ms);signal?.addEventListener("abort",onAbort,{once:true});})}function parseJson(text){if(!text)return void 0;try{return JSON.parse(text)}catch{return void 0}}function isRetryable(err){return err instanceof chunkXIAAWHAY_cjs.StorefrontNetworkError||err instanceof chunkXIAAWHAY_cjs.StorefrontError&&err.status>=500}function createTransport(opts){async function attempt(spec){const controller=new AbortController;let timedOut=false;const timer=setTimeout(()=>{timedOut=true;controller.abort(new DOMException("The request timed out","TimeoutError"));},spec.timeoutMs);const onCallerAbort=()=>controller.abort(spec.signal?.reason);if(spec.signal?.aborted)onCallerAbort();else spec.signal?.addEventListener("abort",onCallerAbort,{once:true});try{let response;let text;try{response=await opts.fetch(buildUrl(opts.baseUrl(),spec),{method:spec.method,headers:{...opts.headers,...spec.body===void 0?{}:{"Content-Type":"application/json"},...spec.headers},body:spec.body===void 0?void 0:JSON.stringify(spec.body),signal:controller.signal});text=await response.text();}catch(err){if(spec.signal?.aborted)throw spec.signal.reason;if(timedOut)throw new chunkXIAAWHAY_cjs.StorefrontTimeoutError(spec.timeoutMs);throw new chunkXIAAWHAY_cjs.StorefrontNetworkError(err)}const body=parseJson(text);if(!response.ok)throw chunkXIAAWHAY_cjs.errorFromResponse(response,body);const envelope=body;const meta=envelope?.meta??{};const requestId=typeof meta["requestId"]==="string"?meta["requestId"]:response.headers.get("x-request-id");if(!envelope||typeof envelope!=="object"||!("data"in envelope)){throw new chunkXIAAWHAY_cjs.StorefrontError({status:response.status,code:"invalid_response",message:"The Storefront API answered without a data envelope",requestId})}return {status:response.status,requestId,data:envelope.data,meta}}finally{clearTimeout(timer);spec.signal?.removeEventListener("abort",onCallerAbort);}}return {async send(spec){try{return await attempt(spec)}catch(err){if(spec.method!=="GET"||!isRetryable(err))throw err;await sleep(Math.random()*GET_RETRY_JITTER_MS,spec.signal);return attempt(spec)}}}}var STOREFRONT_API_PATH="/api/storefront/v1";var READ_TIMEOUT_MS=1e4;var WRITE_TIMEOUT_MS=2e4;function resolveBaseUrl(baseUrl,origin){if(baseUrl===void 0)return `${origin}${STOREFRONT_API_PATH}`;if(baseUrl==="same-origin"){const pageOrigin=globalThis.location?.origin;if(!pageOrigin||pageOrigin==="null"){throw new chunkXIAAWHAY_cjs.StorefrontConfigError("baseUrl 'same-origin' needs a page origin; pass an explicit baseUrl outside a browser.")}return `${pageOrigin}${STOREFRONT_API_PATH}`}let url;try{url=new URL(baseUrl);}catch{throw new chunkXIAAWHAY_cjs.StorefrontConfigError(`baseUrl must be an absolute URL or 'same-origin'.`)}const path=url.pathname.replace(/\/+$/,"");return `${url.origin}${path.endsWith(STOREFRONT_API_PATH)?path:`${path}${STOREFRONT_API_PATH}`}`}function uuidV4(){const c=globalThis.crypto;if(typeof c.randomUUID==="function")return c.randomUUID();const b=c.getRandomValues(new Uint8Array(16));b[6]=b[6]&15|64;b[8]=b[8]&63|128;const hex=Array.from(b,x=>x.toString(16).padStart(2,"0")).join("");return `${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`}function validate(schema,value,res){const parsed=schema.safeParse(value);if(parsed.success)return parsed.data;throw new chunkXIAAWHAY_cjs.StorefrontError({status:res.status,code:"invalid_response",message:"The Storefront API answered a shape this SDK version does not understand",requestId:res.requestId,details:{issues:parsed.error.issues.map(i=>({path:i.path,code:i.code}))}})}var paginationSchema=zod.z.object({total:zod.z.number().int(),limit:zod.z.number().int(),offset:zod.z.number().int()});var seg=value=>encodeURIComponent(value);var slotOf=(quoteRef,ratePlanId)=>`${quoteRef}\0${ratePlanId??""}`;var RELEASED_SESSION_STATUSES=new Set(["expired","cancelled"]);var KEY_BOUND_ELSEWHERE="idempotency_key_reused";function endsSession(err){return err.code==="session_expired"||err.details["requiresNewSession"]===true}var attributionWatched=false;function createStorefrontClient(options){const key=parsePublishableKey(options.publishableKey);const baseUrl=resolveBaseUrl(options.baseUrl,defaultApiOrigin(key));const transport=createTransport({baseUrl:()=>baseUrl,fetch:(input,init)=>(options.fetch??globalThis.fetch)(input,init),headers:{Authorization:`Bearer ${options.publishableKey.trim()}`,Accept:"application/json","X-SuiteOp-SDK":`storefront-js/${SDK_VERSION}`,"X-SuiteOp-Api-Version":STOREFRONT_API_VERSION,...options.locale?{"Accept-Language":options.locale}:{}}});const keySlots=new Map;const sessionSlots=new Map;const release=(slot,key2)=>{if(keySlots.get(slot)===key2)keySlots.delete(slot);};const releaseSession=id=>{const entry=sessionSlots.get(id);if(!entry)return;sessionSlots.delete(id);release(...entry);};if(!attributionWatched&&typeof window!=="undefined"){attributionWatched=true;watchAttributionConsent();}const readTimeoutMs=options.timeoutMs??READ_TIMEOUT_MS;const writeTimeoutMs=options.timeoutMs??WRITE_TIMEOUT_MS;async function get(schema,path,opts,query){const res=await transport.send({method:"GET",path,query,timeoutMs:readTimeoutMs,signal:opts?.signal});return validate(schema,res.data,res)}async function post(schema,path,body,opts,headers){const res=await transport.send({method:"POST",path,body,headers,timeoutMs:writeTimeoutMs,signal:opts?.signal});return validate(schema,res.data,res)}return {publishableKey:options.publishableKey.trim(),baseUrl,site:{get:opts=>get(storefrontSiteSchema,"/site",opts)},listings:{async list(query,opts){const res=await transport.send({method:"GET",path:"/listings",query:{location:query?.location,building:query?.building,limit:query?.limit,offset:query?.offset},timeoutMs:readTimeoutMs,signal:opts?.signal});const items=validate(zod.z.array(storefrontListingSummarySchema),res.data,res);const pagination=validate(paginationSchema,res.meta["pagination"],res);return {items,...pagination}},get:(id,opts)=>get(storefrontListingSchema,`/listings/${seg(id)}`,opts)},buildings:{list:opts=>get(zod.z.array(storefrontBuildingSchema),"/buildings",opts),get:(id,opts)=>get(storefrontBuildingSchema,`/buildings/${seg(id)}`,opts)},locations:{list:opts=>get(zod.z.array(storefrontLocationSchema),"/locations",opts)},amenities:{list:opts=>get(zod.z.array(zod.z.string()),"/amenities",opts)},reviews:{list:(query,opts)=>get(zod.z.array(storefrontReviewSchema),"/reviews",opts,{listingId:query?.listingId,limit:query?.limit,offset:query?.offset})},availability:{get:(listingId,stay,opts)=>get(chunkLVFRVNT3_cjs.storefrontAvailabilitySchema,`/listings/${seg(listingId)}/availability`,opts,{checkIn:stay.checkIn,checkOut:stay.checkOut,guests:stay.guests})},calendar:{get:(listingId,range,opts)=>get(chunkLVFRVNT3_cjs.storefrontCalendarSchema,`/listings/${seg(listingId)}/calendar`,opts,{from:range.from,to:range.to})},quotes:{create:(input,opts)=>post(chunkXIAAWHAY_cjs.storefrontQuoteSchema,"/quotes",input,opts)},checkoutSessions:{async create(input,opts){const slot=slotOf(input.quoteRef,input.ratePlanId);const idempotencyKey=opts?.idempotencyKey??keySlots.get(slot)??uuidV4();keySlots.set(slot,idempotencyKey);const attribution=input.attribution===void 0?getAttribution():input.attribution;const body=attribution?{...input,attribution}:input;try{const created=await post(checkoutSessionSchema,"/checkout-sessions",body,opts,{"Idempotency-Key":idempotencyKey});if(RELEASED_SESSION_STATUSES.has(created.status))release(slot,idempotencyKey);else sessionSlots.set(created.id,[slot,idempotencyKey]);return {...created,idempotencyKey}}catch(err){if(err instanceof chunkXIAAWHAY_cjs.StorefrontError){err.details["idempotencyKey"]=idempotencyKey;if(err.code===KEY_BOUND_ELSEWHERE)release(slot,idempotencyKey);}throw err}},get:(id,opts)=>get(checkoutSessionSchema,`/checkout-sessions/${seg(id)}`,opts),async confirm(id,input,opts){try{const result=await post(bookingResultSchema,`/checkout-sessions/${seg(id)}/confirm`,input,opts);return result}catch(err){if(err instanceof chunkXIAAWHAY_cjs.StorefrontError&&endsSession(err)){releaseSession(id);}throw err}},forget(quoteRef,ratePlanId){keySlots.delete(slotOf(quoteRef,ratePlanId));}},bookings:{get:(token,opts)=>get(storefrontBookingSchema,`/bookings/${seg(token)}`,opts)},contact:{async create(input,opts){await post(storefrontContactResultSchema,"/contact",input,opts);}}}}
|
|
9
|
-
|
|
10
|
-
exports.SDK_VERSION = SDK_VERSION;
|
|
11
|
-
exports.STOREFRONT_API_PATH = STOREFRONT_API_PATH;
|
|
12
|
-
exports.STOREFRONT_API_VERSION = STOREFRONT_API_VERSION;
|
|
13
|
-
exports.analyticsFor = analyticsFor;
|
|
14
|
-
exports.createAnalytics = createAnalytics;
|
|
15
|
-
exports.createStorefrontClient = createStorefrontClient;
|
|
16
|
-
exports.getAttribution = getAttribution;
|
|
17
|
-
exports.parsePublishableKey = parsePublishableKey;
|
|
18
|
-
exports.trackPurchasePixel = trackPurchasePixel;
|