@pelcro/react-pelcro-js 2.4.0-beta.9 → 2.6.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.esm.js CHANGED
@@ -3432,6 +3432,7 @@ var paymentMethod_fr = {
3432
3432
  };
3433
3433
 
3434
3434
  var title$d = "Enter your email to subscribe to our newsletter";
3435
+ var updateTitle$1 = "Update newsletter selections";
3435
3436
  var subtitle$7 = "We may use your email for other marketing communication";
3436
3437
  var labels$l = {
3437
3438
  submit: "Submit",
@@ -3443,22 +3444,21 @@ var labels$l = {
3443
3444
  };
3444
3445
  var messages$p = {
3445
3446
  alreadyHaveAccount: "Already have an account?",
3447
+ success: "Newsletters were successfully updated",
3446
3448
  loginHere: "Login here.",
3447
3449
  createAnAccount: " Create an account by clicking ",
3448
3450
  here: "here"
3449
3451
  };
3450
- var errors$b = {
3451
- "": ""
3452
- };
3453
3452
  var newsletter_en = {
3454
3453
  title: title$d,
3454
+ updateTitle: updateTitle$1,
3455
3455
  subtitle: subtitle$7,
3456
3456
  labels: labels$l,
3457
- messages: messages$p,
3458
- errors: errors$b
3457
+ messages: messages$p
3459
3458
  };
3460
3459
 
3461
3460
  var title$c = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
3461
+ var updateTitle = "Mettre à jour son choix d'infolettres";
3462
3462
  var subtitle$6 = "Nous pouvons utiliser votre adresse courriel pour d’autres communications marketing";
3463
3463
  var labels$k = {
3464
3464
  submit: "Lire l’article !",
@@ -3470,19 +3470,17 @@ var labels$k = {
3470
3470
  };
3471
3471
  var messages$o = {
3472
3472
  alreadyHaveAccount: "Vous avez déjà un compte ?",
3473
+ success: "Votre choix d'infolettres à été mis à jour",
3473
3474
  loginHere: "Connectez-vous ici",
3474
3475
  createAnAccount: " Créez un compte en cliquant ",
3475
3476
  here: "ici"
3476
3477
  };
3477
- var errors$a = {
3478
- "": ""
3479
- };
3480
3478
  var newsletter_fr = {
3481
3479
  title: title$c,
3480
+ updateTitle: updateTitle,
3482
3481
  subtitle: subtitle$6,
3483
3482
  labels: labels$k,
3484
- messages: messages$o,
3485
- errors: errors$a
3483
+ messages: messages$o
3486
3484
  };
3487
3485
 
3488
3486
  var labels$j = {
@@ -3591,7 +3589,8 @@ var labels$h = {
3591
3589
  code: "Coupon code",
3592
3590
  "for": "for",
3593
3591
  interval: "{{count}} {{interval}}",
3594
- interval_plural: "{{count}} {{interval}}s"
3592
+ interval_plural: "{{count}} {{interval}}s",
3593
+ tax: "+ Tax"
3595
3594
  };
3596
3595
  var checkoutForm_en = {
3597
3596
  messages: messages$j,
@@ -3616,7 +3615,8 @@ var labels$g = {
3616
3615
  code: "Code promo",
3617
3616
  "for": "pour",
3618
3617
  interval: "{{count}} {{interval}}",
3619
- interval_plural: "{{count}} {{interval}}s"
3618
+ interval_plural: "{{count}} {{interval}}s",
3619
+ tax: "+ Taxe"
3620
3620
  };
3621
3621
  var checkoutForm_fr = {
3622
3622
  messages: messages$i,
@@ -4329,7 +4329,8 @@ var labels$3 = {
4329
4329
  title: "Status",
4330
4330
  active: "Active",
4331
4331
  inTrial: "In trial",
4332
- endingSoon: "Ending soon"
4332
+ endingSoon: "Ending soon",
4333
+ scheduled: "Scheduled"
4333
4334
  },
4334
4335
  shipments: "Shipments remaining",
4335
4336
  logout: "Logout",
@@ -4345,6 +4346,7 @@ var labels$3 = {
4345
4346
  profile: "Profile",
4346
4347
  updateProfile: "Edit profile",
4347
4348
  changePassword: "Change password",
4349
+ editNewsletters: "Edit newsletters",
4348
4350
  edit: "Edit",
4349
4351
  gifts: "Gifts",
4350
4352
  redeemGift: "Redeem gift",
@@ -4354,6 +4356,7 @@ var labels$3 = {
4354
4356
  paymentSource: "Payment cards",
4355
4357
  actions: "Actions",
4356
4358
  expiresOn: "Ends",
4359
+ startsOn: "Starts",
4357
4360
  renewsOn: "Renews",
4358
4361
  canceledOn: "Canceled on",
4359
4362
  recipient: "Recipient",
@@ -4405,7 +4408,8 @@ var labels$2 = {
4405
4408
  title: "Statut",
4406
4409
  active: "Active",
4407
4410
  inTrial: "Dans l'essai",
4408
- endingSoon: "Fin bientôt"
4411
+ endingSoon: "Fin bientôt",
4412
+ scheduled: "Programmé"
4409
4413
  },
4410
4414
  shipments: "Expéditions restantes",
4411
4415
  logout: "Déconnexion",
@@ -4421,6 +4425,7 @@ var labels$2 = {
4421
4425
  profile: "Profil",
4422
4426
  updateProfile: "Mettre à jour le profil",
4423
4427
  changePassword: "Changer le mot de passe",
4428
+ editNewsletters: "Modifier les newsletters",
4424
4429
  edit: "Modifier",
4425
4430
  gifts: "Cadeaux",
4426
4431
  redeemGift: "Échanger un cadeau",
@@ -4430,6 +4435,7 @@ var labels$2 = {
4430
4435
  paymentSource: "Sources de paiement",
4431
4436
  actions: "Actes",
4432
4437
  expiresOn: "Expire le",
4438
+ startsOn: "Débute le",
4433
4439
  renewsOn: "Renouvelle le",
4434
4440
  canceledOn: "Annulé le",
4435
4441
  recipient: "Destinataire",
@@ -4462,7 +4468,7 @@ var messages$2 = {
4462
4468
  isSureToCancel: "Êtes-vous certain de vouloir annuler votre abonnement?",
4463
4469
  loading: "Annulation de l'abonnement",
4464
4470
  success: "L'abonnement a été annulé avec succès",
4465
- error: "Une erreure s'est produite lors de l'annulation de l'abonnement"
4471
+ error: "Une erreur s'est produite lors de l'annulation de l'abonnement"
4466
4472
  }
4467
4473
  };
4468
4474
  var dashboard_fr = {
@@ -5897,7 +5903,7 @@ class PelcroActions {
5897
5903
  view,
5898
5904
  cartItems,
5899
5905
  ...otherStateFields
5900
- } = initialState$f;
5906
+ } = initialState$g;
5901
5907
  this.set(otherStateFields);
5902
5908
  });
5903
5909
 
@@ -6187,7 +6193,7 @@ class PelcroCallbacks {
6187
6193
 
6188
6194
  }
6189
6195
 
6190
- const initialState$f = {
6196
+ const initialState$g = {
6191
6197
  // View
6192
6198
  view: null,
6193
6199
  // Plans
@@ -6215,7 +6221,7 @@ const createPelcroStore = () => createStore(middleware_3((set, get) => {
6215
6221
  return {
6216
6222
  // Store setter
6217
6223
  set,
6218
- ...initialState$f,
6224
+ ...initialState$g,
6219
6225
  // State actions
6220
6226
  ...actions,
6221
6227
  // Callbacks
@@ -6295,13 +6301,34 @@ const getAddressById = id => {
6295
6301
  };
6296
6302
  /**
6297
6303
  * Transforms locale names stored in our backend like
6298
- * "en_US" into the standerd accepted in core i18n methods: "en-US"
6304
+ * "en_US" into the standard accepted in core i18n methods: "en-US"
6299
6305
  * @param {string} localeName
6300
6306
  * @return {string | undefined}
6301
6307
  * @example getCanonicalLocaleFormat("en_US") => "en-US"
6302
6308
  */
6303
6309
 
6304
6310
  const getCanonicalLocaleFormat = localeName => localeName === null || localeName === void 0 ? void 0 : localeName.replace("_", "-");
6311
+ /**
6312
+ * @param {string} localeName
6313
+ * @return {string | undefined}
6314
+ * @example getLanguageWithoutRegion("en-US") => "en"
6315
+ */
6316
+
6317
+ const getLanguageWithoutRegion = localeName => {
6318
+ var _getCanonicalLocaleFo;
6319
+
6320
+ return (_getCanonicalLocaleFo = getCanonicalLocaleFormat(localeName)) === null || _getCanonicalLocaleFo === void 0 ? void 0 : _getCanonicalLocaleFo.split("-")[0];
6321
+ };
6322
+ /**
6323
+ * Gets the current page language or fallbacks to site default
6324
+ * @return {string | undefined}
6325
+ */
6326
+
6327
+ const getPageOrDefaultLanguage = () => {
6328
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6329
+
6330
+ 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);
6331
+ };
6305
6332
  /**
6306
6333
  * Returns a formatted price string depending on locale
6307
6334
  * @param {number} amount
@@ -6311,7 +6338,7 @@ const getCanonicalLocaleFormat = localeName => localeName === null || localeName
6311
6338
  * @example getFormattedPriceByLocal(10, 'USD', 'en-US') => "$10.00"
6312
6339
  */
6313
6340
 
6314
- const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en-US") => {
6341
+ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6315
6342
  const formatter = new Intl.NumberFormat(getCanonicalLocaleFormat(locale), {
6316
6343
  style: "currency",
6317
6344
  currency
@@ -6336,8 +6363,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6336
6363
  totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6337
6364
  }
6338
6365
 
6339
- const locale = window.Pelcro.site.read().default_locale;
6340
- return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, locale);
6366
+ return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
6341
6367
  };
6342
6368
  /**
6343
6369
  * returns true if the URL contains a supported view trigger URL
@@ -6346,11 +6372,43 @@ const calcAndFormatItemsTotal = (items, currency) => {
6346
6372
  */
6347
6373
 
6348
6374
  const isValidViewFromURL = viewID => {
6349
- if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart"].includes(viewID)) {
6375
+ if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6350
6376
  return true;
6351
6377
  }
6352
6378
 
6353
6379
  return false;
6380
+ /**
6381
+ *
6382
+ */
6383
+
6384
+ function hasValidNewsletterUpdateUrl() {
6385
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
6386
+
6387
+ if (viewID !== "newsletter-update") return false;
6388
+ 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;
6389
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6390
+
6391
+ if (!siteHasNewslettersDefined) {
6392
+ return false;
6393
+ }
6394
+
6395
+ const queryParamEmail = window.Pelcro.helpers.getURLParameter("email");
6396
+
6397
+ if (queryParamEmail && window.Pelcro.user.isAuthenticated()) {
6398
+ var _window$Pelcro$user$r4;
6399
+
6400
+ if (queryParamEmail !== ((_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.email)) {
6401
+ console.error("email query parameter and user account email are different, url email query parameter must match user email if user is logged in");
6402
+ return false;
6403
+ }
6404
+ }
6405
+
6406
+ if (!queryParamEmail && !window.Pelcro.user.isAuthenticated()) {
6407
+ return false;
6408
+ }
6409
+
6410
+ return true;
6411
+ }
6354
6412
  };
6355
6413
  /**
6356
6414
  * Returns the current stable viewID from all old variations
@@ -6382,7 +6440,7 @@ const disableScroll = () => {
6382
6440
  }
6383
6441
  };
6384
6442
  const trackSubscriptionOnGA = () => {
6385
- var _ReactGA$set, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6443
+ var _ReactGA$set, _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6386
6444
 
6387
6445
  const {
6388
6446
  product,
@@ -6404,7 +6462,7 @@ const trackSubscriptionOnGA = () => {
6404
6462
  }
6405
6463
 
6406
6464
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
6407
- currencyCode: (_window$Pelcro$user$r4 = (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.currency) !== null && _window$Pelcro$user$r4 !== void 0 ? _window$Pelcro$user$r4 : plan.currency
6465
+ 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
6408
6466
  });
6409
6467
  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", {
6410
6468
  id: lastSubscriptionId,
@@ -6432,9 +6490,9 @@ const trackSubscriptionOnGA = () => {
6432
6490
  */
6433
6491
 
6434
6492
  const userHasPaymentMethod = () => {
6435
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
6493
+ var _window$Pelcro$user$r7, _window$Pelcro$user$r8;
6436
6494
 
6437
- const sources = (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.sources) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : [];
6495
+ const sources = (_window$Pelcro$user$r7 = (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.sources) !== null && _window$Pelcro$user$r7 !== void 0 ? _window$Pelcro$user$r7 : [];
6438
6496
  return sources.length > 0;
6439
6497
  };
6440
6498
  /**
@@ -6500,10 +6558,20 @@ const getPaymentCardIcon$1 = name => {
6500
6558
  d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
6501
6559
  }));
6502
6560
  };
6561
+ /**
6562
+ * Gets the current date with time set to 0
6563
+ * @param {Date} dateObject
6564
+ * @return {Date}
6565
+ */
6566
+
6567
+ function getDateWithoutTime(dateObject) {
6568
+ const date = new Date(dateObject.getTime());
6569
+ date.setHours(0, 0, 0, 0);
6570
+ return date;
6571
+ }
6503
6572
 
6504
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6505
6573
  const resources = {
6506
- "en-US": {
6574
+ en: {
6507
6575
  common: common_en,
6508
6576
  paymentMethod: paymentMethod_en,
6509
6577
  newsletter: newsletter_en,
@@ -6525,7 +6593,7 @@ const resources = {
6525
6593
  select: select_en,
6526
6594
  notification: notification_en
6527
6595
  },
6528
- "fr-CA": {
6596
+ fr: {
6529
6597
  common: common_fr,
6530
6598
  paymentMethod: paymentMethod_fr,
6531
6599
  newsletter: newsletter_fr,
@@ -6547,13 +6615,14 @@ const resources = {
6547
6615
  select: select_fr,
6548
6616
  notification: notification_fr
6549
6617
  }
6550
- };
6551
- let locale = (_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;
6552
- if (!locale) locale = "en-US";
6618
+ }; // set UI language to the page language or default to the language in site settings
6619
+
6620
+ const locale = getPageOrDefaultLanguage();
6553
6621
  i18next.use(initReactI18next) // passes i18n down to react-i18next,
6554
6622
  .init({
6555
6623
  resources,
6556
- lng: getCanonicalLocaleFormat(locale),
6624
+ lng: locale,
6625
+ fallbackLng: "en",
6557
6626
  // debug: true,
6558
6627
  interpolation: {
6559
6628
  escapeValue: false // react already safes from xss
@@ -6564,6 +6633,16 @@ i18next.use(initReactI18next) // passes i18n down to react-i18next,
6564
6633
 
6565
6634
  }
6566
6635
  });
6636
+ const pageLanguageObserver = new MutationObserver(mutationsList => {
6637
+ mutationsList.forEach(mutationRecord => {
6638
+ if (mutationRecord.attributeName === "lang") {
6639
+ i18next.changeLanguage(window.Pelcro.helpers.getHtmlLanguageAttribute());
6640
+ }
6641
+ });
6642
+ });
6643
+ pageLanguageObserver.observe(document.documentElement, {
6644
+ attributes: true
6645
+ });
6567
6646
 
6568
6647
  function _classPrivateFieldGet(receiver, privateMap) {
6569
6648
  var descriptor = privateMap.get(receiver);
@@ -6816,8 +6895,8 @@ const saveToMetadataButton = new SaveToMetadataButtonClass();
6816
6895
 
6817
6896
  let e={data:""},t=t=>"undefined"!=typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||e,l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(})/g,a=/\/\*[^]*?\*\/|\s\s+|\n/g,n=(e,t)=>{let r,l="",a="",o="";for(let c in e){let s=e[c];"object"==typeof s?(r=t?t.replace(/([^,])+/g,e=>c.replace(/([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):c,a+="@"==c[0]?"f"==c[1]?n(s,c):c+"{"+n(s,"k"==c[1]?"":t)+"}":n(s,r)):"@"==c[0]&&"i"==c[1]?l=c+" "+s+";":(c=c.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=n.p?n.p(c,s):c+":"+s+";");}return o[0]?(r=t?t+"{"+o+"}":o,l+r+a):l+a},o={},c=e=>{let t="";for(let r in e)t+=r+("object"==typeof e[r]?c(e[r]):e[r]);return t},s=(e,t,r,s,i)=>{let p="object"==typeof e?c(e):e,u=o[p]||(o[p]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return "go"+r})(p));if(!o[u]){let t="object"==typeof e?e:(e=>{let t,r=[{}];for(;t=l.exec(e.replace(a,""));)t[4]&&r.shift(),t[3]?r.unshift(r[0][t[3]]=r[0][t[3]]||{}):t[4]||(r[0][t[1]]=t[2]);return r[0]})(e);o[u]=n(i?{["@keyframes "+u]:t}:t,r?"":"."+u);}return ((e,t,r)=>{-1==t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e);})(o[u],t,s),u},i=(e,t,r)=>e.reduce((e,l,a)=>{let o=t[a];if(o&&o.call){let e=o(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;o=t?"."+t:e&&"object"==typeof e?e.props?"":n(e,""):e;}return e+l+(null==o?"":o)},"");function p(e){let r=this||{},l=e.call?e(r.p):e;return s(l.unshift?l.raw?i(l,[].slice.call(arguments,1),r.p):l.reduce((e,t)=>t?Object.assign(e,t.call?t(r.p):t):e,{}):l,t(r.target),r.g,r.o,r.k)}let u,f,d;p.bind({g:1});let b=p.bind({k:1});function h(e,t,r,l){n.p=t,u=e,f=r,d=l;}function y(e,t){let r=this||{};return function(){let l=arguments;function a(n,o){let c=Object.assign({},n),s=c.className||a.className;r.p=Object.assign({theme:f&&f()},c),r.o=/ *go\d+/.test(s),c.className=p.apply(r,l)+(s?" "+s:""),t&&(c.ref=o);let i=c.as||e;return d&&i[0]&&d(c),u(i,c)}return t?t(a):a}}
6818
6897
 
6819
- function _extends$t() {
6820
- _extends$t = Object.assign || function (target) {
6898
+ function _extends$v() {
6899
+ _extends$v = Object.assign || function (target) {
6821
6900
  for (var i = 1; i < arguments.length; i++) {
6822
6901
  var source = arguments[i];
6823
6902
 
@@ -6831,7 +6910,7 @@ function _extends$t() {
6831
6910
  return target;
6832
6911
  };
6833
6912
 
6834
- return _extends$t.apply(this, arguments);
6913
+ return _extends$v.apply(this, arguments);
6835
6914
  }
6836
6915
 
6837
6916
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -6921,7 +7000,7 @@ var clearFromRemoveQueue = function clearFromRemoveQueue(toastId) {
6921
7000
  var reducer = function reducer(state, action) {
6922
7001
  switch (action.type) {
6923
7002
  case ActionType.ADD_TOAST:
6924
- return _extends$t({}, state, {
7003
+ return _extends$v({}, state, {
6925
7004
  toasts: [action.toast].concat(state.toasts).slice(0, TOAST_LIMIT)
6926
7005
  });
6927
7006
 
@@ -6931,9 +7010,9 @@ var reducer = function reducer(state, action) {
6931
7010
  clearFromRemoveQueue(action.toast.id);
6932
7011
  }
6933
7012
 
6934
- return _extends$t({}, state, {
7013
+ return _extends$v({}, state, {
6935
7014
  toasts: state.toasts.map(function (t) {
6936
- return t.id === action.toast.id ? _extends$t({}, t, action.toast) : t;
7015
+ return t.id === action.toast.id ? _extends$v({}, t, action.toast) : t;
6937
7016
  })
6938
7017
  });
6939
7018
 
@@ -6960,9 +7039,9 @@ var reducer = function reducer(state, action) {
6960
7039
  });
6961
7040
  }
6962
7041
 
6963
- return _extends$t({}, state, {
7042
+ return _extends$v({}, state, {
6964
7043
  toasts: state.toasts.map(function (t) {
6965
- return t.id === toastId || toastId === undefined ? _extends$t({}, t, {
7044
+ return t.id === toastId || toastId === undefined ? _extends$v({}, t, {
6966
7045
  visible: false
6967
7046
  }) : t;
6968
7047
  })
@@ -6970,28 +7049,28 @@ var reducer = function reducer(state, action) {
6970
7049
 
6971
7050
  case ActionType.REMOVE_TOAST:
6972
7051
  if (action.toastId === undefined) {
6973
- return _extends$t({}, state, {
7052
+ return _extends$v({}, state, {
6974
7053
  toasts: []
6975
7054
  });
6976
7055
  }
6977
7056
 
6978
- return _extends$t({}, state, {
7057
+ return _extends$v({}, state, {
6979
7058
  toasts: state.toasts.filter(function (t) {
6980
7059
  return t.id !== action.toastId;
6981
7060
  })
6982
7061
  });
6983
7062
 
6984
7063
  case ActionType.START_PAUSE:
6985
- return _extends$t({}, state, {
7064
+ return _extends$v({}, state, {
6986
7065
  pausedAt: action.time
6987
7066
  });
6988
7067
 
6989
7068
  case ActionType.END_PAUSE:
6990
7069
  var diff = action.time - (state.pausedAt || 0);
6991
- return _extends$t({}, state, {
7070
+ return _extends$v({}, state, {
6992
7071
  pausedAt: undefined,
6993
7072
  toasts: state.toasts.map(function (t) {
6994
- return _extends$t({}, t, {
7073
+ return _extends$v({}, t, {
6995
7074
  pauseDuration: t.pauseDuration + diff
6996
7075
  });
6997
7076
  })
@@ -7038,12 +7117,12 @@ var useStore = function useStore(toastOptions) {
7038
7117
  var mergedToasts = state.toasts.map(function (t) {
7039
7118
  var _toastOptions$t$type, _toastOptions, _toastOptions$t$type2;
7040
7119
 
7041
- return _extends$t({}, toastOptions, toastOptions[t.type], t, {
7120
+ return _extends$v({}, toastOptions, toastOptions[t.type], t, {
7042
7121
  duration: t.duration || ((_toastOptions$t$type = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type.duration) || ((_toastOptions = toastOptions) == null ? void 0 : _toastOptions.duration) || defaultTimeouts[t.type],
7043
- style: _extends$t({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7122
+ style: _extends$v({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7044
7123
  });
7045
7124
  });
7046
- return _extends$t({}, state, {
7125
+ return _extends$v({}, state, {
7047
7126
  toasts: mergedToasts
7048
7127
  });
7049
7128
  };
@@ -7053,7 +7132,7 @@ var createToast = function createToast(message, type, opts) {
7053
7132
  type = 'blank';
7054
7133
  }
7055
7134
 
7056
- return _extends$t({
7135
+ return _extends$v({
7057
7136
  createdAt: Date.now(),
7058
7137
  visible: true,
7059
7138
  type: type,
@@ -7103,14 +7182,14 @@ toast.remove = function (toastId) {
7103
7182
  };
7104
7183
 
7105
7184
  toast.promise = function (promise, msgs, opts) {
7106
- var id = toast.loading(msgs.loading, _extends$t({}, opts, opts == null ? void 0 : opts.loading));
7185
+ var id = toast.loading(msgs.loading, _extends$v({}, opts, opts == null ? void 0 : opts.loading));
7107
7186
  promise.then(function (p) {
7108
- toast.success(resolveValue(msgs.success, p), _extends$t({
7187
+ toast.success(resolveValue(msgs.success, p), _extends$v({
7109
7188
  id: id
7110
7189
  }, opts, opts == null ? void 0 : opts.success));
7111
7190
  return p;
7112
7191
  })["catch"](function (e) {
7113
- toast.error(resolveValue(msgs.error, e), _extends$t({
7192
+ toast.error(resolveValue(msgs.error, e), _extends$v({
7114
7193
  id: id
7115
7194
  }, opts, opts == null ? void 0 : opts.error));
7116
7195
  });
@@ -7449,7 +7528,7 @@ var ToastBar = /*#__PURE__*/memo(function (_ref2) {
7449
7528
  var message = createElement(Message, Object.assign({}, toast.ariaProps), resolveValue(toast.message, toast));
7450
7529
  return createElement(ToastBarBase, {
7451
7530
  className: toast.className,
7452
- style: _extends$t({}, animationStyle, style, toast.style)
7531
+ style: _extends$v({}, animationStyle, style, toast.style)
7453
7532
  }, typeof children === 'function' ? children({
7454
7533
  icon: icon,
7455
7534
  message: message
@@ -7479,7 +7558,7 @@ var getPositionStyle = function getPositionStyle(position, offset) {
7479
7558
  } : position.includes('right') ? {
7480
7559
  justifyContent: 'flex-end'
7481
7560
  } : {};
7482
- return _extends$t({
7561
+ return _extends$v({
7483
7562
  left: 0,
7484
7563
  right: 0,
7485
7564
  display: 'flex',
@@ -7506,7 +7585,7 @@ var Toaster = function Toaster(_ref) {
7506
7585
  handlers = _useToaster.handlers;
7507
7586
 
7508
7587
  return createElement("div", {
7509
- style: _extends$t({
7588
+ style: _extends$v({
7510
7589
  position: 'fixed',
7511
7590
  zIndex: 9999,
7512
7591
  top: DEFAULT_OFFSET,
@@ -7541,82 +7620,82 @@ var Toaster = function Toaster(_ref) {
7541
7620
  }));
7542
7621
  };
7543
7622
 
7544
- var _path$q;
7623
+ var _path$s;
7545
7624
 
7546
- function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
7625
+ function _extends$u() { _extends$u = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$u.apply(this, arguments); }
7547
7626
 
7548
7627
  function SvgCheckSolid(props) {
7549
- return /*#__PURE__*/React.createElement("svg", _extends$s({
7628
+ return /*#__PURE__*/React.createElement("svg", _extends$u({
7550
7629
  xmlns: "http://www.w3.org/2000/svg",
7551
7630
  className: "h-5 w-5",
7552
7631
  viewBox: "0 0 20 20",
7553
7632
  fill: "currentColor"
7554
- }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
7633
+ }, props), _path$s || (_path$s = /*#__PURE__*/React.createElement("path", {
7555
7634
  fillRule: "evenodd",
7556
7635
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
7557
7636
  clipRule: "evenodd"
7558
7637
  })));
7559
7638
  }
7560
7639
 
7561
- var _path$p;
7640
+ var _path$r;
7562
7641
 
7563
- function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
7642
+ function _extends$t() { _extends$t = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
7564
7643
 
7565
7644
  function SvgXIcon(props) {
7566
- return /*#__PURE__*/React.createElement("svg", _extends$r({
7645
+ return /*#__PURE__*/React.createElement("svg", _extends$t({
7567
7646
  xmlns: "http://www.w3.org/2000/svg",
7568
7647
  viewBox: "0 0 20 20",
7569
7648
  fill: "currentColor"
7570
- }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
7649
+ }, props), _path$r || (_path$r = /*#__PURE__*/React.createElement("path", {
7571
7650
  fill: "evenodd",
7572
7651
  d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
7573
7652
  clipRule: "evenodd"
7574
7653
  })));
7575
7654
  }
7576
7655
 
7577
- var _path$o;
7656
+ var _path$q;
7578
7657
 
7579
- function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
7658
+ function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
7580
7659
 
7581
7660
  function SvgXIconSolid(props) {
7582
- return /*#__PURE__*/React.createElement("svg", _extends$q({
7661
+ return /*#__PURE__*/React.createElement("svg", _extends$s({
7583
7662
  className: "plc-w-4 plc-h-4",
7584
7663
  fill: "currentColor",
7585
7664
  xmlns: "http://www.w3.org/2000/svg",
7586
7665
  viewBox: "0 0 100 100"
7587
- }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
7666
+ }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
7588
7667
  d: "M94.842 48.408c0 24.852-20.148 44.999-45.002 44.999-24.851 0-44.997-20.146-44.997-44.999 0-24.854 20.146-45 44.997-45 24.853 0 45.002 20.146 45.002 45zM71.073 64.841L54.73 48.497l16.344-16.344-4.979-4.979-16.343 16.345-16.343-16.344-4.799 4.799 16.344 16.344L28.61 64.661l4.979 4.978 16.344-16.344 16.343 16.344 4.797-4.798z"
7589
7668
  })));
7590
7669
  }
7591
7670
 
7592
- var _path$n;
7671
+ var _path$p;
7593
7672
 
7594
- function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
7673
+ function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
7595
7674
 
7596
7675
  function SvgExclamation(props) {
7597
- return /*#__PURE__*/React.createElement("svg", _extends$p({
7676
+ return /*#__PURE__*/React.createElement("svg", _extends$r({
7598
7677
  className: "plc-w-4 plc-h-4 plc-mr-1",
7599
7678
  xmlns: "http://www.w3.org/2000/svg",
7600
7679
  viewBox: "0 0 20 20",
7601
7680
  fill: "currentColor"
7602
- }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
7681
+ }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
7603
7682
  fillRule: "evenodd",
7604
7683
  d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
7605
7684
  clipRule: "evenodd"
7606
7685
  })));
7607
7686
  }
7608
7687
 
7609
- var _path$m, _path2$3;
7688
+ var _path$o, _path2$3;
7610
7689
 
7611
- function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
7690
+ function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
7612
7691
 
7613
7692
  function SvgSpinner(props) {
7614
- return /*#__PURE__*/React.createElement("svg", _extends$o({
7693
+ return /*#__PURE__*/React.createElement("svg", _extends$q({
7615
7694
  className: "plc-animate-spin",
7616
7695
  viewBox: "0 0 24 24",
7617
7696
  fill: "currentColor",
7618
7697
  xmlns: "http://www.w3.org/2000/svg"
7619
- }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
7698
+ }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
7620
7699
  opacity: 0.2,
7621
7700
  fill: "evenodd",
7622
7701
  clipRule: "evenodd",
@@ -7842,6 +7921,16 @@ const init$1 = () => {
7842
7921
  }
7843
7922
  }
7844
7923
 
7924
+ const pelcroUpdateNewslettersButtons = document.getElementsByClassName("pelcro-update-newsletters-button");
7925
+
7926
+ if (pelcroUpdateNewslettersButtons.length !== 0) {
7927
+ for (let i = 0; i < pelcroUpdateNewslettersButtons.length; i++) {
7928
+ pelcroUpdateNewslettersButtons[i].addEventListener("click", () => {
7929
+ switchView("newsletter-update");
7930
+ });
7931
+ }
7932
+ }
7933
+
7845
7934
  const pelcroCartButtonsByClass = document.getElementsByClassName("pelcro-cart-button");
7846
7935
 
7847
7936
  if (pelcroCartButtonsByClass.length !== 0) {
@@ -8057,87 +8146,71 @@ function Link({
8057
8146
 
8058
8147
  const init = () => {
8059
8148
  const {
8060
- whenSiteReady,
8061
- view,
8062
- resetView,
8063
8149
  switchView,
8064
8150
  set
8065
8151
  } = usePelcro.getStore();
8066
- whenSiteReady(() => {
8067
- const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8152
+ const entitlementsProtectedElements = document.querySelectorAll("[data-pelcro-entitlements]");
8068
8153
 
8069
- if (entitlementsProtectedElements.length === 0) {
8070
- return;
8071
- }
8154
+ if (entitlementsProtectedElements.length === 0) {
8155
+ return false;
8156
+ }
8072
8157
 
8073
- if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8074
- console.error("not all elements protected by entitlements have the same entitlements, all elements protected by entitlements must have the exact same data-pelcro-entitlements attribute value");
8075
- return;
8076
- }
8158
+ if (!allElemsHaveSameEntitlements(entitlementsProtectedElements)) {
8159
+ console.error("not all elements protected by entitlements have the same entitlements, all elements protected by entitlements must have the exact same data-pelcro-entitlements attribute value");
8160
+ return false;
8161
+ }
8077
8162
 
8078
- entitlementsProtectedElements.forEach(elem => {
8079
- const entitlements = getEntitlementsFromElem(elem);
8163
+ for (const elem of entitlementsProtectedElements) {
8164
+ const entitlements = getEntitlementsFromElem(elem);
8080
8165
 
8081
- if (entitlements.length === 0) {
8082
- console.error("invalid data-pelcro-entitlements attribute value", elem);
8083
- return;
8084
- }
8166
+ if (entitlements.length === 0) {
8167
+ console.error("invalid data-pelcro-entitlements attribute value", elem);
8168
+ return false;
8169
+ }
8085
8170
 
8086
- if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8087
- console.warn("user can't subscribe to any plan that has any of the entitlement(s) needed, this is usually unintentional, make sure that the entitlements are spelled correctly, entitlements are case sensitive. make sure that your plans are configured in a way that allows users from all supported countries, using all supported currencies, to have access to your content by subscribing to certain plans that provide the needed entitlement(s)");
8088
- }
8171
+ if (window.Pelcro.product.getByEntitlements(entitlements).length === 0) {
8172
+ console.warn("user can't subscribe to any plan that has any of the entitlement(s) needed, this is usually unintentional, make sure that the entitlements are spelled correctly, entitlements are case sensitive. make sure that your plans are configured in a way that allows users from all supported countries, using all supported currencies, to have access to your content by subscribing to certain plans that provide the needed entitlement(s)");
8173
+ }
8089
8174
 
8090
- if (shouldBlurContent(entitlements)) {
8091
- // remove all event listeners from the elem by replacing it with a deep clone of itself
8092
- const elemDeepClone = elem.cloneNode(true);
8093
- elem.replaceWith(elemDeepClone);
8094
- disableKeyboardInteractions(elemDeepClone);
8095
- elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8096
- unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8097
- /*
8098
- showing both the meter and the entitlements notification doesn't make sense from
8099
- a product prespective + they would take half the screen on mobile devies, so we're
8100
- hiding the meter, and showing the entitlements notification only.
8101
- */
8175
+ if (shouldBlurContent(entitlements)) {
8176
+ // remove all event listeners from the elem by replacing it with a deep clone of itself
8177
+ const elemDeepClone = elem.cloneNode(true);
8178
+ elem.replaceWith(elemDeepClone);
8179
+ disableKeyboardInteractions(elemDeepClone);
8180
+ elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
8181
+ unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
8182
+ const NOTIFICATION_ID = "entitlement";
8183
+ notify( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
8184
+ i18nKey: "messages:entitlement"
8185
+ }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default.createElement(Link, {
8186
+ onClick: () => {
8187
+ const productId = Number(elem.dataset.productId);
8188
+ const planId = Number(elem.dataset.planId);
8189
+ const selectedProduct = window.Pelcro.product.getById(productId);
8190
+ const selectedPlan = window.Pelcro.plan.getById(planId);
8191
+ const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8102
8192
 
8103
- if (view === "meter") {
8104
- resetView();
8105
- }
8193
+ if (hasValidProductAndPlan) {
8194
+ set({
8195
+ product: selectedProduct,
8196
+ plan: selectedPlan
8197
+ });
8198
+ }
8106
8199
 
8107
- const NOTIFICATION_ID = "entitlement";
8108
- notify( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
8109
- i18nKey: "messages:entitlement"
8110
- }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default.createElement(Link, {
8111
- onClick: () => {
8112
- const productId = Number(elem.dataset.productId);
8113
- const planId = Number(elem.dataset.planId);
8114
- const selectedProduct = window.Pelcro.product.getById(productId);
8115
- const selectedPlan = window.Pelcro.plan.getById(planId);
8116
- const hasValidProductAndPlan = Boolean(selectedProduct && selectedPlan);
8117
-
8118
- if (hasValidProductAndPlan) {
8119
- set({
8120
- product: selectedProduct,
8121
- plan: selectedPlan
8122
- });
8123
- }
8200
+ notify.dismiss(NOTIFICATION_ID);
8201
+ switchView("_plan-select-entitlements");
8202
+ }
8203
+ }, "Subscribe"), "now to get full page access.")), {
8204
+ className: "pelcro-notification-entitlement",
8205
+ position: "bottom-right",
8206
+ duration: Infinity,
8207
+ id: NOTIFICATION_ID
8208
+ });
8209
+ }
8210
+ }
8124
8211
 
8125
- notify.dismiss(NOTIFICATION_ID);
8126
- switchView("_plan-select-entitlements");
8127
- }
8128
- }, "Subscribe"), "now to get full page access.")), {
8129
- className: "pelcro-notification-entitlement",
8130
- position: "bottom-right",
8131
- duration: Infinity,
8132
- id: NOTIFICATION_ID
8133
- });
8134
- }
8135
- });
8136
- });
8212
+ return true;
8137
8213
  };
8138
- /**
8139
- *
8140
- */
8141
8214
 
8142
8215
  function allElemsHaveSameEntitlements(elems) {
8143
8216
  const entitlements = getEntitlementsFromElem(elems[0]);
@@ -8147,10 +8220,6 @@ function allElemsHaveSameEntitlements(elems) {
8147
8220
  return entitlements.every(ent => elemEntitlements.includes(ent));
8148
8221
  });
8149
8222
  }
8150
- /**
8151
- *
8152
- */
8153
-
8154
8223
 
8155
8224
  function disableKeyboardInteractions(elem) {
8156
8225
  elem.addEventListener("keydown", event => {
@@ -8163,10 +8232,6 @@ function disableKeyboardInteractions(elem) {
8163
8232
  }
8164
8233
  }, true);
8165
8234
  }
8166
- /**
8167
- *
8168
- */
8169
-
8170
8235
 
8171
8236
  function unblurElemWhenUserSubscribes(elem, entitlements) {
8172
8237
  document.addEventListener("PelcroSubscriptionCreate", event => {
@@ -8174,11 +8239,11 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8174
8239
  isGift
8175
8240
  } = usePelcro.getStore();
8176
8241
  if (isGift) return;
8177
- const latestSub = event.detail.data.subscriptions[0];
8242
+ const latestSub = event.detail.data.subscriptions[event.detail.data.subscriptions.length - 1];
8178
8243
  const shouldUnblurContent = entitlements.some(ent => {
8179
- var _latestSub$plan$entit, _latestSub$plan$entit2;
8244
+ var _latestSub$plan$entit, _latestSub$plan, _latestSub$plan$entit2;
8180
8245
 
8181
- return (_latestSub$plan$entit = (_latestSub$plan$entit2 = latestSub.plan.entitlements) === null || _latestSub$plan$entit2 === void 0 ? void 0 : _latestSub$plan$entit2.includes(ent)) !== null && _latestSub$plan$entit !== void 0 ? _latestSub$plan$entit : false;
8246
+ return (_latestSub$plan$entit = latestSub === null || latestSub === void 0 ? void 0 : (_latestSub$plan = latestSub.plan) === null || _latestSub$plan === void 0 ? void 0 : (_latestSub$plan$entit2 = _latestSub$plan.entitlements) === null || _latestSub$plan$entit2 === void 0 ? void 0 : _latestSub$plan$entit2.includes(ent)) !== null && _latestSub$plan$entit !== void 0 ? _latestSub$plan$entit : false;
8182
8247
  });
8183
8248
 
8184
8249
  if (shouldUnblurContent) {
@@ -8186,15 +8251,180 @@ function unblurElemWhenUserSubscribes(elem, entitlements) {
8186
8251
  }
8187
8252
  });
8188
8253
  }
8189
- /**
8190
- *
8191
- */
8192
-
8193
8254
 
8194
8255
  function shouldBlurContent(entitlements) {
8195
8256
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
8196
8257
  }
8197
8258
 
8259
+ var pure$1 = createCommonjsModule(function (module, exports) {
8260
+
8261
+ Object.defineProperty(exports, '__esModule', { value: true });
8262
+
8263
+ function _typeof(obj) {
8264
+ "@babel/helpers - typeof";
8265
+
8266
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
8267
+ _typeof = function (obj) {
8268
+ return typeof obj;
8269
+ };
8270
+ } else {
8271
+ _typeof = function (obj) {
8272
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8273
+ };
8274
+ }
8275
+
8276
+ return _typeof(obj);
8277
+ }
8278
+
8279
+ var V3_URL = 'https://js.stripe.com/v3';
8280
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
8281
+ var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
8282
+ var findScript = function findScript() {
8283
+ var scripts = document.querySelectorAll("script[src^=\"".concat(V3_URL, "\"]"));
8284
+
8285
+ for (var i = 0; i < scripts.length; i++) {
8286
+ var script = scripts[i];
8287
+
8288
+ if (!V3_URL_REGEX.test(script.src)) {
8289
+ continue;
8290
+ }
8291
+
8292
+ return script;
8293
+ }
8294
+
8295
+ return null;
8296
+ };
8297
+
8298
+ var injectScript = function injectScript(params) {
8299
+ var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
8300
+ var script = document.createElement('script');
8301
+ script.src = "".concat(V3_URL).concat(queryString);
8302
+ var headOrBody = document.head || document.body;
8303
+
8304
+ if (!headOrBody) {
8305
+ throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
8306
+ }
8307
+
8308
+ headOrBody.appendChild(script);
8309
+ return script;
8310
+ };
8311
+
8312
+ var registerWrapper = function registerWrapper(stripe, startTime) {
8313
+ if (!stripe || !stripe._registerWrapper) {
8314
+ return;
8315
+ }
8316
+
8317
+ stripe._registerWrapper({
8318
+ name: 'stripe-js',
8319
+ version: "1.21.1",
8320
+ startTime: startTime
8321
+ });
8322
+ };
8323
+
8324
+ var stripePromise = null;
8325
+ var loadScript = function loadScript(params) {
8326
+ // Ensure that we only attempt to load Stripe.js at most once
8327
+ if (stripePromise !== null) {
8328
+ return stripePromise;
8329
+ }
8330
+
8331
+ stripePromise = new Promise(function (resolve, reject) {
8332
+ if (typeof window === 'undefined') {
8333
+ // Resolve to null when imported server side. This makes the module
8334
+ // safe to import in an isomorphic code base.
8335
+ resolve(null);
8336
+ return;
8337
+ }
8338
+
8339
+ if (window.Stripe && params) {
8340
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8341
+ }
8342
+
8343
+ if (window.Stripe) {
8344
+ resolve(window.Stripe);
8345
+ return;
8346
+ }
8347
+
8348
+ try {
8349
+ var script = findScript();
8350
+
8351
+ if (script && params) {
8352
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8353
+ } else if (!script) {
8354
+ script = injectScript(params);
8355
+ }
8356
+
8357
+ script.addEventListener('load', function () {
8358
+ if (window.Stripe) {
8359
+ resolve(window.Stripe);
8360
+ } else {
8361
+ reject(new Error('Stripe.js not available'));
8362
+ }
8363
+ });
8364
+ script.addEventListener('error', function () {
8365
+ reject(new Error('Failed to load Stripe.js'));
8366
+ });
8367
+ } catch (error) {
8368
+ reject(error);
8369
+ return;
8370
+ }
8371
+ });
8372
+ return stripePromise;
8373
+ };
8374
+ var initStripe = function initStripe(maybeStripe, args, startTime) {
8375
+ if (maybeStripe === null) {
8376
+ return null;
8377
+ }
8378
+
8379
+ var stripe = maybeStripe.apply(undefined, args);
8380
+ registerWrapper(stripe, startTime);
8381
+ return stripe;
8382
+ };
8383
+ var validateLoadParams = function validateLoadParams(params) {
8384
+ var errorMessage = "invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(params), "\n");
8385
+
8386
+ if (params === null || _typeof(params) !== 'object') {
8387
+ throw new Error(errorMessage);
8388
+ }
8389
+
8390
+ if (Object.keys(params).length === 1 && typeof params.advancedFraudSignals === 'boolean') {
8391
+ return params;
8392
+ }
8393
+
8394
+ throw new Error(errorMessage);
8395
+ };
8396
+
8397
+ var loadParams;
8398
+ var loadStripeCalled = false;
8399
+ var loadStripe = function loadStripe() {
8400
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8401
+ args[_key] = arguments[_key];
8402
+ }
8403
+
8404
+ loadStripeCalled = true;
8405
+ var startTime = Date.now();
8406
+ return loadScript(loadParams).then(function (maybeStripe) {
8407
+ return initStripe(maybeStripe, args, startTime);
8408
+ });
8409
+ };
8410
+
8411
+ loadStripe.setLoadParameters = function (params) {
8412
+ if (loadStripeCalled) {
8413
+ throw new Error('You cannot change load parameters after calling loadStripe');
8414
+ }
8415
+
8416
+ loadParams = validateLoadParams(params);
8417
+ };
8418
+
8419
+ exports.loadStripe = loadStripe;
8420
+ });
8421
+
8422
+ unwrapExports(pure$1);
8423
+ pure$1.loadStripe;
8424
+
8425
+ var pure = pure$1;
8426
+ var pure_1 = pure.loadStripe;
8427
+
8198
8428
  /**
8199
8429
  * @typedef {Object} OptionsType
8200
8430
  * @property {boolean} loadPaymentSDKs
@@ -8220,6 +8450,7 @@ const optionsController = options => {
8220
8450
  enableURLTriggers: initViewFromURL,
8221
8451
  enableTheme: applyPelcroTheme,
8222
8452
  enablePaywalls: initPaywalls,
8453
+ loadSecuritySDK: initSecuritySdk,
8223
8454
  enableGoogleAnalytics: initGATracking
8224
8455
  }; // Only execute enabled options
8225
8456
 
@@ -8236,7 +8467,9 @@ const initPaywalls = () => {
8236
8467
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
8237
8468
 
8238
8469
  if (((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.settings) === "subscription") {
8239
- // Skip if article is not restricted
8470
+ // blur entitlements based content
8471
+ const didBlurContent = init(); // Skip paywall if article is not restricted
8472
+
8240
8473
  if (isValidViewFromURL(viewFromURL) || !paywallMethods.isArticleRestricted()) {
8241
8474
  return;
8242
8475
  }
@@ -8246,9 +8479,14 @@ const initPaywalls = () => {
8246
8479
  } = usePelcro.getStore();
8247
8480
 
8248
8481
  if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
8249
- switchView("meter"); // initializing content entitlement here because it interacts with meter
8250
-
8251
- init();
8482
+ /*
8483
+ showing both the meter and the entitlements notification doesn't make sense from
8484
+ a product prespective + they would take half the screen on mobile devies, so we're
8485
+ not showing the meter, and only showing the entitlements notification.
8486
+ */
8487
+ if (!didBlurContent) {
8488
+ switchView("meter");
8489
+ }
8252
8490
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
8253
8491
  switchView("newsletter");
8254
8492
  } else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
@@ -8257,8 +8495,15 @@ const initPaywalls = () => {
8257
8495
  }
8258
8496
  };
8259
8497
  const loadPaymentSDKs = () => {
8260
- // Load stripe's SDK
8261
- window.Pelcro.helpers.loadSDK("https://js.stripe.com/v3/", "pelcro-sdk-stripe-id"); // Load PayPal SDK's
8498
+ // Lazy load stripe's SDK
8499
+ const {
8500
+ whenUserReady
8501
+ } = usePelcro.getStore();
8502
+ whenUserReady(() => {
8503
+ if (!window.Stripe) {
8504
+ pure_1(window.Pelcro.environment.stripe);
8505
+ }
8506
+ }); // Load PayPal SDK's
8262
8507
 
8263
8508
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
8264
8509
 
@@ -8267,6 +8512,18 @@ const loadPaymentSDKs = () => {
8267
8512
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8268
8513
  }
8269
8514
  };
8515
+ const initSecuritySdk = () => {
8516
+ const {
8517
+ whenSiteReady
8518
+ } = usePelcro.getStore();
8519
+ whenSiteReady(() => {
8520
+ var _window$Pelcro$site$r2;
8521
+
8522
+ const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
8523
+ if (!securityKey) return;
8524
+ window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
8525
+ });
8526
+ };
8270
8527
  const initGATracking = () => {
8271
8528
  var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
8272
8529
 
@@ -8353,9 +8610,9 @@ const applyPelcroTheme = () => {
8353
8610
  };
8354
8611
 
8355
8612
  whenSiteReady(() => {
8356
- var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
8613
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
8357
8614
 
8358
- const primaryColorHex = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : (_window$Pelcro$site$r3 = _window$Pelcro$site$r2.design_settings) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.primary_color;
8615
+ const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
8359
8616
 
8360
8617
  if (!primaryColorHex) {
8361
8618
  return;
@@ -8554,6 +8811,7 @@ const defaultOptions = {
8554
8811
  enableURLTriggers: true,
8555
8812
  enableTheme: true,
8556
8813
  enablePaywalls: true,
8814
+ loadSecuritySDK: true,
8557
8815
  enableGoogleAnalytics: false
8558
8816
  };
8559
8817
  const PelcroModalController = ({
@@ -8852,6 +9110,7 @@ const GET_STATES_SUCCESS = "GET_STATES_SUCCESS";
8852
9110
  const GET_STATES_FETCH = "GET_STATES_FETCH";
8853
9111
  const HANDLE_SUBMIT = "HANDLE_SUBMIT";
8854
9112
  const SET_UPDATED_PRICE = "SET_UPDATED_PRICE";
9113
+ const SET_TAX_AMOUNT = "SET_TAX_AMOUNT";
8855
9114
  const SET_CAN_MAKE_PAYMENT = "SET_CAN_MAKE_PAYMENT";
8856
9115
  const SET_PAYMENT_REQUEST = "SET_PAYMENT_REQUEST";
8857
9116
  const INIT_CONTAINER = "INIT_CONTAINER";
@@ -8880,6 +9139,9 @@ const SET_IMAGE_SRC = "SET_IMAGE_SRC";
8880
9139
  const PASSWORD_CHANGE_SUCCESS = "PASSWORD_CHANGE_SUCCESS";
8881
9140
  const SELECT_PAYMENT_METHOD = "SELECT_PAYMENT_METHOD";
8882
9141
  const LOAD_PAYMENT_METHODS = "LOAD_PAYMENT_METHODS";
9142
+ const GET_NEWSLETTERS_FETCH = "GET_NEWSLETTERS_FETCH";
9143
+ const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
9144
+ const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
8883
9145
 
8884
9146
  /**
8885
9147
  * Extracts error message from the response error object
@@ -8941,7 +9203,7 @@ const debounce = (func, waitTime) => {
8941
9203
  };
8942
9204
  };
8943
9205
 
8944
- const initialState$e = {
9206
+ const initialState$f = {
8945
9207
  email: "",
8946
9208
  password: "",
8947
9209
  emailError: null,
@@ -8952,10 +9214,10 @@ const initialState$e = {
8952
9214
  content: ""
8953
9215
  }
8954
9216
  };
8955
- const store$e = /*#__PURE__*/createContext(initialState$e);
9217
+ const store$f = /*#__PURE__*/createContext(initialState$f);
8956
9218
  const {
8957
- Provider: Provider$e
8958
- } = store$e;
9219
+ Provider: Provider$f
9220
+ } = store$f;
8959
9221
 
8960
9222
  const LoginContainer = ({
8961
9223
  style,
@@ -9062,7 +9324,7 @@ const LoginContainer = ({
9062
9324
  });
9063
9325
 
9064
9326
  case RESET_LOGIN_FORM:
9065
- return initialState$e;
9327
+ return initialState$f;
9066
9328
 
9067
9329
  case DISABLE_LOGIN_BUTTON:
9068
9330
  return lib_7({ ...state,
@@ -9080,12 +9342,12 @@ const LoginContainer = ({
9080
9342
  default:
9081
9343
  return state;
9082
9344
  }
9083
- }, initialState$e);
9345
+ }, initialState$f);
9084
9346
  return /*#__PURE__*/React__default.createElement("div", {
9085
9347
  style: { ...style
9086
9348
  },
9087
9349
  className: `pelcro-container pelcro-login-container ${className}`
9088
- }, /*#__PURE__*/React__default.createElement(Provider$e, {
9350
+ }, /*#__PURE__*/React__default.createElement(Provider$f, {
9089
9351
  value: {
9090
9352
  state,
9091
9353
  dispatch
@@ -9093,12 +9355,12 @@ const LoginContainer = ({
9093
9355
  }, children.length ? children.map((child, i) => {
9094
9356
  if (child) {
9095
9357
  return /*#__PURE__*/React__default.cloneElement(child, {
9096
- store: store$e,
9358
+ store: store$f,
9097
9359
  key: i
9098
9360
  });
9099
9361
  }
9100
9362
  }) : /*#__PURE__*/React__default.cloneElement(children, {
9101
- store: store$e
9363
+ store: store$f
9102
9364
  })));
9103
9365
  };
9104
9366
 
@@ -9343,7 +9605,7 @@ const LoginButton = ({
9343
9605
  buttonDisabled
9344
9606
  },
9345
9607
  dispatch
9346
- } = useContext(store$e);
9608
+ } = useContext(store$f);
9347
9609
  const {
9348
9610
  t
9349
9611
  } = useTranslation("login");
@@ -9364,23 +9626,23 @@ const LoginButton = ({
9364
9626
  };
9365
9627
 
9366
9628
  const LoginEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
9367
- store: store$e
9629
+ store: store$f
9368
9630
  }, props));
9369
9631
 
9370
9632
  const LoginPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
9371
- store: store$e
9633
+ store: store$f
9372
9634
  }, props));
9373
9635
 
9374
- var _path$l;
9636
+ var _path$n;
9375
9637
 
9376
- function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
9638
+ function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
9377
9639
 
9378
9640
  function SvgCheck(props) {
9379
- return /*#__PURE__*/React.createElement("svg", _extends$n({
9641
+ return /*#__PURE__*/React.createElement("svg", _extends$p({
9380
9642
  xmlns: "http://www.w3.org/2000/svg",
9381
9643
  fill: "currentColor",
9382
9644
  viewBox: "0 0 20 20"
9383
- }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
9645
+ }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
9384
9646
  fillRule: "evenodd",
9385
9647
  d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
9386
9648
  clipRule: "evenodd"
@@ -9445,7 +9707,7 @@ var facebookLoginRenderProps = createCommonjsModule(function (module, exports) {
9445
9707
  var FacebookLogin = unwrapExports(facebookLoginRenderProps);
9446
9708
  facebookLoginRenderProps.FacebookLogin;
9447
9709
 
9448
- const initialState$d = {
9710
+ const initialState$e = {
9449
9711
  email: "",
9450
9712
  password: "",
9451
9713
  emailError: null,
@@ -9462,10 +9724,10 @@ const initialState$d = {
9462
9724
  content: ""
9463
9725
  }
9464
9726
  };
9465
- const store$d = /*#__PURE__*/createContext(initialState$d);
9727
+ const store$e = /*#__PURE__*/createContext(initialState$e);
9466
9728
  const {
9467
- Provider: Provider$d
9468
- } = store$d;
9729
+ Provider: Provider$e
9730
+ } = store$e;
9469
9731
 
9470
9732
  const RegisterContainer = ({
9471
9733
  style,
@@ -9490,35 +9752,53 @@ const RegisterContainer = ({
9490
9752
  jobTitle,
9491
9753
  selectFields
9492
9754
  } = filteredData;
9493
- window.Pelcro.user.register({
9494
- email,
9495
- password,
9496
- first_name: firstName,
9497
- last_name: lastName,
9498
- metadata: {
9499
- organization,
9500
- jobTitle,
9501
- ...selectFields
9502
- }
9503
- }, (err, res) => {
9504
- dispatch({
9505
- type: DISABLE_REGISTRATION_BUTTON,
9506
- payload: false
9755
+
9756
+ if (!hasSecurityTokenEnabled()) {
9757
+ sendRegisterRequest();
9758
+ return;
9759
+ }
9760
+
9761
+ window.grecaptcha.enterprise.ready(async () => {
9762
+ var _window$Pelcro$site$r;
9763
+
9764
+ const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
9765
+ action: "register"
9507
9766
  });
9767
+ sendRegisterRequest(token);
9768
+ });
9508
9769
 
9509
- if (err) {
9770
+ function sendRegisterRequest(securityToken) {
9771
+ window.Pelcro.user.register({
9772
+ email,
9773
+ password,
9774
+ first_name: firstName,
9775
+ last_name: lastName,
9776
+ security_token: securityToken,
9777
+ metadata: {
9778
+ organization,
9779
+ jobTitle,
9780
+ ...selectFields
9781
+ }
9782
+ }, (err, res) => {
9510
9783
  dispatch({
9511
- type: SHOW_ALERT,
9512
- payload: {
9513
- type: "error",
9514
- content: getErrorMessages(err)
9515
- }
9784
+ type: DISABLE_REGISTRATION_BUTTON,
9785
+ payload: false
9516
9786
  });
9517
- onFailure(err);
9518
- } else {
9519
- onSuccess(res);
9520
- }
9521
- });
9787
+
9788
+ if (err) {
9789
+ dispatch({
9790
+ type: SHOW_ALERT,
9791
+ payload: {
9792
+ type: "error",
9793
+ content: getErrorMessages(err)
9794
+ }
9795
+ });
9796
+ onFailure(err);
9797
+ } else {
9798
+ onSuccess(res);
9799
+ }
9800
+ });
9801
+ }
9522
9802
  };
9523
9803
 
9524
9804
  const handleSocialLogin = ({
@@ -9630,7 +9910,7 @@ const RegisterContainer = ({
9630
9910
  });
9631
9911
 
9632
9912
  case RESET_LOGIN_FORM:
9633
- return initialState$d;
9913
+ return initialState$e;
9634
9914
 
9635
9915
  case DISABLE_REGISTRATION_BUTTON:
9636
9916
  return lib_7({ ...state,
@@ -9648,12 +9928,12 @@ const RegisterContainer = ({
9648
9928
  default:
9649
9929
  return state;
9650
9930
  }
9651
- }, initialState$d);
9931
+ }, initialState$e);
9652
9932
  return /*#__PURE__*/React__default.createElement("div", {
9653
9933
  style: { ...style
9654
9934
  },
9655
9935
  className: `pelcro-container pelcro-register-container ${className}`
9656
- }, /*#__PURE__*/React__default.createElement(Provider$d, {
9936
+ }, /*#__PURE__*/React__default.createElement(Provider$e, {
9657
9937
  value: {
9658
9938
  state,
9659
9939
  dispatch
@@ -9661,24 +9941,33 @@ const RegisterContainer = ({
9661
9941
  }, children.length ? children.map((child, i) => {
9662
9942
  if (child) {
9663
9943
  return /*#__PURE__*/React__default.cloneElement(child, {
9664
- store: store$d,
9944
+ store: store$e,
9665
9945
  key: i
9666
9946
  });
9667
9947
  }
9668
9948
  }) : /*#__PURE__*/React__default.cloneElement(children, {
9669
- store: store$d
9949
+ store: store$e
9670
9950
  })));
9671
9951
  };
9952
+ /**
9953
+ * Checks if the current site has security token enabled
9954
+ * @return {boolean}
9955
+ */
9956
+
9957
+ function hasSecurityTokenEnabled() {
9958
+ const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
9959
+ return hasSecuritySdkLoaded;
9960
+ }
9672
9961
 
9673
- var _path$k;
9962
+ var _path$m;
9674
9963
 
9675
- function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
9964
+ function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
9676
9965
 
9677
9966
  function SvgFacebookLogo(props) {
9678
- return /*#__PURE__*/React.createElement("svg", _extends$m({
9967
+ return /*#__PURE__*/React.createElement("svg", _extends$o({
9679
9968
  xmlns: "http://www.w3.org/2000/svg",
9680
9969
  viewBox: "88.428 12.828 107.543 207.085"
9681
- }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
9970
+ }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
9682
9971
  d: "M158.232 219.912v-94.461h31.707l4.747-36.813h-36.454V65.134c0-10.658 2.96-17.922 18.245-17.922l19.494-.009V14.278c-3.373-.447-14.944-1.449-28.406-1.449-28.106 0-47.348 17.155-47.348 48.661v27.149H88.428v36.813h31.788v94.461l38.016-.001z",
9683
9972
  fill: "#3c5a9a"
9684
9973
  })));
@@ -9690,15 +9979,15 @@ const FacebookLoginButton = ({
9690
9979
  labelClassName = "",
9691
9980
  iconClassName = ""
9692
9981
  }) => {
9693
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9982
+ var _window$Pelcro$site$r;
9694
9983
 
9695
9984
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
9696
9985
  const {
9697
9986
  dispatch: loginDispatch
9698
- } = useContext(store$e);
9987
+ } = useContext(store$f);
9699
9988
  const {
9700
9989
  dispatch: registerDispatch
9701
- } = useContext(store$d);
9990
+ } = useContext(store$e);
9702
9991
 
9703
9992
  const onSuccess = facebookUser => {
9704
9993
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
@@ -9729,7 +10018,7 @@ const FacebookLoginButton = ({
9729
10018
 
9730
10019
  return facebookLoginEnabled ? /*#__PURE__*/React__default.createElement(FacebookLogin, {
9731
10020
  appId: window.Pelcro.site.read().facebook_app_id,
9732
- language: (_window$Pelcro$site$r2 = window.Pelcro.site.read().default_locale) !== null && _window$Pelcro$site$r2 !== void 0 ? _window$Pelcro$site$r2 : "en_US",
10021
+ language: getPageOrDefaultLanguage(),
9733
10022
  fields: "first_name,last_name,email,picture",
9734
10023
  callback: onSuccess,
9735
10024
  onFailure: onFailure,
@@ -9751,15 +10040,15 @@ var googleLogin = createCommonjsModule(function (module, exports) {
9751
10040
  unwrapExports(googleLogin);
9752
10041
  var googleLogin_1 = googleLogin.GoogleLogin;
9753
10042
 
9754
- var _path$j, _path2$2, _path3$1, _path4;
10043
+ var _path$l, _path2$2, _path3$1, _path4;
9755
10044
 
9756
- function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
10045
+ function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
9757
10046
 
9758
10047
  function SvgGoogleLogo(props) {
9759
- return /*#__PURE__*/React.createElement("svg", _extends$l({
10048
+ return /*#__PURE__*/React.createElement("svg", _extends$n({
9760
10049
  viewBox: "0 0 24 24",
9761
10050
  xmlns: "http://www.w3.org/2000/svg"
9762
- }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
10051
+ }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
9763
10052
  fill: "#4285F4",
9764
10053
  d: "M23.745 12.27c0-.79-.07-1.54-.19-2.27h-11.3v4.51h6.47c-.29 1.48-1.14 2.73-2.4 3.58v3h3.86c2.26-2.09 3.56-5.17 3.56-8.82z"
9765
10054
  })), _path2$2 || (_path2$2 = /*#__PURE__*/React.createElement("path", {
@@ -9785,10 +10074,10 @@ const GoogleLoginButton = ({
9785
10074
  const googleLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
9786
10075
  const {
9787
10076
  dispatch: loginDispatch
9788
- } = useContext(store$e);
10077
+ } = useContext(store$f);
9789
10078
  const {
9790
10079
  dispatch: registerDispatch
9791
- } = useContext(store$d);
10080
+ } = useContext(store$e);
9792
10081
 
9793
10082
  const onSuccess = response => {
9794
10083
  var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
@@ -9893,15 +10182,15 @@ function LoginView(props) {
9893
10182
  }, /*#__PURE__*/React__default.createElement(GoogleLoginButton, null), /*#__PURE__*/React__default.createElement(FacebookLoginButton, null))))));
9894
10183
  }
9895
10184
 
9896
- var _path$i, _path2$1, _path3;
10185
+ var _path$k, _path2$1, _path3;
9897
10186
 
9898
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
10187
+ function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
9899
10188
 
9900
10189
  function SvgPelcroAuthorship(props) {
9901
- return /*#__PURE__*/React.createElement("svg", _extends$k({
10190
+ return /*#__PURE__*/React.createElement("svg", _extends$m({
9902
10191
  xmlns: "http://www.w3.org/2000/svg",
9903
10192
  viewBox: "0 -80.652 497.072 179.991"
9904
- }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
10193
+ }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
9905
10194
  fill: "none",
9906
10195
  stroke: "#4a4a4a",
9907
10196
  d: "M487.89 42.299c0 13.158-10.671 23.829-23.829 23.829H37.074c-13.162 0-23.832-10.671-23.832-23.829v-63.552c0-13.158 10.67-23.831 23.832-23.831H464.06c13.158 0 23.829 10.672 23.829 23.831l.001 63.552z"
@@ -10048,18 +10337,21 @@ function LoginModal({
10048
10337
  LoginModal.viewId = "login";
10049
10338
 
10050
10339
  const RegisterEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
10051
- store: store$d
10340
+ store: store$e
10052
10341
  }, props));
10053
10342
 
10054
10343
  const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
10055
- store: store$d
10344
+ store: store$e
10056
10345
  }, props));
10057
10346
 
10058
10347
  const RegisterButton = ({
10059
10348
  name,
10060
10349
  onClick,
10350
+ className,
10061
10351
  ...otherProps
10062
10352
  }) => {
10353
+ var _window$Pelcro$site$r;
10354
+
10063
10355
  const {
10064
10356
  state: {
10065
10357
  emailError,
@@ -10069,7 +10361,7 @@ const RegisterButton = ({
10069
10361
  buttonDisabled
10070
10362
  },
10071
10363
  dispatch
10072
- } = useContext(store$d);
10364
+ } = useContext(store$e);
10073
10365
  const {
10074
10366
  t
10075
10367
  } = useTranslation("register");
@@ -10085,7 +10377,10 @@ const RegisterButton = ({
10085
10377
  onClick === null || onClick === void 0 ? void 0 : onClick();
10086
10378
  },
10087
10379
  disabled: isDisabled,
10088
- isLoading: buttonDisabled
10380
+ isLoading: buttonDisabled,
10381
+ className: `${className} g-recaptcha`,
10382
+ "data-action": "register",
10383
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
10089
10384
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
10090
10385
  };
10091
10386
 
@@ -10204,7 +10499,7 @@ function FirstName({
10204
10499
  }
10205
10500
 
10206
10501
  const RegisterFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
10207
- store: store$d
10502
+ store: store$e
10208
10503
  }, props));
10209
10504
 
10210
10505
  function LastName({
@@ -10235,7 +10530,7 @@ function LastName({
10235
10530
  }
10236
10531
 
10237
10532
  const RegisterLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
10238
- store: store$d
10533
+ store: store$e
10239
10534
  }, props));
10240
10535
 
10241
10536
  /**
@@ -10339,7 +10634,7 @@ function TextInput({
10339
10634
 
10340
10635
  const RegisterTextInput = props => {
10341
10636
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
10342
- store: store$d
10637
+ store: store$e
10343
10638
  }));
10344
10639
  };
10345
10640
 
@@ -12304,13 +12599,14 @@ class PaypalGateWay {
12304
12599
  * @property {unknown} canMakePayment
12305
12600
  * @property {unknown} paymentRequest
12306
12601
  * @property {number} updatedPrice
12602
+ * @property {number} taxAmount
12307
12603
  * @property {object} currentPlan
12308
12604
  * @property {object} alert
12309
12605
  */
12310
12606
 
12311
12607
  /** @type {PaymentStateType} */
12312
12608
 
12313
- const initialState$c = {
12609
+ const initialState$d = {
12314
12610
  disableSubmit: false,
12315
12611
  isLoading: false,
12316
12612
  disableCouponButton: false,
@@ -12322,16 +12618,17 @@ const initialState$c = {
12322
12618
  canMakePayment: false,
12323
12619
  paymentRequest: null,
12324
12620
  updatedPrice: null,
12621
+ taxAmount: null,
12325
12622
  currentPlan: null,
12326
12623
  alert: {
12327
12624
  type: "error",
12328
12625
  content: ""
12329
12626
  }
12330
12627
  };
12331
- const store$c = /*#__PURE__*/createContext(initialState$c);
12628
+ const store$d = /*#__PURE__*/createContext(initialState$d);
12332
12629
  const {
12333
- Provider: Provider$c
12334
- } = store$c;
12630
+ Provider: Provider$d
12631
+ } = store$d;
12335
12632
 
12336
12633
  const PaymentMethodContainerWithoutStripe = ({
12337
12634
  style,
@@ -12372,6 +12669,7 @@ const PaymentMethodContainerWithoutStripe = ({
12372
12669
  dispatch({
12373
12670
  type: INIT_CONTAINER
12374
12671
  });
12672
+ updateTotalAmountWithTax();
12375
12673
  }, []);
12376
12674
 
12377
12675
  const initPaymentRequest = (state, dispatch) => {
@@ -12438,6 +12736,45 @@ const PaymentMethodContainerWithoutStripe = ({
12438
12736
  console.log("Google Pay/Apple pay isn't available in this country");
12439
12737
  }
12440
12738
  };
12739
+ /**
12740
+ * Updates the total amount after adding taxes only if site taxes are enabled
12741
+ */
12742
+
12743
+
12744
+ const updateTotalAmountWithTax = () => {
12745
+ var _window$Pelcro$site$r;
12746
+
12747
+ const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
12748
+
12749
+ if (taxesEnabled && type === "createPayment") {
12750
+ dispatch({
12751
+ type: DISABLE_SUBMIT,
12752
+ payload: true
12753
+ });
12754
+ resolveTaxCalculation().then(res => {
12755
+ if (res) {
12756
+ dispatch({
12757
+ type: SET_TAX_AMOUNT,
12758
+ payload: res.taxAmount
12759
+ });
12760
+ dispatch({
12761
+ type: SET_UPDATED_PRICE,
12762
+ payload: res.totalAmountWithTax
12763
+ });
12764
+ dispatch({
12765
+ type: UPDATE_PAYMENT_REQUEST
12766
+ });
12767
+ }
12768
+ }).catch(error => {
12769
+ handlePaymentError(error);
12770
+ }).finally(() => {
12771
+ dispatch({
12772
+ type: DISABLE_SUBMIT,
12773
+ payload: false
12774
+ });
12775
+ });
12776
+ }
12777
+ };
12441
12778
 
12442
12779
  const onApplyCouponCode = (state, dispatch) => {
12443
12780
  const {
@@ -12464,6 +12801,10 @@ const PaymentMethodContainerWithoutStripe = ({
12464
12801
  });
12465
12802
  }
12466
12803
 
12804
+ dispatch({
12805
+ type: SET_COUPON_ERROR,
12806
+ payload: ""
12807
+ });
12467
12808
  dispatch({
12468
12809
  type: SHOW_ALERT,
12469
12810
  payload: {
@@ -12479,6 +12820,10 @@ const PaymentMethodContainerWithoutStripe = ({
12479
12820
  type: SET_PERCENT_OFF,
12480
12821
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
12481
12822
  });
12823
+ dispatch({
12824
+ type: SET_TAX_AMOUNT,
12825
+ payload: res.data.taxes
12826
+ });
12482
12827
  dispatch({
12483
12828
  type: SET_UPDATED_PRICE,
12484
12829
  payload: res.data.total
@@ -12488,6 +12833,29 @@ const PaymentMethodContainerWithoutStripe = ({
12488
12833
  });
12489
12834
  };
12490
12835
 
12836
+ if ((couponCode === null || couponCode === void 0 ? void 0 : couponCode.trim()) === "") {
12837
+ dispatch({
12838
+ type: SET_COUPON,
12839
+ payload: null
12840
+ });
12841
+ dispatch({
12842
+ type: SET_PERCENT_OFF,
12843
+ payload: ""
12844
+ });
12845
+ dispatch({
12846
+ type: SET_UPDATED_PRICE,
12847
+ payload: null
12848
+ });
12849
+ dispatch({
12850
+ type: SET_TAX_AMOUNT,
12851
+ payload: null
12852
+ });
12853
+ dispatch({
12854
+ type: UPDATE_PAYMENT_REQUEST
12855
+ });
12856
+ updateTotalAmountWithTax();
12857
+ }
12858
+
12491
12859
  if (couponCode !== null && couponCode !== void 0 && couponCode.trim()) {
12492
12860
  dispatch({
12493
12861
  type: DISABLE_COUPON_BUTTON,
@@ -12874,16 +13242,20 @@ const PaymentMethodContainerWithoutStripe = ({
12874
13242
  const totalAmount = (_ref = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
12875
13243
 
12876
13244
  if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
12877
- return resolveTaxCalculation().then(totalAmountWithTax => generate3DSecureSource(source, totalAmountWithTax !== null && totalAmountWithTax !== void 0 ? totalAmountWithTax : totalAmount).then(({
12878
- source,
12879
- error
12880
- }) => {
12881
- if (error) {
12882
- return handlePaymentError(error);
12883
- }
13245
+ return resolveTaxCalculation().then(res => {
13246
+ var _res$totalAmountWithT;
12884
13247
 
12885
- toggleAuthenticationPendingView(true, source);
12886
- }));
13248
+ return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
13249
+ source,
13250
+ error
13251
+ }) => {
13252
+ if (error) {
13253
+ return handlePaymentError(error);
13254
+ }
13255
+
13256
+ toggleAuthenticationPendingView(true, source);
13257
+ });
13258
+ });
12887
13259
  }
12888
13260
 
12889
13261
  return handlePayment(source);
@@ -12892,15 +13264,15 @@ const PaymentMethodContainerWithoutStripe = ({
12892
13264
  });
12893
13265
  };
12894
13266
  /**
12895
- * Resolves with the total including taxes incase taxes enabled by site
13267
+ * Resolves with the total & tax amount incase taxes enabled by site
12896
13268
  * @return {Promise}
12897
13269
  */
12898
13270
 
12899
13271
 
12900
13272
  const resolveTaxCalculation = () => {
12901
- var _window$Pelcro$site$r;
13273
+ var _window$Pelcro$site$r2;
12902
13274
 
12903
- const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
13275
+ const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
12904
13276
  return new Promise((resolve, reject) => {
12905
13277
  // resolve early if taxes isn't enabled
12906
13278
  if (!taxesEnabled) {
@@ -12913,14 +13285,18 @@ const PaymentMethodContainerWithoutStripe = ({
12913
13285
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
12914
13286
  address_id: selectedAddressId
12915
13287
  }, (error, res) => {
12916
- var _res$data;
13288
+ var _res$data, _res$data2;
12917
13289
 
12918
13290
  if (error) {
12919
13291
  return reject(error);
12920
13292
  }
12921
13293
 
12922
- const totalAmountWithTax = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.total;
12923
- resolve(totalAmountWithTax);
13294
+ const taxAmount = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.taxes;
13295
+ const totalAmountWithTax = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.total;
13296
+ resolve({
13297
+ totalAmountWithTax,
13298
+ taxAmount
13299
+ });
12924
13300
  });
12925
13301
  });
12926
13302
  };
@@ -12975,13 +13351,13 @@ const PaymentMethodContainerWithoutStripe = ({
12975
13351
  const handlePaymentError = error => {
12976
13352
  if (error.type === "validation_error" && // Subscription creation & renewal
12977
13353
  type === "createPayment") {
12978
- var _state$coupon;
13354
+ var _state$couponObject;
12979
13355
 
12980
13356
  const {
12981
13357
  updatedPrice
12982
13358
  } = state; // When price is 0, we allow submitting without card info
12983
13359
 
12984
- if (updatedPrice === 0 && ((_state$coupon = state.coupon) === null || _state$coupon === void 0 ? void 0 : _state$coupon.duration) === "forever") {
13360
+ if (updatedPrice === 0 && ((_state$couponObject = state.couponObject) === null || _state$couponObject === void 0 ? void 0 : _state$couponObject.duration) === "forever") {
12985
13361
  return subscribe({}, state, dispatch);
12986
13362
  }
12987
13363
  }
@@ -13109,6 +13485,11 @@ const PaymentMethodContainerWithoutStripe = ({
13109
13485
  updatedPrice: action.payload
13110
13486
  });
13111
13487
 
13488
+ case SET_TAX_AMOUNT:
13489
+ return lib_7({ ...state,
13490
+ taxAmount: action.payload
13491
+ });
13492
+
13112
13493
  case SET_CAN_MAKE_PAYMENT:
13113
13494
  return lib_7({ ...state,
13114
13495
  canMakePayment: action.payload
@@ -13126,7 +13507,7 @@ const PaymentMethodContainerWithoutStripe = ({
13126
13507
 
13127
13508
  case SET_COUPON:
13128
13509
  return lib_7({ ...state,
13129
- coupon: action.payload
13510
+ couponObject: action.payload
13130
13511
  });
13131
13512
 
13132
13513
  case SET_COUPON_ERROR:
@@ -13152,34 +13533,43 @@ const PaymentMethodContainerWithoutStripe = ({
13152
13533
  default:
13153
13534
  return state;
13154
13535
  }
13155
- }, initialState$c);
13536
+ }, initialState$d);
13156
13537
  return /*#__PURE__*/React__default.createElement("div", {
13157
13538
  style: { ...style
13158
13539
  },
13159
13540
  className: `pelcro-container pelcro-payment-container ${className}`
13160
- }, /*#__PURE__*/React__default.createElement(Provider$c, {
13541
+ }, /*#__PURE__*/React__default.createElement(Provider$d, {
13161
13542
  value: {
13162
13543
  state,
13163
13544
  dispatch
13164
13545
  }
13165
13546
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
13166
- store: store$c,
13547
+ store: store$d,
13167
13548
  key: i
13168
13549
  })) : /*#__PURE__*/React__default.cloneElement(children, {
13169
- store: store$c
13550
+ store: store$d
13170
13551
  })));
13171
13552
  };
13172
13553
 
13173
13554
  const UnwrappedForm = es_12(PaymentMethodContainerWithoutStripe);
13174
13555
 
13175
13556
  const PaymentMethodContainer = props => {
13176
- if (window.Stripe) {
13557
+ const [isStripeLoaded, setIsStripeLoaded] = useState(Boolean(window.Stripe));
13558
+ useEffect(() => {
13559
+ if (!window.Stripe) {
13560
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
13561
+ setIsStripeLoaded(true);
13562
+ });
13563
+ }
13564
+ }, []);
13565
+
13566
+ if (isStripeLoaded) {
13177
13567
  return /*#__PURE__*/React__default.createElement(es_13, {
13178
13568
  apiKey: window.Pelcro.environment.stripe,
13179
13569
  stripeAccount: window.Pelcro.site.read().account_id,
13180
- locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13570
+ locale: getPageOrDefaultLanguage()
13181
13571
  }, /*#__PURE__*/React__default.createElement(es_11, null, /*#__PURE__*/React__default.createElement(UnwrappedForm, Object.assign({
13182
- store: store$c
13572
+ store: store$d
13183
13573
  }, props))));
13184
13574
  }
13185
13575
 
@@ -13232,7 +13622,7 @@ const PelcroPaymentRequestButton = props => {
13232
13622
  currentPlan,
13233
13623
  updatedPrice
13234
13624
  }
13235
- } = useContext(store$c);
13625
+ } = useContext(store$d);
13236
13626
 
13237
13627
  const updatePaymentRequest = () => {
13238
13628
  // Make sure payment request is up to date, eg. user added a coupon code.
@@ -13285,24 +13675,25 @@ const DiscountedPrice = props => {
13285
13675
  const {
13286
13676
  state: {
13287
13677
  updatedPrice,
13678
+ taxAmount,
13288
13679
  percentOff
13289
13680
  }
13290
- } = useContext(store$c);
13291
- const {
13292
- default_locale
13293
- } = Pelcro.site.read();
13681
+ } = useContext(store$d);
13294
13682
  const {
13295
13683
  order,
13296
13684
  plan
13297
13685
  } = usePelcro();
13298
13686
  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;
13299
13687
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13300
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : updatedPrice * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13688
+ const discountedPriceWithoutTax = updatedPrice - taxAmount;
13689
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13301
13690
 
13302
13691
  if (percentOff) {
13303
13692
  return /*#__PURE__*/React__default.createElement("div", Object.assign({
13304
- className: "plc-my-2"
13305
- }, props), "(-", percentOff, ") ", priceFormatted);
13693
+ className: "plc-flex plc-justify-center plc-mt-2 pelcro-discount"
13694
+ }, props), "(-", percentOff, ")", " ", /*#__PURE__*/React__default.createElement("span", {
13695
+ className: "plc-font-bold pelcro-discounted-price"
13696
+ }, priceFormatted));
13306
13697
  }
13307
13698
 
13308
13699
  return "";
@@ -13327,13 +13718,10 @@ const SubmitPaymentMethod = ({
13327
13718
  isLoading,
13328
13719
  updatedPrice
13329
13720
  }
13330
- } = useContext(store$c);
13331
- const {
13332
- default_locale
13333
- } = Pelcro.site.read();
13721
+ } = useContext(store$d);
13334
13722
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13335
13723
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
13336
- const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13724
+ const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13337
13725
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
13338
13726
  role: "submit",
13339
13727
  className: "plc-w-full plc-py-3",
@@ -13351,17 +13739,17 @@ const SubmitPaymentMethod = ({
13351
13739
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
13352
13740
  };
13353
13741
 
13354
- var _path$h;
13742
+ var _path$j;
13355
13743
 
13356
- function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
13744
+ function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
13357
13745
 
13358
13746
  function SvgArrowLeft(props) {
13359
- return /*#__PURE__*/React.createElement("svg", _extends$j({
13747
+ return /*#__PURE__*/React.createElement("svg", _extends$l({
13360
13748
  xmlns: "http://www.w3.org/2000/svg",
13361
13749
  fill: "none",
13362
13750
  viewBox: "0 0 24 24",
13363
13751
  stroke: "currentColor"
13364
- }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
13752
+ }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
13365
13753
  strokeLinecap: "round",
13366
13754
  strokeLinejoin: "round",
13367
13755
  strokeWidth: 2,
@@ -13380,7 +13768,7 @@ const ApplyCouponButton = ({
13380
13768
  disableCouponButton
13381
13769
  },
13382
13770
  dispatch
13383
- } = useContext(store$c);
13771
+ } = useContext(store$d);
13384
13772
  const {
13385
13773
  t
13386
13774
  } = useTranslation("checkoutForm");
@@ -13414,7 +13802,7 @@ const CouponCodeField = props => {
13414
13802
  couponCode,
13415
13803
  couponError
13416
13804
  }
13417
- } = useContext(store$c);
13805
+ } = useContext(store$d);
13418
13806
 
13419
13807
  const onCouponCodeChange = e => {
13420
13808
  dispatch({
@@ -13432,6 +13820,7 @@ const CouponCodeField = props => {
13432
13820
 
13433
13821
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({
13434
13822
  className: "plc-h-12",
13823
+ wrapperClassName: "plc-mb-1",
13435
13824
  errorClassName: "plc-h-12 sm:plc-h-8",
13436
13825
  error: couponError,
13437
13826
  "aria-label": t("labels.code"),
@@ -13442,17 +13831,17 @@ const CouponCodeField = props => {
13442
13831
  }, props));
13443
13832
  };
13444
13833
 
13445
- var _path$g;
13834
+ var _path$i;
13446
13835
 
13447
- function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
13836
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
13448
13837
 
13449
13838
  function SvgTicket(props) {
13450
- return /*#__PURE__*/React.createElement("svg", _extends$i({
13839
+ return /*#__PURE__*/React.createElement("svg", _extends$k({
13451
13840
  xmlns: "http://www.w3.org/2000/svg",
13452
13841
  fill: "none",
13453
13842
  viewBox: "0 0 24 24",
13454
13843
  stroke: "currentColor"
13455
- }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
13844
+ }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
13456
13845
  strokeLinecap: "round",
13457
13846
  strokeLinejoin: "round",
13458
13847
  strokeWidth: 2,
@@ -13469,7 +13858,7 @@ const CouponCode = ({
13469
13858
  state: {
13470
13859
  enableCouponField
13471
13860
  }
13472
- } = useContext(store$c);
13861
+ } = useContext(store$d);
13473
13862
  const {
13474
13863
  t
13475
13864
  } = useTranslation("checkoutForm");
@@ -13483,16 +13872,16 @@ const CouponCode = ({
13483
13872
  };
13484
13873
 
13485
13874
  return /*#__PURE__*/React__default.createElement("div", {
13486
- className: "plc-my-4"
13875
+ className: "plc-mt-4"
13487
13876
  }, /*#__PURE__*/React__default.createElement(Button, Object.assign({
13488
- className: "plc-text-base plc-text-gray-500",
13877
+ className: "plc-mb-2 plc-text-base plc-text-gray-500",
13489
13878
  variant: "ghost",
13490
13879
  icon: /*#__PURE__*/React__default.createElement(SvgTicket, {
13491
13880
  className: "plc-w-5 plc-h-5 plc-mr-2"
13492
13881
  }),
13493
13882
  onClick: showCouponField
13494
13883
  }, otherProps), !enableCouponField ? t("labels.addCode") : t("labels.hideCode")), enableCouponField && /*#__PURE__*/React__default.createElement("div", {
13495
- className: "plc-flex plc-w-full plc-my-4 pelcro-apply-coupon-wrapper"
13884
+ className: "plc-flex plc-w-full plc-mt-2 pelcro-apply-coupon-wrapper"
13496
13885
  }, /*#__PURE__*/React__default.createElement(CouponCodeField, null), /*#__PURE__*/React__default.createElement(ApplyCouponButton, null)));
13497
13886
  };
13498
13887
 
@@ -13577,7 +13966,7 @@ class PaypalClient {
13577
13966
  this.paypalButton = window.paypal.Buttons({
13578
13967
  fundingSource: window.paypal.FUNDING.PAYPAL,
13579
13968
  // button locale
13580
- locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : this.siteInfo.default_locale,
13969
+ locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : getPageOrDefaultLanguage(),
13581
13970
  // button style
13582
13971
  style: (_this$config$style = this.config.style) !== null && _this$config$style !== void 0 ? _this$config$style : defaultButtonStyle,
13583
13972
  // create payment handler
@@ -13674,7 +14063,7 @@ class PaypalClient {
13674
14063
  } : undefined,
13675
14064
  shippingAddressEditable: this.config.shippingAddressEditable,
13676
14065
  displayName: (_this$config$displayN = this.config.displayName) !== null && _this$config$displayN !== void 0 ? _this$config$displayN : this.siteInfo.name,
13677
- locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : this.siteInfo.default_locale
14066
+ locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : getPageOrDefaultLanguage()
13678
14067
  };
13679
14068
  }
13680
14069
  });
@@ -13683,7 +14072,7 @@ class PaypalClient {
13683
14072
  writable: true,
13684
14073
  value: () => {
13685
14074
  const totalAmount = (this.product.quantity || 1) * this.amount;
13686
- const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, this.siteInfo.default_locale);
14075
+ const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, getPageOrDefaultLanguage());
13687
14076
  const autoRenewed = this.product.auto_renew;
13688
14077
  const {
13689
14078
  interval,
@@ -13726,7 +14115,7 @@ const PaypalSubscribeButton = props => {
13726
14115
  const {
13727
14116
  dispatch,
13728
14117
  state
13729
- } = useContext(store$c);
14118
+ } = useContext(store$d);
13730
14119
  const {
13731
14120
  product,
13732
14121
  plan,
@@ -13811,16 +14200,16 @@ const BankRedirection = () => {
13811
14200
  }));
13812
14201
  };
13813
14202
 
13814
- var _path$f;
14203
+ var _path$h;
13815
14204
 
13816
- function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
14205
+ function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
13817
14206
 
13818
14207
  function SvgLock(props) {
13819
- return /*#__PURE__*/React.createElement("svg", _extends$h({
14208
+ return /*#__PURE__*/React.createElement("svg", _extends$j({
13820
14209
  xmlns: "http://www.w3.org/2000/svg",
13821
14210
  viewBox: "0 0 20 20",
13822
14211
  fill: "currentColor"
13823
- }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
14212
+ }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
13824
14213
  fillRule: "evenodd",
13825
14214
  d: "M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",
13826
14215
  clipRule: "evenodd"
@@ -13837,7 +14226,7 @@ const SelectedPaymentMethod = () => {
13837
14226
  state: {
13838
14227
  isLoading
13839
14228
  }
13840
- } = useContext(store$c);
14229
+ } = useContext(store$d);
13841
14230
  const {
13842
14231
  switchView,
13843
14232
  selectedPaymentMethodId
@@ -13869,6 +14258,34 @@ const SelectedPaymentMethod = () => {
13869
14258
  }, t("select.buttons.changePaymentMethod")))));
13870
14259
  };
13871
14260
 
14261
+ const TaxAmount = () => {
14262
+ var _plan$quantity;
14263
+
14264
+ const {
14265
+ t
14266
+ } = useTranslation("checkoutForm");
14267
+ const {
14268
+ state: {
14269
+ taxAmount
14270
+ }
14271
+ } = useContext(store$d);
14272
+ const {
14273
+ plan
14274
+ } = usePelcro();
14275
+ const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14276
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14277
+
14278
+ if (taxAmount) {
14279
+ return /*#__PURE__*/React__default.createElement("div", {
14280
+ className: "plc-text-center pelcro-tax-amount"
14281
+ }, t("labels.tax"), " ", /*#__PURE__*/React__default.createElement("span", {
14282
+ className: "plc-font-bold"
14283
+ }, priceFormatted));
14284
+ }
14285
+
14286
+ return null;
14287
+ };
14288
+
13872
14289
  /**
13873
14290
  *
13874
14291
  */
@@ -13905,7 +14322,9 @@ function PaymentMethodView({
13905
14322
  onFailure: onFailure
13906
14323
  }, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(AlertWithContext, {
13907
14324
  className: "plc-mb-2"
13908
- }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement("div", {
14325
+ }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement("div", {
14326
+ className: "plc-mb-2"
14327
+ }, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
13909
14328
  className: "plc-grid plc-mt-4 plc-gap-y-2"
13910
14329
  }, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)))))));
13911
14330
  }
@@ -14012,12 +14431,12 @@ function SubscriptionRenewModal({
14012
14431
  }
14013
14432
  SubscriptionRenewModal.viewId = "subscription-renew";
14014
14433
 
14015
- var _path$e;
14434
+ var _path$g;
14016
14435
 
14017
- function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
14436
+ function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
14018
14437
 
14019
14438
  function SvgGift(props) {
14020
- return /*#__PURE__*/React.createElement("svg", _extends$g({
14439
+ return /*#__PURE__*/React.createElement("svg", _extends$i({
14021
14440
  className: "plc-w-6 plc-h-6 plc-mr-2",
14022
14441
  fill: "none",
14023
14442
  stroke: "currentColor",
@@ -14026,7 +14445,7 @@ function SvgGift(props) {
14026
14445
  strokeWidth: 2,
14027
14446
  viewBox: "0 0 24 24",
14028
14447
  xmlns: "http://www.w3.org/2000/svg"
14029
- }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
14448
+ }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
14030
14449
  d: "M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7zM12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z"
14031
14450
  })));
14032
14451
  }
@@ -14357,6 +14776,292 @@ class DefaultNewsLetter extends Component {
14357
14776
 
14358
14777
  const NewsLetter = withTranslation("newsletter")(DefaultNewsLetter);
14359
14778
 
14779
+ const initialState$c = {
14780
+ didSubToNewslettersBefore: false,
14781
+ newsletters: [],
14782
+ isListLoading: true,
14783
+ isSubmitting: false,
14784
+ alert: {
14785
+ type: "error",
14786
+ content: ""
14787
+ }
14788
+ };
14789
+ const store$c = /*#__PURE__*/createContext(initialState$c);
14790
+ const {
14791
+ Provider: Provider$c
14792
+ } = store$c;
14793
+
14794
+ const NewsletterUpdateContainer = ({
14795
+ style,
14796
+ className = "",
14797
+ onSuccess = () => {},
14798
+ onFailure = () => {},
14799
+ children
14800
+ }) => {
14801
+ const [t] = useTranslation("newsletter");
14802
+
14803
+ const handleSubmit = ({
14804
+ newsletters,
14805
+ didSubToNewslettersBefore
14806
+ }, dispatch) => {
14807
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2;
14808
+
14809
+ const callback = (err, res) => {
14810
+ dispatch({
14811
+ type: LOADING,
14812
+ payload: false
14813
+ });
14814
+
14815
+ if (err) {
14816
+ dispatch({
14817
+ type: SHOW_ALERT,
14818
+ payload: {
14819
+ type: "error",
14820
+ content: getErrorMessages(err)
14821
+ }
14822
+ });
14823
+ onFailure(err);
14824
+ } else {
14825
+ if (!didSubToNewslettersBefore) {
14826
+ dispatch({
14827
+ type: SWITCH_TO_UPDATE
14828
+ });
14829
+ }
14830
+
14831
+ dispatch({
14832
+ type: SHOW_ALERT,
14833
+ payload: {
14834
+ type: "success",
14835
+ content: t("messages.success")
14836
+ }
14837
+ });
14838
+ onSuccess(res);
14839
+ }
14840
+ };
14841
+
14842
+ const requestData = {
14843
+ email: (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.email) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : window.Pelcro.helpers.getURLParameter("email"),
14844
+ source: "web",
14845
+ lists: newsletters.filter(newsletter => newsletter.selected).map(newsletter => newsletter.id).join(",")
14846
+ };
14847
+
14848
+ if (didSubToNewslettersBefore) {
14849
+ window.Pelcro.newsletter.update(requestData, callback);
14850
+ } else {
14851
+ window.Pelcro.newsletter.create(requestData, callback);
14852
+ }
14853
+ };
14854
+
14855
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
14856
+ switch (action.type) {
14857
+ case GET_NEWSLETTERS_FETCH:
14858
+ return lib_7({ ...state,
14859
+ isListLoading: true
14860
+ });
14861
+
14862
+ case GET_NEWSLETTERS_SUCCESS:
14863
+ return lib_7({ ...state,
14864
+ newsletters: action.payload.newsletters,
14865
+ didSubToNewslettersBefore: action.payload.didSubToNewslettersBefore,
14866
+ isListLoading: false
14867
+ });
14868
+
14869
+ case SET_SELECT:
14870
+ return lib_7({ ...state,
14871
+ newsletters: state.newsletters.map(newsletter => {
14872
+ if (newsletter.id === action.payload) {
14873
+ return { ...newsletter,
14874
+ selected: !newsletter.selected
14875
+ };
14876
+ }
14877
+
14878
+ return newsletter;
14879
+ })
14880
+ });
14881
+
14882
+ case SWITCH_TO_UPDATE:
14883
+ return lib_7({ ...state,
14884
+ didSubToNewslettersBefore: true
14885
+ });
14886
+
14887
+ case SHOW_ALERT:
14888
+ return lib_7({ ...state,
14889
+ alert: action.payload
14890
+ });
14891
+
14892
+ case LOADING:
14893
+ return lib_7({ ...state,
14894
+ isSubmitting: action.payload
14895
+ });
14896
+
14897
+ case HANDLE_SUBMIT:
14898
+ return lib_5({ ...state,
14899
+ isSubmitting: true
14900
+ }, (state, dispatch) => handleSubmit(state, dispatch));
14901
+
14902
+ default:
14903
+ return state;
14904
+ }
14905
+ }, initialState$c);
14906
+ useEffect(() => {
14907
+ const getUserNewsletters = () => {
14908
+ var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
14909
+
14910
+ dispatch({
14911
+ type: GET_NEWSLETTERS_FETCH
14912
+ });
14913
+ const email = (_window$Pelcro$user$r3 = (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.email) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : window.Pelcro.helpers.getURLParameter("email");
14914
+ window.Pelcro.newsletter.getByEmail(email, (err, res) => {
14915
+ var _window$Pelcro$uiSett, _window$Pelcro, _window$Pelcro$uiSett2, _res$data$lists$split, _res$data$lists;
14916
+
14917
+ if (err) {
14918
+ return dispatch({
14919
+ type: SHOW_ALERT,
14920
+ payload: {
14921
+ type: "error",
14922
+ content: getErrorMessages(err)
14923
+ }
14924
+ });
14925
+ }
14926
+
14927
+ const newsletters = (_window$Pelcro$uiSett = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett2 = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett2 === void 0 ? void 0 : _window$Pelcro$uiSett2.newsletters) !== null && _window$Pelcro$uiSett !== void 0 ? _window$Pelcro$uiSett : [];
14928
+ const selectedNewsletters = (_res$data$lists$split = (_res$data$lists = res.data.lists) === null || _res$data$lists === void 0 ? void 0 : _res$data$lists.split(",")) !== null && _res$data$lists$split !== void 0 ? _res$data$lists$split : [];
14929
+ const allNewslettersWithSelectedField = newsletters.map(newsletter => ({ ...newsletter,
14930
+ id: String(newsletter.id),
14931
+ selected: selectedNewsletters.includes(String(newsletter.id))
14932
+ }));
14933
+ dispatch({
14934
+ type: GET_NEWSLETTERS_SUCCESS,
14935
+ payload: {
14936
+ newsletters: allNewslettersWithSelectedField,
14937
+ didSubToNewslettersBefore: Boolean(res.data.email)
14938
+ }
14939
+ });
14940
+ });
14941
+ };
14942
+
14943
+ getUserNewsletters();
14944
+ }, []);
14945
+ return /*#__PURE__*/React__default.createElement("div", {
14946
+ style: { ...style
14947
+ },
14948
+ className: `pelcro-container pelcro-newsletter-update-container ${className}`
14949
+ }, /*#__PURE__*/React__default.createElement(Provider$c, {
14950
+ value: {
14951
+ state,
14952
+ dispatch
14953
+ }
14954
+ }, children.length ? children.map((child, i) => {
14955
+ if (child) {
14956
+ return /*#__PURE__*/React__default.cloneElement(child, {
14957
+ store: store$c,
14958
+ key: i
14959
+ });
14960
+ }
14961
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
14962
+ store: store$c
14963
+ })));
14964
+ };
14965
+
14966
+ const NewsletterUpdateButton = ({
14967
+ name,
14968
+ onClick,
14969
+ ...otherProps
14970
+ }) => {
14971
+ const {
14972
+ dispatch,
14973
+ state: {
14974
+ isSubmitting,
14975
+ isListLoading
14976
+ }
14977
+ } = useContext(store$c);
14978
+ const {
14979
+ t
14980
+ } = useTranslation("newsletter");
14981
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
14982
+ onClick: () => {
14983
+ dispatch({
14984
+ type: HANDLE_SUBMIT
14985
+ });
14986
+ onClick === null || onClick === void 0 ? void 0 : onClick();
14987
+ },
14988
+ disabled: isListLoading,
14989
+ isLoading: isSubmitting
14990
+ }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
14991
+ };
14992
+
14993
+ const NewsletterUpdateList = () => {
14994
+ const handleSelectNewsletter = event => {
14995
+ dispatch({
14996
+ type: SET_SELECT,
14997
+ payload: event.target.value
14998
+ });
14999
+ };
15000
+
15001
+ const {
15002
+ dispatch,
15003
+ state: {
15004
+ newsletters,
15005
+ isListLoading
15006
+ }
15007
+ } = useContext(store$c);
15008
+
15009
+ if (isListLoading) {
15010
+ return /*#__PURE__*/React__default.createElement(Loader, {
15011
+ width: 60,
15012
+ height: 100
15013
+ });
15014
+ }
15015
+
15016
+ return /*#__PURE__*/React__default.createElement("div", {
15017
+ className: "plc-max-h-80 plc-overflow-y-auto pelcro-newsletters-wrapper"
15018
+ }, newsletters.map(newsletter => /*#__PURE__*/React__default.createElement("div", {
15019
+ key: newsletter.id,
15020
+ className: "plc-p-2 plc-mx-3 plc-mt-2 plc-border plc-border-gray-400 plc-border-solid plc-rounded plc-text-gray-900 pelcro-newsletter-wrapper"
15021
+ }, /*#__PURE__*/React__default.createElement(Checkbox, {
15022
+ className: "pelcro-select-newsletter-checkbox",
15023
+ labelClassName: "plc-cursor-pointer plc-w-full",
15024
+ id: `pelcro-newsletter-update-${newsletter.id}`,
15025
+ checked: newsletter.selected,
15026
+ value: newsletter.id,
15027
+ onChange: handleSelectNewsletter
15028
+ }, newsletter.label))));
15029
+ };
15030
+
15031
+ const NewsletterUpdateView = props => {
15032
+ const {
15033
+ t
15034
+ } = useTranslation("newsletter");
15035
+ return /*#__PURE__*/React__default.createElement("div", {
15036
+ id: "pelcro-newsletter-update-view"
15037
+ }, /*#__PURE__*/React__default.createElement("div", {
15038
+ className: "plc-mb-6 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
15039
+ }, /*#__PURE__*/React__default.createElement("h4", {
15040
+ className: "plc-text-2xl plc-font-semibold"
15041
+ }, t("updateTitle"))), /*#__PURE__*/React__default.createElement("form", {
15042
+ action: "javascript:void(0);",
15043
+ className: "plc-mt-2 pelcro-form"
15044
+ }, /*#__PURE__*/React__default.createElement(NewsletterUpdateContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), /*#__PURE__*/React__default.createElement(NewsletterUpdateList, null), /*#__PURE__*/React__default.createElement(NewsletterUpdateButton, {
15045
+ role: "submit",
15046
+ className: "plc-mt-4 plc-w-full",
15047
+ name: t("labels.submit"),
15048
+ id: "pelcro-submit"
15049
+ }))));
15050
+ };
15051
+
15052
+ const NewsletterUpdateModal = ({
15053
+ onDisplay,
15054
+ onClose,
15055
+ ...otherProps
15056
+ }) => {
15057
+ return /*#__PURE__*/React__default.createElement(Modal, {
15058
+ id: "pelcro-newsletter-update-modal",
15059
+ onDisplay: onDisplay,
15060
+ onClose: onClose
15061
+ }, /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(NewsletterUpdateView, otherProps)), /*#__PURE__*/React__default.createElement(ModalFooter, null, /*#__PURE__*/React__default.createElement(Authorship, null)));
15062
+ };
15063
+ NewsletterUpdateModal.viewId = "newsletter-update";
15064
+
14360
15065
  const MeterView = () => {
14361
15066
  var _paywallProduct$paywa, _paywallProduct$paywa2;
14362
15067
 
@@ -14408,7 +15113,7 @@ const MeterModal = props => {
14408
15113
  className: "plc-fixed plc-bottom-0 plc-right-0 plc-w-full plc-p-4 plc-bg-white plc-border-t-4 plc-rounded plc-shadow-md motion-safe:plc-animate-slideInBottom sm:plc-m-4 sm:plc-max-w-md plc-z-max plc-border-primary-500"
14409
15114
  }, /*#__PURE__*/React__default.createElement("button", {
14410
15115
  type: "button",
14411
- className: "plc-absolute plc-top-0 plc-text-2xl plc-text-gray-500 plc-right-1 pelcro-close-btn",
15116
+ className: "plc-absolute plc-top-0 plc-text-2xl plc-text-gray-500 hover:plc-text-black focus:plc-text-black plc-right-1 plc-border-0 plc-bg-transparent hover:plc-bg-transparent focus:plc-bg-transparent pelcro-close-btn",
14412
15117
  "aria-label": "Close",
14413
15118
  onClick: onClose
14414
15119
  }, /*#__PURE__*/React__default.createElement("span", null, "\xD7")), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(MeterView, props)));
@@ -14441,10 +15146,7 @@ const SubscriptionCreateView = ({
14441
15146
  interval,
14442
15147
  count: interval_count
14443
15148
  });
14444
- const {
14445
- default_locale
14446
- } = Pelcro.site.read();
14447
- const priceFormatted = getFormattedPriceByLocal((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), plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
15149
+ const priceFormatted = getFormattedPriceByLocal((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), plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14448
15150
  return /*#__PURE__*/React__default.createElement("p", {
14449
15151
  className: "plc-text-gray-600"
14450
15152
  }, /*#__PURE__*/React__default.createElement("span", {
@@ -14744,17 +15446,17 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default.createElement(Phone
14744
15446
 
14745
15447
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
14746
15448
 
14747
- var _path$d;
15449
+ var _path$f;
14748
15450
 
14749
- function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
15451
+ function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
14750
15452
 
14751
15453
  function SvgEdit(props) {
14752
- return /*#__PURE__*/React.createElement("svg", _extends$f({
15454
+ return /*#__PURE__*/React.createElement("svg", _extends$h({
14753
15455
  className: "plc-w-6 plc-h-6",
14754
15456
  xmlns: "http://www.w3.org/2000/svg",
14755
15457
  viewBox: "0 0 20 20",
14756
15458
  fill: "currentColor"
14757
- }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
15459
+ }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
14758
15460
  d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
14759
15461
  })));
14760
15462
  }
@@ -17621,7 +18323,6 @@ const OrderConfirmModal = props => {
17621
18323
  const userOrders = window.Pelcro.user.read().orders;
17622
18324
  const latestOrder = userOrders === null || userOrders === void 0 ? void 0 : userOrders[userOrders.length - 1];
17623
18325
  const latestOrderDiscount = latestOrder === null || latestOrder === void 0 ? void 0 : (_latestOrder$coupon = latestOrder.coupon) === null || _latestOrder$coupon === void 0 ? void 0 : _latestOrder$coupon.percent_off;
17624
- const locale = window.Pelcro.site.read().default_locale;
17625
18326
  const {
17626
18327
  t
17627
18328
  } = useTranslation("shop");
@@ -17680,7 +18381,7 @@ const OrderConfirmModal = props => {
17680
18381
  className: "plc-mr-1 pelcro-summary-total-text"
17681
18382
  }, t("labels.total")), /*#__PURE__*/React__default.createElement("p", {
17682
18383
  className: "pelcro-summary-total"
17683
- }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, locale)))), /*#__PURE__*/React__default.createElement("div", {
18384
+ }, latestOrderDiscount && `(-${latestOrderDiscount}%) `, getFormattedPriceByLocal(latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.amount, latestOrder === null || latestOrder === void 0 ? void 0 : latestOrder.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("div", {
17684
18385
  className: "plc-flex plc-justify-center plc-mt-6"
17685
18386
  }, /*#__PURE__*/React__default.createElement(Button, {
17686
18387
  id: "pelcro-submit",
@@ -17742,9 +18443,9 @@ const GiftCreateContainer = ({
17742
18443
  }
17743
18444
 
17744
18445
  if (giftRecipient.startDate) {
17745
- const nowDate = new Date();
17746
- const yearFromNowDate = new Date(new Date().setFullYear(nowDate.getFullYear() + 1));
17747
- const submittedDate = new Date(giftRecipient.startDate);
18446
+ const nowDate = getDateWithoutTime(new Date());
18447
+ const yearFromNowDate = getDateWithoutTime(new Date(new Date().setFullYear(nowDate.getFullYear() + 1)));
18448
+ const submittedDate = getDateWithoutTime(new Date(giftRecipient.startDate));
17748
18449
 
17749
18450
  if (submittedDate < nowDate || submittedDate > yearFromNowDate) {
17750
18451
  dispatch({
@@ -17865,18 +18566,18 @@ const GiftCreateLastName = props => /*#__PURE__*/React__default.createElement(La
17865
18566
  store: store$4
17866
18567
  }, props));
17867
18568
 
17868
- var _path$c;
18569
+ var _path$e;
17869
18570
 
17870
- function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
18571
+ function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
17871
18572
 
17872
18573
  function SvgInfoCircle(props) {
17873
- return /*#__PURE__*/React.createElement("svg", _extends$e({
18574
+ return /*#__PURE__*/React.createElement("svg", _extends$g({
17874
18575
  xmlns: "http://www.w3.org/2000/svg",
17875
18576
  className: "plc-w-5 plc-h-5",
17876
18577
  fill: "none",
17877
18578
  viewBox: "0 0 24 24",
17878
18579
  stroke: "currentColor"
17879
- }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
18580
+ }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
17880
18581
  strokeLinecap: "round",
17881
18582
  strokeLinejoin: "round",
17882
18583
  strokeWidth: 2,
@@ -18863,8 +19564,8 @@ const PaymentMethodSelectModal = ({
18863
19564
  };
18864
19565
  PaymentMethodSelectModal.viewId = "payment-method-select";
18865
19566
 
18866
- function _extends$d() {
18867
- _extends$d = Object.assign || function (target) {
19567
+ function _extends$f() {
19568
+ _extends$f = Object.assign || function (target) {
18868
19569
  for (var i = 1; i < arguments.length; i++) {
18869
19570
  var source = arguments[i];
18870
19571
 
@@ -18878,7 +19579,7 @@ function _extends$d() {
18878
19579
  return target;
18879
19580
  };
18880
19581
 
18881
- return _extends$d.apply(this, arguments);
19582
+ return _extends$f.apply(this, arguments);
18882
19583
  }
18883
19584
 
18884
19585
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -19062,7 +19763,7 @@ function render(props, propsBag, defaultTag, features, visible) {
19062
19763
  return match(strategy, (_match = {}, _match[RenderStrategy.Unmount] = function () {
19063
19764
  return null;
19064
19765
  }, _match[RenderStrategy.Hidden] = function () {
19065
- return _render(_extends$d({}, _rest, {
19766
+ return _render(_extends$f({}, _rest, {
19066
19767
  hidden: true,
19067
19768
  style: {
19068
19769
  display: 'none'
@@ -19590,7 +20291,7 @@ function TransitionChild(props) {
19590
20291
  var passthroughProps = rest;
19591
20292
  return React__default.createElement(NestingContext.Provider, {
19592
20293
  value: nesting
19593
- }, render(_extends$d({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
20294
+ }, render(_extends$f({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
19594
20295
  }
19595
20296
 
19596
20297
  function Transition(props) {
@@ -19634,7 +20335,7 @@ function Transition(props) {
19634
20335
  value: nestingBag
19635
20336
  }, React__default.createElement(TransitionContext.Provider, {
19636
20337
  value: transitionBag
19637
- }, render(_extends$d({}, sharedProps, {
20338
+ }, render(_extends$f({}, sharedProps, {
19638
20339
  as: Fragment,
19639
20340
  children: React__default.createElement(TransitionChild, Object.assign({}, sharedProps, passthroughProps))
19640
20341
  }), propsBag, Fragment, TransitionChildRenderFeatures, state === TreeStates.Visible)));
@@ -19761,12 +20462,12 @@ var ActionTypes;
19761
20462
  })(ActionTypes || (ActionTypes = {}));
19762
20463
 
19763
20464
  (_reducers = {}, _reducers[ActionTypes.CloseMenu] = function (state) {
19764
- return _extends$d({}, state, {
20465
+ return _extends$f({}, state, {
19765
20466
  activeItemIndex: null,
19766
20467
  menuState: MenuStates.Closed
19767
20468
  });
19768
20469
  }, _reducers[ActionTypes.OpenMenu] = function (state) {
19769
- return _extends$d({}, state, {
20470
+ return _extends$f({}, state, {
19770
20471
  menuState: MenuStates.Open
19771
20472
  });
19772
20473
  }, _reducers[ActionTypes.GoToItem] = function (state, action) {
@@ -19785,7 +20486,7 @@ var ActionTypes;
19785
20486
  }
19786
20487
  });
19787
20488
  if (state.searchQuery === '' && state.activeItemIndex === activeItemIndex) return state;
19788
- return _extends$d({}, state, {
20489
+ return _extends$f({}, state, {
19789
20490
  searchQuery: '',
19790
20491
  activeItemIndex: activeItemIndex
19791
20492
  });
@@ -19796,19 +20497,19 @@ var ActionTypes;
19796
20497
 
19797
20498
  return ((_item$dataRef$current = item.dataRef.current.textValue) == null ? void 0 : _item$dataRef$current.startsWith(searchQuery)) && !item.dataRef.current.disabled;
19798
20499
  });
19799
- if (match === -1 || match === state.activeItemIndex) return _extends$d({}, state, {
20500
+ if (match === -1 || match === state.activeItemIndex) return _extends$f({}, state, {
19800
20501
  searchQuery: searchQuery
19801
20502
  });
19802
- return _extends$d({}, state, {
20503
+ return _extends$f({}, state, {
19803
20504
  searchQuery: searchQuery,
19804
20505
  activeItemIndex: match
19805
20506
  });
19806
20507
  }, _reducers[ActionTypes.ClearSearch] = function (state) {
19807
- return _extends$d({}, state, {
20508
+ return _extends$f({}, state, {
19808
20509
  searchQuery: ''
19809
20510
  });
19810
20511
  }, _reducers[ActionTypes.RegisterItem] = function (state, action) {
19811
- return _extends$d({}, state, {
20512
+ return _extends$f({}, state, {
19812
20513
  items: [].concat(state.items, [{
19813
20514
  id: action.id,
19814
20515
  dataRef: action.dataRef
@@ -19821,7 +20522,7 @@ var ActionTypes;
19821
20522
  return a.id === action.id;
19822
20523
  });
19823
20524
  if (idx !== -1) nextItems.splice(idx, 1);
19824
- return _extends$d({}, state, {
20525
+ return _extends$f({}, state, {
19825
20526
  items: nextItems,
19826
20527
  activeItemIndex: function () {
19827
20528
  if (idx === state.activeItemIndex) return null;
@@ -19860,19 +20561,19 @@ var ActionTypes$1;
19860
20561
  (_reducers$1 = {}, _reducers$1[ActionTypes$1.CloseListbox] = function (state) {
19861
20562
  if (state.disabled) return state;
19862
20563
  if (state.listboxState === ListboxStates.Closed) return state;
19863
- return _extends$d({}, state, {
20564
+ return _extends$f({}, state, {
19864
20565
  activeOptionIndex: null,
19865
20566
  listboxState: ListboxStates.Closed
19866
20567
  });
19867
20568
  }, _reducers$1[ActionTypes$1.OpenListbox] = function (state) {
19868
20569
  if (state.disabled) return state;
19869
20570
  if (state.listboxState === ListboxStates.Open) return state;
19870
- return _extends$d({}, state, {
20571
+ return _extends$f({}, state, {
19871
20572
  listboxState: ListboxStates.Open
19872
20573
  });
19873
20574
  }, _reducers$1[ActionTypes$1.SetDisabled] = function (state, action) {
19874
20575
  if (state.disabled === action.disabled) return state;
19875
- return _extends$d({}, state, {
20576
+ return _extends$f({}, state, {
19876
20577
  disabled: action.disabled
19877
20578
  });
19878
20579
  }, _reducers$1[ActionTypes$1.GoToOption] = function (state, action) {
@@ -19893,7 +20594,7 @@ var ActionTypes$1;
19893
20594
  }
19894
20595
  });
19895
20596
  if (state.searchQuery === '' && state.activeOptionIndex === activeOptionIndex) return state;
19896
- return _extends$d({}, state, {
20597
+ return _extends$f({}, state, {
19897
20598
  searchQuery: '',
19898
20599
  activeOptionIndex: activeOptionIndex
19899
20600
  });
@@ -19906,10 +20607,10 @@ var ActionTypes$1;
19906
20607
 
19907
20608
  return !option.dataRef.current.disabled && ((_option$dataRef$curre = option.dataRef.current.textValue) == null ? void 0 : _option$dataRef$curre.startsWith(searchQuery));
19908
20609
  });
19909
- if (match === -1 || match === state.activeOptionIndex) return _extends$d({}, state, {
20610
+ if (match === -1 || match === state.activeOptionIndex) return _extends$f({}, state, {
19910
20611
  searchQuery: searchQuery
19911
20612
  });
19912
- return _extends$d({}, state, {
20613
+ return _extends$f({}, state, {
19913
20614
  searchQuery: searchQuery,
19914
20615
  activeOptionIndex: match
19915
20616
  });
@@ -19917,11 +20618,11 @@ var ActionTypes$1;
19917
20618
  if (state.disabled) return state;
19918
20619
  if (state.listboxState === ListboxStates.Closed) return state;
19919
20620
  if (state.searchQuery === '') return state;
19920
- return _extends$d({}, state, {
20621
+ return _extends$f({}, state, {
19921
20622
  searchQuery: ''
19922
20623
  });
19923
20624
  }, _reducers$1[ActionTypes$1.RegisterOption] = function (state, action) {
19924
- return _extends$d({}, state, {
20625
+ return _extends$f({}, state, {
19925
20626
  options: [].concat(state.options, [{
19926
20627
  id: action.id,
19927
20628
  dataRef: action.dataRef
@@ -19934,7 +20635,7 @@ var ActionTypes$1;
19934
20635
  return a.id === action.id;
19935
20636
  });
19936
20637
  if (idx !== -1) nextOptions.splice(idx, 1);
19937
- return _extends$d({}, state, {
20638
+ return _extends$f({}, state, {
19938
20639
  options: nextOptions,
19939
20640
  activeOptionIndex: function () {
19940
20641
  if (idx === state.activeOptionIndex) return null;
@@ -19995,18 +20696,18 @@ const getPaymentCardIcon = name => {
19995
20696
  }));
19996
20697
  };
19997
20698
 
19998
- var _path$b;
20699
+ var _path$d;
19999
20700
 
20000
- function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
20701
+ function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
20001
20702
 
20002
20703
  function SvgChevronRight(props) {
20003
- return /*#__PURE__*/React.createElement("svg", _extends$c({
20704
+ return /*#__PURE__*/React.createElement("svg", _extends$e({
20004
20705
  className: "plc-w-6 plc-h-6",
20005
20706
  xmlns: "http://www.w3.org/2000/svg",
20006
20707
  fill: "none",
20007
20708
  viewBox: "0 0 24 24",
20008
20709
  stroke: "currentColor"
20009
- }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
20710
+ }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
20010
20711
  strokeLinecap: "round",
20011
20712
  strokeLinejoin: "round",
20012
20713
  strokeWidth: 2,
@@ -20049,7 +20750,6 @@ const OrderItems = ({
20049
20750
  const {
20050
20751
  t
20051
20752
  } = useTranslation("dashboard");
20052
- const site = window.Pelcro.site.read();
20053
20753
  return !(orders !== null && orders !== void 0 && orders.length) ? /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20054
20754
  colSpan: "3",
20055
20755
  className: "plc-text-center plc-text-gray-500"
@@ -20065,7 +20765,7 @@ const OrderItems = ({
20065
20765
  className: "plc-py-4 plc-pl-2"
20066
20766
  }, /*#__PURE__*/React__default.createElement("span", {
20067
20767
  className: "plc-text-xl plc-font-semibold "
20068
- }, getFormattedPriceByLocal(order.amount, order.currency, site.default_locale)), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20768
+ }, getFormattedPriceByLocal(order.amount, order.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20069
20769
  className: "plc-text-xs plc-text-gray-400 plc-uppercase"
20070
20770
  }, t("labels.orders.itemsAmount", {
20071
20771
  count: getItemsAmount(order.id)
@@ -20094,7 +20794,7 @@ const OrderItems = ({
20094
20794
  className: ""
20095
20795
  }, item.product_sku_name))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
20096
20796
  className: "plc-font-semibold"
20097
- }, getFormattedPriceByLocal(item.amount, order.currency, site.default_locale))));
20797
+ }, getFormattedPriceByLocal(item.amount, order.currency, getPageOrDefaultLanguage()))));
20098
20798
  }), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20099
20799
  colSpan: "3"
20100
20800
  }, /*#__PURE__*/React__default.createElement("hr", {
@@ -20223,33 +20923,291 @@ const SavedItems = ({
20223
20923
  });
20224
20924
  };
20225
20925
 
20226
- /**
20227
- * @typedef {Object} AccordionPropsType
20228
- * @property {string} initialActiveMenu the initial active menu
20229
- */
20230
-
20231
- /**
20232
- * Accordion component
20233
- * @param {AccordionPropsType} AccordionProps
20234
- * @return {JSX}
20235
- */
20926
+ var _path$c;
20236
20927
 
20237
- const Accordion = ({
20238
- children,
20239
- initialActiveMenu = ""
20240
- }) => {
20241
- const [activeMenu, setActiveMenu] = useState(initialActiveMenu);
20928
+ function _extends$d() { _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
20242
20929
 
20243
- const toggleActiveMenu = menuToToggle => {
20244
- if (activeMenu === menuToToggle) {
20245
- setActiveMenu("");
20246
- } else {
20247
- setActiveMenu(menuToToggle);
20248
- }
20249
- };
20930
+ function SvgRefresh(props) {
20931
+ return /*#__PURE__*/React.createElement("svg", _extends$d({
20932
+ className: "plc-w-4 plc-h-4 plc-mr-1",
20933
+ xmlns: "http://www.w3.org/2000/svg",
20934
+ fill: "none",
20935
+ viewBox: "0 0 24 24",
20936
+ stroke: "currentColor"
20937
+ }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
20938
+ strokeLinecap: "round",
20939
+ strokeLinejoin: "round",
20940
+ strokeWidth: 2,
20941
+ d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
20942
+ })));
20943
+ }
20944
+
20945
+ var _path$b;
20946
+
20947
+ function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
20948
+
20949
+ function SvgCalendar(props) {
20950
+ return /*#__PURE__*/React.createElement("svg", _extends$c({
20951
+ xmlns: "http://www.w3.org/2000/svg",
20952
+ className: "plc-h-4 plc-w-4 plc-mr-1",
20953
+ viewBox: "0 0 20 20",
20954
+ fill: "currentColor"
20955
+ }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
20956
+ fillRule: "evenodd",
20957
+ d: "M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",
20958
+ clipRule: "evenodd"
20959
+ })));
20960
+ }
20961
+
20962
+ var _path$a;
20963
+
20964
+ function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
20965
+
20966
+ function SvgPlus(props) {
20967
+ return /*#__PURE__*/React.createElement("svg", _extends$b({
20968
+ className: "plc-w-5 plc-h-5",
20969
+ xmlns: "http://www.w3.org/2000/svg",
20970
+ fill: "none",
20971
+ viewBox: "0 0 24 24",
20972
+ stroke: "currentColor"
20973
+ }, props), _path$a || (_path$a = /*#__PURE__*/React.createElement("path", {
20974
+ strokeLinecap: "round",
20975
+ strokeLinejoin: "round",
20976
+ strokeWidth: 2,
20977
+ d: "M12 6v6m0 0v6m0-6h6m-6 0H6"
20978
+ })));
20979
+ }
20980
+
20981
+ var _path$9;
20982
+
20983
+ function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
20984
+
20985
+ function SvgCheckMark(props) {
20986
+ return /*#__PURE__*/React.createElement("svg", _extends$a({
20987
+ className: "plc-w-4 plc-h-4 plc-mr-1",
20988
+ xmlns: "http://www.w3.org/2000/svg",
20989
+ viewBox: "0 0 20 20",
20990
+ fill: "currentColor"
20991
+ }, props), _path$9 || (_path$9 = /*#__PURE__*/React.createElement("path", {
20992
+ fillRule: "evenodd",
20993
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
20994
+ clipRule: "evenodd"
20995
+ })));
20996
+ }
20997
+
20998
+ const SubscriptionsMenu = props => {
20999
+ const {
21000
+ t
21001
+ } = useTranslation("dashboard");
21002
+ return /*#__PURE__*/React__default.createElement("table", {
21003
+ className: "plc-w-full plc-table-fixed"
21004
+ }, /*#__PURE__*/React__default.createElement("thead", {
21005
+ className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
21006
+ }, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
21007
+ className: "plc-w-3/12 "
21008
+ }, t("labels.plan")), /*#__PURE__*/React__default.createElement("th", {
21009
+ className: "plc-w-4/12 "
21010
+ }, t("labels.status.title")), /*#__PURE__*/React__default.createElement("th", {
21011
+ className: "plc-w-3/12 "
21012
+ }, t("labels.actions")), /*#__PURE__*/React__default.createElement("th", {
21013
+ className: "plc-w-2/12 "
21014
+ }))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
21015
+ className: "plc-h-4"
21016
+ })), /*#__PURE__*/React__default.createElement(Accordion, null, /*#__PURE__*/React__default.createElement(SubscriptionsItems, props)), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
21017
+ colSpan: "4",
21018
+ className: "plc-p-1"
21019
+ }, /*#__PURE__*/React__default.createElement(Button, {
21020
+ variant: "ghost",
21021
+ icon: /*#__PURE__*/React__default.createElement(SvgPlus, {
21022
+ className: "plc-w-4 plc-h-4 plc-mr-1"
21023
+ }),
21024
+ className: "plc-w-full plc-h-8 plc-font-semibold plc-tracking-wider plc-text-gray-900 plc-uppercase plc-rounded-none hover:plc-bg-gray-100",
21025
+ onClick: props.displayProductSelect
21026
+ }, t("labels.addSubscription")))), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
21027
+ colSpan: "4",
21028
+ className: "plc-p-1"
21029
+ }, /*#__PURE__*/React__default.createElement(Button, {
21030
+ variant: "ghost",
21031
+ icon: /*#__PURE__*/React__default.createElement(SvgGift, {
21032
+ className: "plc-w-4 plc-h-4 plc-mr-1"
21033
+ }),
21034
+ className: "plc-w-full plc-h-8 plc-font-semibold plc-tracking-wider plc-text-gray-900 plc-uppercase plc-rounded-none hover:plc-bg-gray-100",
21035
+ onClick: props.displayRedeem
21036
+ }, t("labels.redeemGift"))))));
21037
+ };
21038
+ const SubscriptionsItems = ({
21039
+ onClose,
21040
+ cancelSubscription,
21041
+ reactivateSubscription,
21042
+ setProductAndPlan,
21043
+ setSubscriptionIdToRenew,
21044
+ setView,
21045
+ getSubscriptionStatus,
21046
+ disableSubmit,
21047
+ activeMenu,
21048
+ toggleActiveMenu
21049
+ }) => {
21050
+ const {
21051
+ t
21052
+ } = useTranslation("dashboard");
21053
+ const subs = window.Pelcro.subscription.list();
21054
+ if (!subs || subs.length === 0) return null;
21055
+ return window.Pelcro.subscription.list().sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
21056
+ const isActive = activeMenu === sub.id; // Cancel button click handlers
21057
+
21058
+ const onCancelClick = () => {
21059
+ onClose === null || onClose === void 0 ? void 0 : onClose();
21060
+ notify.confirm((onSuccess, onFailure) => {
21061
+ cancelSubscription(sub.id, onSuccess, onFailure);
21062
+ }, {
21063
+ confirmMessage: t("messages.subCancellation.isSureToCancel"),
21064
+ loadingMessage: t("messages.subCancellation.loading"),
21065
+ successMessage: t("messages.subCancellation.success"),
21066
+ errorMessage: t("messages.subCancellation.error")
21067
+ }, {
21068
+ closeButtonLabel: t("labels.subCancellation.goBack")
21069
+ });
21070
+ }; // Reactivate button click handlers
21071
+
21072
+
21073
+ const onReactivateClick = () => {
21074
+ reactivateSubscription(sub.id);
21075
+ }; // Renew click
21076
+
21077
+
21078
+ const onRenewClick = () => {
21079
+ const product_id = sub.plan.product.id;
21080
+ const plan_id = sub.plan.id;
21081
+ const product = window.Pelcro.product.getById(product_id);
21082
+ const plan = window.Pelcro.plan.getById(plan_id);
21083
+ setProductAndPlan(product, plan);
21084
+ setSubscriptionIdToRenew(sub.id);
21085
+ setView("plan-select");
21086
+ };
21087
+
21088
+ const getPhases = () => {
21089
+ if (!sub.schedule) return [];
21090
+ const currentPhaseStartDate = sub.schedule.current_phase.start_date;
21091
+ const currentPhase = sub.schedule.phases.find(phase => {
21092
+ return phase.start_date === currentPhaseStartDate;
21093
+ });
21094
+ const futurePhases = sub.schedule.phases.filter(phase => {
21095
+ return phase.start_date > currentPhaseStartDate;
21096
+ });
21097
+ return [currentPhase, ...futurePhases];
21098
+ };
21099
+
21100
+ const hasPhases = getPhases().length > 0;
21101
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
21102
+ key: sub.id
21103
+ }, /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
21104
+ onClick: () => toggleActiveMenu(sub.id),
21105
+ key: sub.id,
21106
+ className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header ${isActive ? "plc-bg-gray-100" : "hover:plc-bg-gray-50"}`
21107
+ }, /*#__PURE__*/React__default.createElement("td", {
21108
+ className: "plc-truncate"
21109
+ }, sub.plan.nickname && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
21110
+ className: "plc-font-semibold plc-text-gray-500"
21111
+ }, sub.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
21112
+ className: "plc-text-xs plc-text-gray-400"
21113
+ }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("td", {
21114
+ className: "plc-py-2"
21115
+ }, /*#__PURE__*/React__default.createElement("span", {
21116
+ className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getSubscriptionStatus(sub).bgColor} plc-uppercase ${getSubscriptionStatus(sub).textColor} plc-rounded-lg`
21117
+ }, getSubscriptionStatus(sub).icon, getSubscriptionStatus(sub).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21118
+ className: "plc-text-xs plc-text-gray-500"
21119
+ }, sub.status && /*#__PURE__*/React__default.createElement("span", {
21120
+ className: "plc-inline-block plc-mt-1 plc-underline"
21121
+ }, getSubscriptionStatus(sub).content), /*#__PURE__*/React__default.createElement("br", null), sub.shipments_remaining ? /*#__PURE__*/React__default.createElement("span", {
21122
+ className: "plc-inline-block plc-mt-1"
21123
+ }, sub.shipments_remaining, " ", t("labels.shipments")) : null)), /*#__PURE__*/React__default.createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(Button, {
21124
+ variant: "ghost",
21125
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
21126
+ icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
21127
+ onClick: onCancelClick,
21128
+ disabled: disableSubmit,
21129
+ "data-key": sub.id
21130
+ }, t("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default.createElement(Button, {
21131
+ variant: "ghost",
21132
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
21133
+ icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
21134
+ onClick: onReactivateClick,
21135
+ disabled: disableSubmit,
21136
+ "data-key": sub.id
21137
+ }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default.createElement(Button, {
21138
+ variant: "ghost",
21139
+ className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
21140
+ icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
21141
+ onClick: onRenewClick,
21142
+ disabled: disableSubmit,
21143
+ "data-key": sub.id
21144
+ }, t("labels.renew"))), /*#__PURE__*/React__default.createElement("td", null, hasPhases && /*#__PURE__*/React__default.createElement("div", {
21145
+ className: `plc-flex plc-items-center plc-justify-center plc-transition-transform plc-ease-out plc-transform plc-rounded-full plc-w-7 plc-h-7 ${isActive ? "plc-flex plc-place-items-center plc-w-7 plc-h-7 plc-p-1 plc-bg-primary-400 plc-rounded-full" : "accordion-chevron"}`
21146
+ }, /*#__PURE__*/React__default.createElement("span", {
21147
+ className: `plc-transition plc-ease-out ${isActive && "plc-text-white plc-transform plc-rotate-90"}`
21148
+ }, /*#__PURE__*/React__default.createElement(SvgChevronRight, null)))))), /*#__PURE__*/React__default.createElement("tbody", null, isActive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, getPhases().map((phase, i) => {
21149
+ var _phase$plans;
21150
+
21151
+ const plan = (_phase$plans = phase.plans) === null || _phase$plans === void 0 ? void 0 : _phase$plans[0].plan;
21152
+ const isCurrentPhase = i === 0;
21153
+ const startDate = new Date(Number(`${phase.start_date}000`));
21154
+ const endDate = new Date(Number(`${phase.end_date}000`));
21155
+ const formattedStartDate = new Intl.DateTimeFormat("en-CA").format(startDate);
21156
+ const formattedEndDate = new Intl.DateTimeFormat("en-CA").format(endDate);
21157
+ const startDateString = `${t("labels.startsOn")} ${formattedStartDate}`;
21158
+ const endDateString = `${t("labels.expiresOn")} ${formattedEndDate}`;
21159
+ return /*#__PURE__*/React__default.createElement("tr", {
21160
+ key: `${phase.start_date}-${phase.end_date}`,
21161
+ className: "pelcro-sub-phase-row plc-w-full plc-align-middle"
21162
+ }, /*#__PURE__*/React__default.createElement("td", {
21163
+ className: "plc-truncate"
21164
+ }, plan.nickname && /*#__PURE__*/React__default.createElement("span", {
21165
+ className: "plc-font-semibold plc-text-gray-500"
21166
+ }, plan.nickname)), /*#__PURE__*/React__default.createElement("td", {
21167
+ className: "plc-py-2"
21168
+ }, /*#__PURE__*/React__default.createElement("span", {
21169
+ className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold plc-uppercase plc-rounded-lg ${isCurrentPhase ? "plc-text-green-700 plc-bg-green-100" : "plc-text-blue-700 plc-bg-blue-100"}
21170
+ `
21171
+ }, isCurrentPhase ? /*#__PURE__*/React__default.createElement(SvgCheckMark, null) : /*#__PURE__*/React__default.createElement(SvgCalendar, null), isCurrentPhase ? t("labels.status.active") : t("labels.status.scheduled")), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
21172
+ className: "plc-text-xs plc-text-gray-500"
21173
+ }, /*#__PURE__*/React__default.createElement("span", {
21174
+ className: "plc-inline-block plc-mt-1 plc-underline"
21175
+ }, isCurrentPhase ? endDateString : startDateString))));
21176
+ }), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
21177
+ colSpan: "4"
21178
+ }, /*#__PURE__*/React__default.createElement("hr", {
21179
+ className: "plc-mt-4"
21180
+ }))))));
21181
+ });
21182
+ };
21183
+
21184
+ /**
21185
+ * @typedef {Object} AccordionPropsType
21186
+ * @property {string} initialActiveMenu the initial active menu
21187
+ */
21188
+
21189
+ /**
21190
+ * Accordion component
21191
+ * @param {AccordionPropsType} AccordionProps
21192
+ * @return {JSX}
21193
+ */
21194
+
21195
+ const Accordion = ({
21196
+ children,
21197
+ initialActiveMenu = ""
21198
+ }) => {
21199
+ const [activeMenu, setActiveMenu] = useState(initialActiveMenu);
21200
+
21201
+ const toggleActiveMenu = menuToToggle => {
21202
+ if (activeMenu === menuToToggle) {
21203
+ setActiveMenu("");
21204
+ } else {
21205
+ setActiveMenu(menuToToggle);
21206
+ }
21207
+ };
20250
21208
 
20251
21209
  return React__default.Children.map(children, (child, i) => {
20252
- if (child.type === Accordion.item || child.type === OrderItems || child.type === SavedItems) {
21210
+ if (child.type === Accordion.item || child.type === OrderItems || child.type === SavedItems || child.type === SubscriptionsItems) {
20253
21211
  return /*#__PURE__*/React__default.cloneElement(child, {
20254
21212
  activeMenu,
20255
21213
  toggleActiveMenu,
@@ -20305,18 +21263,18 @@ Accordion.item = function AccordionItem({
20305
21263
  }, content)) : null;
20306
21264
  };
20307
21265
 
20308
- var _path$a;
21266
+ var _path$8;
20309
21267
 
20310
- function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
21268
+ function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
20311
21269
 
20312
21270
  function SvgExit(props) {
20313
- return /*#__PURE__*/React.createElement("svg", _extends$b({
21271
+ return /*#__PURE__*/React.createElement("svg", _extends$9({
20314
21272
  className: "plc-w-6 plc-h-6",
20315
21273
  xmlns: "http://www.w3.org/2000/svg",
20316
21274
  fill: "none",
20317
21275
  viewBox: "0 0 24 24",
20318
21276
  stroke: "currentColor"
20319
- }, props), _path$a || (_path$a = /*#__PURE__*/React.createElement("path", {
21277
+ }, props), _path$8 || (_path$8 = /*#__PURE__*/React.createElement("path", {
20320
21278
  strokeLinecap: "round",
20321
21279
  strokeLinejoin: "round",
20322
21280
  strokeWidth: 2,
@@ -20324,34 +21282,17 @@ function SvgExit(props) {
20324
21282
  })));
20325
21283
  }
20326
21284
 
20327
- var _path$9;
20328
-
20329
- function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
20330
-
20331
- function SvgCheckMark(props) {
20332
- return /*#__PURE__*/React.createElement("svg", _extends$a({
20333
- className: "plc-w-4 plc-h-4 plc-mr-1",
20334
- xmlns: "http://www.w3.org/2000/svg",
20335
- viewBox: "0 0 20 20",
20336
- fill: "currentColor"
20337
- }, props), _path$9 || (_path$9 = /*#__PURE__*/React.createElement("path", {
20338
- fillRule: "evenodd",
20339
- d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
20340
- clipRule: "evenodd"
20341
- })));
20342
- }
20343
-
20344
- var _path$8;
21285
+ var _path$7;
20345
21286
 
20346
- function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
21287
+ function _extends$8() { _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
20347
21288
 
20348
21289
  function SvgUser(props) {
20349
- return /*#__PURE__*/React.createElement("svg", _extends$9({
21290
+ return /*#__PURE__*/React.createElement("svg", _extends$8({
20350
21291
  xmlns: "http://www.w3.org/2000/svg",
20351
21292
  fill: "none",
20352
21293
  viewBox: "0 0 24 24",
20353
21294
  stroke: "currentColor"
20354
- }, props), _path$8 || (_path$8 = /*#__PURE__*/React.createElement("path", {
21295
+ }, props), _path$7 || (_path$7 = /*#__PURE__*/React.createElement("path", {
20355
21296
  strokeLinecap: "round",
20356
21297
  strokeLinejoin: "round",
20357
21298
  strokeWidth: 2,
@@ -20359,37 +21300,37 @@ function SvgUser(props) {
20359
21300
  })));
20360
21301
  }
20361
21302
 
20362
- var _path$7;
21303
+ var _path$6;
20363
21304
 
20364
- function _extends$8() { _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
21305
+ function _extends$7() { _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
20365
21306
 
20366
- function SvgRefresh(props) {
20367
- return /*#__PURE__*/React.createElement("svg", _extends$8({
20368
- className: "plc-w-4 plc-h-4 plc-mr-1",
21307
+ function SvgNewsletter(props) {
21308
+ return /*#__PURE__*/React.createElement("svg", _extends$7({
20369
21309
  xmlns: "http://www.w3.org/2000/svg",
21310
+ className: "plc-h-5 plc-w-5",
20370
21311
  fill: "none",
20371
21312
  viewBox: "0 0 24 24",
20372
21313
  stroke: "currentColor"
20373
- }, props), _path$7 || (_path$7 = /*#__PURE__*/React.createElement("path", {
21314
+ }, props), _path$6 || (_path$6 = /*#__PURE__*/React.createElement("path", {
20374
21315
  strokeLinecap: "round",
20375
21316
  strokeLinejoin: "round",
20376
21317
  strokeWidth: 2,
20377
- d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
21318
+ d: "M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"
20378
21319
  })));
20379
21320
  }
20380
21321
 
20381
- var _path$6;
21322
+ var _path$5;
20382
21323
 
20383
- function _extends$7() { _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
21324
+ function _extends$6() { _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
20384
21325
 
20385
21326
  function SvgPaymentCard(props) {
20386
- return /*#__PURE__*/React.createElement("svg", _extends$7({
21327
+ return /*#__PURE__*/React.createElement("svg", _extends$6({
20387
21328
  className: "plc-w-6 plc-h-6 plc-mr-2",
20388
21329
  xmlns: "http://www.w3.org/2000/svg",
20389
21330
  fill: "none",
20390
21331
  viewBox: "0 0 24 24",
20391
21332
  stroke: "currentColor"
20392
- }, props), _path$6 || (_path$6 = /*#__PURE__*/React.createElement("path", {
21333
+ }, props), _path$5 || (_path$5 = /*#__PURE__*/React.createElement("path", {
20393
21334
  strokeLinecap: "round",
20394
21335
  strokeLinejoin: "round",
20395
21336
  strokeWidth: 2,
@@ -20397,18 +21338,18 @@ function SvgPaymentCard(props) {
20397
21338
  })));
20398
21339
  }
20399
21340
 
20400
- var _path$5, _path2;
21341
+ var _path$4, _path2;
20401
21342
 
20402
- function _extends$6() { _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
21343
+ function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
20403
21344
 
20404
21345
  function SvgLocationPin(props) {
20405
- return /*#__PURE__*/React.createElement("svg", _extends$6({
21346
+ return /*#__PURE__*/React.createElement("svg", _extends$5({
20406
21347
  className: "plc-w-6 plc-h-6 plc-mr-2",
20407
21348
  xmlns: "http://www.w3.org/2000/svg",
20408
21349
  fill: "none",
20409
21350
  viewBox: "0 0 24 24",
20410
21351
  stroke: "currentColor"
20411
- }, props), _path$5 || (_path$5 = /*#__PURE__*/React.createElement("path", {
21352
+ }, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
20412
21353
  strokeLinecap: "round",
20413
21354
  strokeLinejoin: "round",
20414
21355
  strokeWidth: 2,
@@ -20423,10 +21364,10 @@ function SvgLocationPin(props) {
20423
21364
 
20424
21365
  var _switch;
20425
21366
 
20426
- function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
21367
+ function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
20427
21368
 
20428
21369
  function SvgSubscription(props) {
20429
- return /*#__PURE__*/React.createElement("svg", _extends$5({
21370
+ return /*#__PURE__*/React.createElement("svg", _extends$4({
20430
21371
  xmlns: "http://www.w3.org/2000/svg",
20431
21372
  viewBox: "0 0 100 125",
20432
21373
  fill: "currentColor"
@@ -20441,30 +21382,11 @@ function SvgSubscription(props) {
20441
21382
  }))))));
20442
21383
  }
20443
21384
 
20444
- var _path$4;
20445
-
20446
- function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
20447
-
20448
- function SvgShopping(props) {
20449
- return /*#__PURE__*/React.createElement("svg", _extends$4({
20450
- className: "plc-w-6 plc-h-6 plc-mr-2",
20451
- xmlns: "http://www.w3.org/2000/svg",
20452
- fill: "none",
20453
- viewBox: "0 0 24 24",
20454
- stroke: "currentColor"
20455
- }, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
20456
- strokeLinecap: "round",
20457
- strokeLinejoin: "round",
20458
- strokeWidth: 2,
20459
- d: "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"
20460
- })));
20461
- }
20462
-
20463
21385
  var _path$3;
20464
21386
 
20465
21387
  function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
20466
21388
 
20467
- function SvgBookmark(props) {
21389
+ function SvgShopping(props) {
20468
21390
  return /*#__PURE__*/React.createElement("svg", _extends$3({
20469
21391
  className: "plc-w-6 plc-h-6 plc-mr-2",
20470
21392
  xmlns: "http://www.w3.org/2000/svg",
@@ -20475,7 +21397,7 @@ function SvgBookmark(props) {
20475
21397
  strokeLinecap: "round",
20476
21398
  strokeLinejoin: "round",
20477
21399
  strokeWidth: 2,
20478
- d: "M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
21400
+ d: "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"
20479
21401
  })));
20480
21402
  }
20481
21403
 
@@ -20483,9 +21405,9 @@ var _path$2;
20483
21405
 
20484
21406
  function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
20485
21407
 
20486
- function SvgPlus(props) {
21408
+ function SvgBookmark(props) {
20487
21409
  return /*#__PURE__*/React.createElement("svg", _extends$2({
20488
- className: "plc-w-5 plc-h-5",
21410
+ className: "plc-w-6 plc-h-6 plc-mr-2",
20489
21411
  xmlns: "http://www.w3.org/2000/svg",
20490
21412
  fill: "none",
20491
21413
  viewBox: "0 0 24 24",
@@ -20494,7 +21416,7 @@ function SvgPlus(props) {
20494
21416
  strokeLinecap: "round",
20495
21417
  strokeLinejoin: "round",
20496
21418
  strokeWidth: 2,
20497
- d: "M12 6v6m0 0v6m0-6h6m-6 0H6"
21419
+ d: "M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
20498
21420
  })));
20499
21421
  }
20500
21422
 
@@ -20594,6 +21516,24 @@ class Dashboard extends Component {
20594
21516
  });
20595
21517
  });
20596
21518
 
21519
+ _defineProperty$3(this, "componentWillUnmount", () => {
21520
+ document.removeEventListener("click", this.hideMenuIfClickedOutside);
21521
+ });
21522
+
21523
+ _defineProperty$3(this, "initializeHideMenuHandler", () => {
21524
+ document.addEventListener("click", this.hideMenuIfClickedOutside);
21525
+ });
21526
+
21527
+ _defineProperty$3(this, "hideMenuIfClickedOutside", event => {
21528
+ const didClickOutsideMenu = this.state.isOpen && this.menuRef.current && !this.menuRef.current.contains(event.target);
21529
+
21530
+ if (didClickOutsideMenu) {
21531
+ this.setState({
21532
+ isOpen: false
21533
+ });
21534
+ }
21535
+ });
21536
+
20597
21537
  _defineProperty$3(this, "cancelSubscription", (subscription_id, onSuccess, onFailure) => {
20598
21538
  // disable the Login button to prevent repeated clicks
20599
21539
  window.Pelcro.subscription.cancel({
@@ -20631,6 +21571,10 @@ class Dashboard extends Component {
20631
21571
  return this.props.setView("password-change");
20632
21572
  });
20633
21573
 
21574
+ _defineProperty$3(this, "displayNewsletterUpdate", () => {
21575
+ return this.props.setView("newsletter-update");
21576
+ });
21577
+
20634
21578
  _defineProperty$3(this, "displayProductSelect", ({
20635
21579
  isGift
20636
21580
  }) => {
@@ -20736,116 +21680,6 @@ class Dashboard extends Component {
20736
21680
  };
20737
21681
  });
20738
21682
 
20739
- _defineProperty$3(this, "renderSubscriptions", () => {
20740
- var _this$state$subscript;
20741
-
20742
- const subscriptions = (_this$state$subscript = this.state.subscriptions) === null || _this$state$subscript === void 0 ? void 0 : _this$state$subscript.sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
20743
- // Cancel button click handlers
20744
- const onCancelClick = () => {
20745
- this.props.onClose();
20746
- notify.confirm((onSuccess, onFailure) => {
20747
- this.cancelSubscription(sub.id, onSuccess, onFailure);
20748
- }, {
20749
- confirmMessage: this.locale("messages.subCancellation.isSureToCancel"),
20750
- loadingMessage: this.locale("messages.subCancellation.loading"),
20751
- successMessage: this.locale("messages.subCancellation.success"),
20752
- errorMessage: this.locale("messages.subCancellation.error")
20753
- }, {
20754
- closeButtonLabel: this.locale("labels.subCancellation.goBack")
20755
- });
20756
- }; // Reactivate button click handlers
20757
-
20758
-
20759
- const onReactivateClick = () => {
20760
- this.reactivateSubscription(sub.id);
20761
- }; // Renew click
20762
-
20763
-
20764
- const onRenewClick = () => {
20765
- const product_id = sub.plan.product.id;
20766
- const plan_id = sub.plan.id;
20767
- const product = window.Pelcro.product.getById(product_id);
20768
- const plan = window.Pelcro.plan.getById(plan_id);
20769
- this.props.setProductAndPlan(product, plan);
20770
- this.props.setSubscriptionIdToRenew(sub.id);
20771
- this.props.setView("plan-select");
20772
- };
20773
-
20774
- return /*#__PURE__*/React__default.createElement("tr", {
20775
- key: "dashboard-subscription-" + sub.id,
20776
- className: "plc-w-full plc-align-top"
20777
- }, /*#__PURE__*/React__default.createElement("td", {
20778
- className: "plc-truncate"
20779
- }, sub.plan.nickname && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
20780
- className: "plc-font-semibold plc-text-gray-500"
20781
- }, sub.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20782
- className: "plc-text-xs plc-text-gray-400"
20783
- }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, this.site.default_locale)))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
20784
- className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(sub).bgColor} plc-uppercase ${this.getSubscriptionStatus(sub).textColor} plc-rounded-lg`
20785
- }, this.getSubscriptionStatus(sub).icon, this.getSubscriptionStatus(sub).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
20786
- className: "plc-mb-4 plc-text-xs plc-text-gray-500"
20787
- }, sub.status && /*#__PURE__*/React__default.createElement("span", {
20788
- className: "plc-inline-block plc-mt-1 plc-underline"
20789
- }, this.getSubscriptionStatus(sub).content), /*#__PURE__*/React__default.createElement("br", null), sub.shipments_remaining ? /*#__PURE__*/React__default.createElement("span", {
20790
- className: "plc-inline-block plc-mt-1"
20791
- }, sub.shipments_remaining, " ", this.locale("labels.shipments")) : null)), /*#__PURE__*/React__default.createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(Button, {
20792
- variant: "ghost",
20793
- className: "plc-text-red-500 focus:plc-ring-red-500",
20794
- icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
20795
- onClick: onCancelClick,
20796
- disabled: this.state.disableSubmit,
20797
- "data-key": sub.id
20798
- }, this.locale("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default.createElement(Button, {
20799
- variant: "ghost",
20800
- className: "plc-text-green-400 focus:plc-ring-green-300",
20801
- icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
20802
- onClick: onReactivateClick,
20803
- disabled: this.state.disableSubmit,
20804
- "data-key": sub.id
20805
- }, this.locale("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default.createElement(Button, {
20806
- variant: "ghost",
20807
- className: "plc-text-blue-400",
20808
- icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
20809
- onClick: onRenewClick,
20810
- disabled: this.state.disableSubmit,
20811
- "data-key": sub.id
20812
- }, this.locale("labels.renew"))));
20813
- });
20814
- return /*#__PURE__*/React__default.createElement("table", {
20815
- className: "plc-w-full plc-table-fixed"
20816
- }, /*#__PURE__*/React__default.createElement("thead", {
20817
- className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
20818
- }, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
20819
- className: "plc-w-5/12 "
20820
- }, this.locale("labels.plan")), /*#__PURE__*/React__default.createElement("th", {
20821
- className: "plc-w-4/12 "
20822
- }, this.locale("labels.status.title")), /*#__PURE__*/React__default.createElement("th", {
20823
- className: "plc-w-3/12 "
20824
- }, this.locale("labels.actions")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
20825
- className: "plc-h-4"
20826
- }), subscriptions, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20827
- colSpan: "4",
20828
- className: "plc-p-1"
20829
- }, /*#__PURE__*/React__default.createElement(Button, {
20830
- variant: "ghost",
20831
- icon: /*#__PURE__*/React__default.createElement(SvgPlus, {
20832
- className: "plc-w-4 plc-h-4 plc-mr-1"
20833
- }),
20834
- className: "plc-w-full plc-h-8 plc-font-semibold plc-tracking-wider plc-text-gray-900 plc-uppercase plc-rounded-none hover:plc-bg-gray-100",
20835
- onClick: this.displayProductSelect
20836
- }, this.locale("labels.addSubscription")))), /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
20837
- colSpan: "4",
20838
- className: "plc-p-1"
20839
- }, /*#__PURE__*/React__default.createElement(Button, {
20840
- variant: "ghost",
20841
- icon: /*#__PURE__*/React__default.createElement(SvgGift, {
20842
- className: "plc-w-4 plc-h-4 plc-mr-1"
20843
- }),
20844
- className: "plc-w-full plc-h-8 plc-font-semibold plc-tracking-wider plc-text-gray-900 plc-uppercase plc-rounded-none hover:plc-bg-gray-100",
20845
- onClick: this.displayRedeem
20846
- }, this.locale("labels.redeemGift"))))));
20847
- });
20848
-
20849
21683
  _defineProperty$3(this, "renderGiftRecipients", () => {
20850
21684
  var _giftRecipients$sort, _giftRecipients$sort$;
20851
21685
 
@@ -20883,7 +21717,7 @@ class Dashboard extends Component {
20883
21717
  className: "plc-font-semibold plc-text-gray-500"
20884
21718
  }, recipient.plan.nickname), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
20885
21719
  className: "plc-text-xs plc-text-gray-400"
20886
- }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, this.site.default_locale)))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
21720
+ }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, getPageOrDefaultLanguage())))), recipient.status && /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("span", {
20887
21721
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${this.getSubscriptionStatus(recipient).bgColor} plc-uppercase ${this.getSubscriptionStatus(recipient).textColor} plc-rounded-lg`
20888
21722
  }, this.getSubscriptionStatus(recipient).icon, this.getSubscriptionStatus(recipient).title), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("div", {
20889
21723
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
@@ -20985,28 +21819,33 @@ class Dashboard extends Component {
20985
21819
  this.site = window.Pelcro.site.read();
20986
21820
  this.locale = this.props.t;
20987
21821
  this.user = window.Pelcro.user.read();
21822
+ this.menuRef = /*#__PURE__*/React__default.createRef();
20988
21823
  }
20989
21824
 
20990
21825
  render() {
20991
- var _window$Pelcro$user$r3, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
21826
+ var _window$Pelcro$user$r3, _window$Pelcro, _window$Pelcro$uiSett, _this$user$source, _this$user$source$pro, _this$user$source2, _this$user$source2$pr;
20992
21827
 
20993
21828
  const {
20994
21829
  isOpen
20995
21830
  } = this.state;
20996
21831
  const userHasName = this.user.first_name || this.user.last_name;
20997
21832
  const profilePicture = (_window$Pelcro$user$r3 = window.Pelcro.user.read().profile_photo) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : userSolidIcon;
21833
+ const newsletters = (_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.newsletters;
21834
+ const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
20998
21835
  return /*#__PURE__*/React__default.createElement(Transition, {
20999
21836
  className: "plc-fixed plc-inset-y-0 plc-right-0 plc-h-full plc-max-w-xl plc-overflow-y-auto plc-text-left plc-bg-white plc-shadow-xl plc-z-max",
21000
21837
  show: isOpen,
21001
21838
  enter: "plc-transform plc-transition plc-duration-500",
21002
21839
  enterFrom: "plc-translate-x-full",
21003
21840
  enterTo: "plc-translate-x-0",
21841
+ afterEnter: this.initializeHideMenuHandler,
21004
21842
  leave: "plc-transform plc-transition plc-duration-500",
21005
21843
  leaveFrom: "plc-translate-x-0",
21006
21844
  leaveTo: "plc-translate-x-full",
21007
21845
  afterLeave: this.props.onClose
21008
21846
  }, /*#__PURE__*/React__default.createElement("div", {
21009
- id: "pelcro-view-dashboard"
21847
+ id: "pelcro-view-dashboard",
21848
+ ref: this.menuRef
21010
21849
  }, /*#__PURE__*/React__default.createElement("header", {
21011
21850
  className: "plc-flex plc-flex-col plc-p-4 plc-pl-2 plc-min-h-40 sm:plc-pr-8 plc-bg-primary-500"
21012
21851
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -21069,7 +21908,14 @@ class Dashboard extends Component {
21069
21908
  }),
21070
21909
  className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21071
21910
  onClick: this.displayChangePassword
21072
- }, this.locale("labels.changePassword")))
21911
+ }, this.locale("labels.changePassword")), siteHasNewslettersDefined && /*#__PURE__*/React__default.createElement(Button, {
21912
+ variant: "ghost",
21913
+ icon: /*#__PURE__*/React__default.createElement(SvgNewsletter, {
21914
+ className: "plc-w-5 plc-h-5 plc-mr-1"
21915
+ }),
21916
+ className: "plc-text-sm plc-text-gray-500 hover:plc-text-primary-700",
21917
+ onClick: this.displayNewsletterUpdate
21918
+ }, this.locale("labels.editNewsletters")))
21073
21919
  }), /*#__PURE__*/React__default.createElement(Accordion.item, {
21074
21920
  name: SUB_MENUS.PAYMENT_CARDS,
21075
21921
  icon: /*#__PURE__*/React__default.createElement(SvgPaymentCard, null),
@@ -21108,7 +21954,18 @@ class Dashboard extends Component {
21108
21954
  className: "plc-w-10 plc-h-10 plc-pt-2 plc-pr-1 plc--ml-2"
21109
21955
  }),
21110
21956
  title: this.locale("labels.subscriptions"),
21111
- content: this.renderSubscriptions()
21957
+ content: /*#__PURE__*/React__default.createElement(SubscriptionsMenu, {
21958
+ onClose: this.props.onClose,
21959
+ cancelSubscription: this.cancelSubscription,
21960
+ reactivateSubscription: this.reactivateSubscription,
21961
+ setProductAndPlan: this.props.setProductAndPlan,
21962
+ setSubscriptionIdToRenew: this.props.setSubscriptionIdToRenew,
21963
+ setView: this.props.setView,
21964
+ getSubscriptionStatus: this.getSubscriptionStatus,
21965
+ disableSubmit: this.state.disableSubmit,
21966
+ displayProductSelect: this.displayProductSelect,
21967
+ displayRedeem: this.displayRedeem
21968
+ })
21112
21969
  }), /*#__PURE__*/React__default.createElement(Accordion.item, {
21113
21970
  name: SUB_MENUS.GIFTS,
21114
21971
  icon: /*#__PURE__*/React__default.createElement(SvgGift, null),
@@ -21145,7 +22002,7 @@ const DashboardOpenButton = () => {
21145
22002
  return /*#__PURE__*/React__default.createElement("div", {
21146
22003
  className: "plc-fixed plc-right-4 plc-bottom-4 pelcro-open-dashboard-btn"
21147
22004
  }, /*#__PURE__*/React__default.createElement("button", {
21148
- className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300",
22005
+ className: "plc-bg-white plc-border-2 plc-rounded-full focus:plc-outline-none plc-border-primary-300 hover:plc-bg-white",
21149
22006
  name: "menu",
21150
22007
  id: "pelcro-view-menu",
21151
22008
  onClick: () => switchView("dashboard")
@@ -22978,4 +23835,4 @@ function ProfilePicChangeModal({
22978
23835
  }
22979
23836
  ProfilePicChangeModal.viewId = "profile-picture";
22980
23837
 
22981
- export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, ApplyCouponButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, notify, unauthenticatedButtons, usePelcro };
23838
+ export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, notify, unauthenticatedButtons, usePelcro };