@pelcro/react-pelcro-js 3.26.0-beta.1 → 3.26.0-beta.10

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.cjs.js CHANGED
@@ -3452,7 +3452,7 @@ var labels$15 = {
3452
3452
  code: "Coupon code",
3453
3453
  "for": "for",
3454
3454
  interval: "{{count}} {{interval}}",
3455
- interval_plural: "{{count}} {{interval}}s",
3455
+ interval_plural: "{{count}} {{interval}}",
3456
3456
  tax: "Tax",
3457
3457
  removeCoupon: "REMOVE",
3458
3458
  firstName: "First name",
@@ -4103,12 +4103,16 @@ var invoiceDetails_en = {
4103
4103
  var labels$U = {
4104
4104
  title: "Cancel subscription",
4105
4105
  cancelReason: "Cancellation reason",
4106
+ endOn: "End on",
4107
+ endImmediately: "End immediately",
4108
+ cancel: "Cancel",
4106
4109
  subCancellation: {
4107
4110
  goBack: "Go back"
4108
4111
  }
4109
4112
  };
4110
4113
  var messages$W = {
4111
4114
  subscriptionEnd: "This subscription is set to expire on",
4115
+ cancelWhen: "When would you like to cancel?",
4112
4116
  cancelNow: "Cancel Subscription Now",
4113
4117
  cancelLater: "Cancel at Period End",
4114
4118
  subCancellation: {
@@ -4374,7 +4378,7 @@ var labels$P = {
4374
4378
  code: "Code promo",
4375
4379
  "for": "pour",
4376
4380
  interval: "{{count}} {{interval}}",
4377
- interval_plural: "{{count}} {{interval}}s",
4381
+ interval_plural: "{{count}} {{interval}}",
4378
4382
  tax: "Taxe",
4379
4383
  removeCoupon: "RETIRER",
4380
4384
  firstName: "Prénom",
@@ -5025,12 +5029,16 @@ var invoiceDetails_fr = {
5025
5029
  var labels$C = {
5026
5030
  title: "Annuler l'abonnement",
5027
5031
  cancelReason: "Motif d'annulation",
5032
+ endOn: "Fin sur",
5033
+ endImmediately: "Fin immédiate",
5034
+ cancel: "Annuler",
5028
5035
  subCancellation: {
5029
5036
  goBack: "Retourner"
5030
5037
  }
5031
5038
  };
5032
5039
  var messages$D = {
5033
5040
  subscriptionEnd: "Cet abonnement doit expirer le",
5041
+ cancelWhen: "Quand voulez-vous annuler?",
5034
5042
  cancelNow: "Cancel Subscription Now",
5035
5043
  cancelLater: "Annuler l'abonnement maintenant",
5036
5044
  subCancellation: {
@@ -6054,12 +6062,16 @@ var invoiceDetails_ko = {
6054
6062
  var labels$k = {
6055
6063
  title: "구독 취소",
6056
6064
  cancelReason: "취소 사유",
6065
+ endOn: "종료",
6066
+ endImmediately: "즉시 종료",
6067
+ cancel: "취소",
6057
6068
  subCancellation: {
6058
6069
  goBack: "돌아가기"
6059
6070
  }
6060
6071
  };
6061
6072
  var messages$k = {
6062
6073
  subscriptionEnd: "이 구독은 다음 날짜에 만료되도록 설정되었습니다.",
6074
+ cancelWhen: "언제 취소하시겠습니까?",
6063
6075
  cancelNow: "지금 구독 취소",
6064
6076
  cancelLater: "기간 종료 시 취소",
6065
6077
  subCancellation: {
@@ -6321,7 +6333,7 @@ var labels$f = {
6321
6333
  code: "Código de cupón",
6322
6334
  "for": "por",
6323
6335
  interval: "{{count}} {{interval}}",
6324
- interval_plural: "{{count}} {{interval}}s",
6336
+ interval_plural: "{{count}} {{interval}}",
6325
6337
  tax: "Impuesto",
6326
6338
  removeCoupon: "ELIMINAR",
6327
6339
  firstName: "Nombre",
@@ -6968,12 +6980,16 @@ var invoiceDetails_es = {
6968
6980
  var labels$2 = {
6969
6981
  title: "Cancelar suscripción",
6970
6982
  cancelReason: "Razón de la cancelación",
6983
+ endOn: "Fin de",
6984
+ endImmediately: "Fin inmediato",
6985
+ cancel: "Cancelar",
6971
6986
  subCancellation: {
6972
6987
  goBack: "Volver"
6973
6988
  }
6974
6989
  };
6975
6990
  var messages$1 = {
6976
6991
  subscriptionEnd: "Esta suscripción expirará el",
6992
+ cancelWhen: "¿Cuándo desea cancelar?",
6977
6993
  cancelNow: "Cancelar Suscripción Ahora",
6978
6994
  cancelLater: "Cancelar al Final del Periodo",
6979
6995
  subCancellation: {
@@ -8411,7 +8427,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8411
8427
  OutboundLink$1.origTrackLink = OutboundLink$1.trackLink;
8412
8428
  OutboundLink$1.trackLink = outboundLink;
8413
8429
  var OutboundLink = OutboundLink$1;
8414
- var ReactGA1 = _objectSpread({}, Defaults, {
8430
+ var ReactGA = _objectSpread({}, Defaults, {
8415
8431
  OutboundLink: OutboundLink
8416
8432
  });
8417
8433
 
@@ -8950,8 +8966,6 @@ exports["default"] = _default;
8950
8966
  var ReactGA4 = unwrapExports(dist);
8951
8967
  dist.ReactGAImplementation;
8952
8968
 
8953
- var _window$d, _window$Pelcro$d, _window$Pelcro$uiSett$d;
8954
- const ReactGA$d = (_window$d = window) !== null && _window$d !== void 0 && (_window$Pelcro$d = _window$d.Pelcro) !== null && _window$Pelcro$d !== void 0 && (_window$Pelcro$uiSett$d = _window$Pelcro$d.uiSettings) !== null && _window$Pelcro$uiSett$d !== void 0 && _window$Pelcro$uiSett$d.enableReactGA4 ? ReactGA4 : ReactGA1;
8955
8969
  class PelcroActions {
8956
8970
  constructor(storeSetter, storeGetter) {
8957
8971
  var _this = this;
@@ -9131,23 +9145,31 @@ class PelcroActions {
9131
9145
  });
9132
9146
  });
9133
9147
  _defineProperty$3(this, "logout", function () {
9134
- var _ReactGA$event;
9148
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
9135
9149
  let displayLogin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
9136
9150
  const {
9137
9151
  switchView,
9138
9152
  resetView,
9139
9153
  isAuthenticated
9140
9154
  } = _this.get();
9155
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
9141
9156
  // if user is not authenticated function execution is terminated
9142
9157
  if (!isAuthenticated()) {
9143
9158
  return console.warn("You are already logged out.");
9144
9159
  }
9145
9160
  window.Pelcro.user.logout();
9146
- ReactGA$d === null || ReactGA$d === void 0 ? void 0 : (_ReactGA$event = ReactGA$d.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$d, {
9147
- category: "ACTIONS",
9148
- action: "Logged out",
9149
- nonInteraction: true
9150
- });
9161
+ if (enableReactGA4) {
9162
+ ReactGA4.event("Logged out", {
9163
+ nonInteraction: true
9164
+ });
9165
+ } else {
9166
+ var _ReactGA$event;
9167
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
9168
+ category: "ACTIONS",
9169
+ action: "Logged out",
9170
+ nonInteraction: true
9171
+ });
9172
+ }
9151
9173
  resetView();
9152
9174
  if (displayLogin) {
9153
9175
  switchView("login");
@@ -9160,7 +9182,7 @@ class PelcroActions {
9160
9182
  return false;
9161
9183
  }
9162
9184
 
9163
- //Dispatch PelcroElementsCartItemAdded when an item added successfully to the
9185
+ // Dispatch PelcroElementsCartItemAdded when an item added successfully to the
9164
9186
  document.dispatchEvent(cartItemAdded(itemToAdd));
9165
9187
  const {
9166
9188
  cartItems
@@ -9372,9 +9394,6 @@ if (process.env.NODE_ENV === "development") {
9372
9394
  c$1("Pelcro Store", usePelcro);
9373
9395
  }
9374
9396
 
9375
- var _window$c, _window$Pelcro$c, _window$Pelcro$uiSett$c;
9376
- const ReactGA$c = (_window$c = window) !== null && _window$c !== void 0 && (_window$Pelcro$c = _window$c.Pelcro) !== null && _window$Pelcro$c !== void 0 && (_window$Pelcro$uiSett$c = _window$Pelcro$c.uiSettings) !== null && _window$Pelcro$uiSett$c !== void 0 && _window$Pelcro$uiSett$c.enableReactGA4 ? ReactGA4 : ReactGA1;
9377
-
9378
9397
  /**
9379
9398
  * List of zero-decimal currencies.
9380
9399
  * @see https://stripe.com/docs/currencies#zero-decimal
@@ -9460,8 +9479,8 @@ const getLanguageWithoutRegion = localeName => {
9460
9479
  * @return {string | undefined}
9461
9480
  */
9462
9481
  const getPageOrDefaultLanguage = () => {
9463
- var _window$Pelcro$helper, _window$Pelcro2, _window$Pelcro2$site, _window$Pelcro2$site$, _window$Pelcro2$site$2;
9464
- return (_window$Pelcro$helper = window.Pelcro.helpers.getHtmlLanguageAttribute()) !== null && _window$Pelcro$helper !== void 0 ? _window$Pelcro$helper : getLanguageWithoutRegion((_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$site = _window$Pelcro2.site) === null || _window$Pelcro2$site === void 0 ? void 0 : (_window$Pelcro2$site$ = _window$Pelcro2$site.read) === null || _window$Pelcro2$site$ === void 0 ? void 0 : (_window$Pelcro2$site$2 = _window$Pelcro2$site$.call(_window$Pelcro2$site)) === null || _window$Pelcro2$site$2 === void 0 ? void 0 : _window$Pelcro2$site$2.default_locale);
9482
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
9483
+ return (_window$Pelcro$helper = window.Pelcro.helpers.getHtmlLanguageAttribute()) !== null && _window$Pelcro$helper !== void 0 ? _window$Pelcro$helper : getLanguageWithoutRegion((_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read) === null || _window$Pelcro$site$r === void 0 ? void 0 : (_window$Pelcro$site$r2 = _window$Pelcro$site$r.call(_window$Pelcro$site)) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.default_locale);
9465
9484
  };
9466
9485
 
9467
9486
  /**
@@ -9514,9 +9533,9 @@ const isValidViewFromURL = viewID => {
9514
9533
  *
9515
9534
  */
9516
9535
  function hasValidNewsletterUpdateUrl() {
9517
- var _window$Pelcro3, _window$Pelcro3$uiSet;
9536
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
9518
9537
  if (viewID !== "newsletter-update") return false;
9519
- const newsletters = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$uiSet = _window$Pelcro3.uiSettings) === null || _window$Pelcro3$uiSet === void 0 ? void 0 : _window$Pelcro3$uiSet.newsletters;
9538
+ const newsletters = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$uiSet = _window$Pelcro2.uiSettings) === null || _window$Pelcro2$uiSet === void 0 ? void 0 : _window$Pelcro2$uiSet.newsletters;
9520
9539
  const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
9521
9540
  if (!siteHasNewslettersDefined) {
9522
9541
  return false;
@@ -9562,7 +9581,7 @@ const disableScroll = () => {
9562
9581
  }
9563
9582
  };
9564
9583
  const trackSubscriptionOnGA = () => {
9565
- var _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$set, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
9584
+ var _window, _window$Pelcro3, _window$Pelcro3$uiSet, _window$Pelcro$user$r5, _window$Pelcro$user$r6;
9566
9585
  const {
9567
9586
  product,
9568
9587
  plan,
@@ -9577,33 +9596,56 @@ const trackSubscriptionOnGA = () => {
9577
9596
  invoices
9578
9597
  } = window.Pelcro.user.read();
9579
9598
  const lastSubscriptionId = invoices === null || invoices === void 0 ? void 0 : invoices[invoices.length - 1].subscription_id;
9599
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro3 = _window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$uiSet = _window$Pelcro3.uiSettings) === null || _window$Pelcro3$uiSet === void 0 ? void 0 : _window$Pelcro3$uiSet.enableReactGA4;
9580
9600
  if (!lastSubscriptionId) {
9581
9601
  return;
9582
9602
  }
9583
9603
  const currencyCode = (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency;
9584
- ReactGA$c === null || ReactGA$c === void 0 ? void 0 : (_ReactGA$set = ReactGA$c.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA$c, {
9585
- currencyCode: currencyCode
9586
- });
9587
- ReactGA$c === null || ReactGA$c === void 0 ? void 0 : (_ReactGA$plugin = ReactGA$c.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$execu = _ReactGA$plugin.execute) === null || _ReactGA$plugin$execu === void 0 ? void 0 : _ReactGA$plugin$execu.call(_ReactGA$plugin, "ecommerce", "addTransaction", {
9588
- id: lastSubscriptionId,
9589
- affiliation: "Pelcro",
9590
- revenue: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9591
- coupon: couponCode
9592
- });
9593
- ReactGA$c === null || ReactGA$c === void 0 ? void 0 : (_ReactGA$plugin2 = ReactGA$c.plugin) === null || _ReactGA$plugin2 === void 0 ? void 0 : (_ReactGA$plugin2$exec = _ReactGA$plugin2.execute) === null || _ReactGA$plugin2$exec === void 0 ? void 0 : _ReactGA$plugin2$exec.call(_ReactGA$plugin2, "ecommerce", "addItem", {
9594
- id: lastSubscriptionId,
9595
- name: product.name,
9596
- category: product.description,
9597
- variant: plan.nickname,
9598
- price: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9599
- quantity: 1
9600
- });
9601
- ReactGA$c === null || ReactGA$c === void 0 ? void 0 : (_ReactGA$plugin3 = ReactGA$c.plugin) === null || _ReactGA$plugin3 === void 0 ? void 0 : (_ReactGA$plugin3$exec = _ReactGA$plugin3.execute) === null || _ReactGA$plugin3$exec === void 0 ? void 0 : _ReactGA$plugin3$exec.call(_ReactGA$plugin3, "ecommerce", "send");
9602
- ReactGA$c === null || ReactGA$c === void 0 ? void 0 : (_ReactGA$event = ReactGA$c.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$c, {
9603
- category: "ACTIONS",
9604
- action: "Subscribed",
9605
- nonInteraction: true
9606
- });
9604
+ if (enableReactGA4) {
9605
+ ReactGA4.event("purchase", {
9606
+ transaction_id: lastSubscriptionId,
9607
+ affiliation: "Pelcro",
9608
+ currency: currencyCode,
9609
+ value: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9610
+ coupon: couponCode,
9611
+ items: [{
9612
+ item_id: lastSubscriptionId,
9613
+ item_name: product.name,
9614
+ item_category: product.description,
9615
+ item_variant: plan.nickname,
9616
+ price: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9617
+ quantity: 1
9618
+ }]
9619
+ });
9620
+ ReactGA4.event("Subscribed", {
9621
+ nonInteraction: true
9622
+ });
9623
+ } else {
9624
+ var _ReactGA$set, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
9625
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
9626
+ currencyCode: currencyCode
9627
+ });
9628
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin = ReactGA.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$execu = _ReactGA$plugin.execute) === null || _ReactGA$plugin$execu === void 0 ? void 0 : _ReactGA$plugin$execu.call(_ReactGA$plugin, "ecommerce", "addTransaction", {
9629
+ id: lastSubscriptionId,
9630
+ affiliation: "Pelcro",
9631
+ revenue: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9632
+ coupon: couponCode
9633
+ });
9634
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin2 = ReactGA.plugin) === null || _ReactGA$plugin2 === void 0 ? void 0 : (_ReactGA$plugin2$exec = _ReactGA$plugin2.execute) === null || _ReactGA$plugin2$exec === void 0 ? void 0 : _ReactGA$plugin2$exec.call(_ReactGA$plugin2, "ecommerce", "addItem", {
9635
+ id: lastSubscriptionId,
9636
+ name: product.name,
9637
+ category: product.description,
9638
+ variant: plan.nickname,
9639
+ price: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
9640
+ quantity: 1
9641
+ });
9642
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin3 = ReactGA.plugin) === null || _ReactGA$plugin3 === void 0 ? void 0 : (_ReactGA$plugin3$exec = _ReactGA$plugin3.execute) === null || _ReactGA$plugin3$exec === void 0 ? void 0 : _ReactGA$plugin3$exec.call(_ReactGA$plugin3, "ecommerce", "send");
9643
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
9644
+ category: "ACTIONS",
9645
+ action: "Subscribed",
9646
+ nonInteraction: true
9647
+ });
9648
+ }
9607
9649
  };
9608
9650
 
9609
9651
  /** check wether or not the user have any existing payment method
@@ -9687,14 +9729,14 @@ function getDateWithoutTime(dateObject) {
9687
9729
  return date;
9688
9730
  }
9689
9731
  function userMustVerifyEmail() {
9690
- var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
9691
- const isEmailVerificationEnabled = (_window$Pelcro$site$r = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.email_verify_enabled) !== null && _window$Pelcro$site$r !== void 0 ? _window$Pelcro$site$r : false;
9732
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
9733
+ const isEmailVerificationEnabled = (_window$Pelcro$site$r3 = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.email_verify_enabled) !== null && _window$Pelcro$site$r3 !== void 0 ? _window$Pelcro$site$r3 : false;
9692
9734
  const isUserEmailVerified = (_window$Pelcro$user$r9 = (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.email_confirm) !== null && _window$Pelcro$user$r9 !== void 0 ? _window$Pelcro$user$r9 : false;
9693
9735
  return window.Pelcro.user.isAuthenticated() && isEmailVerificationEnabled && !isUserEmailVerified;
9694
9736
  }
9695
9737
  function notifyBugsnag(callback, startOptions) {
9696
9738
  if (!window.Bugsnag && !document.querySelector('script[src="https://d2wy8f7a9ursnm.cloudfront.net/v7/bugsnag.min.js"]')) {
9697
- //load bugsnag CDN
9739
+ // load bugsnag CDN
9698
9740
  window.Pelcro.helpers.loadSDK("https://d2wy8f7a9ursnm.cloudfront.net/v7/bugsnag.min.js", "bugsnag-cdn");
9699
9741
  document.querySelector('script[src="https://d2wy8f7a9ursnm.cloudfront.net/v7/bugsnag.min.js"]').addEventListener("load", () => {
9700
9742
  var _window$Pelcro$enviro, _window$Pelcro4, _window$Pelcro4$envir, _window$Pelcro5, _window$Pelcro5$envir;
@@ -10057,10 +10099,8 @@ function _classPrivateFieldGet(receiver, privateMap) {
10057
10099
  return descriptor.value;
10058
10100
  }
10059
10101
 
10060
- var _window$b, _window$Pelcro$b, _window$Pelcro$uiSett$b;
10061
10102
  function _classPrivateFieldInitSpec$2(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); }
10062
10103
  function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
10063
- const ReactGA$b = (_window$b = window) !== null && _window$b !== void 0 && (_window$Pelcro$b = _window$b.Pelcro) !== null && _window$Pelcro$b !== void 0 && (_window$Pelcro$uiSett$b = _window$Pelcro$b.uiSettings) !== null && _window$Pelcro$uiSett$b !== void 0 && _window$Pelcro$uiSett$b.enableReactGA4 ? ReactGA4 : ReactGA1;
10064
10104
  var _isAlreadySaved = /*#__PURE__*/new WeakMap();
10065
10105
  var _markButtonAsLoading = /*#__PURE__*/new WeakMap();
10066
10106
  var _removeLoadingState = /*#__PURE__*/new WeakMap();
@@ -10144,7 +10184,7 @@ class SaveToMetadataButtonClass {
10144
10184
  _classPrivateFieldInitSpec$2(this, _saveToMetadata, {
10145
10185
  writable: true,
10146
10186
  value: event => {
10147
- var _user$metadata;
10187
+ var _window, _window$Pelcro, _window$Pelcro$uiSett, _user$metadata;
10148
10188
  const button = event.currentTarget;
10149
10189
  const user = window.Pelcro.user.read();
10150
10190
  const {
@@ -10154,6 +10194,7 @@ class SaveToMetadataButtonClass {
10154
10194
  key,
10155
10195
  ...buttonMetadata
10156
10196
  } = button.dataset;
10197
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
10157
10198
  if (userMustVerifyEmail()) {
10158
10199
  return switchView("email-verify");
10159
10200
  }
@@ -10178,16 +10219,22 @@ class SaveToMetadataButtonClass {
10178
10219
  value: newMetadataValue,
10179
10220
  auth_token: window.Pelcro.user.read().auth_token
10180
10221
  }, (err, resp) => {
10181
- var _ReactGA$event;
10182
10222
  if (err) {
10183
10223
  return _classPrivateFieldGet(this, _removeLoadingState).call(this, button);
10184
10224
  }
10185
10225
  _classPrivateFieldGet(this, _markButtonAsSaved).call(this, button);
10186
- ReactGA$b === null || ReactGA$b === void 0 ? void 0 : (_ReactGA$event = ReactGA$b.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$b, {
10187
- category: "ACTIONS",
10188
- action: "Save/Follow",
10189
- label: buttonMetadata === null || buttonMetadata === void 0 ? void 0 : buttonMetadata.title
10190
- });
10226
+ if (enableReactGA4) {
10227
+ ReactGA4.event("Save/Follow", {
10228
+ event_label: buttonMetadata === null || buttonMetadata === void 0 ? void 0 : buttonMetadata.title
10229
+ });
10230
+ } else {
10231
+ var _ReactGA$event;
10232
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
10233
+ category: "ACTIONS",
10234
+ action: "Save/Follow",
10235
+ label: buttonMetadata === null || buttonMetadata === void 0 ? void 0 : buttonMetadata.title
10236
+ });
10237
+ }
10191
10238
  });
10192
10239
  }
10193
10240
  }
@@ -10195,6 +10242,7 @@ class SaveToMetadataButtonClass {
10195
10242
  _classPrivateFieldInitSpec$2(this, _removeMetaData, {
10196
10243
  writable: true,
10197
10244
  value: event => {
10245
+ var _window2, _window2$Pelcro, _window2$Pelcro$uiSet;
10198
10246
  const button = event.currentTarget;
10199
10247
  const user = window.Pelcro.user.read();
10200
10248
  const {
@@ -10202,6 +10250,7 @@ class SaveToMetadataButtonClass {
10202
10250
  title
10203
10251
  } = button.dataset;
10204
10252
  const oldValue = user.metadata[`metadata_saved_${key}`];
10253
+ const enableReactGA4 = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$uiSet = _window2$Pelcro.uiSettings) === null || _window2$Pelcro$uiSet === void 0 ? void 0 : _window2$Pelcro$uiSet.enableReactGA4;
10205
10254
  const newMetadataValue = oldValue.filter(metadata => !((metadata === null || metadata === void 0 ? void 0 : metadata.title) === title));
10206
10255
  if (window.Pelcro.user.isAuthenticated()) {
10207
10256
  _classPrivateFieldGet(this, _markButtonAsLoading).call(this, button);
@@ -10210,16 +10259,22 @@ class SaveToMetadataButtonClass {
10210
10259
  value: newMetadataValue,
10211
10260
  auth_token: window.Pelcro.user.read().auth_token
10212
10261
  }, (err, resp) => {
10213
- var _ReactGA$event2;
10214
10262
  if (err) {
10215
10263
  return _classPrivateFieldGet(this, _removeLoadingState).call(this, button);
10216
10264
  }
10217
10265
  _classPrivateFieldGet(this, _unmarkSavedButton).call(this, button);
10218
- ReactGA$b === null || ReactGA$b === void 0 ? void 0 : (_ReactGA$event2 = ReactGA$b.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA$b, {
10219
- category: "ACTIONS",
10220
- action: "Unsave/Unfollow",
10221
- label: title
10222
- });
10266
+ if (enableReactGA4) {
10267
+ ReactGA4.event("Unsave/Unfollow", {
10268
+ event_label: title
10269
+ });
10270
+ } else {
10271
+ var _ReactGA$event2;
10272
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
10273
+ category: "ACTIONS",
10274
+ action: "Unsave/Unfollow",
10275
+ label: title
10276
+ });
10277
+ }
10223
10278
  });
10224
10279
  }
10225
10280
  }
@@ -11742,9 +11797,6 @@ function getSiteCardProcessor() {
11742
11797
  return "stripe";
11743
11798
  }
11744
11799
 
11745
- var _window$a, _window$Pelcro$a, _window$Pelcro$uiSett$a;
11746
- const ReactGA$a = (_window$a = window) !== null && _window$a !== void 0 && (_window$Pelcro$a = _window$a.Pelcro) !== null && _window$Pelcro$a !== void 0 && (_window$Pelcro$uiSett$a = _window$Pelcro$a.uiSettings) !== null && _window$Pelcro$uiSett$a !== void 0 && _window$Pelcro$uiSett$a.enableReactGA4 ? ReactGA4 : ReactGA1;
11747
-
11748
11800
  /**
11749
11801
  * @typedef {Object} OptionsType
11750
11802
  * @property {boolean} loadPaymentSDKs
@@ -11796,21 +11848,31 @@ const initPaywalls = () => {
11796
11848
  return;
11797
11849
  }
11798
11850
  const {
11799
- switchView
11851
+ switchView,
11852
+ isAuthenticated
11800
11853
  } = usePelcro.getStore();
11801
- if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
11802
- /*
11803
- showing both the meter and the entitlements notification doesn't make sense from
11804
- a product prespective + they would take half the screen on mobile devies, so we're
11805
- not showing the meter, and only showing the entitlements notification.
11806
- */
11807
- if (!didBlurContent) {
11808
- switchView("meter");
11854
+ function displayPaywalls() {
11855
+ if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
11856
+ /*
11857
+ showing both the meter and the entitlements notification doesn't make sense from
11858
+ a product prespective + they would take half the screen on mobile devies, so we're
11859
+ not showing the meter, and only showing the entitlements notification.
11860
+ */
11861
+ if (!didBlurContent) {
11862
+ switchView("meter");
11863
+ }
11864
+ } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
11865
+ switchView("newsletter");
11866
+ } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
11867
+ switchView("plan-select");
11809
11868
  }
11810
- } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
11811
- switchView("newsletter");
11812
- } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
11813
- switchView("plan-select");
11869
+ }
11870
+ if (isAuthenticated()) {
11871
+ addEventListener("PelcroUserLoaded", function () {
11872
+ displayPaywalls();
11873
+ });
11874
+ } else {
11875
+ displayPaywalls();
11814
11876
  }
11815
11877
  }
11816
11878
  };
@@ -11822,6 +11884,7 @@ const loadPaymentSDKs = () => {
11822
11884
  if (!window.Stripe && !supportsVantiv && !supportsTap) {
11823
11885
  pure_1(window.Pelcro.environment.stripe);
11824
11886
  }
11887
+ window.Pelcro.helpers.loadSDK("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js", "apple-pay-sdk");
11825
11888
 
11826
11889
  // Load PayPal SDKs
11827
11890
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
@@ -11835,6 +11898,8 @@ const loadPaymentSDKs = () => {
11835
11898
  if (!window.jQuery) {
11836
11899
  window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
11837
11900
  }
11901
+ window.Pelcro.helpers.loadSDK("https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "vantiv-jquery-sdk");
11902
+ window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/eProtect-api3.js", "vantiv-eprotect-api");
11838
11903
  if (!window.EprotectIframeClient) {
11839
11904
  const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
11840
11905
  const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client3.min.js";
@@ -11867,17 +11932,44 @@ const initSecuritySdk = () => {
11867
11932
  });
11868
11933
  };
11869
11934
  const initGATracking = () => {
11870
- var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
11871
- ReactGA$a === null || ReactGA$a === void 0 ? void 0 : (_ReactGA$initialize = ReactGA$a.initialize) === null || _ReactGA$initialize === void 0 ? void 0 : _ReactGA$initialize.call(ReactGA$a, window.Pelcro.site.read().google_analytics_id);
11872
- ReactGA$a === null || ReactGA$a === void 0 ? void 0 : (_ReactGA$plugin = ReactGA$a.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$requi = _ReactGA$plugin.require) === null || _ReactGA$plugin$requi === void 0 ? void 0 : _ReactGA$plugin$requi.call(_ReactGA$plugin, "ecommerce");
11935
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
11936
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
11937
+ if (window.Pelcro.site.read().google_analytics_id) {
11938
+ if (enableReactGA4) {
11939
+ // Initialize ReactGA4 with your tracking ID
11940
+ ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id);
11941
+ // Enable e-commerce tracking
11942
+ ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id, {
11943
+ gaOptions: {
11944
+ send_page_view: true,
11945
+ ecommerce: {
11946
+ enabled: true
11947
+ }
11948
+ }
11949
+ });
11950
+ } else {
11951
+ var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
11952
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$initialize = ReactGA.initialize) === null || _ReactGA$initialize === void 0 ? void 0 : _ReactGA$initialize.call(ReactGA, window.Pelcro.site.read().google_analytics_id);
11953
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin = ReactGA.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$requi = _ReactGA$plugin.require) === null || _ReactGA$plugin$requi === void 0 ? void 0 : _ReactGA$plugin$requi.call(_ReactGA$plugin, "ecommerce");
11954
+ }
11955
+ }
11873
11956
  };
11874
11957
  const dispatchModalDisplayEvents = modalName => {
11875
- var _ReactGA$event, _modalName$replace, _modalName$replace2;
11876
- ReactGA$a === null || ReactGA$a === void 0 ? void 0 : (_ReactGA$event = ReactGA$a.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$a, {
11877
- category: "VIEWS",
11878
- action: `${modalName === null || modalName === void 0 ? void 0 : (_modalName$replace = modalName.replace("pelcro-", "")) === null || _modalName$replace === void 0 ? void 0 : _modalName$replace.replaceAll("-", " ")} viewed`,
11879
- nonInteraction: true
11880
- });
11958
+ var _window2, _window2$Pelcro, _window2$Pelcro$uiSet, _modalName$replace, _modalName$replace2;
11959
+ const enableReactGA4 = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$uiSet = _window2$Pelcro.uiSettings) === null || _window2$Pelcro$uiSet === void 0 ? void 0 : _window2$Pelcro$uiSet.enableReactGA4;
11960
+ const formattedAction = modalName === null || modalName === void 0 ? void 0 : (_modalName$replace = modalName.replace("pelcro-", "")) === null || _modalName$replace === void 0 ? void 0 : _modalName$replace.replaceAll("-", " ");
11961
+ if (enableReactGA4) {
11962
+ ReactGA4.event(`${formattedAction} viewed`, {
11963
+ nonInteraction: true
11964
+ });
11965
+ } else {
11966
+ var _ReactGA$event;
11967
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
11968
+ category: "VIEWS",
11969
+ action: `${formattedAction} viewed`,
11970
+ nonInteraction: true
11971
+ });
11972
+ }
11881
11973
  window.Pelcro.insight.track("Modal Displayed", {
11882
11974
  name: `${modalName === null || modalName === void 0 ? void 0 : (_modalName$replace2 = modalName.replace("pelcro-", "")) === null || _modalName$replace2 === void 0 ? void 0 : _modalName$replace2.replaceAll("-", " ")}`
11883
11975
  });
@@ -12679,6 +12771,7 @@ const LOADING = "LOADING";
12679
12771
  const SUBMIT_PAYMENT = "SUBMIT_PAYMENT";
12680
12772
  const SUBSCRIBE = "CREATE_SUBSCRIPTION";
12681
12773
  const HANDLE_PAYPAL_SUBSCRIPTION = "HANDLE_PAYPAL_SUBSCRIPTION";
12774
+ const HANDLE_APPLEPAY_SUBSCRIPTION = "HANDLE_APPLEPAY_SUBSCRIPTION";
12682
12775
  const DISABLE_COUPON_BUTTON = "DISABLE_COUPON_BUTTON";
12683
12776
  const APPLY_COUPON_CODE = "APPLY_COUPON_CODE";
12684
12777
  const REMOVE_APPLIED_COUPON = "REMOVE_APPLIED_COUPON";
@@ -12740,6 +12833,7 @@ const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
12740
12833
  const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
12741
12834
  const LINK_TOKEN_VERIFY = "LINK_TOKEN_VERIFY";
12742
12835
  const SET_CANCEL_SUBSCRIPTION_REASON = "SET_CANCEL_SUBSCRIPTION_REASON";
12836
+ const SET_CANCEL_SUBSCRIPTION_OPTION = "SET_CANCEL_SUBSCRIPTION_OPTION";
12743
12837
  const HANDLE_CHECKBOX_CHANGE = "HANDLE_CHECKBOX_CHANGE";
12744
12838
  const SET_SUBSCRIPTION_SUSPEND_DATE = "SET_SUBSCRIPTION_SUSPEND_DATE";
12745
12839
  const SET_EMAILS = "SET_EMAILS";
@@ -12770,6 +12864,7 @@ const {
12770
12864
  Provider: Provider$m
12771
12865
  } = store$m;
12772
12866
  const LoginContainer = _ref => {
12867
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
12773
12868
  let {
12774
12869
  style,
12775
12870
  className = "",
@@ -12777,6 +12872,7 @@ const LoginContainer = _ref => {
12777
12872
  onFailure = () => {},
12778
12873
  children
12779
12874
  } = _ref;
12875
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
12780
12876
  const handleLogin = (_ref2, dispatch) => {
12781
12877
  let {
12782
12878
  email,
@@ -12806,13 +12902,19 @@ const LoginContainer = _ref => {
12806
12902
  });
12807
12903
  onFailure(err);
12808
12904
  } else {
12809
- var _ReactGA$event;
12810
12905
  onSuccess(res);
12811
- ReactGA1 === null || ReactGA1 === void 0 ? void 0 : (_ReactGA$event = ReactGA1.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA1, {
12812
- category: "ACTIONS",
12813
- action: "Logged in",
12814
- nonInteraction: true
12815
- });
12906
+ if (enableReactGA4) {
12907
+ ReactGA4.event("Logged in", {
12908
+ nonInteraction: true
12909
+ });
12910
+ } else {
12911
+ var _ReactGA$event;
12912
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
12913
+ category: "ACTIONS",
12914
+ action: "Logged in",
12915
+ nonInteraction: true
12916
+ });
12917
+ }
12816
12918
  }
12817
12919
  });
