@pelcro/react-pelcro-js 3.14.0 → 3.15.1-beta.1

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
@@ -3634,6 +3634,8 @@ var labels$Y = {
3634
3634
  email: "Email",
3635
3635
  firstName: "First name",
3636
3636
  lastName: "Last name",
3637
+ username: "Username",
3638
+ displayname: "Display name",
3637
3639
  phone: "Phone",
3638
3640
  submit: "Submit",
3639
3641
  required: "Required",
@@ -4567,6 +4569,8 @@ var labels$D = {
4567
4569
  email: "Address courriel",
4568
4570
  firstName: "Prénom",
4569
4571
  lastName: "Nom de famille",
4572
+ username: "Nom d'utilisateur",
4573
+ displayname: "Afficher un nom",
4570
4574
  phone: "Numéro de téléphone",
4571
4575
  submit: "Soumettre",
4572
4576
  required: "Champs obligatoires",
@@ -5384,6 +5388,8 @@ var labels$o = {
5384
5388
  email: "이메일",
5385
5389
  firstName: "이름",
5386
5390
  lastName: "성",
5391
+ username: "사용자 이름",
5392
+ displayname: "이름 표시하기",
5387
5393
  phone: "전화번호",
5388
5394
  submit: "제출",
5389
5395
  required: "필수 항목",
@@ -6303,6 +6309,8 @@ var labels$9 = {
6303
6309
  email: "Correo",
6304
6310
  firstName: "Nombre",
6305
6311
  lastName: "Apellido",
6312
+ username: "Nombre de usuario",
6313
+ displayname: "Nombre para mostrar",
6306
6314
  phone: "Teléfono",
6307
6315
  submit: "Enviar",
6308
6316
  required: "Obligatorio",
@@ -8309,7 +8317,7 @@ class PelcroActions {
8309
8317
  return console.error("invalid subscription id");
8310
8318
  }
8311
8319
 
8312
- if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== 'membership') {
8320
+ if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== "membership") {
8313
8321
  return console.error("subscription is not from type membership");
8314
8322
  }
8315
8323
 
@@ -8609,7 +8617,7 @@ const createPelcroHook = store => {
8609
8617
 
8610
8618
  pelcroHook.override = fn => {
8611
8619
  const partialState = fn(store.setState, store.getState);
8612
- usePelcro.setState(partialState);
8620
+ usePelcro$1.setState(partialState);
8613
8621
  };
8614
8622
 
8615
8623
  pelcroHook.getStore = pelcroHook.getState;
@@ -8617,11 +8625,11 @@ const createPelcroHook = store => {
8617
8625
  };
8618
8626
 
8619
8627
  const pelcroStore = createPelcroStore();
8620
- const usePelcro = createPelcroHook(pelcroStore);
8628
+ const usePelcro$1 = createPelcroHook(pelcroStore);
8621
8629
  /* istanbul ignore next */
8622
8630
 
8623
8631
  if (process.env.NODE_ENV === "development") {
8624
- c$1("Pelcro Store", usePelcro);
8632
+ c$1("Pelcro Store", usePelcro$1);
8625
8633
  }
8626
8634
 
8627
8635
  /**
@@ -8826,7 +8834,7 @@ const trackSubscriptionOnGA = () => {
8826
8834
  product,
8827
8835
  plan,
8828
8836
  couponCode
8829
- } = usePelcro.getStore();
8837
+ } = usePelcro$1.getStore();
8830
8838
  /*
8831
8839
  getting the latest subscription id from invoices instead of subscriptions
8832
8840
  to handle gifted subs which are not added to subs list
@@ -9146,7 +9154,7 @@ class SaveToMetadataButtonClass {
9146
9154
  _defineProperty$3(this, "unauthenticated", () => {
9147
9155
  const {
9148
9156
  switchView
9149
- } = usePelcro.getStore();
9157
+ } = usePelcro$1.getStore();
9150
9158
 
9151
9159
  _classPrivateFieldGet(this, _onClick).call(this, () => switchView("login"));
9152
9160
 
@@ -9229,7 +9237,7 @@ class SaveToMetadataButtonClass {
9229
9237
  const user = window.Pelcro.user.read();
9230
9238
  const {
9231
9239
  switchView
9232
- } = usePelcro.getStore();
9240
+ } = usePelcro$1.getStore();
9233
9241
  const {
9234
9242
  key,
9235
9243
  ...buttonMetadata
@@ -10333,7 +10341,7 @@ toast.confirm = (onConfirm, {
10333
10341
  ...options
10334
10342
  });
10335
10343
  setTimeout(() => {
10336
- notify.dismiss(id);
10344
+ notify$1.dismiss(id);
10337
10345
  }, 3000);
10338
10346
  };
10339
10347
 
@@ -10343,12 +10351,12 @@ toast.confirm = (onConfirm, {
10343
10351
  ...options
10344
10352
  });
10345
10353
  setTimeout(() => {
10346
- notify.dismiss(id);
10354
+ notify$1.dismiss(id);
10347
10355
  }, 3000);
10348
10356
  };
10349
10357
  };
10350
10358
 
10351
- const notify = toast;
10359
+ const notify$1 = toast;
10352
10360
 
10353
10361
  const translations = i18next.t("common:buttons", {
10354
10362
  returnObjects: true
@@ -10365,7 +10373,7 @@ const init$1 = () => {
10365
10373
  addToCart,
10366
10374
  purchaseItem,
10367
10375
  setSubscriptionToManageMembers
10368
- } = usePelcro.getStore();
10376
+ } = usePelcro$1.getStore();
10369
10377
  const pelcroDashboardButtonsByClass = document.getElementsByClassName("pelcro-dashboard-button");
10370
10378
 
10371
10379
  if (pelcroDashboardButtonsByClass.length !== 0) {
@@ -10419,7 +10427,7 @@ const init$1 = () => {
10419
10427
  const errorMessage = i18next.t("messages:invalidSubscription", {
10420
10428
  returnObjects: true
10421
10429
  });
10422
- return notify.error(errorMessage);
10430
+ return notify$1.error(errorMessage);
10423
10431
  }
10424
10432
 
10425
10433
  switchView("manage-members");
@@ -10428,7 +10436,7 @@ const init$1 = () => {
10428
10436
  const errorMessage = i18next.t("messages:invalidSubscription", {
10429
10437
  returnObjects: true
10430
10438
  });
10431
- return notify.error(errorMessage);
10439
+ return notify$1.error(errorMessage);
10432
10440
  }
10433
10441
  }
10434
10442
  }
@@ -10598,7 +10606,7 @@ const init$1 = () => {
10598
10606
  const errorMsg = i18next.t("shop:messages.currencyMismatch", {
10599
10607
  currency: userCurrency
10600
10608
  });
10601
- notify.error(errorMsg);
10609
+ notify$1.error(errorMsg);
10602
10610
  }
10603
10611
  });
10604
10612
  }
@@ -10668,7 +10676,7 @@ const init = () => {
10668
10676
  const {
10669
10677
  switchView,
10670
10678
  set
10671
- } = usePelcro.getStore();
10679
+ } = usePelcro$1.getStore();
10672
10680
  const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
10673
10681
 
10674
10682
  if (entitlementsProtectedElements.length === 0) {
@@ -10699,8 +10707,10 @@ const init = () => {
10699
10707
  disableKeyboardInteractions(elemDeepClone);
10700
10708
  elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
10701
10709
  unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
10710
+ unblurElemWhenUserLogsIn(elemDeepClone, entitlements);
10711
+ unblurElemWhenUserLogsOut(elemDeepClone, entitlements);
10702
10712
  const NOTIFICATION_ID = "entitlement";
10703
- notify( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
10713
+ notify$1( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
10704
10714
  i18nKey: "messages:entitlement"
10705
10715
  }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default['default'].createElement(Link, {
10706
10716
  onClick: () => {
@@ -10717,7 +10727,7 @@ const init = () => {
10717
10727
  });
10718
10728
  }
10719
10729
 
10720
- notify.dismiss(NOTIFICATION_ID);
10730
+ notify$1.dismiss(NOTIFICATION_ID);
10721
10731
  switchView("_plan-select-entitlements");
10722
10732
  }
10723
10733
  }, "Subscribe"), "now to get full page access.")), {
@@ -10757,7 +10767,7 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
10757
10767
  document.addEventListener("PelcroSubscriptionCreate", event => {
10758
10768
  const {
10759
10769
  isGift
10760
- } = usePelcro.getStore();
10770
+ } = usePelcro$1.getStore();
10761
10771
  if (isGift) return;
10762
10772
  const latestSub = event.detail.data.subscriptions[event.detail.data.subscriptions.length - 1];
10763
10773
  const shouldUnblurContent = entitlements.some(ent => {
@@ -10772,6 +10782,22 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
10772
10782
  });
10773
10783
  }
10774
10784
 
10785
+ function unblurElemWhenUserLogsIn(elem, entitlements) {
10786
+ document.addEventListener("PelcroUserLoggedIn", () => {
10787
+ if (!shouldBlurContent(entitlements)) {
10788
+ elem.setAttribute("style", "filter:inherit !important; pointer-events:inherit !important; user-select:inherit !important");
10789
+ }
10790
+ });
10791
+ }
10792
+
10793
+ function unblurElemWhenUserLogsOut(elem, entitlements) {
10794
+ document.addEventListener("PelcroUserLogout", () => {
10795
+ if (shouldBlurContent(entitlements)) {
10796
+ elem.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
10797
+ }
10798
+ });
10799
+ }
10800
+
10775
10801
  function shouldBlurContent(entitlements) {
10776
10802
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
10777
10803
  }
@@ -11079,7 +11105,7 @@ const initPaywalls = () => {
11079
11105
 
11080
11106
  const {
11081
11107
  switchView
11082
- } = usePelcro.getStore();
11108
+ } = usePelcro$1.getStore();
11083
11109
 
11084
11110
  if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
11085
11111
  /*
@@ -11101,7 +11127,7 @@ const loadPaymentSDKs = () => {
11101
11127
  // Lazy load stripe's SDK
11102
11128
  const {
11103
11129
  whenUserReady
11104
- } = usePelcro.getStore();
11130
+ } = usePelcro$1.getStore();
11105
11131
  whenUserReady(() => {
11106
11132
  if (!window.Stripe) {
11107
11133
  pure_1(window.Pelcro.environment.stripe);
@@ -11149,7 +11175,7 @@ const loadAuth0SDK = () => {
11149
11175
  const initSecuritySdk = () => {
11150
11176
  const {
11151
11177
  whenSiteReady
11152
- } = usePelcro.getStore();
11178
+ } = usePelcro$1.getStore();
11153
11179
  whenSiteReady(() => {
11154
11180
  var _window$Pelcro$site$r2;
11155
11181
 
@@ -11185,7 +11211,7 @@ const dispatchModalDisplayEvents = modalName => {
11185
11211
  const {
11186
11212
  whenSiteReady,
11187
11213
  whenEcommerceLoaded
11188
- } = usePelcro.getStore();
11214
+ } = usePelcro$1.getStore();
11189
11215
  const renderShopView = shopComponent => {
11190
11216
  whenEcommerceLoaded(() => {
11191
11217
  const shopElement = document.getElementById("pelcro-shop");
@@ -11267,7 +11293,7 @@ const initViewFromURL = () => {
11267
11293
  const {
11268
11294
  switchView,
11269
11295
  whenSiteReady
11270
- } = usePelcro.getStore();
11296
+ } = usePelcro$1.getStore();
11271
11297
 
11272
11298
  if (isValidViewFromURL(view)) {
11273
11299
  whenSiteReady(() => {
@@ -11325,7 +11351,7 @@ const initSubscriptionFromURL = () => {
11325
11351
  switchView,
11326
11352
  whenSiteReady,
11327
11353
  set
11328
- } = usePelcro.getStore();
11354
+ } = usePelcro$1.getStore();
11329
11355
  whenSiteReady(() => {
11330
11356
  var _selectedProduct$plan;
11331
11357
 
@@ -11349,7 +11375,7 @@ const initSubscriptionFromURL = () => {
11349
11375
  isAuthenticated,
11350
11376
  switchToAddressView,
11351
11377
  switchToPaymentView
11352
- } = usePelcro.getStore();
11378
+ } = usePelcro$1.getStore();
11353
11379
 
11354
11380
  if (!isAuthenticated()) {
11355
11381
  return switchView("register");
@@ -11381,7 +11407,7 @@ const initOfflineSubscriptionFromURL = offlinePlanId => {
11381
11407
  switchToPaymentView,
11382
11408
  switchToAddressView,
11383
11409
  set
11384
- } = usePelcro.getStore();
11410
+ } = usePelcro$1.getStore();
11385
11411
  whenSiteReady(() => {
11386
11412
  window.Pelcro.plan.getPlan({
11387
11413
  plan_id: offlinePlanId
@@ -11428,7 +11454,7 @@ const initPurchaseFromUrl = () => {
11428
11454
  const {
11429
11455
  whenEcommerceLoaded,
11430
11456
  purchaseItem
11431
- } = usePelcro.getStore();
11457
+ } = usePelcro$1.getStore();
11432
11458
  whenEcommerceLoaded(() => {
11433
11459
  const skuId = window.Pelcro.helpers.getURLParameter("sku_id");
11434
11460
  purchaseItem(skuId);
@@ -11444,7 +11470,7 @@ const initCartFromUrl = () => {
11444
11470
  whenEcommerceLoaded,
11445
11471
  addToCart,
11446
11472
  switchView
11447
- } = usePelcro.getStore();
11473
+ } = usePelcro$1.getStore();
11448
11474
  whenEcommerceLoaded(() => {
11449
11475
  const skusIdsParam = window.Pelcro.helpers.getURLParameter("sku_id");
11450
11476
  const skusIds = skusIdsParam === null || skusIdsParam === void 0 ? void 0 : skusIdsParam.split(",");
@@ -11465,7 +11491,7 @@ const verifyEmailTokenFromUrl = () => {
11465
11491
 
11466
11492
  const {
11467
11493
  whenSiteReady
11468
- } = usePelcro.getStore();
11494
+ } = usePelcro$1.getStore();
11469
11495
  const translations = i18next.t("verifyEmail:messages", {
11470
11496
  returnObjects: true
11471
11497
  });
@@ -11477,10 +11503,10 @@ const verifyEmailTokenFromUrl = () => {
11477
11503
  token: emailToken
11478
11504
  }, (err, res) => {
11479
11505
  if (err) {
11480
- return notify.error(getErrorMessages(err));
11506
+ return notify$1.error(getErrorMessages(err));
11481
11507
  }
11482
11508
 
11483
- return notify.success(translations.success);
11509
+ return notify$1.success(translations.success);
11484
11510
  });
11485
11511
  }, {
11486
11512
  once: true
@@ -11494,7 +11520,7 @@ const verifyLinkTokenFromUrl = () => {
11494
11520
  whenSiteReady,
11495
11521
  resetView,
11496
11522
  isAuthenticated
11497
- } = usePelcro.getStore();
11523
+ } = usePelcro$1.getStore();
11498
11524
  const translations = i18next.t("verifyLinkToken:messages", {
11499
11525
  returnObjects: true
11500
11526
  });
@@ -11506,7 +11532,7 @@ const verifyLinkTokenFromUrl = () => {
11506
11532
  token: loginToken
11507
11533
  }, (err, res) => {
11508
11534
  if (err) {
11509
- return notify.error(getErrorMessages(err));
11535
+ return notify$1.error(getErrorMessages(err));
11510
11536
  }
11511
11537
 
11512
11538
  const {
@@ -11516,11 +11542,11 @@ const verifyLinkTokenFromUrl = () => {
11516
11542
  auth_token
11517
11543
  }, (err, res) => {
11518
11544
  if (err) {
11519
- return notify.error(getErrorMessages(err));
11545
+ return notify$1.error(getErrorMessages(err));
11520
11546
  }
11521
11547
 
11522
11548
  resetView();
11523
- return notify.success(translations.success);
11549
+ return notify$1.success(translations.success);
11524
11550
  });
11525
11551
  });
11526
11552
  }, {
@@ -11533,12 +11559,12 @@ const showPasswordlessRequestFromUrl = () => {
11533
11559
 
11534
11560
  const {
11535
11561
  isAuthenticated
11536
- } = usePelcro.getStore();
11562
+ } = usePelcro$1.getStore();
11537
11563
  const passwordlessEnabled = (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.passwordless_enabled;
11538
11564
  if (!passwordlessEnabled || isAuthenticated()) return;
11539
11565
  const {
11540
11566
  switchView
11541
- } = usePelcro.getStore();
11567
+ } = usePelcro$1.getStore();
11542
11568
  return switchView("passwordless-request");
11543
11569
  };
11544
11570
 
@@ -11549,7 +11575,7 @@ const showInvoiceDetailsFromUrl = () => {
11549
11575
  whenUserReady,
11550
11576
  whenSiteReady,
11551
11577
  switchView
11552
- } = usePelcro.getStore();
11578
+ } = usePelcro$1.getStore();
11553
11579
  whenSiteReady(() => {
11554
11580
  if (!isAuthenticated()) {
11555
11581
  return switchView("login");
@@ -11563,18 +11589,18 @@ const showInvoiceDetailsFromUrl = () => {
11563
11589
  const errorMessage = i18next.t("messages:invalidInvoice", {
11564
11590
  returnObjects: true
11565
11591
  });
11566
- return notify.error(errorMessage);
11592
+ return notify$1.error(errorMessage);
11567
11593
  }
11568
11594
 
11569
11595
  const {
11570
11596
  invoice
11571
- } = usePelcro.getStore();
11597
+ } = usePelcro$1.getStore();
11572
11598
 
11573
11599
  if (invoice.total === 0) {
11574
11600
  const errorMessage = i18next.t("messages:zeroTotalInvoice", {
11575
11601
  returnObjects: true
11576
11602
  });
11577
- return notify.error(errorMessage);
11603
+ return notify$1.error(errorMessage);
11578
11604
  }
11579
11605
 
11580
11606
  return switchView("invoice-details");
@@ -11589,7 +11615,7 @@ const showSubscriptionManageMembersFromUrl = () => {
11589
11615
  whenUserReady,
11590
11616
  whenSiteReady,
11591
11617
  switchView
11592
- } = usePelcro.getStore();
11618
+ } = usePelcro$1.getStore();
11593
11619
  whenSiteReady(() => {
11594
11620
  if (!isAuthenticated()) {
11595
11621
  return switchView("login");
@@ -11603,7 +11629,7 @@ const showSubscriptionManageMembersFromUrl = () => {
11603
11629
  const errorMessage = i18next.t("messages:invalidSubscription", {
11604
11630
  returnObjects: true
11605
11631
  });
11606
- return notify.error(errorMessage);
11632
+ return notify$1.error(errorMessage);
11607
11633
  }
11608
11634
 
11609
11635
  return switchView("manage-members");
@@ -11629,7 +11655,7 @@ const PelcroModalController = ({
11629
11655
  view,
11630
11656
  isAuthenticated,
11631
11657
  whenSiteReady
11632
- } = usePelcro();
11658
+ } = usePelcro$1();
11633
11659
  React__default['default'].useEffect(() => {
11634
11660
  init$1();
11635
11661
  renderShopView(React__default['default'].Children.map(children, child => child).find(({
@@ -13390,7 +13416,7 @@ function Modal({
13390
13416
  }) {
13391
13417
  var _window$Pelcro, _window$Pelcro$site$r;
13392
13418
 
13393
- const resetView = usePelcro(state => state.resetView);
13419
+ const resetView = usePelcro$1(state => state.resetView);
13394
13420
  React.useEffect(() => {
13395
13421
  onDisplay === null || onDisplay === void 0 ? void 0 : onDisplay();
13396
13422
  dispatchModalDisplayEvents(id);
@@ -13463,8 +13489,11 @@ function LoginModal({
13463
13489
  const {
13464
13490
  switchView,
13465
13491
  resetView,
13466
- invoice
13467
- } = usePelcro();
13492
+ product,
13493
+ order,
13494
+ switchToAddressView,
13495
+ switchToPaymentView
13496
+ } = usePelcro$1();
13468
13497
 
13469
13498
  const onSuccess = res => {
13470
13499
  var _props$onSuccess;
@@ -13475,10 +13504,23 @@ function LoginModal({
13475
13504
  initPaywalls();
13476
13505
  }
13477
13506
 
13507
+ if (product) {
13508
+ if (product.address_required) {
13509
+ return switchToAddressView();
13510
+ } else {
13511
+ return switchToPaymentView();
13512
+ }
13513
+ }
13514
+
13515
+ if (order) {
13516
+ return switchToAddressView();
13517
+ }
13518
+
13478
13519
  resetView();
13479
13520
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13521
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13480
13522
 
13481
- if (viewFromURL === "invoice-details") {
13523
+ if (viewsURLs.includes(viewFromURL)) {
13482
13524
  initViewFromURL();
13483
13525
  }
13484
13526
  };
@@ -13801,7 +13843,7 @@ function RegisterView(props) {
13801
13843
  } = useTranslation("register");
13802
13844
  const {
13803
13845
  product
13804
- } = usePelcro();
13846
+ } = usePelcro$1();
13805
13847
  const title = (_product$paywall$regi = product === null || product === void 0 ? void 0 : (_product$paywall = product.paywall) === null || _product$paywall === void 0 ? void 0 : _product$paywall.register_title) !== null && _product$paywall$regi !== void 0 ? _product$paywall$regi : t("title");
13806
13848
  const subtitle = (_product$paywall$regi2 = product === null || product === void 0 ? void 0 : (_product$paywall2 = product.paywall) === null || _product$paywall2 === void 0 ? void 0 : _product$paywall2.register_subtitle) !== null && _product$paywall$regi2 !== void 0 ? _product$paywall$regi2 : t("subtitle");
13807
13849
  const socialLoginEnabled = ((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id) || ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.google_app_id) || ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.auth0_client_id);
@@ -14032,7 +14074,7 @@ function RegisterModal(props) {
14032
14074
  order,
14033
14075
  giftCode,
14034
14076
  isGift
14035
- } = usePelcro();
14077
+ } = usePelcro$1();
14036
14078
 
14037
14079
  const onSuccess = res => {
14038
14080
  var _props$onSuccess;
@@ -14062,7 +14104,7 @@ function RegisterModal(props) {
14062
14104
 
14063
14105
 
14064
14106
  if (giftCode) {
14065
- return switchToAddressView();
14107
+ return switchView("gift-redeem"); // return switchToAddressView();
14066
14108
  } // Check if the subscription is meant as a gift (if so, gather recipients info)
14067
14109
 
14068
14110
 
@@ -14154,7 +14196,7 @@ function SelectModalWithHook(props) {
14154
14196
  resetView,
14155
14197
  view,
14156
14198
  set
14157
- } = usePelcro();
14199
+ } = usePelcro$1();
14158
14200
  const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
14159
14201
  const entitlements = entitlementsProtectedElements.length > 0 ? getEntitlementsFromElem(entitlementsProtectedElements[0]) : null;
14160
14202
  return /*#__PURE__*/React__default['default'].createElement(SelectModalWithTrans, {
@@ -14426,7 +14468,7 @@ class SelectModal extends React.Component {
14426
14468
  const {
14427
14469
  switchToAddressView,
14428
14470
  switchToPaymentView
14429
- } = usePelcro.getStore();
14471
+ } = usePelcro$1.getStore();
14430
14472
 
14431
14473
  if (!isAuthenticated) {
14432
14474
  return setView("register");
@@ -16629,16 +16671,16 @@ const PaymentMethodContainerWithoutStripe = ({
16629
16671
  const {
16630
16672
  t
16631
16673
  } = useTranslation("payment");
16632
- const pelcroStore = usePelcro();
16674
+ const pelcroStore = usePelcro$1();
16633
16675
  const {
16634
16676
  set,
16635
16677
  order,
16636
16678
  selectedPaymentMethodId,
16637
16679
  couponCode
16638
- } = usePelcro();
16680
+ } = usePelcro$1();
16639
16681
  const {
16640
16682
  whenUserReady
16641
- } = usePelcro.getStore();
16683
+ } = usePelcro$1.getStore();
16642
16684
  const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
16643
16685
  const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
16644
16686
  const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
@@ -18102,11 +18144,11 @@ const PaymentMethodContainerWithoutStripe = ({
18102
18144
 
18103
18145
  if (show) {
18104
18146
  injectCardAuthenticationIframe(source);
18105
- cardAuthContainer.classList.remove("plc-hidden");
18106
- cardAuthContainer.classList.add("plc-flex");
18147
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.remove("plc-hidden");
18148
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.add("plc-flex");
18107
18149
  } else {
18108
- cardAuthContainer.classList.add("plc-hidden");
18109
- cardAuthContainer.classList.remove("plc-flex");
18150
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.add("plc-hidden");
18151
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.remove("plc-flex");
18110
18152
  }
18111
18153
  };
18112
18154
 
@@ -18114,11 +18156,11 @@ const PaymentMethodContainerWithoutStripe = ({
18114
18156
  const cardAuthContainer = document.querySelector(".card-authentication-success-container");
18115
18157
 
18116
18158
  if (show) {
18117
- cardAuthContainer.classList.remove("plc-hidden");
18118
- cardAuthContainer.classList.add("plc-flex");
18159
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.remove("plc-hidden");
18160
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.add("plc-flex");
18119
18161
  } else {
18120
- cardAuthContainer.classList.add("plc-hidden");
18121
- cardAuthContainer.classList.remove("plc-flex");
18162
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.add("plc-hidden");
18163
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.classList.remove("plc-flex");
18122
18164
  }
18123
18165
  };
18124
18166
 
@@ -18129,7 +18171,7 @@ const PaymentMethodContainerWithoutStripe = ({
18129
18171
  const iframe = document.createElement("iframe");
18130
18172
  iframe.src = source !== null && source !== void 0 && (_source$redirect = source.redirect) !== null && _source$redirect !== void 0 && _source$redirect.url ? source.redirect.url : source.threeDSecure_url;
18131
18173
  iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; z-index: 10;";
18132
- cardAuthContainer.appendChild(iframe);
18174
+ cardAuthContainer === null || cardAuthContainer === void 0 ? void 0 : cardAuthContainer.appendChild(iframe);
18133
18175
  };
18134
18176
 
18135
18177
  const [state, dispatch] = useReducerWithSideEffects((state, action) => {
@@ -18318,7 +18360,7 @@ const PaymentMethodContainer = props => {
18318
18360
  const [isStripeLoaded, setIsStripeLoaded] = React.useState(Boolean(window.Stripe));
18319
18361
  const {
18320
18362
  whenUserReady
18321
- } = usePelcro.getStore();
18363
+ } = usePelcro$1.getStore();
18322
18364
  React.useEffect(() => {
18323
18365
  whenUserReady(() => {
18324
18366
  if (!window.Stripe) {
@@ -18419,7 +18461,7 @@ const PelcroPaymentRequestButton = props => {
18419
18461
  const CheckoutForm = () => {
18420
18462
  const {
18421
18463
  selectedPaymentMethodId
18422
- } = usePelcro();
18464
+ } = usePelcro$1();
18423
18465
  const cardProcessor = getSiteCardProcessor();
18424
18466
 
18425
18467
  if (selectedPaymentMethodId) {
@@ -18474,7 +18516,7 @@ const DiscountedPrice = props => {
18474
18516
  const {
18475
18517
  order,
18476
18518
  plan
18477
- } = usePelcro();
18519
+ } = usePelcro$1();
18478
18520
  const isTaxInclusive = (_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$r.tax_inclusive;
18479
18521
  const ecommOrderCurrency = (_order$currency = order === null || order === void 0 ? void 0 : order.currency) !== null && _order$currency !== void 0 ? _order$currency : order === null || order === void 0 ? void 0 : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
18480
18522
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
@@ -18510,7 +18552,7 @@ const SubmitPaymentMethod = ({
18510
18552
 
18511
18553
  const {
18512
18554
  plan
18513
- } = usePelcro();
18555
+ } = usePelcro$1();
18514
18556
  const {
18515
18557
  t
18516
18558
  } = useTranslation("checkoutForm");
@@ -18942,7 +18984,7 @@ const PaypalSubscribeButton = props => {
18942
18984
  plan,
18943
18985
  invoice,
18944
18986
  selectedAddressId
18945
- } = usePelcro();
18987
+ } = usePelcro$1();
18946
18988
  React.useEffect(() => {
18947
18989
  var _ref, _ref2, _state$updatedPrice, _props$plan, _props$selectedAddres;
18948
18990
 
@@ -19084,7 +19126,7 @@ const SelectedPaymentMethod = () => {
19084
19126
  const {
19085
19127
  switchView,
19086
19128
  selectedPaymentMethodId
19087
- } = usePelcro();
19129
+ } = usePelcro$1();
19088
19130
  const paymentMethod = (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : (_window$Pelcro$user$r2 = _window$Pelcro$user$r.sources) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : (_window$Pelcro$user$r3 = _window$Pelcro$user$r2.find) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.call(_window$Pelcro$user$r2, source => {
19089
19131
  return source.id == selectedPaymentMethodId;
19090
19132
  });
@@ -19125,7 +19167,7 @@ const TaxAmount = () => {
19125
19167
  } = React.useContext(store$k);
19126
19168
  const {
19127
19169
  plan
19128
- } = usePelcro();
19170
+ } = usePelcro$1();
19129
19171
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
19130
19172
  const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
19131
19173
  const isTaxInclusive = (_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$r.tax_inclusive;
@@ -19271,7 +19313,7 @@ const SubscriptionRenewView = ({
19271
19313
  const {
19272
19314
  product,
19273
19315
  plan
19274
- } = usePelcro();
19316
+ } = usePelcro$1();
19275
19317
  const skipPayment = (_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.skipPaymentForFreePlans;
19276
19318
  const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
19277
19319
 
@@ -19326,7 +19368,7 @@ function SubscriptionRenewModal({
19326
19368
  }) {
19327
19369
  const {
19328
19370
  switchView
19329
- } = usePelcro();
19371
+ } = usePelcro$1();
19330
19372
 
19331
19373
  const onSuccess = res => {
19332
19374
  var _otherProps$onSuccess, _ReactGA$event;
@@ -19531,7 +19573,7 @@ const SubscriptionCancelNowButton = ({
19531
19573
  }) => {
19532
19574
  const {
19533
19575
  switchView
19534
- } = usePelcro();
19576
+ } = usePelcro$1();
19535
19577
  const {
19536
19578
  state: {
19537
19579
  cancelationReason
@@ -19578,7 +19620,7 @@ const SubscriptionCancelNowButton = ({
19578
19620
 
19579
19621
  switchView(null); //Show confirmation alert after closing the modal
19580
19622
 
19581
- notify.confirm((onSuccess, onFailure) => {
19623
+ notify$1.confirm((onSuccess, onFailure) => {
19582
19624
  cancelSubscription(payload, onSuccess, onFailure);
19583
19625
  }, {
19584
19626
  confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
@@ -19603,7 +19645,7 @@ const SubscriptionCancelLaterButton = ({
19603
19645
  }) => {
19604
19646
  const {
19605
19647
  switchView
19606
- } = usePelcro();
19648
+ } = usePelcro$1();
19607
19649
  const {
19608
19650
  state: {
19609
19651
  cancelationReason
@@ -19650,7 +19692,7 @@ const SubscriptionCancelLaterButton = ({
19650
19692
 
19651
19693
  switchView(null); //Show confirmation alert after closing the modal
19652
19694
 
19653
- notify.confirm((onSuccess, onFailure) => {
19695
+ notify$1.confirm((onSuccess, onFailure) => {
19654
19696
  cancelSubscription(payload, onSuccess, onFailure);
19655
19697
  }, {
19656
19698
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -19671,7 +19713,7 @@ const SubscriptionCancelLaterButton = ({
19671
19713
  const SubscriptionCancelView = props => {
19672
19714
  const {
19673
19715
  subscriptionToCancel
19674
- } = usePelcro();
19716
+ } = usePelcro$1();
19675
19717
  const {
19676
19718
  t
19677
19719
  } = useTranslation("subscriptionCancel");
@@ -19845,7 +19887,7 @@ const SubscriptionSuspendButton = ({
19845
19887
  }) => {
19846
19888
  const {
19847
19889
  switchView
19848
- } = usePelcro();
19890
+ } = usePelcro$1();
19849
19891
  const {
19850
19892
  state: {
19851
19893
  suspendDate,
@@ -19887,7 +19929,7 @@ const SubscriptionSuspendButton = ({
19887
19929
 
19888
19930
  switchView(null); //Show confirmation alert after closing the modal
19889
19931
 
19890
- notify.confirm((onSuccess, onFailure) => {
19932
+ notify$1.confirm((onSuccess, onFailure) => {
19891
19933
  suspendSubscription(payload, onSuccess, onFailure);
19892
19934
  }, {
19893
19935
  confirmMessage: t("messages.subCancellation.isSureToSuspendNow"),
@@ -19909,7 +19951,7 @@ const SubscriptionSuspendButton = ({
19909
19951
  const SubscriptionSuspendView = props => {
19910
19952
  const {
19911
19953
  subscriptionToSuspend
19912
- } = usePelcro();
19954
+ } = usePelcro$1();
19913
19955
  const {
19914
19956
  t
19915
19957
  } = useTranslation("subscriptionSuspend");
@@ -20002,7 +20044,7 @@ const getCurrentFlow = () => {
20002
20044
  giftRecipient,
20003
20045
  giftCode,
20004
20046
  invoice
20005
- } = usePelcro.getStore();
20047
+ } = usePelcro$1.getStore();
20006
20048
 
20007
20049
  if (invoice) {
20008
20050
  return "invoicePayment";
@@ -20021,7 +20063,7 @@ const getSuccessContent = i18n => {
20021
20063
  const flow = getCurrentFlow();
20022
20064
  const {
20023
20065
  product
20024
- } = usePelcro.getStore();
20066
+ } = usePelcro$1.getStore();
20025
20067
  const wordingDictionary = {
20026
20068
  subscriptionSuccess: {
20027
20069
  successIcon: /*#__PURE__*/React__default['default'].createElement(SvgCheckSolid, {
@@ -20065,7 +20107,7 @@ function PaymentSuccessModal({
20065
20107
  }) {
20066
20108
  const {
20067
20109
  resetView
20068
- } = usePelcro();
20110
+ } = usePelcro$1();
20069
20111
 
20070
20112
  const onClose = () => {
20071
20113
  var _props$onClose;
@@ -20098,7 +20140,7 @@ function NewsletterWithHook(props) {
20098
20140
  switchView,
20099
20141
  resetView,
20100
20142
  product
20101
- } = usePelcro();
20143
+ } = usePelcro$1();
20102
20144
  return /*#__PURE__*/React__default['default'].createElement(NewsLetter, {
20103
20145
  onClose: () => {
20104
20146
  var _props$onClose;
@@ -20597,7 +20639,7 @@ const MeterView = () => {
20597
20639
  switchView,
20598
20640
  product,
20599
20641
  isAuthenticated
20600
- } = usePelcro();
20642
+ } = usePelcro$1();
20601
20643
  const paywallProduct = product !== null && product !== void 0 ? product : window.Pelcro.paywall.getProduct();
20602
20644
  const visitsLeft = window.Pelcro.paywall.freeVisitsLeft();
20603
20645
  const title = `${paywallProduct === null || paywallProduct === void 0 ? void 0 : (_paywallProduct$paywa = paywallProduct.paywall) === null || _paywallProduct$paywa === void 0 ? void 0 : _paywallProduct$paywa.meter_title}: ${visitsLeft}`;
@@ -20619,7 +20661,7 @@ const MeterView = () => {
20619
20661
  const MeterModal = props => {
20620
20662
  const {
20621
20663
  resetView
20622
- } = usePelcro();
20664
+ } = usePelcro$1();
20623
20665
  React.useEffect(() => {
20624
20666
  var _props$onDisplay;
20625
20667
 
@@ -20657,7 +20699,7 @@ const SubscriptionCreateView = ({
20657
20699
  const {
20658
20700
  product,
20659
20701
  plan
20660
- } = usePelcro();
20702
+ } = usePelcro$1();
20661
20703
  const skipPayment = (_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.skipPaymentForFreePlans;
20662
20704
  const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
20663
20705
 
@@ -20715,7 +20757,7 @@ function SubscriptionCreateModal({
20715
20757
  useTranslation("common");
20716
20758
  const {
20717
20759
  switchView
20718
- } = usePelcro();
20760
+ } = usePelcro$1();
20719
20761
 
20720
20762
  const onSuccess = res => {
20721
20763
  var _otherProps$onSuccess;
@@ -20761,7 +20803,7 @@ const SubscriptionManageMembersContainer = ({
20761
20803
  }) => {
20762
20804
  const {
20763
20805
  subscriptionToManageMembers
20764
- } = usePelcro();
20806
+ } = usePelcro$1();
20765
20807
  const subscription_id = subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : subscriptionToManageMembers.id;
20766
20808
 
20767
20809
  const handleListMembers = ({}, dispatch) => {
@@ -21056,8 +21098,8 @@ function SubscriptionManageMembersList(props) {
21056
21098
  return {
21057
21099
  title: sub.status,
21058
21100
  content: sub.status,
21059
- textColor: "plc-text-orange-700",
21060
- bgColor: "plc-bg-orange-100",
21101
+ textColor: "plc-text-yellow-500",
21102
+ bgColor: "plc-bg-yellow-100",
21061
21103
  icon: /*#__PURE__*/React__default['default'].createElement(SvgExclamation, null)
21062
21104
  };
21063
21105
  }
@@ -21113,7 +21155,8 @@ function SubscriptionManageMembersList(props) {
21113
21155
  key: member.id,
21114
21156
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
21115
21157
  }, /*#__PURE__*/React__default['default'].createElement("td", {
21116
- className: "plc-truncate"
21158
+ className: "plc-truncate plc-text-left",
21159
+ title: member === null || member === void 0 ? void 0 : member.invitation_email
21117
21160
  }, /*#__PURE__*/React__default['default'].createElement("span", {
21118
21161
  className: "plc-font-semibold plc-text-gray-500"
21119
21162
  }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default['default'].createElement("td", {
@@ -21167,8 +21210,10 @@ function SubscriptionManageMembersView(props) {
21167
21210
  className: "plc-flex-shrink-0 plc-p-2 plc-text-xs plc-text-gray-400 plc-uppercase"
21168
21211
  }, t("labels.listOfMembers")), /*#__PURE__*/React__default['default'].createElement("hr", {
21169
21212
  className: "plc-w-full plc-border-gray-300"
21170
- })), /*#__PURE__*/React__default['default'].createElement("table", {
21171
- className: "plc-w-full plc-table-fixed"
21213
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
21214
+ className: "plc-max-h-48 plc-overflow-x-hidden plc-overflow-y-auto"
21215
+ }, /*#__PURE__*/React__default['default'].createElement("table", {
21216
+ className: "plc-w-full plc-table-fixed plc-text-center plc-p-2 plc-m-1"
21172
21217
  }, /*#__PURE__*/React__default['default'].createElement("thead", {
21173
21218
  className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
21174
21219
  }, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("th", {
@@ -21177,7 +21222,7 @@ function SubscriptionManageMembersView(props) {
21177
21222
  className: "plc-w-3/12 "
21178
21223
  }, t("labels.status")), /*#__PURE__*/React__default['default'].createElement("th", {
21179
21224
  className: "plc-w-3/12 "
21180
- }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement(SubscriptionManageMembersList, null)))))));
21225
+ }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement(SubscriptionManageMembersList, null))))))));
21181
21226
  }
21182
21227
 
21183
21228
  /**
@@ -21206,7 +21251,7 @@ function SubscriptionManageMembersModal({
21206
21251
  }
21207
21252
  SubscriptionManageMembersModal.viewId = "manage-members";
21208
21253
 
21209
- var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _window$Pelcro$user$r6;
21254
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _window$Pelcro$user$r6, _window$Pelcro$user$r7;
21210
21255
  const initialState$f = {
21211
21256
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
21212
21257
  emailError: null,
@@ -21214,10 +21259,12 @@ const initialState$f = {
21214
21259
  firstNameError: null,
21215
21260
  lastName: (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.last_name,
21216
21261
  lastNameError: null,
21217
- displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
21218
- phone: (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.phone,
21262
+ username: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.username,
21263
+ usernameError: null,
21264
+ displayName: (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.display_name,
21265
+ phone: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.phone,
21219
21266
  phoneError: null,
21220
- tin: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.tin,
21267
+ tin: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.tin,
21221
21268
  buttonDisabled: false,
21222
21269
  textFields: {},
21223
21270
  alert: {
@@ -21248,26 +21295,29 @@ const UserUpdateContainer = ({
21248
21295
  }, []);
21249
21296
 
21250
21297
  const loadUserDataIntoFields = () => {
21251
- var _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10, _window$Pelcro$user$r11, _window$Pelcro$user$r12;
21298
+ var _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10, _window$Pelcro$user$r11, _window$Pelcro$user$r12, _window$Pelcro$user$r13, _window$Pelcro$user$r14;
21252
21299
 
21253
21300
  const fields = [{
21254
21301
  type: SET_EMAIL,
21255
- payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.email
21302
+ payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.email
21256
21303
  }, {
21257
21304
  type: SET_FIRST_NAME,
21258
- payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.first_name
21305
+ payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.first_name
21259
21306
  }, {
21260
21307
  type: SET_LAST_NAME,
21261
- payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.last_name
21308
+ payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.last_name
21309
+ }, {
21310
+ type: SET_USERNAME,
21311
+ payload: (_window$Pelcro$user$r11 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r11 === void 0 ? void 0 : _window$Pelcro$user$r11.username
21262
21312
  }, {
21263
21313
  type: SET_DISPLAY_NAME,
21264
- payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.display_name
21314
+ payload: (_window$Pelcro$user$r12 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r12 === void 0 ? void 0 : _window$Pelcro$user$r12.display_name
21265
21315
  }, {
21266
21316
  type: SET_PHONE,
21267
- payload: (_window$Pelcro$user$r11 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r11 === void 0 ? void 0 : _window$Pelcro$user$r11.phone
21317
+ payload: (_window$Pelcro$user$r13 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r13 === void 0 ? void 0 : _window$Pelcro$user$r13.phone
21268
21318
  }, {
21269
21319
  type: SET_TIN,
21270
- payload: (_window$Pelcro$user$r12 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r12 === void 0 ? void 0 : _window$Pelcro$user$r12.tin
21320
+ payload: (_window$Pelcro$user$r14 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r14 === void 0 ? void 0 : _window$Pelcro$user$r14.tin
21271
21321
  }];
21272
21322
  fields.filter(field => Boolean(field.payload)).forEach(field => {
21273
21323
  dispatch(field);
@@ -21278,6 +21328,7 @@ const UserUpdateContainer = ({
21278
21328
  email,
21279
21329
  firstName,
21280
21330
  lastName,
21331
+ username,
21281
21332
  phone,
21282
21333
  tin,
21283
21334
  textFields,
@@ -21288,6 +21339,9 @@ const UserUpdateContainer = ({
21288
21339
  email: email,
21289
21340
  first_name: firstName,
21290
21341
  last_name: lastName,
21342
+ ...(username && {
21343
+ username
21344
+ }),
21291
21345
  display_name: displayName,
21292
21346
  phone: phone,
21293
21347
  tin: tin,
@@ -21373,6 +21427,18 @@ const UserUpdateContainer = ({
21373
21427
  lastName: ""
21374
21428
  });
21375
21429
 
21430
+ case SET_USERNAME:
21431
+ return lib_7({ ...state,
21432
+ username: action.payload,
21433
+ usernameError: null
21434
+ });
21435
+
21436
+ case SET_USERNAME_ERROR:
21437
+ return lib_7({ ...state,
21438
+ usernameError: action.payload,
21439
+ username: ""
21440
+ });
21441
+
21376
21442
  case SET_PHONE:
21377
21443
  return lib_7({ ...state,
21378
21444
  phone: action.payload,
@@ -21418,10 +21484,14 @@ const UserUpdateContainer = ({
21418
21484
  state,
21419
21485
  dispatch
21420
21486
  }
21421
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
21422
- store: store$f,
21423
- key: i
21424
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
21487
+ }, children.length ? children.map((child, i) => {
21488
+ if (child) {
21489
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
21490
+ store: store$f,
21491
+ key: i
21492
+ });
21493
+ }
21494
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
21425
21495
  store: store$f
21426
21496
  })));
21427
21497
  };
@@ -21529,6 +21599,84 @@ const UserUpdateButton = ({
21529
21599
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
21530
21600
  };
21531
21601
 
21602
+ function UpdateUserNameInput({
21603
+ initWithUserName = true,
21604
+ store,
21605
+ ...otherProps
21606
+ }) {
21607
+ const {
21608
+ t
21609
+ } = useTranslation("common");
21610
+ const {
21611
+ dispatch,
21612
+ state: {
21613
+ username: stateUsername,
21614
+ usernameError
21615
+ }
21616
+ } = React.useContext(store);
21617
+ const [username, setUsername] = React.useState(stateUsername);
21618
+ const [finishedTyping, setFinishedTyping] = React.useState(false);
21619
+ const handleInputChange = React.useCallback(value => {
21620
+ setUsername(value);
21621
+
21622
+ if (finishedTyping) {
21623
+ if (username !== null && username !== void 0 && username.length) {
21624
+ dispatch({
21625
+ type: SET_USERNAME,
21626
+ payload: username
21627
+ });
21628
+ } else {
21629
+ if (otherProps.required) {
21630
+ dispatch({
21631
+ type: SET_USERNAME_ERROR,
21632
+ payload: t("validation.enterUsername")
21633
+ });
21634
+ } else {
21635
+ dispatch({
21636
+ type: SET_USERNAME,
21637
+ payload: username
21638
+ });
21639
+ }
21640
+ }
21641
+ }
21642
+ }, [dispatch, username, finishedTyping]);
21643
+ React.useEffect(() => {
21644
+ handleInputChange(username);
21645
+ }, [finishedTyping, username, handleInputChange]); // Initialize username field with user's username
21646
+
21647
+ const loadFirstNameIntoField = () => {
21648
+ handleInputChange(window.Pelcro.user.read().username);
21649
+ dispatch({
21650
+ type: SET_USERNAME,
21651
+ payload: window.Pelcro.user.read().username
21652
+ });
21653
+ };
21654
+
21655
+ React.useEffect(() => {
21656
+ if (initWithUserName) {
21657
+ document.addEventListener("PelcroUserLoaded", () => {
21658
+ loadFirstNameIntoField();
21659
+ });
21660
+ loadFirstNameIntoField();
21661
+ return () => {
21662
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
21663
+ };
21664
+ }
21665
+ }, []);
21666
+ return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
21667
+ type: "text",
21668
+ error: usernameError,
21669
+ value: username,
21670
+ onChange: e => handleInputChange(e.target.value),
21671
+ onBlur: () => setFinishedTyping(true),
21672
+ onFocus: () => setFinishedTyping(false)
21673
+ }, otherProps));
21674
+ }
21675
+
21676
+ const UserUpdateUsername = props => /*#__PURE__*/React__default['default'].createElement(UpdateUserNameInput, Object.assign({
21677
+ store: store$f
21678
+ }, props));
21679
+
21532
21680
  const UserUpdateFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
21533
21681
  store: store$f
21534
21682
  }, props));
@@ -21628,13 +21776,45 @@ const UserUpdateTin = props => /*#__PURE__*/React__default['default'].createElem
21628
21776
  store: store$f
21629
21777
  }, props));
21630
21778
 
21779
+ function DisplayName({
21780
+ store,
21781
+ ...otherProps
21782
+ }) {
21783
+ const {
21784
+ dispatch,
21785
+ state
21786
+ } = React.useContext(store);
21787
+
21788
+ const handleInputChange = value => {
21789
+ dispatch({
21790
+ type: SET_DISPLAY_NAME,
21791
+ payload: value
21792
+ });
21793
+ };
21794
+
21795
+ if (state.loading) {
21796
+ return /*#__PURE__*/React__default['default'].createElement(Loader, null);
21797
+ }
21798
+
21799
+ return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
21800
+ type: "text",
21801
+ value: state.displayName || null,
21802
+ onChange: e => handleInputChange(e.target.value)
21803
+ }, otherProps));
21804
+ }
21805
+
21806
+ const UserUpdateDisplayName = props => /*#__PURE__*/React__default['default'].createElement(DisplayName, Object.assign({
21807
+ store: store$f
21808
+ }, props));
21809
+
21631
21810
  const UserUpdateView = props => {
21632
- var _window$Pelcro$site$r;
21811
+ var _window$Pelcro$site$r, _window$Pelcro, _window$Pelcro$uiSett;
21633
21812
 
21634
21813
  const {
21635
21814
  t
21636
21815
  } = useTranslation("userEdit");
21637
21816
  const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
21817
+ const showUsernameInput = (_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.enableLoginWithUsername;
21638
21818
  return /*#__PURE__*/React__default['default'].createElement("div", {
21639
21819
  id: "pelcro-user-update-view"
21640
21820
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -21662,7 +21842,17 @@ const UserUpdateView = props => {
21662
21842
  errorId: "pelcro-input-last-name-error",
21663
21843
  label: t("labels.lastName"),
21664
21844
  required: supportsTap ? true : false
21665
- })), /*#__PURE__*/React__default['default'].createElement("div", {
21845
+ })), /*#__PURE__*/React__default['default'].createElement(UserUpdateDisplayName, {
21846
+ id: "pelcro-input-display-name",
21847
+ autoComplete: "display-name",
21848
+ errorId: "pelcro-input-display-name-error",
21849
+ label: t("labels.displayname")
21850
+ }), showUsernameInput && /*#__PURE__*/React__default['default'].createElement(UserUpdateUsername, {
21851
+ id: "pelcro-input-user-name",
21852
+ autoComplete: "user-name",
21853
+ errorId: "pelcro-input-user-name-error",
21854
+ label: t("labels.username")
21855
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
21666
21856
  className: "plc-flex plc-items-start"
21667
21857
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdatePhone, {
21668
21858
  id: "pelcro-input-phone",
@@ -21693,7 +21883,7 @@ function UserUpdateModal({
21693
21883
  }) {
21694
21884
  const {
21695
21885
  switchView
21696
- } = usePelcro();
21886
+ } = usePelcro$1();
21697
21887
 
21698
21888
  const onPictureClick = () => {
21699
21889
  switchView("profile-picture");
@@ -21709,37 +21899,6 @@ function UserUpdateModal({
21709
21899
  }
21710
21900
  UserUpdateModal.viewId = "user-edit";
21711
21901
 
21712
- function DisplayName({
21713
- store,
21714
- ...otherProps
21715
- }) {
21716
- const {
21717
- dispatch,
21718
- state
21719
- } = React.useContext(store);
21720
-
21721
- const handleInputChange = value => {
21722
- dispatch({
21723
- type: SET_DISPLAY_NAME,
21724
- payload: value
21725
- });
21726
- };
21727
-
21728
- if (state.loading) {
21729
- return /*#__PURE__*/React__default['default'].createElement(Loader, null);
21730
- }
21731
-
21732
- return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
21733
- type: "text",
21734
- value: state.displayName || null,
21735
- onChange: e => handleInputChange(e.target.value)
21736
- }, otherProps));
21737
- }
21738
-
21739
- const UserUpdateDisplayName = props => /*#__PURE__*/React__default['default'].createElement(DisplayName, Object.assign({
21740
- store: store$f
21741
- }, props));
21742
-
21743
21902
  const UserUpdateTextInput = props => {
21744
21903
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
21745
21904
  store: store$f
@@ -21802,7 +21961,7 @@ const AddressCreateContainer = ({
21802
21961
  order,
21803
21962
  set,
21804
21963
  selectedMembership
21805
- } = usePelcro();
21964
+ } = usePelcro$1();
21806
21965
  const giftCode = (_props$giftCode = props.giftCode) !== null && _props$giftCode !== void 0 ? _props$giftCode : giftCodeFromStore;
21807
21966
  const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
21808
21967
  React.useEffect(() => {
@@ -21907,7 +22066,7 @@ const AddressCreateContainer = ({
21907
22066
  return onFailure(err);
21908
22067
  }
21909
22068
 
21910
- notify.success(t("messages.addressUpdated"));
22069
+ notify$1.success(t("messages.addressUpdated"));
21911
22070
  return onMembershipAdressUpdateSuccess(res);
21912
22071
  });
21913
22072
  }
@@ -22559,7 +22718,7 @@ const AddressCreateModal = ({
22559
22718
  switchView,
22560
22719
  switchToPaymentView,
22561
22720
  resetView
22562
- } = usePelcro();
22721
+ } = usePelcro$1();
22563
22722
 
22564
22723
  const onSuccess = newAddressId => {
22565
22724
  var _otherProps$onSuccess;
@@ -22652,7 +22811,7 @@ const AddressUpdateContainer = ({
22652
22811
 
22653
22812
  const {
22654
22813
  addressIdToEdit
22655
- } = usePelcro();
22814
+ } = usePelcro$1();
22656
22815
  const addressId = (_props$addressId = props === null || props === void 0 ? void 0 : props.addressId) !== null && _props$addressId !== void 0 ? _props$addressId : addressIdToEdit;
22657
22816
  const [t] = useTranslation("address");
22658
22817
  React.useEffect(() => {
@@ -23743,7 +23902,7 @@ const PasswordForgotModal = ({
23743
23902
  } = useTranslation("passwordForgot");
23744
23903
  const {
23745
23904
  switchView
23746
- } = usePelcro();
23905
+ } = usePelcro$1();
23747
23906
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
23748
23907
  id: "pelcro-password-forgot-modal",
23749
23908
  onDisplay: onDisplay,
@@ -24328,7 +24487,7 @@ const CartContainer = ({
24328
24487
  const {
24329
24488
  cartItems,
24330
24489
  set
24331
- } = usePelcro();
24490
+ } = usePelcro$1();
24332
24491
  const {
24333
24492
  t
24334
24493
  } = useTranslation("shop");
@@ -24433,7 +24592,7 @@ const CartRemoveItemButton = ({
24433
24592
  }) => {
24434
24593
  const {
24435
24594
  removeFromCart
24436
- } = usePelcro();
24595
+ } = usePelcro$1();
24437
24596
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
24438
24597
  variant: "icon",
24439
24598
  "data-key": itemId,
@@ -24496,7 +24655,7 @@ const CartTotalPrice = () => {
24496
24655
  } = React.useContext(store$8);
24497
24656
  const {
24498
24657
  cartItems
24499
- } = usePelcro();
24658
+ } = usePelcro$1();
24500
24659
  const totalPriceCurrency = cartItems[0].currency;
24501
24660
  const {
24502
24661
  t
@@ -24516,7 +24675,7 @@ const CartTotalPrice = () => {
24516
24675
  const CartView = props => {
24517
24676
  const {
24518
24677
  cartItems
24519
- } = usePelcro();
24678
+ } = usePelcro$1();
24520
24679
  const {
24521
24680
  t
24522
24681
  } = useTranslation("cart");
@@ -24577,7 +24736,7 @@ const CartModal = ({
24577
24736
  switchView,
24578
24737
  switchToAddressView,
24579
24738
  isAuthenticated
24580
- } = usePelcro();
24739
+ } = usePelcro$1();
24581
24740
 
24582
24741
  const onSuccess = items => {
24583
24742
  var _otherProps$onSuccess;
@@ -24609,7 +24768,7 @@ const ShopSelectProductButton = ({
24609
24768
  }) => {
24610
24769
  const {
24611
24770
  addToCart
24612
- } = usePelcro();
24771
+ } = usePelcro$1();
24613
24772
  const {
24614
24773
  t
24615
24774
  } = useTranslation("shop");
@@ -24641,7 +24800,7 @@ const ShopPurchaseButton = ({
24641
24800
  }) => {
24642
24801
  const {
24643
24802
  purchaseItem
24644
- } = usePelcro();
24803
+ } = usePelcro$1();
24645
24804
  const {
24646
24805
  t
24647
24806
  } = useTranslation("shop");
@@ -24677,7 +24836,7 @@ const ShopView = () => {
24677
24836
  className: "plc-mt-2"
24678
24837
  }), /*#__PURE__*/React__default['default'].createElement(ShopPurchaseButton, {
24679
24838
  itemId: item.id,
24680
- className: "plc-mt-2"
24839
+ className: "plc-mt-2 pelcro-purchase-button"
24681
24840
  })));
24682
24841
  })));
24683
24842
  };
@@ -24717,7 +24876,7 @@ const OrderCreateModal = ({
24717
24876
  }) => {
24718
24877
  const {
24719
24878
  switchView
24720
- } = usePelcro();
24879
+ } = usePelcro$1();
24721
24880
 
24722
24881
  const onSuccess = () => {
24723
24882
  var _otherProps$onSuccess;
@@ -24747,7 +24906,7 @@ const OrderConfirmModal = props => {
24747
24906
  } = useTranslation("shop");
24748
24907
  const {
24749
24908
  resetView
24750
- } = usePelcro();
24909
+ } = usePelcro$1();
24751
24910
 
24752
24911
  const onClose = () => {
24753
24912
  var _props$onClose;
@@ -24839,7 +24998,7 @@ const GiftCreateContainer = ({
24839
24998
  } = useTranslation("register");
24840
24999
  const {
24841
25000
  set
24842
- } = usePelcro();
25001
+ } = usePelcro$1();
24843
25002
 
24844
25003
  const handleSubmit = (state, dispatch) => {
24845
25004
  const giftRecipient = {
@@ -25131,7 +25290,7 @@ const GiftCreateModal = ({
25131
25290
  switchToAddressView,
25132
25291
  switchToPaymentView,
25133
25292
  product
25134
- } = usePelcro();
25293
+ } = usePelcro$1();
25135
25294
 
25136
25295
  const onSuccess = giftRecipient => {
25137
25296
  var _otherProps$onSuccess;
@@ -25159,6 +25318,7 @@ const GiftCreateModal = ({
25159
25318
  GiftCreateModal.viewId = "gift-create";
25160
25319
 
25161
25320
  const initialState$6 = {
25321
+ isSubmitting: false,
25162
25322
  giftCode: "",
25163
25323
  buttonDisabled: true,
25164
25324
  alert: {
@@ -25177,14 +25337,24 @@ const GiftRedeemContainer = ({
25177
25337
  onSuccess = () => {},
25178
25338
  onFailure = () => {},
25179
25339
  onDisplay = () => {},
25180
- children
25340
+ children,
25341
+ ...props
25181
25342
  }) => {
25343
+ var _ref, _props$subscriptionId;
25344
+
25182
25345
  const {
25183
25346
  t
25184
25347
  } = useTranslation("register");
25185
25348
  const {
25186
25349
  set
25187
- } = usePelcro();
25350
+ } = usePelcro$1();
25351
+ const {
25352
+ switchView,
25353
+ switchToAddressView,
25354
+ isAuthenticated,
25355
+ subscriptionIdToRenew: subscriptionIdToRenewFromStore
25356
+ } = usePelcro$1();
25357
+ const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
25188
25358
  React.useEffect(() => {
25189
25359
  onDisplay();
25190
25360
  }, []);
@@ -25205,7 +25375,41 @@ const GiftRedeemContainer = ({
25205
25375
  set({
25206
25376
  giftCode
25207
25377
  });
25208
- onSuccess(giftCode);
25378
+
25379
+ if (!isAuthenticated()) {
25380
+ switchView("register");
25381
+ } else {
25382
+ console.log("Shaker");
25383
+ window.Pelcro.subscription.redeemGift({
25384
+ auth_token: window.Pelcro.user.read().auth_token,
25385
+ gift_code: giftCode,
25386
+ // redeem gift as a future phase of an existing subscription
25387
+ subscription_id: subscriptionIdToRenew
25388
+ }, (err, res) => {
25389
+ dispatch({
25390
+ type: LOADING,
25391
+ payload: false
25392
+ });
25393
+
25394
+ if (err) {
25395
+ dispatch({
25396
+ type: SHOW_ALERT,
25397
+ payload: {
25398
+ type: "error",
25399
+ content: getErrorMessages(err)
25400
+ }
25401
+ });
25402
+
25403
+ if (getErrorMessages(err) === "Address ID is required") {
25404
+ switchToAddressView();
25405
+ } else {
25406
+ return onFailure(err);
25407
+ }
25408
+ } else {
25409
+ return onSuccess(giftCode);
25410
+ }
25411
+ });
25412
+ }
25209
25413
  }
25210
25414
  };
25211
25415
 
@@ -25226,8 +25430,14 @@ const GiftRedeemContainer = ({
25226
25430
  buttonDisabled: action.payload
25227
25431
  });
25228
25432
 
25433
+ case LOADING:
25434
+ return lib_7({ ...state,
25435
+ isSubmitting: action.payload
25436
+ });
25437
+
25229
25438
  case HANDLE_SUBMIT:
25230
25439
  return lib_5({ ...state,
25440
+ isSubmitting: true,
25231
25441
  buttonDisabled: true
25232
25442
  }, (state, dispatch) => handleRedeem(state, dispatch));
25233
25443
 
@@ -25296,7 +25506,8 @@ const GiftRedeemSubmitButton = ({
25296
25506
  const {
25297
25507
  dispatch,
25298
25508
  state: {
25299
- disableSubmit
25509
+ disableSubmit,
25510
+ isSubmitting
25300
25511
  }
25301
25512
  } = React.useContext(store$6);
25302
25513
  const {
@@ -25309,7 +25520,8 @@ const GiftRedeemSubmitButton = ({
25309
25520
  });
25310
25521
  onClick === null || onClick === void 0 ? void 0 : onClick();
25311
25522
  },
25312
- disabled: disableSubmit
25523
+ disabled: disableSubmit,
25524
+ isLoading: isSubmitting
25313
25525
  }, otherProps), name !== null && name !== void 0 ? name : t("redeem.buttons.redeem"));
25314
25526
  };
25315
25527
 
@@ -25354,18 +25566,13 @@ const GiftRedeemModal = ({
25354
25566
  switchView,
25355
25567
  switchToAddressView,
25356
25568
  isAuthenticated
25357
- } = usePelcro();
25569
+ } = usePelcro$1();
25358
25570
 
25359
25571
  const onSuccess = giftCode => {
25360
25572
  var _otherProps$onSuccess;
25361
25573
 
25362
25574
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, giftCode);
25363
-
25364
- if (isAuthenticated()) {
25365
- switchToAddressView();
25366
- } else {
25367
- switchView("register");
25368
- }
25575
+ switchView("subscription-success");
25369
25576
  };
25370
25577
 
25371
25578
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
@@ -25426,7 +25633,7 @@ const AddressSelectContainer = ({
25426
25633
  subscriptionIdToRenew: subscriptionIdToRenewFromStore,
25427
25634
  set,
25428
25635
  selectedMembership
25429
- } = usePelcro();
25636
+ } = usePelcro$1();
25430
25637
  const giftCode = (_props$giftCode = props.giftCode) !== null && _props$giftCode !== void 0 ? _props$giftCode : giftCodeFromStore;
25431
25638
  const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
25432
25639
 
@@ -25463,7 +25670,7 @@ const AddressSelectContainer = ({
25463
25670
  return onFailure(err);
25464
25671
  }
25465
25672
 
25466
- notify.success(t("messages.addressUpdated"));
25673
+ notify$1.success(t("messages.addressUpdated"));
25467
25674
  return onMembershipAdressUpdateSuccess(res);
25468
25675
  });
25469
25676
  }
@@ -25668,7 +25875,7 @@ const AddressSelectModal = ({
25668
25875
  switchView,
25669
25876
  switchToPaymentView,
25670
25877
  resetView
25671
- } = usePelcro();
25878
+ } = usePelcro$1();
25672
25879
 
25673
25880
  const onSuccess = selectedAddressId => {
25674
25881
  var _otherProps$onSuccess;
@@ -25746,7 +25953,7 @@ const PaymentMethodSelectContainer = ({
25746
25953
  const {
25747
25954
  set,
25748
25955
  selectedPaymentMethodId: selectedPaymentMethodIdFromStore
25749
- } = usePelcro();
25956
+ } = usePelcro$1();
25750
25957
 
25751
25958
  const submitPaymentMethod = ({
25752
25959
  selectedPaymentMethodId
@@ -25929,7 +26136,7 @@ const PaymentMethodSelectModal = ({
25929
26136
  switchToCheckoutForm,
25930
26137
  set,
25931
26138
  plan
25932
- } = usePelcro();
26139
+ } = usePelcro$1();
25933
26140
  const skipPayment = (_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.skipPaymentForFreePlans;
25934
26141
  React.useEffect(() => {
25935
26142
  if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
@@ -27237,7 +27444,7 @@ const SavedItems = ({
27237
27444
  const [isLoading, setLoading] = React.useState(false);
27238
27445
  const {
27239
27446
  isAuthenticated
27240
- } = usePelcro();
27447
+ } = usePelcro$1();
27241
27448
 
27242
27449
  const removeItemFromMetadata = (category, title) => {
27243
27450
  const user = window.Pelcro.user.read();
@@ -27436,7 +27643,7 @@ const SubscriptionsItems = ({
27436
27643
  setSubscriptionToCancel,
27437
27644
  setSubscriptionToSuspend,
27438
27645
  set
27439
- } = usePelcro();
27646
+ } = usePelcro$1();
27440
27647
  const subs = getNonDonationSubs();
27441
27648
  if (subs.length === 0) return null;
27442
27649
  return subs.sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
@@ -27457,7 +27664,7 @@ const SubscriptionsItems = ({
27457
27664
  }
27458
27665
 
27459
27666
  onClose === null || onClose === void 0 ? void 0 : onClose();
27460
- notify.confirm((onSuccess, onFailure) => {
27667
+ notify$1.confirm((onSuccess, onFailure) => {
27461
27668
  cancelSubscription(sub.id, onSuccess, onFailure);
27462
27669
  }, {
27463
27670
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -27515,7 +27722,7 @@ const SubscriptionsItems = ({
27515
27722
  }
27516
27723
 
27517
27724
  onClose === null || onClose === void 0 ? void 0 : onClose();
27518
- notify.confirm((onSuccess, onFailure) => {
27725
+ notify$1.confirm((onSuccess, onFailure) => {
27519
27726
  unSuspendSubscription(sub.id, onSuccess, onFailure);
27520
27727
  }, {
27521
27728
  confirmMessage: t("messages.subUnSuspend.isSureToUnSuspend"),
@@ -27961,11 +28168,56 @@ function SvgQrcode(props) {
27961
28168
  })));
27962
28169
  }
27963
28170
 
27964
- const DonationsMenu = () => {
28171
+ const DonationsMenu = ({
28172
+ reactivateSubscription,
28173
+ disableSubmit,
28174
+ cancelSubscription
28175
+ }) => {
27965
28176
  const {
27966
28177
  t
27967
28178
  } = useTranslation("dashboard");
28179
+ const {
28180
+ switchView,
28181
+ setSubscriptionToCancel
28182
+ } = usePelcro$1();
27968
28183
  const subscriptions = getDonationSubs().sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
28184
+ // Cancel button click handlers
28185
+ const onCancelClick = () => {
28186
+ var _onClose;
28187
+
28188
+ const isImmediateCancelationEnabled = window.Pelcro.site.read().cancel_settings.status;
28189
+
28190
+ if (isImmediateCancelationEnabled) {
28191
+ setSubscriptionToCancel(sub.id);
28192
+ return switchView("subscription-cancel");
28193
+ }
28194
+
28195
+ if (userMustVerifyEmail()) {
28196
+ return switchView("email-verify");
28197
+ }
28198
+
28199
+ (_onClose = onClose) === null || _onClose === void 0 ? void 0 : _onClose();
28200
+ notify.confirm((onSuccess, onFailure) => {
28201
+ cancelSubscription(sub.id, onSuccess, onFailure);
28202
+ }, {
28203
+ confirmMessage: t("messages.subCancellation.isSureToCancel"),
28204
+ loadingMessage: t("messages.subCancellation.loading"),
28205
+ successMessage: t("messages.subCancellation.success"),
28206
+ errorMessage: t("messages.subCancellation.error")
28207
+ }, {
28208
+ closeButtonLabel: t("labels.subCancellation.goBack")
28209
+ });
28210
+ }; // Reactivate button click handlers
28211
+
28212
+
28213
+ const onReactivateClick = () => {
28214
+ if (userMustVerifyEmail()) {
28215
+ return switchView("email-verify");
28216
+ }
28217
+
28218
+ reactivateSubscription(sub.id);
28219
+ };
28220
+
27969
28221
  return /*#__PURE__*/React__default['default'].createElement("tr", {
27970
28222
  key: sub.id,
27971
28223
  className: "plc-w-full plc-align-top pelcro-donation-row"
@@ -27977,7 +28229,21 @@ const DonationsMenu = () => {
27977
28229
  className: "plc-text-xs plc-text-gray-400 pelcro-donation-price"
27978
28230
  }, getFormattedPriceByLocal(sub.plan.amount * sub.quantity, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("div", {
27979
28231
  className: "plc-mb-4 plc-text-gray-500 pelcro-donation-date"
27980
- }, sub.status && /*#__PURE__*/React__default['default'].createElement("span", null, formatStartDate(sub.start)))));
28232
+ }, sub.status && /*#__PURE__*/React__default['default'].createElement("span", null, formatStartDate(sub.start)))), /*#__PURE__*/React__default['default'].createElement("td", null, sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default['default'].createElement(Button, {
28233
+ variant: "ghost",
28234
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
28235
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
28236
+ onClick: onReactivateClick,
28237
+ disabled: disableSubmit,
28238
+ "data-key": sub.id
28239
+ }, t("labels.reactivate")), !sub.plan.auto_renew || sub.plan.auto_renew && sub.cancel_at_period_end === 0 ? /*#__PURE__*/React__default['default'].createElement(Button, {
28240
+ variant: "ghost",
28241
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
28242
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
28243
+ onClick: onCancelClick,
28244
+ disabled: disableSubmit,
28245
+ "data-key": sub.id
28246
+ }, t("labels.unsubscribe")) : ""));
27981
28247
  });
27982
28248
  return /*#__PURE__*/React__default['default'].createElement("table", {
27983
28249
  className: "plc-w-full plc-table-fixed pelcro-donations-table"
@@ -27987,7 +28253,9 @@ const DonationsMenu = () => {
27987
28253
  className: "plc-w-6/12 "
27988
28254
  }, t("labels.plan")), /*#__PURE__*/React__default['default'].createElement("th", {
27989
28255
  className: "plc-w-6/12 "
27990
- }, t("labels.startDate")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", {
28256
+ }, t("labels.startDate")), /*#__PURE__*/React__default['default'].createElement("th", {
28257
+ className: "plc-w-3/12 "
28258
+ }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", {
27991
28259
  className: "plc-h-4"
27992
28260
  }), subscriptions));
27993
28261
  };
@@ -28033,7 +28301,7 @@ const InvoicesItems = () => {
28033
28301
  const {
28034
28302
  setInvoice,
28035
28303
  switchView
28036
- } = usePelcro();
28304
+ } = usePelcro$1();
28037
28305
  const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28038
28306
 
28039
28307
  const showInvoiceDetails = event => {
@@ -28164,7 +28432,7 @@ const MembershipsItems = () => {
28164
28432
  switchView,
28165
28433
  setSelectedMembership,
28166
28434
  switchToAddressView
28167
- } = usePelcro();
28435
+ } = usePelcro$1();
28168
28436
  const memberships = getActiveMemberships();
28169
28437
 
28170
28438
  const onChangeAddressClick = membershipId => {
@@ -28244,7 +28512,7 @@ function DashboardWithHook(props) {
28244
28512
  resetView,
28245
28513
  logout,
28246
28514
  set
28247
- } = usePelcro();
28515
+ } = usePelcro$1();
28248
28516
  return /*#__PURE__*/React__default['default'].createElement(DashboardWithTrans, {
28249
28517
  setAddress: addressIdToEdit => set({
28250
28518
  addressIdToEdit
@@ -28820,7 +29088,11 @@ class Dashboard extends React.Component {
28820
29088
  className: "plc-transform plc-scale-120 plc-w-7 plc-h-8 plc-mr-1 plc-pt-1"
28821
29089
  }),
28822
29090
  title: this.locale("labels.donations"),
28823
- content: /*#__PURE__*/React__default['default'].createElement(DonationsMenu, null)
29091
+ content: /*#__PURE__*/React__default['default'].createElement(DonationsMenu, {
29092
+ reactivateSubscription: this.reactivateSubscription,
29093
+ disableSubmit: this.state.disableSubmit,
29094
+ cancelSubscription: this.cancelSubscription
29095
+ })
28824
29096
  }), /*#__PURE__*/React__default['default'].createElement(Accordion.item, {
28825
29097
  name: SUB_MENUS.GIFTS,
28826
29098
  icon: /*#__PURE__*/React__default['default'].createElement(SvgGift, null),
@@ -28880,7 +29152,7 @@ const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
28880
29152
  const DashboardOpenButton = () => {
28881
29153
  const {
28882
29154
  switchView
28883
- } = usePelcro();
29155
+ } = usePelcro$1();
28884
29156
  return /*#__PURE__*/React__default['default'].createElement("div", {
28885
29157
  className: "plc-fixed plc-right-4 plc-bottom-4 pelcro-open-dashboard-btn"
28886
29158
  }, /*#__PURE__*/React__default['default'].createElement("button", {
@@ -30869,11 +31141,34 @@ const EmailVerifyModal = ({
30869
31141
  onClose,
30870
31142
  ...otherProps
30871
31143
  }) => {
31144
+ const {
31145
+ product,
31146
+ plan,
31147
+ switchToAddressView,
31148
+ switchToPaymentView
31149
+ } = usePelcro();
31150
+
31151
+ const onSuccess = res => {
31152
+ var _props$onSuccess, _props;
31153
+
31154
+ (_props$onSuccess = (_props = props).onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(_props, res);
31155
+
31156
+ if (product) {
31157
+ if (product.address_required) {
31158
+ return switchToAddressView();
31159
+ } else {
31160
+ return switchToPaymentView();
31161
+ }
31162
+ }
31163
+ };
31164
+
30872
31165
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
30873
31166
  onDisplay: onDisplay,
30874
31167
  onClose: onClose,
30875
31168
  id: "pelcro-email-verify-modal"
30876
- }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(EmailVerifyView, otherProps)), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
31169
+ }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(EmailVerifyView, Object.assign({
31170
+ onSuccess: onSuccess
31171
+ }, otherProps))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
30877
31172
  };
30878
31173
  EmailVerifyModal.viewId = "email-verify";
30879
31174
 
@@ -31021,14 +31316,14 @@ function VerifyLinkTokenModal({
31021
31316
  } = useTranslation("verifyLinkToken");
31022
31317
  const {
31023
31318
  resetView
31024
- } = usePelcro();
31319
+ } = usePelcro$1();
31025
31320
 
31026
31321
  const onSuccess = res => {
31027
31322
  var _props$onSuccess;
31028
31323
 
31029
31324
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
31030
31325
  resetView();
31031
- notify.success(t("messages.success"));
31326
+ notify$1.success(t("messages.success"));
31032
31327
  };
31033
31328
 
31034
31329
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
@@ -31071,7 +31366,7 @@ const InvoicePaymentModal = ({
31071
31366
  }) => {
31072
31367
  const {
31073
31368
  switchView
31074
- } = usePelcro();
31369
+ } = usePelcro$1();
31075
31370
 
31076
31371
  const onSuccess = () => {
31077
31372
  var _otherProps$onSuccess;
@@ -31148,7 +31443,7 @@ const InvoiceDetailsDownloadButton = ({
31148
31443
  } = useTranslation("invoiceDetails");
31149
31444
  const {
31150
31445
  invoice
31151
- } = usePelcro();
31446
+ } = usePelcro$1();
31152
31447
  return /*#__PURE__*/React__default['default'].createElement(Link, Object.assign({
31153
31448
  className: `plc-px-6 plc-py-2 plc-uppercase plc-bg-transparent plc-text-primary-500 plc-border plc-border-primary-500 plc-rounded focus:plc-outline-none focus:plc-ring-2 focus:plc-ring-primary-300 plc-tracking-wider hover:plc-bg-primary-600 focus:plc-bg-primary-600 hover:plc-text-white focus:plc-text-white hover:plc-shadow-none plc-no-underline ${className}`,
31154
31449
  id: "pelcro-download-invoice-link",
@@ -31185,7 +31480,7 @@ const InvoiceDetailsView = props => {
31185
31480
  } = useTranslation("invoiceDetails");
31186
31481
  const {
31187
31482
  invoice
31188
- } = usePelcro();
31483
+ } = usePelcro$1();
31189
31484
  const showPayButton = canPayInvoice(invoice);
31190
31485
  const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
31191
31486
  const hasPlanDetails = Boolean(invoice.plan);
@@ -31253,7 +31548,7 @@ const InvoiceDetailsModal = ({
31253
31548
  }) => {
31254
31549
  const {
31255
31550
  switchToPaymentView
31256
- } = usePelcro();
31551
+ } = usePelcro$1();
31257
31552
 
31258
31553
  const onSuccess = () => {
31259
31554
  var _otherProps$onSuccess;
@@ -32911,6 +33206,7 @@ exports.UserUpdatePhone = UserUpdatePhone;
32911
33206
  exports.UserUpdateProfilePic = UserUpdateProfilePic;
32912
33207
  exports.UserUpdateTextInput = UserUpdateTextInput;
32913
33208
  exports.UserUpdateTin = UserUpdateTin;
33209
+ exports.UserUpdateUsername = UserUpdateUsername;
32914
33210
  exports.UserUpdateView = UserUpdateView;
32915
33211
  exports.VerifyLinkTokenContainer = VerifyLinkTokenContainer;
32916
33212
  exports.VerifyLinkTokenLoader = VerifyLinkTokenLoader;
@@ -32921,6 +33217,6 @@ exports.i18n = i18next;
32921
33217
  exports.initButtons = init$1;
32922
33218
  exports.initContentEntitlement = init;
32923
33219
  exports.invoicePaymentSubmitButton = invoicePaymentSubmitButton;
32924
- exports.notify = notify;
33220
+ exports.notify = notify$1;
32925
33221
  exports.unauthenticatedButtons = unauthenticatedButtons;
32926
- exports.usePelcro = usePelcro;
33222
+ exports.usePelcro = usePelcro$1;