@superlogic/spree-pay 0.5.3 → 0.5.5
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/build/{CryptoComTab-GL5DOJ2P.js → CryptoComTab-3MCYJORT.js} +4 -4
- package/build/{CryptoTab-ODXWUOMD.js → CryptoTab-ROWYOLOL.js} +7 -10
- package/build/{chunk-PMTKUR3L.js → chunk-OTFCW74L.js} +5 -4
- package/build/{chunk-HZDR76ZV.js → chunk-UVD3GGPC.js} +1 -1
- package/build/{chunk-NOTIAH6W.js → chunk-WYLYH7AK.js} +453 -15
- package/build/index.cjs +742 -242
- package/build/index.css +3 -0
- package/build/index.js +107 -55
- package/package.json +5 -3
package/build/index.cjs
CHANGED
|
@@ -30,6 +30,448 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
+
// ../../node_modules/@ebay/nice-modal-react/lib/esm/index.js
|
|
34
|
+
function getModal(modalId) {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = MODAL_REGISTRY[modalId]) === null || _a === void 0 ? void 0 : _a.comp;
|
|
37
|
+
}
|
|
38
|
+
function showModal(modalId, args) {
|
|
39
|
+
return {
|
|
40
|
+
type: "nice-modal/show",
|
|
41
|
+
payload: {
|
|
42
|
+
modalId,
|
|
43
|
+
args
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function setModalFlags(modalId, flags) {
|
|
48
|
+
return {
|
|
49
|
+
type: "nice-modal/set-flags",
|
|
50
|
+
payload: {
|
|
51
|
+
modalId,
|
|
52
|
+
flags
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function hideModal(modalId) {
|
|
57
|
+
return {
|
|
58
|
+
type: "nice-modal/hide",
|
|
59
|
+
payload: {
|
|
60
|
+
modalId
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function removeModal(modalId) {
|
|
65
|
+
return {
|
|
66
|
+
type: "nice-modal/remove",
|
|
67
|
+
payload: {
|
|
68
|
+
modalId
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function show(modal, args) {
|
|
73
|
+
var modalId = getModalId(modal);
|
|
74
|
+
if (typeof modal !== "string" && !MODAL_REGISTRY[modalId]) {
|
|
75
|
+
register(modalId, modal);
|
|
76
|
+
}
|
|
77
|
+
dispatch(showModal(modalId, args));
|
|
78
|
+
if (!modalCallbacks[modalId]) {
|
|
79
|
+
var theResolve_1;
|
|
80
|
+
var theReject_1;
|
|
81
|
+
var promise = new Promise(function(resolve, reject) {
|
|
82
|
+
theResolve_1 = resolve;
|
|
83
|
+
theReject_1 = reject;
|
|
84
|
+
});
|
|
85
|
+
modalCallbacks[modalId] = {
|
|
86
|
+
resolve: theResolve_1,
|
|
87
|
+
reject: theReject_1,
|
|
88
|
+
promise
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return modalCallbacks[modalId].promise;
|
|
92
|
+
}
|
|
93
|
+
function hide(modal) {
|
|
94
|
+
var modalId = getModalId(modal);
|
|
95
|
+
dispatch(hideModal(modalId));
|
|
96
|
+
delete modalCallbacks[modalId];
|
|
97
|
+
if (!hideModalCallbacks[modalId]) {
|
|
98
|
+
var theResolve_2;
|
|
99
|
+
var theReject_2;
|
|
100
|
+
var promise = new Promise(function(resolve, reject) {
|
|
101
|
+
theResolve_2 = resolve;
|
|
102
|
+
theReject_2 = reject;
|
|
103
|
+
});
|
|
104
|
+
hideModalCallbacks[modalId] = {
|
|
105
|
+
resolve: theResolve_2,
|
|
106
|
+
reject: theReject_2,
|
|
107
|
+
promise
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return hideModalCallbacks[modalId].promise;
|
|
111
|
+
}
|
|
112
|
+
function useModal(modal, args) {
|
|
113
|
+
var modals = (0, import_react.useContext)(NiceModalContext);
|
|
114
|
+
var contextModalId = (0, import_react.useContext)(NiceModalIdContext);
|
|
115
|
+
var modalId = null;
|
|
116
|
+
var isUseComponent = modal && typeof modal !== "string";
|
|
117
|
+
if (!modal) {
|
|
118
|
+
modalId = contextModalId;
|
|
119
|
+
} else {
|
|
120
|
+
modalId = getModalId(modal);
|
|
121
|
+
}
|
|
122
|
+
if (!modalId)
|
|
123
|
+
throw new Error("No modal id found in NiceModal.useModal.");
|
|
124
|
+
var mid = modalId;
|
|
125
|
+
(0, import_react.useEffect)(function() {
|
|
126
|
+
if (isUseComponent && !MODAL_REGISTRY[mid]) {
|
|
127
|
+
register(mid, modal, args);
|
|
128
|
+
}
|
|
129
|
+
}, [isUseComponent, mid, modal, args]);
|
|
130
|
+
var modalInfo = modals[mid];
|
|
131
|
+
var showCallback = (0, import_react.useCallback)(function(args2) {
|
|
132
|
+
return show(mid, args2);
|
|
133
|
+
}, [mid]);
|
|
134
|
+
var hideCallback = (0, import_react.useCallback)(function() {
|
|
135
|
+
return hide(mid);
|
|
136
|
+
}, [mid]);
|
|
137
|
+
var removeCallback = (0, import_react.useCallback)(function() {
|
|
138
|
+
return remove(mid);
|
|
139
|
+
}, [mid]);
|
|
140
|
+
var resolveCallback = (0, import_react.useCallback)(function(args2) {
|
|
141
|
+
var _a;
|
|
142
|
+
(_a = modalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.resolve(args2);
|
|
143
|
+
delete modalCallbacks[mid];
|
|
144
|
+
}, [mid]);
|
|
145
|
+
var rejectCallback = (0, import_react.useCallback)(function(args2) {
|
|
146
|
+
var _a;
|
|
147
|
+
(_a = modalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.reject(args2);
|
|
148
|
+
delete modalCallbacks[mid];
|
|
149
|
+
}, [mid]);
|
|
150
|
+
var resolveHide = (0, import_react.useCallback)(function(args2) {
|
|
151
|
+
var _a;
|
|
152
|
+
(_a = hideModalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.resolve(args2);
|
|
153
|
+
delete hideModalCallbacks[mid];
|
|
154
|
+
}, [mid]);
|
|
155
|
+
return (0, import_react.useMemo)(function() {
|
|
156
|
+
return {
|
|
157
|
+
id: mid,
|
|
158
|
+
args: modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args,
|
|
159
|
+
visible: !!(modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible),
|
|
160
|
+
keepMounted: !!(modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.keepMounted),
|
|
161
|
+
show: showCallback,
|
|
162
|
+
hide: hideCallback,
|
|
163
|
+
remove: removeCallback,
|
|
164
|
+
resolve: resolveCallback,
|
|
165
|
+
reject: rejectCallback,
|
|
166
|
+
resolveHide
|
|
167
|
+
};
|
|
168
|
+
}, [
|
|
169
|
+
mid,
|
|
170
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args,
|
|
171
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible,
|
|
172
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.keepMounted,
|
|
173
|
+
showCallback,
|
|
174
|
+
hideCallback,
|
|
175
|
+
removeCallback,
|
|
176
|
+
resolveCallback,
|
|
177
|
+
rejectCallback,
|
|
178
|
+
resolveHide
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
var import_react, __assign, __rest, symModalId, initialState, NiceModalContext, NiceModalIdContext, MODAL_REGISTRY, ALREADY_MOUNTED, uidSeed, dispatch, getUid, reducer, modalCallbacks, hideModalCallbacks, getModalId, remove, setFlags, create, register, unregister, NiceModalPlaceholder, InnerContextProvider, Provider, ModalDef, ModalHolder, antdModal, antdDrawer, muiDialog, bootstrapDialog, NiceModal, esm_default;
|
|
182
|
+
var init_esm = __esm({
|
|
183
|
+
"../../node_modules/@ebay/nice-modal-react/lib/esm/index.js"() {
|
|
184
|
+
"use strict";
|
|
185
|
+
import_react = __toESM(require("react"));
|
|
186
|
+
__assign = function() {
|
|
187
|
+
__assign = Object.assign || function(t) {
|
|
188
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
189
|
+
s = arguments[i];
|
|
190
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
191
|
+
t[p] = s[p];
|
|
192
|
+
}
|
|
193
|
+
return t;
|
|
194
|
+
};
|
|
195
|
+
return __assign.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
__rest = function(s, e) {
|
|
198
|
+
var t = {};
|
|
199
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
200
|
+
t[p] = s[p];
|
|
201
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
202
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
203
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
204
|
+
t[p[i]] = s[p[i]];
|
|
205
|
+
}
|
|
206
|
+
return t;
|
|
207
|
+
};
|
|
208
|
+
symModalId = /* @__PURE__ */ Symbol("NiceModalId");
|
|
209
|
+
initialState = {};
|
|
210
|
+
NiceModalContext = import_react.default.createContext(initialState);
|
|
211
|
+
NiceModalIdContext = import_react.default.createContext(null);
|
|
212
|
+
MODAL_REGISTRY = {};
|
|
213
|
+
ALREADY_MOUNTED = {};
|
|
214
|
+
uidSeed = 0;
|
|
215
|
+
dispatch = function() {
|
|
216
|
+
throw new Error("No dispatch method detected, did you embed your app with NiceModal.Provider?");
|
|
217
|
+
};
|
|
218
|
+
getUid = function() {
|
|
219
|
+
return "_nice_modal_" + uidSeed++;
|
|
220
|
+
};
|
|
221
|
+
reducer = function(state, action) {
|
|
222
|
+
var _a, _b, _c;
|
|
223
|
+
if (state === void 0) {
|
|
224
|
+
state = initialState;
|
|
225
|
+
}
|
|
226
|
+
switch (action.type) {
|
|
227
|
+
case "nice-modal/show": {
|
|
228
|
+
var _d = action.payload, modalId = _d.modalId, args = _d.args;
|
|
229
|
+
return __assign(__assign({}, state), (_a = {}, _a[modalId] = __assign(__assign({}, state[modalId]), {
|
|
230
|
+
id: modalId,
|
|
231
|
+
args,
|
|
232
|
+
// If modal is not mounted, mount it first then make it visible.
|
|
233
|
+
// There is logic inside HOC wrapper to make it visible after its first mount.
|
|
234
|
+
// This mechanism ensures the entering transition.
|
|
235
|
+
visible: !!ALREADY_MOUNTED[modalId],
|
|
236
|
+
delayVisible: !ALREADY_MOUNTED[modalId]
|
|
237
|
+
}), _a));
|
|
238
|
+
}
|
|
239
|
+
case "nice-modal/hide": {
|
|
240
|
+
var modalId = action.payload.modalId;
|
|
241
|
+
if (!state[modalId])
|
|
242
|
+
return state;
|
|
243
|
+
return __assign(__assign({}, state), (_b = {}, _b[modalId] = __assign(__assign({}, state[modalId]), { visible: false }), _b));
|
|
244
|
+
}
|
|
245
|
+
case "nice-modal/remove": {
|
|
246
|
+
var modalId = action.payload.modalId;
|
|
247
|
+
var newState = __assign({}, state);
|
|
248
|
+
delete newState[modalId];
|
|
249
|
+
return newState;
|
|
250
|
+
}
|
|
251
|
+
case "nice-modal/set-flags": {
|
|
252
|
+
var _e = action.payload, modalId = _e.modalId, flags = _e.flags;
|
|
253
|
+
return __assign(__assign({}, state), (_c = {}, _c[modalId] = __assign(__assign({}, state[modalId]), flags), _c));
|
|
254
|
+
}
|
|
255
|
+
default:
|
|
256
|
+
return state;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
modalCallbacks = {};
|
|
260
|
+
hideModalCallbacks = {};
|
|
261
|
+
getModalId = function(modal) {
|
|
262
|
+
if (typeof modal === "string")
|
|
263
|
+
return modal;
|
|
264
|
+
if (!modal[symModalId]) {
|
|
265
|
+
modal[symModalId] = getUid();
|
|
266
|
+
}
|
|
267
|
+
return modal[symModalId];
|
|
268
|
+
};
|
|
269
|
+
remove = function(modal) {
|
|
270
|
+
var modalId = getModalId(modal);
|
|
271
|
+
dispatch(removeModal(modalId));
|
|
272
|
+
delete modalCallbacks[modalId];
|
|
273
|
+
delete hideModalCallbacks[modalId];
|
|
274
|
+
};
|
|
275
|
+
setFlags = function(modalId, flags) {
|
|
276
|
+
dispatch(setModalFlags(modalId, flags));
|
|
277
|
+
};
|
|
278
|
+
create = function(Comp) {
|
|
279
|
+
return function(_a) {
|
|
280
|
+
var _b;
|
|
281
|
+
var defaultVisible = _a.defaultVisible, keepMounted = _a.keepMounted, id = _a.id, props = __rest(_a, ["defaultVisible", "keepMounted", "id"]);
|
|
282
|
+
var _c = useModal(id), args = _c.args, show2 = _c.show;
|
|
283
|
+
var modals = (0, import_react.useContext)(NiceModalContext);
|
|
284
|
+
var shouldMount = !!modals[id];
|
|
285
|
+
(0, import_react.useEffect)(function() {
|
|
286
|
+
if (defaultVisible) {
|
|
287
|
+
show2();
|
|
288
|
+
}
|
|
289
|
+
ALREADY_MOUNTED[id] = true;
|
|
290
|
+
return function() {
|
|
291
|
+
delete ALREADY_MOUNTED[id];
|
|
292
|
+
};
|
|
293
|
+
}, [id, show2, defaultVisible]);
|
|
294
|
+
(0, import_react.useEffect)(function() {
|
|
295
|
+
if (keepMounted)
|
|
296
|
+
setFlags(id, { keepMounted: true });
|
|
297
|
+
}, [id, keepMounted]);
|
|
298
|
+
var delayVisible = (_b = modals[id]) === null || _b === void 0 ? void 0 : _b.delayVisible;
|
|
299
|
+
(0, import_react.useEffect)(function() {
|
|
300
|
+
if (delayVisible) {
|
|
301
|
+
show2(args);
|
|
302
|
+
}
|
|
303
|
+
}, [delayVisible, args, show2]);
|
|
304
|
+
if (!shouldMount)
|
|
305
|
+
return null;
|
|
306
|
+
return import_react.default.createElement(
|
|
307
|
+
NiceModalIdContext.Provider,
|
|
308
|
+
{ value: id },
|
|
309
|
+
import_react.default.createElement(Comp, __assign({}, props, args))
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
register = function(id, comp, props) {
|
|
314
|
+
if (!MODAL_REGISTRY[id]) {
|
|
315
|
+
MODAL_REGISTRY[id] = { comp, props };
|
|
316
|
+
} else {
|
|
317
|
+
MODAL_REGISTRY[id].props = props;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
unregister = function(id) {
|
|
321
|
+
delete MODAL_REGISTRY[id];
|
|
322
|
+
};
|
|
323
|
+
NiceModalPlaceholder = function() {
|
|
324
|
+
var modals = (0, import_react.useContext)(NiceModalContext);
|
|
325
|
+
var visibleModalIds = Object.keys(modals).filter(function(id) {
|
|
326
|
+
return !!modals[id];
|
|
327
|
+
});
|
|
328
|
+
visibleModalIds.forEach(function(id) {
|
|
329
|
+
if (!MODAL_REGISTRY[id] && !ALREADY_MOUNTED[id]) {
|
|
330
|
+
console.warn("No modal found for id: " + id + ". Please check the id or if it is registered or declared via JSX.");
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
var toRender = visibleModalIds.filter(function(id) {
|
|
335
|
+
return MODAL_REGISTRY[id];
|
|
336
|
+
}).map(function(id) {
|
|
337
|
+
return __assign({ id }, MODAL_REGISTRY[id]);
|
|
338
|
+
});
|
|
339
|
+
return import_react.default.createElement(import_react.default.Fragment, null, toRender.map(function(t) {
|
|
340
|
+
return import_react.default.createElement(t.comp, __assign({ key: t.id, id: t.id }, t.props));
|
|
341
|
+
}));
|
|
342
|
+
};
|
|
343
|
+
InnerContextProvider = function(_a) {
|
|
344
|
+
var children = _a.children;
|
|
345
|
+
var arr = (0, import_react.useReducer)(reducer, initialState);
|
|
346
|
+
var modals = arr[0];
|
|
347
|
+
dispatch = arr[1];
|
|
348
|
+
return import_react.default.createElement(
|
|
349
|
+
NiceModalContext.Provider,
|
|
350
|
+
{ value: modals },
|
|
351
|
+
children,
|
|
352
|
+
import_react.default.createElement(NiceModalPlaceholder, null)
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
Provider = function(_a) {
|
|
356
|
+
var children = _a.children, givenDispatch = _a.dispatch, givenModals = _a.modals;
|
|
357
|
+
if (!givenDispatch || !givenModals) {
|
|
358
|
+
return import_react.default.createElement(InnerContextProvider, null, children);
|
|
359
|
+
}
|
|
360
|
+
dispatch = givenDispatch;
|
|
361
|
+
return import_react.default.createElement(
|
|
362
|
+
NiceModalContext.Provider,
|
|
363
|
+
{ value: givenModals },
|
|
364
|
+
children,
|
|
365
|
+
import_react.default.createElement(NiceModalPlaceholder, null)
|
|
366
|
+
);
|
|
367
|
+
};
|
|
368
|
+
ModalDef = function(_a) {
|
|
369
|
+
var id = _a.id, component = _a.component;
|
|
370
|
+
(0, import_react.useEffect)(function() {
|
|
371
|
+
register(id, component);
|
|
372
|
+
return function() {
|
|
373
|
+
unregister(id);
|
|
374
|
+
};
|
|
375
|
+
}, [id, component]);
|
|
376
|
+
return null;
|
|
377
|
+
};
|
|
378
|
+
ModalHolder = function(_a) {
|
|
379
|
+
var _b;
|
|
380
|
+
var modal = _a.modal, _c = _a.handler, handler = _c === void 0 ? {} : _c, restProps = __rest(_a, ["modal", "handler"]);
|
|
381
|
+
var mid = (0, import_react.useMemo)(function() {
|
|
382
|
+
return getUid();
|
|
383
|
+
}, []);
|
|
384
|
+
var ModalComp = typeof modal === "string" ? (_b = MODAL_REGISTRY[modal]) === null || _b === void 0 ? void 0 : _b.comp : modal;
|
|
385
|
+
if (!handler) {
|
|
386
|
+
throw new Error("No handler found in NiceModal.ModalHolder.");
|
|
387
|
+
}
|
|
388
|
+
if (!ModalComp) {
|
|
389
|
+
throw new Error("No modal found for id: " + modal + " in NiceModal.ModalHolder.");
|
|
390
|
+
}
|
|
391
|
+
handler.show = (0, import_react.useCallback)(function(args) {
|
|
392
|
+
return show(mid, args);
|
|
393
|
+
}, [mid]);
|
|
394
|
+
handler.hide = (0, import_react.useCallback)(function() {
|
|
395
|
+
return hide(mid);
|
|
396
|
+
}, [mid]);
|
|
397
|
+
return import_react.default.createElement(ModalComp, __assign({ id: mid }, restProps));
|
|
398
|
+
};
|
|
399
|
+
antdModal = function(modal) {
|
|
400
|
+
return {
|
|
401
|
+
visible: modal.visible,
|
|
402
|
+
onOk: function() {
|
|
403
|
+
return modal.hide();
|
|
404
|
+
},
|
|
405
|
+
onCancel: function() {
|
|
406
|
+
return modal.hide();
|
|
407
|
+
},
|
|
408
|
+
afterClose: function() {
|
|
409
|
+
modal.resolveHide();
|
|
410
|
+
if (!modal.keepMounted)
|
|
411
|
+
modal.remove();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
antdDrawer = function(modal) {
|
|
416
|
+
return {
|
|
417
|
+
visible: modal.visible,
|
|
418
|
+
onClose: function() {
|
|
419
|
+
return modal.hide();
|
|
420
|
+
},
|
|
421
|
+
afterVisibleChange: function(v) {
|
|
422
|
+
if (!v) {
|
|
423
|
+
modal.resolveHide();
|
|
424
|
+
}
|
|
425
|
+
!v && !modal.keepMounted && modal.remove();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
muiDialog = function(modal) {
|
|
430
|
+
return {
|
|
431
|
+
open: modal.visible,
|
|
432
|
+
onClose: function() {
|
|
433
|
+
return modal.hide();
|
|
434
|
+
},
|
|
435
|
+
onExited: function() {
|
|
436
|
+
modal.resolveHide();
|
|
437
|
+
!modal.keepMounted && modal.remove();
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
bootstrapDialog = function(modal) {
|
|
442
|
+
return {
|
|
443
|
+
show: modal.visible,
|
|
444
|
+
onHide: function() {
|
|
445
|
+
return modal.hide();
|
|
446
|
+
},
|
|
447
|
+
onExited: function() {
|
|
448
|
+
modal.resolveHide();
|
|
449
|
+
!modal.keepMounted && modal.remove();
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
NiceModal = {
|
|
454
|
+
Provider,
|
|
455
|
+
ModalDef,
|
|
456
|
+
ModalHolder,
|
|
457
|
+
NiceModalContext,
|
|
458
|
+
create,
|
|
459
|
+
register,
|
|
460
|
+
getModal,
|
|
461
|
+
show,
|
|
462
|
+
hide,
|
|
463
|
+
remove,
|
|
464
|
+
useModal,
|
|
465
|
+
reducer,
|
|
466
|
+
antdModal,
|
|
467
|
+
antdDrawer,
|
|
468
|
+
muiDialog,
|
|
469
|
+
bootstrapDialog
|
|
470
|
+
};
|
|
471
|
+
esm_default = NiceModal;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
33
475
|
// src/types/payments.ts
|
|
34
476
|
var isNewCard, PaymentType, PaymentStatus;
|
|
35
477
|
var init_payments = __esm({
|
|
@@ -133,7 +575,7 @@ var init_errors = __esm({
|
|
|
133
575
|
var version;
|
|
134
576
|
var init_package = __esm({
|
|
135
577
|
"package.json"() {
|
|
136
|
-
version = "0.5.
|
|
578
|
+
version = "0.5.5";
|
|
137
579
|
}
|
|
138
580
|
});
|
|
139
581
|
|
|
@@ -259,28 +701,28 @@ var init_logger = __esm({
|
|
|
259
701
|
});
|
|
260
702
|
|
|
261
703
|
// src/context/SpreePayActionsContext.tsx
|
|
262
|
-
var
|
|
704
|
+
var import_react2, import_jsx_runtime, processLogger, SpreePayActionsContext, SpreePayProvider, useSpreePay, useSpreePaymentMethod, useSpreePayEnv, useSpreePayRegister;
|
|
263
705
|
var init_SpreePayActionsContext = __esm({
|
|
264
706
|
"src/context/SpreePayActionsContext.tsx"() {
|
|
265
707
|
"use strict";
|
|
266
|
-
|
|
708
|
+
import_react2 = require("react");
|
|
267
709
|
init_errors();
|
|
268
710
|
init_logger();
|
|
269
711
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
270
712
|
processLogger = logger.child("process");
|
|
271
|
-
SpreePayActionsContext = (0,
|
|
713
|
+
SpreePayActionsContext = (0, import_react2.createContext)(void 0);
|
|
272
714
|
SpreePayProvider = ({ children, env }) => {
|
|
273
|
-
const processRef = (0,
|
|
274
|
-
const inFlightRef = (0,
|
|
275
|
-
const [selectedPaymentMethod, setSelectedPaymentMethod] = (0,
|
|
715
|
+
const processRef = (0, import_react2.useRef)(null);
|
|
716
|
+
const inFlightRef = (0, import_react2.useRef)(false);
|
|
717
|
+
const [selectedPaymentMethod, setSelectedPaymentMethod] = (0, import_react2.useState)({
|
|
276
718
|
type: "CREDIT_CARD" /* CREDIT_CARD */,
|
|
277
719
|
method: null
|
|
278
720
|
});
|
|
279
|
-
const [isInternalProcessing, setInternalProcessing] = (0,
|
|
280
|
-
const
|
|
721
|
+
const [isInternalProcessing, setInternalProcessing] = (0, import_react2.useState)(false);
|
|
722
|
+
const register2 = (0, import_react2.useCallback)((fn) => {
|
|
281
723
|
processRef.current = fn;
|
|
282
724
|
}, []);
|
|
283
|
-
const process = (0,
|
|
725
|
+
const process = (0, import_react2.useCallback)(
|
|
284
726
|
async (data) => {
|
|
285
727
|
if (!processRef.current) {
|
|
286
728
|
const error = new Error("SpreePay process function not registered");
|
|
@@ -330,14 +772,14 @@ var init_SpreePayActionsContext = __esm({
|
|
|
330
772
|
enabled: Boolean(selectedPaymentMethod.method),
|
|
331
773
|
isInternalProcessing,
|
|
332
774
|
process,
|
|
333
|
-
register,
|
|
775
|
+
register: register2,
|
|
334
776
|
selectedPaymentMethod,
|
|
335
777
|
setSelectedPaymentMethod
|
|
336
778
|
};
|
|
337
779
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpreePayActionsContext.Provider, { value, children });
|
|
338
780
|
};
|
|
339
781
|
useSpreePay = () => {
|
|
340
|
-
const ctx = (0,
|
|
782
|
+
const ctx = (0, import_react2.useContext)(SpreePayActionsContext);
|
|
341
783
|
if (!ctx) throw new Error("useSpreePay must be used within a SpreePayProvider");
|
|
342
784
|
return {
|
|
343
785
|
process: ctx.process,
|
|
@@ -347,7 +789,7 @@ var init_SpreePayActionsContext = __esm({
|
|
|
347
789
|
};
|
|
348
790
|
};
|
|
349
791
|
useSpreePaymentMethod = () => {
|
|
350
|
-
const ctx = (0,
|
|
792
|
+
const ctx = (0, import_react2.useContext)(SpreePayActionsContext);
|
|
351
793
|
if (!ctx) throw new Error("useSpreePay must be used within a SpreePayProvider");
|
|
352
794
|
return {
|
|
353
795
|
setSelectedPaymentMethod: ctx.setSelectedPaymentMethod,
|
|
@@ -356,12 +798,12 @@ var init_SpreePayActionsContext = __esm({
|
|
|
356
798
|
};
|
|
357
799
|
};
|
|
358
800
|
useSpreePayEnv = () => {
|
|
359
|
-
const ctx = (0,
|
|
801
|
+
const ctx = (0, import_react2.useContext)(SpreePayActionsContext);
|
|
360
802
|
if (!ctx) throw new Error("useSpreePay must be used within a SpreePayProvider");
|
|
361
803
|
return ctx.env;
|
|
362
804
|
};
|
|
363
805
|
useSpreePayRegister = () => {
|
|
364
|
-
const ctx = (0,
|
|
806
|
+
const ctx = (0, import_react2.useContext)(SpreePayActionsContext);
|
|
365
807
|
if (!ctx) throw new Error("useSpreePayRegister must be used within a SpreePayProvider");
|
|
366
808
|
return { register: ctx.register };
|
|
367
809
|
};
|
|
@@ -457,20 +899,20 @@ var init_config = __esm({
|
|
|
457
899
|
});
|
|
458
900
|
|
|
459
901
|
// src/context/StaticConfigContext.tsx
|
|
460
|
-
var
|
|
902
|
+
var import_react3, import_jsx_runtime2, StaticConfigContext, StaticConfigProvider, useStaticConfig;
|
|
461
903
|
var init_StaticConfigContext = __esm({
|
|
462
904
|
"src/context/StaticConfigContext.tsx"() {
|
|
463
905
|
"use strict";
|
|
464
906
|
"use client";
|
|
465
|
-
|
|
907
|
+
import_react3 = require("react");
|
|
466
908
|
init_logger();
|
|
467
909
|
init_SpreePayActionsContext();
|
|
468
910
|
init_config();
|
|
469
911
|
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
470
|
-
StaticConfigContext = (0,
|
|
912
|
+
StaticConfigContext = (0, import_react3.createContext)(null);
|
|
471
913
|
StaticConfigProvider = ({ children, props }) => {
|
|
472
914
|
const { environment, tenantId } = useSpreePayEnv();
|
|
473
|
-
const staticConfig = (0,
|
|
915
|
+
const staticConfig = (0, import_react3.useMemo)(() => {
|
|
474
916
|
const envConfig = config[environment];
|
|
475
917
|
const isKnownTenant = tenantId in envConfig;
|
|
476
918
|
if (!isKnownTenant) {
|
|
@@ -482,11 +924,11 @@ var init_StaticConfigContext = __esm({
|
|
|
482
924
|
const appKey = isKnownTenant ? tenantId : "moca";
|
|
483
925
|
return envConfig[appKey];
|
|
484
926
|
}, [environment, tenantId]);
|
|
485
|
-
const value = (0,
|
|
927
|
+
const value = (0, import_react3.useMemo)(() => ({ staticConfig, appProps: props }), [staticConfig, props]);
|
|
486
928
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StaticConfigContext.Provider, { value, children });
|
|
487
929
|
};
|
|
488
930
|
useStaticConfig = () => {
|
|
489
|
-
const ctx = (0,
|
|
931
|
+
const ctx = (0, import_react3.useContext)(StaticConfigContext);
|
|
490
932
|
if (!ctx) throw new Error("useStaticConfig must be used within StaticConfigProvider");
|
|
491
933
|
return ctx;
|
|
492
934
|
};
|
|
@@ -531,17 +973,17 @@ function PortalContainerProvider({
|
|
|
531
973
|
container,
|
|
532
974
|
children
|
|
533
975
|
}) {
|
|
534
|
-
return
|
|
976
|
+
return import_react4.default.createElement(PortalContainerContext.Provider, { value: { container } }, children);
|
|
535
977
|
}
|
|
536
978
|
function usePortalContainer() {
|
|
537
|
-
return
|
|
979
|
+
return import_react4.default.useContext(PortalContainerContext).container;
|
|
538
980
|
}
|
|
539
|
-
var
|
|
981
|
+
var import_react4, PortalContainerContext;
|
|
540
982
|
var init_portal = __esm({
|
|
541
983
|
"src/ui/portal.ts"() {
|
|
542
984
|
"use strict";
|
|
543
|
-
|
|
544
|
-
PortalContainerContext =
|
|
985
|
+
import_react4 = __toESM(require("react"), 1);
|
|
986
|
+
PortalContainerContext = import_react4.default.createContext({ container: null });
|
|
545
987
|
}
|
|
546
988
|
});
|
|
547
989
|
|
|
@@ -636,18 +1078,18 @@ var init_dialog = __esm({
|
|
|
636
1078
|
});
|
|
637
1079
|
|
|
638
1080
|
// src/modals/Iframe3ds.tsx
|
|
639
|
-
var
|
|
1081
|
+
var import_react5, import_jsx_runtime4, Iframe3ds;
|
|
640
1082
|
var init_Iframe3ds = __esm({
|
|
641
1083
|
"src/modals/Iframe3ds.tsx"() {
|
|
642
1084
|
"use strict";
|
|
643
|
-
|
|
644
|
-
|
|
1085
|
+
import_react5 = require("react");
|
|
1086
|
+
init_esm();
|
|
645
1087
|
init_eventBus();
|
|
646
1088
|
init_dialog();
|
|
647
1089
|
import_jsx_runtime4 = require("react/jsx-runtime");
|
|
648
|
-
Iframe3ds =
|
|
649
|
-
const modal =
|
|
650
|
-
(0,
|
|
1090
|
+
Iframe3ds = esm_default.create(({ url }) => {
|
|
1091
|
+
const modal = useModal();
|
|
1092
|
+
(0, import_react5.useEffect)(() => {
|
|
651
1093
|
return bus.on("paymentIntent", (data) => {
|
|
652
1094
|
modal.resolve(data.paymentIntent);
|
|
653
1095
|
modal.remove();
|
|
@@ -970,11 +1412,11 @@ var init_useSpreePayConfig = __esm({
|
|
|
970
1412
|
const { origin, tenantId } = useSpreePayEnv();
|
|
971
1413
|
const { staticConfig } = useStaticConfig();
|
|
972
1414
|
const key = origin ? `${URL}?origin=${origin}` : URL;
|
|
973
|
-
const { data, isLoading } = (0, import_swr.default)(
|
|
1415
|
+
const { data, isLoading, error } = (0, import_swr.default)(
|
|
974
1416
|
key,
|
|
975
1417
|
(path) => publicGet(staticConfig.slapiUrl, tenantId, path)
|
|
976
1418
|
);
|
|
977
|
-
return { spreePayConfig: data ?? null, configIsLoading: isLoading };
|
|
1419
|
+
return { spreePayConfig: data ?? null, configIsLoading: isLoading, configError: error };
|
|
978
1420
|
};
|
|
979
1421
|
}
|
|
980
1422
|
});
|
|
@@ -1010,16 +1452,16 @@ var init_useSlapiBalance = __esm({
|
|
|
1010
1452
|
});
|
|
1011
1453
|
|
|
1012
1454
|
// src/context/LoginStatusContext.tsx
|
|
1013
|
-
var
|
|
1455
|
+
var import_react7, import_jsx_runtime5, LoginStatusContext, LoginStatusProvider, useIsLoggedIn;
|
|
1014
1456
|
var init_LoginStatusContext = __esm({
|
|
1015
1457
|
"src/context/LoginStatusContext.tsx"() {
|
|
1016
1458
|
"use strict";
|
|
1017
1459
|
"use client";
|
|
1018
|
-
|
|
1460
|
+
import_react7 = require("react");
|
|
1019
1461
|
import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1020
|
-
LoginStatusContext = (0,
|
|
1462
|
+
LoginStatusContext = (0, import_react7.createContext)(false);
|
|
1021
1463
|
LoginStatusProvider = ({ isLoggedIn, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoginStatusContext.Provider, { value: isLoggedIn, children });
|
|
1022
|
-
useIsLoggedIn = () => (0,
|
|
1464
|
+
useIsLoggedIn = () => (0, import_react7.useContext)(LoginStatusContext);
|
|
1023
1465
|
}
|
|
1024
1466
|
});
|
|
1025
1467
|
|
|
@@ -1234,11 +1676,11 @@ var init_InfoBanner = __esm({
|
|
|
1234
1676
|
});
|
|
1235
1677
|
|
|
1236
1678
|
// src/components/common/PointsSwitch.tsx
|
|
1237
|
-
var
|
|
1679
|
+
var import_react8, import_jsx_runtime10, PointsSwitch;
|
|
1238
1680
|
var init_PointsSwitch = __esm({
|
|
1239
1681
|
"src/components/common/PointsSwitch.tsx"() {
|
|
1240
1682
|
"use strict";
|
|
1241
|
-
|
|
1683
|
+
import_react8 = require("react");
|
|
1242
1684
|
init_StaticConfigContext();
|
|
1243
1685
|
init_useSlapiBalance();
|
|
1244
1686
|
init_useSpreePayConfig();
|
|
@@ -1255,7 +1697,7 @@ var init_PointsSwitch = __esm({
|
|
|
1255
1697
|
const { balance } = useSlapiBalance();
|
|
1256
1698
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
1257
1699
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
1258
|
-
const id = (0,
|
|
1700
|
+
const id = (0, import_react8.useId)();
|
|
1259
1701
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
1260
1702
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1261
1703
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
@@ -1936,11 +2378,11 @@ var init_input = __esm({
|
|
|
1936
2378
|
});
|
|
1937
2379
|
|
|
1938
2380
|
// ../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
1939
|
-
var
|
|
2381
|
+
var React14, ReactDOM2, import_react_slot5, import_jsx_runtime35, NODES2, Primitive2;
|
|
1940
2382
|
var init_dist = __esm({
|
|
1941
2383
|
"../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs"() {
|
|
1942
2384
|
"use strict";
|
|
1943
|
-
|
|
2385
|
+
React14 = __toESM(require("react"), 1);
|
|
1944
2386
|
ReactDOM2 = __toESM(require("react-dom"), 1);
|
|
1945
2387
|
import_react_slot5 = require("@radix-ui/react-slot");
|
|
1946
2388
|
import_jsx_runtime35 = require("react/jsx-runtime");
|
|
@@ -1965,7 +2407,7 @@ var init_dist = __esm({
|
|
|
1965
2407
|
];
|
|
1966
2408
|
Primitive2 = NODES2.reduce((primitive, node) => {
|
|
1967
2409
|
const Slot2 = (0, import_react_slot5.createSlot)(`Primitive.${node}`);
|
|
1968
|
-
const Node2 =
|
|
2410
|
+
const Node2 = React14.forwardRef((props, forwardedRef) => {
|
|
1969
2411
|
const { asChild, ...primitiveProps } = props;
|
|
1970
2412
|
const Comp = asChild ? Slot2 : node;
|
|
1971
2413
|
if (typeof window !== "undefined") {
|
|
@@ -1983,17 +2425,17 @@ var init_dist = __esm({
|
|
|
1983
2425
|
function isValidOrientation(orientation) {
|
|
1984
2426
|
return ORIENTATIONS.includes(orientation);
|
|
1985
2427
|
}
|
|
1986
|
-
var
|
|
2428
|
+
var React15, import_jsx_runtime36, NAME, DEFAULT_ORIENTATION, ORIENTATIONS, Separator, Root6;
|
|
1987
2429
|
var init_dist2 = __esm({
|
|
1988
2430
|
"../../node_modules/@radix-ui/react-separator/dist/index.mjs"() {
|
|
1989
2431
|
"use strict";
|
|
1990
|
-
|
|
2432
|
+
React15 = __toESM(require("react"), 1);
|
|
1991
2433
|
init_dist();
|
|
1992
2434
|
import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1993
2435
|
NAME = "Separator";
|
|
1994
2436
|
DEFAULT_ORIENTATION = "horizontal";
|
|
1995
2437
|
ORIENTATIONS = ["horizontal", "vertical"];
|
|
1996
|
-
Separator =
|
|
2438
|
+
Separator = React15.forwardRef((props, forwardedRef) => {
|
|
1997
2439
|
const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
|
|
1998
2440
|
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
|
1999
2441
|
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
|
@@ -2050,10 +2492,10 @@ function useBaseERC20Token() {
|
|
|
2050
2492
|
const { address } = (0, import_wagmi2.useAccount)();
|
|
2051
2493
|
const baseClient = (0, import_wagmi2.usePublicClient)({ chainId: BASE_CHAIN_ID });
|
|
2052
2494
|
const defaultClient = (0, import_wagmi2.usePublicClient)();
|
|
2053
|
-
const [rows, setRows] =
|
|
2054
|
-
const [isLoading, setLoading] =
|
|
2055
|
-
const [error, setError] =
|
|
2056
|
-
|
|
2495
|
+
const [rows, setRows] = React16.useState([]);
|
|
2496
|
+
const [isLoading, setLoading] = React16.useState(false);
|
|
2497
|
+
const [error, setError] = React16.useState(null);
|
|
2498
|
+
React16.useEffect(() => {
|
|
2057
2499
|
let cancelled = false;
|
|
2058
2500
|
async function run() {
|
|
2059
2501
|
const client = baseClient ?? defaultClient;
|
|
@@ -2108,11 +2550,11 @@ function useBaseERC20Token() {
|
|
|
2108
2550
|
}, [address, baseClient, defaultClient]);
|
|
2109
2551
|
return { isLoading, error: error ?? null, erc20Balances: rows };
|
|
2110
2552
|
}
|
|
2111
|
-
var
|
|
2553
|
+
var React16, import_viem5, import_wagmi2;
|
|
2112
2554
|
var init_useBaseERC20Token = __esm({
|
|
2113
2555
|
"src/hooks/useBaseERC20Token.ts"() {
|
|
2114
2556
|
"use strict";
|
|
2115
|
-
|
|
2557
|
+
React16 = __toESM(require("react"), 1);
|
|
2116
2558
|
import_viem5 = require("viem");
|
|
2117
2559
|
import_wagmi2 = require("wagmi");
|
|
2118
2560
|
init_baseTokens();
|
|
@@ -2157,12 +2599,12 @@ var init_useBaseTokens = __esm({
|
|
|
2157
2599
|
});
|
|
2158
2600
|
|
|
2159
2601
|
// src/modals/CryptoSelectModal.tsx
|
|
2160
|
-
var
|
|
2602
|
+
var import_react18, import_jsx_runtime38, CryptoSelectModal;
|
|
2161
2603
|
var init_CryptoSelectModal = __esm({
|
|
2162
2604
|
"src/modals/CryptoSelectModal.tsx"() {
|
|
2163
2605
|
"use strict";
|
|
2164
|
-
|
|
2165
|
-
|
|
2606
|
+
import_react18 = require("react");
|
|
2607
|
+
init_esm();
|
|
2166
2608
|
init_input();
|
|
2167
2609
|
init_separator();
|
|
2168
2610
|
init_symbolLogos();
|
|
@@ -2172,13 +2614,13 @@ var init_CryptoSelectModal = __esm({
|
|
|
2172
2614
|
init_useBaseTokens();
|
|
2173
2615
|
init_dialog();
|
|
2174
2616
|
import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2175
|
-
CryptoSelectModal =
|
|
2176
|
-
const modal =
|
|
2617
|
+
CryptoSelectModal = esm_default.create(() => {
|
|
2618
|
+
const modal = useModal();
|
|
2177
2619
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
2178
2620
|
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
2179
2621
|
const { tokens, tokensIsLoading } = useBaseTokens();
|
|
2180
|
-
const [search, setSearch] = (0,
|
|
2181
|
-
const filteredCoins = (0,
|
|
2622
|
+
const [search, setSearch] = (0, import_react18.useState)("");
|
|
2623
|
+
const filteredCoins = (0, import_react18.useMemo)(() => {
|
|
2182
2624
|
return tokens.filter(
|
|
2183
2625
|
(coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
|
|
2184
2626
|
);
|
|
@@ -2282,16 +2724,16 @@ var init_CryptoSelectModal = __esm({
|
|
|
2282
2724
|
});
|
|
2283
2725
|
|
|
2284
2726
|
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
2285
|
-
var
|
|
2727
|
+
var import_jsx_runtime39, SelectCoinButton;
|
|
2286
2728
|
var init_SelectCoinButton = __esm({
|
|
2287
2729
|
"src/components/CryptoTab/Crypto/SelectCoinButton.tsx"() {
|
|
2288
2730
|
"use strict";
|
|
2289
|
-
|
|
2731
|
+
init_esm();
|
|
2290
2732
|
init_CryptoSelectModal();
|
|
2291
2733
|
import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2292
2734
|
SelectCoinButton = () => {
|
|
2293
2735
|
const openModal = () => {
|
|
2294
|
-
|
|
2736
|
+
esm_default.show(CryptoSelectModal);
|
|
2295
2737
|
};
|
|
2296
2738
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2297
2739
|
"button",
|
|
@@ -2338,11 +2780,11 @@ var init_SelectedCoin = __esm({
|
|
|
2338
2780
|
});
|
|
2339
2781
|
|
|
2340
2782
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
2341
|
-
var
|
|
2783
|
+
var import_react19, import_wagmi4, import_jsx_runtime41, Crypto;
|
|
2342
2784
|
var init_Crypto = __esm({
|
|
2343
2785
|
"src/components/CryptoTab/Crypto/Crypto.tsx"() {
|
|
2344
2786
|
"use strict";
|
|
2345
|
-
|
|
2787
|
+
import_react19 = require("react");
|
|
2346
2788
|
import_wagmi4 = require("wagmi");
|
|
2347
2789
|
init_SpreePayActionsContext();
|
|
2348
2790
|
init_useCryptoPayment();
|
|
@@ -2360,8 +2802,8 @@ var init_Crypto = __esm({
|
|
|
2360
2802
|
const { cryptoPayment } = useCryptoPayment();
|
|
2361
2803
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2362
2804
|
const isWalletConnected = Boolean(address);
|
|
2363
|
-
const { register } = useSpreePayRegister();
|
|
2364
|
-
const handlePay = (0,
|
|
2805
|
+
const { register: register2 } = useSpreePayRegister();
|
|
2806
|
+
const handlePay = (0, import_react19.useCallback)(
|
|
2365
2807
|
async (data) => {
|
|
2366
2808
|
try {
|
|
2367
2809
|
const res = await cryptoPayment(data);
|
|
@@ -2372,9 +2814,9 @@ var init_Crypto = __esm({
|
|
|
2372
2814
|
},
|
|
2373
2815
|
[cryptoPayment]
|
|
2374
2816
|
);
|
|
2375
|
-
(0,
|
|
2376
|
-
|
|
2377
|
-
}, [
|
|
2817
|
+
(0, import_react19.useEffect)(() => {
|
|
2818
|
+
register2(handlePay);
|
|
2819
|
+
}, [register2, handlePay]);
|
|
2378
2820
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
2379
2821
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
2380
2822
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "text-lg leading-7 font-medium text-(--brand-primary) md:text-[22px]", children: "Pay with Crypto" }),
|
|
@@ -2408,13 +2850,13 @@ function getCachedWagmiConfig(projectId, appName) {
|
|
|
2408
2850
|
}
|
|
2409
2851
|
return cfg2;
|
|
2410
2852
|
}
|
|
2411
|
-
var
|
|
2853
|
+
var import_react20, import_react_query, import_rainbowkit2, import_styles, import_wagmi5, import_chains, import_jsx_runtime42, queryClient, CHAINS, wagmiConfigCache, CryptoWrapper;
|
|
2412
2854
|
var init_CryptoWrapper = __esm({
|
|
2413
2855
|
"src/components/CryptoTab/Crypto/CryptoWrapper.tsx"() {
|
|
2414
2856
|
"use strict";
|
|
2415
|
-
|
|
2857
|
+
import_react20 = require("react");
|
|
2416
2858
|
import_react_query = require("@tanstack/react-query");
|
|
2417
|
-
|
|
2859
|
+
init_esm();
|
|
2418
2860
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
2419
2861
|
import_styles = require("@rainbow-me/rainbowkit/styles.css");
|
|
2420
2862
|
import_wagmi5 = require("wagmi");
|
|
@@ -2429,12 +2871,12 @@ var init_CryptoWrapper = __esm({
|
|
|
2429
2871
|
CryptoWrapper = () => {
|
|
2430
2872
|
const isLoggedIn = useIsLoggedIn();
|
|
2431
2873
|
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
2432
|
-
const wagmiConfig = (0,
|
|
2874
|
+
const wagmiConfig = (0, import_react20.useMemo)(() => {
|
|
2433
2875
|
if (!spreePayConfig) return null;
|
|
2434
2876
|
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
2435
2877
|
}, [spreePayConfig]);
|
|
2436
2878
|
if (!isLoggedIn || configIsLoading || !wagmiConfig) return null;
|
|
2437
|
-
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(esm_default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Crypto, {}) }) }) }) });
|
|
2438
2880
|
};
|
|
2439
2881
|
}
|
|
2440
2882
|
});
|
|
@@ -2481,11 +2923,11 @@ var init_CryptoTab2 = __esm({
|
|
|
2481
2923
|
});
|
|
2482
2924
|
|
|
2483
2925
|
// src/hooks/payments/useCryptoComPayment.ts
|
|
2484
|
-
var
|
|
2926
|
+
var cryptoComLogger, useCryptoComPayment;
|
|
2485
2927
|
var init_useCryptoComPayment = __esm({
|
|
2486
2928
|
"src/hooks/payments/useCryptoComPayment.ts"() {
|
|
2487
2929
|
"use strict";
|
|
2488
|
-
|
|
2930
|
+
init_esm();
|
|
2489
2931
|
init_SpreePayActionsContext();
|
|
2490
2932
|
init_Iframe3ds();
|
|
2491
2933
|
init_slapi();
|
|
@@ -2516,7 +2958,7 @@ var init_useCryptoComPayment = __esm({
|
|
|
2516
2958
|
let { status } = paymentResData;
|
|
2517
2959
|
if (paymentResData.redirectUrl) {
|
|
2518
2960
|
cryptoComLogger.debug("Opening CDC payment redirect", { paymentId: paymentResData.id });
|
|
2519
|
-
const paymentIntent = await
|
|
2961
|
+
const paymentIntent = await esm_default.show(Iframe3ds, { url: paymentResData.redirectUrl });
|
|
2520
2962
|
cryptoComLogger.info("CDC payment redirect completed", { paymentIntent });
|
|
2521
2963
|
if (paymentIntent === "success") {
|
|
2522
2964
|
cryptoComLogger.debug("Validating CDC payment", { paymentId: paymentResData.id });
|
|
@@ -2619,11 +3061,11 @@ var init_Checkout = __esm({
|
|
|
2619
3061
|
});
|
|
2620
3062
|
|
|
2621
3063
|
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
2622
|
-
var
|
|
3064
|
+
var import_react21, import_jsx_runtime45, CryptoComTab;
|
|
2623
3065
|
var init_CryptoComTab = __esm({
|
|
2624
3066
|
"src/components/CryptoComTab/CryptoComTab.tsx"() {
|
|
2625
3067
|
"use strict";
|
|
2626
|
-
|
|
3068
|
+
import_react21 = require("react");
|
|
2627
3069
|
init_SpreePayActionsContext();
|
|
2628
3070
|
init_useCryptoComPayment();
|
|
2629
3071
|
init_useSpreePayConfig();
|
|
@@ -2632,10 +3074,10 @@ var init_CryptoComTab = __esm({
|
|
|
2632
3074
|
init_Checkout();
|
|
2633
3075
|
import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2634
3076
|
CryptoComTab = () => {
|
|
2635
|
-
const { register } = useSpreePayRegister();
|
|
3077
|
+
const { register: register2 } = useSpreePayRegister();
|
|
2636
3078
|
const { cryptoComPayment } = useCryptoComPayment();
|
|
2637
3079
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2638
|
-
const handlePay = (0,
|
|
3080
|
+
const handlePay = (0, import_react21.useCallback)(
|
|
2639
3081
|
async (data) => {
|
|
2640
3082
|
try {
|
|
2641
3083
|
const res = await cryptoComPayment(data);
|
|
@@ -2646,9 +3088,9 @@ var init_CryptoComTab = __esm({
|
|
|
2646
3088
|
},
|
|
2647
3089
|
[cryptoComPayment]
|
|
2648
3090
|
);
|
|
2649
|
-
(0,
|
|
2650
|
-
|
|
2651
|
-
}, [
|
|
3091
|
+
(0, import_react21.useEffect)(() => {
|
|
3092
|
+
register2(handlePay);
|
|
3093
|
+
}, [register2, handlePay]);
|
|
2652
3094
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
|
|
2653
3095
|
spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InfoBanner, { message: spreePayConfig.cryptoCom.infoMessage }),
|
|
2654
3096
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Legal, {}),
|
|
@@ -2690,20 +3132,20 @@ __export(index_exports, {
|
|
|
2690
3132
|
module.exports = __toCommonJS(index_exports);
|
|
2691
3133
|
|
|
2692
3134
|
// src/SpreePay.tsx
|
|
2693
|
-
var
|
|
2694
|
-
|
|
3135
|
+
var import_react25 = require("react");
|
|
3136
|
+
init_esm();
|
|
2695
3137
|
var import_swr5 = require("swr");
|
|
2696
3138
|
|
|
2697
3139
|
// src/SpreePayContent.tsx
|
|
2698
|
-
var
|
|
3140
|
+
var import_react22 = require("react");
|
|
2699
3141
|
|
|
2700
3142
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
2701
|
-
var
|
|
3143
|
+
var import_react17 = require("react");
|
|
2702
3144
|
init_SpreePayActionsContext();
|
|
2703
3145
|
init_StaticConfigContext();
|
|
2704
3146
|
|
|
2705
3147
|
// src/hooks/payments/useCardPayment.ts
|
|
2706
|
-
|
|
3148
|
+
init_esm();
|
|
2707
3149
|
init_SpreePayActionsContext();
|
|
2708
3150
|
init_StaticConfigContext();
|
|
2709
3151
|
init_Iframe3ds();
|
|
@@ -2773,7 +3215,7 @@ var useCardPayment = () => {
|
|
|
2773
3215
|
cardPaymentLogger.debug("Starting 3DS flow", {
|
|
2774
3216
|
paymentId: paymentResData.id
|
|
2775
3217
|
});
|
|
2776
|
-
const paymentIntent = await
|
|
3218
|
+
const paymentIntent = await esm_default.show(Iframe3ds, { url: paymentResData.redirectUrl });
|
|
2777
3219
|
if (paymentIntent) {
|
|
2778
3220
|
cardPaymentLogger.debug("3DS completed, validating", {
|
|
2779
3221
|
paymentId: paymentResData.id,
|
|
@@ -2920,7 +3362,7 @@ init_logger();
|
|
|
2920
3362
|
init_useSpreePayConfig();
|
|
2921
3363
|
|
|
2922
3364
|
// src/hooks/payments/utils.ts
|
|
2923
|
-
|
|
3365
|
+
init_esm();
|
|
2924
3366
|
init_Iframe3ds();
|
|
2925
3367
|
init_slapi();
|
|
2926
3368
|
init_errors();
|
|
@@ -2968,7 +3410,7 @@ async function longPollCardStatus(paymentId) {
|
|
|
2968
3410
|
return detail.status;
|
|
2969
3411
|
}
|
|
2970
3412
|
if (!shown3ds && detail.card?.redirectUrl) {
|
|
2971
|
-
const paymentIntent = await
|
|
3413
|
+
const paymentIntent = await esm_default.show(Iframe3ds, { url: detail.card?.redirectUrl });
|
|
2972
3414
|
shown3ds = true;
|
|
2973
3415
|
if (paymentIntent) {
|
|
2974
3416
|
await SlapiPaymentService.validate3DS({ paymentId });
|
|
@@ -3089,7 +3531,7 @@ var usePointsPayment = (mode = "web2") => {
|
|
|
3089
3531
|
};
|
|
3090
3532
|
|
|
3091
3533
|
// src/hooks/payments/useSplitCardPayments.ts
|
|
3092
|
-
|
|
3534
|
+
init_esm();
|
|
3093
3535
|
init_SpreePayActionsContext();
|
|
3094
3536
|
init_StaticConfigContext();
|
|
3095
3537
|
init_Iframe3ds();
|
|
@@ -3153,7 +3595,7 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3153
3595
|
});
|
|
3154
3596
|
if (paymentResData.redirectUrl) {
|
|
3155
3597
|
splitPaymentLogger.debug("Starting 3DS flow for card portion", { paymentId: paymentResData.id });
|
|
3156
|
-
const paymentIntent = await
|
|
3598
|
+
const paymentIntent = await esm_default.show(Iframe3ds, { url: paymentResData.redirectUrl });
|
|
3157
3599
|
if (paymentIntent) {
|
|
3158
3600
|
splitPaymentLogger.debug("3DS completed, validating", { paymentId: paymentResData.id });
|
|
3159
3601
|
await SlapiPaymentService.validate3DS({ paymentId: paymentResData.id });
|
|
@@ -3228,14 +3670,14 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3228
3670
|
};
|
|
3229
3671
|
|
|
3230
3672
|
// src/hooks/useCards.ts
|
|
3231
|
-
var
|
|
3673
|
+
var import_react6 = require("react");
|
|
3232
3674
|
var import_swr2 = __toESM(require("swr"), 1);
|
|
3233
3675
|
init_SpreePayActionsContext();
|
|
3234
3676
|
var URL2 = "/v1/payments/cards";
|
|
3235
3677
|
var useCards = () => {
|
|
3236
3678
|
const { origin } = useSpreePayEnv();
|
|
3237
3679
|
const { data, isLoading, mutate } = (0, import_swr2.default)(origin ? `${URL2}?origin=${origin}` : URL2);
|
|
3238
|
-
const cards = (0,
|
|
3680
|
+
const cards = (0, import_react6.useMemo)(() => data?.data.filter((c) => c.active) ?? [], [data]);
|
|
3239
3681
|
return {
|
|
3240
3682
|
cards,
|
|
3241
3683
|
cardsIsLoading: isLoading,
|
|
@@ -3252,7 +3694,7 @@ init_split();
|
|
|
3252
3694
|
init_CheckoutButton();
|
|
3253
3695
|
|
|
3254
3696
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3255
|
-
var
|
|
3697
|
+
var import_react11 = require("react");
|
|
3256
3698
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
3257
3699
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
3258
3700
|
init_LoginStatusContext();
|
|
@@ -3261,13 +3703,13 @@ init_useSpreePayConfig();
|
|
|
3261
3703
|
init_InfoBanner();
|
|
3262
3704
|
|
|
3263
3705
|
// src/components/CreditCardTab/CreditCard/CardsList.tsx
|
|
3264
|
-
var
|
|
3706
|
+
var import_react9 = require("react");
|
|
3265
3707
|
init_utils();
|
|
3266
3708
|
init_slapi();
|
|
3267
3709
|
init_payments();
|
|
3268
3710
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3269
3711
|
var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
3270
|
-
const [isRemoving, setIsRemoving] = (0,
|
|
3712
|
+
const [isRemoving, setIsRemoving] = (0, import_react9.useState)(false);
|
|
3271
3713
|
const removeDisabled = isSelected || isRemoving;
|
|
3272
3714
|
const handleRemove = async (e) => {
|
|
3273
3715
|
e.stopPropagation();
|
|
@@ -3332,7 +3774,7 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
|
3332
3774
|
};
|
|
3333
3775
|
var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
3334
3776
|
const { cards, cardsIsLoading, mutateCards } = useCards();
|
|
3335
|
-
const allCards = (0,
|
|
3777
|
+
const allCards = (0, import_react9.useMemo)(() => [...cards, ...newCards], [cards, newCards]);
|
|
3336
3778
|
const handleRemove = async (card) => {
|
|
3337
3779
|
if (isNewCard(card)) {
|
|
3338
3780
|
onRemoveNewCard(card);
|
|
@@ -3358,7 +3800,7 @@ var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
|
3358
3800
|
};
|
|
3359
3801
|
|
|
3360
3802
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
3361
|
-
var
|
|
3803
|
+
var import_react10 = require("react");
|
|
3362
3804
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
3363
3805
|
|
|
3364
3806
|
// src/ui/button.tsx
|
|
@@ -3440,15 +3882,15 @@ var stripeElementClasses = {
|
|
|
3440
3882
|
invalid: "focus-visible:ring-(--negative)",
|
|
3441
3883
|
focus: "border-(--b-tertiary) ring-(--b-tertiary)/50 ring-2"
|
|
3442
3884
|
};
|
|
3443
|
-
var CreditCardForm = ({ cancel, saveCard }) => {
|
|
3444
|
-
const [cardError, setCardError] = (0,
|
|
3445
|
-
const [stripeStyles, setStripeStyles] = (0,
|
|
3446
|
-
const [shouldSaveCard, setShouldSaveCard] = (0,
|
|
3447
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
3885
|
+
var CreditCardForm = ({ cancel, saveCard, showCancel }) => {
|
|
3886
|
+
const [cardError, setCardError] = (0, import_react10.useState)(void 0);
|
|
3887
|
+
const [stripeStyles, setStripeStyles] = (0, import_react10.useState)({});
|
|
3888
|
+
const [shouldSaveCard, setShouldSaveCard] = (0, import_react10.useState)(true);
|
|
3889
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react10.useState)(false);
|
|
3448
3890
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
3449
3891
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
3450
|
-
const [id] = (0,
|
|
3451
|
-
const formRef = (0,
|
|
3892
|
+
const [id] = (0, import_react10.useState)(() => crypto.randomUUID());
|
|
3893
|
+
const formRef = (0, import_react10.useCallback)((node) => {
|
|
3452
3894
|
if (!node) return;
|
|
3453
3895
|
const container = node.closest(".sl-spreepay");
|
|
3454
3896
|
if (!container) return;
|
|
@@ -3547,7 +3989,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3547
3989
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { className: "text-sm font-medium", htmlFor: "saveCard", children: "Save card for future purchases" })
|
|
3548
3990
|
] }),
|
|
3549
3991
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full justify-end gap-2", children: [
|
|
3550
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3992
|
+
showCancel && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3551
3993
|
Button,
|
|
3552
3994
|
{
|
|
3553
3995
|
variant: "outline",
|
|
@@ -3572,15 +4014,32 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3572
4014
|
|
|
3573
4015
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3574
4016
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3575
|
-
var StripeWrapper = ({ onCancel, saveNewCard, publicKey }) => {
|
|
3576
|
-
const stripePromise = (0,
|
|
3577
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard }) });
|
|
4017
|
+
var StripeWrapper = ({ onCancel, saveNewCard, publicKey, showCancel }) => {
|
|
4018
|
+
const stripePromise = (0, import_react11.useMemo)(() => (0, import_stripe_js.loadStripe)(publicKey), [publicKey]);
|
|
4019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard, showCancel }) });
|
|
3578
4020
|
};
|
|
3579
4021
|
var CreditCard = ({ newCards, setNewCards }) => {
|
|
3580
|
-
const [showForm, setShowForm] = (0,
|
|
4022
|
+
const [showForm, setShowForm] = (0, import_react11.useState)(false);
|
|
3581
4023
|
const isLoggedIn = useIsLoggedIn();
|
|
3582
4024
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
3583
4025
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4026
|
+
const { cards, cardsIsLoading } = useCards();
|
|
4027
|
+
const canUseForm = isLoggedIn && Boolean(spreePayConfig?.stripePublicKey);
|
|
4028
|
+
const hasCards = cards.length + newCards.length > 0;
|
|
4029
|
+
const formVisible = canUseForm && (showForm || !hasCards && !cardsIsLoading);
|
|
4030
|
+
const didAutoSelect = (0, import_react11.useRef)(false);
|
|
4031
|
+
(0, import_react11.useEffect)(() => {
|
|
4032
|
+
if (!isLoggedIn) {
|
|
4033
|
+
didAutoSelect.current = false;
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
if (didAutoSelect.current || cardsIsLoading) return;
|
|
4037
|
+
didAutoSelect.current = true;
|
|
4038
|
+
const alreadySelected = selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && Boolean(selectedPaymentMethod.method);
|
|
4039
|
+
if (!alreadySelected && cards.length > 0) {
|
|
4040
|
+
setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: cards[0] });
|
|
4041
|
+
}
|
|
4042
|
+
}, [isLoggedIn, cardsIsLoading, cards, selectedPaymentMethod, setSelectedPaymentMethod]);
|
|
3584
4043
|
const setCard = (card) => {
|
|
3585
4044
|
const isAlreadySelected = selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method?.id === card.id;
|
|
3586
4045
|
setSelectedPaymentMethod({
|
|
@@ -3594,7 +4053,7 @@ var CreditCard = ({ newCards, setNewCards }) => {
|
|
|
3594
4053
|
setCard(newCard);
|
|
3595
4054
|
setShowForm(false);
|
|
3596
4055
|
};
|
|
3597
|
-
const removeNewCard = (0,
|
|
4056
|
+
const removeNewCard = (0, import_react11.useCallback)(
|
|
3598
4057
|
(card) => {
|
|
3599
4058
|
setNewCards((prev) => prev.filter((c) => c.id !== card.id));
|
|
3600
4059
|
},
|
|
@@ -3613,7 +4072,7 @@ var CreditCard = ({ newCards, setNewCards }) => {
|
|
|
3613
4072
|
};
|
|
3614
4073
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
3615
4074
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h3", { className: "text-[22px] leading-9 font-medium text-(--brand-primary)", children: "Your Cards" }),
|
|
3616
|
-
!
|
|
4075
|
+
!formVisible && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
3617
4076
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3618
4077
|
CardsList,
|
|
3619
4078
|
{
|
|
@@ -3628,26 +4087,35 @@ var CreditCard = ({ newCards, setNewCards }) => {
|
|
|
3628
4087
|
"button",
|
|
3629
4088
|
{
|
|
3630
4089
|
onClick: handleAddNewCard,
|
|
3631
|
-
disabled: !
|
|
4090
|
+
disabled: !canUseForm,
|
|
3632
4091
|
className: "text-md text-(--brand-primary) hover:underline disabled:cursor-not-allowed disabled:no-underline disabled:opacity-50",
|
|
3633
4092
|
children: "Add new card"
|
|
3634
4093
|
}
|
|
3635
4094
|
)
|
|
3636
4095
|
] }),
|
|
3637
|
-
|
|
4096
|
+
formVisible && spreePayConfig?.stripePublicKey && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4097
|
+
StripeWrapper,
|
|
4098
|
+
{
|
|
4099
|
+
onCancel: handleCancel,
|
|
4100
|
+
saveNewCard,
|
|
4101
|
+
publicKey: spreePayConfig.stripePublicKey,
|
|
4102
|
+
showCancel: hasCards
|
|
4103
|
+
}
|
|
4104
|
+
)
|
|
3638
4105
|
] });
|
|
3639
4106
|
};
|
|
3640
4107
|
|
|
3641
4108
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
3642
|
-
var
|
|
4109
|
+
var import_react16 = require("react");
|
|
3643
4110
|
init_LoginStatusContext();
|
|
3644
4111
|
init_SpreePayActionsContext();
|
|
3645
4112
|
init_StaticConfigContext();
|
|
4113
|
+
init_useSlapiBalance();
|
|
3646
4114
|
init_useSpreePayConfig();
|
|
3647
4115
|
init_common();
|
|
3648
4116
|
|
|
3649
4117
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
3650
|
-
var
|
|
4118
|
+
var import_react15 = require("react");
|
|
3651
4119
|
var import_airkit2 = require("@mocanetwork/airkit");
|
|
3652
4120
|
init_SpreePayActionsContext();
|
|
3653
4121
|
init_StaticConfigContext();
|
|
@@ -3657,7 +4125,7 @@ init_format();
|
|
|
3657
4125
|
init_logger();
|
|
3658
4126
|
|
|
3659
4127
|
// src/components/CreditCardTab/Points/PointsSelector.tsx
|
|
3660
|
-
var
|
|
4128
|
+
var import_react14 = require("react");
|
|
3661
4129
|
init_SpreePayActionsContext();
|
|
3662
4130
|
init_StaticConfigContext();
|
|
3663
4131
|
init_useSlapiBalance();
|
|
@@ -3685,10 +4153,10 @@ function Input({ className, type, ...props }) {
|
|
|
3685
4153
|
}
|
|
3686
4154
|
|
|
3687
4155
|
// src/ui/slider.tsx
|
|
3688
|
-
var
|
|
4156
|
+
var React13 = __toESM(require("react"), 1);
|
|
3689
4157
|
|
|
3690
4158
|
// ../../node_modules/@radix-ui/react-slider/dist/index.mjs
|
|
3691
|
-
var
|
|
4159
|
+
var React12 = __toESM(require("react"), 1);
|
|
3692
4160
|
|
|
3693
4161
|
// ../../node_modules/@radix-ui/number/dist/index.mjs
|
|
3694
4162
|
function clamp(value, [min, max]) {
|
|
@@ -3707,7 +4175,7 @@ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForD
|
|
|
3707
4175
|
}
|
|
3708
4176
|
|
|
3709
4177
|
// ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
3710
|
-
var
|
|
4178
|
+
var React3 = __toESM(require("react"), 1);
|
|
3711
4179
|
function setRef(ref, value) {
|
|
3712
4180
|
if (typeof ref === "function") {
|
|
3713
4181
|
return ref(value);
|
|
@@ -3740,41 +4208,41 @@ function composeRefs(...refs) {
|
|
|
3740
4208
|
};
|
|
3741
4209
|
}
|
|
3742
4210
|
function useComposedRefs(...refs) {
|
|
3743
|
-
return
|
|
4211
|
+
return React3.useCallback(composeRefs(...refs), refs);
|
|
3744
4212
|
}
|
|
3745
4213
|
|
|
3746
4214
|
// ../../node_modules/@radix-ui/react-context/dist/index.mjs
|
|
3747
|
-
var
|
|
4215
|
+
var React4 = __toESM(require("react"), 1);
|
|
3748
4216
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3749
4217
|
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
3750
4218
|
let defaultContexts = [];
|
|
3751
4219
|
function createContext32(rootComponentName, defaultContext) {
|
|
3752
|
-
const BaseContext =
|
|
4220
|
+
const BaseContext = React4.createContext(defaultContext);
|
|
3753
4221
|
const index = defaultContexts.length;
|
|
3754
4222
|
defaultContexts = [...defaultContexts, defaultContext];
|
|
3755
|
-
const
|
|
4223
|
+
const Provider2 = (props) => {
|
|
3756
4224
|
const { scope, children, ...context } = props;
|
|
3757
4225
|
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
3758
|
-
const value =
|
|
4226
|
+
const value = React4.useMemo(() => context, Object.values(context));
|
|
3759
4227
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Context.Provider, { value, children });
|
|
3760
4228
|
};
|
|
3761
|
-
|
|
4229
|
+
Provider2.displayName = rootComponentName + "Provider";
|
|
3762
4230
|
function useContext22(consumerName, scope) {
|
|
3763
4231
|
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
3764
|
-
const context =
|
|
4232
|
+
const context = React4.useContext(Context);
|
|
3765
4233
|
if (context) return context;
|
|
3766
4234
|
if (defaultContext !== void 0) return defaultContext;
|
|
3767
4235
|
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
3768
4236
|
}
|
|
3769
|
-
return [
|
|
4237
|
+
return [Provider2, useContext22];
|
|
3770
4238
|
}
|
|
3771
4239
|
const createScope = () => {
|
|
3772
4240
|
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
3773
|
-
return
|
|
4241
|
+
return React4.createContext(defaultContext);
|
|
3774
4242
|
});
|
|
3775
4243
|
return function useScope(scope) {
|
|
3776
4244
|
const contexts = scope?.[scopeName] || scopeContexts;
|
|
3777
|
-
return
|
|
4245
|
+
return React4.useMemo(
|
|
3778
4246
|
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
3779
4247
|
[scope, contexts]
|
|
3780
4248
|
);
|
|
@@ -3797,7 +4265,7 @@ function composeContextScopes(...scopes) {
|
|
|
3797
4265
|
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
3798
4266
|
return { ...nextScopes2, ...currentScope };
|
|
3799
4267
|
}, {});
|
|
3800
|
-
return
|
|
4268
|
+
return React4.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
3801
4269
|
};
|
|
3802
4270
|
};
|
|
3803
4271
|
createScope.scopeName = baseScope.scopeName;
|
|
@@ -3805,16 +4273,16 @@ function composeContextScopes(...scopes) {
|
|
|
3805
4273
|
}
|
|
3806
4274
|
|
|
3807
4275
|
// ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
3808
|
-
var
|
|
4276
|
+
var React6 = __toESM(require("react"), 1);
|
|
3809
4277
|
|
|
3810
4278
|
// ../../node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
3811
|
-
var
|
|
3812
|
-
var useLayoutEffect2 = globalThis?.document ?
|
|
4279
|
+
var React5 = __toESM(require("react"), 1);
|
|
4280
|
+
var useLayoutEffect2 = globalThis?.document ? React5.useLayoutEffect : () => {
|
|
3813
4281
|
};
|
|
3814
4282
|
|
|
3815
4283
|
// ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
3816
4284
|
var React22 = __toESM(require("react"), 1);
|
|
3817
|
-
var useInsertionEffect =
|
|
4285
|
+
var useInsertionEffect = React6[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
3818
4286
|
function useControllableState({
|
|
3819
4287
|
prop,
|
|
3820
4288
|
defaultProp,
|
|
@@ -3829,8 +4297,8 @@ function useControllableState({
|
|
|
3829
4297
|
const isControlled = prop !== void 0;
|
|
3830
4298
|
const value = isControlled ? prop : uncontrolledProp;
|
|
3831
4299
|
if (true) {
|
|
3832
|
-
const isControlledRef =
|
|
3833
|
-
|
|
4300
|
+
const isControlledRef = React6.useRef(prop !== void 0);
|
|
4301
|
+
React6.useEffect(() => {
|
|
3834
4302
|
const wasControlled = isControlledRef.current;
|
|
3835
4303
|
if (wasControlled !== isControlled) {
|
|
3836
4304
|
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
@@ -3842,7 +4310,7 @@ function useControllableState({
|
|
|
3842
4310
|
isControlledRef.current = isControlled;
|
|
3843
4311
|
}, [isControlled, caller]);
|
|
3844
4312
|
}
|
|
3845
|
-
const setValue =
|
|
4313
|
+
const setValue = React6.useCallback(
|
|
3846
4314
|
(nextValue) => {
|
|
3847
4315
|
if (isControlled) {
|
|
3848
4316
|
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
@@ -3861,13 +4329,13 @@ function useUncontrolledState({
|
|
|
3861
4329
|
defaultProp,
|
|
3862
4330
|
onChange
|
|
3863
4331
|
}) {
|
|
3864
|
-
const [value, setValue] =
|
|
3865
|
-
const prevValueRef =
|
|
3866
|
-
const onChangeRef =
|
|
4332
|
+
const [value, setValue] = React6.useState(defaultProp);
|
|
4333
|
+
const prevValueRef = React6.useRef(value);
|
|
4334
|
+
const onChangeRef = React6.useRef(onChange);
|
|
3867
4335
|
useInsertionEffect(() => {
|
|
3868
4336
|
onChangeRef.current = onChange;
|
|
3869
4337
|
}, [onChange]);
|
|
3870
|
-
|
|
4338
|
+
React6.useEffect(() => {
|
|
3871
4339
|
if (prevValueRef.current !== value) {
|
|
3872
4340
|
onChangeRef.current?.(value);
|
|
3873
4341
|
prevValueRef.current = value;
|
|
@@ -3880,19 +4348,19 @@ function isFunction(value) {
|
|
|
3880
4348
|
}
|
|
3881
4349
|
|
|
3882
4350
|
// ../../node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
3883
|
-
var
|
|
4351
|
+
var React7 = __toESM(require("react"), 1);
|
|
3884
4352
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3885
|
-
var DirectionContext =
|
|
4353
|
+
var DirectionContext = React7.createContext(void 0);
|
|
3886
4354
|
function useDirection(localDir) {
|
|
3887
|
-
const globalDir =
|
|
4355
|
+
const globalDir = React7.useContext(DirectionContext);
|
|
3888
4356
|
return localDir || globalDir || "ltr";
|
|
3889
4357
|
}
|
|
3890
4358
|
|
|
3891
4359
|
// ../../node_modules/@radix-ui/react-use-previous/dist/index.mjs
|
|
3892
|
-
var
|
|
4360
|
+
var React8 = __toESM(require("react"), 1);
|
|
3893
4361
|
function usePrevious(value) {
|
|
3894
|
-
const ref =
|
|
3895
|
-
return
|
|
4362
|
+
const ref = React8.useRef({ value, previous: value });
|
|
4363
|
+
return React8.useMemo(() => {
|
|
3896
4364
|
if (ref.current.value !== value) {
|
|
3897
4365
|
ref.current.previous = ref.current.value;
|
|
3898
4366
|
ref.current.value = value;
|
|
@@ -3902,9 +4370,9 @@ function usePrevious(value) {
|
|
|
3902
4370
|
}
|
|
3903
4371
|
|
|
3904
4372
|
// ../../node_modules/@radix-ui/react-use-size/dist/index.mjs
|
|
3905
|
-
var
|
|
4373
|
+
var React9 = __toESM(require("react"), 1);
|
|
3906
4374
|
function useSize(element) {
|
|
3907
|
-
const [size, setSize] =
|
|
4375
|
+
const [size, setSize] = React9.useState(void 0);
|
|
3908
4376
|
useLayoutEffect2(() => {
|
|
3909
4377
|
if (element) {
|
|
3910
4378
|
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
@@ -3939,7 +4407,7 @@ function useSize(element) {
|
|
|
3939
4407
|
}
|
|
3940
4408
|
|
|
3941
4409
|
// ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
3942
|
-
var
|
|
4410
|
+
var React10 = __toESM(require("react"), 1);
|
|
3943
4411
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
3944
4412
|
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
3945
4413
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -3964,7 +4432,7 @@ var NODES = [
|
|
|
3964
4432
|
];
|
|
3965
4433
|
var Primitive = NODES.reduce((primitive, node) => {
|
|
3966
4434
|
const Slot2 = (0, import_react_slot2.createSlot)(`Primitive.${node}`);
|
|
3967
|
-
const Node2 =
|
|
4435
|
+
const Node2 = React10.forwardRef((props, forwardedRef) => {
|
|
3968
4436
|
const { asChild, ...primitiveProps } = props;
|
|
3969
4437
|
const Comp = asChild ? Slot2 : node;
|
|
3970
4438
|
if (typeof window !== "undefined") {
|
|
@@ -3977,10 +4445,10 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
3977
4445
|
}, {});
|
|
3978
4446
|
|
|
3979
4447
|
// ../../node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
3980
|
-
var
|
|
4448
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
3981
4449
|
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
3982
4450
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3983
|
-
var
|
|
4451
|
+
var import_react13 = __toESM(require("react"), 1);
|
|
3984
4452
|
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
3985
4453
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3986
4454
|
function createCollection(name) {
|
|
@@ -3992,14 +4460,14 @@ function createCollection(name) {
|
|
|
3992
4460
|
);
|
|
3993
4461
|
const CollectionProvider = (props) => {
|
|
3994
4462
|
const { scope, children } = props;
|
|
3995
|
-
const ref =
|
|
3996
|
-
const itemMap =
|
|
4463
|
+
const ref = import_react12.default.useRef(null);
|
|
4464
|
+
const itemMap = import_react12.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
3997
4465
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
3998
4466
|
};
|
|
3999
4467
|
CollectionProvider.displayName = PROVIDER_NAME;
|
|
4000
4468
|
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
4001
4469
|
const CollectionSlotImpl = (0, import_react_slot3.createSlot)(COLLECTION_SLOT_NAME);
|
|
4002
|
-
const CollectionSlot =
|
|
4470
|
+
const CollectionSlot = import_react12.default.forwardRef(
|
|
4003
4471
|
(props, forwardedRef) => {
|
|
4004
4472
|
const { scope, children } = props;
|
|
4005
4473
|
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
@@ -4011,13 +4479,13 @@ function createCollection(name) {
|
|
|
4011
4479
|
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
4012
4480
|
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
4013
4481
|
const CollectionItemSlotImpl = (0, import_react_slot3.createSlot)(ITEM_SLOT_NAME);
|
|
4014
|
-
const CollectionItemSlot =
|
|
4482
|
+
const CollectionItemSlot = import_react12.default.forwardRef(
|
|
4015
4483
|
(props, forwardedRef) => {
|
|
4016
4484
|
const { scope, children, ...itemData } = props;
|
|
4017
|
-
const ref =
|
|
4485
|
+
const ref = import_react12.default.useRef(null);
|
|
4018
4486
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
4019
4487
|
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
4020
|
-
|
|
4488
|
+
import_react12.default.useEffect(() => {
|
|
4021
4489
|
context.itemMap.set(ref, { ref, ...itemData });
|
|
4022
4490
|
return () => void context.itemMap.delete(ref);
|
|
4023
4491
|
});
|
|
@@ -4027,7 +4495,7 @@ function createCollection(name) {
|
|
|
4027
4495
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
4028
4496
|
function useCollection2(scope) {
|
|
4029
4497
|
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
4030
|
-
const getItems =
|
|
4498
|
+
const getItems = import_react12.default.useCallback(() => {
|
|
4031
4499
|
const collectionNode = context.collectionRef.current;
|
|
4032
4500
|
if (!collectionNode) return [];
|
|
4033
4501
|
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
@@ -4062,7 +4530,7 @@ var [createSliderContext, createSliderScope] = createContextScope(SLIDER_NAME, [
|
|
|
4062
4530
|
createCollectionScope
|
|
4063
4531
|
]);
|
|
4064
4532
|
var [SliderProvider, useSliderContext] = createSliderContext(SLIDER_NAME);
|
|
4065
|
-
var Slider =
|
|
4533
|
+
var Slider = React12.forwardRef(
|
|
4066
4534
|
(props, forwardedRef) => {
|
|
4067
4535
|
const {
|
|
4068
4536
|
name,
|
|
@@ -4082,8 +4550,8 @@ var Slider = React11.forwardRef(
|
|
|
4082
4550
|
form,
|
|
4083
4551
|
...sliderProps
|
|
4084
4552
|
} = props;
|
|
4085
|
-
const thumbRefs =
|
|
4086
|
-
const valueIndexToChangeRef =
|
|
4553
|
+
const thumbRefs = React12.useRef(/* @__PURE__ */ new Set());
|
|
4554
|
+
const valueIndexToChangeRef = React12.useRef(0);
|
|
4087
4555
|
const isHorizontal = orientation === "horizontal";
|
|
4088
4556
|
const SliderOrientation = isHorizontal ? SliderHorizontal : SliderVertical;
|
|
4089
4557
|
const [values = [], setValues] = useControllableState({
|
|
@@ -4095,7 +4563,7 @@ var Slider = React11.forwardRef(
|
|
|
4095
4563
|
onValueChange(value2);
|
|
4096
4564
|
}
|
|
4097
4565
|
});
|
|
4098
|
-
const valuesBeforeSlideStartRef =
|
|
4566
|
+
const valuesBeforeSlideStartRef = React12.useRef(values);
|
|
4099
4567
|
function handleSlideStart(value2) {
|
|
4100
4568
|
const closestIndex = getClosestValueIndex(values, value2);
|
|
4101
4569
|
updateValues(value2, closestIndex);
|
|
@@ -4180,7 +4648,7 @@ var [SliderOrientationProvider, useSliderOrientationContext] = createSliderConte
|
|
|
4180
4648
|
size: "width",
|
|
4181
4649
|
direction: 1
|
|
4182
4650
|
});
|
|
4183
|
-
var SliderHorizontal =
|
|
4651
|
+
var SliderHorizontal = React12.forwardRef(
|
|
4184
4652
|
(props, forwardedRef) => {
|
|
4185
4653
|
const {
|
|
4186
4654
|
min,
|
|
@@ -4193,9 +4661,9 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
4193
4661
|
onStepKeyDown,
|
|
4194
4662
|
...sliderProps
|
|
4195
4663
|
} = props;
|
|
4196
|
-
const [slider, setSlider] =
|
|
4664
|
+
const [slider, setSlider] = React12.useState(null);
|
|
4197
4665
|
const composedRefs = useComposedRefs(forwardedRef, (node) => setSlider(node));
|
|
4198
|
-
const rectRef =
|
|
4666
|
+
const rectRef = React12.useRef(void 0);
|
|
4199
4667
|
const direction = useDirection(dir);
|
|
4200
4668
|
const isDirectionLTR = direction === "ltr";
|
|
4201
4669
|
const isSlidingFromLeft = isDirectionLTR && !inverted || !isDirectionLTR && inverted;
|
|
@@ -4249,7 +4717,7 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
4249
4717
|
);
|
|
4250
4718
|
}
|
|
4251
4719
|
);
|
|
4252
|
-
var SliderVertical =
|
|
4720
|
+
var SliderVertical = React12.forwardRef(
|
|
4253
4721
|
(props, forwardedRef) => {
|
|
4254
4722
|
const {
|
|
4255
4723
|
min,
|
|
@@ -4261,9 +4729,9 @@ var SliderVertical = React11.forwardRef(
|
|
|
4261
4729
|
onStepKeyDown,
|
|
4262
4730
|
...sliderProps
|
|
4263
4731
|
} = props;
|
|
4264
|
-
const sliderRef =
|
|
4732
|
+
const sliderRef = React12.useRef(null);
|
|
4265
4733
|
const ref = useComposedRefs(forwardedRef, sliderRef);
|
|
4266
|
-
const rectRef =
|
|
4734
|
+
const rectRef = React12.useRef(void 0);
|
|
4267
4735
|
const isSlidingFromBottom = !inverted;
|
|
4268
4736
|
function getValueFromPointer(pointerPosition) {
|
|
4269
4737
|
const rect = rectRef.current || sliderRef.current.getBoundingClientRect();
|
|
@@ -4314,7 +4782,7 @@ var SliderVertical = React11.forwardRef(
|
|
|
4314
4782
|
);
|
|
4315
4783
|
}
|
|
4316
4784
|
);
|
|
4317
|
-
var SliderImpl =
|
|
4785
|
+
var SliderImpl = React12.forwardRef(
|
|
4318
4786
|
(props, forwardedRef) => {
|
|
4319
4787
|
const {
|
|
4320
4788
|
__scopeSlider,
|
|
@@ -4370,7 +4838,7 @@ var SliderImpl = React11.forwardRef(
|
|
|
4370
4838
|
}
|
|
4371
4839
|
);
|
|
4372
4840
|
var TRACK_NAME = "SliderTrack";
|
|
4373
|
-
var SliderTrack =
|
|
4841
|
+
var SliderTrack = React12.forwardRef(
|
|
4374
4842
|
(props, forwardedRef) => {
|
|
4375
4843
|
const { __scopeSlider, ...trackProps } = props;
|
|
4376
4844
|
const context = useSliderContext(TRACK_NAME, __scopeSlider);
|
|
@@ -4387,12 +4855,12 @@ var SliderTrack = React11.forwardRef(
|
|
|
4387
4855
|
);
|
|
4388
4856
|
SliderTrack.displayName = TRACK_NAME;
|
|
4389
4857
|
var RANGE_NAME = "SliderRange";
|
|
4390
|
-
var SliderRange =
|
|
4858
|
+
var SliderRange = React12.forwardRef(
|
|
4391
4859
|
(props, forwardedRef) => {
|
|
4392
4860
|
const { __scopeSlider, ...rangeProps } = props;
|
|
4393
4861
|
const context = useSliderContext(RANGE_NAME, __scopeSlider);
|
|
4394
4862
|
const orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider);
|
|
4395
|
-
const ref =
|
|
4863
|
+
const ref = React12.useRef(null);
|
|
4396
4864
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
4397
4865
|
const valuesCount = context.values.length;
|
|
4398
4866
|
const percentages = context.values.map(
|
|
@@ -4418,24 +4886,24 @@ var SliderRange = React11.forwardRef(
|
|
|
4418
4886
|
);
|
|
4419
4887
|
SliderRange.displayName = RANGE_NAME;
|
|
4420
4888
|
var THUMB_NAME = "SliderThumb";
|
|
4421
|
-
var SliderThumb =
|
|
4889
|
+
var SliderThumb = React12.forwardRef(
|
|
4422
4890
|
(props, forwardedRef) => {
|
|
4423
4891
|
const getItems = useCollection(props.__scopeSlider);
|
|
4424
|
-
const [thumb, setThumb] =
|
|
4892
|
+
const [thumb, setThumb] = React12.useState(null);
|
|
4425
4893
|
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
|
|
4426
|
-
const index =
|
|
4894
|
+
const index = React12.useMemo(
|
|
4427
4895
|
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
|
|
4428
4896
|
[getItems, thumb]
|
|
4429
4897
|
);
|
|
4430
4898
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index });
|
|
4431
4899
|
}
|
|
4432
4900
|
);
|
|
4433
|
-
var SliderThumbImpl =
|
|
4901
|
+
var SliderThumbImpl = React12.forwardRef(
|
|
4434
4902
|
(props, forwardedRef) => {
|
|
4435
4903
|
const { __scopeSlider, index, name, ...thumbProps } = props;
|
|
4436
4904
|
const context = useSliderContext(THUMB_NAME, __scopeSlider);
|
|
4437
4905
|
const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider);
|
|
4438
|
-
const [thumb, setThumb] =
|
|
4906
|
+
const [thumb, setThumb] = React12.useState(null);
|
|
4439
4907
|
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
|
|
4440
4908
|
const isFormControl = thumb ? context.form || !!thumb.closest("form") : true;
|
|
4441
4909
|
const size = useSize(thumb);
|
|
@@ -4444,7 +4912,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
4444
4912
|
const label = getLabel(index, context.values.length);
|
|
4445
4913
|
const orientationSize = size?.[orientation.size];
|
|
4446
4914
|
const thumbInBoundsOffset = orientationSize ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0;
|
|
4447
|
-
|
|
4915
|
+
React12.useEffect(() => {
|
|
4448
4916
|
if (thumb) {
|
|
4449
4917
|
context.thumbs.add(thumb);
|
|
4450
4918
|
return () => {
|
|
@@ -4497,12 +4965,12 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
4497
4965
|
);
|
|
4498
4966
|
SliderThumb.displayName = THUMB_NAME;
|
|
4499
4967
|
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
|
|
4500
|
-
var SliderBubbleInput =
|
|
4968
|
+
var SliderBubbleInput = React12.forwardRef(
|
|
4501
4969
|
({ __scopeSlider, value, ...props }, forwardedRef) => {
|
|
4502
|
-
const ref =
|
|
4970
|
+
const ref = React12.useRef(null);
|
|
4503
4971
|
const composedRefs = useComposedRefs(ref, forwardedRef);
|
|
4504
4972
|
const prevValue = usePrevious(value);
|
|
4505
|
-
|
|
4973
|
+
React12.useEffect(() => {
|
|
4506
4974
|
const input = ref.current;
|
|
4507
4975
|
if (!input) return;
|
|
4508
4976
|
const inputProto = window.HTMLInputElement.prototype;
|
|
@@ -4593,7 +5061,7 @@ init_utils2();
|
|
|
4593
5061
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4594
5062
|
function Slider2(props) {
|
|
4595
5063
|
const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
|
|
4596
|
-
const _values =
|
|
5064
|
+
const _values = React13.useMemo(
|
|
4597
5065
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
4598
5066
|
[value, defaultValue, min, max]
|
|
4599
5067
|
);
|
|
@@ -4660,7 +5128,7 @@ var PointsSelector = (props) => {
|
|
|
4660
5128
|
const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (amount ?? 0) / pointsConversionRatio : 0;
|
|
4661
5129
|
const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
|
|
4662
5130
|
const step = 10;
|
|
4663
|
-
const [splitTokens, setSplitTokens] = (0,
|
|
5131
|
+
const [splitTokens, setSplitTokens] = (0, import_react14.useState)(0);
|
|
4664
5132
|
const usdAmount = getSplitAmount(amount ?? 0, splitTokens, pointsConversionRatio);
|
|
4665
5133
|
const pointsValue = String(Math.round(splitTokens));
|
|
4666
5134
|
const usdWithFee = usdAmount + getTransactionFee(usdAmount, transactionFeePercentage);
|
|
@@ -4721,8 +5189,10 @@ var PointsSelector = (props) => {
|
|
|
4721
5189
|
Slider2,
|
|
4722
5190
|
{
|
|
4723
5191
|
value: [splitTokens],
|
|
4724
|
-
|
|
4725
|
-
|
|
5192
|
+
onValueChange: ([v]) => {
|
|
5193
|
+
setSplitTokens(v);
|
|
5194
|
+
handleCommit(v);
|
|
5195
|
+
},
|
|
4726
5196
|
onPointerDown: (e) => e.stopPropagation(),
|
|
4727
5197
|
min,
|
|
4728
5198
|
max,
|
|
@@ -4758,14 +5228,14 @@ var SplitBlock = (props) => {
|
|
|
4758
5228
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4759
5229
|
const { appProps } = useStaticConfig();
|
|
4760
5230
|
const { currencyCode, exchangeRate, foreignCurrencyAmount } = appProps;
|
|
4761
|
-
const [address, setAddress] = (0,
|
|
4762
|
-
const [walletReady, setWalletReady] = (0,
|
|
5231
|
+
const [address, setAddress] = (0, import_react15.useState)(null);
|
|
5232
|
+
const [walletReady, setWalletReady] = (0, import_react15.useState)(false);
|
|
4763
5233
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
4764
5234
|
const { useWeb3Points, environment } = useSpreePayEnv();
|
|
4765
5235
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
4766
5236
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
4767
|
-
const prevPointsChainRef = (0,
|
|
4768
|
-
const initWallet = (0,
|
|
5237
|
+
const prevPointsChainRef = (0, import_react15.useRef)(spreePayConfig?.pointsChain);
|
|
5238
|
+
const initWallet = (0, import_react15.useCallback)(
|
|
4769
5239
|
async (pointsChain) => {
|
|
4770
5240
|
if (!pointsChain) return;
|
|
4771
5241
|
try {
|
|
@@ -4788,7 +5258,7 @@ var SplitBlock = (props) => {
|
|
|
4788
5258
|
},
|
|
4789
5259
|
[onToggle, environment]
|
|
4790
5260
|
);
|
|
4791
|
-
(0,
|
|
5261
|
+
(0, import_react15.useEffect)(() => {
|
|
4792
5262
|
if (!useWeb3Points) return;
|
|
4793
5263
|
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
4794
5264
|
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
@@ -4819,11 +5289,24 @@ var SplitBlock = (props) => {
|
|
|
4819
5289
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4820
5290
|
var Points = () => {
|
|
4821
5291
|
const isLoggedIn = useIsLoggedIn();
|
|
4822
|
-
const [usePoints, setUsePoints] = (0,
|
|
4823
|
-
const [selectedPointsType, setSelectedPointsType] = (0,
|
|
5292
|
+
const [usePoints, setUsePoints] = (0, import_react16.useState)(false);
|
|
5293
|
+
const [selectedPointsType, setSelectedPointsType] = (0, import_react16.useState)(null);
|
|
4824
5294
|
const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
|
|
4825
|
-
const { spreePayConfig } = useSpreePayConfig();
|
|
5295
|
+
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
4826
5296
|
const { appProps } = useStaticConfig();
|
|
5297
|
+
const { balance } = useSlapiBalance();
|
|
5298
|
+
const { useWeb3Points } = useSpreePayEnv();
|
|
5299
|
+
const pointsDisabled = !isLoggedIn || !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints;
|
|
5300
|
+
const [didInit, setDidInit] = (0, import_react16.useState)(false);
|
|
5301
|
+
if (!isLoggedIn) {
|
|
5302
|
+
if (didInit) setDidInit(false);
|
|
5303
|
+
} else if (!didInit && balance !== void 0 && !configIsLoading) {
|
|
5304
|
+
setDidInit(true);
|
|
5305
|
+
if (!useWeb3Points && !pointsDisabled && balance.availablePoints > 0) {
|
|
5306
|
+
setUsePoints(true);
|
|
5307
|
+
setSelectedPointsType("air");
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
4827
5310
|
const handleTogglePoints = (enabled) => {
|
|
4828
5311
|
setUsePoints(enabled);
|
|
4829
5312
|
if (!enabled) {
|
|
@@ -4838,7 +5321,7 @@ var Points = () => {
|
|
|
4838
5321
|
value: usePoints,
|
|
4839
5322
|
onChange: handleTogglePoints,
|
|
4840
5323
|
message: spreePayConfig?.creditCard.pointsInfoMessage,
|
|
4841
|
-
disabled:
|
|
5324
|
+
disabled: pointsDisabled
|
|
4842
5325
|
}
|
|
4843
5326
|
),
|
|
4844
5327
|
usePoints && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
@@ -4859,15 +5342,15 @@ var CreditCardTab = () => {
|
|
|
4859
5342
|
const { useWeb3Points } = useSpreePayEnv();
|
|
4860
5343
|
const { appProps } = useStaticConfig();
|
|
4861
5344
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4862
|
-
const { register } = useSpreePayRegister();
|
|
5345
|
+
const { register: register2 } = useSpreePayRegister();
|
|
4863
5346
|
const { cards, mutateCards } = useCards();
|
|
4864
5347
|
const { mutateBalance } = useSlapiBalance();
|
|
4865
|
-
const [newCards, setNewCards] = (0,
|
|
5348
|
+
const [newCards, setNewCards] = (0, import_react17.useState)([]);
|
|
4866
5349
|
const isWeb3Enabled = Boolean(useWeb3Points);
|
|
4867
5350
|
const { cardPayment } = useCardPayment();
|
|
4868
5351
|
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
4869
5352
|
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
4870
|
-
const handlePay = (0,
|
|
5353
|
+
const handlePay = (0, import_react17.useCallback)(
|
|
4871
5354
|
async (data) => {
|
|
4872
5355
|
const pointsAmount = selectedPaymentMethod.pointsAmount ?? 0;
|
|
4873
5356
|
const usdAmount = getSplitAmount(appProps.amount ?? 0, pointsAmount, spreePayConfig?.pointsConversionRatio);
|
|
@@ -4916,9 +5399,9 @@ var CreditCardTab = () => {
|
|
|
4916
5399
|
mutateBalance
|
|
4917
5400
|
]
|
|
4918
5401
|
);
|
|
4919
|
-
(0,
|
|
4920
|
-
|
|
4921
|
-
}, [
|
|
5402
|
+
(0, import_react17.useEffect)(() => {
|
|
5403
|
+
register2(handlePay);
|
|
5404
|
+
}, [register2, handlePay]);
|
|
4922
5405
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { children: [
|
|
4923
5406
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CreditCard, { newCards, setNewCards }) }),
|
|
4924
5407
|
!spreePayConfig?.creditCard.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Points, {}) }),
|
|
@@ -4948,12 +5431,13 @@ var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
|
|
|
4948
5431
|
};
|
|
4949
5432
|
var TabButtons = (props) => {
|
|
4950
5433
|
const { value, onChange } = props;
|
|
4951
|
-
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
5434
|
+
const { spreePayConfig, configIsLoading, configError } = useSpreePayConfig();
|
|
4952
5435
|
const handleChange = (type) => () => {
|
|
4953
5436
|
if (value !== type) {
|
|
4954
5437
|
onChange({ type, method: null });
|
|
4955
5438
|
}
|
|
4956
5439
|
};
|
|
5440
|
+
if (configError) return null;
|
|
4957
5441
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full gap-4 overflow-x-auto px-5 py-2 md:px-7", children: [
|
|
4958
5442
|
configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "h-[74px] w-[180px] animate-pulse rounded-md bg-(--s-primary)" }),
|
|
4959
5443
|
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
|
|
@@ -5001,9 +5485,11 @@ var TabButtons = (props) => {
|
|
|
5001
5485
|
// src/SpreePayContent.tsx
|
|
5002
5486
|
init_LoginStatusContext();
|
|
5003
5487
|
init_SpreePayActionsContext();
|
|
5488
|
+
init_useSpreePayConfig();
|
|
5489
|
+
init_utils();
|
|
5004
5490
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5005
|
-
var CryptoTab2 = (0,
|
|
5006
|
-
var CryptoComTab2 = (0,
|
|
5491
|
+
var CryptoTab2 = (0, import_react22.lazy)(() => Promise.resolve().then(() => (init_CryptoTab2(), CryptoTab_exports)).then((module2) => ({ default: module2.CryptoTab })));
|
|
5492
|
+
var CryptoComTab2 = (0, import_react22.lazy)(
|
|
5007
5493
|
() => Promise.resolve().then(() => (init_CryptoComTab2(), CryptoComTab_exports)).then((module2) => ({ default: module2.CryptoComTab }))
|
|
5008
5494
|
);
|
|
5009
5495
|
var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
@@ -5013,30 +5499,44 @@ var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("di
|
|
|
5013
5499
|
var SpreePayContent = () => {
|
|
5014
5500
|
const isLoggedIn = useIsLoggedIn();
|
|
5015
5501
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
5016
|
-
|
|
5502
|
+
const { configError } = useSpreePayConfig();
|
|
5503
|
+
(0, import_react22.useEffect)(() => {
|
|
5017
5504
|
if (!isLoggedIn) {
|
|
5018
5505
|
setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
5019
5506
|
}
|
|
5020
5507
|
}, [isLoggedIn, setSelectedPaymentMethod]);
|
|
5021
|
-
return
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5508
|
+
return (
|
|
5509
|
+
// Config failed: inert disables the whole widget and drops it from tab order + a11y.
|
|
5510
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
5511
|
+
"div",
|
|
5512
|
+
{
|
|
5513
|
+
inert: !!configError,
|
|
5514
|
+
className: cn(
|
|
5515
|
+
"w-full overflow-hidden rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]",
|
|
5516
|
+
configError && "opacity-75"
|
|
5517
|
+
),
|
|
5518
|
+
children: [
|
|
5519
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col gap-2 border-b border-b-(--border-component-specific-card) pt-5 pb-3 md:pt-6 md:pb-5", children: [
|
|
5520
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { className: "px-5 text-[28px] leading-8 font-medium text-(--brand-primary) md:px-7", children: "Choose a payment method" }),
|
|
5521
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
5522
|
+
] }),
|
|
5523
|
+
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CreditCardTab, {}),
|
|
5524
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react22.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabLoadingFallback, {}), children: [
|
|
5525
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoTab2, {}),
|
|
5526
|
+
selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoComTab2, {})
|
|
5527
|
+
] })
|
|
5528
|
+
]
|
|
5529
|
+
}
|
|
5530
|
+
)
|
|
5531
|
+
);
|
|
5032
5532
|
};
|
|
5033
5533
|
|
|
5034
5534
|
// src/components/ErrorBoundary.tsx
|
|
5035
|
-
var
|
|
5535
|
+
var import_react23 = require("react");
|
|
5036
5536
|
init_utils();
|
|
5037
5537
|
init_logger();
|
|
5038
5538
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5039
|
-
var ErrorBoundary = class extends
|
|
5539
|
+
var ErrorBoundary = class extends import_react23.Component {
|
|
5040
5540
|
constructor(props) {
|
|
5041
5541
|
super(props);
|
|
5042
5542
|
this.state = { hasError: false, error: null };
|
|
@@ -5088,22 +5588,22 @@ init_StaticConfigContext();
|
|
|
5088
5588
|
init_client();
|
|
5089
5589
|
|
|
5090
5590
|
// src/hooks/useKeycloakSSO.ts
|
|
5091
|
-
var
|
|
5591
|
+
var import_react24 = require("react");
|
|
5092
5592
|
var import_keycloak_js = __toESM(require("keycloak-js"), 1);
|
|
5093
5593
|
init_logger();
|
|
5094
5594
|
var refreshAheadSeconds = 60;
|
|
5095
5595
|
var keycloakLogger = logger.child("keycloak");
|
|
5096
5596
|
function useKeycloakSSO(config2) {
|
|
5097
5597
|
const { url, realm, clientId, ssoPageURI, enabled } = config2;
|
|
5098
|
-
const initRef = (0,
|
|
5099
|
-
const kcRef = (0,
|
|
5100
|
-
const refreshTimerRef = (0,
|
|
5101
|
-
const scheduleRefreshRef = (0,
|
|
5598
|
+
const initRef = (0, import_react24.useRef)(false);
|
|
5599
|
+
const kcRef = (0, import_react24.useRef)(null);
|
|
5600
|
+
const refreshTimerRef = (0, import_react24.useRef)(null);
|
|
5601
|
+
const scheduleRefreshRef = (0, import_react24.useRef)(() => {
|
|
5102
5602
|
});
|
|
5103
|
-
const [error, setError] = (0,
|
|
5104
|
-
const [isChecking, setIsChecking] = (0,
|
|
5105
|
-
const [accessToken, setAccessToken] = (0,
|
|
5106
|
-
const scheduleRefresh = (0,
|
|
5603
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
5604
|
+
const [isChecking, setIsChecking] = (0, import_react24.useState)(enabled);
|
|
5605
|
+
const [accessToken, setAccessToken] = (0, import_react24.useState)(null);
|
|
5606
|
+
const scheduleRefresh = (0, import_react24.useCallback)(() => {
|
|
5107
5607
|
const kc = kcRef.current;
|
|
5108
5608
|
if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
|
|
5109
5609
|
return;
|
|
@@ -5127,10 +5627,10 @@ function useKeycloakSSO(config2) {
|
|
|
5127
5627
|
});
|
|
5128
5628
|
}, delayMs);
|
|
5129
5629
|
}, []);
|
|
5130
|
-
(0,
|
|
5630
|
+
(0, import_react24.useEffect)(() => {
|
|
5131
5631
|
scheduleRefreshRef.current = scheduleRefresh;
|
|
5132
5632
|
}, [scheduleRefresh]);
|
|
5133
|
-
(0,
|
|
5633
|
+
(0, import_react24.useEffect)(() => {
|
|
5134
5634
|
if (initRef.current || !enabled) return;
|
|
5135
5635
|
initRef.current = true;
|
|
5136
5636
|
const kc = new import_keycloak_js.default({ url, realm, clientId });
|
|
@@ -5183,14 +5683,14 @@ var isTokenExpired = (token) => {
|
|
|
5183
5683
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5184
5684
|
var unauthenticatedFetcher = () => Promise.resolve(null);
|
|
5185
5685
|
var SpreePayInner = () => {
|
|
5186
|
-
const [portalEl, setPortalEl] = (0,
|
|
5187
|
-
const rootRef = (0,
|
|
5686
|
+
const [portalEl, setPortalEl] = (0, import_react25.useState)(null);
|
|
5687
|
+
const rootRef = (0, import_react25.useCallback)((node) => {
|
|
5188
5688
|
if (!node) return;
|
|
5189
5689
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
5190
5690
|
setPortalEl(el ?? null);
|
|
5191
5691
|
}, []);
|
|
5192
5692
|
const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
|
|
5193
|
-
(0,
|
|
5693
|
+
(0, import_react25.useEffect)(() => {
|
|
5194
5694
|
configureLogger({ environment });
|
|
5195
5695
|
logger.logVersion();
|
|
5196
5696
|
}, [environment]);
|
|
@@ -5204,7 +5704,7 @@ var SpreePayInner = () => {
|
|
|
5204
5704
|
enabled: !envTokenValid
|
|
5205
5705
|
});
|
|
5206
5706
|
const _accessToken = envTokenValid ? envAccessToken : accessToken;
|
|
5207
|
-
const slapiFetcher = (0,
|
|
5707
|
+
const slapiFetcher = (0, import_react25.useMemo)(() => {
|
|
5208
5708
|
if (_accessToken) {
|
|
5209
5709
|
return registerApi({
|
|
5210
5710
|
accessToken: _accessToken,
|
|
@@ -5230,7 +5730,7 @@ var SpreePayInner = () => {
|
|
|
5230
5730
|
revalidateOnFocus: false,
|
|
5231
5731
|
revalidateIfStale: false
|
|
5232
5732
|
},
|
|
5233
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5733
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(esm_default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(LoginStatusProvider, { isLoggedIn: Boolean(_accessToken), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SpreePayContent, {}) }) }) })
|
|
5234
5734
|
}
|
|
5235
5735
|
);
|
|
5236
5736
|
};
|
|
@@ -5244,9 +5744,9 @@ var SpreePay = (props) => {
|
|
|
5244
5744
|
};
|
|
5245
5745
|
|
|
5246
5746
|
// src/hooks/useCapture3DS.ts
|
|
5247
|
-
var
|
|
5747
|
+
var import_react26 = require("react");
|
|
5248
5748
|
var useCapture3DS = ({ paymentIntent }) => {
|
|
5249
|
-
(0,
|
|
5749
|
+
(0, import_react26.useEffect)(() => {
|
|
5250
5750
|
if (typeof window !== "undefined" && window.parent && paymentIntent) {
|
|
5251
5751
|
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent });
|
|
5252
5752
|
}
|