12818
12920
  };
@@ -13198,17 +13300,23 @@ function ConfirmPassword(_ref) {
13198
13300
  }, otherProps));
13199
13301
  }
13200
13302
 
13201
- var _window$9, _window$Pelcro$9, _window$Pelcro$uiSett$9;
13202
- const ReactGA$9 = (_window$9 = window) !== null && _window$9 !== void 0 && (_window$Pelcro$9 = _window$9.Pelcro) !== null && _window$Pelcro$9 !== void 0 && (_window$Pelcro$uiSett$9 = _window$Pelcro$9.uiSettings) !== null && _window$Pelcro$uiSett$9 !== void 0 && _window$Pelcro$uiSett$9.enableReactGA4 ? ReactGA4 : ReactGA1;
13203
13303
  const Logout = props => {
13204
13304
  const handleLogout = () => {
13205
- var _ReactGA$event;
13305
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
13206
13306
  window.Pelcro.user.logout();
13207
- ReactGA$9 === null || ReactGA$9 === void 0 ? void 0 : (_ReactGA$event = ReactGA$9.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$9, {
13208
- category: "ACTIONS",
13209
- action: "Logged out",
13210
- nonInteraction: true
13211
- });
13307
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
13308
+ if (enableReactGA4) {
13309
+ ReactGA4.event("Logged out", {
13310
+ nonInteraction: true
13311
+ });
13312
+ } else {
13313
+ var _ReactGA$event;
13314
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
13315
+ category: "ACTIONS",
13316
+ action: "Logged out",
13317
+ nonInteraction: true
13318
+ });
13319
+ }
13212
13320
  };
