@movmo_app/payments 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,979 @@
1
+ import Je, { useState as M, useRef as ye, useEffect as he, useCallback as ge, useMemo as Cr } from "react";
2
+ var be = { exports: {} }, q = {};
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.min.js
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var We;
13
+ function Tr() {
14
+ if (We) return q;
15
+ We = 1;
16
+ var n = Je, o = Symbol.for("react.element"), c = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, v = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, w = { key: !0, ref: !0, __self: !0, __source: !0 };
17
+ function A(O, b, S) {
18
+ var E, y = {}, D = null, C = null;
19
+ S !== void 0 && (D = "" + S), b.key !== void 0 && (D = "" + b.key), b.ref !== void 0 && (C = b.ref);
20
+ for (E in b) i.call(b, E) && !w.hasOwnProperty(E) && (y[E] = b[E]);
21
+ if (O && O.defaultProps) for (E in b = O.defaultProps, b) y[E] === void 0 && (y[E] = b[E]);
22
+ return { $$typeof: o, type: O, key: D, ref: C, props: y, _owner: v.current };
23
+ }
24
+ return q.Fragment = c, q.jsx = A, q.jsxs = A, q;
25
+ }
26
+ var B = {};
27
+ /**
28
+ * @license React
29
+ * react-jsx-runtime.development.js
30
+ *
31
+ * Copyright (c) Facebook, Inc. and its affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ */
36
+ var Ve;
37
+ function jr() {
38
+ return Ve || (Ve = 1, process.env.NODE_ENV !== "production" && function() {
39
+ var n = Je, o = Symbol.for("react.element"), c = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), A = Symbol.for("react.provider"), O = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), S = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), C = Symbol.for("react.offscreen"), h = Symbol.iterator, R = "@@iterator";
40
+ function j(e) {
41
+ if (e === null || typeof e != "object")
42
+ return null;
43
+ var r = h && e[h] || e[R];
44
+ return typeof r == "function" ? r : null;
45
+ }
46
+ var x = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
+ function p(e) {
48
+ {
49
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++)
50
+ t[a - 1] = arguments[a];
51
+ K("error", e, t);
52
+ }
53
+ }
54
+ function K(e, r, t) {
55
+ {
56
+ var a = x.ReactDebugCurrentFrame, u = a.getStackAddendum();
57
+ u !== "" && (r += "%s", t = t.concat([u]));
58
+ var f = t.map(function(l) {
59
+ return String(l);
60
+ });
61
+ f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
62
+ }
63
+ }
64
+ var G = !1, oe = !1, U = !1, ie = !1, se = !1, H;
65
+ H = Symbol.for("react.module.reference");
66
+ function Y(e) {
67
+ return !!(typeof e == "string" || typeof e == "function" || e === i || e === w || se || e === v || e === S || e === E || ie || e === C || G || oe || U || typeof e == "object" && e !== null && (e.$$typeof === D || e.$$typeof === y || e.$$typeof === A || e.$$typeof === O || e.$$typeof === b || // This needs to include all possible module reference object
68
+ // types supported by any Flight configuration anywhere since
69
+ // we don't know which Flight build this will end up being used
70
+ // with.
71
+ e.$$typeof === H || e.getModuleId !== void 0));
72
+ }
73
+ function X(e, r, t) {
74
+ var a = e.displayName;
75
+ if (a)
76
+ return a;
77
+ var u = r.displayName || r.name || "";
78
+ return u !== "" ? t + "(" + u + ")" : t;
79
+ }
80
+ function Z(e) {
81
+ return e.displayName || "Context";
82
+ }
83
+ function N(e) {
84
+ if (e == null)
85
+ return null;
86
+ if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
87
+ return e.displayName || e.name || null;
88
+ if (typeof e == "string")
89
+ return e;
90
+ switch (e) {
91
+ case i:
92
+ return "Fragment";
93
+ case c:
94
+ return "Portal";
95
+ case w:
96
+ return "Profiler";
97
+ case v:
98
+ return "StrictMode";
99
+ case S:
100
+ return "Suspense";
101
+ case E:
102
+ return "SuspenseList";
103
+ }
104
+ if (typeof e == "object")
105
+ switch (e.$$typeof) {
106
+ case O:
107
+ var r = e;
108
+ return Z(r) + ".Consumer";
109
+ case A:
110
+ var t = e;
111
+ return Z(t._context) + ".Provider";
112
+ case b:
113
+ return X(e, e.render, "ForwardRef");
114
+ case y:
115
+ var a = e.displayName || null;
116
+ return a !== null ? a : N(e.type) || "Memo";
117
+ case D: {
118
+ var u = e, f = u._payload, l = u._init;
119
+ try {
120
+ return N(l(f));
121
+ } catch {
122
+ return null;
123
+ }
124
+ }
125
+ }
126
+ return null;
127
+ }
128
+ var d = Object.assign, k = 0, L, Ee, _e, Re, xe, we, Se;
129
+ function Ce() {
130
+ }
131
+ Ce.__reactDisabledLog = !0;
132
+ function Qe() {
133
+ {
134
+ if (k === 0) {
135
+ L = console.log, Ee = console.info, _e = console.warn, Re = console.error, xe = console.group, we = console.groupCollapsed, Se = console.groupEnd;
136
+ var e = {
137
+ configurable: !0,
138
+ enumerable: !0,
139
+ value: Ce,
140
+ writable: !0
141
+ };
142
+ Object.defineProperties(console, {
143
+ info: e,
144
+ log: e,
145
+ warn: e,
146
+ error: e,
147
+ group: e,
148
+ groupCollapsed: e,
149
+ groupEnd: e
150
+ });
151
+ }
152
+ k++;
153
+ }
154
+ }
155
+ function er() {
156
+ {
157
+ if (k--, k === 0) {
158
+ var e = {
159
+ configurable: !0,
160
+ enumerable: !0,
161
+ writable: !0
162
+ };
163
+ Object.defineProperties(console, {
164
+ log: d({}, e, {
165
+ value: L
166
+ }),
167
+ info: d({}, e, {
168
+ value: Ee
169
+ }),
170
+ warn: d({}, e, {
171
+ value: _e
172
+ }),
173
+ error: d({}, e, {
174
+ value: Re
175
+ }),
176
+ group: d({}, e, {
177
+ value: xe
178
+ }),
179
+ groupCollapsed: d({}, e, {
180
+ value: we
181
+ }),
182
+ groupEnd: d({}, e, {
183
+ value: Se
184
+ })
185
+ });
186
+ }
187
+ k < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
+ }
189
+ }
190
+ var le = x.ReactCurrentDispatcher, ce;
191
+ function Q(e, r, t) {
192
+ {
193
+ if (ce === void 0)
194
+ try {
195
+ throw Error();
196
+ } catch (u) {
197
+ var a = u.stack.trim().match(/\n( *(at )?)/);
198
+ ce = a && a[1] || "";
199
+ }
200
+ return `
201
+ ` + ce + e;
202
+ }
203
+ }
204
+ var ue = !1, ee;
205
+ {
206
+ var rr = typeof WeakMap == "function" ? WeakMap : Map;
207
+ ee = new rr();
208
+ }
209
+ function Te(e, r) {
210
+ if (!e || ue)
211
+ return "";
212
+ {
213
+ var t = ee.get(e);
214
+ if (t !== void 0)
215
+ return t;
216
+ }
217
+ var a;
218
+ ue = !0;
219
+ var u = Error.prepareStackTrace;
220
+ Error.prepareStackTrace = void 0;
221
+ var f;
222
+ f = le.current, le.current = null, Qe();
223
+ try {
224
+ if (r) {
225
+ var l = function() {
226
+ throw Error();
227
+ };
228
+ if (Object.defineProperty(l.prototype, "props", {
229
+ set: function() {
230
+ throw Error();
231
+ }
232
+ }), typeof Reflect == "object" && Reflect.construct) {
233
+ try {
234
+ Reflect.construct(l, []);
235
+ } catch (P) {
236
+ a = P;
237
+ }
238
+ Reflect.construct(e, [], l);
239
+ } else {
240
+ try {
241
+ l.call();
242
+ } catch (P) {
243
+ a = P;
244
+ }
245
+ e.call(l.prototype);
246
+ }
247
+ } else {
248
+ try {
249
+ throw Error();
250
+ } catch (P) {
251
+ a = P;
252
+ }
253
+ e();
254
+ }
255
+ } catch (P) {
256
+ if (P && a && typeof P.stack == "string") {
257
+ for (var s = P.stack.split(`
258
+ `), T = a.stack.split(`
259
+ `), g = s.length - 1, _ = T.length - 1; g >= 1 && _ >= 0 && s[g] !== T[_]; )
260
+ _--;
261
+ for (; g >= 1 && _ >= 0; g--, _--)
262
+ if (s[g] !== T[_]) {
263
+ if (g !== 1 || _ !== 1)
264
+ do
265
+ if (g--, _--, _ < 0 || s[g] !== T[_]) {
266
+ var F = `
267
+ ` + s[g].replace(" at new ", " at ");
268
+ return e.displayName && F.includes("<anonymous>") && (F = F.replace("<anonymous>", e.displayName)), typeof e == "function" && ee.set(e, F), F;
269
+ }
270
+ while (g >= 1 && _ >= 0);
271
+ break;
272
+ }
273
+ }
274
+ } finally {
275
+ ue = !1, le.current = f, er(), Error.prepareStackTrace = u;
276
+ }
277
+ var W = e ? e.displayName || e.name : "", I = W ? Q(W) : "";
278
+ return typeof e == "function" && ee.set(e, I), I;
279
+ }
280
+ function tr(e, r, t) {
281
+ return Te(e, !1);
282
+ }
283
+ function nr(e) {
284
+ var r = e.prototype;
285
+ return !!(r && r.isReactComponent);
286
+ }
287
+ function re(e, r, t) {
288
+ if (e == null)
289
+ return "";
290
+ if (typeof e == "function")
291
+ return Te(e, nr(e));
292
+ if (typeof e == "string")
293
+ return Q(e);
294
+ switch (e) {
295
+ case S:
296
+ return Q("Suspense");
297
+ case E:
298
+ return Q("SuspenseList");
299
+ }
300
+ if (typeof e == "object")
301
+ switch (e.$$typeof) {
302
+ case b:
303
+ return tr(e.render);
304
+ case y:
305
+ return re(e.type, r, t);
306
+ case D: {
307
+ var a = e, u = a._payload, f = a._init;
308
+ try {
309
+ return re(f(u), r, t);
310
+ } catch {
311
+ }
312
+ }
313
+ }
314
+ return "";
315
+ }
316
+ var z = Object.prototype.hasOwnProperty, je = {}, Pe = x.ReactDebugCurrentFrame;
317
+ function te(e) {
318
+ if (e) {
319
+ var r = e._owner, t = re(e.type, e._source, r ? r.type : null);
320
+ Pe.setExtraStackFrame(t);
321
+ } else
322
+ Pe.setExtraStackFrame(null);
323
+ }
324
+ function ar(e, r, t, a, u) {
325
+ {
326
+ var f = Function.call.bind(z);
327
+ for (var l in e)
328
+ if (f(e, l)) {
329
+ var s = void 0;
330
+ try {
331
+ if (typeof e[l] != "function") {
332
+ var T = Error((a || "React class") + ": " + t + " type `" + l + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[l] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
+ throw T.name = "Invariant Violation", T;
334
+ }
335
+ s = e[l](r, l, a, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
+ } catch (g) {
337
+ s = g;
338
+ }
339
+ s && !(s instanceof Error) && (te(u), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", a || "React class", t, l, typeof s), te(null)), s instanceof Error && !(s.message in je) && (je[s.message] = !0, te(u), p("Failed %s type: %s", t, s.message), te(null));
340
+ }
341
+ }
342
+ }
343
+ var or = Array.isArray;
344
+ function de(e) {
345
+ return or(e);
346
+ }
347
+ function ir(e) {
348
+ {
349
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
350
+ return t;
351
+ }
352
+ }
353
+ function sr(e) {
354
+ try {
355
+ return Oe(e), !1;
356
+ } catch {
357
+ return !0;
358
+ }
359
+ }
360
+ function Oe(e) {
361
+ return "" + e;
362
+ }
363
+ function ke(e) {
364
+ if (sr(e))
365
+ return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ir(e)), Oe(e);
366
+ }
367
+ var Fe = x.ReactCurrentOwner, lr = {
368
+ key: !0,
369
+ ref: !0,
370
+ __self: !0,
371
+ __source: !0
372
+ }, Ae, De;
373
+ function cr(e) {
374
+ if (z.call(e, "ref")) {
375
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
376
+ if (r && r.isReactWarning)
377
+ return !1;
378
+ }
379
+ return e.ref !== void 0;
380
+ }
381
+ function ur(e) {
382
+ if (z.call(e, "key")) {
383
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
384
+ if (r && r.isReactWarning)
385
+ return !1;
386
+ }
387
+ return e.key !== void 0;
388
+ }
389
+ function dr(e, r) {
390
+ typeof e.ref == "string" && Fe.current;
391
+ }
392
+ function fr(e, r) {
393
+ {
394
+ var t = function() {
395
+ Ae || (Ae = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
396
+ };
397
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
398
+ get: t,
399
+ configurable: !0
400
+ });
401
+ }
402
+ }
403
+ function mr(e, r) {
404
+ {
405
+ var t = function() {
406
+ De || (De = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
407
+ };
408
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
409
+ get: t,
410
+ configurable: !0
411
+ });
412
+ }
413
+ }
414
+ var vr = function(e, r, t, a, u, f, l) {
415
+ var s = {
416
+ // This tag allows us to uniquely identify this as a React Element
417
+ $$typeof: o,
418
+ // Built-in properties that belong on the element
419
+ type: e,
420
+ key: r,
421
+ ref: t,
422
+ props: l,
423
+ // Record the component responsible for creating this element.
424
+ _owner: f
425
+ };
426
+ return s._store = {}, Object.defineProperty(s._store, "validated", {
427
+ configurable: !1,
428
+ enumerable: !1,
429
+ writable: !0,
430
+ value: !1
431
+ }), Object.defineProperty(s, "_self", {
432
+ configurable: !1,
433
+ enumerable: !1,
434
+ writable: !1,
435
+ value: a
436
+ }), Object.defineProperty(s, "_source", {
437
+ configurable: !1,
438
+ enumerable: !1,
439
+ writable: !1,
440
+ value: u
441
+ }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
442
+ };
443
+ function pr(e, r, t, a, u) {
444
+ {
445
+ var f, l = {}, s = null, T = null;
446
+ t !== void 0 && (ke(t), s = "" + t), ur(r) && (ke(r.key), s = "" + r.key), cr(r) && (T = r.ref, dr(r, u));
447
+ for (f in r)
448
+ z.call(r, f) && !lr.hasOwnProperty(f) && (l[f] = r[f]);
449
+ if (e && e.defaultProps) {
450
+ var g = e.defaultProps;
451
+ for (f in g)
452
+ l[f] === void 0 && (l[f] = g[f]);
453
+ }
454
+ if (s || T) {
455
+ var _ = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
456
+ s && fr(l, _), T && mr(l, _);
457
+ }
458
+ return vr(e, s, T, u, a, Fe.current, l);
459
+ }
460
+ }
461
+ var fe = x.ReactCurrentOwner, Ne = x.ReactDebugCurrentFrame;
462
+ function $(e) {
463
+ if (e) {
464
+ var r = e._owner, t = re(e.type, e._source, r ? r.type : null);
465
+ Ne.setExtraStackFrame(t);
466
+ } else
467
+ Ne.setExtraStackFrame(null);
468
+ }
469
+ var me;
470
+ me = !1;
471
+ function ve(e) {
472
+ return typeof e == "object" && e !== null && e.$$typeof === o;
473
+ }
474
+ function Le() {
475
+ {
476
+ if (fe.current) {
477
+ var e = N(fe.current.type);
478
+ if (e)
479
+ return `
480
+
481
+ Check the render method of \`` + e + "`.";
482
+ }
483
+ return "";
484
+ }
485
+ }
486
+ function yr(e) {
487
+ return "";
488
+ }
489
+ var Ue = {};
490
+ function hr(e) {
491
+ {
492
+ var r = Le();
493
+ if (!r) {
494
+ var t = typeof e == "string" ? e : e.displayName || e.name;
495
+ t && (r = `
496
+
497
+ Check the top-level render call using <` + t + ">.");
498
+ }
499
+ return r;
500
+ }
501
+ }
502
+ function Ye(e, r) {
503
+ {
504
+ if (!e._store || e._store.validated || e.key != null)
505
+ return;
506
+ e._store.validated = !0;
507
+ var t = hr(r);
508
+ if (Ue[t])
509
+ return;
510
+ Ue[t] = !0;
511
+ var a = "";
512
+ e && e._owner && e._owner !== fe.current && (a = " It was passed a child from " + N(e._owner.type) + "."), $(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, a), $(null);
513
+ }
514
+ }
515
+ function Me(e, r) {
516
+ {
517
+ if (typeof e != "object")
518
+ return;
519
+ if (de(e))
520
+ for (var t = 0; t < e.length; t++) {
521
+ var a = e[t];
522
+ ve(a) && Ye(a, r);
523
+ }
524
+ else if (ve(e))
525
+ e._store && (e._store.validated = !0);
526
+ else if (e) {
527
+ var u = j(e);
528
+ if (typeof u == "function" && u !== e.entries)
529
+ for (var f = u.call(e), l; !(l = f.next()).done; )
530
+ ve(l.value) && Ye(l.value, r);
531
+ }
532
+ }
533
+ }
534
+ function gr(e) {
535
+ {
536
+ var r = e.type;
537
+ if (r == null || typeof r == "string")
538
+ return;
539
+ var t;
540
+ if (typeof r == "function")
541
+ t = r.propTypes;
542
+ else if (typeof r == "object" && (r.$$typeof === b || // Note: Memo only checks outer props here.
543
+ // Inner props are checked in the reconciler.
544
+ r.$$typeof === y))
545
+ t = r.propTypes;
546
+ else
547
+ return;
548
+ if (t) {
549
+ var a = N(r);
550
+ ar(t, e.props, "prop", a, e);
551
+ } else if (r.PropTypes !== void 0 && !me) {
552
+ me = !0;
553
+ var u = N(r);
554
+ p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown");
555
+ }
556
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
+ }
558
+ }
559
+ function br(e) {
560
+ {
561
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
562
+ var a = r[t];
563
+ if (a !== "children" && a !== "key") {
564
+ $(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", a), $(null);
565
+ break;
566
+ }
567
+ }
568
+ e.ref !== null && ($(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), $(null));
569
+ }
570
+ }
571
+ var Ie = {};
572
+ function $e(e, r, t, a, u, f) {
573
+ {
574
+ var l = Y(e);
575
+ if (!l) {
576
+ var s = "";
577
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (s += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
+ var T = yr();
579
+ T ? s += T : s += Le();
580
+ var g;
581
+ e === null ? g = "null" : de(e) ? g = "array" : e !== void 0 && e.$$typeof === o ? (g = "<" + (N(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : g = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", g, s);
582
+ }
583
+ var _ = pr(e, r, t, u, f);
584
+ if (_ == null)
585
+ return _;
586
+ if (l) {
587
+ var F = r.children;
588
+ if (F !== void 0)
589
+ if (a)
590
+ if (de(F)) {
591
+ for (var W = 0; W < F.length; W++)
592
+ Me(F[W], e);
593
+ Object.freeze && Object.freeze(F);
594
+ } else
595
+ p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
596
+ else
597
+ Me(F, e);
598
+ }
599
+ if (z.call(r, "key")) {
600
+ var I = N(e), P = Object.keys(r).filter(function(Sr) {
601
+ return Sr !== "key";
602
+ }), pe = P.length > 0 ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}";
603
+ if (!Ie[I + pe]) {
604
+ var wr = P.length > 0 ? "{" + P.join(": ..., ") + ": ...}" : "{}";
605
+ p(`A props object containing a "key" prop is being spread into JSX:
606
+ let props = %s;
607
+ <%s {...props} />
608
+ React keys must be passed directly to JSX without using spread:
609
+ let props = %s;
610
+ <%s key={someKey} {...props} />`, pe, I, wr, I), Ie[I + pe] = !0;
611
+ }
612
+ }
613
+ return e === i ? br(_) : gr(_), _;
614
+ }
615
+ }
616
+ function Er(e, r, t) {
617
+ return $e(e, r, t, !0);
618
+ }
619
+ function _r(e, r, t) {
620
+ return $e(e, r, t, !1);
621
+ }
622
+ var Rr = _r, xr = Er;
623
+ B.Fragment = i, B.jsx = Rr, B.jsxs = xr;
624
+ }()), B;
625
+ }
626
+ process.env.NODE_ENV === "production" ? be.exports = Tr() : be.exports = jr();
627
+ var m = be.exports;
628
+ function Ke(n) {
629
+ var o, c, i = "";
630
+ if (typeof n == "string" || typeof n == "number") i += n;
631
+ else if (typeof n == "object") if (Array.isArray(n)) {
632
+ var v = n.length;
633
+ for (o = 0; o < v; o++) n[o] && (c = Ke(n[o])) && (i && (i += " "), i += c);
634
+ } else for (c in n) n[c] && (i && (i += " "), i += c);
635
+ return i;
636
+ }
637
+ function ze() {
638
+ for (var n, o, c = 0, i = "", v = arguments.length; c < v; c++) (n = arguments[c]) && (o = Ke(n)) && (i && (i += " "), i += o);
639
+ return i;
640
+ }
641
+ const Pr = "https://core.spreedly.com/iframe/iframe-v1.min.js";
642
+ let ae = {};
643
+ const $r = (n) => {
644
+ ae = { ...ae, ...n };
645
+ }, qe = (n) => {
646
+ var c;
647
+ const o = globalThis.process;
648
+ return (c = o == null ? void 0 : o.env) == null ? void 0 : c[n];
649
+ }, Ge = () => ({
650
+ baseUrl: ae.baseUrl ?? qe("REACT_APP_MOVMO_API_URL") ?? "",
651
+ spreedlyScriptUrl: ae.spreedlyScriptUrl ?? qe("REACT_APP_SPREEDLY_SCRIPT_URL") ?? Pr
652
+ }), He = {
653
+ Accept: "application/json",
654
+ "Content-Type": "application/json"
655
+ }, Xe = (n) => {
656
+ const { baseUrl: o } = Ge();
657
+ if (!o)
658
+ throw new Error(
659
+ "@movmo_app/payments: baseUrl is not configured. Call setPaymentsConfig({ baseUrl }) at app boot, or set REACT_APP_MOVMO_API_URL."
660
+ );
661
+ return `${o}${n}`;
662
+ }, Ze = async (n, o) => {
663
+ try {
664
+ return (await n.json()).message || o;
665
+ } catch {
666
+ return o;
667
+ }
668
+ }, Or = async () => {
669
+ const n = await fetch(Xe("/v1/payments/tokenization-session"), {
670
+ method: "GET",
671
+ headers: He,
672
+ credentials: "include"
673
+ });
674
+ if (!n.ok)
675
+ throw new Error(await Ze(n, `Failed to fetch tokenization session (${n.status})`));
676
+ return await n.json();
677
+ }, kr = async (n, o, c) => {
678
+ const i = await fetch(Xe(`/v1/users/${encodeURIComponent(n)}/payment-methods/from-token`), {
679
+ method: "POST",
680
+ headers: He,
681
+ credentials: "include",
682
+ body: JSON.stringify({ tokenizedPaymentMethodId: o, isDefault: c })
683
+ });
684
+ if (!i.ok)
685
+ throw new Error(await Ze(i, `Failed to save payment method (${i.status})`));
686
+ const v = await i.json();
687
+ return {
688
+ id: v.id,
689
+ last4: v.last4,
690
+ brand: v.brand,
691
+ expMonth: v.expMonth,
692
+ expYear: v.expYear,
693
+ isDefault: v.isDefault
694
+ };
695
+ };
696
+ let J = null;
697
+ const Fr = () => {
698
+ if (typeof window > "u")
699
+ return Promise.reject(new Error("Spreedly can only be loaded in a browser environment."));
700
+ if (window.Spreedly)
701
+ return Promise.resolve(window.Spreedly);
702
+ if (J)
703
+ return J;
704
+ const { spreedlyScriptUrl: n } = Ge();
705
+ return J = new Promise((o, c) => {
706
+ const i = document.querySelector(
707
+ `script[src="${n}"]`
708
+ ), v = () => {
709
+ window.Spreedly ? o(window.Spreedly) : c(new Error("Spreedly script loaded but window.Spreedly is undefined."));
710
+ };
711
+ if (i) {
712
+ if (window.Spreedly) {
713
+ v();
714
+ return;
715
+ }
716
+ i.addEventListener("load", v, { once: !0 }), i.addEventListener(
717
+ "error",
718
+ () => {
719
+ i.remove(), c(new Error("Failed to load Spreedly iframe script."));
720
+ },
721
+ { once: !0 }
722
+ );
723
+ return;
724
+ }
725
+ const w = document.createElement("script");
726
+ w.src = n, w.async = !0, w.onload = v, w.onerror = () => {
727
+ w.remove(), c(new Error("Failed to load Spreedly iframe script."));
728
+ }, document.head.appendChild(w);
729
+ }).catch((o) => {
730
+ throw J = null, o;
731
+ }), J;
732
+ }, Ar = "movmo-card-number", Dr = "movmo-card-cvv", Nr = (n) => ({
733
+ first_name: n.firstName,
734
+ last_name: n.lastName,
735
+ month: n.month,
736
+ year: n.year,
737
+ ...n.email ? { email: n.email } : {},
738
+ ...n.zip ? { zip: n.zip } : {}
739
+ }), Lr = (n = {}) => {
740
+ const {
741
+ numberEl: o = Ar,
742
+ cvvEl: c = Dr,
743
+ onCardTokenized: i,
744
+ onFieldErrors: v
745
+ } = n, [w, A] = M("idle"), [O, b] = M(null), S = ye(null), E = ye(i), y = ye(v);
746
+ he(() => {
747
+ E.current = i;
748
+ }, [i]), he(() => {
749
+ y.current = v;
750
+ }, [v]), he(() => {
751
+ let C = !1;
752
+ return A("loading"), b(null), (async () => {
753
+ try {
754
+ const [h, R] = await Promise.all([
755
+ Or(),
756
+ Fr()
757
+ ]);
758
+ if (C) return;
759
+ S.current = R, R.on("ready", () => {
760
+ C || A("ready");
761
+ }), R.on("paymentMethod", (j) => {
762
+ var x;
763
+ (x = E.current) == null || x.call(E, j);
764
+ }), R.on("errors", (j) => {
765
+ var x;
766
+ (x = y.current) == null || x.call(y, j);
767
+ }), R.on("consoleError", (j) => {
768
+ var p;
769
+ const x = j instanceof Error ? j.message : "An unexpected error occurred while securing your card.";
770
+ (p = y.current) == null || p.call(y, [{ message: x }]);
771
+ }), R.init(h.environmentKey, {
772
+ numberEl: o,
773
+ cvvEl: c,
774
+ nonce: h.nonce,
775
+ timestamp: String(h.timestamp),
776
+ certificateToken: h.certificateToken,
777
+ signature: h.signature
778
+ });
779
+ } catch (h) {
780
+ if (C) return;
781
+ const R = h instanceof Error ? h.message : "Failed to initialize card form.";
782
+ b(R), A("error");
783
+ }
784
+ })(), () => {
785
+ var h, R;
786
+ C = !0;
787
+ try {
788
+ (R = (h = S.current) == null ? void 0 : h.removeHandlers) == null || R.call(h);
789
+ } catch {
790
+ }
791
+ S.current = null;
792
+ };
793
+ }, [o, c]);
794
+ const D = ge((C) => {
795
+ var h;
796
+ (h = S.current) == null || h.tokenizeCreditCard(Nr(C));
797
+ }, []);
798
+ return { status: w, error: O, tokenize: D };
799
+ }, ne = "h-11 w-full rounded-md border border-grayWarm-300 bg-white px-3 py-2 text-sm text-grayWarm-900 placeholder:text-grayWarm-400 focus:border-brand-500 focus:outline-none focus:ring-1 focus:ring-brand-500", Be = "h-11 w-full rounded-md border border-grayWarm-300 bg-white px-3 py-2 focus-within:border-brand-500 focus-within:ring-1 focus-within:ring-brand-500", V = "mb-1 block text-xs font-medium text-grayWarm-700", Ur = Array.from({ length: 12 }, (n, o) => String(o + 1).padStart(2, "0")), Yr = (() => {
800
+ const n = (/* @__PURE__ */ new Date()).getFullYear();
801
+ return Array.from({ length: 15 }, (o, c) => String(n + c));
802
+ })(), Mr = ({
803
+ userId: n,
804
+ onSuccess: o,
805
+ onError: c,
806
+ isDefault: i = !1,
807
+ className: v,
808
+ defaultCardholderFirstName: w = "",
809
+ defaultCardholderLastName: A = ""
810
+ }) => {
811
+ const [O, b] = M(w), [S, E] = M(A), [y, D] = M(""), [C, h] = M(""), [R, j] = M("idle"), [x, p] = M(null), K = ge(
812
+ async (d) => {
813
+ j("saving");
814
+ try {
815
+ const k = await kr(n, d, i);
816
+ j("ready"), o(k);
817
+ } catch (k) {
818
+ const L = k instanceof Error ? k.message : "Failed to save payment method.";
819
+ p(L), j("ready"), c(L);
820
+ }
821
+ },
822
+ [n, i, o, c]
823
+ ), G = ge(
824
+ (d) => {
825
+ const k = d.map((L) => L.message).filter(Boolean).join("; ") || "Card validation failed.";
826
+ p(k), j((L) => L === "tokenizing" ? "ready" : L), c(k);
827
+ },
828
+ [c]
829
+ ), oe = Cr(
830
+ () => ({
831
+ onCardTokenized: K,
832
+ onFieldErrors: G
833
+ }),
834
+ [K, G]
835
+ ), { status: U, error: ie, tokenize: se } = Lr(oe), H = !O.trim() || !S.trim() || !y || !C, Y = R === "tokenizing" || R === "saving", X = U === "ready" && !Y && !H, Z = (d) => {
836
+ d.preventDefault(), X && (p(null), j("tokenizing"), se({
837
+ firstName: O.trim(),
838
+ lastName: S.trim(),
839
+ month: y,
840
+ year: C
841
+ }));
842
+ }, N = x ?? ie;
843
+ return /* @__PURE__ */ m.jsxs(
844
+ "form",
845
+ {
846
+ onSubmit: Z,
847
+ className: ze("flex w-full flex-col gap-4", v),
848
+ "data-testid": "movmo-card-form",
849
+ children: [
850
+ /* @__PURE__ */ m.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2", children: [
851
+ /* @__PURE__ */ m.jsxs("div", { children: [
852
+ /* @__PURE__ */ m.jsx("label", { htmlFor: "movmo-card-first-name", className: V, children: "First name" }),
853
+ /* @__PURE__ */ m.jsx(
854
+ "input",
855
+ {
856
+ id: "movmo-card-first-name",
857
+ type: "text",
858
+ autoComplete: "cc-given-name",
859
+ value: O,
860
+ onChange: (d) => b(d.target.value),
861
+ className: ne,
862
+ disabled: U !== "ready" || Y,
863
+ required: !0
864
+ }
865
+ )
866
+ ] }),
867
+ /* @__PURE__ */ m.jsxs("div", { children: [
868
+ /* @__PURE__ */ m.jsx("label", { htmlFor: "movmo-card-last-name", className: V, children: "Last name" }),
869
+ /* @__PURE__ */ m.jsx(
870
+ "input",
871
+ {
872
+ id: "movmo-card-last-name",
873
+ type: "text",
874
+ autoComplete: "cc-family-name",
875
+ value: S,
876
+ onChange: (d) => E(d.target.value),
877
+ className: ne,
878
+ disabled: U !== "ready" || Y,
879
+ required: !0
880
+ }
881
+ )
882
+ ] })
883
+ ] }),
884
+ /* @__PURE__ */ m.jsxs("div", { children: [
885
+ /* @__PURE__ */ m.jsx("span", { id: "movmo-card-number-label", className: V, children: "Card number" }),
886
+ /* @__PURE__ */ m.jsx(
887
+ "div",
888
+ {
889
+ id: "movmo-card-number",
890
+ "aria-labelledby": "movmo-card-number-label",
891
+ className: Be,
892
+ "data-testid": "movmo-card-number-mount"
893
+ }
894
+ )
895
+ ] }),
896
+ /* @__PURE__ */ m.jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
897
+ /* @__PURE__ */ m.jsxs("div", { children: [
898
+ /* @__PURE__ */ m.jsx("label", { htmlFor: "movmo-card-exp-month", className: V, children: "Month" }),
899
+ /* @__PURE__ */ m.jsxs(
900
+ "select",
901
+ {
902
+ id: "movmo-card-exp-month",
903
+ value: y,
904
+ onChange: (d) => D(d.target.value),
905
+ className: ne,
906
+ disabled: U !== "ready" || Y,
907
+ required: !0,
908
+ children: [
909
+ /* @__PURE__ */ m.jsx("option", { value: "", children: "MM" }),
910
+ Ur.map((d) => /* @__PURE__ */ m.jsx("option", { value: d, children: d }, d))
911
+ ]
912
+ }
913
+ )
914
+ ] }),
915
+ /* @__PURE__ */ m.jsxs("div", { children: [
916
+ /* @__PURE__ */ m.jsx("label", { htmlFor: "movmo-card-exp-year", className: V, children: "Year" }),
917
+ /* @__PURE__ */ m.jsxs(
918
+ "select",
919
+ {
920
+ id: "movmo-card-exp-year",
921
+ value: C,
922
+ onChange: (d) => h(d.target.value),
923
+ className: ne,
924
+ disabled: U !== "ready" || Y,
925
+ required: !0,
926
+ children: [
927
+ /* @__PURE__ */ m.jsx("option", { value: "", children: "YYYY" }),
928
+ Yr.map((d) => /* @__PURE__ */ m.jsx("option", { value: d, children: d }, d))
929
+ ]
930
+ }
931
+ )
932
+ ] }),
933
+ /* @__PURE__ */ m.jsxs("div", { children: [
934
+ /* @__PURE__ */ m.jsx("span", { id: "movmo-card-cvv-label", className: V, children: "CVV" }),
935
+ /* @__PURE__ */ m.jsx(
936
+ "div",
937
+ {
938
+ id: "movmo-card-cvv",
939
+ "aria-labelledby": "movmo-card-cvv-label",
940
+ className: Be,
941
+ "data-testid": "movmo-card-cvv-mount"
942
+ }
943
+ )
944
+ ] })
945
+ ] }),
946
+ N ? /* @__PURE__ */ m.jsx(
947
+ "p",
948
+ {
949
+ role: "alert",
950
+ className: "rounded-md bg-error-50 px-3 py-2 text-sm text-error-700",
951
+ "data-testid": "movmo-card-error",
952
+ children: N
953
+ }
954
+ ) : null,
955
+ /* @__PURE__ */ m.jsx(
956
+ "button",
957
+ {
958
+ type: "submit",
959
+ disabled: !X,
960
+ className: ze(
961
+ "inline-flex h-11 items-center justify-center rounded-md bg-brand-500 px-4 text-sm font-semibold text-white transition-colors hover:bg-brand-600",
962
+ "disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"
963
+ ),
964
+ "data-testid": "movmo-card-save",
965
+ children: Y ? "Saving…" : U === "loading" ? "Loading…" : "Save card"
966
+ }
967
+ )
968
+ ]
969
+ }
970
+ );
971
+ };
972
+ Mr.displayName = "MovmoCardForm";
973
+ export {
974
+ Mr as MovmoCardForm,
975
+ Ge as getPaymentsConfig,
976
+ $r as setPaymentsConfig,
977
+ Lr as useMovmoCardFields
978
+ };
979
+ //# sourceMappingURL=index.es.js.map