@calcom/atoms 2.8.2 → 2.8.3

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.
@@ -1,544 +0,0 @@
1
- import { jsxs as V, jsx as _ } from "react/jsx-runtime";
2
- import m, { useState as L, useEffect as ie } from "react";
3
- import { g as Ce, u as se, C as we, B as X, W as Re } from "./index-uxS4DSg-.js";
4
- var N = { exports: {} }, W, z;
5
- function xe() {
6
- if (z) return W;
7
- z = 1;
8
- var t = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
9
- return W = t, W;
10
- }
11
- var q, J;
12
- function Te() {
13
- if (J) return q;
14
- J = 1;
15
- var t = /* @__PURE__ */ xe();
16
- function e() {
17
- }
18
- function r() {
19
- }
20
- return r.resetWarningCache = e, q = function() {
21
- function n(p, u, a, f, y, h) {
22
- if (h !== t) {
23
- var c = new Error(
24
- "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
25
- );
26
- throw c.name = "Invariant Violation", c;
27
- }
28
- }
29
- n.isRequired = n;
30
- function s() {
31
- return n;
32
- }
33
- var i = {
34
- array: n,
35
- bigint: n,
36
- bool: n,
37
- func: n,
38
- number: n,
39
- object: n,
40
- string: n,
41
- symbol: n,
42
- any: n,
43
- arrayOf: s,
44
- element: n,
45
- elementType: n,
46
- instanceOf: s,
47
- node: n,
48
- objectOf: s,
49
- oneOf: s,
50
- oneOfType: s,
51
- shape: s,
52
- exact: s,
53
- checkPropTypes: r,
54
- resetWarningCache: e
55
- };
56
- return i.PropTypes = i, i;
57
- }, q;
58
- }
59
- var Q;
60
- function je() {
61
- return Q || (Q = 1, N.exports = /* @__PURE__ */ Te()()), N.exports;
62
- }
63
- var Ae = /* @__PURE__ */ je();
64
- const P = /* @__PURE__ */ Ce(Ae);
65
- function Z(t, e) {
66
- var r = Object.keys(t);
67
- if (Object.getOwnPropertySymbols) {
68
- var n = Object.getOwnPropertySymbols(t);
69
- e && (n = n.filter(function(s) {
70
- return Object.getOwnPropertyDescriptor(t, s).enumerable;
71
- })), r.push.apply(r, n);
72
- }
73
- return r;
74
- }
75
- function ee(t) {
76
- for (var e = 1; e < arguments.length; e++) {
77
- var r = arguments[e] != null ? arguments[e] : {};
78
- e % 2 ? Z(Object(r), !0).forEach(function(n) {
79
- ce(t, n, r[n]);
80
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : Z(Object(r)).forEach(function(n) {
81
- Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
82
- });
83
- }
84
- return t;
85
- }
86
- function A(t) {
87
- "@babel/helpers - typeof";
88
- return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? A = function(e) {
89
- return typeof e;
90
- } : A = function(e) {
91
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
92
- }, A(t);
93
- }
94
- function ce(t, e, r) {
95
- return e in t ? Object.defineProperty(t, e, {
96
- value: r,
97
- enumerable: !0,
98
- configurable: !0,
99
- writable: !0
100
- }) : t[e] = r, t;
101
- }
102
- function Le(t, e) {
103
- return Ie(t) || ke(t, e) || Ne(t, e) || We();
104
- }
105
- function Ie(t) {
106
- if (Array.isArray(t)) return t;
107
- }
108
- function ke(t, e) {
109
- var r = t && (typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"]);
110
- if (r != null) {
111
- var n = [], s = !0, i = !1, p, u;
112
- try {
113
- for (r = r.call(t); !(s = (p = r.next()).done) && (n.push(p.value), !(e && n.length === e)); s = !0)
114
- ;
115
- } catch (a) {
116
- i = !0, u = a;
117
- } finally {
118
- try {
119
- !s && r.return != null && r.return();
120
- } finally {
121
- if (i) throw u;
122
- }
123
- }
124
- return n;
125
- }
126
- }
127
- function Ne(t, e) {
128
- if (t) {
129
- if (typeof t == "string") return te(t, e);
130
- var r = Object.prototype.toString.call(t).slice(8, -1);
131
- if (r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set") return Array.from(t);
132
- if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return te(t, e);
133
- }
134
- }
135
- function te(t, e) {
136
- (e == null || e > t.length) && (e = t.length);
137
- for (var r = 0, n = new Array(e); r < e; r++) n[r] = t[r];
138
- return n;
139
- }
140
- function We() {
141
- throw new TypeError(`Invalid attempt to destructure non-iterable instance.
142
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
143
- }
144
- var $ = function(e) {
145
- var r = m.useRef(e);
146
- return m.useEffect(function() {
147
- r.current = e;
148
- }, [e]), r.current;
149
- }, T = function(e) {
150
- return e !== null && A(e) === "object";
151
- }, qe = function(e) {
152
- return T(e) && typeof e.then == "function";
153
- }, Be = function(e) {
154
- return T(e) && typeof e.elements == "function" && typeof e.createToken == "function" && typeof e.createPaymentMethod == "function" && typeof e.confirmCardPayment == "function";
155
- }, re = "[object Object]", Fe = function t(e, r) {
156
- if (!T(e) || !T(r))
157
- return e === r;
158
- var n = Array.isArray(e), s = Array.isArray(r);
159
- if (n !== s) return !1;
160
- var i = Object.prototype.toString.call(e) === re, p = Object.prototype.toString.call(r) === re;
161
- if (i !== p) return !1;
162
- if (!i && !n) return e === r;
163
- var u = Object.keys(e), a = Object.keys(r);
164
- if (u.length !== a.length) return !1;
165
- for (var f = {}, y = 0; y < u.length; y += 1)
166
- f[u[y]] = !0;
167
- for (var h = 0; h < a.length; h += 1)
168
- f[a[h]] = !0;
169
- var c = Object.keys(f);
170
- if (c.length !== u.length)
171
- return !1;
172
- var O = e, v = r, o = function(d) {
173
- return t(O[d], v[d]);
174
- };
175
- return c.every(o);
176
- }, ue = function(e, r, n) {
177
- return T(e) ? Object.keys(e).reduce(function(s, i) {
178
- var p = !T(r) || !Fe(e[i], r[i]);
179
- return n.includes(i) ? (p && console.warn("Unsupported prop change: options.".concat(i, " is not a mutable property.")), s) : p ? ee(ee({}, s || {}), {}, ce({}, i, e[i])) : s;
180
- }, null) : null;
181
- }, $e = "Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.", ne = function(e) {
182
- if (e === null || Be(e))
183
- return e;
184
- throw new Error($e);
185
- }, Ue = function(e) {
186
- if (qe(e))
187
- return {
188
- tag: "async",
189
- stripePromise: Promise.resolve(e).then(ne)
190
- };
191
- var r = ne(e);
192
- return r === null ? {
193
- tag: "empty"
194
- } : {
195
- tag: "sync",
196
- stripe: r
197
- };
198
- }, U = /* @__PURE__ */ m.createContext(null);
199
- U.displayName = "ElementsContext";
200
- var De = function(e, r) {
201
- if (!e)
202
- throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(r, " in an <Elements> provider."));
203
- return e;
204
- }, le = function(e) {
205
- var r = e.stripe, n = e.options, s = e.children, i = m.useMemo(function() {
206
- return Ue(r);
207
- }, [r]), p = m.useState(function() {
208
- return {
209
- stripe: i.tag === "sync" ? i.stripe : null,
210
- elements: i.tag === "sync" ? i.stripe.elements(n) : null
211
- };
212
- }), u = Le(p, 2), a = u[0], f = u[1];
213
- m.useEffect(function() {
214
- var c = !0, O = function(o) {
215
- f(function(l) {
216
- return l.stripe ? l : {
217
- stripe: o,
218
- elements: o.elements(n)
219
- };
220
- });
221
- };
222
- return i.tag === "async" && !a.stripe ? i.stripePromise.then(function(v) {
223
- v && c && O(v);
224
- }) : i.tag === "sync" && !a.stripe && O(i.stripe), function() {
225
- c = !1;
226
- };
227
- }, [i, a, n]);
228
- var y = $(r);
229
- m.useEffect(function() {
230
- y !== null && y !== r && console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.");
231
- }, [y, r]);
232
- var h = $(n);
233
- return m.useEffect(function() {
234
- if (a.elements) {
235
- var c = ue(n, h, ["clientSecret", "fonts"]);
236
- c && a.elements.update(c);
237
- }
238
- }, [n, h, a.elements]), m.useEffect(function() {
239
- var c = a.stripe;
240
- !c || !c._registerWrapper || !c.registerAppInfo || (c._registerWrapper({
241
- name: "react-stripe-js",
242
- version: "1.10.0"
243
- }), c.registerAppInfo({
244
- name: "react-stripe-js",
245
- version: "1.10.0",
246
- url: "https://stripe.com/docs/stripe-js/react"
247
- }));
248
- }, [a.stripe]), /* @__PURE__ */ m.createElement(U.Provider, {
249
- value: a
250
- }, s);
251
- };
252
- le.propTypes = {
253
- stripe: P.any,
254
- options: P.object
255
- };
256
- var I = function(e) {
257
- var r = m.useContext(U);
258
- return De(r, e);
259
- }, Me = function() {
260
- var e = I("calls useElements()"), r = e.elements;
261
- return r;
262
- }, He = function() {
263
- var e = I("calls useStripe()"), r = e.stripe;
264
- return r;
265
- };
266
- P.func.isRequired;
267
- var C = function(e) {
268
- var r = m.useRef(e);
269
- return m.useEffect(function() {
270
- r.current = e;
271
- }, [e]), function() {
272
- r.current && r.current.apply(r, arguments);
273
- };
274
- }, w = function() {
275
- }, Ke = function(e) {
276
- return e.charAt(0).toUpperCase() + e.slice(1);
277
- }, g = function(e, r) {
278
- var n = "".concat(Ke(e), "Element"), s = function(a) {
279
- var f = a.id, y = a.className, h = a.options, c = h === void 0 ? {} : h, O = a.onBlur, v = O === void 0 ? w : O, o = a.onFocus, l = o === void 0 ? w : o, d = a.onReady, b = d === void 0 ? w : d, x = a.onChange, pe = x === void 0 ? w : x, D = a.onEscape, fe = D === void 0 ? w : D, M = a.onClick, de = M === void 0 ? w : M, H = a.onLoadError, me = H === void 0 ? w : H, K = a.onLoaderStart, ye = K === void 0 ? w : K, ve = I("mounts <".concat(n, ">")), Y = ve.elements, R = m.useRef(null), k = m.useRef(null), he = C(b), ge = C(v), Se = C(l), be = C(de), Ee = C(pe), _e = C(fe), Pe = C(me), Oe = C(ye);
280
- m.useLayoutEffect(function() {
281
- if (R.current == null && Y && k.current != null) {
282
- var E = Y.create(e, c);
283
- R.current = E, E.mount(k.current), E.on("ready", function() {
284
- return he(E);
285
- }), E.on("change", Ee), E.on("blur", ge), E.on("focus", Se), E.on("escape", _e), E.on("loaderror", Pe), E.on("loaderstart", Oe), E.on("click", be);
286
- }
287
- });
288
- var G = $(c);
289
- return m.useEffect(function() {
290
- if (R.current) {
291
- var E = ue(c, G, ["paymentRequest"]);
292
- E && R.current.update(E);
293
- }
294
- }, [c, G]), m.useLayoutEffect(function() {
295
- return function() {
296
- R.current && (R.current.destroy(), R.current = null);
297
- };
298
- }, []), /* @__PURE__ */ m.createElement("div", {
299
- id: f,
300
- className: y,
301
- ref: k
302
- });
303
- }, i = function(a) {
304
- I("mounts <".concat(n, ">"));
305
- var f = a.id, y = a.className;
306
- return /* @__PURE__ */ m.createElement("div", {
307
- id: f,
308
- className: y
309
- });
310
- }, p = r ? i : s;
311
- return p.propTypes = {
312
- id: P.string,
313
- className: P.string,
314
- onChange: P.func,
315
- onBlur: P.func,
316
- onFocus: P.func,
317
- onReady: P.func,
318
- onClick: P.func,
319
- onLoadError: P.func,
320
- onLoaderStart: P.func,
321
- options: P.object
322
- }, p.displayName = n, p.__elementType = e, p;
323
- }, S = typeof window > "u";
324
- g("auBankAccount", S);
325
- g("card", S);
326
- g("cardNumber", S);
327
- g("cardExpiry", S);
328
- g("cardCvc", S);
329
- g("fpxBank", S);
330
- g("iban", S);
331
- g("idealBank", S);
332
- g("p24Bank", S);
333
- g("epsBank", S);
334
- var Ye = g("payment", S);
335
- g("paymentRequestButton", S);
336
- g("linkAuthentication", S);
337
- g("shippingAddress", S);
338
- g("affirmMessage", S);
339
- g("afterpayClearpayMessage", S);
340
- var j = {}, ae;
341
- function Ge() {
342
- if (ae) return j;
343
- ae = 1, Object.defineProperty(j, "__esModule", { value: !0 });
344
- function t(v) {
345
- "@babel/helpers - typeof";
346
- return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? t = function(o) {
347
- return typeof o;
348
- } : t = function(o) {
349
- return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
350
- }, t(v);
351
- }
352
- var e = "https://js.stripe.com/v3", r = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/, n = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used", s = function() {
353
- for (var o = document.querySelectorAll('script[src^="'.concat(e, '"]')), l = 0; l < o.length; l++) {
354
- var d = o[l];
355
- if (r.test(d.src))
356
- return d;
357
- }
358
- return null;
359
- }, i = function(o) {
360
- var l = o && !o.advancedFraudSignals ? "?advancedFraudSignals=false" : "", d = document.createElement("script");
361
- d.src = "".concat(e).concat(l);
362
- var b = document.head || document.body;
363
- if (!b)
364
- throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
365
- return b.appendChild(d), d;
366
- }, p = function(o, l) {
367
- !o || !o._registerWrapper || o._registerWrapper({
368
- name: "stripe-js",
369
- version: "1.35.0",
370
- startTime: l
371
- });
372
- }, u = null, a = function(o) {
373
- return u !== null || (u = new Promise(function(l, d) {
374
- if (typeof window > "u") {
375
- l(null);
376
- return;
377
- }
378
- if (window.Stripe && o && console.warn(n), window.Stripe) {
379
- l(window.Stripe);
380
- return;
381
- }
382
- try {
383
- var b = s();
384
- b && o ? console.warn(n) : b || (b = i(o)), b.addEventListener("load", function() {
385
- window.Stripe ? l(window.Stripe) : d(new Error("Stripe.js not available"));
386
- }), b.addEventListener("error", function() {
387
- d(new Error("Failed to load Stripe.js"));
388
- });
389
- } catch (x) {
390
- d(x);
391
- return;
392
- }
393
- })), u;
394
- }, f = function(o, l, d) {
395
- if (o === null)
396
- return null;
397
- var b = o.apply(void 0, l);
398
- return p(b, d), b;
399
- }, y = function(o) {
400
- var l = `invalid load parameters; expected object of shape
401
-
402
- {advancedFraudSignals: boolean}
403
-
404
- but received
405
-
406
- `.concat(JSON.stringify(o), `
407
- `);
408
- if (o === null || t(o) !== "object")
409
- throw new Error(l);
410
- if (Object.keys(o).length === 1 && typeof o.advancedFraudSignals == "boolean")
411
- return o;
412
- throw new Error(l);
413
- }, h, c = !1, O = function() {
414
- for (var o = arguments.length, l = new Array(o), d = 0; d < o; d++)
415
- l[d] = arguments[d];
416
- c = !0;
417
- var b = Date.now();
418
- return a(h).then(function(x) {
419
- return f(x, l, b);
420
- });
421
- };
422
- return O.setLoadParameters = function(v) {
423
- if (c)
424
- throw new Error("You cannot change load parameters after calling loadStripe");
425
- h = y(v);
426
- }, j.loadStripe = O, j;
427
- }
428
- var B, oe;
429
- function Ve() {
430
- return oe || (oe = 1, B = Ge()), B;
431
- }
432
- var Xe = Ve(), ze = {};
433
- const Je = ze.NEXT_PUBLIC_STRIPE_PUBLIC_KEY || "";
434
- let F;
435
- const Qe = (t) => (F || (F = Xe.loadStripe(t || Je)), F), Ze = (t) => {
436
- const { t: e, i18n: r } = se(), { paymentOption: n, elements: s, state: i, onPaymentElementChange: p } = t, [u, a] = L(!1), [f, y] = L(n !== "HOLD"), h = u || !f || ["processing", "error"].includes(i.status), c = { layout: "accordion" };
437
- return ie(() => {
438
- s == null || s.update({ locale: r.language });
439
- }, [s, r.language]), /* @__PURE__ */ V("form", { id: "payment-form", className: "bg-subtle mt-4 rounded-md p-6", onSubmit: t.onSubmit, children: [
440
- /* @__PURE__ */ _("div", { children: /* @__PURE__ */ _(Ye, { options: c, onChange: () => p() }) }),
441
- n === "HOLD" && /* @__PURE__ */ _("div", { className: "bg-cal-info mb-5 mt-2 rounded-md p-3", children: /* @__PURE__ */ _(
442
- we,
443
- {
444
- description: e("acknowledge_booking_no_show_fee", {
445
- amount: t.payment.amount / 100,
446
- formatParams: { amount: { currency: t.payment.currency } }
447
- }),
448
- onChange: (O) => y(O.target.checked),
449
- descriptionClassName: "text-info font-semibold"
450
- }
451
- ) }),
452
- /* @__PURE__ */ V("div", { className: "mt-2 flex justify-end space-x-2", children: [
453
- /* @__PURE__ */ _(
454
- X,
455
- {
456
- color: "minimal",
457
- disabled: h,
458
- id: "cancel",
459
- type: "button",
460
- loading: u,
461
- onClick: () => {
462
- a(!0), t.onCancel();
463
- },
464
- children: /* @__PURE__ */ _("span", { id: "button-text", children: e("cancel") })
465
- }
466
- ),
467
- /* @__PURE__ */ _(
468
- X,
469
- {
470
- type: "submit",
471
- disabled: h,
472
- loading: i.status === "processing",
473
- id: "submit",
474
- color: "secondary",
475
- children: /* @__PURE__ */ _("span", { id: "button-text", children: i.status === "processing" ? /* @__PURE__ */ _("div", { className: "spinner", id: "spinner" }) : e(n === "HOLD" ? "submit_card" : "pay_now") })
476
- }
477
- )
478
- ] }),
479
- i.status === "error" && /* @__PURE__ */ _("div", { className: "mt-4 text-center text-red-900 dark:text-gray-300", role: "alert", children: i.error.message })
480
- ] });
481
- }, et = (t) => {
482
- const { t: e } = se(), r = Me(), n = t.payment.paymentOption;
483
- t.booking.attendees[0].email;
484
- const s = He(), [i, p] = L({ status: "idle" });
485
- return /* @__PURE__ */ _(
486
- Ze,
487
- {
488
- ...t,
489
- elements: r,
490
- paymentOption: n,
491
- state: i,
492
- onSubmit: async (u) => {
493
- var y;
494
- if (u.preventDefault(), !s || !r)
495
- return;
496
- p({ status: "processing" });
497
- let a;
498
- const f = {
499
- uid: t.booking.uid
500
- };
501
- n === "HOLD" && "setupIntent" in t.payment.data ? (a = await s.confirmSetup({
502
- elements: r,
503
- redirect: "if_required"
504
- }), a.setupIntent && (f.payment_intent = a.setupIntent.id, f.payment_intent_client_secret = a.setupIntent.client_secret || void 0, f.redirect_status = a.setupIntent.status)) : n === "ON_BOOKING" && (a = await s.confirmPayment({
505
- elements: r,
506
- redirect: "if_required",
507
- confirmParams: {
508
- return_url: `${Re}/booking/${f.uid}`
509
- }
510
- }), a.paymentIntent && (f.payment_intent = a.paymentIntent.id, f.payment_intent_client_secret = a.paymentIntent.client_secret || void 0, f.redirect_status = a.paymentIntent.status)), a != null && a.error ? p({
511
- status: "error",
512
- error: new Error(`Payment failed: ${a.error.message}`)
513
- }) : (p({ status: "idle" }), (y = t.onPaymentSuccess) == null || y.call(t, t), t.location && (t.location.includes("integration") ? f.location = e("web_conferencing_details_to_follow") : f.location = t.location));
514
- },
515
- onCancel: () => {
516
- var u;
517
- (u = t.onPaymentCancellation) == null || u.call(t, t);
518
- },
519
- onPaymentElementChange: () => {
520
- p({ status: "idle" });
521
- }
522
- }
523
- );
524
- }, at = (t) => {
525
- const e = Qe(t.payment.data.stripe_publishable_key), [r, n] = L("stripe");
526
- return ie(() => {
527
- document.documentElement.classList.contains("dark") && n("night");
528
- }, []), /* @__PURE__ */ _(
529
- le,
530
- {
531
- stripe: e,
532
- options: {
533
- clientSecret: t.clientSecret,
534
- appearance: {
535
- theme: r
536
- }
537
- },
538
- children: /* @__PURE__ */ _(et, { ...t })
539
- }
540
- );
541
- };
542
- export {
543
- at as default
544
- };