13213
13321
  return /*#__PURE__*/React__default['default'].createElement("button", {
13214
13322
  name: "logout",
@@ -14766,13 +14874,11 @@ const RegisterCompany = props => {
14766
14874
  }, props));
14767
14875
  };
14768
14876
 
14769
- var _window$8, _window$Pelcro$8, _window$Pelcro$uiSett$8;
14770
- const ReactGA$8 = (_window$8 = window) !== null && _window$8 !== void 0 && (_window$Pelcro$8 = _window$8.Pelcro) !== null && _window$Pelcro$8 !== void 0 && (_window$Pelcro$uiSett$8 = _window$Pelcro$8.uiSettings) !== null && _window$Pelcro$uiSett$8 !== void 0 && _window$Pelcro$uiSett$8.enableReactGA4 ? ReactGA4 : ReactGA1;
14771
-
14772
14877
  /**
14773
14878
  *
14774
14879
  */
14775
14880
  function RegisterModal(props) {
14881
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
14776
14882
  const {
14777
14883
  t
14778
14884
  } = useTranslation("register");
@@ -14787,18 +14893,26 @@ function RegisterModal(props) {
14787
14893
  giftCode,
14788
14894
  isGift
14789
14895
  } = usePelcro();
14896
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
14790
14897
  const onSuccess = res => {
14791
14898
  var _props$onSuccess;
14792
14899
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
14793
14900
  handleAfterRegistrationLogic();
14794
14901
  };
14795
14902
  const handleAfterRegistrationLogic = () => {
14796
- var _ReactGA$event, _window$Pelcro$site$r, _window$Pelcro$site$r2;
14797
- ReactGA$8 === null || ReactGA$8 === void 0 ? void 0 : (_ReactGA$event = ReactGA$8.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$8, {
14798
- category: "ACTIONS",
14799
- action: "Registered",
14800
- nonInteraction: true
14801
- });
14903
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
14904
+ if (enableReactGA4) {
14905
+ ReactGA4.event("Registered", {
14906
+ nonInteraction: true
14907
+ });
14908
+ } else {
14909
+ var _ReactGA$event;
14910
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
14911
+ category: "ACTIONS",
14912
+ action: "Registered",
14913
+ nonInteraction: true
14914
+ });
14915
+ }
14802
14916
  const isEmailVerificationEnabled = (_window$Pelcro$site$r = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.email_verify_enabled) !== null && _window$Pelcro$site$r !== void 0 ? _window$Pelcro$site$r : false;
14803
14917
  if (isEmailVerificationEnabled) {
14804
14918
  return switchView("email-verify");
@@ -14885,9 +14999,6 @@ function Radio(_ref) {
14885
14999
  }, children));
14886
15000
  }
14887
15001
 
