@cimplify/sdk 0.67.0 → 0.69.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/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-SSLFZPAI.js → chunk-5HAUJBOK.js} +35 -35
- package/dist/{chunk-FNK6UZOE.mjs → chunk-5UYNERYE.mjs} +2 -2
- package/dist/{chunk-SXGFJEME.js → chunk-I4MP2XZS.js} +73 -7
- package/dist/{chunk-JAPCAZN4.mjs → chunk-KNPE4WCQ.mjs} +1 -1
- package/dist/{chunk-FVGVJ4TC.mjs → chunk-O3ECKVOM.mjs} +73 -7
- package/dist/{chunk-QQMDEGAK.mjs → chunk-SOV4H6PQ.mjs} +177 -50
- package/dist/{chunk-SH6HJW4A.js → chunk-TBSDZN2W.js} +4 -4
- package/dist/{chunk-3QSW33RG.js → chunk-WCSAZRNC.js} +179 -49
- package/dist/{client-DVFQoDtI.d.ts → client-CO2s-kxY.d.ts} +57 -19
- package/dist/{client-CQlEWH5j.d.ts → client-DUpz-PGs.d.ts} +1 -1
- package/dist/{client-Dd82KQ_G.d.mts → client-DZ-nbVnb.d.mts} +1 -1
- package/dist/{client-ByI_3jfL.d.mts → client-K_n5ceLI.d.mts} +57 -19
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +89 -72
- package/dist/index.mjs +15 -10
- package/dist/mock/cli.mjs +73 -7
- package/dist/mock/library.js +73 -7
- package/dist/mock/library.mjs +73 -7
- package/dist/mock/msw.js +73 -7
- package/dist/mock/msw.mjs +73 -7
- package/dist/react.d.mts +197 -40
- package/dist/react.d.ts +197 -40
- package/dist/react.js +1241 -567
- package/dist/react.mjs +824 -155
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/{sign-in-RFuWZOgF.d.mts → sign-in-DQlIdqsi.d.mts} +8 -0
- package/dist/{sign-in-RFuWZOgF.d.ts → sign-in-DQlIdqsi.d.ts} +8 -0
- package/dist/styles.css +1 -1
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +17 -17
- package/dist/testing.d.ts +17 -17
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/package.json +1 -1
- package/registry/index.json +0 -9
- package/registry/account.json +0 -15
package/dist/react.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkIQLJJW2H_js = require('./chunk-IQLJJW2H.js');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunk5HAUJBOK_js = require('./chunk-5HAUJBOK.js');
|
|
6
|
+
var chunkWCSAZRNC_js = require('./chunk-WCSAZRNC.js');
|
|
7
7
|
var chunk7Y2O3E4D_js = require('./chunk-7Y2O3E4D.js');
|
|
8
8
|
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
9
9
|
require('./chunk-OWW5GUSB.js');
|
|
10
|
-
var
|
|
10
|
+
var React14 = require('react');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
12
|
var clsx = require('clsx');
|
|
13
13
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -27,7 +27,7 @@ var input = require('@base-ui/react/input');
|
|
|
27
27
|
|
|
28
28
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var React14__default = /*#__PURE__*/_interopDefault(React14);
|
|
31
31
|
|
|
32
32
|
// src/ads/identity.ts
|
|
33
33
|
var COOKIE_NAME = "_cimplify_uid";
|
|
@@ -204,7 +204,7 @@ function deriveAdsApiUrl() {
|
|
|
204
204
|
}
|
|
205
205
|
return "https://api.cimplify.io";
|
|
206
206
|
}
|
|
207
|
-
var AdContext =
|
|
207
|
+
var AdContext = React14.createContext({
|
|
208
208
|
siteId: null,
|
|
209
209
|
config: null,
|
|
210
210
|
isLoading: true,
|
|
@@ -212,7 +212,7 @@ var AdContext = React12.createContext({
|
|
|
212
212
|
apiBase: "https://api.cimplify.io"
|
|
213
213
|
});
|
|
214
214
|
function useAds() {
|
|
215
|
-
return
|
|
215
|
+
return React14.useContext(AdContext);
|
|
216
216
|
}
|
|
217
217
|
function AdProvider({
|
|
218
218
|
siteId,
|
|
@@ -221,10 +221,10 @@ function AdProvider({
|
|
|
221
221
|
children
|
|
222
222
|
}) {
|
|
223
223
|
const resolvedApiBase = apiBase || deriveAdsApiUrl();
|
|
224
|
-
const [config, setConfig] =
|
|
225
|
-
const [isLoading, setIsLoading] =
|
|
226
|
-
const [identity, setIdentity] =
|
|
227
|
-
|
|
224
|
+
const [config, setConfig] = React14.useState(null);
|
|
225
|
+
const [isLoading, setIsLoading] = React14.useState(true);
|
|
226
|
+
const [identity, setIdentity] = React14.useState(null);
|
|
227
|
+
React14.useEffect(() => {
|
|
228
228
|
const userIdentity = getUserIdentity(authenticatedAccountId);
|
|
229
229
|
setIdentity(userIdentity);
|
|
230
230
|
fetch(`${resolvedApiBase}/ads/config/${siteId}`).then((r) => r.json()).then((data) => {
|
|
@@ -247,11 +247,11 @@ function Ad({
|
|
|
247
247
|
onClick
|
|
248
248
|
}) {
|
|
249
249
|
const { siteId, config, isLoading, identity, apiBase } = useAds();
|
|
250
|
-
const [ad, setAd] =
|
|
251
|
-
const [error, setError] =
|
|
252
|
-
const impressionTracked =
|
|
253
|
-
const containerRef =
|
|
254
|
-
|
|
250
|
+
const [ad, setAd] = React14.useState(null);
|
|
251
|
+
const [error, setError] = React14.useState(false);
|
|
252
|
+
const impressionTracked = React14.useRef(false);
|
|
253
|
+
const containerRef = React14.useRef(null);
|
|
254
|
+
React14.useEffect(() => {
|
|
255
255
|
if (isLoading || !config?.enabled || !siteId || !identity) return;
|
|
256
256
|
const path = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
257
257
|
const referrer = typeof document !== "undefined" ? document.referrer : "";
|
|
@@ -294,7 +294,7 @@ function Ad({
|
|
|
294
294
|
}
|
|
295
295
|
}).catch(() => setError(true));
|
|
296
296
|
}, [siteId, config, isLoading, slot, identity, apiBase]);
|
|
297
|
-
|
|
297
|
+
React14.useEffect(() => {
|
|
298
298
|
if (!ad || impressionTracked.current || typeof window === "undefined" || !identity) return;
|
|
299
299
|
const observer = new IntersectionObserver(
|
|
300
300
|
([entry]) => {
|
|
@@ -623,7 +623,7 @@ function applyCartPatch(base, patch) {
|
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
function useCollectionStore(collection) {
|
|
626
|
-
return
|
|
626
|
+
return React14.useSyncExternalStore(
|
|
627
627
|
(listener) => collection.subscribe(listener),
|
|
628
628
|
() => collection.getSnapshot(),
|
|
629
629
|
() => collection.getSnapshot()
|
|
@@ -993,7 +993,7 @@ function useCart(options = {}) {
|
|
|
993
993
|
const locationId = options.locationId ?? client.getLocationId();
|
|
994
994
|
const currency = options.currency ?? context?.currency ?? "USD";
|
|
995
995
|
const optimisticEnabled = context?.optimistic ?? true;
|
|
996
|
-
const entry =
|
|
996
|
+
const entry = React14.useMemo(
|
|
997
997
|
() => getOrCreateStore({
|
|
998
998
|
client,
|
|
999
999
|
locationId,
|
|
@@ -1003,44 +1003,44 @@ function useCart(options = {}) {
|
|
|
1003
1003
|
[client, currency, locationId, optimisticEnabled]
|
|
1004
1004
|
);
|
|
1005
1005
|
const view = useCollectionStore(entry.collection);
|
|
1006
|
-
|
|
1006
|
+
React14.useEffect(() => {
|
|
1007
1007
|
void ensureInitialized(entry);
|
|
1008
1008
|
}, [entry]);
|
|
1009
|
-
const addItem =
|
|
1009
|
+
const addItem = React14.useCallback(
|
|
1010
1010
|
async (product, quantity, addOptions) => {
|
|
1011
1011
|
await performAddItem(entry, product, quantity ?? 1, addOptions ?? {});
|
|
1012
1012
|
},
|
|
1013
1013
|
[entry]
|
|
1014
1014
|
);
|
|
1015
|
-
const removeItem =
|
|
1015
|
+
const removeItem = React14.useCallback(
|
|
1016
1016
|
async (itemId) => {
|
|
1017
1017
|
await performRemoveItem(entry, itemId);
|
|
1018
1018
|
},
|
|
1019
1019
|
[entry]
|
|
1020
1020
|
);
|
|
1021
|
-
const updateQuantity =
|
|
1021
|
+
const updateQuantity = React14.useCallback(
|
|
1022
1022
|
async (itemId, quantity) => {
|
|
1023
1023
|
await performUpdateQuantity(entry, itemId, quantity);
|
|
1024
1024
|
},
|
|
1025
1025
|
[entry]
|
|
1026
1026
|
);
|
|
1027
|
-
const clearCart =
|
|
1027
|
+
const clearCart = React14.useCallback(async () => {
|
|
1028
1028
|
await performClear(entry);
|
|
1029
1029
|
}, [entry]);
|
|
1030
|
-
const sync =
|
|
1030
|
+
const sync = React14.useCallback(async () => {
|
|
1031
1031
|
await syncFromServer(entry);
|
|
1032
1032
|
}, [entry]);
|
|
1033
|
-
const reorder =
|
|
1033
|
+
const reorder = React14.useCallback(
|
|
1034
1034
|
async (orderId) => {
|
|
1035
1035
|
return performReorder(entry, orderId);
|
|
1036
1036
|
},
|
|
1037
1037
|
[entry]
|
|
1038
1038
|
);
|
|
1039
|
-
const itemCount =
|
|
1039
|
+
const itemCount = React14.useMemo(
|
|
1040
1040
|
() => view.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
1041
1041
|
[view.items]
|
|
1042
1042
|
);
|
|
1043
|
-
return
|
|
1043
|
+
return React14.useMemo(
|
|
1044
1044
|
() => ({
|
|
1045
1045
|
items: view.items,
|
|
1046
1046
|
itemCount,
|
|
@@ -1086,7 +1086,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1086
1086
|
function createDefaultClient() {
|
|
1087
1087
|
const processRef = globalThis.process;
|
|
1088
1088
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1089
|
-
return
|
|
1089
|
+
return chunk5HAUJBOK_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1090
1090
|
}
|
|
1091
1091
|
function getStoredLocationId() {
|
|
1092
1092
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -1143,30 +1143,30 @@ function resolveInitialLocation(locations) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
return locations[0];
|
|
1145
1145
|
}
|
|
1146
|
-
var CimplifyClientContext =
|
|
1147
|
-
var CimplifyStateContext =
|
|
1146
|
+
var CimplifyClientContext = React14.createContext(null);
|
|
1147
|
+
var CimplifyStateContext = React14.createContext(null);
|
|
1148
1148
|
function CimplifyProvider({
|
|
1149
1149
|
client,
|
|
1150
1150
|
children,
|
|
1151
1151
|
onLocationChange,
|
|
1152
1152
|
optimistic = true
|
|
1153
1153
|
}) {
|
|
1154
|
-
const resolvedClient =
|
|
1155
|
-
const onLocationChangeRef =
|
|
1156
|
-
const [business, setBusiness] =
|
|
1157
|
-
const [locations, setLocations] =
|
|
1158
|
-
const [currentLocation, setCurrentLocationState] =
|
|
1159
|
-
const [isReady, setIsReady] =
|
|
1160
|
-
|
|
1154
|
+
const resolvedClient = React14.useMemo(() => client ?? createDefaultClient(), [client]);
|
|
1155
|
+
const onLocationChangeRef = React14.useRef(onLocationChange);
|
|
1156
|
+
const [business, setBusiness] = React14.useState(null);
|
|
1157
|
+
const [locations, setLocations] = React14.useState([]);
|
|
1158
|
+
const [currentLocation, setCurrentLocationState] = React14.useState(null);
|
|
1159
|
+
const [isReady, setIsReady] = React14.useState(false);
|
|
1160
|
+
React14.useEffect(() => {
|
|
1161
1161
|
onLocationChangeRef.current = onLocationChange;
|
|
1162
1162
|
}, [onLocationChange]);
|
|
1163
1163
|
const baseCurrency = business?.default_currency || DEFAULT_CURRENCY;
|
|
1164
|
-
const [displayCurrencyOverride, setDisplayCurrencyOverride] =
|
|
1164
|
+
const [displayCurrencyOverride, setDisplayCurrencyOverride] = React14.useState(
|
|
1165
1165
|
() => getStoredDisplayCurrency()
|
|
1166
1166
|
);
|
|
1167
|
-
const [fxRate, setFxRate] =
|
|
1167
|
+
const [fxRate, setFxRate] = React14.useState(null);
|
|
1168
1168
|
const displayCurrency = displayCurrencyOverride && displayCurrencyOverride !== baseCurrency ? displayCurrencyOverride : baseCurrency;
|
|
1169
|
-
const setDisplayCurrency =
|
|
1169
|
+
const setDisplayCurrency = React14.useCallback(
|
|
1170
1170
|
(currency) => {
|
|
1171
1171
|
const normalized = currency?.trim().toUpperCase() || null;
|
|
1172
1172
|
if (normalized && !chunkXA3ZNR75_js.isSupportedCurrency(normalized)) {
|
|
@@ -1180,7 +1180,7 @@ function CimplifyProvider({
|
|
|
1180
1180
|
},
|
|
1181
1181
|
[baseCurrency]
|
|
1182
1182
|
);
|
|
1183
|
-
|
|
1183
|
+
React14.useEffect(() => {
|
|
1184
1184
|
if (displayCurrency === baseCurrency) {
|
|
1185
1185
|
setFxRate(null);
|
|
1186
1186
|
return;
|
|
@@ -1205,7 +1205,7 @@ function CimplifyProvider({
|
|
|
1205
1205
|
clearInterval(intervalId);
|
|
1206
1206
|
};
|
|
1207
1207
|
}, [resolvedClient, baseCurrency, displayCurrency]);
|
|
1208
|
-
const convertPrice =
|
|
1208
|
+
const convertPrice = React14.useCallback(
|
|
1209
1209
|
(amount) => {
|
|
1210
1210
|
const num = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
1211
1211
|
if (isNaN(num)) return 0;
|
|
@@ -1214,7 +1214,7 @@ function CimplifyProvider({
|
|
|
1214
1214
|
},
|
|
1215
1215
|
[fxRate, displayCurrency, baseCurrency]
|
|
1216
1216
|
);
|
|
1217
|
-
const setCurrentLocation =
|
|
1217
|
+
const setCurrentLocation = React14.useCallback(
|
|
1218
1218
|
(location) => {
|
|
1219
1219
|
const previousLocationId = resolvedClient.getLocationId();
|
|
1220
1220
|
if (previousLocationId && previousLocationId !== location.id) {
|
|
@@ -1227,7 +1227,7 @@ function CimplifyProvider({
|
|
|
1227
1227
|
},
|
|
1228
1228
|
[resolvedClient]
|
|
1229
1229
|
);
|
|
1230
|
-
|
|
1230
|
+
React14.useEffect(() => {
|
|
1231
1231
|
let cancelled = false;
|
|
1232
1232
|
async function bootstrap() {
|
|
1233
1233
|
setIsReady(false);
|
|
@@ -1272,7 +1272,7 @@ function CimplifyProvider({
|
|
|
1272
1272
|
cancelled = true;
|
|
1273
1273
|
};
|
|
1274
1274
|
}, [resolvedClient]);
|
|
1275
|
-
const clientContextValue =
|
|
1275
|
+
const clientContextValue = React14.useMemo(
|
|
1276
1276
|
() => ({
|
|
1277
1277
|
client: resolvedClient,
|
|
1278
1278
|
business,
|
|
@@ -1292,7 +1292,7 @@ function CimplifyProvider({
|
|
|
1292
1292
|
optimistic
|
|
1293
1293
|
]
|
|
1294
1294
|
);
|
|
1295
|
-
const stateContextValue =
|
|
1295
|
+
const stateContextValue = React14.useMemo(
|
|
1296
1296
|
() => ({
|
|
1297
1297
|
currentLocation,
|
|
1298
1298
|
setCurrentLocation,
|
|
@@ -1313,20 +1313,20 @@ function CimplifyProvider({
|
|
|
1313
1313
|
return /* @__PURE__ */ jsxRuntime.jsx(CimplifyClientContext.Provider, { value: clientContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(CimplifyStateContext.Provider, { value: stateContextValue, children }) });
|
|
1314
1314
|
}
|
|
1315
1315
|
function useCimplify() {
|
|
1316
|
-
const clientContext =
|
|
1317
|
-
const stateContext =
|
|
1316
|
+
const clientContext = React14.useContext(CimplifyClientContext);
|
|
1317
|
+
const stateContext = React14.useContext(CimplifyStateContext);
|
|
1318
1318
|
if (!clientContext || !stateContext) {
|
|
1319
1319
|
throw new Error("useCimplify must be used within CimplifyProvider");
|
|
1320
1320
|
}
|
|
1321
|
-
return
|
|
1321
|
+
return React14.useMemo(
|
|
1322
1322
|
() => ({ ...clientContext, ...stateContext }),
|
|
1323
1323
|
[clientContext, stateContext]
|
|
1324
1324
|
);
|
|
1325
1325
|
}
|
|
1326
1326
|
function useOptionalCimplify() {
|
|
1327
|
-
const clientContext =
|
|
1328
|
-
const stateContext =
|
|
1329
|
-
return
|
|
1327
|
+
const clientContext = React14.useContext(CimplifyClientContext);
|
|
1328
|
+
const stateContext = React14.useContext(CimplifyStateContext);
|
|
1329
|
+
return React14.useMemo(() => {
|
|
1330
1330
|
if (!clientContext || !stateContext) {
|
|
1331
1331
|
return null;
|
|
1332
1332
|
}
|
|
@@ -1334,14 +1334,14 @@ function useOptionalCimplify() {
|
|
|
1334
1334
|
}, [clientContext, stateContext]);
|
|
1335
1335
|
}
|
|
1336
1336
|
function useCimplifyClient() {
|
|
1337
|
-
const context =
|
|
1337
|
+
const context = React14.useContext(CimplifyClientContext);
|
|
1338
1338
|
if (!context) {
|
|
1339
1339
|
throw new Error("useCimplifyClient must be used within CimplifyProvider");
|
|
1340
1340
|
}
|
|
1341
1341
|
return context;
|
|
1342
1342
|
}
|
|
1343
1343
|
function useOptionalCimplifyClient() {
|
|
1344
|
-
return
|
|
1344
|
+
return React14.useContext(CimplifyClientContext);
|
|
1345
1345
|
}
|
|
1346
1346
|
function shellColors(isDark) {
|
|
1347
1347
|
return {
|
|
@@ -1392,34 +1392,34 @@ function CimplifyCheckout({
|
|
|
1392
1392
|
appearance,
|
|
1393
1393
|
className
|
|
1394
1394
|
}) {
|
|
1395
|
-
const resolvedOrderTypes =
|
|
1395
|
+
const resolvedOrderTypes = React14.useMemo(
|
|
1396
1396
|
() => orderTypes && orderTypes.length > 0 ? orderTypes : ["pickup", "delivery"],
|
|
1397
1397
|
[orderTypes]
|
|
1398
1398
|
);
|
|
1399
|
-
const resolvedDefaultOrderType =
|
|
1399
|
+
const resolvedDefaultOrderType = React14.useMemo(() => {
|
|
1400
1400
|
if (defaultOrderType && resolvedOrderTypes.includes(defaultOrderType)) {
|
|
1401
1401
|
return defaultOrderType;
|
|
1402
1402
|
}
|
|
1403
1403
|
return resolvedOrderTypes[0] || "pickup";
|
|
1404
1404
|
}, [defaultOrderType, resolvedOrderTypes]);
|
|
1405
|
-
const [orderType, setOrderType] =
|
|
1406
|
-
const [status, setStatus] =
|
|
1407
|
-
const [statusText, setStatusText] =
|
|
1408
|
-
const [isSubmitting, setIsSubmitting] =
|
|
1409
|
-
const [isInitializing, setIsInitializing] =
|
|
1410
|
-
const [errorMessage, setErrorMessage] =
|
|
1411
|
-
const [resolvedBusinessId, setResolvedBusinessId] =
|
|
1412
|
-
const [resolvedCartId, setResolvedCartId] =
|
|
1413
|
-
const [resolvedCart, setResolvedCart] =
|
|
1414
|
-
const checkoutMountRef =
|
|
1415
|
-
const elementsRef =
|
|
1416
|
-
const activeCheckoutRef =
|
|
1417
|
-
const initialAppearanceRef =
|
|
1418
|
-
const hasWarnedInlineAppearanceRef =
|
|
1419
|
-
const isMountedRef =
|
|
1405
|
+
const [orderType, setOrderType] = React14.useState(resolvedDefaultOrderType);
|
|
1406
|
+
const [status, setStatus] = React14.useState(null);
|
|
1407
|
+
const [statusText, setStatusText] = React14.useState("");
|
|
1408
|
+
const [isSubmitting, setIsSubmitting] = React14.useState(false);
|
|
1409
|
+
const [isInitializing, setIsInitializing] = React14.useState(false);
|
|
1410
|
+
const [errorMessage, setErrorMessage] = React14.useState(null);
|
|
1411
|
+
const [resolvedBusinessId, setResolvedBusinessId] = React14.useState(businessId ?? null);
|
|
1412
|
+
const [resolvedCartId, setResolvedCartId] = React14.useState(cartId ?? null);
|
|
1413
|
+
const [resolvedCart, setResolvedCart] = React14.useState(null);
|
|
1414
|
+
const checkoutMountRef = React14.useRef(null);
|
|
1415
|
+
const elementsRef = React14.useRef(null);
|
|
1416
|
+
const activeCheckoutRef = React14.useRef(null);
|
|
1417
|
+
const initialAppearanceRef = React14.useRef(appearance);
|
|
1418
|
+
const hasWarnedInlineAppearanceRef = React14.useRef(false);
|
|
1419
|
+
const isMountedRef = React14.useRef(true);
|
|
1420
1420
|
const isTestMode = client.isTestMode();
|
|
1421
1421
|
const cimplifyCtx = useOptionalCimplify();
|
|
1422
|
-
const fxOptions =
|
|
1422
|
+
const fxOptions = React14.useMemo(() => {
|
|
1423
1423
|
if (!cimplifyCtx?.fxRate) return void 0;
|
|
1424
1424
|
if (cimplifyCtx.displayCurrency === cimplifyCtx.baseCurrency) return void 0;
|
|
1425
1425
|
return {
|
|
@@ -1427,29 +1427,29 @@ function CimplifyCheckout({
|
|
|
1427
1427
|
convertPrice: cimplifyCtx.convertPrice
|
|
1428
1428
|
};
|
|
1429
1429
|
}, [cimplifyCtx?.fxRate, cimplifyCtx?.displayCurrency, cimplifyCtx?.baseCurrency, cimplifyCtx?.convertPrice]);
|
|
1430
|
-
const fxOptionsRef =
|
|
1430
|
+
const fxOptionsRef = React14.useRef(fxOptions);
|
|
1431
1431
|
fxOptionsRef.current = fxOptions;
|
|
1432
|
-
const resolvedCartRef =
|
|
1432
|
+
const resolvedCartRef = React14.useRef(resolvedCart);
|
|
1433
1433
|
resolvedCartRef.current = resolvedCart;
|
|
1434
1434
|
const isDark = appearance?.theme === "dark";
|
|
1435
|
-
const emitStatus =
|
|
1435
|
+
const emitStatus = React14__default.default.useEffectEvent(
|
|
1436
1436
|
(nextStatus, context = {}) => {
|
|
1437
1437
|
setStatus(nextStatus);
|
|
1438
1438
|
setStatusText(context.display_text || "");
|
|
1439
1439
|
onStatusChange?.(nextStatus, context);
|
|
1440
1440
|
}
|
|
1441
1441
|
);
|
|
1442
|
-
const fireError =
|
|
1442
|
+
const fireError = React14__default.default.useEffectEvent(
|
|
1443
1443
|
(error) => {
|
|
1444
1444
|
onError?.(error);
|
|
1445
1445
|
}
|
|
1446
1446
|
);
|
|
1447
|
-
|
|
1447
|
+
React14.useEffect(() => {
|
|
1448
1448
|
if (!resolvedOrderTypes.includes(orderType)) {
|
|
1449
1449
|
setOrderType(resolvedDefaultOrderType);
|
|
1450
1450
|
}
|
|
1451
1451
|
}, [resolvedOrderTypes, resolvedDefaultOrderType, orderType]);
|
|
1452
|
-
|
|
1452
|
+
React14.useEffect(() => {
|
|
1453
1453
|
if (appearance && appearance !== initialAppearanceRef.current && !hasWarnedInlineAppearanceRef.current) {
|
|
1454
1454
|
hasWarnedInlineAppearanceRef.current = true;
|
|
1455
1455
|
console.warn(
|
|
@@ -1457,7 +1457,7 @@ function CimplifyCheckout({
|
|
|
1457
1457
|
);
|
|
1458
1458
|
}
|
|
1459
1459
|
}, [appearance]);
|
|
1460
|
-
|
|
1460
|
+
React14.useEffect(() => {
|
|
1461
1461
|
let cancelled = false;
|
|
1462
1462
|
async function bootstrap() {
|
|
1463
1463
|
const needsBusinessResolve = !businessId;
|
|
@@ -1528,14 +1528,14 @@ function CimplifyCheckout({
|
|
|
1528
1528
|
cancelled = true;
|
|
1529
1529
|
};
|
|
1530
1530
|
}, [businessId, cartId, client]);
|
|
1531
|
-
|
|
1531
|
+
React14.useEffect(() => {
|
|
1532
1532
|
return () => {
|
|
1533
1533
|
isMountedRef.current = false;
|
|
1534
1534
|
activeCheckoutRef.current?.abort();
|
|
1535
1535
|
activeCheckoutRef.current = null;
|
|
1536
1536
|
};
|
|
1537
1537
|
}, []);
|
|
1538
|
-
const handleSubmit =
|
|
1538
|
+
const handleSubmit = React14__default.default.useEffectEvent(async () => {
|
|
1539
1539
|
if (isSubmitting || isInitializing || !resolvedCartId) {
|
|
1540
1540
|
if (!resolvedCartId && !isInitializing) {
|
|
1541
1541
|
const message = "Your cart is empty. Add items before checkout.";
|
|
@@ -1580,7 +1580,7 @@ function CimplifyCheckout({
|
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
1582
1582
|
});
|
|
1583
|
-
|
|
1583
|
+
React14.useEffect(() => {
|
|
1584
1584
|
if (!resolvedBusinessId) {
|
|
1585
1585
|
elementsRef.current = null;
|
|
1586
1586
|
return;
|
|
@@ -1626,7 +1626,7 @@ function CimplifyCheckout({
|
|
|
1626
1626
|
resolvedDefaultOrderType,
|
|
1627
1627
|
submitLabel
|
|
1628
1628
|
]);
|
|
1629
|
-
|
|
1629
|
+
React14.useEffect(() => {
|
|
1630
1630
|
if (!resolvedCart || !elementsRef.current) return;
|
|
1631
1631
|
const checkoutElement = elementsRef.current.getElement("checkout");
|
|
1632
1632
|
if (checkoutElement) {
|
|
@@ -1662,100 +1662,6 @@ function CimplifyCheckout({
|
|
|
1662
1662
|
function cn(...inputs) {
|
|
1663
1663
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
1664
1664
|
}
|
|
1665
|
-
var DEFAULT_LINK_URL = "https://link.cimplify.io";
|
|
1666
|
-
function CimplifyAccount({
|
|
1667
|
-
client: clientProp,
|
|
1668
|
-
linkUrl,
|
|
1669
|
-
section,
|
|
1670
|
-
businessId: businessIdProp,
|
|
1671
|
-
merchantName,
|
|
1672
|
-
appearance,
|
|
1673
|
-
onLogout,
|
|
1674
|
-
className
|
|
1675
|
-
}) {
|
|
1676
|
-
const context = useOptionalCimplify();
|
|
1677
|
-
const client = clientProp ?? context?.client;
|
|
1678
|
-
const resolvedLinkUrl = linkUrl || DEFAULT_LINK_URL;
|
|
1679
|
-
const resolvedBusinessId = businessIdProp || client?.getBusinessId?.() || "";
|
|
1680
|
-
const iframeRef = React12.useRef(null);
|
|
1681
|
-
const [height, setHeight] = React12.useState(400);
|
|
1682
|
-
const [isReady, setIsReady] = React12.useState(false);
|
|
1683
|
-
const iframeSrc = React12.useMemo(() => {
|
|
1684
|
-
const path = section ? `/elements/account/${section}` : "/elements/account";
|
|
1685
|
-
const url = new URL(path, resolvedLinkUrl);
|
|
1686
|
-
if (resolvedBusinessId) url.searchParams.set("businessId", resolvedBusinessId);
|
|
1687
|
-
return url.toString();
|
|
1688
|
-
}, [resolvedLinkUrl, section, resolvedBusinessId]);
|
|
1689
|
-
React12.useEffect(() => {
|
|
1690
|
-
function handleMessage(event) {
|
|
1691
|
-
if (!event.data || typeof event.data !== "object") return;
|
|
1692
|
-
if (iframeRef.current?.contentWindow && event.source !== iframeRef.current.contentWindow) {
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
switch (event.data.type) {
|
|
1696
|
-
case "ready":
|
|
1697
|
-
setIsReady(true);
|
|
1698
|
-
if (typeof event.data.height === "number") {
|
|
1699
|
-
setHeight(event.data.height);
|
|
1700
|
-
}
|
|
1701
|
-
sendInit();
|
|
1702
|
-
break;
|
|
1703
|
-
case "height_change":
|
|
1704
|
-
if (typeof event.data.height === "number") {
|
|
1705
|
-
setHeight(event.data.height);
|
|
1706
|
-
}
|
|
1707
|
-
break;
|
|
1708
|
-
case "logout_complete":
|
|
1709
|
-
onLogout?.();
|
|
1710
|
-
break;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
window.addEventListener("message", handleMessage);
|
|
1714
|
-
return () => window.removeEventListener("message", handleMessage);
|
|
1715
|
-
}, [appearance, client, onLogout]);
|
|
1716
|
-
function sendInit() {
|
|
1717
|
-
const contentWindow = iframeRef.current?.contentWindow;
|
|
1718
|
-
if (!contentWindow) return;
|
|
1719
|
-
const token = client?.getAccessToken?.();
|
|
1720
|
-
contentWindow.postMessage(
|
|
1721
|
-
{
|
|
1722
|
-
type: "init",
|
|
1723
|
-
token: token ?? void 0,
|
|
1724
|
-
appearance: appearance ?? void 0,
|
|
1725
|
-
businessId: resolvedBusinessId || void 0,
|
|
1726
|
-
merchantName: merchantName ?? void 0
|
|
1727
|
-
},
|
|
1728
|
-
resolvedLinkUrl
|
|
1729
|
-
);
|
|
1730
|
-
}
|
|
1731
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1732
|
-
"div",
|
|
1733
|
-
{
|
|
1734
|
-
"data-cimplify-account": true,
|
|
1735
|
-
className: cn("relative overflow-hidden", className),
|
|
1736
|
-
children: [
|
|
1737
|
-
!isReady && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-6 h-6 border-2 border-border border-t-foreground rounded-full animate-spin" }) }),
|
|
1738
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1739
|
-
"iframe",
|
|
1740
|
-
{
|
|
1741
|
-
ref: iframeRef,
|
|
1742
|
-
src: iframeSrc,
|
|
1743
|
-
style: {
|
|
1744
|
-
border: "none",
|
|
1745
|
-
width: "100%",
|
|
1746
|
-
height: `${height}px`,
|
|
1747
|
-
display: isReady ? "block" : "none",
|
|
1748
|
-
overflow: "hidden",
|
|
1749
|
-
background: "transparent"
|
|
1750
|
-
},
|
|
1751
|
-
allow: "geolocation",
|
|
1752
|
-
sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"
|
|
1753
|
-
}
|
|
1754
|
-
)
|
|
1755
|
-
]
|
|
1756
|
-
}
|
|
1757
|
-
);
|
|
1758
|
-
}
|
|
1759
1665
|
var BUTTON_BASE = "inline-flex items-center justify-center gap-2 font-semibold leading-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 disabled:opacity-50 disabled:cursor-not-allowed [font-family:inherit] cursor-pointer rounded-[10px]";
|
|
1760
1666
|
var BUTTON_VARIANTS = {
|
|
1761
1667
|
primary: "bg-foreground text-background hover:bg-foreground/90",
|
|
@@ -1767,7 +1673,7 @@ var BUTTON_SIZES = {
|
|
|
1767
1673
|
sm: "px-[13px] py-[7px] text-[12.5px]",
|
|
1768
1674
|
md: "px-[18px] py-[10px] text-[13.5px]"
|
|
1769
1675
|
};
|
|
1770
|
-
var Button =
|
|
1676
|
+
var Button = React14__default.default.forwardRef(function Button2({ variant = "primary", size = "md", className, children, ...props }, ref) {
|
|
1771
1677
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1772
1678
|
"button",
|
|
1773
1679
|
{
|
|
@@ -1987,6 +1893,17 @@ function Toast({ title, description, onUndo, onDismiss, className }) {
|
|
|
1987
1893
|
}
|
|
1988
1894
|
);
|
|
1989
1895
|
}
|
|
1896
|
+
|
|
1897
|
+
// src/react/utils/avatar.ts
|
|
1898
|
+
function avatarGradient(seed) {
|
|
1899
|
+
let hash = 0;
|
|
1900
|
+
for (let i = 0; i < seed.length; i++) hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
|
|
1901
|
+
const hue = (Math.abs(hash) % 60 + 20) % 360;
|
|
1902
|
+
return `linear-gradient(135deg, oklch(0.78 0.10 ${hue}), oklch(0.55 0.16 ${hue - 8}))`;
|
|
1903
|
+
}
|
|
1904
|
+
function initials(name) {
|
|
1905
|
+
return name.trim().split(/\s+/).map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
1906
|
+
}
|
|
1990
1907
|
function AccountShell({ sidebar, children, className }) {
|
|
1991
1908
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1992
1909
|
"div",
|
|
@@ -2021,15 +1938,6 @@ function AccountSidebar({ children, scopeNote, className }) {
|
|
|
2021
1938
|
}
|
|
2022
1939
|
);
|
|
2023
1940
|
}
|
|
2024
|
-
function avatarGradient(seed) {
|
|
2025
|
-
let hash = 0;
|
|
2026
|
-
for (let i = 0; i < seed.length; i++) hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
|
|
2027
|
-
const hue = (Math.abs(hash) % 60 + 20) % 360;
|
|
2028
|
-
return `linear-gradient(135deg, oklch(0.78 0.10 ${hue}), oklch(0.55 0.16 ${hue - 8}))`;
|
|
2029
|
-
}
|
|
2030
|
-
function initials(name) {
|
|
2031
|
-
return name.trim().split(/\s+/).map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
2032
|
-
}
|
|
2033
1941
|
function AccountIdentityStrip({
|
|
2034
1942
|
name,
|
|
2035
1943
|
email,
|
|
@@ -2546,6 +2454,560 @@ function ContextCard({ rows, className }) {
|
|
|
2546
2454
|
}
|
|
2547
2455
|
);
|
|
2548
2456
|
}
|
|
2457
|
+
function RiderAvatar({ rider, size }) {
|
|
2458
|
+
if (rider.photoUrl) {
|
|
2459
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2460
|
+
"img",
|
|
2461
|
+
{
|
|
2462
|
+
src: rider.photoUrl,
|
|
2463
|
+
alt: "",
|
|
2464
|
+
className: "rounded-full object-cover",
|
|
2465
|
+
style: { width: size, height: size }
|
|
2466
|
+
}
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2469
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2470
|
+
"span",
|
|
2471
|
+
{
|
|
2472
|
+
"aria-hidden": true,
|
|
2473
|
+
className: "grid place-items-center rounded-full font-serif font-semibold text-white",
|
|
2474
|
+
style: { width: size, height: size, fontSize: size * 0.38, background: avatarGradient(rider.name) },
|
|
2475
|
+
children: initials(rider.name)
|
|
2476
|
+
}
|
|
2477
|
+
);
|
|
2478
|
+
}
|
|
2479
|
+
function RiderMeta({ rider }) {
|
|
2480
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2481
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
2482
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: rider.name }),
|
|
2483
|
+
rider.rating !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-xs font-semibold text-amber-500", children: [
|
|
2484
|
+
"\u2605 ",
|
|
2485
|
+
rider.rating.toFixed(1)
|
|
2486
|
+
] })
|
|
2487
|
+
] }),
|
|
2488
|
+
rider.vehicle && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-xs text-foreground/55", children: rider.vehicle })
|
|
2489
|
+
] });
|
|
2490
|
+
}
|
|
2491
|
+
function DotStep({ steps }) {
|
|
2492
|
+
const current = steps.find((s) => s.state === "current") ?? [...steps].reverse().find((s) => s.state === "done");
|
|
2493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3.5", children: [
|
|
2494
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1.5", children: steps.map((step, i) => /* @__PURE__ */ jsxRuntime.jsxs(React14__default.default.Fragment, { children: [
|
|
2495
|
+
i > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2496
|
+
"span",
|
|
2497
|
+
{
|
|
2498
|
+
className: cn(
|
|
2499
|
+
"h-0.5 flex-1 rounded-full",
|
|
2500
|
+
steps[i - 1].state === "done" ? "bg-primary" : "bg-border"
|
|
2501
|
+
)
|
|
2502
|
+
}
|
|
2503
|
+
),
|
|
2504
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2505
|
+
"span",
|
|
2506
|
+
{
|
|
2507
|
+
className: cn(
|
|
2508
|
+
"block size-[7px] shrink-0 rounded-full",
|
|
2509
|
+
step.state === "done" && "bg-primary",
|
|
2510
|
+
step.state === "current" && "bg-primary ring-4 ring-primary/15",
|
|
2511
|
+
step.state === "pending" && "bg-border"
|
|
2512
|
+
)
|
|
2513
|
+
}
|
|
2514
|
+
)
|
|
2515
|
+
] }, step.label)) }),
|
|
2516
|
+
current && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 truncate text-center text-[11.5px] font-semibold text-primary", children: current.label })
|
|
2517
|
+
] });
|
|
2518
|
+
}
|
|
2519
|
+
function DeliveryTracker({
|
|
2520
|
+
steps,
|
|
2521
|
+
statusLabel,
|
|
2522
|
+
etaLabel,
|
|
2523
|
+
rider,
|
|
2524
|
+
live,
|
|
2525
|
+
onTrackLive,
|
|
2526
|
+
onContactRider,
|
|
2527
|
+
variant = "card",
|
|
2528
|
+
className
|
|
2529
|
+
}) {
|
|
2530
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2531
|
+
"div",
|
|
2532
|
+
{
|
|
2533
|
+
"data-cimplify-delivery-tracker": true,
|
|
2534
|
+
"data-mode": live ? "live" : "steps",
|
|
2535
|
+
className: cn(
|
|
2536
|
+
"overflow-hidden",
|
|
2537
|
+
variant === "card" && "rounded-[var(--radius,12px)] border border-border/60 bg-card",
|
|
2538
|
+
className
|
|
2539
|
+
),
|
|
2540
|
+
children: live ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2541
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-[216px] w-full overflow-hidden bg-muted", children: [
|
|
2542
|
+
live.map,
|
|
2543
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute left-3 top-3 inline-flex items-center gap-1.5 rounded-full border border-border/40 bg-background/90 px-2.5 py-1 text-xs font-semibold shadow-sm backdrop-blur", children: [
|
|
2544
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative size-[7px] rounded-full bg-emerald-500", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-0 animate-ping rounded-full bg-emerald-500" }) }),
|
|
2545
|
+
"Live"
|
|
2546
|
+
] }),
|
|
2547
|
+
(live.etaLabel ?? etaLabel) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-3 top-3 rounded-full bg-foreground px-3 py-1.5 text-xs font-semibold text-background shadow-lg", children: live.etaLabel ?? etaLabel })
|
|
2548
|
+
] }),
|
|
2549
|
+
rider && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative z-[2] -mt-6 mx-3.5 mb-3.5 rounded-2xl border border-border/60 bg-card p-3.5 shadow-[0_10px_30px_-16px_rgba(16,24,40,0.32)]", children: [
|
|
2550
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2551
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [
|
|
2552
|
+
/* @__PURE__ */ jsxRuntime.jsx(RiderAvatar, { rider, size: 46 }),
|
|
2553
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -bottom-px -right-px size-3 rounded-full border-[2.5px] border-card bg-emerald-500" })
|
|
2554
|
+
] }),
|
|
2555
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(RiderMeta, { rider }) }),
|
|
2556
|
+
(rider.etaLabel || rider.distanceLabel) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-right", children: [
|
|
2557
|
+
rider.etaLabel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[15px] font-semibold tabular-nums text-foreground", children: rider.etaLabel }),
|
|
2558
|
+
rider.distanceLabel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11.5px] text-foreground/55", children: rider.distanceLabel })
|
|
2559
|
+
] })
|
|
2560
|
+
] }),
|
|
2561
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex gap-2", children: [
|
|
2562
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2563
|
+
"button",
|
|
2564
|
+
{
|
|
2565
|
+
type: "button",
|
|
2566
|
+
onClick: onTrackLive,
|
|
2567
|
+
className: "h-10 flex-1 rounded-xl bg-primary text-sm font-semibold text-[var(--color-primary-foreground,#fff)] hover:brightness-105",
|
|
2568
|
+
children: "Track live"
|
|
2569
|
+
}
|
|
2570
|
+
),
|
|
2571
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2572
|
+
"button",
|
|
2573
|
+
{
|
|
2574
|
+
type: "button",
|
|
2575
|
+
onClick: onContactRider,
|
|
2576
|
+
"aria-label": `Contact ${rider.name}`,
|
|
2577
|
+
className: "grid size-10 place-items-center rounded-xl border border-border bg-card text-foreground hover:bg-muted/50",
|
|
2578
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3 19.5 19.5 0 0 1-6-6 19.8 19.8 0 0 1-3-8.6A2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8.1 9.9a16 16 0 0 0 6 6l1.3-1.2a2 2 0 0 1 2.1-.5c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2Z" }) })
|
|
2579
|
+
}
|
|
2580
|
+
)
|
|
2581
|
+
] }),
|
|
2582
|
+
/* @__PURE__ */ jsxRuntime.jsx(DotStep, { steps })
|
|
2583
|
+
] })
|
|
2584
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: variant === "card" ? "p-4 sm:p-5" : "", children: [
|
|
2585
|
+
(statusLabel || etaLabel) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 flex items-center justify-between", children: [
|
|
2586
|
+
statusLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-amber-500/10 px-2.5 py-1 text-xs font-semibold text-amber-600", children: [
|
|
2587
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-current" }),
|
|
2588
|
+
statusLabel
|
|
2589
|
+
] }),
|
|
2590
|
+
etaLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] font-semibold tabular-nums text-foreground", children: etaLabel })
|
|
2591
|
+
] }),
|
|
2592
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "relative ml-[9px] border-l-2 border-border", children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "relative pb-4 pl-6 last:pb-0", children: [
|
|
2593
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2594
|
+
"span",
|
|
2595
|
+
{
|
|
2596
|
+
className: cn(
|
|
2597
|
+
"absolute -left-[9px] top-px grid size-[18px] place-items-center rounded-full border-2 bg-card",
|
|
2598
|
+
step.state === "done" && "border-primary bg-primary",
|
|
2599
|
+
step.state === "current" && "border-primary ring-4 ring-primary/15",
|
|
2600
|
+
step.state === "pending" && "border-border"
|
|
2601
|
+
),
|
|
2602
|
+
children: [
|
|
2603
|
+
step.state === "done" && /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "#fff", strokeWidth: "3.5", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" }) }),
|
|
2604
|
+
step.state === "current" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-[7px] rounded-full bg-primary" })
|
|
2605
|
+
]
|
|
2606
|
+
}
|
|
2607
|
+
),
|
|
2608
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2609
|
+
"div",
|
|
2610
|
+
{
|
|
2611
|
+
className: cn(
|
|
2612
|
+
"text-[13px] font-semibold",
|
|
2613
|
+
step.state === "pending" ? "text-foreground/45" : "text-foreground"
|
|
2614
|
+
),
|
|
2615
|
+
children: step.label
|
|
2616
|
+
}
|
|
2617
|
+
),
|
|
2618
|
+
step.time && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-foreground/55", children: step.time })
|
|
2619
|
+
] }, step.label)) }),
|
|
2620
|
+
rider && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1 flex items-center gap-3 border-t border-border/60 pt-4", children: [
|
|
2621
|
+
/* @__PURE__ */ jsxRuntime.jsx(RiderAvatar, { rider, size: 42 }),
|
|
2622
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(RiderMeta, { rider }) }),
|
|
2623
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2624
|
+
"button",
|
|
2625
|
+
{
|
|
2626
|
+
type: "button",
|
|
2627
|
+
onClick: onContactRider,
|
|
2628
|
+
className: "h-9 rounded-[10px] border border-border bg-card px-4 text-[13px] font-semibold text-foreground hover:bg-muted/50",
|
|
2629
|
+
children: "Contact"
|
|
2630
|
+
}
|
|
2631
|
+
)
|
|
2632
|
+
] })
|
|
2633
|
+
] })
|
|
2634
|
+
}
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
var STATE_TONE = {
|
|
2638
|
+
preparing: "text-amber-600",
|
|
2639
|
+
ready: "text-emerald-600",
|
|
2640
|
+
delivered: "text-emerald-600",
|
|
2641
|
+
booked: "text-primary",
|
|
2642
|
+
cancelled: "text-destructive",
|
|
2643
|
+
default: "text-foreground/55"
|
|
2644
|
+
};
|
|
2645
|
+
function StateDot({ label, tone = "default" }) {
|
|
2646
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn("inline-flex items-center gap-1.5 text-xs font-medium", STATE_TONE[tone]), children: [
|
|
2647
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-current" }),
|
|
2648
|
+
label
|
|
2649
|
+
] });
|
|
2650
|
+
}
|
|
2651
|
+
var TYPE_GLYPH = {
|
|
2652
|
+
product: null,
|
|
2653
|
+
bundle: null,
|
|
2654
|
+
composite: null,
|
|
2655
|
+
service: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "19", height: "19", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", children: [
|
|
2656
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "4", width: "18", height: "17", rx: "2" }),
|
|
2657
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9h18M8 2v4M16 2v4" })
|
|
2658
|
+
] }),
|
|
2659
|
+
digital: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "19", height: "19", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", children: [
|
|
2660
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 4h11l5 5v11a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z" }),
|
|
2661
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 4v5h5" })
|
|
2662
|
+
] })
|
|
2663
|
+
};
|
|
2664
|
+
function Thumb({ item }) {
|
|
2665
|
+
const glyph = item.lineType ? TYPE_GLYPH[item.lineType] : null;
|
|
2666
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-px size-[46px] shrink-0 overflow-hidden rounded-[10px] bg-muted/50", children: item.imageUrl ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.imageUrl, alt: "", className: "size-full object-cover" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid size-full place-items-center text-foreground/35", children: glyph }) });
|
|
2667
|
+
}
|
|
2668
|
+
function AccountLineItem({ item, className }) {
|
|
2669
|
+
const [open, setOpen] = React14.useState(false);
|
|
2670
|
+
const subtitle = item.subtitle ?? ([item.variant, item.addOns?.length ? `+ ${item.addOns.map((a) => a.name).join(", ")}` : null].filter(Boolean).join(" \xB7 ") || void 0);
|
|
2671
|
+
const hasDetail = !!item.customerInputs?.length || !!item.includes?.length || !!item.customisations?.length;
|
|
2672
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-line-item": true, "data-type": item.lineType, className: cn("py-[15px]", className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[46px_minmax(0,1fr)_auto] items-start gap-x-[13px]", children: [
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsx(Thumb, { item }),
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
2675
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold leading-tight tracking-[-0.01em] text-foreground", children: item.name }),
|
|
2676
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 text-[12.5px] text-foreground/55", children: subtitle }),
|
|
2677
|
+
item.scheduling && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-0.5 text-[12.5px] text-foreground/55", children: [
|
|
2678
|
+
item.scheduling.whenLabel,
|
|
2679
|
+
item.scheduling.staffName && ` \xB7 with ${item.scheduling.staffName}`
|
|
2680
|
+
] }),
|
|
2681
|
+
(item.stateLabel || item.scheduling?.confirmationCode || hasDetail || item.digital) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-x-3 gap-y-1.5", children: [
|
|
2682
|
+
item.stateLabel && /* @__PURE__ */ jsxRuntime.jsx(StateDot, { label: item.stateLabel, tone: item.stateTone }),
|
|
2683
|
+
item.scheduling?.confirmationCode && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-foreground/45", children: [
|
|
2684
|
+
"#",
|
|
2685
|
+
item.scheduling.confirmationCode
|
|
2686
|
+
] }),
|
|
2687
|
+
item.digital && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2689
|
+
StateDot,
|
|
2690
|
+
{
|
|
2691
|
+
label: item.digital.statusLabel,
|
|
2692
|
+
tone: item.digital.tone === "revoked" ? "cancelled" : "ready"
|
|
2693
|
+
}
|
|
2694
|
+
),
|
|
2695
|
+
item.digital.usageSummary && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11.5px] text-foreground/55", children: item.digital.usageSummary }),
|
|
2696
|
+
item.digital.onDownload && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2697
|
+
"button",
|
|
2698
|
+
{
|
|
2699
|
+
type: "button",
|
|
2700
|
+
onClick: item.digital.onDownload,
|
|
2701
|
+
className: "inline-flex items-center gap-1.5 text-xs font-semibold text-primary hover:underline",
|
|
2702
|
+
children: [
|
|
2703
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 3v12m0 0 4-4m-4 4-4-4M5 21h14" }) }),
|
|
2704
|
+
"Download"
|
|
2705
|
+
]
|
|
2706
|
+
}
|
|
2707
|
+
)
|
|
2708
|
+
] }),
|
|
2709
|
+
hasDetail && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2710
|
+
"button",
|
|
2711
|
+
{
|
|
2712
|
+
type: "button",
|
|
2713
|
+
onClick: () => setOpen((v) => !v),
|
|
2714
|
+
"aria-expanded": open,
|
|
2715
|
+
className: "inline-flex items-center gap-1.5 text-[12.5px] font-semibold text-foreground/55 hover:text-foreground",
|
|
2716
|
+
children: [
|
|
2717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2718
|
+
"svg",
|
|
2719
|
+
{
|
|
2720
|
+
width: "13",
|
|
2721
|
+
height: "13",
|
|
2722
|
+
viewBox: "0 0 24 24",
|
|
2723
|
+
fill: "none",
|
|
2724
|
+
stroke: "currentColor",
|
|
2725
|
+
strokeWidth: "2",
|
|
2726
|
+
className: cn("transition-transform", open && "rotate-90"),
|
|
2727
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m9 18 6-6-6-6" })
|
|
2728
|
+
}
|
|
2729
|
+
),
|
|
2730
|
+
item.customisations?.length || item.customerInputs?.length ? "Customisations & details" : "What's included"
|
|
2731
|
+
]
|
|
2732
|
+
}
|
|
2733
|
+
)
|
|
2734
|
+
] }),
|
|
2735
|
+
open && hasDetail && /* @__PURE__ */ jsxRuntime.jsx(LineItemDetails, { item, className: "ml-[1px] mt-2.5" })
|
|
2736
|
+
] }),
|
|
2737
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold tabular-nums text-foreground", children: item.priceLabel })
|
|
2738
|
+
] }) });
|
|
2739
|
+
}
|
|
2740
|
+
function ChildRow({ sel }) {
|
|
2741
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-2 py-1.5 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-border/50", children: [
|
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-[11px] font-semibold tabular-nums text-foreground/55", children: [
|
|
2743
|
+
sel.quantity ?? 1,
|
|
2744
|
+
"\xD7"
|
|
2745
|
+
] }),
|
|
2746
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
2747
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[12.5px] font-medium text-foreground", children: sel.name }),
|
|
2748
|
+
sel.variantName && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] text-foreground/55", children: sel.variantName })
|
|
2749
|
+
] }),
|
|
2750
|
+
sel.priceLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-[11.5px] tabular-nums text-foreground/55", children: sel.priceLabel })
|
|
2751
|
+
] });
|
|
2752
|
+
}
|
|
2753
|
+
function LineItemDetails({
|
|
2754
|
+
item,
|
|
2755
|
+
className
|
|
2756
|
+
}) {
|
|
2757
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-3", className), children: [
|
|
2758
|
+
item.includes && item.includes.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2759
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1 text-[10px] font-bold uppercase tracking-wider text-foreground/45", children: "Bundle includes" }),
|
|
2760
|
+
item.includes.map((sel, i) => /* @__PURE__ */ jsxRuntime.jsx(ChildRow, { sel }, i))
|
|
2761
|
+
] }),
|
|
2762
|
+
item.customisations && item.customisations.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2763
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1 text-[10px] font-bold uppercase tracking-wider text-foreground/45", children: "Customisations" }),
|
|
2764
|
+
item.customisations.map((sel, i) => /* @__PURE__ */ jsxRuntime.jsx(ChildRow, { sel }, i))
|
|
2765
|
+
] }),
|
|
2766
|
+
item.customerInputs && item.customerInputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-[84px_minmax(0,1fr)] items-start gap-x-2.5 gap-y-1 text-xs sm:grid-cols-[104px_minmax(0,1fr)]", children: item.customerInputs.map((input) => /* @__PURE__ */ jsxRuntime.jsxs(React14__default.default.Fragment, { children: [
|
|
2767
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "capitalize text-foreground/55", children: input.fieldName }),
|
|
2768
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomerInputValue, { input })
|
|
2769
|
+
] }, input.fieldId)) })
|
|
2770
|
+
] });
|
|
2771
|
+
}
|
|
2772
|
+
function asObject(v) {
|
|
2773
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
2774
|
+
}
|
|
2775
|
+
function CustomerInputValue({ input }) {
|
|
2776
|
+
const v = input.value;
|
|
2777
|
+
const obj = asObject(v);
|
|
2778
|
+
if (input.semanticKind === "allergen" || input.semanticKind === "sensitivity") {
|
|
2779
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 font-medium text-amber-600", children: [
|
|
2780
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z" }) }),
|
|
2781
|
+
String(v ?? "")
|
|
2782
|
+
] });
|
|
2783
|
+
}
|
|
2784
|
+
switch (input.fieldType) {
|
|
2785
|
+
case "textarea":
|
|
2786
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block whitespace-pre-wrap rounded-md bg-muted/40 px-2.5 py-1.5 leading-relaxed text-foreground/90", children: String(v ?? "") });
|
|
2787
|
+
case "number":
|
|
2788
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold tabular-nums text-foreground", children: String(v ?? "") });
|
|
2789
|
+
case "select":
|
|
2790
|
+
case "radio":
|
|
2791
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex w-fit items-center rounded-full border border-primary/20 bg-primary/[0.12] px-2 py-0.5 text-[11.5px] font-medium text-primary", children: String(v ?? "") });
|
|
2792
|
+
case "multi_select":
|
|
2793
|
+
case "checkbox": {
|
|
2794
|
+
if (typeof v === "boolean") return /* @__PURE__ */ jsxRuntime.jsx(BooleanBadge, { value: v });
|
|
2795
|
+
const list = Array.isArray(v) ? v.map(String) : [String(v ?? "")];
|
|
2796
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex flex-wrap gap-1", children: list.filter(Boolean).map((label, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-[11px] font-medium", children: label }, i)) });
|
|
2797
|
+
}
|
|
2798
|
+
case "color": {
|
|
2799
|
+
const hex = String(v ?? "");
|
|
2800
|
+
const label = obj?.label ? String(obj.label) : hex;
|
|
2801
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 font-medium text-foreground", children: [
|
|
2802
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block size-3.5 rounded-full border border-black/10", style: { background: hex } }),
|
|
2803
|
+
label,
|
|
2804
|
+
hex && hex !== label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-[11px] text-foreground/55", children: hex })
|
|
2805
|
+
] });
|
|
2806
|
+
}
|
|
2807
|
+
case "date":
|
|
2808
|
+
case "date_time":
|
|
2809
|
+
case "time":
|
|
2810
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium tabular-nums text-foreground", children: String(v ?? "") });
|
|
2811
|
+
case "date_range": {
|
|
2812
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 font-medium tabular-nums text-foreground", children: [
|
|
2813
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: String(obj?.start ?? "") }),
|
|
2814
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground/55", children: "\u2192" }),
|
|
2815
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: String(obj?.end ?? "") })
|
|
2816
|
+
] });
|
|
2817
|
+
}
|
|
2818
|
+
case "file": {
|
|
2819
|
+
const url = String(v ?? "");
|
|
2820
|
+
const filename = url.split("/").pop() || "Attachment";
|
|
2821
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2822
|
+
"a",
|
|
2823
|
+
{
|
|
2824
|
+
href: url,
|
|
2825
|
+
target: "_blank",
|
|
2826
|
+
rel: "noopener noreferrer",
|
|
2827
|
+
className: "inline-flex w-fit max-w-full items-center gap-1.5 rounded-md border border-border bg-muted/40 px-2 py-1 text-foreground hover:border-primary hover:text-primary",
|
|
2828
|
+
children: [
|
|
2829
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 3v5h5M15 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8Z" }) }),
|
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-[11.5px] font-medium", children: filename })
|
|
2831
|
+
]
|
|
2832
|
+
}
|
|
2833
|
+
);
|
|
2834
|
+
}
|
|
2835
|
+
case "image": {
|
|
2836
|
+
const url = typeof v === "string" ? v : "";
|
|
2837
|
+
if (!url) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "italic text-foreground/55", children: "No image" });
|
|
2838
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "block size-14 overflow-hidden rounded-md border border-border", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: input.fieldName, className: "size-full object-cover" }) });
|
|
2839
|
+
}
|
|
2840
|
+
case "url": {
|
|
2841
|
+
const url = String(v ?? "");
|
|
2842
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "inline-flex max-w-full items-center gap-1 truncate text-primary hover:underline", children: url.replace(/^https?:\/\//, "").replace(/\/$/, "") });
|
|
2843
|
+
}
|
|
2844
|
+
case "email":
|
|
2845
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: `mailto:${String(v ?? "")}`, className: "text-primary hover:underline", children: String(v ?? "") });
|
|
2846
|
+
case "phone": {
|
|
2847
|
+
const display = obj?.formatted ? String(obj.formatted) : String(v ?? "");
|
|
2848
|
+
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: `tel:${display}`, className: "tabular-nums text-primary hover:underline", children: display });
|
|
2849
|
+
}
|
|
2850
|
+
case "address": {
|
|
2851
|
+
const formatted = obj?.formatted_address ? String(obj.formatted_address) : String(v ?? "");
|
|
2852
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block whitespace-pre-line rounded-md bg-muted/40 px-2.5 py-1.5 text-[11.5px] leading-relaxed", children: formatted });
|
|
2853
|
+
}
|
|
2854
|
+
case "location": {
|
|
2855
|
+
const label = obj?.label ? String(obj.label) : null;
|
|
2856
|
+
const lat = obj?.latitude;
|
|
2857
|
+
const lng = obj?.longitude;
|
|
2858
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 font-medium text-foreground", children: [
|
|
2859
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "text-destructive", children: [
|
|
2860
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 21s-7-5.5-7-11a7 7 0 0 1 14 0c0 5.5-7 11-7 11Z" }),
|
|
2861
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "10", r: "2.5" })
|
|
2862
|
+
] }),
|
|
2863
|
+
label ?? `${lat ?? "?"}, ${lng ?? "?"}`
|
|
2864
|
+
] });
|
|
2865
|
+
}
|
|
2866
|
+
case "signature": {
|
|
2867
|
+
const signer = obj?.signer_name ? String(obj.signer_name) : null;
|
|
2868
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex w-fit items-center gap-1 rounded-full border border-emerald-500/20 bg-emerald-500/[0.12] px-2 py-0.5 text-[11px] font-semibold text-emerald-600", children: [
|
|
2869
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" }) }),
|
|
2870
|
+
signer ? `Signed by ${signer}` : "Signed"
|
|
2871
|
+
] });
|
|
2872
|
+
}
|
|
2873
|
+
case "text":
|
|
2874
|
+
default:
|
|
2875
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "italic text-foreground/90", children: [
|
|
2876
|
+
"\u201C",
|
|
2877
|
+
String(v ?? ""),
|
|
2878
|
+
"\u201D"
|
|
2879
|
+
] });
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
function BooleanBadge({ value }) {
|
|
2883
|
+
return value ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex w-fit items-center gap-1 rounded-full border border-emerald-500/20 bg-emerald-500/[0.12] px-2 py-0.5 text-[11px] font-semibold text-emerald-600", children: [
|
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" }) }),
|
|
2885
|
+
"Yes"
|
|
2886
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex w-fit items-center rounded-full bg-muted/40 px-2 py-0.5 text-[11px] font-medium text-foreground/55", children: "No" });
|
|
2887
|
+
}
|
|
2888
|
+
function AccountLineItems({ items, className }) {
|
|
2889
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-line-items": true, className: cn("divide-y divide-border/60", className), children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(AccountLineItem, { item }, item.id)) });
|
|
2890
|
+
}
|
|
2891
|
+
var STATUS_TONE = {
|
|
2892
|
+
progress: "bg-amber-500/10 text-amber-600",
|
|
2893
|
+
positive: "bg-emerald-500/10 text-emerald-600",
|
|
2894
|
+
muted: "bg-muted/60 text-foreground/60"
|
|
2895
|
+
};
|
|
2896
|
+
function SectionLabel({ children }) {
|
|
2897
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] font-bold uppercase tracking-wider text-foreground/45", children });
|
|
2898
|
+
}
|
|
2899
|
+
function AccountOrderView({
|
|
2900
|
+
orderNumber,
|
|
2901
|
+
placedLabel,
|
|
2902
|
+
statusLabel,
|
|
2903
|
+
statusTone = "progress",
|
|
2904
|
+
items,
|
|
2905
|
+
itemsLabel = "Items",
|
|
2906
|
+
delivery,
|
|
2907
|
+
payment,
|
|
2908
|
+
shipTo,
|
|
2909
|
+
actions,
|
|
2910
|
+
onBack,
|
|
2911
|
+
backLabel = "Back to orders",
|
|
2912
|
+
className
|
|
2913
|
+
}) {
|
|
2914
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-view": true, className: cn("min-w-0", className), children: [
|
|
2915
|
+
onBack && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2916
|
+
"button",
|
|
2917
|
+
{
|
|
2918
|
+
type: "button",
|
|
2919
|
+
onClick: onBack,
|
|
2920
|
+
className: "mb-5 inline-flex items-center gap-1.5 text-[13px] font-medium text-foreground/55 hover:text-foreground",
|
|
2921
|
+
children: [
|
|
2922
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m15 18-6-6 6-6" }) }),
|
|
2923
|
+
backLabel
|
|
2924
|
+
]
|
|
2925
|
+
}
|
|
2926
|
+
),
|
|
2927
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-5 flex items-start justify-between gap-3", children: [
|
|
2928
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
2929
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h1", { className: "font-serif text-2xl font-semibold tracking-[-0.02em] tabular-nums text-foreground", children: [
|
|
2930
|
+
"Order #",
|
|
2931
|
+
orderNumber
|
|
2932
|
+
] }),
|
|
2933
|
+
placedLabel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 text-[13px] text-foreground/55", children: placedLabel })
|
|
2934
|
+
] }),
|
|
2935
|
+
statusLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2936
|
+
"span",
|
|
2937
|
+
{
|
|
2938
|
+
className: cn(
|
|
2939
|
+
"shrink-0 rounded-full px-2.5 py-1 text-xs font-semibold",
|
|
2940
|
+
STATUS_TONE[statusTone]
|
|
2941
|
+
),
|
|
2942
|
+
children: statusLabel
|
|
2943
|
+
}
|
|
2944
|
+
)
|
|
2945
|
+
] }),
|
|
2946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_300px] lg:gap-14", children: [
|
|
2947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
2948
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { children: [
|
|
2949
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: itemsLabel }),
|
|
2950
|
+
/* @__PURE__ */ jsxRuntime.jsx(AccountLineItems, { items, className: "mt-2.5" })
|
|
2951
|
+
] }),
|
|
2952
|
+
delivery && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mt-6 border-t border-border/60 pt-6", children: [
|
|
2953
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1 flex items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: delivery.label ?? "Delivery" }) }),
|
|
2954
|
+
delivery.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-4 text-[11.5px] text-foreground/55", children: delivery.note }),
|
|
2955
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2956
|
+
DeliveryTracker,
|
|
2957
|
+
{
|
|
2958
|
+
variant: "plain",
|
|
2959
|
+
steps: delivery.steps,
|
|
2960
|
+
statusLabel: delivery.statusLabel,
|
|
2961
|
+
etaLabel: delivery.etaLabel,
|
|
2962
|
+
rider: delivery.rider,
|
|
2963
|
+
live: delivery.live,
|
|
2964
|
+
onTrackLive: delivery.onTrackLive,
|
|
2965
|
+
onContactRider: delivery.onContactRider
|
|
2966
|
+
}
|
|
2967
|
+
)
|
|
2968
|
+
] })
|
|
2969
|
+
] }),
|
|
2970
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2971
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-[var(--radius,12px)] bg-muted/40 p-4", children: [
|
|
2972
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
2973
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: "Payment" }),
|
|
2974
|
+
payment.stateLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2975
|
+
"span",
|
|
2976
|
+
{
|
|
2977
|
+
className: cn(
|
|
2978
|
+
"rounded-full px-2 py-0.5 text-[11.5px] font-semibold",
|
|
2979
|
+
payment.stateTone === "warning" ? "bg-amber-500/10 text-amber-600" : payment.stateTone === "muted" ? "bg-muted/70 text-foreground/60" : "bg-emerald-500/10 text-emerald-600"
|
|
2980
|
+
),
|
|
2981
|
+
children: payment.stateLabel
|
|
2982
|
+
}
|
|
2983
|
+
)
|
|
2984
|
+
] }),
|
|
2985
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 text-[13px]", children: [
|
|
2986
|
+
payment.rows.map((row, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
|
|
2987
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground/55", children: row.label }),
|
|
2988
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("tabular-nums", row.tone === "positive" && "text-emerald-600"), children: row.value })
|
|
2989
|
+
] }, i)),
|
|
2990
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-2 h-px bg-border" }),
|
|
2991
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between text-[15px] font-semibold", children: [
|
|
2992
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: payment.total.label }),
|
|
2993
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums", children: payment.total.value })
|
|
2994
|
+
] })
|
|
2995
|
+
] }),
|
|
2996
|
+
payment.method && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2997
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 h-px bg-border" }),
|
|
2998
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[12.5px] text-foreground", children: payment.method })
|
|
2999
|
+
] })
|
|
3000
|
+
] }),
|
|
3001
|
+
shipTo && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-7", children: [
|
|
3002
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: shipTo.heading ?? "Delivering to" }),
|
|
3003
|
+
shipTo.name && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-[13px] font-semibold text-foreground", children: shipTo.name }),
|
|
3004
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-[12.5px] leading-relaxed text-foreground/55", children: shipTo.lines })
|
|
3005
|
+
] }),
|
|
3006
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-7 space-y-2.5", children: actions })
|
|
3007
|
+
] })
|
|
3008
|
+
] })
|
|
3009
|
+
] });
|
|
3010
|
+
}
|
|
2549
3011
|
function SubscriptionRow({
|
|
2550
3012
|
subscription,
|
|
2551
3013
|
onSelect,
|
|
@@ -2711,11 +3173,11 @@ function CimplifySignInButton({
|
|
|
2711
3173
|
onError,
|
|
2712
3174
|
...signInOpts
|
|
2713
3175
|
}) {
|
|
2714
|
-
const [busy, setBusy] =
|
|
3176
|
+
const [busy, setBusy] = React14.useState(false);
|
|
2715
3177
|
const onClick = async () => {
|
|
2716
3178
|
if (busy || disabled) return;
|
|
2717
3179
|
setBusy(true);
|
|
2718
|
-
await
|
|
3180
|
+
await chunkWCSAZRNC_js.startSignIn({
|
|
2719
3181
|
...signInOpts,
|
|
2720
3182
|
onSuccess: () => {
|
|
2721
3183
|
setBusy(false);
|
|
@@ -3327,9 +3789,9 @@ function AccountSubscriptionDetailPage({
|
|
|
3327
3789
|
}
|
|
3328
3790
|
function useCimplifySession(options) {
|
|
3329
3791
|
const sessionUri = options?.sessionUri ?? "/auth/session";
|
|
3330
|
-
const [session, setSession] =
|
|
3331
|
-
const [loading, setLoading] =
|
|
3332
|
-
const fetchSession =
|
|
3792
|
+
const [session, setSession] = React14.useState(null);
|
|
3793
|
+
const [loading, setLoading] = React14.useState(true);
|
|
3794
|
+
const fetchSession = React14.useCallback(async () => {
|
|
3333
3795
|
setLoading(true);
|
|
3334
3796
|
try {
|
|
3335
3797
|
const res = await fetch(sessionUri, { credentials: "include" });
|
|
@@ -3345,11 +3807,218 @@ function useCimplifySession(options) {
|
|
|
3345
3807
|
setLoading(false);
|
|
3346
3808
|
}
|
|
3347
3809
|
}, [sessionUri]);
|
|
3348
|
-
|
|
3810
|
+
React14.useEffect(() => {
|
|
3349
3811
|
void fetchSession();
|
|
3350
3812
|
}, [fetchSession]);
|
|
3351
3813
|
return { session, loading, refresh: fetchSession };
|
|
3352
3814
|
}
|
|
3815
|
+
var DEFAULT_LINKS = [
|
|
3816
|
+
{
|
|
3817
|
+
label: "Your orders",
|
|
3818
|
+
href: "/account/orders",
|
|
3819
|
+
icon: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
|
|
3820
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z" }),
|
|
3821
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 6h18" }),
|
|
3822
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 10a4 4 0 0 1-8 0" })
|
|
3823
|
+
] })
|
|
3824
|
+
},
|
|
3825
|
+
{
|
|
3826
|
+
label: "Subscriptions",
|
|
3827
|
+
href: "/account/subscriptions",
|
|
3828
|
+
icon: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
|
|
3829
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
3830
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9h18M8 2v4M16 2v4" })
|
|
3831
|
+
] })
|
|
3832
|
+
}
|
|
3833
|
+
];
|
|
3834
|
+
var LinkIcon = /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
|
|
3835
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 13.5a4 4 0 0 0 5.6 0l3-3a4 4 0 0 0-5.6-5.6L11.5 6.4" }),
|
|
3836
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 10.5a4 4 0 0 0-5.6 0l-3 3a4 4 0 0 0 5.6 5.6l1.5-1.5" })
|
|
3837
|
+
] });
|
|
3838
|
+
var ExternalIcon = /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, className: "ml-auto opacity-50", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 17 17 7M9 7h8v8" }) });
|
|
3839
|
+
function Avatar({ seed, name, size }) {
|
|
3840
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3841
|
+
"span",
|
|
3842
|
+
{
|
|
3843
|
+
"aria-hidden": true,
|
|
3844
|
+
className: "grid place-items-center rounded-full font-serif font-semibold text-white shrink-0",
|
|
3845
|
+
style: { width: size, height: size, fontSize: size * 0.4, background: avatarGradient(seed) },
|
|
3846
|
+
children: initials(name)
|
|
3847
|
+
}
|
|
3848
|
+
);
|
|
3849
|
+
}
|
|
3850
|
+
function CimplifyUserButton({
|
|
3851
|
+
session: controlledSession,
|
|
3852
|
+
sessionUri,
|
|
3853
|
+
links = DEFAULT_LINKS,
|
|
3854
|
+
identityUrl = "https://link.cimplify.io",
|
|
3855
|
+
signOutHref = "/auth/signout",
|
|
3856
|
+
onSignOut,
|
|
3857
|
+
clientId,
|
|
3858
|
+
redirectUri,
|
|
3859
|
+
signInLabel,
|
|
3860
|
+
onSignIn,
|
|
3861
|
+
hideName,
|
|
3862
|
+
align = "end",
|
|
3863
|
+
className
|
|
3864
|
+
}) {
|
|
3865
|
+
const controlled = controlledSession !== void 0;
|
|
3866
|
+
const hook = useCimplifySession({ sessionUri });
|
|
3867
|
+
const session = controlled ? controlledSession : hook.session;
|
|
3868
|
+
const loading = controlled ? false : hook.loading;
|
|
3869
|
+
const [open, setOpen] = React14.useState(false);
|
|
3870
|
+
const rootRef = React14.useRef(null);
|
|
3871
|
+
const menuId = React14.useId();
|
|
3872
|
+
React14.useEffect(() => {
|
|
3873
|
+
if (!open) return;
|
|
3874
|
+
const onDocClick = (e) => {
|
|
3875
|
+
if (!rootRef.current?.contains(e.target)) setOpen(false);
|
|
3876
|
+
};
|
|
3877
|
+
const onKey = (e) => {
|
|
3878
|
+
if (e.key === "Escape") setOpen(false);
|
|
3879
|
+
};
|
|
3880
|
+
document.addEventListener("mousedown", onDocClick);
|
|
3881
|
+
document.addEventListener("keydown", onKey);
|
|
3882
|
+
return () => {
|
|
3883
|
+
document.removeEventListener("mousedown", onDocClick);
|
|
3884
|
+
document.removeEventListener("keydown", onKey);
|
|
3885
|
+
};
|
|
3886
|
+
}, [open]);
|
|
3887
|
+
if (loading) {
|
|
3888
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("inline-flex items-center", className), "data-cimplify-user-button": "loading", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-8 rounded-full bg-muted/60 animate-pulse" }) });
|
|
3889
|
+
}
|
|
3890
|
+
if (!session) {
|
|
3891
|
+
if (!clientId || !redirectUri) return null;
|
|
3892
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3893
|
+
CimplifySignInButton,
|
|
3894
|
+
{
|
|
3895
|
+
variant: "outline",
|
|
3896
|
+
label: signInLabel ?? "Sign in",
|
|
3897
|
+
clientId,
|
|
3898
|
+
redirectUri,
|
|
3899
|
+
onSuccess: onSignIn,
|
|
3900
|
+
className
|
|
3901
|
+
}
|
|
3902
|
+
);
|
|
3903
|
+
}
|
|
3904
|
+
const name = session.name?.trim() || session.email || "Account";
|
|
3905
|
+
const seed = session.sub || name;
|
|
3906
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: rootRef, className: cn("relative inline-block", className), "data-cimplify-user-button": true, children: [
|
|
3907
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3908
|
+
"button",
|
|
3909
|
+
{
|
|
3910
|
+
type: "button",
|
|
3911
|
+
onClick: () => setOpen((v) => !v),
|
|
3912
|
+
"aria-haspopup": "menu",
|
|
3913
|
+
"aria-expanded": open,
|
|
3914
|
+
"aria-controls": menuId,
|
|
3915
|
+
className: cn(
|
|
3916
|
+
"inline-flex items-center gap-2 rounded-full border border-border bg-card p-1 pr-2.5",
|
|
3917
|
+
"shadow-[0_1px_2px_rgba(16,24,40,0.06)] transition-colors cursor-pointer",
|
|
3918
|
+
"hover:border-foreground/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
3919
|
+
hideName && "pr-1"
|
|
3920
|
+
),
|
|
3921
|
+
children: [
|
|
3922
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { seed, name, size: 28 }),
|
|
3923
|
+
!hideName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-[120px] truncate text-[13px] font-semibold text-foreground", children: session.name?.split(/\s+/)[0] || name }),
|
|
3924
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3925
|
+
"svg",
|
|
3926
|
+
{
|
|
3927
|
+
width: "13",
|
|
3928
|
+
height: "13",
|
|
3929
|
+
viewBox: "0 0 24 24",
|
|
3930
|
+
fill: "none",
|
|
3931
|
+
stroke: "currentColor",
|
|
3932
|
+
strokeWidth: "2.2",
|
|
3933
|
+
"aria-hidden": true,
|
|
3934
|
+
className: cn("text-foreground/45 transition-transform", open && "rotate-180"),
|
|
3935
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6" })
|
|
3936
|
+
}
|
|
3937
|
+
)
|
|
3938
|
+
]
|
|
3939
|
+
}
|
|
3940
|
+
),
|
|
3941
|
+
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3942
|
+
"div",
|
|
3943
|
+
{
|
|
3944
|
+
id: menuId,
|
|
3945
|
+
role: "menu",
|
|
3946
|
+
className: cn(
|
|
3947
|
+
"absolute top-[calc(100%+8px)] z-50 w-[280px] max-w-[calc(100vw-1.5rem)] overflow-hidden",
|
|
3948
|
+
"rounded-[14px] border border-border bg-card",
|
|
3949
|
+
"shadow-[0_1px_2px_rgba(16,24,40,0.04),0_16px_40px_-16px_rgba(16,24,40,0.24)]",
|
|
3950
|
+
align === "end" ? "right-0" : "left-0"
|
|
3951
|
+
),
|
|
3952
|
+
children: [
|
|
3953
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 border-b border-border/60 p-3.5", children: [
|
|
3954
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { seed, name, size: 40 }),
|
|
3955
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
3956
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-[14px] font-semibold text-foreground", children: name }),
|
|
3957
|
+
session.email && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-[12px] text-foreground/55", children: session.email })
|
|
3958
|
+
] })
|
|
3959
|
+
] }),
|
|
3960
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-1.5", children: [
|
|
3961
|
+
links.map((link) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3962
|
+
"a",
|
|
3963
|
+
{
|
|
3964
|
+
role: "menuitem",
|
|
3965
|
+
href: link.href,
|
|
3966
|
+
target: link.external ? "_blank" : void 0,
|
|
3967
|
+
rel: link.external ? "noreferrer" : void 0,
|
|
3968
|
+
className: "flex items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-foreground hover:bg-muted/50",
|
|
3969
|
+
children: [
|
|
3970
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground/45", children: link.icon }),
|
|
3971
|
+
link.label,
|
|
3972
|
+
link.external && ExternalIcon
|
|
3973
|
+
]
|
|
3974
|
+
},
|
|
3975
|
+
link.href
|
|
3976
|
+
)),
|
|
3977
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-1.5 h-px bg-border/60" }),
|
|
3978
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3979
|
+
"a",
|
|
3980
|
+
{
|
|
3981
|
+
role: "menuitem",
|
|
3982
|
+
href: identityUrl,
|
|
3983
|
+
target: "_blank",
|
|
3984
|
+
rel: "noreferrer",
|
|
3985
|
+
className: "flex items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-foreground hover:bg-muted/50",
|
|
3986
|
+
children: [
|
|
3987
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground/45", children: LinkIcon }),
|
|
3988
|
+
"Manage Cimplify identity",
|
|
3989
|
+
ExternalIcon
|
|
3990
|
+
]
|
|
3991
|
+
}
|
|
3992
|
+
),
|
|
3993
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3994
|
+
"form",
|
|
3995
|
+
{
|
|
3996
|
+
method: "post",
|
|
3997
|
+
action: signOutHref,
|
|
3998
|
+
onSubmit: onSignOut ? () => onSignOut() : void 0,
|
|
3999
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4000
|
+
"button",
|
|
4001
|
+
{
|
|
4002
|
+
type: "submit",
|
|
4003
|
+
role: "menuitem",
|
|
4004
|
+
className: "flex w-full items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-destructive hover:bg-destructive/10",
|
|
4005
|
+
children: [
|
|
4006
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
|
|
4007
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
|
|
4008
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m16 17 5-5-5-5M21 12H9" })
|
|
4009
|
+
] }),
|
|
4010
|
+
"Sign out"
|
|
4011
|
+
]
|
|
4012
|
+
}
|
|
4013
|
+
)
|
|
4014
|
+
}
|
|
4015
|
+
)
|
|
4016
|
+
] })
|
|
4017
|
+
]
|
|
4018
|
+
}
|
|
4019
|
+
)
|
|
4020
|
+
] });
|
|
4021
|
+
}
|
|
3353
4022
|
function Price({ amount, currency, className, prefix }) {
|
|
3354
4023
|
const context = useOptionalCimplify();
|
|
3355
4024
|
const resolvedCurrency = currency ?? context?.displayCurrency ?? "USD";
|
|
@@ -3384,9 +4053,9 @@ function createCachedQuery(config) {
|
|
|
3384
4053
|
}
|
|
3385
4054
|
const enabled = options.enabled ?? true;
|
|
3386
4055
|
const locationId = client.getLocationId();
|
|
3387
|
-
const previousLocationRef =
|
|
3388
|
-
const requestIdRef =
|
|
3389
|
-
const optionsRef =
|
|
4056
|
+
const previousLocationRef = React14.useRef(locationId);
|
|
4057
|
+
const requestIdRef = React14.useRef(0);
|
|
4058
|
+
const optionsRef = React14.useRef(options);
|
|
3390
4059
|
optionsRef.current = options;
|
|
3391
4060
|
if (config.locationSensitive && previousLocationRef.current !== locationId) {
|
|
3392
4061
|
cache.clear();
|
|
@@ -3396,10 +4065,10 @@ function createCachedQuery(config) {
|
|
|
3396
4065
|
sweep();
|
|
3397
4066
|
const cacheKey2 = config.key(client, options);
|
|
3398
4067
|
const cached = cache.get(cacheKey2);
|
|
3399
|
-
const [data, setData] =
|
|
3400
|
-
const [isLoading, setIsLoading] =
|
|
3401
|
-
const [error, setError] =
|
|
3402
|
-
const load =
|
|
4068
|
+
const [data, setData] = React14.useState(cached?.data ?? null);
|
|
4069
|
+
const [isLoading, setIsLoading] = React14.useState(enabled && !cached);
|
|
4070
|
+
const [error, setError] = React14.useState(null);
|
|
4071
|
+
const load = React14.useCallback(
|
|
3403
4072
|
async (force = false) => {
|
|
3404
4073
|
if (!enabled) {
|
|
3405
4074
|
setIsLoading(false);
|
|
@@ -3442,10 +4111,10 @@ function createCachedQuery(config) {
|
|
|
3442
4111
|
},
|
|
3443
4112
|
[cacheKey2, client, enabled]
|
|
3444
4113
|
);
|
|
3445
|
-
|
|
4114
|
+
React14.useEffect(() => {
|
|
3446
4115
|
void load(false);
|
|
3447
4116
|
}, [load]);
|
|
3448
|
-
const refetch =
|
|
4117
|
+
const refetch = React14.useCallback(async () => {
|
|
3449
4118
|
cache.delete(cacheKey2);
|
|
3450
4119
|
await load(true);
|
|
3451
4120
|
}, [cacheKey2, load]);
|
|
@@ -3575,25 +4244,25 @@ function useOrder(orderId, options = {}) {
|
|
|
3575
4244
|
if (!client) {
|
|
3576
4245
|
throw new Error("useOrder must be used within CimplifyProvider or passed { client }.");
|
|
3577
4246
|
}
|
|
3578
|
-
const normalizedOrderId =
|
|
4247
|
+
const normalizedOrderId = React14.useMemo(() => (orderId || "").trim(), [orderId]);
|
|
3579
4248
|
const enabled = options.enabled ?? true;
|
|
3580
4249
|
const poll = options.poll ?? false;
|
|
3581
4250
|
const pollInterval = options.pollInterval ?? 5e3;
|
|
3582
|
-
const requestIdRef =
|
|
3583
|
-
const previousStatusRef =
|
|
3584
|
-
const onStatusChangeRef =
|
|
4251
|
+
const requestIdRef = React14.useRef(0);
|
|
4252
|
+
const previousStatusRef = React14.useRef(null);
|
|
4253
|
+
const onStatusChangeRef = React14.useRef(options.onStatusChange);
|
|
3585
4254
|
onStatusChangeRef.current = options.onStatusChange;
|
|
3586
|
-
const cacheKey2 =
|
|
4255
|
+
const cacheKey2 = React14.useMemo(
|
|
3587
4256
|
() => buildOrderCacheKey(client, normalizedOrderId),
|
|
3588
4257
|
[client, normalizedOrderId]
|
|
3589
4258
|
);
|
|
3590
4259
|
const cached = orderCache.get(cacheKey2);
|
|
3591
|
-
const [order, setOrder] =
|
|
3592
|
-
const [isLoading, setIsLoading] =
|
|
4260
|
+
const [order, setOrder] = React14.useState(cached?.order ?? null);
|
|
4261
|
+
const [isLoading, setIsLoading] = React14.useState(
|
|
3593
4262
|
enabled && normalizedOrderId.length > 0 && !cached
|
|
3594
4263
|
);
|
|
3595
|
-
const [error, setError] =
|
|
3596
|
-
const load =
|
|
4264
|
+
const [error, setError] = React14.useState(null);
|
|
4265
|
+
const load = React14.useCallback(
|
|
3597
4266
|
async (force = false) => {
|
|
3598
4267
|
if (!enabled || normalizedOrderId.length === 0) {
|
|
3599
4268
|
setOrder(null);
|
|
@@ -3652,11 +4321,11 @@ function useOrder(orderId, options = {}) {
|
|
|
3652
4321
|
},
|
|
3653
4322
|
[cacheKey2, client, enabled, normalizedOrderId]
|
|
3654
4323
|
);
|
|
3655
|
-
|
|
4324
|
+
React14.useEffect(() => {
|
|
3656
4325
|
void load(false);
|
|
3657
4326
|
}, [load]);
|
|
3658
4327
|
const isTerminal = order ? TERMINAL_STATUSES.has(order.status) : false;
|
|
3659
|
-
|
|
4328
|
+
React14.useEffect(() => {
|
|
3660
4329
|
if (!poll || !enabled || normalizedOrderId.length === 0 || isTerminal) {
|
|
3661
4330
|
return;
|
|
3662
4331
|
}
|
|
@@ -3667,7 +4336,7 @@ function useOrder(orderId, options = {}) {
|
|
|
3667
4336
|
window.clearInterval(timer);
|
|
3668
4337
|
};
|
|
3669
4338
|
}, [enabled, isTerminal, load, normalizedOrderId, poll, pollInterval]);
|
|
3670
|
-
const refetch =
|
|
4339
|
+
const refetch = React14.useCallback(async () => {
|
|
3671
4340
|
orderCache.delete(cacheKey2);
|
|
3672
4341
|
await load(true);
|
|
3673
4342
|
}, [cacheKey2, load]);
|
|
@@ -3718,10 +4387,10 @@ function useLocations(options = {}) {
|
|
|
3718
4387
|
};
|
|
3719
4388
|
}
|
|
3720
4389
|
const client = options.client;
|
|
3721
|
-
const [locations, setLocations] =
|
|
3722
|
-
const [currentLocation, setCurrentLocationState] =
|
|
3723
|
-
const [isLoading, setIsLoading] =
|
|
3724
|
-
const setCurrentLocation =
|
|
4390
|
+
const [locations, setLocations] = React14.useState([]);
|
|
4391
|
+
const [currentLocation, setCurrentLocationState] = React14.useState(null);
|
|
4392
|
+
const [isLoading, setIsLoading] = React14.useState(true);
|
|
4393
|
+
const setCurrentLocation = React14.useCallback(
|
|
3725
4394
|
(location) => {
|
|
3726
4395
|
setCurrentLocationState(location);
|
|
3727
4396
|
if (client) {
|
|
@@ -3731,7 +4400,7 @@ function useLocations(options = {}) {
|
|
|
3731
4400
|
},
|
|
3732
4401
|
[client]
|
|
3733
4402
|
);
|
|
3734
|
-
|
|
4403
|
+
React14.useEffect(() => {
|
|
3735
4404
|
if (!client) {
|
|
3736
4405
|
setLocations([]);
|
|
3737
4406
|
setCurrentLocationState(null);
|
|
@@ -3835,14 +4504,14 @@ function useSearch(options = {}) {
|
|
|
3835
4504
|
const minLength = Math.max(0, options.minLength ?? 2);
|
|
3836
4505
|
const debounceMs = Math.max(0, options.debounceMs ?? 300);
|
|
3837
4506
|
const limit = Math.max(1, options.limit ?? 20);
|
|
3838
|
-
const [query, setQueryState] =
|
|
3839
|
-
const [results, setResults] =
|
|
3840
|
-
const [isLoading, setIsLoading] =
|
|
3841
|
-
const [error, setError] =
|
|
3842
|
-
const requestIdRef =
|
|
3843
|
-
const timerRef =
|
|
4507
|
+
const [query, setQueryState] = React14.useState("");
|
|
4508
|
+
const [results, setResults] = React14.useState([]);
|
|
4509
|
+
const [isLoading, setIsLoading] = React14.useState(false);
|
|
4510
|
+
const [error, setError] = React14.useState(null);
|
|
4511
|
+
const requestIdRef = React14.useRef(0);
|
|
4512
|
+
const timerRef = React14.useRef(null);
|
|
3844
4513
|
const tagsSignature = options.tags?.join(",") ?? "";
|
|
3845
|
-
|
|
4514
|
+
React14.useEffect(() => {
|
|
3846
4515
|
if (timerRef.current) {
|
|
3847
4516
|
clearTimeout(timerRef.current);
|
|
3848
4517
|
timerRef.current = null;
|
|
@@ -3897,10 +4566,10 @@ function useSearch(options = {}) {
|
|
|
3897
4566
|
}
|
|
3898
4567
|
};
|
|
3899
4568
|
}, [client, debounceMs, limit, minLength, options.category, options.taxonomy, tagsSignature, options.featured, options.in_stock, options.min_price, options.max_price, options.sort_by, options.sort_order, query]);
|
|
3900
|
-
const setQuery =
|
|
4569
|
+
const setQuery = React14.useCallback((nextQuery) => {
|
|
3901
4570
|
setQueryState(nextQuery);
|
|
3902
4571
|
}, []);
|
|
3903
|
-
const clear =
|
|
4572
|
+
const clear = React14.useCallback(() => {
|
|
3904
4573
|
requestIdRef.current += 1;
|
|
3905
4574
|
if (timerRef.current) {
|
|
3906
4575
|
clearTimeout(timerRef.current);
|
|
@@ -3991,34 +4660,34 @@ function useQuote(input, options = {}) {
|
|
|
3991
4660
|
const autoRefresh = options.autoRefresh ?? true;
|
|
3992
4661
|
const refreshBeforeExpiryMs = Math.max(0, options.refreshBeforeExpiryMs ?? 3e4);
|
|
3993
4662
|
const locationId = client.getLocationId();
|
|
3994
|
-
const requestIdRef =
|
|
3995
|
-
const debounceTimerRef =
|
|
4663
|
+
const requestIdRef = React14.useRef(0);
|
|
4664
|
+
const debounceTimerRef = React14.useRef(null);
|
|
3996
4665
|
const inputSignature = buildQuoteInputSignature(input);
|
|
3997
|
-
const normalizedInput =
|
|
4666
|
+
const normalizedInput = React14.useMemo(() => {
|
|
3998
4667
|
if (!input) {
|
|
3999
4668
|
return null;
|
|
4000
4669
|
}
|
|
4001
4670
|
const normalized = normalizeInput(input, locationId);
|
|
4002
4671
|
return normalized.product_id.length > 0 ? normalized : null;
|
|
4003
4672
|
}, [inputSignature, locationId]);
|
|
4004
|
-
const cacheKey2 =
|
|
4673
|
+
const cacheKey2 = React14.useMemo(
|
|
4005
4674
|
() => buildQuoteCacheKey(client, locationId, inputSignature),
|
|
4006
4675
|
[client, inputSignature, locationId]
|
|
4007
4676
|
);
|
|
4008
4677
|
const cached = quoteCache.get(cacheKey2);
|
|
4009
|
-
const [quote, setQuote] =
|
|
4010
|
-
const [isLoading, setIsLoading] =
|
|
4011
|
-
const [error, setError] =
|
|
4012
|
-
const [isExpired, setIsExpired] =
|
|
4013
|
-
const [messages, setMessages] =
|
|
4014
|
-
const quoteExpiryTimestamp =
|
|
4678
|
+
const [quote, setQuote] = React14.useState(cached?.quote ?? null);
|
|
4679
|
+
const [isLoading, setIsLoading] = React14.useState(enabled && normalizedInput !== null && !cached);
|
|
4680
|
+
const [error, setError] = React14.useState(null);
|
|
4681
|
+
const [isExpired, setIsExpired] = React14.useState(isQuoteExpired(cached?.quote ?? null));
|
|
4682
|
+
const [messages, setMessages] = React14.useState(cached?.quote?.ui_messages ?? []);
|
|
4683
|
+
const quoteExpiryTimestamp = React14.useMemo(() => {
|
|
4015
4684
|
if (!quote?.expires_at) {
|
|
4016
4685
|
return Number.NaN;
|
|
4017
4686
|
}
|
|
4018
4687
|
const expiresAt = Date.parse(quote.expires_at);
|
|
4019
4688
|
return Number.isFinite(expiresAt) ? expiresAt : Number.NaN;
|
|
4020
4689
|
}, [quote?.expires_at]);
|
|
4021
|
-
const load =
|
|
4690
|
+
const load = React14.useCallback(
|
|
4022
4691
|
async (force = false) => {
|
|
4023
4692
|
if (!enabled || !normalizedInput) {
|
|
4024
4693
|
setQuote(null);
|
|
@@ -4078,7 +4747,7 @@ function useQuote(input, options = {}) {
|
|
|
4078
4747
|
},
|
|
4079
4748
|
[cacheKey2, client, enabled, normalizedInput]
|
|
4080
4749
|
);
|
|
4081
|
-
|
|
4750
|
+
React14.useEffect(() => {
|
|
4082
4751
|
if (debounceTimerRef.current) {
|
|
4083
4752
|
clearTimeout(debounceTimerRef.current);
|
|
4084
4753
|
}
|
|
@@ -4097,7 +4766,7 @@ function useQuote(input, options = {}) {
|
|
|
4097
4766
|
}
|
|
4098
4767
|
};
|
|
4099
4768
|
}, [load, cacheKey2, enabled, normalizedInput]);
|
|
4100
|
-
const refresh =
|
|
4769
|
+
const refresh = React14.useCallback(async () => {
|
|
4101
4770
|
if (!enabled || !normalizedInput) {
|
|
4102
4771
|
return;
|
|
4103
4772
|
}
|
|
@@ -4134,7 +4803,7 @@ function useQuote(input, options = {}) {
|
|
|
4134
4803
|
}
|
|
4135
4804
|
}
|
|
4136
4805
|
}, [cacheKey2, client, enabled, load, normalizedInput, quote]);
|
|
4137
|
-
|
|
4806
|
+
React14.useEffect(() => {
|
|
4138
4807
|
if (!Number.isFinite(quoteExpiryTimestamp)) {
|
|
4139
4808
|
setIsExpired(false);
|
|
4140
4809
|
return;
|
|
@@ -4310,9 +4979,9 @@ function useValidateDiscount(options = {}) {
|
|
|
4310
4979
|
if (!client) {
|
|
4311
4980
|
throw new Error("useValidateDiscount must be used within CimplifyProvider or passed { client }.");
|
|
4312
4981
|
}
|
|
4313
|
-
const [isValidating, setIsValidating] =
|
|
4314
|
-
const [error, setError] =
|
|
4315
|
-
const validate =
|
|
4982
|
+
const [isValidating, setIsValidating] = React14.useState(false);
|
|
4983
|
+
const [error, setError] = React14.useState(null);
|
|
4984
|
+
const validate = React14.useCallback(
|
|
4316
4985
|
async (code, orderSubtotal, locationId) => {
|
|
4317
4986
|
setError(null);
|
|
4318
4987
|
setIsValidating(true);
|
|
@@ -4359,7 +5028,7 @@ function useProductPrice(input) {
|
|
|
4359
5028
|
compositePrice,
|
|
4360
5029
|
bundleTotalPrice
|
|
4361
5030
|
} = input;
|
|
4362
|
-
return
|
|
5031
|
+
return React14.useMemo(() => {
|
|
4363
5032
|
let unitPrice;
|
|
4364
5033
|
if (bundleTotalPrice != null) {
|
|
4365
5034
|
unitPrice = bundleTotalPrice;
|
|
@@ -4408,10 +5077,10 @@ function useOrders(options = {}) {
|
|
|
4408
5077
|
function useSubscriptions(options = {}) {
|
|
4409
5078
|
const { client } = useCimplifyClient();
|
|
4410
5079
|
const { status, enabled = true } = options;
|
|
4411
|
-
const [subscriptions, setSubscriptions] =
|
|
4412
|
-
const [isLoading, setIsLoading] =
|
|
4413
|
-
const [error, setError] =
|
|
4414
|
-
const fetch2 =
|
|
5080
|
+
const [subscriptions, setSubscriptions] = React14.useState([]);
|
|
5081
|
+
const [isLoading, setIsLoading] = React14.useState(false);
|
|
5082
|
+
const [error, setError] = React14.useState(null);
|
|
5083
|
+
const fetch2 = React14.useCallback(async () => {
|
|
4415
5084
|
if (!enabled) return;
|
|
4416
5085
|
setIsLoading(true);
|
|
4417
5086
|
setError(null);
|
|
@@ -4429,7 +5098,7 @@ function useSubscriptions(options = {}) {
|
|
|
4429
5098
|
setIsLoading(false);
|
|
4430
5099
|
}
|
|
4431
5100
|
}, [client, enabled, status]);
|
|
4432
|
-
|
|
5101
|
+
React14.useEffect(() => {
|
|
4433
5102
|
void fetch2();
|
|
4434
5103
|
}, [fetch2]);
|
|
4435
5104
|
return { subscriptions, isLoading, error, refetch: fetch2 };
|
|
@@ -4438,10 +5107,10 @@ function useSubscription(id, options = {}) {
|
|
|
4438
5107
|
const { client } = useCimplifyClient();
|
|
4439
5108
|
const { enabled = true } = options;
|
|
4440
5109
|
const normalizedId = (id || "").trim();
|
|
4441
|
-
const [subscription, setSubscription] =
|
|
4442
|
-
const [isLoading, setIsLoading] =
|
|
4443
|
-
const [error, setError] =
|
|
4444
|
-
const fetch2 =
|
|
5110
|
+
const [subscription, setSubscription] = React14.useState(null);
|
|
5111
|
+
const [isLoading, setIsLoading] = React14.useState(false);
|
|
5112
|
+
const [error, setError] = React14.useState(null);
|
|
5113
|
+
const fetch2 = React14.useCallback(async () => {
|
|
4445
5114
|
if (!enabled || !normalizedId) return;
|
|
4446
5115
|
setIsLoading(true);
|
|
4447
5116
|
setError(null);
|
|
@@ -4458,25 +5127,25 @@ function useSubscription(id, options = {}) {
|
|
|
4458
5127
|
setIsLoading(false);
|
|
4459
5128
|
}
|
|
4460
5129
|
}, [client, enabled, normalizedId]);
|
|
4461
|
-
|
|
5130
|
+
React14.useEffect(() => {
|
|
4462
5131
|
void fetch2();
|
|
4463
5132
|
}, [fetch2]);
|
|
4464
|
-
const cancel =
|
|
5133
|
+
const cancel = React14.useCallback(async (reason) => {
|
|
4465
5134
|
if (!normalizedId) return;
|
|
4466
5135
|
await client.subscriptions.cancel(normalizedId, reason);
|
|
4467
5136
|
void fetch2();
|
|
4468
5137
|
}, [client, normalizedId, fetch2]);
|
|
4469
|
-
const pause =
|
|
5138
|
+
const pause = React14.useCallback(async () => {
|
|
4470
5139
|
if (!normalizedId) return;
|
|
4471
5140
|
await client.subscriptions.pause(normalizedId);
|
|
4472
5141
|
void fetch2();
|
|
4473
5142
|
}, [client, normalizedId, fetch2]);
|
|
4474
|
-
const resume =
|
|
5143
|
+
const resume = React14.useCallback(async () => {
|
|
4475
5144
|
if (!normalizedId) return;
|
|
4476
5145
|
await client.subscriptions.resume(normalizedId);
|
|
4477
5146
|
void fetch2();
|
|
4478
5147
|
}, [client, normalizedId, fetch2]);
|
|
4479
|
-
const skipNext =
|
|
5148
|
+
const skipNext = React14.useCallback(async () => {
|
|
4480
5149
|
if (!normalizedId) return;
|
|
4481
5150
|
await client.subscriptions.skipNextRenewal(normalizedId);
|
|
4482
5151
|
void fetch2();
|
|
@@ -4580,7 +5249,7 @@ function useBookings(options = {}) {
|
|
|
4580
5249
|
const context = useOptionalCimplifyClient();
|
|
4581
5250
|
const client = options.client ?? context?.client;
|
|
4582
5251
|
const { data, isLoading, error, refetch } = bookingsQuery(options);
|
|
4583
|
-
const cancelBooking =
|
|
5252
|
+
const cancelBooking = React14.useCallback(
|
|
4584
5253
|
async (bookingId, reason) => {
|
|
4585
5254
|
if (!client) throw new Error("useBookings must be used within CimplifyProvider or passed { client }.");
|
|
4586
5255
|
const result = await client.scheduling.cancelBooking({
|
|
@@ -4636,14 +5305,14 @@ function useBillingPlans(productId, options = {}) {
|
|
|
4636
5305
|
throw new Error("useBillingPlans must be used within CimplifyProvider or passed { client }.");
|
|
4637
5306
|
}
|
|
4638
5307
|
const enabled = options.enabled ?? true;
|
|
4639
|
-
const requestIdRef =
|
|
4640
|
-
const [plans, setPlans] =
|
|
4641
|
-
const [isLoading, setIsLoading] =
|
|
4642
|
-
const [error, setError] =
|
|
5308
|
+
const requestIdRef = React14.useRef(0);
|
|
5309
|
+
const [plans, setPlans] = React14.useState([]);
|
|
5310
|
+
const [isLoading, setIsLoading] = React14.useState(enabled && !!productId);
|
|
5311
|
+
const [error, setError] = React14.useState(null);
|
|
4643
5312
|
const customerId = options.customerId;
|
|
4644
5313
|
const quantity = options.quantity;
|
|
4645
5314
|
const orderValue = options.orderValue;
|
|
4646
|
-
const load =
|
|
5315
|
+
const load = React14.useCallback(
|
|
4647
5316
|
async (force = false) => {
|
|
4648
5317
|
if (!enabled || !productId) {
|
|
4649
5318
|
setPlans([]);
|
|
@@ -4678,17 +5347,17 @@ function useBillingPlans(productId, options = {}) {
|
|
|
4678
5347
|
},
|
|
4679
5348
|
[client, enabled, productId, customerId, quantity, orderValue]
|
|
4680
5349
|
);
|
|
4681
|
-
|
|
5350
|
+
React14.useEffect(() => {
|
|
4682
5351
|
void load(false);
|
|
4683
5352
|
}, [load]);
|
|
4684
|
-
const refetch =
|
|
5353
|
+
const refetch = React14.useCallback(async () => {
|
|
4685
5354
|
await load(true);
|
|
4686
5355
|
}, [load]);
|
|
4687
|
-
const subscriptionPlans =
|
|
5356
|
+
const subscriptionPlans = React14.useMemo(
|
|
4688
5357
|
() => plans.filter((p) => p.plan_type === "subscription"),
|
|
4689
5358
|
[plans]
|
|
4690
5359
|
);
|
|
4691
|
-
const installmentPlans =
|
|
5360
|
+
const installmentPlans = React14.useMemo(
|
|
4692
5361
|
() => plans.filter((p) => p.plan_type === "installment"),
|
|
4693
5362
|
[plans]
|
|
4694
5363
|
);
|
|
@@ -4723,8 +5392,8 @@ function computeAvailableValues(variants, axes, selections) {
|
|
|
4723
5392
|
}
|
|
4724
5393
|
function useVariantSelector(options) {
|
|
4725
5394
|
const { variants, axes } = options;
|
|
4726
|
-
const [selectedValues, setSelectedValues] =
|
|
4727
|
-
const selectValue =
|
|
5395
|
+
const [selectedValues, setSelectedValues] = React14.useState({});
|
|
5396
|
+
const selectValue = React14.useCallback(
|
|
4728
5397
|
(axisId, valueId) => {
|
|
4729
5398
|
setSelectedValues((prev) => {
|
|
4730
5399
|
if (prev[axisId] === valueId) {
|
|
@@ -4737,16 +5406,16 @@ function useVariantSelector(options) {
|
|
|
4737
5406
|
},
|
|
4738
5407
|
[]
|
|
4739
5408
|
);
|
|
4740
|
-
const reset =
|
|
4741
|
-
const selectedVariant =
|
|
5409
|
+
const reset = React14.useCallback(() => setSelectedValues({}), []);
|
|
5410
|
+
const selectedVariant = React14.useMemo(
|
|
4742
5411
|
() => findMatchingVariant(variants, selectedValues),
|
|
4743
5412
|
[variants, selectedValues]
|
|
4744
5413
|
);
|
|
4745
|
-
const variantImage =
|
|
5414
|
+
const variantImage = React14.useMemo(
|
|
4746
5415
|
() => selectedVariant?.images?.[0] ?? null,
|
|
4747
5416
|
[selectedVariant]
|
|
4748
5417
|
);
|
|
4749
|
-
const availableValues =
|
|
5418
|
+
const availableValues = React14.useMemo(
|
|
4750
5419
|
() => computeAvailableValues(variants, axes, selectedValues),
|
|
4751
5420
|
[variants, axes, selectedValues]
|
|
4752
5421
|
);
|
|
@@ -4772,7 +5441,7 @@ function useActivityState(options = {}) {
|
|
|
4772
5441
|
const context = useOptionalCimplifyClient();
|
|
4773
5442
|
const client = options.client ?? context?.client;
|
|
4774
5443
|
const { data, isLoading, error, refetch } = activityStateQuery(options);
|
|
4775
|
-
const dismissMessage =
|
|
5444
|
+
const dismissMessage = React14.useCallback(
|
|
4776
5445
|
async (code) => {
|
|
4777
5446
|
if (!client) return;
|
|
4778
5447
|
const result = await client.activity.dismissMessage(code);
|
|
@@ -4874,31 +5543,31 @@ var WS_PATH = "/api/v1/support/conversation/ws";
|
|
|
4874
5543
|
function useChat(options = {}) {
|
|
4875
5544
|
const context = useOptionalCimplifyClient();
|
|
4876
5545
|
const client = options.client ?? context?.client;
|
|
4877
|
-
const [messages, setMessages] =
|
|
4878
|
-
const [isLoading, setIsLoading] =
|
|
4879
|
-
const [isSending, setIsSending] =
|
|
4880
|
-
const [error, setError] =
|
|
4881
|
-
const [conversationOpened, setConversationOpened] =
|
|
4882
|
-
const pollRef =
|
|
4883
|
-
const lastActivityRef =
|
|
4884
|
-
const openedRef =
|
|
4885
|
-
const messagesRef =
|
|
4886
|
-
const clientRef =
|
|
4887
|
-
const wsRef =
|
|
4888
|
-
const wsReconnectAttemptRef =
|
|
4889
|
-
const wsReconnectTimerRef =
|
|
5546
|
+
const [messages, setMessages] = React14.useState([]);
|
|
5547
|
+
const [isLoading, setIsLoading] = React14.useState(false);
|
|
5548
|
+
const [isSending, setIsSending] = React14.useState(false);
|
|
5549
|
+
const [error, setError] = React14.useState(null);
|
|
5550
|
+
const [conversationOpened, setConversationOpened] = React14.useState(false);
|
|
5551
|
+
const pollRef = React14.useRef(null);
|
|
5552
|
+
const lastActivityRef = React14.useRef(Date.now());
|
|
5553
|
+
const openedRef = React14.useRef(false);
|
|
5554
|
+
const messagesRef = React14.useRef([]);
|
|
5555
|
+
const clientRef = React14.useRef(client);
|
|
5556
|
+
const wsRef = React14.useRef(null);
|
|
5557
|
+
const wsReconnectAttemptRef = React14.useRef(0);
|
|
5558
|
+
const wsReconnectTimerRef = React14.useRef(null);
|
|
4890
5559
|
messagesRef.current = messages;
|
|
4891
5560
|
clientRef.current = client;
|
|
4892
5561
|
const pollInterval = options.pollInterval ?? POLL_INTERVAL_MS;
|
|
4893
5562
|
const pollIdleInterval = options.pollIdleInterval ?? POLL_IDLE_INTERVAL_MS;
|
|
4894
|
-
const appendMessages =
|
|
5563
|
+
const appendMessages = React14.useCallback((incoming) => {
|
|
4895
5564
|
setMessages((prev) => {
|
|
4896
5565
|
const ids = new Set(prev.map((m) => m.id));
|
|
4897
5566
|
const fresh = incoming.filter((m) => !ids.has(m.id));
|
|
4898
5567
|
return fresh.length > 0 ? [...prev, ...fresh] : prev;
|
|
4899
5568
|
});
|
|
4900
5569
|
}, []);
|
|
4901
|
-
const pollMessages =
|
|
5570
|
+
const pollMessages = React14.useCallback(async () => {
|
|
4902
5571
|
const c = clientRef.current;
|
|
4903
5572
|
if (!c) return;
|
|
4904
5573
|
if (Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS) return;
|
|
@@ -4911,18 +5580,18 @@ function useChat(options = {}) {
|
|
|
4911
5580
|
appendMessages(result.value);
|
|
4912
5581
|
}
|
|
4913
5582
|
}, [appendMessages]);
|
|
4914
|
-
const startPolling =
|
|
5583
|
+
const startPolling = React14.useCallback(() => {
|
|
4915
5584
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
4916
5585
|
const interval = Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS ? pollIdleInterval : pollInterval;
|
|
4917
5586
|
pollRef.current = setInterval(pollMessages, interval);
|
|
4918
5587
|
}, [pollMessages, pollInterval, pollIdleInterval]);
|
|
4919
|
-
const stopPolling =
|
|
5588
|
+
const stopPolling = React14.useCallback(() => {
|
|
4920
5589
|
if (pollRef.current) {
|
|
4921
5590
|
clearInterval(pollRef.current);
|
|
4922
5591
|
pollRef.current = null;
|
|
4923
5592
|
}
|
|
4924
5593
|
}, []);
|
|
4925
|
-
const connectWebSocket =
|
|
5594
|
+
const connectWebSocket = React14.useCallback(() => {
|
|
4926
5595
|
const c = clientRef.current;
|
|
4927
5596
|
if (!c || typeof WebSocket === "undefined") {
|
|
4928
5597
|
startPolling();
|
|
@@ -4963,7 +5632,7 @@ function useChat(options = {}) {
|
|
|
4963
5632
|
};
|
|
4964
5633
|
wsRef.current = ws;
|
|
4965
5634
|
}, [appendMessages, startPolling, stopPolling, pollMessages]);
|
|
4966
|
-
|
|
5635
|
+
React14.useEffect(() => {
|
|
4967
5636
|
return () => {
|
|
4968
5637
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
4969
5638
|
if (wsReconnectTimerRef.current) clearTimeout(wsReconnectTimerRef.current);
|
|
@@ -4973,7 +5642,7 @@ function useChat(options = {}) {
|
|
|
4973
5642
|
}
|
|
4974
5643
|
};
|
|
4975
5644
|
}, []);
|
|
4976
|
-
const openConversation =
|
|
5645
|
+
const openConversation = React14.useCallback(async () => {
|
|
4977
5646
|
if (openedRef.current || !client) return;
|
|
4978
5647
|
openedRef.current = true;
|
|
4979
5648
|
setIsLoading(true);
|
|
@@ -4989,7 +5658,7 @@ function useChat(options = {}) {
|
|
|
4989
5658
|
}
|
|
4990
5659
|
setIsLoading(false);
|
|
4991
5660
|
}, [client, connectWebSocket]);
|
|
4992
|
-
const send =
|
|
5661
|
+
const send = React14.useCallback(
|
|
4993
5662
|
async (content) => {
|
|
4994
5663
|
if (!client || !content.trim()) return;
|
|
4995
5664
|
setError(null);
|
|
@@ -5023,7 +5692,7 @@ function useChat(options = {}) {
|
|
|
5023
5692
|
},
|
|
5024
5693
|
[client, openConversation]
|
|
5025
5694
|
);
|
|
5026
|
-
const startConversation =
|
|
5695
|
+
const startConversation = React14.useCallback(
|
|
5027
5696
|
async (starterText) => {
|
|
5028
5697
|
await openConversation();
|
|
5029
5698
|
if (starterText) {
|
|
@@ -5042,15 +5711,15 @@ function useChat(options = {}) {
|
|
|
5042
5711
|
startConversation
|
|
5043
5712
|
};
|
|
5044
5713
|
}
|
|
5045
|
-
var ElementsContext =
|
|
5714
|
+
var ElementsContext = React14.createContext({
|
|
5046
5715
|
elements: null,
|
|
5047
5716
|
isReady: false
|
|
5048
5717
|
});
|
|
5049
5718
|
function useElements() {
|
|
5050
|
-
return
|
|
5719
|
+
return React14.useContext(ElementsContext).elements;
|
|
5051
5720
|
}
|
|
5052
5721
|
function useElementsReady() {
|
|
5053
|
-
return
|
|
5722
|
+
return React14.useContext(ElementsContext).isReady;
|
|
5054
5723
|
}
|
|
5055
5724
|
function ElementsProvider({
|
|
5056
5725
|
client,
|
|
@@ -5058,10 +5727,10 @@ function ElementsProvider({
|
|
|
5058
5727
|
options,
|
|
5059
5728
|
children
|
|
5060
5729
|
}) {
|
|
5061
|
-
const [elements, setElements] =
|
|
5062
|
-
const [isReady, setIsReady] =
|
|
5063
|
-
const initialOptionsRef =
|
|
5064
|
-
|
|
5730
|
+
const [elements, setElements] = React14.useState(null);
|
|
5731
|
+
const [isReady, setIsReady] = React14.useState(false);
|
|
5732
|
+
const initialOptionsRef = React14.useRef(options);
|
|
5733
|
+
React14.useEffect(() => {
|
|
5065
5734
|
let cancelled = false;
|
|
5066
5735
|
let instance = null;
|
|
5067
5736
|
setIsReady(false);
|
|
@@ -5101,28 +5770,28 @@ function AuthElement({
|
|
|
5101
5770
|
onAuthenticated,
|
|
5102
5771
|
onError
|
|
5103
5772
|
}) {
|
|
5104
|
-
const containerRef =
|
|
5105
|
-
const elementRef =
|
|
5773
|
+
const containerRef = React14.useRef(null);
|
|
5774
|
+
const elementRef = React14.useRef(null);
|
|
5106
5775
|
const elements = useElements();
|
|
5107
|
-
const onReadyRef =
|
|
5108
|
-
const onAuthenticatedRef =
|
|
5109
|
-
const onErrorRef =
|
|
5110
|
-
|
|
5776
|
+
const onReadyRef = React14.useRef(onReady);
|
|
5777
|
+
const onAuthenticatedRef = React14.useRef(onAuthenticated);
|
|
5778
|
+
const onErrorRef = React14.useRef(onError);
|
|
5779
|
+
React14.useEffect(() => {
|
|
5111
5780
|
onReadyRef.current = onReady;
|
|
5112
5781
|
onAuthenticatedRef.current = onAuthenticated;
|
|
5113
5782
|
onErrorRef.current = onError;
|
|
5114
5783
|
}, [onReady, onAuthenticated, onError]);
|
|
5115
|
-
|
|
5784
|
+
React14.useEffect(() => {
|
|
5116
5785
|
if (!elements || !containerRef.current) return;
|
|
5117
|
-
const element = elements.create(
|
|
5786
|
+
const element = elements.create(chunkWCSAZRNC_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
5118
5787
|
elementRef.current = element;
|
|
5119
|
-
element.on(
|
|
5788
|
+
element.on(chunkWCSAZRNC_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
5120
5789
|
element.on(
|
|
5121
|
-
|
|
5790
|
+
chunkWCSAZRNC_js.EVENT_TYPES.AUTHENTICATED,
|
|
5122
5791
|
(data) => onAuthenticatedRef.current?.(data)
|
|
5123
5792
|
);
|
|
5124
5793
|
element.on(
|
|
5125
|
-
|
|
5794
|
+
chunkWCSAZRNC_js.EVENT_TYPES.ERROR,
|
|
5126
5795
|
(data) => onErrorRef.current?.(data)
|
|
5127
5796
|
);
|
|
5128
5797
|
element.mount(containerRef.current);
|
|
@@ -5138,28 +5807,28 @@ function AddressElement({
|
|
|
5138
5807
|
onChange,
|
|
5139
5808
|
onError
|
|
5140
5809
|
}) {
|
|
5141
|
-
const containerRef =
|
|
5142
|
-
const elementRef =
|
|
5810
|
+
const containerRef = React14.useRef(null);
|
|
5811
|
+
const elementRef = React14.useRef(null);
|
|
5143
5812
|
const elements = useElements();
|
|
5144
|
-
const onReadyRef =
|
|
5145
|
-
const onChangeRef =
|
|
5146
|
-
const onErrorRef =
|
|
5147
|
-
|
|
5813
|
+
const onReadyRef = React14.useRef(onReady);
|
|
5814
|
+
const onChangeRef = React14.useRef(onChange);
|
|
5815
|
+
const onErrorRef = React14.useRef(onError);
|
|
5816
|
+
React14.useEffect(() => {
|
|
5148
5817
|
onReadyRef.current = onReady;
|
|
5149
5818
|
onChangeRef.current = onChange;
|
|
5150
5819
|
onErrorRef.current = onError;
|
|
5151
5820
|
}, [onReady, onChange, onError]);
|
|
5152
|
-
|
|
5821
|
+
React14.useEffect(() => {
|
|
5153
5822
|
if (!elements || !containerRef.current) return;
|
|
5154
|
-
const element = elements.create(
|
|
5823
|
+
const element = elements.create(chunkWCSAZRNC_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
5155
5824
|
elementRef.current = element;
|
|
5156
|
-
element.on(
|
|
5825
|
+
element.on(chunkWCSAZRNC_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
5157
5826
|
element.on(
|
|
5158
|
-
|
|
5827
|
+
chunkWCSAZRNC_js.EVENT_TYPES.CHANGE,
|
|
5159
5828
|
(data) => onChangeRef.current?.(data)
|
|
5160
5829
|
);
|
|
5161
5830
|
element.on(
|
|
5162
|
-
|
|
5831
|
+
chunkWCSAZRNC_js.EVENT_TYPES.ERROR,
|
|
5163
5832
|
(data) => onErrorRef.current?.(data)
|
|
5164
5833
|
);
|
|
5165
5834
|
element.mount(containerRef.current);
|
|
@@ -5176,28 +5845,28 @@ function PaymentElement({
|
|
|
5176
5845
|
onChange,
|
|
5177
5846
|
onError
|
|
5178
5847
|
}) {
|
|
5179
|
-
const containerRef =
|
|
5180
|
-
const elementRef =
|
|
5848
|
+
const containerRef = React14.useRef(null);
|
|
5849
|
+
const elementRef = React14.useRef(null);
|
|
5181
5850
|
const elements = useElements();
|
|
5182
|
-
const onReadyRef =
|
|
5183
|
-
const onChangeRef =
|
|
5184
|
-
const onErrorRef =
|
|
5185
|
-
|
|
5851
|
+
const onReadyRef = React14.useRef(onReady);
|
|
5852
|
+
const onChangeRef = React14.useRef(onChange);
|
|
5853
|
+
const onErrorRef = React14.useRef(onError);
|
|
5854
|
+
React14.useEffect(() => {
|
|
5186
5855
|
onReadyRef.current = onReady;
|
|
5187
5856
|
onChangeRef.current = onChange;
|
|
5188
5857
|
onErrorRef.current = onError;
|
|
5189
5858
|
}, [onReady, onChange, onError]);
|
|
5190
|
-
|
|
5859
|
+
React14.useEffect(() => {
|
|
5191
5860
|
if (!elements || !containerRef.current) return;
|
|
5192
|
-
const element = elements.create(
|
|
5861
|
+
const element = elements.create(chunkWCSAZRNC_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
5193
5862
|
elementRef.current = element;
|
|
5194
|
-
element.on(
|
|
5863
|
+
element.on(chunkWCSAZRNC_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
5195
5864
|
element.on(
|
|
5196
|
-
|
|
5865
|
+
chunkWCSAZRNC_js.EVENT_TYPES.CHANGE,
|
|
5197
5866
|
(data) => onChangeRef.current?.(data)
|
|
5198
5867
|
);
|
|
5199
5868
|
element.on(
|
|
5200
|
-
|
|
5869
|
+
chunkWCSAZRNC_js.EVENT_TYPES.ERROR,
|
|
5201
5870
|
(data) => onErrorRef.current?.(data)
|
|
5202
5871
|
);
|
|
5203
5872
|
element.mount(containerRef.current);
|
|
@@ -5207,8 +5876,8 @@ function PaymentElement({
|
|
|
5207
5876
|
}
|
|
5208
5877
|
function useCheckout() {
|
|
5209
5878
|
const elements = useElements();
|
|
5210
|
-
const [isLoading, setIsLoading] =
|
|
5211
|
-
const submit =
|
|
5879
|
+
const [isLoading, setIsLoading] = React14.useState(false);
|
|
5880
|
+
const submit = React14.useCallback(
|
|
5212
5881
|
async (data) => {
|
|
5213
5882
|
if (!elements) {
|
|
5214
5883
|
return { success: false, error: { code: "NO_ELEMENTS", message: "Elements not initialized" } };
|
|
@@ -5222,7 +5891,7 @@ function useCheckout() {
|
|
|
5222
5891
|
},
|
|
5223
5892
|
[elements]
|
|
5224
5893
|
);
|
|
5225
|
-
const process =
|
|
5894
|
+
const process = React14.useCallback(
|
|
5226
5895
|
async (options) => {
|
|
5227
5896
|
if (!elements) {
|
|
5228
5897
|
return {
|
|
@@ -5316,13 +5985,13 @@ function VariantSelector({
|
|
|
5316
5985
|
className,
|
|
5317
5986
|
classNames
|
|
5318
5987
|
}) {
|
|
5319
|
-
const [axisSelections, setAxisSelections] =
|
|
5320
|
-
const initialized =
|
|
5321
|
-
const idPrefix =
|
|
5322
|
-
|
|
5988
|
+
const [axisSelections, setAxisSelections] = React14.useState({});
|
|
5989
|
+
const initialized = React14.useRef(false);
|
|
5990
|
+
const idPrefix = React14.useId();
|
|
5991
|
+
React14.useEffect(() => {
|
|
5323
5992
|
initialized.current = false;
|
|
5324
5993
|
}, [variants]);
|
|
5325
|
-
|
|
5994
|
+
React14.useEffect(() => {
|
|
5326
5995
|
if (initialized.current) return;
|
|
5327
5996
|
if (!variants || variants.length === 0) return;
|
|
5328
5997
|
const defaultVariant = variants.find((v) => v.is_default) || variants[0];
|
|
@@ -5337,7 +6006,7 @@ function VariantSelector({
|
|
|
5337
6006
|
setAxisSelections(initial);
|
|
5338
6007
|
}
|
|
5339
6008
|
}, [variants, onVariantChange]);
|
|
5340
|
-
|
|
6009
|
+
React14.useEffect(() => {
|
|
5341
6010
|
if (!initialized.current) return;
|
|
5342
6011
|
if (!variantAxes || variantAxes.length === 0) return;
|
|
5343
6012
|
const match = variants.find((v) => {
|
|
@@ -5480,12 +6149,12 @@ function AddOnSelector({
|
|
|
5480
6149
|
className,
|
|
5481
6150
|
classNames
|
|
5482
6151
|
}) {
|
|
5483
|
-
const selectedSet =
|
|
5484
|
-
const isOptionSelected =
|
|
6152
|
+
const selectedSet = React14.useMemo(() => new Set(selectedOptions), [selectedOptions]);
|
|
6153
|
+
const isOptionSelected = React14.useCallback(
|
|
5485
6154
|
(optionId) => selectedSet.has(optionId),
|
|
5486
6155
|
[selectedSet]
|
|
5487
6156
|
);
|
|
5488
|
-
const handleCheckedChange =
|
|
6157
|
+
const handleCheckedChange = React14.useCallback(
|
|
5489
6158
|
(addOn, optionId, checked) => {
|
|
5490
6159
|
const isSelected = selectedSet.has(optionId);
|
|
5491
6160
|
if (addOn.is_mutually_exclusive || !addOn.is_multiple_allowed) {
|
|
@@ -5661,9 +6330,9 @@ function BundleSelector({
|
|
|
5661
6330
|
className,
|
|
5662
6331
|
classNames
|
|
5663
6332
|
}) {
|
|
5664
|
-
const [variantChoices, setVariantChoices] =
|
|
5665
|
-
const lastComponentIds =
|
|
5666
|
-
|
|
6333
|
+
const [variantChoices, setVariantChoices] = React14.useState({});
|
|
6334
|
+
const lastComponentIds = React14.useRef("");
|
|
6335
|
+
React14.useEffect(() => {
|
|
5667
6336
|
const ids = components.map((c) => c.id).sort().join();
|
|
5668
6337
|
if (ids === lastComponentIds.current) return;
|
|
5669
6338
|
lastComponentIds.current = ids;
|
|
@@ -5680,20 +6349,20 @@ function BundleSelector({
|
|
|
5680
6349
|
}
|
|
5681
6350
|
setVariantChoices(defaults);
|
|
5682
6351
|
}, [components]);
|
|
5683
|
-
const selections =
|
|
6352
|
+
const selections = React14.useMemo(() => {
|
|
5684
6353
|
return components.map((comp) => ({
|
|
5685
6354
|
component_id: comp.id,
|
|
5686
6355
|
variant_id: variantChoices[comp.id],
|
|
5687
6356
|
quantity: comp.quantity
|
|
5688
6357
|
}));
|
|
5689
6358
|
}, [components, variantChoices]);
|
|
5690
|
-
|
|
6359
|
+
React14.useEffect(() => {
|
|
5691
6360
|
onSelectionsChange(selections);
|
|
5692
6361
|
}, [selections, onSelectionsChange]);
|
|
5693
|
-
|
|
6362
|
+
React14.useEffect(() => {
|
|
5694
6363
|
onReady?.(components.length > 0 && selections.length > 0);
|
|
5695
6364
|
}, [components, selections, onReady]);
|
|
5696
|
-
const totalPrice =
|
|
6365
|
+
const totalPrice = React14.useMemo(() => {
|
|
5697
6366
|
if (pricingType === "fixed" && bundlePrice) {
|
|
5698
6367
|
return chunk7Y2O3E4D_js.parsePrice(bundlePrice);
|
|
5699
6368
|
}
|
|
@@ -5708,10 +6377,10 @@ function BundleSelector({
|
|
|
5708
6377
|
}
|
|
5709
6378
|
return componentsTotal;
|
|
5710
6379
|
}, [components, variantChoices, pricingType, bundlePrice, discountValue]);
|
|
5711
|
-
|
|
6380
|
+
React14.useEffect(() => {
|
|
5712
6381
|
onPriceChange?.(totalPrice);
|
|
5713
6382
|
}, [totalPrice, onPriceChange]);
|
|
5714
|
-
const handleVariantChange =
|
|
6383
|
+
const handleVariantChange = React14.useCallback(
|
|
5715
6384
|
(componentId, variantId) => {
|
|
5716
6385
|
setVariantChoices((prev) => ({ ...prev, [componentId]: variantId }));
|
|
5717
6386
|
},
|
|
@@ -5792,9 +6461,9 @@ function BundleComponentCard({
|
|
|
5792
6461
|
onVariantChange,
|
|
5793
6462
|
classNames
|
|
5794
6463
|
}) {
|
|
5795
|
-
const idPrefix =
|
|
6464
|
+
const idPrefix = React14.useId();
|
|
5796
6465
|
const showVariantPicker = component.allow_variant_choice && component.available_variants.length > 1;
|
|
5797
|
-
const displayPrice =
|
|
6466
|
+
const displayPrice = React14.useMemo(
|
|
5798
6467
|
() => getComponentPrice(component, selectedVariantId),
|
|
5799
6468
|
[component, selectedVariantId]
|
|
5800
6469
|
);
|
|
@@ -5942,11 +6611,11 @@ function CompositeSelector({
|
|
|
5942
6611
|
classNames
|
|
5943
6612
|
}) {
|
|
5944
6613
|
const { client } = useCimplifyClient();
|
|
5945
|
-
const [groupSelections, setGroupSelections] =
|
|
5946
|
-
const [priceResult, setPriceResult] =
|
|
5947
|
-
const [isPriceLoading, setIsPriceLoading] =
|
|
5948
|
-
const [priceError, setPriceError] =
|
|
5949
|
-
const selections =
|
|
6614
|
+
const [groupSelections, setGroupSelections] = React14.useState({});
|
|
6615
|
+
const [priceResult, setPriceResult] = React14.useState(null);
|
|
6616
|
+
const [isPriceLoading, setIsPriceLoading] = React14.useState(false);
|
|
6617
|
+
const [priceError, setPriceError] = React14.useState(false);
|
|
6618
|
+
const selections = React14.useMemo(() => {
|
|
5950
6619
|
const result = [];
|
|
5951
6620
|
for (const groupSels of Object.values(groupSelections)) {
|
|
5952
6621
|
for (const [componentId, qty] of Object.entries(groupSels)) {
|
|
@@ -5957,13 +6626,13 @@ function CompositeSelector({
|
|
|
5957
6626
|
}
|
|
5958
6627
|
return result;
|
|
5959
6628
|
}, [groupSelections]);
|
|
5960
|
-
|
|
6629
|
+
React14.useEffect(() => {
|
|
5961
6630
|
onSelectionsChange(selections);
|
|
5962
6631
|
}, [selections, onSelectionsChange]);
|
|
5963
|
-
|
|
6632
|
+
React14.useEffect(() => {
|
|
5964
6633
|
onPriceChange?.(priceResult);
|
|
5965
6634
|
}, [priceResult, onPriceChange]);
|
|
5966
|
-
const allGroupsSatisfied =
|
|
6635
|
+
const allGroupsSatisfied = React14.useMemo(() => {
|
|
5967
6636
|
for (const group of groups) {
|
|
5968
6637
|
const groupSels = groupSelections[group.id] || {};
|
|
5969
6638
|
const totalSelected = Object.values(groupSels).reduce((sum, q) => sum + q, 0);
|
|
@@ -5971,17 +6640,17 @@ function CompositeSelector({
|
|
|
5971
6640
|
}
|
|
5972
6641
|
return true;
|
|
5973
6642
|
}, [groups, groupSelections]);
|
|
5974
|
-
const sortedGroups =
|
|
6643
|
+
const sortedGroups = React14.useMemo(
|
|
5975
6644
|
() => [...groups].sort((a, b) => a.display_order - b.display_order).map((group) => ({
|
|
5976
6645
|
...group,
|
|
5977
6646
|
_sortedComponents: group.components.filter((component) => component.is_available && !component.is_archived).sort((a, b) => a.display_order - b.display_order)
|
|
5978
6647
|
})),
|
|
5979
6648
|
[groups]
|
|
5980
6649
|
);
|
|
5981
|
-
|
|
6650
|
+
React14.useEffect(() => {
|
|
5982
6651
|
onReady?.(allGroupsSatisfied);
|
|
5983
6652
|
}, [allGroupsSatisfied, onReady]);
|
|
5984
|
-
|
|
6653
|
+
React14.useEffect(() => {
|
|
5985
6654
|
if (skipPriceFetch || !allGroupsSatisfied || selections.length === 0) return;
|
|
5986
6655
|
let cancelled = false;
|
|
5987
6656
|
const timer = setTimeout(() => {
|
|
@@ -6008,7 +6677,7 @@ function CompositeSelector({
|
|
|
6008
6677
|
clearTimeout(timer);
|
|
6009
6678
|
};
|
|
6010
6679
|
}, [selections, allGroupsSatisfied, compositeId, client, skipPriceFetch]);
|
|
6011
|
-
const toggleComponent =
|
|
6680
|
+
const toggleComponent = React14.useCallback(
|
|
6012
6681
|
(group, component) => {
|
|
6013
6682
|
setGroupSelections((prev) => {
|
|
6014
6683
|
const groupSels = { ...prev[group.id] || {} };
|
|
@@ -6036,7 +6705,7 @@ function CompositeSelector({
|
|
|
6036
6705
|
},
|
|
6037
6706
|
[]
|
|
6038
6707
|
);
|
|
6039
|
-
const updateQuantity =
|
|
6708
|
+
const updateQuantity = React14.useCallback(
|
|
6040
6709
|
(group, componentId, newValue) => {
|
|
6041
6710
|
setGroupSelections((prev) => {
|
|
6042
6711
|
const groupSels = { ...prev[group.id] || {} };
|
|
@@ -6615,7 +7284,7 @@ function DatePicker({
|
|
|
6615
7284
|
classNames,
|
|
6616
7285
|
"aria-label": ariaLabel
|
|
6617
7286
|
}) {
|
|
6618
|
-
const [open, setOpen] =
|
|
7287
|
+
const [open, setOpen] = React14.useState(false);
|
|
6619
7288
|
const selected = parseValue(value);
|
|
6620
7289
|
const disabledMatchers = [];
|
|
6621
7290
|
if (minDate) disabledMatchers.push({ before: minDate });
|
|
@@ -6769,9 +7438,9 @@ function TimePicker({
|
|
|
6769
7438
|
classNames,
|
|
6770
7439
|
"aria-label": ariaLabel
|
|
6771
7440
|
}) {
|
|
6772
|
-
const [open, setOpen] =
|
|
7441
|
+
const [open, setOpen] = React14.useState(false);
|
|
6773
7442
|
const parsed = parseHHmm(value);
|
|
6774
|
-
const options =
|
|
7443
|
+
const options = React14.useMemo(
|
|
6775
7444
|
() => buildOptions(minTime, maxTime, stepMinutes),
|
|
6776
7445
|
[minTime, maxTime, stepMinutes]
|
|
6777
7446
|
);
|
|
@@ -6860,13 +7529,13 @@ function CustomerInputFields({
|
|
|
6860
7529
|
const clientContext = useOptionalCimplifyClient();
|
|
6861
7530
|
if (fields.length === 0) return null;
|
|
6862
7531
|
const sorted = [...fields].sort((a, b) => a.display_order - b.display_order);
|
|
6863
|
-
const setValue =
|
|
7532
|
+
const setValue = React14.useCallback(
|
|
6864
7533
|
(fieldId, value) => {
|
|
6865
7534
|
onChange({ ...values, [fieldId]: value });
|
|
6866
7535
|
},
|
|
6867
7536
|
[values, onChange]
|
|
6868
7537
|
);
|
|
6869
|
-
const defaultFileUpload =
|
|
7538
|
+
const defaultFileUpload = React14.useCallback(
|
|
6870
7539
|
async (file) => {
|
|
6871
7540
|
if (onFileUpload) return onFileUpload(file, {});
|
|
6872
7541
|
if (!clientContext?.client) throw new Error("No upload provider available");
|
|
@@ -7201,7 +7870,7 @@ function FileUploadInput({
|
|
|
7201
7870
|
onFileUpload,
|
|
7202
7871
|
classNames
|
|
7203
7872
|
}) {
|
|
7204
|
-
const [isUploading, setIsUploading] =
|
|
7873
|
+
const [isUploading, setIsUploading] = React14__default.default.useState(false);
|
|
7205
7874
|
const fileUrl = typeof value === "string" ? value : void 0;
|
|
7206
7875
|
const acceptedFormats = field.validation?.accepted_formats;
|
|
7207
7876
|
const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunkIQLJJW2H_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
|
|
@@ -7351,22 +8020,22 @@ function AddressInput({
|
|
|
7351
8020
|
}) {
|
|
7352
8021
|
const clientContext = useOptionalCimplifyClient();
|
|
7353
8022
|
const addr = value && typeof value === "object" ? value : null;
|
|
7354
|
-
const [inputText, setInputText] =
|
|
7355
|
-
const [suggestions, setSuggestions] =
|
|
7356
|
-
const [isOpen, setIsOpen] =
|
|
7357
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
7358
|
-
const debounceRef =
|
|
7359
|
-
const seqRef =
|
|
7360
|
-
const sessionTokenRef =
|
|
7361
|
-
const blurTimeoutRef =
|
|
7362
|
-
|
|
8023
|
+
const [inputText, setInputText] = React14__default.default.useState(addr?.formatted_address ?? "");
|
|
8024
|
+
const [suggestions, setSuggestions] = React14__default.default.useState([]);
|
|
8025
|
+
const [isOpen, setIsOpen] = React14__default.default.useState(false);
|
|
8026
|
+
const [highlightedIndex, setHighlightedIndex] = React14__default.default.useState(-1);
|
|
8027
|
+
const debounceRef = React14__default.default.useRef(null);
|
|
8028
|
+
const seqRef = React14__default.default.useRef(0);
|
|
8029
|
+
const sessionTokenRef = React14__default.default.useRef(createSessionToken());
|
|
8030
|
+
const blurTimeoutRef = React14__default.default.useRef(null);
|
|
8031
|
+
React14__default.default.useEffect(() => {
|
|
7363
8032
|
return () => {
|
|
7364
8033
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7365
8034
|
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
7366
8035
|
seqRef.current += 1;
|
|
7367
8036
|
};
|
|
7368
8037
|
}, []);
|
|
7369
|
-
const fetchSuggestions =
|
|
8038
|
+
const fetchSuggestions = React14__default.default.useCallback(async (query) => {
|
|
7370
8039
|
const client = clientContext?.client;
|
|
7371
8040
|
if (!client || query.length < 3) {
|
|
7372
8041
|
setSuggestions([]);
|
|
@@ -7390,7 +8059,7 @@ function AddressInput({
|
|
|
7390
8059
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7391
8060
|
debounceRef.current = setTimeout(() => void fetchSuggestions(nextValue.trim()), 300);
|
|
7392
8061
|
};
|
|
7393
|
-
const selectSuggestion =
|
|
8062
|
+
const selectSuggestion = React14__default.default.useCallback(async (suggestion) => {
|
|
7394
8063
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7395
8064
|
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
7396
8065
|
const fallback = suggestion.description.split(",")[0]?.trim() || suggestion.description;
|
|
@@ -7493,22 +8162,22 @@ function LocationInput({
|
|
|
7493
8162
|
}) {
|
|
7494
8163
|
const clientContext = useOptionalCimplifyClient();
|
|
7495
8164
|
const loc = value && typeof value === "object" ? value : null;
|
|
7496
|
-
const [inputText, setInputText] =
|
|
7497
|
-
const [suggestions, setSuggestions] =
|
|
7498
|
-
const [isOpen, setIsOpen] =
|
|
7499
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
7500
|
-
const debounceRef =
|
|
7501
|
-
const seqRef =
|
|
7502
|
-
const sessionTokenRef =
|
|
7503
|
-
const blurTimeoutRef =
|
|
7504
|
-
|
|
8165
|
+
const [inputText, setInputText] = React14__default.default.useState(loc?.label ?? "");
|
|
8166
|
+
const [suggestions, setSuggestions] = React14__default.default.useState([]);
|
|
8167
|
+
const [isOpen, setIsOpen] = React14__default.default.useState(false);
|
|
8168
|
+
const [highlightedIndex, setHighlightedIndex] = React14__default.default.useState(-1);
|
|
8169
|
+
const debounceRef = React14__default.default.useRef(null);
|
|
8170
|
+
const seqRef = React14__default.default.useRef(0);
|
|
8171
|
+
const sessionTokenRef = React14__default.default.useRef(createSessionToken());
|
|
8172
|
+
const blurTimeoutRef = React14__default.default.useRef(null);
|
|
8173
|
+
React14__default.default.useEffect(() => {
|
|
7505
8174
|
return () => {
|
|
7506
8175
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7507
8176
|
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
7508
8177
|
seqRef.current += 1;
|
|
7509
8178
|
};
|
|
7510
8179
|
}, []);
|
|
7511
|
-
const fetchSuggestions =
|
|
8180
|
+
const fetchSuggestions = React14__default.default.useCallback(async (query) => {
|
|
7512
8181
|
const client = clientContext?.client;
|
|
7513
8182
|
if (!client || query.length < 3) {
|
|
7514
8183
|
setSuggestions([]);
|
|
@@ -7532,7 +8201,7 @@ function LocationInput({
|
|
|
7532
8201
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7533
8202
|
debounceRef.current = setTimeout(() => void fetchSuggestions(nextValue.trim()), 300);
|
|
7534
8203
|
};
|
|
7535
|
-
const selectSuggestion =
|
|
8204
|
+
const selectSuggestion = React14__default.default.useCallback(async (suggestion) => {
|
|
7536
8205
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
7537
8206
|
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
7538
8207
|
const label = suggestion.description.split(",")[0]?.trim() || suggestion.description;
|
|
@@ -7621,8 +8290,8 @@ function PhoneInput({
|
|
|
7621
8290
|
inputClass
|
|
7622
8291
|
}) {
|
|
7623
8292
|
const phone = value && typeof value === "object" ? value : null;
|
|
7624
|
-
const [code, setCode] =
|
|
7625
|
-
const [number, setNumber] =
|
|
8293
|
+
const [code, setCode] = React14__default.default.useState(phone?.country_code ?? "+1");
|
|
8294
|
+
const [number, setNumber] = React14__default.default.useState(phone?.number ?? "");
|
|
7626
8295
|
const update = (nextCode, nextNumber) => {
|
|
7627
8296
|
setCode(nextCode);
|
|
7628
8297
|
setNumber(nextNumber);
|
|
@@ -7667,8 +8336,8 @@ function SignatureInput({
|
|
|
7667
8336
|
classNames
|
|
7668
8337
|
}) {
|
|
7669
8338
|
const sig = value && typeof value === "object" ? value : null;
|
|
7670
|
-
const canvasRef =
|
|
7671
|
-
const isDrawing =
|
|
8339
|
+
const canvasRef = React14__default.default.useRef(null);
|
|
8340
|
+
const isDrawing = React14__default.default.useRef(false);
|
|
7672
8341
|
const getCtx = () => canvasRef.current?.getContext("2d") ?? null;
|
|
7673
8342
|
const startDraw = (e) => {
|
|
7674
8343
|
const ctx = getCtx();
|
|
@@ -7844,7 +8513,7 @@ function SlotPicker({
|
|
|
7844
8513
|
}
|
|
7845
8514
|
);
|
|
7846
8515
|
const rawSlots = slotsProp ?? fetched;
|
|
7847
|
-
const slots =
|
|
8516
|
+
const slots = React14.useMemo(() => {
|
|
7848
8517
|
if (!hideElapsedSlots) return rawSlots;
|
|
7849
8518
|
const cutoff = Date.now() + minLeadMinutes * 6e4;
|
|
7850
8519
|
return rawSlots.filter((slot) => {
|
|
@@ -7982,9 +8651,9 @@ function DateSlotPicker({
|
|
|
7982
8651
|
className,
|
|
7983
8652
|
classNames
|
|
7984
8653
|
}) {
|
|
7985
|
-
const [offset, setOffset] =
|
|
7986
|
-
const [selectedDate, setSelectedDate] =
|
|
7987
|
-
const dateRange =
|
|
8654
|
+
const [offset, setOffset] = React14.useState(0);
|
|
8655
|
+
const [selectedDate, setSelectedDate] = React14.useState(toDateString(/* @__PURE__ */ new Date()));
|
|
8656
|
+
const dateRange = React14.useMemo(() => {
|
|
7988
8657
|
const today = /* @__PURE__ */ new Date();
|
|
7989
8658
|
const start = addDays(today, offset);
|
|
7990
8659
|
const dates = [];
|
|
@@ -8007,25 +8676,25 @@ function DateSlotPicker({
|
|
|
8007
8676
|
}
|
|
8008
8677
|
);
|
|
8009
8678
|
const days = availabilityProp ?? fetchedDays;
|
|
8010
|
-
const availabilityMap =
|
|
8679
|
+
const availabilityMap = React14.useMemo(() => {
|
|
8011
8680
|
const map = /* @__PURE__ */ new Map();
|
|
8012
8681
|
for (const day of days) {
|
|
8013
8682
|
map.set(day.date, day);
|
|
8014
8683
|
}
|
|
8015
8684
|
return map;
|
|
8016
8685
|
}, [days]);
|
|
8017
|
-
const handlePrev =
|
|
8686
|
+
const handlePrev = React14.useCallback(() => {
|
|
8018
8687
|
setOffset((prev) => Math.max(0, prev - daysToShow));
|
|
8019
8688
|
}, [daysToShow]);
|
|
8020
|
-
const handleNext =
|
|
8689
|
+
const handleNext = React14.useCallback(() => {
|
|
8021
8690
|
setOffset((prev) => prev + daysToShow);
|
|
8022
8691
|
}, [daysToShow]);
|
|
8023
|
-
const handleDateChange =
|
|
8692
|
+
const handleDateChange = React14.useCallback((value) => {
|
|
8024
8693
|
if (typeof value === "string") {
|
|
8025
8694
|
setSelectedDate(value);
|
|
8026
8695
|
}
|
|
8027
8696
|
}, []);
|
|
8028
|
-
const handleSlotSelect =
|
|
8697
|
+
const handleSlotSelect = React14.useCallback(
|
|
8029
8698
|
(slot) => {
|
|
8030
8699
|
onSlotSelect?.(slot, selectedDate);
|
|
8031
8700
|
},
|
|
@@ -8141,22 +8810,22 @@ function ProductCustomizer({
|
|
|
8141
8810
|
className,
|
|
8142
8811
|
classNames
|
|
8143
8812
|
}) {
|
|
8144
|
-
const [quantity, setQuantity] =
|
|
8145
|
-
const [isAdded, setIsAdded] =
|
|
8146
|
-
const [isSubmitting, setIsSubmitting] =
|
|
8147
|
-
const [selectedVariantId, setSelectedVariantId] =
|
|
8148
|
-
const [selectedVariant, setSelectedVariant] =
|
|
8149
|
-
const [selectedAddOnOptionIds, setSelectedAddOnOptionIds] =
|
|
8150
|
-
const [compositeSelections, setCompositeSelections] =
|
|
8151
|
-
const [compositePrice, setCompositePrice] =
|
|
8152
|
-
const [compositeReady, setCompositeReady] =
|
|
8153
|
-
const [bundleSelections, setBundleSelections] =
|
|
8154
|
-
const [bundleTotalPrice, setBundleTotalPrice] =
|
|
8155
|
-
const [bundleReady, setBundleReady] =
|
|
8156
|
-
const [selectedBillingPlan, setSelectedBillingPlan] =
|
|
8157
|
-
const [customerInputValues, setCustomerInputValues] =
|
|
8158
|
-
const [specialInstructions, setSpecialInstructions] =
|
|
8159
|
-
const [selectedSlot, setSelectedSlot] =
|
|
8813
|
+
const [quantity, setQuantity] = React14.useState(product.min_order_quantity ?? 1);
|
|
8814
|
+
const [isAdded, setIsAdded] = React14.useState(false);
|
|
8815
|
+
const [isSubmitting, setIsSubmitting] = React14.useState(false);
|
|
8816
|
+
const [selectedVariantId, setSelectedVariantId] = React14.useState();
|
|
8817
|
+
const [selectedVariant, setSelectedVariant] = React14.useState();
|
|
8818
|
+
const [selectedAddOnOptionIds, setSelectedAddOnOptionIds] = React14.useState([]);
|
|
8819
|
+
const [compositeSelections, setCompositeSelections] = React14.useState([]);
|
|
8820
|
+
const [compositePrice, setCompositePrice] = React14.useState(null);
|
|
8821
|
+
const [compositeReady, setCompositeReady] = React14.useState(false);
|
|
8822
|
+
const [bundleSelections, setBundleSelections] = React14.useState([]);
|
|
8823
|
+
const [bundleTotalPrice, setBundleTotalPrice] = React14.useState(null);
|
|
8824
|
+
const [bundleReady, setBundleReady] = React14.useState(false);
|
|
8825
|
+
const [selectedBillingPlan, setSelectedBillingPlan] = React14.useState(null);
|
|
8826
|
+
const [customerInputValues, setCustomerInputValues] = React14.useState({});
|
|
8827
|
+
const [specialInstructions, setSpecialInstructions] = React14.useState("");
|
|
8828
|
+
const [selectedSlot, setSelectedSlot] = React14.useState(null);
|
|
8160
8829
|
const cart = useCart();
|
|
8161
8830
|
const productType = product.type || "product";
|
|
8162
8831
|
const isComposite = productType === "composite";
|
|
@@ -8166,7 +8835,7 @@ function ProductCustomizer({
|
|
|
8166
8835
|
const isStandard = !isComposite && !isBundle;
|
|
8167
8836
|
const hasVariants = isStandard && product.variants && product.variants.length > 0;
|
|
8168
8837
|
const hasAddOns = isStandard && product.add_ons && product.add_ons.length > 0;
|
|
8169
|
-
|
|
8838
|
+
React14.useEffect(() => {
|
|
8170
8839
|
setQuantity(product.min_order_quantity ?? 1);
|
|
8171
8840
|
setIsAdded(false);
|
|
8172
8841
|
setIsSubmitting(false);
|
|
@@ -8184,7 +8853,7 @@ function ProductCustomizer({
|
|
|
8184
8853
|
setSpecialInstructions("");
|
|
8185
8854
|
setSelectedSlot(null);
|
|
8186
8855
|
}, [product.id, product.min_order_quantity]);
|
|
8187
|
-
const selectedAddOnOptions =
|
|
8856
|
+
const selectedAddOnOptions = React14.useMemo(() => {
|
|
8188
8857
|
if (!product.add_ons) return [];
|
|
8189
8858
|
const options = [];
|
|
8190
8859
|
for (const addOn of product.add_ons) {
|
|
@@ -8196,11 +8865,11 @@ function ProductCustomizer({
|
|
|
8196
8865
|
}
|
|
8197
8866
|
return options;
|
|
8198
8867
|
}, [product.add_ons, selectedAddOnOptionIds]);
|
|
8199
|
-
const normalizedAddOnOptionIds =
|
|
8868
|
+
const normalizedAddOnOptionIds = React14.useMemo(() => {
|
|
8200
8869
|
if (selectedAddOnOptionIds.length === 0) return [];
|
|
8201
8870
|
return Array.from(new Set(selectedAddOnOptionIds.map((id) => id.trim()).filter(Boolean))).sort();
|
|
8202
8871
|
}, [selectedAddOnOptionIds]);
|
|
8203
|
-
const localTotalPrice =
|
|
8872
|
+
const localTotalPrice = React14.useMemo(() => {
|
|
8204
8873
|
if (isComposite && compositePrice) {
|
|
8205
8874
|
return chunk7Y2O3E4D_js.parsePrice(compositePrice.final_price) * quantity;
|
|
8206
8875
|
}
|
|
@@ -8218,7 +8887,7 @@ function ProductCustomizer({
|
|
|
8218
8887
|
}
|
|
8219
8888
|
return price * quantity;
|
|
8220
8889
|
}, [product.default_price, selectedVariant, selectedAddOnOptions, quantity, isComposite, compositePrice, isBundle, bundleTotalPrice]);
|
|
8221
|
-
const requiredAddOnsSatisfied =
|
|
8890
|
+
const requiredAddOnsSatisfied = React14.useMemo(() => {
|
|
8222
8891
|
if (!product.add_ons) return true;
|
|
8223
8892
|
for (const addOn of product.add_ons) {
|
|
8224
8893
|
if (addOn.is_required) {
|
|
@@ -8233,7 +8902,7 @@ function ProductCustomizer({
|
|
|
8233
8902
|
}
|
|
8234
8903
|
return true;
|
|
8235
8904
|
}, [product.add_ons, selectedAddOnOptionIds]);
|
|
8236
|
-
const quoteInput =
|
|
8905
|
+
const quoteInput = React14.useMemo(
|
|
8237
8906
|
() => ({
|
|
8238
8907
|
productId: product.id,
|
|
8239
8908
|
quantity,
|
|
@@ -8244,7 +8913,7 @@ function ProductCustomizer({
|
|
|
8244
8913
|
}),
|
|
8245
8914
|
[product.id, quantity, selectedVariantId, normalizedAddOnOptionIds, isBundle, bundleSelections, isComposite, compositeSelections]
|
|
8246
8915
|
);
|
|
8247
|
-
const requiredInputsSatisfied =
|
|
8916
|
+
const requiredInputsSatisfied = React14.useMemo(() => {
|
|
8248
8917
|
if (!product.input_fields || product.input_fields.length === 0) return true;
|
|
8249
8918
|
return product.input_fields.every((field) => {
|
|
8250
8919
|
if (!field.is_required) return true;
|
|
@@ -8257,7 +8926,7 @@ function ProductCustomizer({
|
|
|
8257
8926
|
enabled: quoteEnabled
|
|
8258
8927
|
});
|
|
8259
8928
|
const quoteId = quote?.quote_id;
|
|
8260
|
-
const quotedTotalPrice =
|
|
8929
|
+
const quotedTotalPrice = React14.useMemo(() => {
|
|
8261
8930
|
if (!quote) return void 0;
|
|
8262
8931
|
const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
|
|
8263
8932
|
const perUnit = priceInfo.pre_tax_price;
|
|
@@ -8265,7 +8934,7 @@ function ProductCustomizer({
|
|
|
8265
8934
|
return chunk7Y2O3E4D_js.parsePrice(perUnit) * quantity;
|
|
8266
8935
|
}, [quote, quantity]);
|
|
8267
8936
|
const displayTotalPrice = quotedTotalPrice ?? localTotalPrice;
|
|
8268
|
-
const handleVariantChange =
|
|
8937
|
+
const handleVariantChange = React14.useCallback(
|
|
8269
8938
|
(variantId, variant) => {
|
|
8270
8939
|
setSelectedVariantId(variantId);
|
|
8271
8940
|
setSelectedVariant(variant);
|
|
@@ -8273,9 +8942,9 @@ function ProductCustomizer({
|
|
|
8273
8942
|
},
|
|
8274
8943
|
[onVariantChange]
|
|
8275
8944
|
);
|
|
8276
|
-
const addedTimerRef =
|
|
8277
|
-
|
|
8278
|
-
const handleAddToCart =
|
|
8945
|
+
const addedTimerRef = React14.useRef(void 0);
|
|
8946
|
+
React14.useEffect(() => () => clearTimeout(addedTimerRef.current), []);
|
|
8947
|
+
const handleAddToCart = React14.useCallback(async () => {
|
|
8279
8948
|
if (isSubmitting) return;
|
|
8280
8949
|
setIsSubmitting(true);
|
|
8281
8950
|
const options = {
|
|
@@ -8500,14 +9169,14 @@ function ProductImageGallery({
|
|
|
8500
9169
|
aspectRatio = "4/3",
|
|
8501
9170
|
className
|
|
8502
9171
|
}) {
|
|
8503
|
-
const normalizedImages =
|
|
9172
|
+
const normalizedImages = React14.useMemo(
|
|
8504
9173
|
() => images.filter(
|
|
8505
9174
|
(image) => typeof image === "string" && image.trim().length > 0
|
|
8506
9175
|
),
|
|
8507
9176
|
[images]
|
|
8508
9177
|
);
|
|
8509
|
-
const [selectedImage, setSelectedImage] =
|
|
8510
|
-
|
|
9178
|
+
const [selectedImage, setSelectedImage] = React14.useState(0);
|
|
9179
|
+
React14.useEffect(() => {
|
|
8511
9180
|
setSelectedImage(0);
|
|
8512
9181
|
}, [normalizedImages.length, productName]);
|
|
8513
9182
|
if (normalizedImages.length === 0) {
|
|
@@ -8590,9 +9259,9 @@ function StoreVideo({
|
|
|
8590
9259
|
lazy = true,
|
|
8591
9260
|
className
|
|
8592
9261
|
}) {
|
|
8593
|
-
const ref =
|
|
8594
|
-
const [inView, setInView] =
|
|
8595
|
-
|
|
9262
|
+
const ref = React14.useRef(null);
|
|
9263
|
+
const [inView, setInView] = React14.useState(!lazy);
|
|
9264
|
+
React14.useEffect(() => {
|
|
8596
9265
|
if (!lazy || inView) return;
|
|
8597
9266
|
const node = ref.current;
|
|
8598
9267
|
if (!node || typeof IntersectionObserver === "undefined") {
|
|
@@ -8680,8 +9349,8 @@ function ProductModel3D({
|
|
|
8680
9349
|
cameraControls = true,
|
|
8681
9350
|
className
|
|
8682
9351
|
}) {
|
|
8683
|
-
const [ready, setReady] =
|
|
8684
|
-
|
|
9352
|
+
const [ready, setReady] = React14.useState(false);
|
|
9353
|
+
React14.useEffect(() => {
|
|
8685
9354
|
let cancelled = false;
|
|
8686
9355
|
ensureModelViewer().then(
|
|
8687
9356
|
() => {
|
|
@@ -8700,7 +9369,7 @@ function ProductModel3D({
|
|
|
8700
9369
|
"data-cimplify-product-model-3d": true,
|
|
8701
9370
|
className,
|
|
8702
9371
|
style: { position: "relative", overflow: "hidden", ...ASPECT_STYLES3[aspectRatio] },
|
|
8703
|
-
children: ready ?
|
|
9372
|
+
children: ready ? React14__default.default.createElement("model-viewer", {
|
|
8704
9373
|
src,
|
|
8705
9374
|
"ios-src": iosSrc,
|
|
8706
9375
|
alt,
|
|
@@ -8711,12 +9380,12 @@ function ProductModel3D({
|
|
|
8711
9380
|
"auto-rotate": autoRotate || void 0,
|
|
8712
9381
|
"shadow-intensity": "1",
|
|
8713
9382
|
style: { width: "100%", height: "100%", backgroundColor: "transparent" }
|
|
8714
|
-
}) : poster ?
|
|
9383
|
+
}) : poster ? React14__default.default.createElement("img", {
|
|
8715
9384
|
src: poster,
|
|
8716
9385
|
alt: alt ?? "",
|
|
8717
9386
|
"data-cimplify-product-model-3d-loading": true,
|
|
8718
9387
|
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
8719
|
-
}) :
|
|
9388
|
+
}) : React14__default.default.createElement("div", {
|
|
8720
9389
|
"data-cimplify-product-model-3d-loading": true,
|
|
8721
9390
|
style: { width: "100%", height: "100%", backgroundColor: "var(--muted, #f3f4f6)" }
|
|
8722
9391
|
})
|
|
@@ -8744,12 +9413,12 @@ function MediaGallery({
|
|
|
8744
9413
|
aspectRatio = "4/3",
|
|
8745
9414
|
className
|
|
8746
9415
|
}) {
|
|
8747
|
-
const validItems =
|
|
9416
|
+
const validItems = React14.useMemo(
|
|
8748
9417
|
() => items.filter((i) => typeof i.src === "string" && i.src.trim().length > 0),
|
|
8749
9418
|
[items]
|
|
8750
9419
|
);
|
|
8751
|
-
const [selected, setSelected] =
|
|
8752
|
-
|
|
9420
|
+
const [selected, setSelected] = React14.useState(0);
|
|
9421
|
+
React14.useEffect(() => {
|
|
8753
9422
|
setSelected(0);
|
|
8754
9423
|
}, [validItems.length, productName]);
|
|
8755
9424
|
if (validItems.length === 0) return null;
|
|
@@ -9377,7 +10046,7 @@ var RICH_TEXT_PROSE = cn(
|
|
|
9377
10046
|
"[&_iframe]:my-4 [&_iframe]:aspect-video [&_iframe]:w-full [&_iframe]:rounded-md"
|
|
9378
10047
|
);
|
|
9379
10048
|
function RichText({ html, className, ...rest }) {
|
|
9380
|
-
const clean =
|
|
10049
|
+
const clean = React14.useMemo(() => html ? sanitizeRichTextHtml(html) : "", [html]);
|
|
9381
10050
|
if (!clean) {
|
|
9382
10051
|
return null;
|
|
9383
10052
|
}
|
|
@@ -9473,7 +10142,7 @@ function ProductSheet({
|
|
|
9473
10142
|
}
|
|
9474
10143
|
);
|
|
9475
10144
|
}
|
|
9476
|
-
const [selectedVariant, setSelectedVariant] =
|
|
10145
|
+
const [selectedVariant, setSelectedVariant] = React14.useState(
|
|
9477
10146
|
void 0
|
|
9478
10147
|
);
|
|
9479
10148
|
const variantImages = selectedVariant?.images?.filter(Boolean) ?? [];
|
|
@@ -10498,22 +11167,22 @@ function ProductCard({
|
|
|
10498
11167
|
classNames
|
|
10499
11168
|
}) {
|
|
10500
11169
|
const mode = displayMode ?? product.display_mode ?? "card";
|
|
10501
|
-
const [isOpen, setIsOpen] =
|
|
10502
|
-
const [shouldFetch, setShouldFetch] =
|
|
11170
|
+
const [isOpen, setIsOpen] = React14.useState(false);
|
|
11171
|
+
const [shouldFetch, setShouldFetch] = React14.useState(false);
|
|
10503
11172
|
const { product: productDetails } = useProduct(
|
|
10504
11173
|
product.slug ?? product.id,
|
|
10505
11174
|
{ enabled: shouldFetch || isOpen }
|
|
10506
11175
|
);
|
|
10507
|
-
const handlePrefetch =
|
|
11176
|
+
const handlePrefetch = React14.useCallback(() => {
|
|
10508
11177
|
setShouldFetch(true);
|
|
10509
11178
|
}, []);
|
|
10510
|
-
const handleOpenChange =
|
|
11179
|
+
const handleOpenChange = React14.useCallback((open) => {
|
|
10511
11180
|
setIsOpen(open);
|
|
10512
11181
|
if (open) {
|
|
10513
11182
|
setShouldFetch(true);
|
|
10514
11183
|
}
|
|
10515
11184
|
}, []);
|
|
10516
|
-
const handleClose =
|
|
11185
|
+
const handleClose = React14.useCallback(() => {
|
|
10517
11186
|
setIsOpen(false);
|
|
10518
11187
|
}, []);
|
|
10519
11188
|
const imageUrl = product.image_url || product.images?.[0];
|
|
@@ -10643,13 +11312,13 @@ function ProductGrid({
|
|
|
10643
11312
|
className,
|
|
10644
11313
|
classNames
|
|
10645
11314
|
}) {
|
|
10646
|
-
const rawId =
|
|
11315
|
+
const rawId = React14__default.default.useId();
|
|
10647
11316
|
const gridId = `cimplify-grid-${rawId.replace(/:/g, "")}`;
|
|
10648
11317
|
const sm = columns?.sm ?? 1;
|
|
10649
11318
|
const md = columns?.md ?? 2;
|
|
10650
11319
|
const lg = columns?.lg ?? 3;
|
|
10651
11320
|
const xl = columns?.xl ?? 4;
|
|
10652
|
-
const css =
|
|
11321
|
+
const css = React14__default.default.useMemo(
|
|
10653
11322
|
() => [
|
|
10654
11323
|
`#${gridId}{display:grid;grid-template-columns:repeat(${sm},1fr);gap:1rem}`,
|
|
10655
11324
|
`@media(min-width:768px){#${gridId}{grid-template-columns:repeat(${md},1fr)}}`,
|
|
@@ -10727,12 +11396,12 @@ function SearchInput({
|
|
|
10727
11396
|
className,
|
|
10728
11397
|
classNames
|
|
10729
11398
|
}) {
|
|
10730
|
-
const mergedOptions =
|
|
11399
|
+
const mergedOptions = React14.useMemo(
|
|
10731
11400
|
() => categoryId ? { ...searchOptions, category: categoryId } : searchOptions ?? {},
|
|
10732
11401
|
[searchOptions, categoryId]
|
|
10733
11402
|
);
|
|
10734
11403
|
const { results, isLoading, query, setQuery, clear } = useSearch(mergedOptions);
|
|
10735
|
-
const handleValueChange =
|
|
11404
|
+
const handleValueChange = React14.useCallback(
|
|
10736
11405
|
(value) => {
|
|
10737
11406
|
setQuery(value);
|
|
10738
11407
|
},
|
|
@@ -10831,7 +11500,7 @@ function CategoryFilter({
|
|
|
10831
11500
|
classNames
|
|
10832
11501
|
}) {
|
|
10833
11502
|
const { categories, isLoading } = useCategories();
|
|
10834
|
-
const handleValueChange =
|
|
11503
|
+
const handleValueChange = React14.useCallback(
|
|
10835
11504
|
(value) => {
|
|
10836
11505
|
onSelect(value === ALL_VALUE ? null : String(value));
|
|
10837
11506
|
},
|
|
@@ -10898,10 +11567,10 @@ function DiscountInput({
|
|
|
10898
11567
|
className,
|
|
10899
11568
|
classNames
|
|
10900
11569
|
}) {
|
|
10901
|
-
const [code, setCode] =
|
|
10902
|
-
const [appliedValidation, setAppliedValidation] =
|
|
11570
|
+
const [code, setCode] = React14.useState("");
|
|
11571
|
+
const [appliedValidation, setAppliedValidation] = React14.useState(null);
|
|
10903
11572
|
const { validate, isValidating, error } = useValidateDiscount();
|
|
10904
|
-
const handleApply =
|
|
11573
|
+
const handleApply = React14.useCallback(async () => {
|
|
10905
11574
|
const trimmed = code.trim();
|
|
10906
11575
|
if (!trimmed) return;
|
|
10907
11576
|
const result = await validate(trimmed, orderSubtotal, locationId);
|
|
@@ -10914,12 +11583,12 @@ function DiscountInput({
|
|
|
10914
11583
|
}
|
|
10915
11584
|
}
|
|
10916
11585
|
}, [code, validate, orderSubtotal, locationId, onApply]);
|
|
10917
|
-
const handleClear =
|
|
11586
|
+
const handleClear = React14.useCallback(() => {
|
|
10918
11587
|
setCode("");
|
|
10919
11588
|
setAppliedValidation(null);
|
|
10920
11589
|
onClear?.();
|
|
10921
11590
|
}, [onClear]);
|
|
10922
|
-
const handleKeyDown =
|
|
11591
|
+
const handleKeyDown = React14.useCallback(
|
|
10923
11592
|
(e) => {
|
|
10924
11593
|
if (e.key === "Enter") {
|
|
10925
11594
|
void handleApply();
|
|
@@ -11010,7 +11679,7 @@ function CategoryGrid({
|
|
|
11010
11679
|
enabled: categoriesProp === void 0
|
|
11011
11680
|
});
|
|
11012
11681
|
const categories = categoriesProp ?? fetched;
|
|
11013
|
-
const rawId =
|
|
11682
|
+
const rawId = React14__default.default.useId();
|
|
11014
11683
|
const gridId = `cimplify-cat-grid-${rawId.replace(/:/g, "")}`;
|
|
11015
11684
|
const sm = columns?.sm ?? 2;
|
|
11016
11685
|
const md = columns?.md ?? 3;
|
|
@@ -11236,7 +11905,7 @@ function OrderSummary({
|
|
|
11236
11905
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: order.delivery_address })
|
|
11237
11906
|
] }),
|
|
11238
11907
|
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-order-items": true, className: classNames?.items, children: order.items.map(
|
|
11239
|
-
(item) => renderLineItem ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
11908
|
+
(item) => renderLineItem ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderLineItem(item) }, item.id) : /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-line-item": true, className: classNames?.lineItem, children: [
|
|
11240
11909
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-line-info": true, children: [
|
|
11241
11910
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-order-line-qty": true, children: [
|
|
11242
11911
|
item.quantity,
|
|
@@ -11894,13 +12563,13 @@ function BookingPage({
|
|
|
11894
12563
|
const { addItem } = useCart();
|
|
11895
12564
|
const { client } = useCimplifyClient();
|
|
11896
12565
|
const isReschedule = existingBooking !== void 0;
|
|
11897
|
-
const [step, setStep] =
|
|
11898
|
-
const [selectedSlot, setSelectedSlot] =
|
|
11899
|
-
const [selectedDate, setSelectedDate] =
|
|
11900
|
-
const [selectedStaffId, setSelectedStaffId] =
|
|
11901
|
-
const [selectedResourceId, setSelectedResourceId] =
|
|
11902
|
-
const [isSubmitting, setIsSubmitting] =
|
|
11903
|
-
const [error, setError] =
|
|
12566
|
+
const [step, setStep] = React14.useState(STEP.SELECT_SLOT);
|
|
12567
|
+
const [selectedSlot, setSelectedSlot] = React14.useState(null);
|
|
12568
|
+
const [selectedDate, setSelectedDate] = React14.useState(null);
|
|
12569
|
+
const [selectedStaffId, setSelectedStaffId] = React14.useState(null);
|
|
12570
|
+
const [selectedResourceId, setSelectedResourceId] = React14.useState(null);
|
|
12571
|
+
const [isSubmitting, setIsSubmitting] = React14.useState(false);
|
|
12572
|
+
const [error, setError] = React14.useState(null);
|
|
11904
12573
|
const hasResourceStep = resources && resources.length > 0;
|
|
11905
12574
|
const hasStaffStep = staff && staff.length > 0;
|
|
11906
12575
|
const depositType = product?.deposit_type;
|
|
@@ -11908,7 +12577,7 @@ function BookingPage({
|
|
|
11908
12577
|
const hasDeposit = depositType !== void 0 && depositType !== "none" && depositAmount !== void 0 && chunk7Y2O3E4D_js.parsePrice(depositAmount) !== 0;
|
|
11909
12578
|
const cancellationMinutes = product?.cancellation_window_minutes;
|
|
11910
12579
|
const noShowFee = product?.no_show_fee;
|
|
11911
|
-
const handleSlotSelect =
|
|
12580
|
+
const handleSlotSelect = React14.useCallback(
|
|
11912
12581
|
(slot, date) => {
|
|
11913
12582
|
setSelectedSlot(slot);
|
|
11914
12583
|
setSelectedDate(date);
|
|
@@ -11923,7 +12592,7 @@ function BookingPage({
|
|
|
11923
12592
|
},
|
|
11924
12593
|
[hasResourceStep, hasStaffStep]
|
|
11925
12594
|
);
|
|
11926
|
-
const handleResourceSelect =
|
|
12595
|
+
const handleResourceSelect = React14.useCallback(
|
|
11927
12596
|
(resourceId) => {
|
|
11928
12597
|
setSelectedResourceId(resourceId);
|
|
11929
12598
|
if (hasStaffStep) {
|
|
@@ -11934,11 +12603,11 @@ function BookingPage({
|
|
|
11934
12603
|
},
|
|
11935
12604
|
[hasStaffStep]
|
|
11936
12605
|
);
|
|
11937
|
-
const handleStaffSelect =
|
|
12606
|
+
const handleStaffSelect = React14.useCallback((staffId) => {
|
|
11938
12607
|
setSelectedStaffId(staffId);
|
|
11939
12608
|
setStep(STEP.CONFIRM);
|
|
11940
12609
|
}, []);
|
|
11941
|
-
const handleBack =
|
|
12610
|
+
const handleBack = React14.useCallback(() => {
|
|
11942
12611
|
setError(null);
|
|
11943
12612
|
if (step === STEP.CONFIRM && hasStaffStep) {
|
|
11944
12613
|
setStep(STEP.SELECT_STAFF);
|
|
@@ -11952,7 +12621,7 @@ function BookingPage({
|
|
|
11952
12621
|
onBack?.();
|
|
11953
12622
|
}
|
|
11954
12623
|
}, [step, hasStaffStep, hasResourceStep, onBack]);
|
|
11955
|
-
const handleConfirm =
|
|
12624
|
+
const handleConfirm = React14.useCallback(async () => {
|
|
11956
12625
|
if (!selectedSlot || !selectedDate) return;
|
|
11957
12626
|
setIsSubmitting(true);
|
|
11958
12627
|
setError(null);
|
|
@@ -12154,9 +12823,9 @@ function BookingsPage({
|
|
|
12154
12823
|
className,
|
|
12155
12824
|
classNames
|
|
12156
12825
|
}) {
|
|
12157
|
-
const [filter, setFilter] =
|
|
12158
|
-
const [selectedBooking, setSelectedBooking] =
|
|
12159
|
-
const handleBookingClick =
|
|
12826
|
+
const [filter, setFilter] = React14.useState("all");
|
|
12827
|
+
const [selectedBooking, setSelectedBooking] = React14.useState(null);
|
|
12828
|
+
const handleBookingClick = React14.useCallback(
|
|
12160
12829
|
(booking) => {
|
|
12161
12830
|
if (onBookingNavigate) {
|
|
12162
12831
|
onBookingNavigate(booking);
|
|
@@ -12166,7 +12835,7 @@ function BookingsPage({
|
|
|
12166
12835
|
},
|
|
12167
12836
|
[onBookingNavigate]
|
|
12168
12837
|
);
|
|
12169
|
-
const handleBack =
|
|
12838
|
+
const handleBack = React14.useCallback(() => {
|
|
12170
12839
|
setSelectedBooking(null);
|
|
12171
12840
|
}, []);
|
|
12172
12841
|
if (selectedBooking && !onBookingNavigate) {
|
|
@@ -12396,7 +13065,7 @@ function DefaultCatalogueLayout({
|
|
|
12396
13065
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium", children: "No products found" }),
|
|
12397
13066
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try adjusting your filters" })
|
|
12398
13067
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-4", children: products.map(
|
|
12399
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13068
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12400
13069
|
ProductCard,
|
|
12401
13070
|
{
|
|
12402
13071
|
product,
|
|
@@ -12503,7 +13172,7 @@ function CompactCatalogueLayout({
|
|
|
12503
13172
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium", children: "No items found" }),
|
|
12504
13173
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different category or search" })
|
|
12505
13174
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 lg:grid-cols-3 gap-5", children: products.map(
|
|
12506
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13175
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12507
13176
|
ProductCard,
|
|
12508
13177
|
{
|
|
12509
13178
|
product,
|
|
@@ -12526,8 +13195,8 @@ var BUILT_IN_LAYOUTS = {
|
|
|
12526
13195
|
["compact" /* Compact */]: CompactCatalogueLayout
|
|
12527
13196
|
};
|
|
12528
13197
|
function useDebounce(value, delay) {
|
|
12529
|
-
const [debounced, setDebounced] =
|
|
12530
|
-
|
|
13198
|
+
const [debounced, setDebounced] = React14__default.default.useState(value);
|
|
13199
|
+
React14__default.default.useEffect(() => {
|
|
12531
13200
|
const timer = setTimeout(() => setDebounced(value), delay);
|
|
12532
13201
|
return () => clearTimeout(timer);
|
|
12533
13202
|
}, [value, delay]);
|
|
@@ -12551,15 +13220,15 @@ function CataloguePage({
|
|
|
12551
13220
|
className,
|
|
12552
13221
|
classNames
|
|
12553
13222
|
}) {
|
|
12554
|
-
const [selectedCategory, setSelectedCategory] =
|
|
12555
|
-
const [searchQuery, setSearchQuery] =
|
|
12556
|
-
const [sortBy, setSortBy] =
|
|
12557
|
-
const [sortOrder, setSortOrder] =
|
|
12558
|
-
const [inStockOnly, setInStockOnly] =
|
|
12559
|
-
const [selectedTags, setSelectedTags] =
|
|
12560
|
-
const [minPrice, setMinPrice] =
|
|
12561
|
-
const [maxPrice, setMaxPrice] =
|
|
12562
|
-
const [page, setPage] =
|
|
13223
|
+
const [selectedCategory, setSelectedCategory] = React14.useState(null);
|
|
13224
|
+
const [searchQuery, setSearchQuery] = React14.useState("");
|
|
13225
|
+
const [sortBy, setSortBy] = React14.useState(defaultSort?.by ?? "created_at");
|
|
13226
|
+
const [sortOrder, setSortOrder] = React14.useState(defaultSort?.order ?? "desc");
|
|
13227
|
+
const [inStockOnly, setInStockOnly] = React14.useState(false);
|
|
13228
|
+
const [selectedTags, setSelectedTags] = React14.useState([]);
|
|
13229
|
+
const [minPrice, setMinPrice] = React14.useState("");
|
|
13230
|
+
const [maxPrice, setMaxPrice] = React14.useState("");
|
|
13231
|
+
const [page, setPage] = React14.useState(1);
|
|
12563
13232
|
const debouncedSearch = useDebounce(searchQuery, 300);
|
|
12564
13233
|
const { products: fetchedProducts, isLoading, pagination } = useProducts({
|
|
12565
13234
|
enabled: productsProp === void 0,
|
|
@@ -12580,22 +13249,22 @@ function CataloguePage({
|
|
|
12580
13249
|
const products = productsProp ?? fetchedProducts;
|
|
12581
13250
|
const categories = categoriesProp ?? fetchedCategories;
|
|
12582
13251
|
const totalPages = pagination?.total_pages ?? 1;
|
|
12583
|
-
const handleCategoryChange =
|
|
13252
|
+
const handleCategoryChange = React14.useCallback((id) => {
|
|
12584
13253
|
setSelectedCategory(id);
|
|
12585
13254
|
setPage(1);
|
|
12586
13255
|
}, []);
|
|
12587
|
-
const handleSortChange =
|
|
13256
|
+
const handleSortChange = React14.useCallback((by, order) => {
|
|
12588
13257
|
setSortBy(by);
|
|
12589
13258
|
setSortOrder(order);
|
|
12590
13259
|
setPage(1);
|
|
12591
13260
|
}, []);
|
|
12592
|
-
const handleTagToggle =
|
|
13261
|
+
const handleTagToggle = React14.useCallback((tag) => {
|
|
12593
13262
|
setSelectedTags(
|
|
12594
13263
|
(prev) => prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag]
|
|
12595
13264
|
);
|
|
12596
13265
|
setPage(1);
|
|
12597
13266
|
}, []);
|
|
12598
|
-
const handlePriceRangeChange =
|
|
13267
|
+
const handlePriceRangeChange = React14.useCallback((min, max) => {
|
|
12599
13268
|
setMinPrice(min);
|
|
12600
13269
|
setMaxPrice(max);
|
|
12601
13270
|
setPage(1);
|
|
@@ -12783,7 +13452,7 @@ function DefaultProductLayout({
|
|
|
12783
13452
|
showRelated = true,
|
|
12784
13453
|
className
|
|
12785
13454
|
}) {
|
|
12786
|
-
const [selectedVariantId, setSelectedVariantId] =
|
|
13455
|
+
const [selectedVariantId, setSelectedVariantId] = React14__default.default.useState();
|
|
12787
13456
|
const images = chunkIQLJJW2H_js.resolveGallery(product, selectedVariantId);
|
|
12788
13457
|
const hasRange = product.quantity_pricing && product.quantity_pricing.length > 1 || product.variants && product.variants.length > 1;
|
|
12789
13458
|
const onSale = chunk7Y2O3E4D_js.isOnSale(product);
|
|
@@ -13701,36 +14370,36 @@ function CartPage({
|
|
|
13701
14370
|
}
|
|
13702
14371
|
) });
|
|
13703
14372
|
}
|
|
13704
|
-
var CartDrawerContext =
|
|
14373
|
+
var CartDrawerContext = React14.createContext(null);
|
|
13705
14374
|
function useCartDrawer() {
|
|
13706
|
-
const ctx =
|
|
14375
|
+
const ctx = React14.useContext(CartDrawerContext);
|
|
13707
14376
|
if (!ctx) {
|
|
13708
14377
|
throw new Error("useCartDrawer must be used within <CartDrawerProvider>");
|
|
13709
14378
|
}
|
|
13710
14379
|
return ctx;
|
|
13711
14380
|
}
|
|
13712
14381
|
function CartDrawerProvider({ children, openOnAdd = true }) {
|
|
13713
|
-
const [isOpen, setIsOpen] =
|
|
14382
|
+
const [isOpen, setIsOpen] = React14.useState(false);
|
|
13714
14383
|
const cart = useCart();
|
|
13715
|
-
const lastPendingRef =
|
|
13716
|
-
const open =
|
|
13717
|
-
const close =
|
|
13718
|
-
const toggle =
|
|
13719
|
-
|
|
14384
|
+
const lastPendingRef = React14.useRef(0);
|
|
14385
|
+
const open = React14.useCallback(() => setIsOpen(true), []);
|
|
14386
|
+
const close = React14.useCallback(() => setIsOpen(false), []);
|
|
14387
|
+
const toggle = React14.useCallback(() => setIsOpen((v) => !v), []);
|
|
14388
|
+
React14.useEffect(() => {
|
|
13720
14389
|
if (!openOnAdd) return;
|
|
13721
14390
|
if (cart.pendingOpCount > lastPendingRef.current && cart.pendingOpCount > 0) {
|
|
13722
14391
|
setIsOpen(true);
|
|
13723
14392
|
}
|
|
13724
14393
|
lastPendingRef.current = cart.pendingOpCount;
|
|
13725
14394
|
}, [cart.pendingOpCount, openOnAdd]);
|
|
13726
|
-
const value =
|
|
14395
|
+
const value = React14.useMemo(() => ({ isOpen, open, close, toggle }), [isOpen, open, close, toggle]);
|
|
13727
14396
|
return /* @__PURE__ */ jsxRuntime.jsx(CartDrawerContext.Provider, { value, children });
|
|
13728
14397
|
}
|
|
13729
14398
|
function useAnimatedNumber(target, durationMs = 250) {
|
|
13730
|
-
const [value, setValue] =
|
|
13731
|
-
const fromRef =
|
|
13732
|
-
const startRef =
|
|
13733
|
-
|
|
14399
|
+
const [value, setValue] = React14.useState(target);
|
|
14400
|
+
const fromRef = React14.useRef(target);
|
|
14401
|
+
const startRef = React14.useRef(null);
|
|
14402
|
+
React14.useEffect(() => {
|
|
13734
14403
|
fromRef.current = value;
|
|
13735
14404
|
startRef.current = null;
|
|
13736
14405
|
let raf = 0;
|
|
@@ -13758,7 +14427,7 @@ function CartDrawer({
|
|
|
13758
14427
|
const cart = useCart();
|
|
13759
14428
|
const subtotalNum = chunk7Y2O3E4D_js.parsePrice(cart.subtotal);
|
|
13760
14429
|
const animatedSubtotal = useAnimatedNumber(subtotalNum);
|
|
13761
|
-
|
|
14430
|
+
React14.useEffect(() => {
|
|
13762
14431
|
if (!isOpen) return;
|
|
13763
14432
|
const original = document.body.style.overflow;
|
|
13764
14433
|
document.body.style.overflow = "hidden";
|
|
@@ -13963,9 +14632,9 @@ function DefaultCollectionLayout({
|
|
|
13963
14632
|
onQuickAdd,
|
|
13964
14633
|
className
|
|
13965
14634
|
}) {
|
|
13966
|
-
const [searchQuery, setSearchQuery] =
|
|
13967
|
-
const [activeTag, setActiveTag] =
|
|
13968
|
-
const collectionTags =
|
|
14635
|
+
const [searchQuery, setSearchQuery] = React14.useState("");
|
|
14636
|
+
const [activeTag, setActiveTag] = React14.useState(null);
|
|
14637
|
+
const collectionTags = React14.useMemo(() => {
|
|
13969
14638
|
const tagSet = /* @__PURE__ */ new Set();
|
|
13970
14639
|
for (const p of products) {
|
|
13971
14640
|
if (p.tags) {
|
|
@@ -13974,7 +14643,7 @@ function DefaultCollectionLayout({
|
|
|
13974
14643
|
}
|
|
13975
14644
|
return Array.from(tagSet).slice(0, 6);
|
|
13976
14645
|
}, [products]);
|
|
13977
|
-
const filtered =
|
|
14646
|
+
const filtered = React14.useMemo(() => {
|
|
13978
14647
|
let result = products;
|
|
13979
14648
|
if (searchQuery.trim().length >= 2) {
|
|
13980
14649
|
const q = searchQuery.toLowerCase();
|
|
@@ -14049,7 +14718,7 @@ function DefaultCollectionLayout({
|
|
|
14049
14718
|
] })
|
|
14050
14719
|
] }),
|
|
14051
14720
|
filtered.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: filtered.map(
|
|
14052
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
14721
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
14053
14722
|
ProductCard,
|
|
14054
14723
|
{
|
|
14055
14724
|
product,
|
|
@@ -14102,7 +14771,7 @@ function FeaturedCollectionLayout({
|
|
|
14102
14771
|
] })
|
|
14103
14772
|
] }),
|
|
14104
14773
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6", children: products.map(
|
|
14105
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
14774
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
14106
14775
|
ProductCard,
|
|
14107
14776
|
{
|
|
14108
14777
|
product,
|
|
@@ -14124,10 +14793,10 @@ function CatalogueCollectionLayout({
|
|
|
14124
14793
|
onQuickAdd,
|
|
14125
14794
|
className
|
|
14126
14795
|
}) {
|
|
14127
|
-
const [searchQuery, setSearchQuery] =
|
|
14128
|
-
const [activeCategory, setActiveCategory] =
|
|
14129
|
-
const [sortBy, setSortBy] =
|
|
14130
|
-
const categories =
|
|
14796
|
+
const [searchQuery, setSearchQuery] = React14.useState("");
|
|
14797
|
+
const [activeCategory, setActiveCategory] = React14.useState(null);
|
|
14798
|
+
const [sortBy, setSortBy] = React14.useState("default");
|
|
14799
|
+
const categories = React14.useMemo(() => {
|
|
14131
14800
|
const cats = /* @__PURE__ */ new Map();
|
|
14132
14801
|
for (const p of products) {
|
|
14133
14802
|
if (p.category_id && p.tags) {
|
|
@@ -14138,7 +14807,7 @@ function CatalogueCollectionLayout({
|
|
|
14138
14807
|
}
|
|
14139
14808
|
return Array.from(cats.values()).slice(0, 8);
|
|
14140
14809
|
}, [products]);
|
|
14141
|
-
const filtered =
|
|
14810
|
+
const filtered = React14.useMemo(() => {
|
|
14142
14811
|
let result = products;
|
|
14143
14812
|
if (searchQuery.trim().length >= 2) {
|
|
14144
14813
|
const q = searchQuery.toLowerCase();
|
|
@@ -14226,7 +14895,7 @@ function CatalogueCollectionLayout({
|
|
|
14226
14895
|
] })
|
|
14227
14896
|
] }),
|
|
14228
14897
|
filtered.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: filtered.map(
|
|
14229
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
14898
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
14230
14899
|
ProductCard,
|
|
14231
14900
|
{
|
|
14232
14901
|
product,
|
|
@@ -14405,13 +15074,13 @@ function OrderHistoryPage({
|
|
|
14405
15074
|
className,
|
|
14406
15075
|
classNames
|
|
14407
15076
|
}) {
|
|
14408
|
-
const [statusFilter, setStatusFilter] =
|
|
14409
|
-
const [selectedOrder, setSelectedOrder] =
|
|
14410
|
-
const handleTabChange =
|
|
15077
|
+
const [statusFilter, setStatusFilter] = React14.useState(void 0);
|
|
15078
|
+
const [selectedOrder, setSelectedOrder] = React14.useState(null);
|
|
15079
|
+
const handleTabChange = React14.useCallback((value) => {
|
|
14411
15080
|
const filter = STATUS_FILTERS.find((f) => f.tabValue === value);
|
|
14412
15081
|
setStatusFilter(filter?.value);
|
|
14413
15082
|
}, []);
|
|
14414
|
-
const handleOrderClick =
|
|
15083
|
+
const handleOrderClick = React14.useCallback(
|
|
14415
15084
|
(order) => {
|
|
14416
15085
|
if (onOrderNavigate) {
|
|
14417
15086
|
onOrderNavigate(order);
|
|
@@ -14421,7 +15090,7 @@ function OrderHistoryPage({
|
|
|
14421
15090
|
},
|
|
14422
15091
|
[onOrderNavigate]
|
|
14423
15092
|
);
|
|
14424
|
-
const handleBack =
|
|
15093
|
+
const handleBack = React14.useCallback(() => {
|
|
14425
15094
|
setSelectedOrder(null);
|
|
14426
15095
|
}, []);
|
|
14427
15096
|
const activeTabValue = STATUS_FILTERS.find((f) => f.value === statusFilter)?.tabValue ?? "all";
|
|
@@ -14606,7 +15275,7 @@ function DefaultSearchLayout({
|
|
|
14606
15275
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different search term" }),
|
|
14607
15276
|
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: clear, className: "text-sm font-medium text-primary mt-4 hover:underline", children: "Clear search" })
|
|
14608
15277
|
] }) : results.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-4", children: results.map(
|
|
14609
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
15278
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
14610
15279
|
ProductCard,
|
|
14611
15280
|
{
|
|
14612
15281
|
product,
|
|
@@ -14708,7 +15377,7 @@ function CompactSearchLayout({
|
|
|
14708
15377
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Try a different search term" }),
|
|
14709
15378
|
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: clear, className: "text-sm font-medium text-primary mt-4 hover:underline", children: "Clear search" })
|
|
14710
15379
|
] }) : results.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 lg:grid-cols-3 gap-5", children: results.map(
|
|
14711
|
-
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
15380
|
+
(product) => renderCard ? /* @__PURE__ */ jsxRuntime.jsx(React14__default.default.Fragment, { children: renderCard(product) }, product.id) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
14712
15381
|
ProductCard,
|
|
14713
15382
|
{
|
|
14714
15383
|
product,
|
|
@@ -15039,11 +15708,11 @@ function DeliveryEstimate({
|
|
|
15039
15708
|
}) {
|
|
15040
15709
|
const context = useOptionalCimplifyClient();
|
|
15041
15710
|
const client = context?.client ?? null;
|
|
15042
|
-
const [result, setResult] =
|
|
15043
|
-
const [isLoading, setIsLoading] =
|
|
15044
|
-
const [error, setError] =
|
|
15045
|
-
const requestIdRef =
|
|
15046
|
-
|
|
15711
|
+
const [result, setResult] = React14.useState(null);
|
|
15712
|
+
const [isLoading, setIsLoading] = React14.useState(true);
|
|
15713
|
+
const [error, setError] = React14.useState(null);
|
|
15714
|
+
const requestIdRef = React14.useRef(0);
|
|
15715
|
+
React14.useEffect(() => {
|
|
15047
15716
|
if (!client) return;
|
|
15048
15717
|
const nextRequestId = ++requestIdRef.current;
|
|
15049
15718
|
setIsLoading(true);
|
|
@@ -15124,10 +15793,10 @@ function CurrencySelector({
|
|
|
15124
15793
|
}) {
|
|
15125
15794
|
const context = useOptionalCimplifyClient();
|
|
15126
15795
|
const client = context?.client ?? null;
|
|
15127
|
-
const [rates, setRates] =
|
|
15128
|
-
const [isLoadingRates, setIsLoadingRates] =
|
|
15129
|
-
const requestIdRef =
|
|
15130
|
-
|
|
15796
|
+
const [rates, setRates] = React14.useState({});
|
|
15797
|
+
const [isLoadingRates, setIsLoadingRates] = React14.useState(false);
|
|
15798
|
+
const requestIdRef = React14.useRef(0);
|
|
15799
|
+
React14.useEffect(() => {
|
|
15131
15800
|
if (!showRate || !baseCurrency || !client) return;
|
|
15132
15801
|
const targets = currencies.filter((c) => c !== baseCurrency);
|
|
15133
15802
|
if (targets.length === 0) return;
|
|
@@ -15190,11 +15859,11 @@ function ChatWidget({
|
|
|
15190
15859
|
}) {
|
|
15191
15860
|
const context = useOptionalCimplifyClient();
|
|
15192
15861
|
const client = clientProp ?? context?.client;
|
|
15193
|
-
const [open, setOpen] =
|
|
15194
|
-
const [unread, setUnread] =
|
|
15862
|
+
const [open, setOpen] = React14.useState(defaultOpen);
|
|
15863
|
+
const [unread, setUnread] = React14.useState(0);
|
|
15195
15864
|
const { messages, isLoading, isSending, error, isActive, send, startConversation } = useChat({ client, pollInterval });
|
|
15196
|
-
const prevCountRef =
|
|
15197
|
-
|
|
15865
|
+
const prevCountRef = React14.useRef(messages.length);
|
|
15866
|
+
React14.useEffect(() => {
|
|
15198
15867
|
if (!open && messages.length > prevCountRef.current) {
|
|
15199
15868
|
const newMessages = messages.slice(prevCountRef.current);
|
|
15200
15869
|
const incomingCount = newMessages.filter(
|
|
@@ -15204,11 +15873,11 @@ function ChatWidget({
|
|
|
15204
15873
|
}
|
|
15205
15874
|
prevCountRef.current = messages.length;
|
|
15206
15875
|
}, [messages, open]);
|
|
15207
|
-
const handleOpen =
|
|
15876
|
+
const handleOpen = React14.useCallback(() => {
|
|
15208
15877
|
setOpen(true);
|
|
15209
15878
|
setUnread(0);
|
|
15210
15879
|
}, []);
|
|
15211
|
-
const handleClose =
|
|
15880
|
+
const handleClose = React14.useCallback(() => setOpen(false), []);
|
|
15212
15881
|
const isLeft = position === "bottom-left";
|
|
15213
15882
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
15214
15883
|
"div",
|
|
@@ -15450,8 +16119,8 @@ function MessageList({
|
|
|
15450
16119
|
isSending,
|
|
15451
16120
|
className
|
|
15452
16121
|
}) {
|
|
15453
|
-
const bottomRef =
|
|
15454
|
-
|
|
16122
|
+
const bottomRef = React14.useRef(null);
|
|
16123
|
+
React14.useEffect(() => {
|
|
15455
16124
|
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
15456
16125
|
}, [messages.length, isSending]);
|
|
15457
16126
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -15511,9 +16180,9 @@ function ChatInput({
|
|
|
15511
16180
|
onSend,
|
|
15512
16181
|
className
|
|
15513
16182
|
}) {
|
|
15514
|
-
const [value, setValue] =
|
|
15515
|
-
const textareaRef =
|
|
15516
|
-
const handleSend =
|
|
16183
|
+
const [value, setValue] = React14.useState("");
|
|
16184
|
+
const textareaRef = React14.useRef(null);
|
|
16185
|
+
const handleSend = React14.useCallback(() => {
|
|
15517
16186
|
const trimmed = value.trim();
|
|
15518
16187
|
if (!trimmed || isSending) return;
|
|
15519
16188
|
setValue("");
|
|
@@ -15522,7 +16191,7 @@ function ChatInput({
|
|
|
15522
16191
|
}
|
|
15523
16192
|
onSend(trimmed);
|
|
15524
16193
|
}, [value, isSending, onSend]);
|
|
15525
|
-
const handleKeyDown =
|
|
16194
|
+
const handleKeyDown = React14.useCallback(
|
|
15526
16195
|
(e) => {
|
|
15527
16196
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
15528
16197
|
e.preventDefault();
|
|
@@ -15531,7 +16200,7 @@ function ChatInput({
|
|
|
15531
16200
|
},
|
|
15532
16201
|
[handleSend]
|
|
15533
16202
|
);
|
|
15534
|
-
const handleInput =
|
|
16203
|
+
const handleInput = React14.useCallback(() => {
|
|
15535
16204
|
const el = textareaRef.current;
|
|
15536
16205
|
if (!el) return;
|
|
15537
16206
|
el.style.height = "auto";
|
|
@@ -15671,8 +16340,11 @@ exports.AccountContent = AccountContent;
|
|
|
15671
16340
|
exports.AccountDashboardPage = AccountDashboardPage;
|
|
15672
16341
|
exports.AccountHero = AccountHero;
|
|
15673
16342
|
exports.AccountIdentityStrip = AccountIdentityStrip;
|
|
16343
|
+
exports.AccountLineItem = AccountLineItem;
|
|
16344
|
+
exports.AccountLineItems = AccountLineItems;
|
|
15674
16345
|
exports.AccountNav = AccountNav;
|
|
15675
16346
|
exports.AccountOrderDetailPage = AccountOrderDetailPage;
|
|
16347
|
+
exports.AccountOrderView = AccountOrderView;
|
|
15676
16348
|
exports.AccountOrdersPage = AccountOrdersPage;
|
|
15677
16349
|
exports.AccountShell = AccountShell;
|
|
15678
16350
|
exports.AccountSidebar = AccountSidebar;
|
|
@@ -15712,10 +16384,10 @@ exports.CategoryGrid = CategoryGrid;
|
|
|
15712
16384
|
exports.ChatWidget = ChatWidget;
|
|
15713
16385
|
exports.CheckIcon = CheckIcon;
|
|
15714
16386
|
exports.CheckoutPage = CheckoutPage;
|
|
15715
|
-
exports.CimplifyAccount = CimplifyAccount;
|
|
15716
16387
|
exports.CimplifyCheckout = CimplifyCheckout;
|
|
15717
16388
|
exports.CimplifyProvider = CimplifyProvider;
|
|
15718
16389
|
exports.CimplifySignInButton = CimplifySignInButton;
|
|
16390
|
+
exports.CimplifyUserButton = CimplifyUserButton;
|
|
15719
16391
|
exports.CollectionPage = CollectionPage;
|
|
15720
16392
|
exports.CollectionTemplate = CollectionTemplate;
|
|
15721
16393
|
exports.CompactCartLayout = CompactCartLayout;
|
|
@@ -15742,6 +16414,7 @@ exports.DefaultCollectionLayout = DefaultCollectionLayout;
|
|
|
15742
16414
|
exports.DefaultProductLayout = DefaultProductLayout;
|
|
15743
16415
|
exports.DefaultSearchLayout = DefaultSearchLayout;
|
|
15744
16416
|
exports.DeliveryEstimate = DeliveryEstimate;
|
|
16417
|
+
exports.DeliveryTracker = DeliveryTracker;
|
|
15745
16418
|
exports.DeliveryTruckIcon = DeliveryTruckIcon;
|
|
15746
16419
|
exports.DigitalProductCard = DigitalProductCard;
|
|
15747
16420
|
exports.DigitalProductLayout = DigitalProductLayout;
|
|
@@ -15759,6 +16432,7 @@ exports.IdentityOfframp = IdentityOfframp;
|
|
|
15759
16432
|
exports.InventoryBadge = InventoryBadge;
|
|
15760
16433
|
exports.ItemsCard = ItemsCard;
|
|
15761
16434
|
exports.LeaseServiceCard = LeaseServiceCard;
|
|
16435
|
+
exports.LineItemDetails = LineItemDetails;
|
|
15762
16436
|
exports.LocationPicker = LocationPicker;
|
|
15763
16437
|
exports.MediaGallery = MediaGallery;
|
|
15764
16438
|
exports.MetadataStringList = MetadataStringList;
|