@paynext/sdk 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -175,7 +175,7 @@ let Wi = class {
175
175
  });
176
176
  }
177
177
  };
178
- class de {
178
+ class ue {
179
179
  constructor() {
180
180
  _(this, "listeners", []);
181
181
  }
@@ -217,7 +217,7 @@ class Yi {
217
217
  _(this, "google", null);
218
218
  _(this, "threeDs", null);
219
219
  _(this, "events", {
220
- ready: new de()
220
+ ready: new ue()
221
221
  });
222
222
  }
223
223
  // is should load
@@ -342,7 +342,7 @@ function ta(r, t) {
342
342
  function ra(r, t) {
343
343
  return r.at === t.at ? r.value === null ? 1 : t.value === null ? -1 : 0 : r.at - t.at;
344
344
  }
345
- const he = (r) => !!(r && r.getVelocity), ar = /* @__NO_SIDE_EFFECTS__ */ (r, t, e) => {
345
+ const fe = (r) => !!(r && r.getVelocity), ar = /* @__NO_SIDE_EFFECTS__ */ (r, t, e) => {
346
346
  const n = t - r;
347
347
  return n === 0 ? 1 : (e - r) / n;
348
348
  };
@@ -438,7 +438,7 @@ function aa(r, i = {}, n, a) {
438
438
  const x = w + g;
439
439
  ea(S, G, C, j, w, x), k = Math.max(P + g, k), f = Math.max(x, f);
440
440
  };
441
- if (he(y)) {
441
+ if (fe(y)) {
442
442
  const L = Lr(y, c);
443
443
  I(T, N, Pr("default", L));
444
444
  } else {
@@ -849,7 +849,7 @@ function Ea(r, t) {
849
849
  }
850
850
  }
851
851
  function Ca(r) {
852
- return !!(he(r) && r.add);
852
+ return !!(fe(r) && r.add);
853
853
  }
854
854
  function _a(r, t) {
855
855
  const e = r.getValue("willChange");
@@ -966,7 +966,7 @@ const jt = {
966
966
  test: /* @__PURE__ */ ur("hsl", "hue"),
967
967
  parse: /* @__PURE__ */ jn("hue", "saturation", "lightness"),
968
968
  transform: ({ hue: r, saturation: t, lightness: e, alpha: n = 1 }) => "hsla(" + Math.round(r) + ", " + Ue.transform(rt(t)) + ", " + Ue.transform(rt(e)) + ", " + rt(st.transform(n)) + ")"
969
- }, ue = {
969
+ }, pe = {
970
970
  test: (r) => Le.test(r) || jt.test(r) || Ve.test(r),
971
971
  parse: (r) => Le.test(r) ? Le.parse(r) : Ve.test(r) ? Ve.parse(r) : jt.parse(r),
972
972
  transform: (r) => typeof r == "string" ? r : r.hasOwnProperty("red") ? Le.transform(r) : Ve.transform(r)
@@ -983,7 +983,7 @@ function ot(r) {
983
983
  var: []
984
984
  }, a = [];
985
985
  let i = 0;
986
- const s = t.replace(qa, (l) => (ue.test(l) ? (n.color.push(i), a.push(Kn), e.push(ue.parse(l))) : l.startsWith(Wa) ? (n.var.push(i), a.push(Ha), e.push(l)) : (n.number.push(i), a.push(Bn), e.push(parseFloat(l))), ++i, Vr)).split(Vr);
986
+ const s = t.replace(qa, (l) => (pe.test(l) ? (n.color.push(i), a.push(Kn), e.push(pe.parse(l))) : l.startsWith(Wa) ? (n.var.push(i), a.push(Ha), e.push(l)) : (n.number.push(i), a.push(Bn), e.push(parseFloat(l))), ++i, Vr)).split(Vr);
987
987
  return { values: e, split: s, indexes: n, types: a };
988
988
  }
989
989
  function Hn(r) {
@@ -996,7 +996,7 @@ function Wn(r) {
996
996
  for (let o = 0; o < n; o++)
997
997
  if (i += t[o], a[o] !== void 0) {
998
998
  const s = e[o];
999
- s === Bn ? i += rt(a[o]) : s === Kn ? i += ue.transform(a[o]) : i += a[o];
999
+ s === Bn ? i += rt(a[o]) : s === Kn ? i += pe.transform(a[o]) : i += a[o];
1000
1000
  }
1001
1001
  return i;
1002
1002
  };
@@ -1060,7 +1060,7 @@ function es(r, t) {
1060
1060
  return (e) => ct(r, t, e);
1061
1061
  }
1062
1062
  function hr(r) {
1063
- return typeof r == "number" ? es : typeof r == "string" ? cr(r) ? At : ue.test(r) ? Ur : ns : Array.isArray(r) ? qn : typeof r == "object" ? ue.test(r) ? Ur : ts : At;
1063
+ return typeof r == "number" ? es : typeof r == "string" ? cr(r) ? At : pe.test(r) ? Ur : ns : Array.isArray(r) ? qn : typeof r == "object" ? pe.test(r) ? Ur : ts : At;
1064
1064
  }
1065
1065
  function qn(r, t) {
1066
1066
  const e = [...r], n = e.length, a = r.map((i, o) => hr(i)(i, t[o]));
@@ -2180,9 +2180,9 @@ function po(r) {
2180
2180
  function ho(r, t, e) {
2181
2181
  for (const n in t) {
2182
2182
  const a = t[n], i = e[n];
2183
- if (he(a))
2183
+ if (fe(a))
2184
2184
  r.addValue(n, a);
2185
- else if (he(i))
2185
+ else if (fe(i))
2186
2186
  r.addValue(n, at(a, { owner: r }));
2187
2187
  else if (i !== a)
2188
2188
  if (r.hasValue(n)) {
@@ -2200,7 +2200,7 @@ function ho(r, t, e) {
2200
2200
  const vi = (r) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(r), gi = (r) => /^0[^.\s]+$/u.test(r), fo = {
2201
2201
  test: (r) => r === "auto",
2202
2202
  parse: (r) => r
2203
- }, yi = (r) => (t) => t.test(r), bi = [We, Z, Ue, ke, ja, za, fo], Xr = (r) => bi.find(yi(r)), mo = [...bi, ue, qe], vo = (r) => mo.find(yi(r)), go = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
2203
+ }, yi = (r) => (t) => t.test(r), bi = [We, Z, Ue, ke, ja, za, fo], Xr = (r) => bi.find(yi(r)), mo = [...bi, pe, qe], vo = (r) => mo.find(yi(r)), go = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
2204
2204
  function yo(r) {
2205
2205
  const [t, e] = r.slice(0, -1).split("(");
2206
2206
  if (t === "drop-shadow")
@@ -2288,17 +2288,17 @@ const bo = /\b([a-z-]*)\(.*?\)/gu, er = ee(K({}, qe), {
2288
2288
  numOctaves: Jr
2289
2289
  }), Co = ee(K({}, _r), {
2290
2290
  // Color props
2291
- color: ue,
2292
- backgroundColor: ue,
2293
- outlineColor: ue,
2294
- fill: ue,
2295
- stroke: ue,
2291
+ color: pe,
2292
+ backgroundColor: pe,
2293
+ outlineColor: pe,
2294
+ fill: pe,
2295
+ stroke: pe,
2296
2296
  // Border props
2297
- borderColor: ue,
2298
- borderTopColor: ue,
2299
- borderRightColor: ue,
2300
- borderBottomColor: ue,
2301
- borderLeftColor: ue,
2297
+ borderColor: pe,
2298
+ borderTopColor: pe,
2299
+ borderRightColor: pe,
2300
+ borderBottomColor: pe,
2301
+ borderLeftColor: pe,
2302
2302
  filter: er,
2303
2303
  WebkitFilter: er
2304
2304
  }), Ei = (r) => Co[r];
@@ -2338,7 +2338,7 @@ class _i {
2338
2338
  const h = this.scrapeMotionValuesFromProps(e, {}, this), { willChange: d } = h, u = Ee(h, ["willChange"]);
2339
2339
  for (const p in u) {
2340
2340
  const f = u[p];
2341
- l[p] !== void 0 && he(f) && f.set(l[p], !1);
2341
+ l[p] !== void 0 && fe(f) && f.set(l[p], !1);
2342
2342
  }
2343
2343
  }
2344
2344
  mount(t) {
@@ -2477,7 +2477,7 @@ class _i {
2477
2477
  readValue(t, e) {
2478
2478
  var a;
2479
2479
  let n = this.latestValues[t] !== void 0 || !this.current ? this.latestValues[t] : (a = this.getBaseTargetFromProps(this.props, t)) != null ? a : this.readValueFromInstance(this.current, t, this.options);
2480
- return n != null && (typeof n == "string" && (vi(n) || gi(n)) ? n = parseFloat(n) : !vo(n) && qe.test(e) && (n = Ci(t, e)), this.setBaseTarget(t, he(n) ? n.get() : n)), he(n) ? n.get() : n;
2480
+ return n != null && (typeof n == "string" && (vi(n) || gi(n)) ? n = parseFloat(n) : !vo(n) && qe.test(e) && (n = Ci(t, e)), this.setBaseTarget(t, fe(n) ? n.get() : n)), fe(n) ? n.get() : n;
2481
2481
  }
2482
2482
  /**
2483
2483
  * Set the base target to later animate back to. This is currently
@@ -2501,7 +2501,7 @@ class _i {
2501
2501
  if (e && n !== void 0)
2502
2502
  return n;
2503
2503
  const a = this.getBaseTargetFromProps(this.props, t);
2504
- return a !== void 0 && !he(a) ? a : this.initialValues[t] !== void 0 && n === void 0 ? void 0 : this.baseTarget[t];
2504
+ return a !== void 0 && !fe(a) ? a : this.initialValues[t] !== void 0 && n === void 0 ? void 0 : this.baseTarget[t];
2505
2505
  }
2506
2506
  on(t, e) {
2507
2507
  return this.events[t] || (this.events[t] = new Mn()), this.events[t].add(e);
@@ -2618,7 +2618,7 @@ class Ti extends _i {
2618
2618
  handleChildMotionValue() {
2619
2619
  this.childSubscription && (this.childSubscription(), delete this.childSubscription);
2620
2620
  const { children: t } = this.props;
2621
- he(t) && (this.childSubscription = t.on("change", (e) => {
2621
+ fe(t) && (this.childSubscription = t.on("change", (e) => {
2622
2622
  this.current && (this.current.textContent = `${e}`);
2623
2623
  }));
2624
2624
  }
@@ -2682,7 +2682,7 @@ function Oi(r, t, e) {
2682
2682
  var i;
2683
2683
  const { style: n } = r, a = {};
2684
2684
  for (const o in n)
2685
- (he(n[o]) || t.style && he(t.style[o]) || Ro(o, r) || ((i = e == null ? void 0 : e.getValue(o)) == null ? void 0 : i.liveStyle) !== void 0) && (a[o] = n[o]);
2685
+ (fe(n[o]) || t.style && fe(t.style[o]) || Ro(o, r) || ((i = e == null ? void 0 : e.getValue(o)) == null ? void 0 : i.liveStyle) !== void 0) && (a[o] = n[o]);
2686
2686
  return a;
2687
2687
  }
2688
2688
  function So(r) {
@@ -2815,7 +2815,7 @@ function Ko(r, t, e, n) {
2815
2815
  function Ho(r, t, e) {
2816
2816
  const n = Oi(r, t, e);
2817
2817
  for (const a in r)
2818
- if (he(r[a]) || he(t[a])) {
2818
+ if (fe(r[a]) || fe(t[a])) {
2819
2819
  const i = Ke.indexOf(a) !== -1 ? "attr" + a.charAt(0).toUpperCase() + a.substring(1) : a;
2820
2820
  n[i] = r[a];
2821
2821
  }
@@ -2885,11 +2885,11 @@ function Yo(r) {
2885
2885
  e.mount(r), it.set(r, e);
2886
2886
  }
2887
2887
  function $o(r, t, e) {
2888
- const n = he(r) ? r : at(r);
2888
+ const n = fe(r) ? r : at(r);
2889
2889
  return n.start(pi("", n, t, e)), n.animation;
2890
2890
  }
2891
2891
  function Qo(r, t) {
2892
- return he(r) || typeof r == "number" || typeof r == "string" && !ir(t);
2892
+ return fe(r) || typeof r == "number" || typeof r == "string" && !ir(t);
2893
2893
  }
2894
2894
  function Li(r, t, e, n) {
2895
2895
  const a = [];
@@ -3043,7 +3043,7 @@ class hl {
3043
3043
  return this.loader;
3044
3044
  }
3045
3045
  }
3046
- const fl = "_checkout_5sq3n_1", ml = "_hidden_5sq3n_7", vl = "_formInitial_5sq3n_11", gl = "_btnsInitial_5sq3n_16", me = {
3046
+ const fl = "_checkout_5sq3n_1", ml = "_hidden_5sq3n_7", vl = "_formInitial_5sq3n_11", gl = "_btnsInitial_5sq3n_16", ve = {
3047
3047
  checkout: fl,
3048
3048
  hidden: ml,
3049
3049
  formInitial: vl,
@@ -3537,7 +3537,7 @@ const Tt = [
3537
3537
  error: ce.Invalid
3538
3538
  };
3539
3539
  };
3540
- var re = /* @__PURE__ */ ((r) => (r.PAYPAL = "PAYPAL", r.APPLE_PAY = "APPLEPAY", r.GOOGLE_PAY = "GPAY", r.CARD = "CARD", r.VENMO = "VENMO", r))(re || {}), tr = /* @__PURE__ */ ((r) => (r.PENDING = "PENDING", r.FAILED = "FAILED", r.AUTHORIZED = "AUTHORIZED", r.SETTLING = "SETTLING", r.SETTLED = "SETTLED", r.DECLINED = "DECLINED", r.CANCELLED = "CANCELLED", r))(tr || {}), ve = /* @__PURE__ */ ((r) => (r.INSUFFICIENT_FUNDS = "insufficient_funds", r.AUTHENTICATION_REQUIRED = "authentication_required", r.CARD_ISSUER_DECLINE = "card_issuer_decline", r.GENERIC_DECLINE = "generic_decline", r.WITHDRAWAL_LIMIT_EXCEEDED = "withdrawal_limit_exceeded", r.DO_NOT_HONOR = "do_not_honor", r.EXPIRED_CARD = "expired_card", r.SUSPECTED_FRAUD = "suspected_fraud", r.INCORRECT_CVC = "incorrect_cvc", r.INVALID_CARD_NUMBER = "invalid_card_number", r.ISSUER_UNAVAILABLE = "issuer_unavailable", r.CARD_LOST_OR_STOLEN = "card_lost_or_stolen", r.CARD_DECLINED = "card_declined", r))(ve || {});
3540
+ var re = /* @__PURE__ */ ((r) => (r.PAYPAL = "PAYPAL", r.APPLE_PAY = "APPLEPAY", r.GOOGLE_PAY = "GPAY", r.CARD = "CARD", r.VENMO = "VENMO", r))(re || {}), tr = /* @__PURE__ */ ((r) => (r.PENDING = "PENDING", r.FAILED = "FAILED", r.AUTHORIZED = "AUTHORIZED", r.SETTLING = "SETTLING", r.SETTLED = "SETTLED", r.DECLINED = "DECLINED", r.CANCELLED = "CANCELLED", r))(tr || {}), de = /* @__PURE__ */ ((r) => (r.INSUFFICIENT_FUNDS = "insufficient_funds", r.AUTHENTICATION_REQUIRED = "authentication_required", r.CARD_ISSUER_DECLINE = "card_issuer_decline", r.GENERIC_DECLINE = "generic_decline", r.WITHDRAWAL_LIMIT_EXCEEDED = "withdrawal_limit_exceeded", r.DO_NOT_HONOR = "do_not_honor", r.EXPIRED_CARD = "expired_card", r.SUSPECTED_FRAUD = "suspected_fraud", r.INCORRECT_CVC = "incorrect_cvc", r.INVALID_CARD_NUMBER = "invalid_card_number", r.ISSUER_UNAVAILABLE = "issuer_unavailable", r.CARD_LOST_OR_STOLEN = "card_lost_or_stolen", r.CARD_DECLINED = "card_declined", r))(de || {});
3541
3541
  const Tr = (r = "sandbox") => ({
3542
3542
  develop: "https://dev-api.paynext.com",
3543
3543
  staging: "https://staging-api.paynext.com",
@@ -4199,19 +4199,19 @@ const ec = [
4199
4199
  const t = r.errors;
4200
4200
  return {
4201
4201
  // DeclineCode enum mapping (keys are API decline_code values)
4202
- [ve.INSUFFICIENT_FUNDS]: t == null ? void 0 : t.insufficientFunds,
4203
- [ve.AUTHENTICATION_REQUIRED]: t == null ? void 0 : t.cardholderAuthenticationRequired,
4204
- [ve.CARD_ISSUER_DECLINE]: t == null ? void 0 : t.declined,
4205
- [ve.GENERIC_DECLINE]: t == null ? void 0 : t.declined,
4206
- [ve.WITHDRAWAL_LIMIT_EXCEEDED]: t == null ? void 0 : t.limitExceeded,
4207
- [ve.DO_NOT_HONOR]: t == null ? void 0 : t.doNotHonor,
4208
- [ve.EXPIRED_CARD]: t == null ? void 0 : t.expiredCard,
4209
- [ve.SUSPECTED_FRAUD]: t == null ? void 0 : t.processorDeclinedFraudSuspected,
4210
- [ve.INCORRECT_CVC]: (t == null ? void 0 : t.invalidSecurePaymentData) || (t == null ? void 0 : t.invalidCreditCardNumber),
4211
- [ve.INVALID_CARD_NUMBER]: t == null ? void 0 : t.invalidCreditCardNumber,
4212
- [ve.ISSUER_UNAVAILABLE]: t == null ? void 0 : t.offlineIssuerDeclined,
4213
- [ve.CARD_LOST_OR_STOLEN]: t == null ? void 0 : t.cardReportedAsLostOrStolen,
4214
- [ve.CARD_DECLINED]: t == null ? void 0 : t.declined,
4202
+ [de.INSUFFICIENT_FUNDS]: t == null ? void 0 : t.insufficientFunds,
4203
+ [de.AUTHENTICATION_REQUIRED]: t == null ? void 0 : t.cardholderAuthenticationRequired,
4204
+ [de.CARD_ISSUER_DECLINE]: t == null ? void 0 : t.declined,
4205
+ [de.GENERIC_DECLINE]: t == null ? void 0 : t.declined,
4206
+ [de.WITHDRAWAL_LIMIT_EXCEEDED]: t == null ? void 0 : t.limitExceeded,
4207
+ [de.DO_NOT_HONOR]: t == null ? void 0 : t.doNotHonor,
4208
+ [de.EXPIRED_CARD]: t == null ? void 0 : t.expiredCard,
4209
+ [de.SUSPECTED_FRAUD]: t == null ? void 0 : t.processorDeclinedFraudSuspected,
4210
+ [de.INCORRECT_CVC]: (t == null ? void 0 : t.invalidSecurePaymentData) || (t == null ? void 0 : t.invalidCreditCardNumber),
4211
+ [de.INVALID_CARD_NUMBER]: t == null ? void 0 : t.invalidCreditCardNumber,
4212
+ [de.ISSUER_UNAVAILABLE]: t == null ? void 0 : t.offlineIssuerDeclined,
4213
+ [de.CARD_LOST_OR_STOLEN]: t == null ? void 0 : t.cardReportedAsLostOrStolen,
4214
+ [de.CARD_DECLINED]: t == null ? void 0 : t.declined,
4215
4215
  errorText: t == null ? void 0 : t.errorText,
4216
4216
  "Frame closed before tokenization could occur.": t == null ? void 0 : t.venmoClosed,
4217
4217
  "Window is closed, can not determine type": t == null ? void 0 : t.paypalClosed,
@@ -4231,7 +4231,7 @@ class tc {
4231
4231
  constructor(t) {
4232
4232
  _(this, "element");
4233
4233
  _(this, "events", {
4234
- ready: new de()
4234
+ ready: new ue()
4235
4235
  });
4236
4236
  _(this, "ev");
4237
4237
  _(this, "customButtonStyles");
@@ -4303,7 +4303,7 @@ const rc = [
4303
4303
  open: { y: 0, opacity: 1 },
4304
4304
  close: { y: -100, opacity: 0 },
4305
4305
  transition: { duration: 0.25, type: "spring", bounce: 0 }
4306
- }, pe = {
4306
+ }, he = {
4307
4307
  open: { y: 0, opacity: 1 },
4308
4308
  close: { y: 15, opacity: 0 },
4309
4309
  transition: { duration: 0.25, type: "spring", bounce: 0 }
@@ -4319,7 +4319,7 @@ class ac {
4319
4319
  constructor(t) {
4320
4320
  _(this, "element");
4321
4321
  _(this, "events", {
4322
- ready: new de()
4322
+ ready: new ue()
4323
4323
  });
4324
4324
  _(this, "ev");
4325
4325
  _(this, "customButtonStyles");
@@ -4382,7 +4382,7 @@ class lc {
4382
4382
  constructor(t) {
4383
4383
  _(this, "element");
4384
4384
  _(this, "events", {
4385
- ready: new de()
4385
+ ready: new ue()
4386
4386
  });
4387
4387
  _(this, "paypal");
4388
4388
  _(this, "customButtonStyles");
@@ -4393,45 +4393,68 @@ class lc {
4393
4393
  // init
4394
4394
  init(t) {
4395
4395
  return q(this, null, function* () {
4396
- var o, s, l;
4397
- if (!this.config) return !1;
4396
+ var o, s;
4397
+ if (!this.config)
4398
+ return !1;
4398
4399
  const e = this.config.state.transaction.getState(), n = this.config.state.checkout.getState(), a = () => q(this, null, function* () {
4399
- return yield jl(n.clientToken, n.environment, n.apiVersion);
4400
+ try {
4401
+ return yield jl(n.clientToken, n.environment, n.apiVersion);
4402
+ } catch (l) {
4403
+ throw l;
4404
+ }
4400
4405
  });
4401
4406
  if (!e || Object.keys(e).length === 0)
4402
4407
  return console.error("PayPal transaction data is empty or invalid"), !1;
4403
- yield this.paypal.init({
4404
- clientId: ((o = e == null ? void 0 : e.paypal_info) == null ? void 0 : o.client_id) || "",
4405
- environment: ((s = e == null ? void 0 : e.paypal_info) == null ? void 0 : s.environment) || "sandbox",
4406
- vault: !0,
4407
- locale: Yl(this.config.state.translate.locale())
4408
- });
4408
+ if (!((o = e == null ? void 0 : e.paypal_info) != null && o.client_id))
4409
+ return !1;
4410
+ try {
4411
+ if (yield this.paypal.init({
4412
+ clientId: e.paypal_info.client_id,
4413
+ environment: e.paypal_info.environment || "sandbox",
4414
+ vault: !0,
4415
+ locale: Yl(this.config.state.translate.locale())
4416
+ }), !this.paypal.isLoaded())
4417
+ return !1;
4418
+ } catch (l) {
4419
+ return !1;
4420
+ }
4409
4421
  const i = t ? ee(K({}, t), {
4410
- onError: (c) => {
4411
- var f, m;
4422
+ onError: (l) => {
4423
+ var p, f;
4412
4424
  if (!this.isInitialized) {
4413
- console.error("PayPal error:", c);
4425
+ console.error("PayPal error:", l);
4414
4426
  return;
4415
4427
  }
4416
- const d = this.config.state.translate.messages(), u = je(c, d), h = xe(d)[u], p = ((f = this.config.state.translate.messages().errors) == null ? void 0 : f.errorText) || "Error";
4417
- this.error.setMessage(`PayPal ${p.toLowerCase()}: ${h != null ? h : u}`), this.error.render().style.display = "", (m = t.onError) == null || m.call(t, c);
4428
+ const c = this.config.state.translate.messages(), d = je(l, c), u = xe(c)[d], h = ((p = this.config.state.translate.messages().errors) == null ? void 0 : p.errorText) || "Error";
4429
+ this.error.setMessage(`PayPal ${h.toLowerCase()}: ${u != null ? u : d}`), this.error.render().style.display = "", (f = t.onError) == null || f.call(t, l);
4418
4430
  },
4419
4431
  onCancel: t.onCancel,
4420
- onSuccess: (c) => {
4421
- var d;
4422
- this.error.render().style.display = "none", (d = t.onSuccess) == null || d.call(t, c);
4432
+ onSuccess: (l) => {
4433
+ var c;
4434
+ this.error.render().style.display = "none", (c = t.onSuccess) == null || c.call(t, l);
4423
4435
  }
4424
4436
  }) : void 0;
4425
- return yield this.paypal.render(this.element, ee(K({}, i), {
4426
- createBillingAgreement: a,
4427
- onApprove: (d) => q(this, [d], function* ({ billingToken: c }) {
4428
- var u;
4429
- (u = i == null ? void 0 : i.onSuccess) == null || u.call(i, c || "");
4430
- }),
4431
- style: (l = this.customButtonStyles) == null ? void 0 : l.styles,
4432
- onCancel: i == null ? void 0 : i.onCancel,
4433
- onError: i == null ? void 0 : i.onError
4434
- })), this.element.addEventListener("click", () => _e.hideAll()), this.element.append(this.error.render()), this.element.classList.remove(Mt.hidden), this.isInitialized = !0, this.events.ready.emit(), !0;
4437
+ try {
4438
+ yield this.paypal.render(this.element, ee(K({}, i), {
4439
+ createBillingAgreement: a,
4440
+ onApprove: (c) => q(this, [c], function* ({ billingToken: l }) {
4441
+ var d;
4442
+ (d = i == null ? void 0 : i.onSuccess) == null || d.call(i, l || "");
4443
+ }),
4444
+ style: (s = this.customButtonStyles) == null ? void 0 : s.styles,
4445
+ onCancel: () => {
4446
+ var l;
4447
+ (l = i == null ? void 0 : i.onCancel) == null || l.call(i);
4448
+ },
4449
+ onError: (l) => {
4450
+ var c;
4451
+ (c = i == null ? void 0 : i.onError) == null || c.call(i, l);
4452
+ }
4453
+ }));
4454
+ } catch (l) {
4455
+ return !1;
4456
+ }
4457
+ return this.element.addEventListener("click", () => _e.hideAll()), this.element.append(this.error.render()), this.element.classList.remove(Mt.hidden), this.isInitialized = !0, this.events.ready.emit(), !0;
4435
4458
  });
4436
4459
  }
4437
4460
  // add event listener
@@ -4517,7 +4540,7 @@ class yc {
4517
4540
  _(this, "container");
4518
4541
  _(this, "venmoButton");
4519
4542
  _(this, "events", {
4520
- ready: new de()
4543
+ ready: new ue()
4521
4544
  });
4522
4545
  _(this, "braintree");
4523
4546
  _(this, "error");
@@ -4532,17 +4555,17 @@ class yc {
4532
4555
  var n;
4533
4556
  if (!this.config) return !1;
4534
4557
  const e = this.config.state.transaction.getState();
4535
- if (console.log("----- init braintree venmo: ", e), !e || Object.keys(e).length === 0)
4536
- return console.error("Braintree Venmo transaction data is empty or invalid"), !1;
4558
+ if (!e || Object.keys(e).length === 0)
4559
+ return !1;
4537
4560
  try {
4538
4561
  return yield this.braintree.init({
4539
4562
  authorization: ((n = e == null ? void 0 : e.brain_tree_info) == null ? void 0 : n.client_token) || ""
4540
4563
  }), yield this.braintree.createVenmo({
4541
4564
  // ToDo: update before release
4542
4565
  // deepLinkReturnUrl: checkout?.returnUrl,
4543
- }), this.braintree.isBrowserSupported() ? (this.displayVenmoButton(t), this.braintree.hasTokenizationResult() ? (yield this.handleExistingTokenization(t), !1) : (this.venmoButton.classList.remove(bt.hidden), this.container.append(this.error.render()), this.isInitialized = !0, this.events.ready.emit(), !0)) : (console.log("Browser does not support Venmo"), this.handleVenmoError(new Error("Browser does not support Venmo")), !1);
4566
+ }), this.braintree.isBrowserSupported() ? (this.displayVenmoButton(t), this.braintree.hasTokenizationResult() ? (yield this.handleExistingTokenization(t), !1) : (this.venmoButton.classList.remove(bt.hidden), this.container.append(this.error.render()), this.isInitialized = !0, this.events.ready.emit(), !0)) : (this.handleVenmoError(new Error("Browser does not support Venmo")), !1);
4544
4567
  } catch (a) {
4545
- return console.error("Error initializing Venmo:", a), this.handleVenmoError(a), !1;
4568
+ return this.handleVenmoError(a), !1;
4546
4569
  }
4547
4570
  });
4548
4571
  }
@@ -4576,13 +4599,12 @@ class yc {
4576
4599
  // handle successful venmo payment
4577
4600
  handleVenmoSuccess(t, e) {
4578
4601
  var n;
4579
- console.log("Venmo payment successful:", t), this.error.render().style.display = "none", (n = e.onSuccess) == null || n.call(e, t);
4602
+ this.error.render().style.display = "none", (n = e.onSuccess) == null || n.call(e, t);
4580
4603
  }
4581
4604
  // handle venmo errors
4582
4605
  handleVenmoError(t, e) {
4583
4606
  var s, l;
4584
- if (console.error("Venmo error:", t), !this.isInitialized)
4585
- return;
4607
+ if (!this.isInitialized) return;
4586
4608
  const n = this.config.state.translate.messages(), a = je(t, n), i = xe(n)[a], o = ((s = n.errors) == null ? void 0 : s.errorText) || "Error";
4587
4609
  this.error.setMessage(`Venmo ${o.toLowerCase()}: ${i != null ? i : a}`), this.error.render().style.display = "", (l = e == null ? void 0 : e.onError) == null || l.call(e, t);
4588
4610
  }
@@ -4592,10 +4614,7 @@ class yc {
4592
4614
  }
4593
4615
  showExternalError(t) {
4594
4616
  var i;
4595
- if (!this.isInitialized) {
4596
- console.error("Venmo error:", t);
4597
- return;
4598
- }
4617
+ if (!this.isInitialized) return;
4599
4618
  const e = this.config.state.translate.messages(), n = xe(e)[t], a = ((i = e.errors) == null ? void 0 : i.errorText) || "Error";
4600
4619
  this.error.setMessage(`Venmo ${a.toLowerCase()}: ${n != null ? n : t}`), this.error.render().style.display = "";
4601
4620
  }
@@ -4618,11 +4637,11 @@ class bc {
4618
4637
  _(this, "braintree");
4619
4638
  _(this, "lastInteracted", null);
4620
4639
  _(this, "events", {
4621
- ready: new de(),
4622
- open: new de(),
4623
- error: new de(),
4624
- cancel: new de(),
4625
- success: new de()
4640
+ ready: new ue(),
4641
+ open: new ue(),
4642
+ error: new ue(),
4643
+ cancel: new ue(),
4644
+ success: new ue()
4626
4645
  });
4627
4646
  this.config = t, this.buttons = document.createElement("div"), this.buttons.classList.add(Pt.buttons, Pt.hidden);
4628
4647
  }
@@ -4686,15 +4705,16 @@ class bc {
4686
4705
  if (this.paypal) {
4687
4706
  this.isPayPalReady = !1;
4688
4707
  try {
4689
- (yield this.paypal.init({
4690
- onError: (n) => this.events.error.emit(n),
4708
+ const e = this.paypal.render();
4709
+ t == null || t.appendChild(e), (yield this.paypal.init({
4710
+ onError: (a) => this.events.error.emit(a),
4691
4711
  onCancel: () => this.events.cancel.emit(),
4692
- onSuccess: (n) => {
4693
- this.lastInteracted = "paypal", this.events.success.emit({ paypalId: n, type: "paypal" });
4712
+ onSuccess: (a) => {
4713
+ this.lastInteracted = "paypal", this.events.success.emit({ paypalId: a, type: "paypal" });
4694
4714
  }
4695
- })) ? t == null || t.appendChild(this.paypal.render()) : t == null || t.remove();
4715
+ })) || t == null || t.remove();
4696
4716
  } catch (e) {
4697
- console.error(e), t == null || t.remove();
4717
+ t == null || t.remove();
4698
4718
  } finally {
4699
4719
  this.isPayPalReady = !0;
4700
4720
  }
@@ -4900,7 +4920,7 @@ class Bc {
4900
4920
  _(this, "isDisabled", !1);
4901
4921
  _(this, "isChanged", !1);
4902
4922
  _(this, "events", {
4903
- change: new de()
4923
+ change: new ue()
4904
4924
  });
4905
4925
  var a, i, o, s, l, c, d, u, h;
4906
4926
  const n = t.messages();
@@ -4924,10 +4944,10 @@ class Bc {
4924
4944
  toggleLabelError(t) {
4925
4945
  return q(this, null, function* () {
4926
4946
  if (t) {
4927
- this.inputContainer.classList.add(oe.errorInput), this.endContent.classList.remove(oe.hidden), this.labelError.classList.remove(oe.hidden), yield le(this.labelError, pe.open, pe.transition);
4947
+ this.inputContainer.classList.add(oe.errorInput), this.endContent.classList.remove(oe.hidden), this.labelError.classList.remove(oe.hidden), yield le(this.labelError, he.open, he.transition);
4928
4948
  return;
4929
4949
  }
4930
- this.inputContainer.classList.remove(oe.errorInput), this.endContent.classList.add(oe.hidden), yield le(this.labelError, pe.close, pe.transition), this.labelError.classList.add(oe.hidden);
4950
+ this.inputContainer.classList.remove(oe.errorInput), this.endContent.classList.add(oe.hidden), yield le(this.labelError, he.close, he.transition), this.labelError.classList.add(oe.hidden);
4931
4951
  });
4932
4952
  }
4933
4953
  addEventListener(t, e) {
@@ -5316,7 +5336,7 @@ class ld {
5316
5336
  _(this, "isDisabled", !1);
5317
5337
  _(this, "isChanged", !1);
5318
5338
  _(this, "events", {
5319
- change: new de()
5339
+ change: new ue()
5320
5340
  });
5321
5341
  var a, i, o, s, l, c, d, u, h;
5322
5342
  this.translate = t;
@@ -5367,10 +5387,10 @@ ${m}::-ms-input-placeholder{${f}}
5367
5387
  toggleLabelError(t) {
5368
5388
  return q(this, null, function* () {
5369
5389
  if (t) {
5370
- this.inputContainer.classList.add(ie.errorInput), this.labelError.classList.remove(ie.hidden), yield le(this.labelError, pe.open, pe.transition);
5390
+ this.inputContainer.classList.add(ie.errorInput), this.labelError.classList.remove(ie.hidden), yield le(this.labelError, he.open, he.transition);
5371
5391
  return;
5372
5392
  }
5373
- yield le(this.labelError, pe.close, pe.transition), this.labelError.classList.add(ie.hidden);
5393
+ yield le(this.labelError, he.close, he.transition), this.labelError.classList.add(ie.hidden);
5374
5394
  });
5375
5395
  }
5376
5396
  toggleErrorMessage(t) {
@@ -5504,8 +5524,8 @@ class Cd {
5504
5524
  _(this, "isCvcRequired", !1);
5505
5525
  _(this, "isCvcChanged", !1);
5506
5526
  _(this, "events", {
5507
- expiryChange: new de(),
5508
- cvcChange: new de()
5527
+ expiryChange: new ue(),
5528
+ cvcChange: new ue()
5509
5529
  });
5510
5530
  var o, s, l, c, d, u, h, p, f, m, v, y, T, N, k, I, L;
5511
5531
  this.translate = t;
@@ -5596,10 +5616,10 @@ class Cd {
5596
5616
  toggleCvcLabelError(t) {
5597
5617
  return q(this, null, function* () {
5598
5618
  if (t) {
5599
- this.cvcInputContainer.classList.add(Q.errorInput), this.cvcLabelError.classList.remove(Q.hidden), yield le(this.cvcLabelError, pe.open, pe.transition);
5619
+ this.cvcInputContainer.classList.add(Q.errorInput), this.cvcLabelError.classList.remove(Q.hidden), yield le(this.cvcLabelError, he.open, he.transition);
5600
5620
  return;
5601
5621
  }
5602
- yield le(this.cvcLabelError, pe.close, pe.transition), this.cvcLabelError.classList.add(Q.hidden);
5622
+ yield le(this.cvcLabelError, he.close, he.transition), this.cvcLabelError.classList.add(Q.hidden);
5603
5623
  });
5604
5624
  }
5605
5625
  toggleCvcErrorMessage(t) {
@@ -5643,10 +5663,10 @@ class Cd {
5643
5663
  toggleExpiryLabelError(t) {
5644
5664
  return q(this, null, function* () {
5645
5665
  if (t) {
5646
- this.expiryInputContainer.classList.add(Q.errorInput), this.expiryLabelError.classList.remove(Q.hidden), yield le(this.expiryLabelError, pe.open, pe.transition);
5666
+ this.expiryInputContainer.classList.add(Q.errorInput), this.expiryLabelError.classList.remove(Q.hidden), yield le(this.expiryLabelError, he.open, he.transition);
5647
5667
  return;
5648
5668
  }
5649
- yield le(this.expiryLabelError, pe.close, pe.transition), this.expiryLabelError.classList.add(Q.hidden);
5669
+ yield le(this.expiryLabelError, he.close, he.transition), this.expiryLabelError.classList.add(Q.hidden);
5650
5670
  });
5651
5671
  }
5652
5672
  toggleExpiryErrorMessage(t) {
@@ -5699,8 +5719,8 @@ class _d {
5699
5719
  _(this, "translate");
5700
5720
  _(this, "isBackVisible", !0);
5701
5721
  _(this, "events", {
5702
- submit: new de(),
5703
- close: new de()
5722
+ submit: new ue(),
5723
+ close: new ue()
5704
5724
  });
5705
5725
  const i = n.getState();
5706
5726
  this.translate = t, this.element = document.createElement("form"), this.error = new _e(t), this.submit = new kc(t, i.SubmitButton), this.back = new Ac(), this.number = new ld(t, i.Input), this.name = new Bc(t, i.Input), this.cardSecurity = new Cd(t, i.Input), this.error.addClassName(Ae.hidden), this.element.classList.add(Ae.cardForm, e || "");
@@ -5822,23 +5842,27 @@ class Nd {
5822
5842
  _(this, "form");
5823
5843
  this.config = t, this.buttons = new bc(t), this.form = new _d({
5824
5844
  translate: t.state.translate,
5825
- className: me.hidden,
5845
+ className: ve.hidden,
5826
5846
  stylesState: t.state.styles,
5827
5847
  isDefaultVariant: t.state.checkout.getState().variant === "default"
5828
- }), this.success = new Id(t.state.translate), this.success.addClassName(me.hidden), this.container.append(this.loader.render(), this.buttons.render(), this.form.render()), this.checkout = document.createElement("div"), this.checkout.classList.add(me.checkout), this.checkout.append(this.container, this.success.render());
5848
+ }), this.success = new Id(t.state.translate), this.success.addClassName(ve.hidden), this.container.append(this.loader.render(), this.buttons.render(), this.form.render()), this.checkout = document.createElement("div"), this.checkout.classList.add(ve.checkout), this.checkout.append(this.container, this.success.render());
5829
5849
  }
5830
5850
  // init
5831
5851
  init() {
5832
5852
  return q(this, null, function* () {
5833
5853
  this.buttons.addEventListener("ready", () => q(this, null, function* () {
5834
- this.loader.setClassName(me.hidden);
5854
+ this.loader.setClassName(ve.hidden);
5835
5855
  const { variant: t } = this.config.state.checkout.getState();
5836
- this.form.setDefaultVariant(t === "default"), this.buttons.showButton(), t === "default" && (this.form.element.classList.remove(me.hidden), this.isFormOpen = !0);
5856
+ this.form.setDefaultVariant(t === "default"), this.buttons.showButton(), t === "default" && (this.form.element.classList.remove(ve.hidden), this.isFormOpen = !0);
5837
5857
  })), this.buttons.addEventListener("open", () => q(this, null, function* () {
5838
- this.isLoading || (this.hideError(), yield le(this.buttons.buttons, yt.close, yt.transition), this.buttons.buttons.classList.add(me.hidden), this.form.element.classList.add(me.formInitial), this.form.element.classList.remove(me.hidden), yield le(this.form.element, Me.open, Me.transition), this.isFormOpen = !0);
5858
+ this.isLoading || (this.hideError(), yield le(this.buttons.buttons, yt.close, yt.transition), this.buttons.buttons.classList.add(ve.hidden), this.form.element.classList.add(ve.formInitial), this.form.element.classList.remove(ve.hidden), yield le(this.form.element, Me.open, Me.transition), this.isFormOpen = !0);
5839
5859
  })), this.buttons.addEventListener("error", (t) => {
5840
5860
  const { onCheckoutFail: e } = this.config.state.checkout.getState(), n = this.config.state.translate.messages(), a = je(t, n);
5841
- this.buttons.showExternalError(a), e == null || e(t);
5861
+ this.buttons.showExternalError(a), e == null || e({
5862
+ advice_code: "try_again_later",
5863
+ decline_code: de.GENERIC_DECLINE,
5864
+ message: t.message || t
5865
+ });
5842
5866
  }), this.buttons.addEventListener("success", (t) => {
5843
5867
  const { clientToken: e } = this.config.state.checkout.getState();
5844
5868
  switch (t.type) {
@@ -5856,9 +5880,9 @@ class Nd {
5856
5880
  }
5857
5881
  }), this.form.addEventListener("close", () => q(this, null, function* () {
5858
5882
  if (this.isLoading) return;
5859
- this.hideError(), yield le(this.form.element, Me.close, Me.transition), this.form.element.classList.add(me.hidden);
5883
+ this.hideError(), yield le(this.form.element, Me.close, Me.transition), this.form.element.classList.add(ve.hidden);
5860
5884
  const { variant: t } = this.config.state.checkout.getState();
5861
- t !== "default" && (this.buttons.buttons.classList.add(me.btnsInitial), this.buttons.buttons.classList.remove(me.hidden), yield le(this.buttons.buttons, yt.open, yt.transition)), this.isFormOpen = !1;
5885
+ t !== "default" && (this.buttons.buttons.classList.add(ve.btnsInitial), this.buttons.buttons.classList.remove(ve.hidden), yield le(this.buttons.buttons, yt.open, yt.transition)), this.isFormOpen = !1;
5862
5886
  })), this.form.addEventListener("submit", (t) => q(this, null, function* () {
5863
5887
  if (this.isLoading || (this.form.touchSubmit(), !this.form.validate())) return;
5864
5888
  const n = t.number.replace(/\D/g, ""), a = this.config.state.checkout.getState(), i = this.config.service.ev.getEv(), [o, s] = yield Promise.all([i.encrypt(n), i.encrypt(t.cvc)]), [l, c] = t.expiry.split("/");
@@ -5886,47 +5910,55 @@ class Nd {
5886
5910
  handleError(t) {
5887
5911
  var i;
5888
5912
  const e = this.config.state.checkout.getState();
5889
- console.error(t);
5913
+ console.error("Error: ", t);
5890
5914
  const n = this.config.state.translate.messages(), a = je(t, n);
5891
5915
  this.buttons.showExternalError(a), this.showError(a), (i = e.onCheckoutFail) == null || i.call(e, t), this.setLoading(!1);
5892
5916
  }
5893
5917
  // handle success
5894
5918
  handleSuccess(t) {
5895
5919
  return q(this, null, function* () {
5896
- var a, i, o;
5920
+ var a, i;
5897
5921
  if (this.isLoading) return;
5898
5922
  this.hideError(), this.setLoading(!0);
5899
5923
  const e = this.config.state.checkout.getState(), n = this.config.state.translate.messages();
5900
5924
  try {
5901
- const s = yield zl(t, e.environment, e.apiVersion);
5902
- if (s.error)
5903
- throw new Error(((a = s.error) == null ? void 0 : a.message) || n.status.error);
5904
- if (s.three_ds_session_id) {
5925
+ const o = yield zl(t, e.environment, e.apiVersion);
5926
+ if (o.error)
5927
+ throw new Error(((a = o.error) == null ? void 0 : a.message) || n.status.error);
5928
+ if (o.three_ds_session_id) {
5905
5929
  yield this.config.service.ev.initThreeDs({
5906
- threeDsId: s.three_ds_session_id,
5930
+ threeDsId: o.three_ds_session_id,
5907
5931
  onSuccess: () => {
5908
- this.setLoading(!1), this.handleSuccess(ee(K({}, t), { threeDsSessionId: s.three_ds_session_id }));
5932
+ this.setLoading(!1), this.handleSuccess(ee(K({}, t), { threeDsSessionId: o.three_ds_session_id }));
5909
5933
  },
5910
5934
  onError: () => {
5911
- this.handleError("Three DS Error");
5935
+ this.handleError({
5936
+ advice_code: "try_again_later",
5937
+ decline_code: de.GENERIC_DECLINE,
5938
+ message: "Three DS Error"
5939
+ });
5912
5940
  }
5913
5941
  });
5914
5942
  return;
5915
5943
  }
5916
- if (s.payment_status === tr.FAILED || s.payment_status === tr.DECLINED) {
5917
- this.handleError((i = s.status_reason) == null ? void 0 : i.status_reason);
5944
+ if (o.payment_status === tr.FAILED || o.payment_status === tr.DECLINED) {
5945
+ this.handleError(o.status_reason.status_reason);
5918
5946
  return;
5919
5947
  }
5920
- yield this.showSuccess(), (o = e.onCheckoutComplete) == null || o.call(e, s), this.setLoading(!1);
5921
- } catch (s) {
5922
- this.handleError(s);
5948
+ yield this.showSuccess(), (i = e.onCheckoutComplete) == null || i.call(e, o), this.setLoading(!1);
5949
+ } catch (o) {
5950
+ this.handleError({
5951
+ advice_code: "try_again_later",
5952
+ decline_code: de.GENERIC_DECLINE,
5953
+ message: o.message || o
5954
+ });
5923
5955
  }
5924
5956
  });
5925
5957
  }
5926
5958
  // show success
5927
5959
  showSuccess() {
5928
5960
  return q(this, null, function* () {
5929
- this.container.classList.add(me.hidden), this.success.removeClassName(me.hidden), yield le(this.success.element, Me.open, Me.transition);
5961
+ this.container.classList.add(ve.hidden), this.success.removeClassName(ve.hidden), yield le(this.success.element, Me.open, Me.transition);
5930
5962
  });
5931
5963
  }
5932
5964
  // hide error
@@ -5939,7 +5971,7 @@ class Nd {
5939
5971
  }
5940
5972
  // set loading
5941
5973
  setLoading(t) {
5942
- this.isLoading = t, this.form.setLoading(t), this.loader.setClassName(!t || this.isFormOpen ? me.hidden : "");
5974
+ this.isLoading = t, this.form.setLoading(t), this.loader.setClassName(!t || this.isFormOpen ? ve.hidden : "");
5943
5975
  }
5944
5976
  // render
5945
5977
  render() {
@@ -5978,7 +6010,7 @@ class It {
5978
6010
  constructor(t) {
5979
6011
  _(this, "initialState");
5980
6012
  _(this, "state");
5981
- _(this, "observer", new de());
6013
+ _(this, "observer", new ue());
5982
6014
  this.initialState = t, this.state = t;
5983
6015
  }
5984
6016
  getState() {
@@ -8436,7 +8468,7 @@ const Sd = {
8436
8468
  const r = navigator == null ? void 0 : navigator.language.split("-")[0];
8437
8469
  return rr[r] || rr.en;
8438
8470
  }, Cn = (r, t = {}) => {
8439
- var i, o, s, l, c, d, u, h, p, f, m, v, y, T, N, k, I, L, O, S, U, W, G, F, j, B, J, D, Y, H, C, g, P, V, b, w, E, x, M, A, z, $, ne, R, te, fe, wr, Ir;
8471
+ var i, o, s, l, c, d, u, h, p, f, m, v, y, T, N, k, I, L, O, S, U, W, G, F, j, B, J, D, Y, H, C, g, P, V, b, w, E, x, M, A, z, $, ne, R, te, me, wr, Ir;
8440
8472
  if (!r) return nr();
8441
8473
  const e = rr[r] || nr(), n = Object.keys(Di.errors || {}).reduce((Nr, Fi) => (Nr[Fi] = e.status.error, Nr), {}), a = K(K(K({}, n), e.errors || {}), t.errors || {});
8442
8474
  return {
@@ -8478,7 +8510,7 @@ const Sd = {
8478
8510
  button: ((R = (ne = t == null ? void 0 : t.card) == null ? void 0 : ne.pay) == null ? void 0 : R.button) || e.card.pay.button
8479
8511
  },
8480
8512
  compact: {
8481
- button: ((fe = (te = t == null ? void 0 : t.card) == null ? void 0 : te.compact) == null ? void 0 : fe.button) || e.card.compact.button
8513
+ button: ((me = (te = t == null ? void 0 : t.card) == null ? void 0 : te.compact) == null ? void 0 : me.button) || e.card.compact.button
8482
8514
  }
8483
8515
  },
8484
8516
  status: {
@@ -8661,21 +8693,29 @@ class Nu {
8661
8693
  try {
8662
8694
  this.paypal = yield Tu(t);
8663
8695
  } catch (e) {
8664
- console.error("failed to load the PayPal JS SDK script", e);
8696
+ throw this.paypal = null, e;
8665
8697
  }
8666
8698
  });
8667
8699
  }
8700
+ // check if PayPal SDK is loaded
8701
+ isLoaded() {
8702
+ return this.paypal !== null && this.paypal.Buttons !== void 0;
8703
+ }
8668
8704
  // render
8669
8705
  render(t, e) {
8670
8706
  return q(this, null, function* () {
8671
8707
  var n, a;
8708
+ if (!t.isConnected)
8709
+ throw new Error("PayPal parent element must be connected to DOM before render()");
8672
8710
  if (this.paypal) {
8673
- const i = K(K({}, Iu), (e == null ? void 0 : e.style) || {});
8674
- yield (a = (n = this.paypal).Buttons) == null ? void 0 : a.call(n, ee(K({
8711
+ const i = K(K({}, Iu), (e == null ? void 0 : e.style) || {}), o = ee(K({
8675
8712
  fundingSource: "paypal"
8676
8713
  }, e), {
8677
8714
  style: i
8678
- })).render(t);
8715
+ }), s = (a = (n = this.paypal).Buttons) == null ? void 0 : a.call(n, o);
8716
+ if (!s)
8717
+ throw new Error("PayPal Buttons instance is null");
8718
+ console.log("PayPalService: Buttons instance created, calling render()..."), yield s.render(t);
8679
8719
  }
8680
8720
  });
8681
8721
  }
@@ -8832,15 +8872,15 @@ function Ou() {
8832
8872
  function $(te) {
8833
8873
  try {
8834
8874
  R(x.next(te));
8835
- } catch (fe) {
8836
- z(fe);
8875
+ } catch (me) {
8876
+ z(me);
8837
8877
  }
8838
8878
  }
8839
8879
  function ne(te) {
8840
8880
  try {
8841
8881
  R(x.throw(te));
8842
- } catch (fe) {
8843
- z(fe);
8882
+ } catch (me) {
8883
+ z(me);
8844
8884
  }
8845
8885
  }
8846
8886
  function R(te) {
@@ -10501,15 +10541,15 @@ function Lu() {
10501
10541
  function $(te) {
10502
10542
  try {
10503
10543
  R(x.next(te));
10504
- } catch (fe) {
10505
- z(fe);
10544
+ } catch (me) {
10545
+ z(me);
10506
10546
  }
10507
10547
  }
10508
10548
  function ne(te) {
10509
10549
  try {
10510
10550
  R(x.throw(te));
10511
- } catch (fe) {
10512
- z(fe);
10551
+ } catch (me) {
10552
+ z(me);
10513
10553
  }
10514
10554
  }
10515
10555
  function R(te) {
@@ -11418,15 +11458,15 @@ function Su() {
11418
11458
  function $(te) {
11419
11459
  try {
11420
11460
  R(x.next(te));
11421
- } catch (fe) {
11422
- z(fe);
11461
+ } catch (me) {
11462
+ z(me);
11423
11463
  }
11424
11464
  }
11425
11465
  function ne(te) {
11426
11466
  try {
11427
11467
  R(x.throw(te));
11428
- } catch (fe) {
11429
- z(fe);
11468
+ } catch (me) {
11469
+ z(me);
11430
11470
  }
11431
11471
  }
11432
11472
  function R(te) {