14888
- var _window$7, _window$Pelcro$7, _window$Pelcro$uiSett$7;
14889
- const ReactGA$7 = (_window$7 = window) !== null && _window$7 !== void 0 && (_window$Pelcro$7 = _window$7.Pelcro) !== null && _window$Pelcro$7 !== void 0 && (_window$Pelcro$uiSett$7 = _window$Pelcro$7.uiSettings) !== null && _window$Pelcro$uiSett$7 !== void 0 && _window$Pelcro$uiSett$7.enableReactGA4 ? ReactGA4 : ReactGA1;
14890
-
14891
15002
  /**
14892
15003
  *
14893
15004
  */
@@ -14947,6 +15058,7 @@ function productMatchPageLanguage(product) {
14947
15058
  SelectModalWithHook.viewId = "plan-select";
14948
15059
  class SelectModal extends React.Component {
14949
15060
  constructor(props) {
15061
+ var _window, _window$Pelcro11, _window$Pelcro11$uiSe;
14950
15062
  super(props);
14951
15063
  _defineProperty$3(this, "componentDidMount", () => {
14952
15064
  if (this.props.product) {
@@ -14981,11 +15093,11 @@ class SelectModal extends React.Component {
14981
15093
  }
14982
15094
  document.addEventListener("keydown", this.handleSubmit);
14983
15095
  if (!document.querySelector("#pelcro-selection-view") || !document.querySelector(".pelcro-select-product-wrapper")) {
14984
- var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro4, _window$Pelcro4$user, _window$Pelcro5, _window$Pelcro5$site;
14985
- const userCurrency = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.read().currency;
14986
- const userCountry = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : _window$Pelcro3$user.location.countryCode;
14987
- const userLanguage = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$user = _window$Pelcro4.user) === null || _window$Pelcro4$user === void 0 ? void 0 : _window$Pelcro4$user.read().language;
14988
- const productsMatchingUserCurrency = (_window$Pelcro5 = window.Pelcro) === null || _window$Pelcro5 === void 0 ? void 0 : (_window$Pelcro5$site = _window$Pelcro5.site) === null || _window$Pelcro5$site === void 0 ? void 0 : _window$Pelcro5$site.read().products.filter(product => {
15096
+ var _window$Pelcro, _window$Pelcro$user, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro4, _window$Pelcro4$site;
15097
+ const userCurrency = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.read().currency;
15098
+ const userCountry = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.location.countryCode;
15099
+ const userLanguage = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : _window$Pelcro3$user.read().language;
15100
+ const productsMatchingUserCurrency = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.filter(product => {
14989
15101
  const filteredPlans = product.plans.filter(plan => plan.currency === userCurrency || !userCurrency);
14990
15102
  if (filteredPlans.length) return filteredPlans;
14991
15103
  });
@@ -14998,12 +15110,12 @@ class SelectModal extends React.Component {
14998
15110
  });
14999
15111
  notifyBugsnag(() => {
15000
15112
  Bugsnag.notify("SelectModal - No data viewed", event => {
15001
- var _window$Pelcro6, _window$Pelcro6$site, _window$Pelcro7, _window$Pelcro7$user, _window$Pelcro8, _window$Pelcro8$uiSet, _window$Pelcro9, _this$props, _window$Pelcro10, _window$Pelcro10$help, _window$Pelcro11, _window$Pelcro11$site;
15113
+ var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe, _window$Pelcro10, _window$Pelcro10$site;
15002
15114
  event.addMetadata("MetaData", {
15003
- site: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$site = _window$Pelcro6.site) === null || _window$Pelcro6$site === void 0 ? void 0 : _window$Pelcro6$site.read(),
15004
- user: (_window$Pelcro7 = window.Pelcro) === null || _window$Pelcro7 === void 0 ? void 0 : (_window$Pelcro7$user = _window$Pelcro7.user) === null || _window$Pelcro7$user === void 0 ? void 0 : _window$Pelcro7$user.read(),
15005
- uiVersion: (_window$Pelcro8 = window.Pelcro) === null || _window$Pelcro8 === void 0 ? void 0 : (_window$Pelcro8$uiSet = _window$Pelcro8.uiSettings) === null || _window$Pelcro8$uiSet === void 0 ? void 0 : _window$Pelcro8$uiSet.uiVersion,
15006
- environment: (_window$Pelcro9 = window.Pelcro) === null || _window$Pelcro9 === void 0 ? void 0 : _window$Pelcro9.environment,
15115
+ site: (_window$Pelcro5 = window.Pelcro) === null || _window$Pelcro5 === void 0 ? void 0 : (_window$Pelcro5$site = _window$Pelcro5.site) === null || _window$Pelcro5$site === void 0 ? void 0 : _window$Pelcro5$site.read(),
15116
+ user: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : _window$Pelcro6$user.read(),
15117
+ uiVersion: (_window$Pelcro7 = window.Pelcro) === null || _window$Pelcro7 === void 0 ? void 0 : (_window$Pelcro7$uiSet = _window$Pelcro7.uiSettings) === null || _window$Pelcro7$uiSet === void 0 ? void 0 : _window$Pelcro7$uiSet.uiVersion,
15118
+ environment: (_window$Pelcro8 = window.Pelcro) === null || _window$Pelcro8 === void 0 ? void 0 : _window$Pelcro8.environment,
15007
15119
  matchingEntitlementsProps: (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.matchingEntitlements,
15008
15120
  productListState: this.state.productList,
15009
15121
  methods: {
@@ -15014,8 +15126,8 @@ class SelectModal extends React.Component {
15014
15126
  userCurrency: userCurrency,
15015
15127
  userCountry: userCountry,
15016
15128
  userLanguage: userLanguage,
15017
- siteLanguage: (_window$Pelcro10 = window.Pelcro) === null || _window$Pelcro10 === void 0 ? void 0 : (_window$Pelcro10$help = _window$Pelcro10.helpers) === null || _window$Pelcro10$help === void 0 ? void 0 : _window$Pelcro10$help.getHtmlLanguageAttribute(),
15018
- products: (_window$Pelcro11 = window.Pelcro) === null || _window$Pelcro11 === void 0 ? void 0 : (_window$Pelcro11$site = _window$Pelcro11.site) === null || _window$Pelcro11$site === void 0 ? void 0 : _window$Pelcro11$site.read().products.length,
15129
+ siteLanguage: (_window$Pelcro9 = window.Pelcro) === null || _window$Pelcro9 === void 0 ? void 0 : (_window$Pelcro9$helpe = _window$Pelcro9.helpers) === null || _window$Pelcro9$helpe === void 0 ? void 0 : _window$Pelcro9$helpe.getHtmlLanguageAttribute(),
15130
+ products: (_window$Pelcro10 = window.Pelcro) === null || _window$Pelcro10 === void 0 ? void 0 : (_window$Pelcro10$site = _window$Pelcro10.site) === null || _window$Pelcro10$site === void 0 ? void 0 : _window$Pelcro10$site.read().products.length,
15019
15131
  currency_matching_filter: `${productsMatchingUserCurrency.length} Products Passed`,
15020
15132
  country_matching_filter: `${productsMatchingUserCountry.length} Products Passed`,
15021
15133
  language_matching_filter: `${productsMatchingUserCountry.filter(productMatchPageLanguage).length} Products Passed`
@@ -15054,7 +15166,7 @@ class SelectModal extends React.Component {
15054
15166
  startingPlan = plan;
15055
15167
  }
15056
15168
  }
15057
- return `${startingPlan.amount_formatted}/${startingPlan.interval_count > 1 ? `${startingPlan.interval_count} ${startingPlan.interval}s` : `${startingPlan.interval}`}`;
15169
+ return `${startingPlan.amount_formatted}/${startingPlan.interval_count > 1 ? `${startingPlan.interval_count} ${startingPlan.interval_translated}` : `${startingPlan.interval_translated}`}`;
15058
15170
  });
15059
15171
  _defineProperty$3(this, "renderOneProduct", (product, index, options) => {
15060
15172
  const isPlanMode = Boolean(this.state.mode === "plan");
@@ -15227,6 +15339,7 @@ class SelectModal extends React.Component {
15227
15339
  this.product = this.props.product || window.Pelcro.paywall.getProduct();
15228
15340
  this.locale = this.props.t;
15229
15341
  this.closeButton = window.Pelcro.paywall.displayCloseButton();
15342
+ this.enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro11 = _window.Pelcro) === null || _window$Pelcro11 === void 0 ? void 0 : (_window$Pelcro11$uiSe = _window$Pelcro11.uiSettings) === null || _window$Pelcro11$uiSe === void 0 ? void 0 : _window$Pelcro11$uiSe.enableReactGA4;
15230
15343
  }
15231
15344
  render() {
15232
15345
  var _window$Pelcro$produc2, _window$Pelcro$produc3, _window$Pelcro$site$r;
@@ -15234,19 +15347,31 @@ class SelectModal extends React.Component {
15234
15347
  disableGifting
15235
15348
  } = this.props;
15236
15349
  if (this.state.mode === "product") {
15237
- var _ReactGA$event;
15238
- ReactGA$7 === null || ReactGA$7 === void 0 ? void 0 : (_ReactGA$event = ReactGA$7.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$7, {
15239
- category: "VIEWS",
15240
- action: "Product Modal Viewed",
15241
- nonInteraction: true
15242
- });
15350
+ if (this.enableReactGA4) {
15351
+ ReactGA4.event("Product Modal Viewed", {
15352
+ nonInteraction: true
15353
+ });
15354
+ } else {
15355
+ var _ReactGA$event;
15356
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
15357
+ category: "VIEWS",
15358
+ action: "Product Modal Viewed",
15359
+ nonInteraction: true
15360
+ });
15361
+ }
15243
15362
  } else if (this.state.mode === "plan") {
15244
- var _ReactGA$event2;
15245
- ReactGA$7 === null || ReactGA$7 === void 0 ? void 0 : (_ReactGA$event2 = ReactGA$7.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA$7, {
15246
- category: "VIEWS",
15247
- action: "Plan Modal Viewed",
15248
- nonInteraction: true
15249
- });
15363
+ if (this.enableReactGA4) {
15364
+ ReactGA4.event("Plan Modal Viewed", {
15365
+ nonInteraction: true
15366
+ });
15367
+ } else {
15368
+ var _ReactGA$event2;
15369
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
15370
+ category: "VIEWS",
15371
+ action: "Plan Modal Viewed",
15372
+ nonInteraction: true
15373
+ });
15374
+ }
15250
15375
  }
15251
15376
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
15252
15377
  hideCloseButton: !this.closeButton,
@@ -15677,14 +15802,14 @@ class DonationModal extends React.Component {
15677
15802
  this.props;
15678
15803
  if (this.state.mode === "product") {
15679
15804
  var _ReactGA$event;
15680
- ReactGA1 === null || ReactGA1 === void 0 ? void 0 : (_ReactGA$event = ReactGA1.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA1, {
15805
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
15681
15806
  category: "VIEWS",
15682
15807
  action: "Product Modal Viewed",
15683
15808
  nonInteraction: true
15684
15809
  });
15685
15810
  } else if (this.state.mode === "plan") {
15686
15811
  var _ReactGA$event2;
15687
- ReactGA1 === null || ReactGA1 === void 0 ? void 0 : (_ReactGA$event2 = ReactGA1.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA1, {
15812
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
15688
15813
  category: "VIEWS",
15689
15814
  action: "Plan Modal Viewed",
15690
15815
  nonInteraction: true
@@ -18021,7 +18146,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18021
18146
  });
18022
18147
  };
18023
18148
 
18024
- /*====== Start Cybersource integration ========*/
18149
+ /* ====== Start Cybersource integration ======== */
18025
18150
  const cybersourceErrorHandle = err => {
18026
18151
  var _err$details, _err$details$response, _err$details$response2;
18027
18152
  if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
@@ -18290,9 +18415,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18290
18415
  });
18291
18416
  };
18292
18417
 
18293
- /*====== End Cybersource integration ========*/
18418
+ /* ====== End Cybersource integration ======== */
18294
18419
 
18295
- /*====== Start Tap integration ========*/
18420
+ /* ====== Start Tap integration ======== */
18296
18421
  const submitUsingTap = state => {
18297
18422
  var _ref4, _ref5, _getPlanAmount;
18298
18423
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -18564,28 +18689,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18564
18689
  cardHolder: "Card Holder Name"
18565
18690
  };
18566
18691
 
18567
- //payment options
18692
+ // payment options
18568
18693
  let paymentOptions = {
18569
18694
  labels: labels,
18570
18695
  TextDirection: "ltr"
18571
18696
  };
18572
18697
 
18573
- //create element, pass style and payment options
18698
+ // create element, pass style and payment options
18574
18699
  let card = elements.create("card", {
18575
18700
  style: style
18576
18701
  }, paymentOptions);
18577
18702
 
18578
- //mount element
18703
+ // mount element
18579
18704
  card.mount("#tapPaymentIframe");
18580
18705
 
18581
- //card change event listener
18706
+ // card change event listener
18582
18707
  card.addEventListener("change", function (event) {
18583
- //If needed
18708
+ // If needed
18584
18709
  });
18585
18710
  tapInstanceRef.current = tapKey;
18586
18711
  tapInstanceCard.current = card;
18587
18712
  };
18588
- /*====== End Tap integration ========*/
18713
+ /* ====== End Tap integration ======== */
18589
18714
 
18590
18715
  const submitUsingVantiv = state => {
18591
18716
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -18773,7 +18898,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18773
18898
  }
18774
18899
  }, [selectedPaymentMethodId]);
18775
18900
 
18776
- //Trigger the handleVantivPayment method when a vantivePaymentRequest is present
18901
+ // Trigger the handleVantivPayment method when a vantivPaymentRequest is present
18777
18902
  React.useEffect(() => {
18778
18903
  if (vantivPaymentRequest) {
18779
18904
  handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
@@ -18933,7 +19058,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18933
19058
  if (err) {
18934
19059
  onFailure(err);
18935
19060
 
18936
- //reset the coupon code in local state
19061
+ // reset the coupon code in local state
18937
19062
  setUpdatedCouponCode("");
18938
19063
  dispatch({
18939
19064
  type: SET_COUPON_ERROR,
@@ -18994,7 +19119,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18994
19119
  payload: res.data.coupon
18995
19120
  });
18996
19121
 
18997
- //set the coupon code in local state to be able to use with Vantiv
19122
+ // set the coupon code in local state to be able to use with Vantiv
18998
19123
  setUpdatedCouponCode(res.data.coupon.code);
18999
19124
  dispatch({
19000
19125
  type: SET_PERCENT_OFF,
@@ -19067,7 +19192,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19067
19192
  const removeAppliedCoupon = state => {
19068
19193
  state.couponCode = "";
19069
19194
 
19070
- //reset the coupon code in local state
19195
+ // reset the coupon code in local state
19071
19196
  setUpdatedCouponCode("");
19072
19197
  dispatch({
19073
19198
  type: SET_COUPON_ERROR,
@@ -19888,6 +20013,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19888
20013
  handlePaypalSubscription(state, action.payload);
19889
20014
  }
19890
20015
  });
20016
+ case HANDLE_APPLEPAY_SUBSCRIPTION:
20017
+ return lib_5(state, (state, dispatch) => {
20018
+ setVantivPaymentRequest(action.payload);
20019
+ });
19891
20020
  case SET_UPDATED_PRICE:
19892
20021
  return lib_7({
19893
20022
  ...state,
@@ -21029,6 +21158,290 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
21029
21158
  store: store$k
21030
21159
  }, props));
21031
21160
 
21161
+ /* eslint-disable no-undef */
21162
+
21163
+ /**
21164
+ * ApplePayButton component
21165
+ * @return {JSX}
21166
+ */
21167
+ const ApplePayButton = _ref => {
21168
+ var _window$Pelcro$site$r, _ref2, _ref3, _state$updatedPrice, _props$plan;
21169
+ let {
21170
+ onClick,
21171
+ props,
21172
+ ...otherProps
21173
+ } = _ref;
21174
+ const {
21175
+ dispatch,
21176
+ state
21177
+ } = React.useContext(store$k);
21178
+ const {
21179
+ plan,
21180
+ invoice
21181
+ } = usePelcro();
21182
+ const {
21183
+ pay_page_id: payPageId,
21184
+ report_group: reportGroup,
21185
+ apple_pay_merchant_id: ApplePayMerchantId,
21186
+ apple_pay_enabled: ApplePayEnabled
21187
+ } = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
21188
+ const updatedPrice = (_ref2 = (_ref3 = (_state$updatedPrice = state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : props === null || props === void 0 ? void 0 : (_props$plan = props.plan) === null || _props$plan === void 0 ? void 0 : _props$plan.amount) !== null && _ref3 !== void 0 ? _ref3 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining;
21189
+ React.useEffect(() => {
21190
+ if (window.ApplePaySession) {
21191
+ // Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
21192
+ const promise = ApplePaySession.canMakePaymentsWithActiveCard(ApplePayMerchantId);
21193
+ promise.then(function (canMakePayments) {
21194
+ if (canMakePayments && ApplePayEnabled) {
21195
+ // Display Apple Pay Buttons here…
21196
+ const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
21197
+ if (pelcroApplyPayButton) {
21198
+ pelcroApplyPayButton.style.display = "block";
21199
+ }
21200
+ console.log("canMakePayments", canMakePayments);
21201
+ }
21202
+ });
21203
+ } else {
21204
+ console.error("ApplePay is not available on this browser");
21205
+ }
21206
+ }, []);
21207
+ function onApplePayButtonClicked() {
21208
+ var _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$l;
21209
+ if (!ApplePaySession) {
21210
+ return;
21211
+ }
21212
+ dispatch({
21213
+ type: DISABLE_SUBMIT,
21214
+ payload: true
21215
+ });
21216
+
21217
+ // Define ApplePayPaymentRequest
21218
+ // @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
21219
+ const ApplePayPaymentRequest = {
21220
+ countryCode: ((_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : (_window$Pelcro$user$l = _window$Pelcro$user.location) === null || _window$Pelcro$user$l === void 0 ? void 0 : _window$Pelcro$user$l.countryCode) || "US",
21221
+ currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
21222
+ merchantCapabilities: ["supports3DS"],
21223
+ supportedNetworks: ["visa", "masterCard", "amex", "discover"],
21224
+ total: {
21225
+ label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
21226
+ type: "final",
21227
+ amount: updatedPrice / 100
21228
+ }
21229
+ };
21230
+ console.log(ApplePayPaymentRequest);
21231
+ // Create ApplePaySession
21232
+ // @todo - Clarify supported version parameter
21233
+ // @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
21234
+ const session = new ApplePaySession(3, ApplePayPaymentRequest);
21235
+
21236
+ // @todo - Detect whether web browser supports a particular Apple Pay version.
21237
+ // @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
21238
+
21239
+ session.onvalidatemerchant = async event => {
21240
+ const {
21241
+ validationURL
21242
+ } = event;
21243
+ console.log("then merchantSession step", event);
21244
+ // Call your own server to request a new merchant session.
21245
+ window.Pelcro.payment.startSession({
21246
+ auth_token: window.Pelcro.user.read().auth_token,
21247
+ site_id: window.Pelcro.siteid,
21248
+ validation_url: validationURL
21249
+ }, (err, res) => {
21250
+ if (err) {
21251
+ // Handle any errors during merchant validation
21252
+ console.error("Merchant validation SDK error: ", err);
21253
+ session.abort();
21254
+ return dispatch({
21255
+ type: SHOW_ALERT,
21256
+ payload: {
21257
+ type: "error",
21258
+ content: getErrorMessages(err)
21259
+ }
21260
+ });
21261
+ }
21262
+ // Complete merchant validation with the merchant session object
21263
+ console.log("Merchant validation SDK response: ", res);
21264
+ const merchantSession = res;
21265
+ session.completeMerchantValidation(merchantSession);
21266
+ });
21267
+ };
21268
+ session.onpaymentmethodselected = event => {
21269
+ console.log("payment method selected step", event);
21270
+ // Define ApplePayPaymentMethodUpdate based on the selected payment method.
21271
+ // No updates or errors are needed, pass an empty object.
21272
+ const newTotal = {
21273
+ label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
21274
+ type: "final",
21275
+ amount: updatedPrice / 100
21276
+ };
21277
+ const newLineItems = [{
21278
+ label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
21279
+ type: "final",
21280
+ amount: updatedPrice / 100
21281
+ }];
21282
+ session.completePaymentMethodSelection(newTotal, newLineItems);
21283
+ };
21284
+
21285
+ // TODO: Check if onshippingmethodselected it should be implemented
21286
+ // session.onshippingmethodselected = (event) => {
21287
+ // console.log("on shipping method selected step", event);
21288
+ // // Define ApplePayShippingMethodUpdate based on the selected shipping method.
21289
+ // // No updates or errors are needed, pass an empty object.
21290
+ // const newTotal = {
21291
+ // label: plan?.nickname || `invoice #${invoice.id}`,
21292
+ // type: "final",
21293
+ // amount: updatedPrice / 100
21294
+ // };
21295
+
21296
+ // const newLineItems = [
21297
+ // {
21298
+ // label: plan?.nickname || `invoice #${invoice.id}`,
21299
+ // type: "final",
21300
+ // amount: updatedPrice / 100
21301
+ // }
21302
+ // ];
21303
+
21304
+ // session.completeShippingMethodSelection(newTotal, newLineItems);
21305
+ // };
21306
+
21307
+ // TODO: Check if onshippingcontactselected it should be implemented
21308
+ // session.onshippingcontactselected = (event) => {
21309
+ // console.log("on shipping contact selected step", event);
21310
+ // // Define ApplePayShippingContactUpdate based on the selected shipping contact.
21311
+ // const update = {};
21312
+ // session.completeShippingContactSelection(update);
21313
+ // };
21314
+
21315
+ session.onpaymentauthorized = event => {
21316
+ console.log("on payment authorized step", event);
21317
+ // Define ApplePayPaymentAuthorizationResult
21318
+ const result = {
21319
+ status: ApplePaySession.STATUS_SUCCESS
21320
+ };
21321
+ const {
21322
+ paymentData
21323
+ } = event.payment.token;
21324
+ const {
21325
+ data,
21326
+ signature,
21327
+ version
21328
+ } = paymentData;
21329
+ const {
21330
+ ephemeralPublicKey,
21331
+ publicKeyHash,
21332
+ transactionId
21333
+ } = paymentData.header;
21334
+ const applePayToken = {
21335
+ data: data,
21336
+ signature: signature,
21337
+ version: version,
21338
+ header: {
21339
+ ephemeralPublicKey: ephemeralPublicKey,
21340
+ publicKeyHash: publicKeyHash,
21341
+ transactionId: transactionId
21342
+ }
21343
+ };
21344
+ console.log(applePayToken);
21345
+ const orderId = `pelcro-${new Date().getTime()}`;
21346
+ const eProtectRequest = {
21347
+ paypageId: payPageId,
21348
+ reportGroup: reportGroup,
21349
+ orderId: orderId,
21350
+ id: orderId,
21351
+ applepay: applePayToken,
21352
+ url: "https://request.eprotect.vantivprelive.com"
21353
+ };
21354
+
21355
+ // successCallback function to handle the response from WorldPay.
21356
+ function successCallback(vantivResponse) {
21357
+ const {
21358
+ expDate
21359
+ } = vantivResponse;
21360
+ console.log("Response:", vantivResponse);
21361
+ const expMonth = expDate.substring(0, 2);
21362
+ const expYear = expDate.substring(2);
21363
+ const vantivPaymentRequest = {
21364
+ ...vantivResponse,
21365
+ expMonth: expMonth,
21366
+ expYear: expYear
21367
+ };
21368
+
21369
+ // Process the registrationId or continue with further payment processing.
21370
+ dispatch({
21371
+ type: HANDLE_APPLEPAY_SUBSCRIPTION,
21372
+ payload: vantivPaymentRequest
21373
+ });
21374
+ dispatch({
21375
+ type: LOADING,
21376
+ payload: true
21377
+ });
21378
+ session.completePayment(result);
21379
+ }
21380
+
21381
+ // errorCallback function to handle any errors that may occur during the tokenization process.
21382
+ function errorCallback(error) {
21383
+ console.error("Error retrieving Registration ID:", error);
21384
+ // Handle error appropriately.
21385
+ }
21386
+ // errorCallback function to handle any errors that may occur during the tokenization process.
21387
+ function timeoutCallback() {
21388
+ console.error("eProtect Timeout");
21389
+ // Handle error appropriately.
21390
+ }
21391
+
21392
+ new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
21393
+ };
21394
+
21395
+ // TODO: Check if oncouponcodechanged it should be implemented
21396
+ // session.oncouponcodechanged = (event) => {
21397
+ // console.log("on coupon code changed step", event);
21398
+ // // Define ApplePayCouponCodeUpdate
21399
+ // const newTotal = calculateNewTotal(event.couponCode);
21400
+ // const newLineItems = calculateNewLineItems(event.couponCode);
21401
+ // const newShippingMethods = calculateNewShippingMethods(
21402
+ // event.couponCode
21403
+ // );
21404
+ // const errors = calculateErrors(event.couponCode);
21405
+
21406
+ // session.completeCouponCodeChange({
21407
+ // newTotal: newTotal,
21408
+ // newLineItems: newLineItems,
21409
+ // newShippingMethods: newShippingMethods,
21410
+ // errors: errors
21411
+ // });
21412
+ // };
21413
+
21414
+ session.oncancel = event => {
21415
+ // Payment cancelled by WebKit
21416
+ console.log("on cancel step", event);
21417
+ dispatch({
21418
+ type: LOADING,
21419
+ payload: false
21420
+ });
21421
+ dispatch({
21422
+ type: DISABLE_SUBMIT,
21423
+ payload: false
21424
+ });
21425
+ };
21426
+ session.begin();
21427
+ }
21428
+ React.useEffect(() => {
21429
+ const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
21430
+ if (pelcroApplyPayButton) {
21431
+ pelcroApplyPayButton.addEventListener("click", onApplePayButtonClicked);
21432
+ }
21433
+ }, []);
21434
+ return /*#__PURE__*/React__default['default'].createElement("apple-pay-button", {
21435
+ id: "pelcro-apple-pay-button",
21436
+ style: {
21437
+ display: "none"
21438
+ },
21439
+ buttonstyle: "black",
21440
+ type: "plain",
21441
+ locale: "en-US"
21442
+ });
21443
+ };
21444
+
21032
21445
  /**
21033
21446
  *
21034
21447
  */
@@ -21043,6 +21456,7 @@ function PaymentMethodView(_ref) {
21043
21456
  showExternalPaymentMethods,
21044
21457
  showSubscriptionButton,
21045
21458
  showOrderButton,
21459
+ showApplePayButton,
21046
21460
  order
21047
21461
  } = _ref;
21048
21462
  const {
@@ -21119,7 +21533,7 @@ function PaymentMethodView(_ref) {
21119
21533
  className: "plc-mb-2"
21120
21534
  }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
21121
21535
  className: "plc-grid plc-mt-4 plc-gap-y-2"
21122
- }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
21536
+ }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null, showApplePayButton && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ApplePayButton, null)) : null)))));
21123
21537
  }
21124
21538
 
21125
21539
  const SubscriptionRenewView = _ref => {
@@ -21141,11 +21555,11 @@ const SubscriptionRenewView = _ref => {
21141
21555
  const getPricingText = plan => {
21142
21556
  const autoRenewed = plan.auto_renew;
21143
21557
  const {
21144
- interval,
21558
+ interval_translated,
21145
21559
  interval_count
21146
21560
  } = plan;
21147
21561
  const intervalText = t("labels.interval", {
21148
- interval,
21562
+ interval: interval_translated,
21149
21563
  count: interval_count
21150
21564
  });
21151
21565
  return /*#__PURE__*/React__default['default'].createElement("p", {
@@ -21170,6 +21584,7 @@ const SubscriptionRenewView = _ref => {
21170
21584
  type: "createPayment",
21171
21585
  showCoupon: true,
21172
21586
  showExternalPaymentMethods: false,
21587
+ showApplePayButton: true,
21173
21588
  onSuccess: onSuccess,
21174
21589
  onGiftRenewalSuccess: onGiftRenewalSuccess,
21175
21590
  onFailure: onFailure,
@@ -21177,13 +21592,11 @@ const SubscriptionRenewView = _ref => {
21177
21592
  }));
21178
21593
  };
21179
21594
 
21180
- var _window$6, _window$Pelcro$6, _window$Pelcro$uiSett$6;
21181
- const ReactGA$6 = (_window$6 = window) !== null && _window$6 !== void 0 && (_window$Pelcro$6 = _window$6.Pelcro) !== null && _window$Pelcro$6 !== void 0 && (_window$Pelcro$uiSett$6 = _window$Pelcro$6.uiSettings) !== null && _window$Pelcro$uiSett$6 !== void 0 && _window$Pelcro$uiSett$6.enableReactGA4 ? ReactGA4 : ReactGA1;
21182
-
21183
21595
  /**
21184
21596
  *
21185
21597
  */
21186
21598
  function SubscriptionRenewModal(_ref) {
21599
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
21187
21600
  let {
21188
21601
  onDisplay,
21189
21602
  onClose,
@@ -21192,24 +21605,39 @@ function SubscriptionRenewModal(_ref) {
21192
21605
  const {
21193
21606
  switchView
21194
21607
  } = usePelcro();
21608
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
21195
21609
  const onSuccess = res => {
21196
- var _otherProps$onSuccess, _ReactGA$event;
21610
+ var _otherProps$onSuccess;
21197
21611
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, res);
21198
- ReactGA$6 === null || ReactGA$6 === void 0 ? void 0 : (_ReactGA$event = ReactGA$6.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$6, {
21199
- category: "ACTIONS",
21200
- action: "Renewed",
21201
- nonInteraction: true
21202
- });
21612
+ if (enableReactGA4) {
21613
+ ReactGA4.event("Renewed", {
21614
+ nonInteraction: true
21615
+ });
21616
+ } else {
21617
+ var _ReactGA$event;
21618
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
21619
+ category: "ACTIONS",
21620
+ action: "Renewed",
21621
+ nonInteraction: true
21622
+ });
21623
+ }
21203
21624
  return switchView("subscription-success");
21204
21625
  };
21205
21626
  const onGiftRenewalSuccess = () => {
21206
- var _otherProps$onGiftRen, _ReactGA$event2;
21627
+ var _otherProps$onGiftRen;
21207
21628
  (_otherProps$onGiftRen = otherProps.onGiftRenewalSuccess) === null || _otherProps$onGiftRen === void 0 ? void 0 : _otherProps$onGiftRen.call(otherProps);
21208
- ReactGA$6 === null || ReactGA$6 === void 0 ? void 0 : (_ReactGA$event2 = ReactGA$6.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA$6, {
21209
- category: "ACTIONS",
21210
- action: "Renewed Gift",
21211
- nonInteraction: true
21212
- });
21629
+ if (enableReactGA4) {
21630
+ ReactGA4.event("Renewed Gift", {
21631
+ nonInteraction: true
21632
+ });
21633
+ } else {
21634
+ var _ReactGA$event2;
21635
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
21636
+ category: "ACTIONS",
21637
+ action: "Renewed Gift",
21638
+ nonInteraction: true
21639
+ });
21640
+ }
21213
21641
  return switchView("subscription-success");
21214
21642
  };
21215
21643
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
@@ -21224,7 +21652,8 @@ function SubscriptionRenewModal(_ref) {
21224
21652
  SubscriptionRenewModal.viewId = "subscription-renew";
21225
21653
 
21226
21654
  const initialState$j = {
21227
- cancelationReason: ""
21655
+ cancelationReason: "",
21656
+ cancelationOption: ""
21228
21657
  };
21229
21658
  const store$j = /*#__PURE__*/React.createContext(initialState$j);
21230
21659
  const {
@@ -21239,7 +21668,6 @@ const SubscriptionCancelContainer = _ref => {
21239
21668
  children,
21240
21669
  ...props
21241
21670
  } = _ref;
21242
- useTranslation("verifyEmail");
21243
21671
  const [state, dispatch] = useReducerWithSideEffects((state, action) => {
21244
21672
  switch (action.type) {
21245
21673
  case SET_CANCEL_SUBSCRIPTION_REASON:
@@ -21247,6 +21675,11 @@ const SubscriptionCancelContainer = _ref => {
21247
21675
  ...state,
21248
21676
  cancelationReason: action.payload
21249
21677
  });
21678
+ case SET_CANCEL_SUBSCRIPTION_OPTION:
21679
+ return lib_7({
21680
+ ...state,
21681
+ cancelationOption: action.payload
21682
+ });
21250
21683
  default:
21251
21684
  return state;
21252
21685
  }
@@ -21346,8 +21779,7 @@ const SubscriptionCancelReason = props => {
21346
21779
  t
21347
21780
  } = useTranslation("subscriptionCancel");
21348
21781
  const {
21349
- dispatch,
21350
- state
21782
+ dispatch
21351
21783
  } = React.useContext(store$j);
21352
21784
  const handleOnTextAreaBlur = e => {
21353
21785
  dispatch({
@@ -21379,9 +21811,7 @@ function SvgSubscription(props) {
21379
21811
  }))))));
21380
21812
  }
21381
21813
 
21382
- var _window$5, _window$Pelcro$5, _window$Pelcro$uiSett$5;
21383
- const ReactGA$5 = (_window$5 = window) !== null && _window$5 !== void 0 && (_window$Pelcro$5 = _window$5.Pelcro) !== null && _window$Pelcro$5 !== void 0 && (_window$Pelcro$uiSett$5 = _window$Pelcro$5.uiSettings) !== null && _window$Pelcro$uiSett$5 !== void 0 && _window$Pelcro$uiSett$5.enableReactGA4 ? ReactGA4 : ReactGA1;
21384
- const SubscriptionCancelNowButton = _ref => {
21814
+ const SubscriptionCancelButton = _ref => {
21385
21815
  let {
21386
21816
  subscription,
21387
21817
  onClick,
@@ -21392,14 +21822,16 @@ const SubscriptionCancelNowButton = _ref => {
21392
21822
  } = usePelcro();
21393
21823
  const {
21394
21824
  state: {
21395
- cancelationReason
21396
- },
21397
- dispatch
21825
+ cancelationReason,
21826
+ cancelationOption
21827
+ }
21398
21828
  } = React.useContext(store$j);
21399
21829
  const {
21400
21830
  t
21401
21831
  } = useTranslation("subscriptionCancel");
21402
21832
  const cancelSubscription = (payload, onSuccess, onFailure) => {
21833
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
21834
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
21403
21835
  window.Pelcro.subscription.cancel({
21404
21836
  auth_token: window.Pelcro.user.read().auth_token,
21405
21837
  subscription_id: payload.subscription_id,
@@ -21408,36 +21840,42 @@ const SubscriptionCancelNowButton = _ref => {
21408
21840
  reason: payload.reason
21409
21841
  })
21410
21842
  }, (err, res) => {
21411
- var _ReactGA$event;
21412
21843
  if (err) {
21413
21844
  return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
21414
21845
  }
21415
- ReactGA$5 === null || ReactGA$5 === void 0 ? void 0 : (_ReactGA$event = ReactGA$5.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$5, {
21416
- category: "ACTIONS",
21417
- action: "Canceled",
21418
- nonInteraction: true
21419
- });
21846
+ if (enableReactGA4) {
21847
+ ReactGA4.event("Canceled", {
21848
+ nonInteraction: true
21849
+ });
21850
+ } else {
21851
+ var _ReactGA$event;
21852
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
21853
+ category: "ACTIONS",
21854
+ action: "Canceled",
21855
+ nonInteraction: true
21856
+ });
21857
+ }
21420
21858
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
21421
21859
  });
21422
21860
  };
21423
- const handleCancelNowClick = () => {
21861
+ const handleCancelClick = () => {
21424
21862
  const payload = {
21425
21863
  subscription_id: subscription.id,
21426
- mode: "now",
21864
+ mode: cancelationOption,
21427
21865
  ...(cancelationReason && {
21428
21866
  reason: cancelationReason
21429
21867
  })
21430
21868
  };
21431
21869
  onClick === null || onClick === void 0 ? void 0 : onClick();
21432
21870
 
21433
- //Close the modal
21871
+ // Close the modal
21434
21872
  switchView(null);
21435
21873
 
21436
- //Show confirmation alert after closing the modal
21874
+ // Show confirmation alert after closing the modal
21437
21875
  notify.confirm((onSuccess, onFailure) => {
21438
21876
  cancelSubscription(payload, onSuccess, onFailure);
21439
21877
  }, {
21440
- confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
21878
+ confirmMessage: cancelationOption === "now" ? t("messages.subCancellation.isSureToCancelNow") : t("messages.subCancellation.isSureToCancel"),
21441
21879
  loadingMessage: t("messages.subCancellation.loading"),
21442
21880
  successMessage: t("messages.subCancellation.success"),
21443
21881
  errorMessage: t("messages.subCancellation.error")
@@ -21446,90 +21884,89 @@ const SubscriptionCancelNowButton = _ref => {
21446
21884
  });
21447
21885
  };
21448
21886
  return /*#__PURE__*/React__default['default'].createElement(Button, {
21449
- onClick: handleCancelNowClick,
21450
- className: `${className}`
21451
- }, t("messages.cancelNow"));
21887
+ onClick: handleCancelClick,
21888
+ className: `${className}`,
21889
+ disabled: !cancelationOption
21890
+ }, t("labels.cancel"));
21452
21891
  };
21453
21892
 
21454
- var _window$4, _window$Pelcro$4, _window$Pelcro$uiSett$4;
21455
- const ReactGA$4 = (_window$4 = window) !== null && _window$4 !== void 0 && (_window$Pelcro$4 = _window$4.Pelcro) !== null && _window$Pelcro$4 !== void 0 && (_window$Pelcro$uiSett$4 = _window$Pelcro$4.uiSettings) !== null && _window$Pelcro$uiSett$4 !== void 0 && _window$Pelcro$uiSett$4.enableReactGA4 ? ReactGA4 : ReactGA1;
21456
- const SubscriptionCancelLaterButton = _ref => {
21893
+ // New cancellation option modal
21894
+ const SubscriptionCancelOptions = _ref => {
21895
+ var _subscription$schedul;
21457
21896
  let {
21458
21897
  subscription,
21898
+ hasPhases,
21459
21899
  onClick,
21460
21900
  className
21461
21901
  } = _ref;
21462
- const {
21463
- switchView
21464
- } = usePelcro();
21465
21902
  const {
21466
21903
  state: {
21467
- cancelationReason
21904
+ cancelationOption
21468
21905
  },
21469
21906
  dispatch
21470
21907
  } = React.useContext(store$j);
21471
21908
  const {
21472
21909
  t
21473
21910
  } = useTranslation("subscriptionCancel");
21474
- const cancelSubscription = (payload, onSuccess, onFailure) => {
21475
- window.Pelcro.subscription.cancel({
21476
- auth_token: window.Pelcro.user.read().auth_token,
21477
- subscription_id: payload.subscription_id,
21478
- mode: payload.mode,
21479
- ...(payload.reason && {
21480
- reason: payload.reason
21481
- })
21482
- }, (err, res) => {
21483
- var _ReactGA$event;
21484
- if (err) {
21485
- return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
21486
- }
21487
- ReactGA$4 === null || ReactGA$4 === void 0 ? void 0 : (_ReactGA$event = ReactGA$4.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$4, {
21488
- category: "ACTIONS",
21489
- action: "Canceled",
21490
- nonInteraction: true
21491
- });
21492
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
21493
- });
21494
- };
21495
- const handleCancelNowClick = () => {
21496
- const payload = {
21497
- subscription_id: subscription.id,
21498
- mode: "period_end",
21499
- ...(cancelationReason && {
21500
- reason: cancelationReason
21501
- })
21502
- };
21503
- onClick === null || onClick === void 0 ? void 0 : onClick();
21504
-
21505
- //Close the modal
21506
- switchView(null);
21507
-
21508
- //Show confirmation alert after closing the modal
21509
- notify.confirm((onSuccess, onFailure) => {
21510
- cancelSubscription(payload, onSuccess, onFailure);
21511
- }, {
21512
- confirmMessage: t("messages.subCancellation.isSureToCancel"),
21513
- loadingMessage: t("messages.subCancellation.loading"),
21514
- successMessage: t("messages.subCancellation.success"),
21515
- errorMessage: t("messages.subCancellation.error")
21516
- }, {
21517
- closeButtonLabel: t("labels.subCancellation.goBack")
21911
+ const phases = subscription === null || subscription === void 0 ? void 0 : (_subscription$schedul = subscription.schedule) === null || _subscription$schedul === void 0 ? void 0 : _subscription$schedul.phases;
21912
+ const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
21913
+ const handleOptionSelect = event => {
21914
+ dispatch({
21915
+ type: SET_CANCEL_SUBSCRIPTION_OPTION,
21916
+ payload: event.target.value
21518
21917
  });
21519
21918
  };
21520
- return /*#__PURE__*/React__default['default'].createElement(Button, {
21521
- onClick: handleCancelNowClick,
21522
- className: `${className}`
21523
- }, t("messages.cancelLater"));
21919
+ return /*#__PURE__*/React__default['default'].createElement("div", {
21920
+ className: "plc-text-left plc-mr-auto plc-mb-6"
21921
+ }, /*#__PURE__*/React__default['default'].createElement("p", {
21922
+ className: "plc-mb-3"
21923
+ }, t("messages.cancelWhen")), subscription.cancel_at_period_end === 0 && hasPhases && /*#__PURE__*/React__default['default'].createElement(Radio, {
21924
+ onChange: handleOptionSelect,
21925
+ checked: cancelationOption === "period_end",
21926
+ value: "period_end"
21927
+ }, t("labels.endOn"), " ", new Date(Number(`${lastPhase === null || lastPhase === void 0 ? void 0 : lastPhase.end_date}000`)).toLocaleDateString("en-CA", {
21928
+ year: "numeric",
21929
+ month: "short",
21930
+ day: "numeric"
21931
+ })), subscription.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(Radio, {
21932
+ onChange: handleOptionSelect,
21933
+ checked: cancelationOption === "current_period_end",
21934
+ value: "current_period_end"
21935
+ }, t("labels.endOn"), " ", new Date(subscription === null || subscription === void 0 ? void 0 : subscription.current_period_end).toLocaleDateString("en-CA", {
21936
+ year: "numeric",
21937
+ month: "short",
21938
+ day: "numeric"
21939
+ })), /*#__PURE__*/React__default['default'].createElement(Radio, {
21940
+ onChange: handleOptionSelect,
21941
+ checked: cancelationOption === "now",
21942
+ value: "now"
21943
+ }, t("labels.endImmediately")));
21524
21944
  };
21525
21945
 
21526
21946
  const SubscriptionCancelView = props => {
21947
+ var _subscriptionToCancel7, _subscriptionToCancel8;
21527
21948
  const {
21528
- subscriptionToCancel
21949
+ subscriptionToCancel,
21950
+ switchView
21529
21951
  } = usePelcro();
21530
21952
  const {
21531
21953
  t
21532
21954
  } = useTranslation("subscriptionCancel");
21955
+ const getPhases = () => {
21956
+ var _subscriptionToCancel, _subscriptionToCancel2, _subscriptionToCancel3, _subscriptionToCancel4, _subscriptionToCancel5, _subscriptionToCancel6;
21957
+ if (!subscriptionToCancel.schedule) return [];
21958
+ const currentPhaseStartDate = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel = subscriptionToCancel.schedule) === null || _subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel2 = _subscriptionToCancel.current_phase) === null || _subscriptionToCancel2 === void 0 ? void 0 : _subscriptionToCancel2.start_date;
21959
+ const currentPhase = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel3 = subscriptionToCancel.schedule) === null || _subscriptionToCancel3 === void 0 ? void 0 : (_subscriptionToCancel4 = _subscriptionToCancel3.phases) === null || _subscriptionToCancel4 === void 0 ? void 0 : _subscriptionToCancel4.find(phase => {
21960
+ return (phase === null || phase === void 0 ? void 0 : phase.start_date) === currentPhaseStartDate;
21961
+ });
21962
+ const futurePhases = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel5 = subscriptionToCancel.schedule) === null || _subscriptionToCancel5 === void 0 ? void 0 : (_subscriptionToCancel6 = _subscriptionToCancel5.phases) === null || _subscriptionToCancel6 === void 0 ? void 0 : _subscriptionToCancel6.filter(phase => {
21963
+ return (phase === null || phase === void 0 ? void 0 : phase.start_date) > currentPhaseStartDate;
21964
+ });
21965
+ return [currentPhase, ...futurePhases];
21966
+ };
21967
+ const hasPhases = getPhases().length > 0;
21968
+ const phases = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel7 = subscriptionToCancel.schedule) === null || _subscriptionToCancel7 === void 0 ? void 0 : _subscriptionToCancel7.phases;
21969
+ const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
21533
21970
  return /*#__PURE__*/React__default['default'].createElement("div", {
21534
21971
  id: "pelcro-subscription-cancel-view"
21535
21972
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -21538,22 +21975,35 @@ const SubscriptionCancelView = props => {
21538
21975
  className: "plc-text-2xl plc-font-semibold"
21539
21976
  }, t("labels.title"), /*#__PURE__*/React__default['default'].createElement("span", {
21540
21977
  className: "plc-text-gray-400 plc-text-base plc-block"
21541
- }, "(", subscriptionToCancel.plan.nickname, ")"))), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelContainer, props, /*#__PURE__*/React__default['default'].createElement("div", {
21978
+ }, "(", subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel8 = subscriptionToCancel.plan) === null || _subscriptionToCancel8 === void 0 ? void 0 : _subscriptionToCancel8.nickname, ")"))), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelContainer, props, /*#__PURE__*/React__default['default'].createElement("div", {
21542
21979
  className: "plc-flex plc-flex-col plc-items-center plc-justify-center plc-mt-4"
21543
21980
  }, /*#__PURE__*/React__default['default'].createElement(SvgSubscription, {
21544
21981
  className: "plc-w-32 plc-h-32"
21545
21982
  }), /*#__PURE__*/React__default['default'].createElement("p", {
21546
- className: "plc-mb-3 plc-text-gray-900 plc-text-center plc-whitespace-pre-line"
21547
- }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
21983
+ className: "plc-mb-3 plc-text-gray-900 plc-text-left plc-mr-auto plc-whitespace-pre-line"
21984
+ }, t("messages.subscriptionEnd"), " ", hasPhases ? new Date(Number(`${lastPhase === null || lastPhase === void 0 ? void 0 : lastPhase.end_date}000`)).toLocaleDateString("en-CA", {
21548
21985
  year: "numeric",
21549
21986
  month: "short",
21550
21987
  day: "numeric"
21551
- }), "."), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelNowButton, {
21552
- className: "plc-mb-2",
21553
- subscription: subscriptionToCancel
21554
- }), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelLaterButton, {
21988
+ }) : new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
21989
+ year: "numeric",
21990
+ month: "short",
21991
+ day: "numeric"
21992
+ }), "."), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelOptions, {
21993
+ subscription: subscriptionToCancel,
21994
+ hasPhases: hasPhases
21995
+ }), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default['default'].createElement("div", {
21996
+ className: "plc-space-x-0 plc-space-y-3 md:plc-space-x-3 md:plc-space-y-0 plc-w-full plc-flex plc-flex-col md:plc-flex-row plc-items-center plc-justify-center"
21997
+ }, /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelButton, {
21998
+ className: "plc-w-3/4 md:plc-w-2/5",
21555
21999
  subscription: subscriptionToCancel
21556
- }))));
22000
+ }), /*#__PURE__*/React__default['default'].createElement(Button, {
22001
+ variant: "outline",
22002
+ className: "plc-w-3/4 md:plc-w-2/5",
22003
+ onClick: () => {
22004
+ switchView("dashboard");
22005
+ }
22006
+ }, t("labels.subCancellation.goBack"))))));
21557
22007
  };
21558
22008
 
21559
22009
  const SubscriptionCancelModal = _ref => {
@@ -21693,9 +22143,8 @@ const SubscriptionSuspendDate = props => {
21693
22143
  }, props));
21694
22144
  };
21695
22145
 
21696
- var _window$3, _window$Pelcro$3, _window$Pelcro$uiSett$3;
21697
- const ReactGA$3 = (_window$3 = window) !== null && _window$3 !== void 0 && (_window$Pelcro$3 = _window$3.Pelcro) !== null && _window$Pelcro$3 !== void 0 && (_window$Pelcro$uiSett$3 = _window$Pelcro$3.uiSettings) !== null && _window$Pelcro$uiSett$3 !== void 0 && _window$Pelcro$uiSett$3.enableReactGA4 ? ReactGA4 : ReactGA1;
21698
22146
  const SubscriptionSuspendButton = _ref => {
22147
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
21699
22148
  let {
21700
22149
  subscription,
21701
22150
  onClick,
@@ -21714,6 +22163,7 @@ const SubscriptionSuspendButton = _ref => {
21714
22163
  const {
21715
22164
  t
21716
22165
  } = useTranslation("subscriptionSuspend");
22166
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
21717
22167
  const suspendSubscription = (payload, onSuccess, onFailure) => {
21718
22168
  window.Pelcro.subscription.update({
21719
22169
  auth_token: window.Pelcro.user.read().auth_token,
@@ -21721,15 +22171,21 @@ const SubscriptionSuspendButton = _ref => {
21721
22171
  suspend: 1,
21722
22172
  shipments_suspended_until: suspendDate
21723
22173
  }, (err, res) => {
21724
- var _ReactGA$event;
21725
22174
  if (err) {
21726
22175
  return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
21727
22176
  }
21728
- ReactGA$3 === null || ReactGA$3 === void 0 ? void 0 : (_ReactGA$event = ReactGA$3.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$3, {
21729
- category: "ACTIONS",
21730
- action: "Suspended",
21731
- nonInteraction: true
21732
- });
22177
+ if (enableReactGA4) {
22178
+ ReactGA4.event("Suspended", {
22179
+ nonInteraction: true
22180
+ });
22181
+ } else {
22182
+ var _ReactGA$event;
22183
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
22184
+ category: "ACTIONS",
22185
+ action: "Suspended",
22186
+ nonInteraction: true
22187
+ });
22188
+ }
21733
22189
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
21734
22190
  });
21735
22191
  };
@@ -21739,10 +22195,10 @@ const SubscriptionSuspendButton = _ref => {
21739
22195
  };
21740
22196
  onClick === null || onClick === void 0 ? void 0 : onClick();
21741
22197
 
21742
- //Close the modal
22198
+ // Close the modal
21743
22199
  switchView(null);
21744
22200
 
21745
- //Show confirmation alert after closing the modal
22201
+ // Show confirmation alert after closing the modal
21746
22202
  notify.confirm((onSuccess, onFailure) => {
21747
22203
  suspendSubscription(payload, onSuccess, onFailure);
21748
22204
  }, {
@@ -22473,11 +22929,11 @@ const SubscriptionCreateView = _ref => {
22473
22929
  var _plan$quantity, _plan$quantity2, _plan$quantity3;
22474
22930
  const autoRenewed = plan.auto_renew;
22475
22931
  const {
22476
- interval,
22932
+ interval_translated,
22477
22933
  interval_count
22478
22934
  } = plan;
22479
22935
  const intervalText = t("labels.interval", {
22480
- interval,
22936
+ interval: interval_translated,
22481
22937
  count: interval_count
22482
22938
  });
22483
22939
  const priceFormatted = plan.type === "donation" && (selectedDonationAmount || customDonationAmount) ? getFormattedPriceByLocal(selectedDonationAmount ? selectedDonationAmount * (plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1) : customDonationAmount * (plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity2 = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity2 !== void 0 ? _plan$quantity2 : 1), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage()) : getFormattedPriceByLocal((plan === null || plan === void 0 ? void 0 : plan.amount) * ((_plan$quantity3 = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity3 !== void 0 ? _plan$quantity3 : 1), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
@@ -22503,6 +22959,7 @@ const SubscriptionCreateView = _ref => {
22503
22959
  type: "createPayment",
22504
22960
  showCoupon: true,
22505
22961
  showExternalPaymentMethods: true,
22962
+ showApplePayButton: true,
22506
22963
  onSuccess: onSuccess,
22507
22964
  onFailure: onFailure,
22508
22965
  showSubscriptionButton: showSubscriptionButton
@@ -24473,7 +24930,7 @@ const {
24473
24930
  Provider: Provider$d
24474
24931
  } = store$d;
24475
24932
  const AddressUpdateContainer = _ref => {
24476
- var _props$addressId;
24933
+ var _props$addressId, _window, _window$Pelcro, _window$Pelcro$uiSett;
24477
24934
  let {
24478
24935
  style,
24479
24936
  className = "",
@@ -24487,6 +24944,7 @@ const AddressUpdateContainer = _ref => {
24487
24944
  addressIdToEdit
24488
24945
  } = usePelcro();
24489
24946
  const addressId = (_props$addressId = props === null || props === void 0 ? void 0 : props.addressId) !== null && _props$addressId !== void 0 ? _props$addressId : addressIdToEdit;
24947
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
24490
24948
  const [t] = useTranslation("address");
24491
24949
  React.useEffect(() => {
24492
24950
  const getCountries = () => {
@@ -24577,7 +25035,6 @@ const AddressUpdateContainer = _ref => {
24577
25035
  });
24578
25036
  onFailure(err);
24579
25037
  } else {
24580
- var _ReactGA$event;
24581
25038
  dispatch({
24582
25039
  type: SHOW_ALERT,
24583
25040
  payload: {
@@ -24586,11 +25043,18 @@ const AddressUpdateContainer = _ref => {
24586
25043
  }
24587
25044
  });
24588
25045
  onSuccess(res);
24589
- ReactGA1 === null || ReactGA1 === void 0 ? void 0 : (_ReactGA$event = ReactGA1.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA1, {
24590
- category: "ACTIONS",
24591
- action: "Updated address",
24592
- nonInteraction: true
24593
- });
25046
+ if (enableReactGA4) {
25047
+ ReactGA4.event("Updated address", {
25048
+ nonInteraction: true
25049
+ });
25050
+ } else {
25051
+ var _ReactGA$event;
25052
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
25053
+ category: "ACTIONS",
25054
+ action: "Updated address",
25055
+ nonInteraction: true
25056
+ });
25057
+ }
24594
25058
  }
24595
25059
  });
24596
25060
  };
@@ -25108,23 +25572,31 @@ function PaymentMethodUpdateView(props) {
25108
25572
  type: "updatePaymentSource",
25109
25573
  showCoupon: false,
25110
25574
  showExternalPaymentMethods: false,
25575
+ showApplePayButton: false,
25111
25576
  onDisplay: props.onDisplay,
25112
25577
  onFailure: props.onFailure,
25113
25578
  onSuccess: props.onSuccess
25114
25579
  }));
25115
25580
  }
25116
25581
 
25117
- var _window$2, _window$Pelcro$2, _window$Pelcro$uiSett$2;
25118
- const ReactGA$2 = (_window$2 = window) !== null && _window$2 !== void 0 && (_window$Pelcro$2 = _window$2.Pelcro) !== null && _window$Pelcro$2 !== void 0 && (_window$Pelcro$uiSett$2 = _window$Pelcro$2.uiSettings) !== null && _window$Pelcro$uiSett$2 !== void 0 && _window$Pelcro$uiSett$2.enableReactGA4 ? ReactGA4 : ReactGA1;
25119
25582
  const PaymentMethodUpdateModal = props => {
25583
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
25584
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
25120
25585
  const onSuccess = res => {
25121
- var _props$onSuccess, _ReactGA$event;
25586
+ var _props$onSuccess;
25122
25587
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
25123
- ReactGA$2 === null || ReactGA$2 === void 0 ? void 0 : (_ReactGA$event = ReactGA$2.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$2, {
25124
- category: "ACTIONS",
25125
- action: "Updated payment card",
25126
- nonInteraction: true
25127
- });
25588
+ if (enableReactGA4) {
25589
+ ReactGA4.event("Updated payment card", {
25590
+ nonInteraction: true
25591
+ });
25592
+ } else {
25593
+ var _ReactGA$event;
25594
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
25595
+ category: "ACTIONS",
25596
+ action: "Updated payment card",
25597
+ nonInteraction: true
25598
+ });
25599
+ }
25128
25600
  };
25129
25601
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
25130
25602
  id: "pelcro-payment-method-update-modal",
@@ -26524,6 +26996,7 @@ const OrderCreateView = props => {
26524
26996
  type: "orderCreate",
26525
26997
  showCoupon: true,
26526
26998
  showExternalPaymentMethods: false,
26999
+ showApplePayButton: false,
26527
27000
  showOrderButton: showOrderButton,
26528
27001
  order: order
26529
27002
  }, props))));
@@ -29001,8 +29474,6 @@ const OrderItems = _ref => {
29001
29474
  });
29002
29475
  };
29003
29476
 
29004
- var _window$1, _window$Pelcro$1, _window$Pelcro$uiSett$1;
29005
- const ReactGA$1 = (_window$1 = window) !== null && _window$1 !== void 0 && (_window$Pelcro$1 = _window$1.Pelcro) !== null && _window$Pelcro$1 !== void 0 && (_window$Pelcro$uiSett$1 = _window$Pelcro$1.uiSettings) !== null && _window$Pelcro$uiSett$1 !== void 0 && _window$Pelcro$uiSett$1.enableReactGA4 ? ReactGA4 : ReactGA1;
29006
29477
  const SavedItemsMenu = () => {
29007
29478
  const {
29008
29479
  t
@@ -29051,8 +29522,10 @@ const SavedItems = _ref3 => {
29051
29522
  isAuthenticated
29052
29523
  } = usePelcro();
29053
29524
  const removeItemFromMetadata = (category, title) => {
29525
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
29054
29526
  const user = window.Pelcro.user.read();
29055
29527
  const oldValue = user.metadata[`metadata_saved_${category}`];
29528
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
29056
29529
  const newMetadataValue = oldValue.filter(metadata => !((metadata === null || metadata === void 0 ? void 0 : metadata.title) === title));
29057
29530
  if (isAuthenticated()) {
29058
29531
  setLoading(true);
@@ -29061,17 +29534,24 @@ const SavedItems = _ref3 => {
29061
29534
  value: newMetadataValue,
29062
29535
  auth_token: window.Pelcro.user.read().auth_token
29063
29536
  }, (error, response) => {
29064
- var _response$data, _ReactGA$event;
29537
+ var _response$data;
29065
29538
  setLoading(false);
29066
29539
  if (error) {
29067
29540
  return;
29068
29541
  }
29069
29542
  setItems(response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.metadata);
29070
- ReactGA$1 === null || ReactGA$1 === void 0 ? void 0 : (_ReactGA$event = ReactGA$1.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$1, {
29071
- category: "ACTIONS",
29072
- action: "Unsave/Unfollow",
29073
- label: title
29074
- });
29543
+ if (enableReactGA4) {
29544
+ ReactGA4.event("Unsave/Unfollow", {
29545
+ event_label: title
29546
+ });
29547
+ } else {
29548
+ var _ReactGA$event;
29549
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
29550
+ category: "ACTIONS",
29551
+ action: "Unsave/Unfollow",
29552
+ label: title
29553
+ });
29554
+ }
29075
29555
  });
29076
29556
  }
29077
29557
  };
@@ -30024,8 +30504,6 @@ function getMemberShipStatus(status) {
30024
30504
  };
30025
30505
  }
30026
30506
 
30027
- var _window, _window$Pelcro, _window$Pelcro$uiSett;
30028
- const ReactGA = (_window = window) !== null && _window !== void 0 && (_window$Pelcro = _window.Pelcro) !== null && _window$Pelcro !== void 0 && (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) !== null && _window$Pelcro$uiSett !== void 0 && _window$Pelcro$uiSett.enableReactGA4 ? ReactGA4 : ReactGA1;
30029
30507
  const SUB_MENUS = {
30030
30508
  PROFILE: "profile",
30031
30509
  SUBSCRIPTIONS: "subscriptions",
@@ -30080,21 +30558,27 @@ function DashboardWithHook(props) {
30080
30558
  DashboardWithHook.viewId = "dashboard";
30081
30559
  class Dashboard extends React.Component {
30082
30560
  constructor(props) {
30083
- var _window$Pelcro$user$r, _window$Pelcro$user$r2;
30561
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window, _window$Pelcro, _window$Pelcro$uiSett;
30084
30562
  super(props);
30085
30563
  _defineProperty$3(this, "componentDidMount", () => {
30086
- var _ReactGA$event;
30087
30564
  this.setState({
30088
30565
  isOpen: true
30089
30566
  });
30090
30567
  window.Pelcro.insight.track("Modal Displayed", {
30091
30568
  name: "dashboard"
30092
30569
  });
30093
- ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
30094
- category: "VIEWS",
30095
- action: "Dashboard Modal Viewed",
30096
- nonInteraction: true
30097
- });
30570
+ if (this.enableReactGA4) {
30571
+ ReactGA4.event("Dashboard Modal Viewed", {
30572
+ nonInteraction: true
30573
+ });
30574
+ } else {
30575
+ var _ReactGA$event;
30576
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
30577
+ category: "VIEWS",
30578
+ action: "Dashboard Modal Viewed",
30579
+ nonInteraction: true
30580
+ });
30581
+ }
30098
30582
  const {
30099
30583
  addresses
30100
30584
  } = window.Pelcro.user.read();
@@ -30122,15 +30606,21 @@ class Dashboard extends React.Component {
30122
30606
  auth_token: window.Pelcro.user.read().auth_token,
30123
30607
  subscription_id: subscription_id
30124
30608
  }, (err, res) => {
30125
- var _ReactGA$event2;
30126
30609
  if (err) {
30127
30610
  return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
30128
30611
  }
30129
- ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
30130
- category: "ACTIONS",
30131
- action: "Canceled",
30132
- nonInteraction: true
30133
- });
30612
+ if (this.enableReactGA4) {
30613
+ ReactGA4.event("Canceled", {
30614
+ nonInteraction: true
30615
+ });
30616
+ } else {
30617
+ var _ReactGA$event2;
30618
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event2 = ReactGA.event) === null || _ReactGA$event2 === void 0 ? void 0 : _ReactGA$event2.call(ReactGA, {
30619
+ category: "ACTIONS",
30620
+ action: "Canceled",
30621
+ nonInteraction: true
30622
+ });
30623
+ }
30134
30624
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
30135
30625
  });
30136
30626
  });
@@ -30140,15 +30630,21 @@ class Dashboard extends React.Component {
30140
30630
  subscription_id: subscription_id,
30141
30631
  suspend: 0
30142
30632
  }, (err, res) => {
30143
- var _ReactGA$event3;
30144
30633
  if (err) {
30145
30634
  return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
30146
30635
  }
30147
- ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event3 = ReactGA.event) === null || _ReactGA$event3 === void 0 ? void 0 : _ReactGA$event3.call(ReactGA, {
30148
- category: "ACTIONS",
30149
- action: "UnSuspended",
30150
- nonInteraction: true
30151
- });
30636
+ if (this.enableReactGA4) {
30637
+ ReactGA4.event("UnSuspended", {
30638
+ nonInteraction: true
30639
+ });
30640
+ } else {
30641
+ var _ReactGA$event3;
30642
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event3 = ReactGA.event) === null || _ReactGA$event3 === void 0 ? void 0 : _ReactGA$event3.call(ReactGA, {
30643
+ category: "ACTIONS",
30644
+ action: "UnSuspended",
30645
+ nonInteraction: true
30646
+ });
30647
+ }
30152
30648
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
30153
30649
  });
30154
30650
  });
@@ -30433,6 +30929,7 @@ class Dashboard extends React.Component {
30433
30929
  this.locale = this.props.t;
30434
30930
  this.user = window.Pelcro.user.read();
30435
30931
  this.menuRef = /*#__PURE__*/React__default['default'].createRef();
30932
+ this.enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
30436
30933
  }
30437
30934
  render() {
30438
30935
  var _window$Pelcro$user$r3, _window$Pelcro2, _window$Pelcro2$uiSet, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
@@ -32846,7 +33343,8 @@ const InvoicePaymentView = props => {
32846
33343
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
32847
33344
  type: "invoicePayment",
32848
33345
  showCoupon: false,
32849
- showExternalPaymentMethods: true
33346
+ showExternalPaymentMethods: true,
33347
+ showApplePayButton: true
32850
33348
  }, props))));
32851
33349
  };
32852
33350