@pelcro/react-pelcro-js 2.6.0-beta.2 → 2.6.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -6327,13 +6327,34 @@ const getAddressById = id => {
6327
6327
  };
6328
6328
  /**
6329
6329
  * Transforms locale names stored in our backend like
6330
- * "en_US" into the standerd accepted in core i18n methods: "en-US"
6330
+ * "en_US" into the standard accepted in core i18n methods: "en-US"
6331
6331
  * @param {string} localeName
6332
6332
  * @return {string | undefined}
6333
6333
  * @example getCanonicalLocaleFormat("en_US") => "en-US"
6334
6334
  */
6335
6335
 
6336
6336
  const getCanonicalLocaleFormat = localeName => localeName === null || localeName === void 0 ? void 0 : localeName.replace("_", "-");
6337
+ /**
6338
+ * @param {string} localeName
6339
+ * @return {string | undefined}
6340
+ * @example getLanguageWithoutRegion("en-US") => "en"
6341
+ */
6342
+
6343
+ const getLanguageWithoutRegion = localeName => {
6344
+ var _getCanonicalLocaleFo;
6345
+
6346
+ return (_getCanonicalLocaleFo = getCanonicalLocaleFormat(localeName)) === null || _getCanonicalLocaleFo === void 0 ? void 0 : _getCanonicalLocaleFo.split("-")[0];
6347
+ };
6348
+ /**
6349
+ * Gets the current page language or fallbacks to site default
6350
+ * @return {string | undefined}
6351
+ */
6352
+
6353
+ const getPageOrDefaultLanguage = () => {
6354
+ var _window$Pelcro$helper, _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6355
+
6356
+ 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);
6357
+ };
6337
6358
  /**
6338
6359
  * Returns a formatted price string depending on locale
6339
6360
  * @param {number} amount
@@ -6343,7 +6364,7 @@ const getCanonicalLocaleFormat = localeName => localeName === null || localeName
6343
6364
  * @example getFormattedPriceByLocal(10, 'USD', 'en-US') => "$10.00"
6344
6365
  */
6345
6366
 
6346
- const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en-US") => {
6367
+ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6347
6368
  const formatter = new Intl.NumberFormat(getCanonicalLocaleFormat(locale), {
6348
6369
  style: "currency",
6349
6370
  currency
@@ -6368,8 +6389,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6368
6389
  totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6369
6390
  }
6370
6391
 
6371
- const locale = window.Pelcro.site.read().default_locale;
6372
- return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, locale);
6392
+ return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
6373
6393
  };
6374
6394
  /**
6375
6395
  * returns true if the URL contains a supported view trigger URL
@@ -6383,12 +6403,15 @@ const isValidViewFromURL = viewID => {
6383
6403
  }
6384
6404
 
6385
6405
  return false;
6406
+ /**
6407
+ *
6408
+ */
6386
6409
 
6387
6410
  function hasValidNewsletterUpdateUrl() {
6388
- var _window$Pelcro, _window$Pelcro$uiSett;
6411
+ var _window$Pelcro2, _window$Pelcro2$uiSet;
6389
6412
 
6390
6413
  if (viewID !== "newsletter-update") return false;
6391
- 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;
6414
+ 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;
6392
6415
  const siteHasNewslettersDefined = Array.isArray(newsletters) && newsletters.length > 0;
6393
6416
 
6394
6417
  if (!siteHasNewslettersDefined) {
@@ -6561,10 +6584,20 @@ const getPaymentCardIcon$1 = name => {
6561
6584
  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"
6562
6585
  }));
6563
6586
  };
6587
+ /**
6588
+ * Gets the current date with time set to 0
6589
+ * @param {Date} dateObject
6590
+ * @return {Date}
6591
+ */
6592
+
6593
+ function getDateWithoutTime(dateObject) {
6594
+ const date = new Date(dateObject.getTime());
6595
+ date.setHours(0, 0, 0, 0);
6596
+ return date;
6597
+ }
6564
6598
 
6565
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro$site$r, _window$Pelcro$site$r2;
6566
6599
  const resources = {
6567
- "en-US": {
6600
+ en: {
6568
6601
  common: common_en,
6569
6602
  paymentMethod: paymentMethod_en,
6570
6603
  newsletter: newsletter_en,
@@ -6586,7 +6619,7 @@ const resources = {
6586
6619
  select: select_en,
6587
6620
  notification: notification_en
6588
6621
  },
6589
- "fr-CA": {
6622
+ fr: {
6590
6623
  common: common_fr,
6591
6624
  paymentMethod: paymentMethod_fr,
6592
6625
  newsletter: newsletter_fr,
@@ -6608,13 +6641,14 @@ const resources = {
6608
6641
  select: select_fr,
6609
6642
  notification: notification_fr
6610
6643
  }
6611
- };
6612
- 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;
6613
- if (!locale) locale = "en-US";
6644
+ }; // set UI language to the page language or default to the language in site settings
6645
+
6646
+ const locale = getPageOrDefaultLanguage();
6614
6647
  i18next.use(initReactI18next) // passes i18n down to react-i18next,
6615
6648
  .init({
6616
6649
  resources,
6617
- lng: getCanonicalLocaleFormat(locale),
6650
+ lng: locale,
6651
+ fallbackLng: "en",
6618
6652
  // debug: true,
6619
6653
  interpolation: {
6620
6654
  escapeValue: false // react already safes from xss
@@ -6625,6 +6659,16 @@ i18next.use(initReactI18next) // passes i18n down to react-i18next,
6625
6659
 
6626
6660
  }
6627
6661
  });
6662
+ const pageLanguageObserver = new MutationObserver(mutationsList => {
6663
+ mutationsList.forEach(mutationRecord => {
6664
+ if (mutationRecord.attributeName === "lang") {
6665
+ i18next.changeLanguage(window.Pelcro.helpers.getHtmlLanguageAttribute());
6666
+ }
6667
+ });
6668
+ });
6669
+ pageLanguageObserver.observe(document.documentElement, {
6670
+ attributes: true
6671
+ });
6628
6672
 
6629
6673
  function _classPrivateFieldGet(receiver, privateMap) {
6630
6674
  var descriptor = privateMap.get(receiver);
@@ -8238,6 +8282,175 @@ function shouldBlurContent(entitlements) {
8238
8282
  return entitlements.every(entitlement => !window.Pelcro.user.isEntitledTo(entitlement));
8239
8283
  }
8240
8284
 
8285
+ var pure$1 = createCommonjsModule(function (module, exports) {
8286
+
8287
+ Object.defineProperty(exports, '__esModule', { value: true });
8288
+
8289
+ function _typeof(obj) {
8290
+ "@babel/helpers - typeof";
8291
+
8292
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
8293
+ _typeof = function (obj) {
8294
+ return typeof obj;
8295
+ };
8296
+ } else {
8297
+ _typeof = function (obj) {
8298
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8299
+ };
8300
+ }
8301
+
8302
+ return _typeof(obj);
8303
+ }
8304
+
8305
+ var V3_URL = 'https://js.stripe.com/v3';
8306
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
8307
+ 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';
8308
+ var findScript = function findScript() {
8309
+ var scripts = document.querySelectorAll("script[src^=\"".concat(V3_URL, "\"]"));
8310
+
8311
+ for (var i = 0; i < scripts.length; i++) {
8312
+ var script = scripts[i];
8313
+
8314
+ if (!V3_URL_REGEX.test(script.src)) {
8315
+ continue;
8316
+ }
8317
+
8318
+ return script;
8319
+ }
8320
+
8321
+ return null;
8322
+ };
8323
+
8324
+ var injectScript = function injectScript(params) {
8325
+ var queryString = params && !params.advancedFraudSignals ? '?advancedFraudSignals=false' : '';
8326
+ var script = document.createElement('script');
8327
+ script.src = "".concat(V3_URL).concat(queryString);
8328
+ var headOrBody = document.head || document.body;
8329
+
8330
+ if (!headOrBody) {
8331
+ throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
8332
+ }
8333
+
8334
+ headOrBody.appendChild(script);
8335
+ return script;
8336
+ };
8337
+
8338
+ var registerWrapper = function registerWrapper(stripe, startTime) {
8339
+ if (!stripe || !stripe._registerWrapper) {
8340
+ return;
8341
+ }
8342
+
8343
+ stripe._registerWrapper({
8344
+ name: 'stripe-js',
8345
+ version: "1.21.1",
8346
+ startTime: startTime
8347
+ });
8348
+ };
8349
+
8350
+ var stripePromise = null;
8351
+ var loadScript = function loadScript(params) {
8352
+ // Ensure that we only attempt to load Stripe.js at most once
8353
+ if (stripePromise !== null) {
8354
+ return stripePromise;
8355
+ }
8356
+
8357
+ stripePromise = new Promise(function (resolve, reject) {
8358
+ if (typeof window === 'undefined') {
8359
+ // Resolve to null when imported server side. This makes the module
8360
+ // safe to import in an isomorphic code base.
8361
+ resolve(null);
8362
+ return;
8363
+ }
8364
+
8365
+ if (window.Stripe && params) {
8366
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8367
+ }
8368
+
8369
+ if (window.Stripe) {
8370
+ resolve(window.Stripe);
8371
+ return;
8372
+ }
8373
+
8374
+ try {
8375
+ var script = findScript();
8376
+
8377
+ if (script && params) {
8378
+ console.warn(EXISTING_SCRIPT_MESSAGE);
8379
+ } else if (!script) {
8380
+ script = injectScript(params);
8381
+ }
8382
+
8383
+ script.addEventListener('load', function () {
8384
+ if (window.Stripe) {
8385
+ resolve(window.Stripe);
8386
+ } else {
8387
+ reject(new Error('Stripe.js not available'));
8388
+ }
8389
+ });
8390
+ script.addEventListener('error', function () {
8391
+ reject(new Error('Failed to load Stripe.js'));
8392
+ });
8393
+ } catch (error) {
8394
+ reject(error);
8395
+ return;
8396
+ }
8397
+ });
8398
+ return stripePromise;
8399
+ };
8400
+ var initStripe = function initStripe(maybeStripe, args, startTime) {
8401
+ if (maybeStripe === null) {
8402
+ return null;
8403
+ }
8404
+
8405
+ var stripe = maybeStripe.apply(undefined, args);
8406
+ registerWrapper(stripe, startTime);
8407
+ return stripe;
8408
+ };
8409
+ var validateLoadParams = function validateLoadParams(params) {
8410
+ var errorMessage = "invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(params), "\n");
8411
+
8412
+ if (params === null || _typeof(params) !== 'object') {
8413
+ throw new Error(errorMessage);
8414
+ }
8415
+
8416
+ if (Object.keys(params).length === 1 && typeof params.advancedFraudSignals === 'boolean') {
8417
+ return params;
8418
+ }
8419
+
8420
+ throw new Error(errorMessage);
8421
+ };
8422
+
8423
+ var loadParams;
8424
+ var loadStripeCalled = false;
8425
+ var loadStripe = function loadStripe() {
8426
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8427
+ args[_key] = arguments[_key];
8428
+ }
8429
+
8430
+ loadStripeCalled = true;
8431
+ var startTime = Date.now();
8432
+ return loadScript(loadParams).then(function (maybeStripe) {
8433
+ return initStripe(maybeStripe, args, startTime);
8434
+ });
8435
+ };
8436
+
8437
+ loadStripe.setLoadParameters = function (params) {
8438
+ if (loadStripeCalled) {
8439
+ throw new Error('You cannot change load parameters after calling loadStripe');
8440
+ }
8441
+
8442
+ loadParams = validateLoadParams(params);
8443
+ };
8444
+
8445
+ exports.loadStripe = loadStripe;
8446
+ });
8447
+
8448
+ unwrapExports(pure$1);
8449
+ pure$1.loadStripe;
8450
+
8451
+ var pure = pure$1;
8452
+ var pure_1 = pure.loadStripe;
8453
+
8241
8454
  /**
8242
8455
  * @typedef {Object} OptionsType
8243
8456
  * @property {boolean} loadPaymentSDKs
@@ -8263,6 +8476,7 @@ const optionsController = options => {
8263
8476
  enableURLTriggers: initViewFromURL,
8264
8477
  enableTheme: applyPelcroTheme,
8265
8478
  enablePaywalls: initPaywalls,
8479
+ loadSecuritySDK: initSecuritySdk,
8266
8480
  enableGoogleAnalytics: initGATracking
8267
8481
  }; // Only execute enabled options
8268
8482
 
@@ -8307,8 +8521,15 @@ const initPaywalls = () => {
8307
8521
  }
8308
8522
  };
8309
8523
  const loadPaymentSDKs = () => {
8310
- // Load stripe's SDK
8311
- window.Pelcro.helpers.loadSDK("https://js.stripe.com/v3/", "pelcro-sdk-stripe-id"); // Load PayPal SDK's
8524
+ // Lazy load stripe's SDK
8525
+ const {
8526
+ whenUserReady
8527
+ } = usePelcro.getStore();
8528
+ whenUserReady(() => {
8529
+ if (!window.Stripe) {
8530
+ pure_1(window.Pelcro.environment.stripe);
8531
+ }
8532
+ }); // Load PayPal SDK's
8312
8533
 
8313
8534
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
8314
8535
 
@@ -8317,6 +8538,18 @@ const loadPaymentSDKs = () => {
8317
8538
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8318
8539
  }
8319
8540
  };
8541
+ const initSecuritySdk = () => {
8542
+ const {
8543
+ whenSiteReady
8544
+ } = usePelcro.getStore();
8545
+ whenSiteReady(() => {
8546
+ var _window$Pelcro$site$r2;
8547
+
8548
+ 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;
8549
+ if (!securityKey) return;
8550
+ window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
8551
+ });
8552
+ };
8320
8553
  const initGATracking = () => {
8321
8554
  var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
8322
8555
 
@@ -8403,9 +8636,9 @@ const applyPelcroTheme = () => {
8403
8636
  };
8404
8637
 
8405
8638
  whenSiteReady(() => {
8406
- var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
8639
+ var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
8407
8640
 
8408
- 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;
8641
+ 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;
8409
8642
 
8410
8643
  if (!primaryColorHex) {
8411
8644
  return;
@@ -8604,6 +8837,7 @@ const defaultOptions = {
8604
8837
  enableURLTriggers: true,
8605
8838
  enableTheme: true,
8606
8839
  enablePaywalls: true,
8840
+ loadSecuritySDK: true,
8607
8841
  enableGoogleAnalytics: false
8608
8842
  };
8609
8843
  const PelcroModalController = ({
@@ -9544,35 +9778,53 @@ const RegisterContainer = ({
9544
9778
  jobTitle,
9545
9779
  selectFields
9546
9780
  } = filteredData;
9547
- window.Pelcro.user.register({
9548
- email,
9549
- password,
9550
- first_name: firstName,
9551
- last_name: lastName,
9552
- metadata: {
9553
- organization,
9554
- jobTitle,
9555
- ...selectFields
9556
- }
9557
- }, (err, res) => {
9558
- dispatch({
9559
- type: DISABLE_REGISTRATION_BUTTON,
9560
- payload: false
9781
+
9782
+ if (!hasSecurityTokenEnabled()) {
9783
+ sendRegisterRequest();
9784
+ return;
9785
+ }
9786
+
9787
+ window.grecaptcha.enterprise.ready(async () => {
9788
+ var _window$Pelcro$site$r;
9789
+
9790
+ 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, {
9791
+ action: "register"
9561
9792
  });
9793
+ sendRegisterRequest(token);
9794
+ });
9562
9795
 
9563
- if (err) {
9796
+ function sendRegisterRequest(securityToken) {
9797
+ window.Pelcro.user.register({
9798
+ email,
9799
+ password,
9800
+ first_name: firstName,
9801
+ last_name: lastName,
9802
+ security_token: securityToken,
9803
+ metadata: {
9804
+ organization,
9805
+ jobTitle,
9806
+ ...selectFields
9807
+ }
9808
+ }, (err, res) => {
9564
9809
  dispatch({
9565
- type: SHOW_ALERT,
9566
- payload: {
9567
- type: "error",
9568
- content: getErrorMessages(err)
9569
- }
9810
+ type: DISABLE_REGISTRATION_BUTTON,
9811
+ payload: false
9570
9812
  });
9571
- onFailure(err);
9572
- } else {
9573
- onSuccess(res);
9574
- }
9575
- });
9813
+
9814
+ if (err) {
9815
+ dispatch({
9816
+ type: SHOW_ALERT,
9817
+ payload: {
9818
+ type: "error",
9819
+ content: getErrorMessages(err)
9820
+ }
9821
+ });
9822
+ onFailure(err);
9823
+ } else {
9824
+ onSuccess(res);
9825
+ }
9826
+ });
9827
+ }
9576
9828
  };
9577
9829
 
9578
9830
  const handleSocialLogin = ({
@@ -9723,6 +9975,15 @@ const RegisterContainer = ({
9723
9975
  store: store$e
9724
9976
  })));
9725
9977
  };
9978
+ /**
9979
+ * Checks if the current site has security token enabled
9980
+ * @return {boolean}
9981
+ */
9982
+
9983
+ function hasSecurityTokenEnabled() {
9984
+ const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
9985
+ return hasSecuritySdkLoaded;
9986
+ }
9726
9987
 
9727
9988
  var _path$l;
9728
9989
 
@@ -9744,7 +10005,7 @@ const FacebookLoginButton = ({
9744
10005
  labelClassName = "",
9745
10006
  iconClassName = ""
9746
10007
  }) => {
9747
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
10008
+ var _window$Pelcro$site$r;
9748
10009
 
9749
10010
  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;
9750
10011
  const {
@@ -9783,7 +10044,7 @@ const FacebookLoginButton = ({
9783
10044
 
9784
10045
  return facebookLoginEnabled ? /*#__PURE__*/React__default['default'].createElement(FacebookLogin, {
9785
10046
  appId: window.Pelcro.site.read().facebook_app_id,
9786
- language: (_window$Pelcro$site$r2 = window.Pelcro.site.read().default_locale) !== null && _window$Pelcro$site$r2 !== void 0 ? _window$Pelcro$site$r2 : "en_US",
10047
+ language: getPageOrDefaultLanguage(),
9787
10048
  fields: "first_name,last_name,email,picture",
9788
10049
  callback: onSuccess,
9789
10050
  onFailure: onFailure,
@@ -10112,8 +10373,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default['default'].createE
10112
10373
  const RegisterButton = ({
10113
10374
  name,
10114
10375
  onClick,
10376
+ className,
10115
10377
  ...otherProps
10116
10378
  }) => {
10379
+ var _window$Pelcro$site$r;
10380
+
10117
10381
  const {
10118
10382
  state: {
10119
10383
  emailError,
@@ -10139,7 +10403,10 @@ const RegisterButton = ({
10139
10403
  onClick === null || onClick === void 0 ? void 0 : onClick();
10140
10404
  },
10141
10405
  disabled: isDisabled,
10142
- isLoading: buttonDisabled
10406
+ isLoading: buttonDisabled,
10407
+ className: `${className} g-recaptcha`,
10408
+ "data-action": "register",
10409
+ "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
10143
10410
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
10144
10411
  };
10145
10412
 
@@ -13317,7 +13584,7 @@ const PaymentMethodContainer = props => {
13317
13584
  return /*#__PURE__*/React__default['default'].createElement(es_13, {
13318
13585
  apiKey: window.Pelcro.environment.stripe,
13319
13586
  stripeAccount: window.Pelcro.site.read().account_id,
13320
- locale: getCanonicalLocaleFormat(window.Pelcro.site.read().default_locale)
13587
+ locale: getPageOrDefaultLanguage()
13321
13588
  }, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
13322
13589
  store: store$d
13323
13590
  }, props))));
@@ -13429,9 +13696,6 @@ const DiscountedPrice = props => {
13429
13696
  percentOff
13430
13697
  }
13431
13698
  } = React.useContext(store$d);
13432
- const {
13433
- default_locale
13434
- } = Pelcro.site.read();
13435
13699
  const {
13436
13700
  order,
13437
13701
  plan
@@ -13439,7 +13703,7 @@ const DiscountedPrice = props => {
13439
13703
  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;
13440
13704
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13441
13705
  const discountedPriceWithoutTax = updatedPrice - taxAmount;
13442
- const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13706
+ const priceFormatted = getFormattedPriceByLocal(order ? updatedPrice : discountedPriceWithoutTax * planQuantity, ecommOrderCurrency !== null && ecommOrderCurrency !== void 0 ? ecommOrderCurrency : plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13443
13707
 
13444
13708
  if (percentOff) {
13445
13709
  return /*#__PURE__*/React__default['default'].createElement("div", Object.assign({
@@ -13472,12 +13736,9 @@ const SubmitPaymentMethod = ({
13472
13736
  updatedPrice
13473
13737
  }
13474
13738
  } = React.useContext(store$d);
13475
- const {
13476
- default_locale
13477
- } = Pelcro.site.read();
13478
13739
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
13479
13740
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
13480
- const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
13741
+ const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
13481
13742
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
13482
13743
  role: "submit",
13483
13744
  className: "plc-w-full plc-py-3",
@@ -13722,7 +13983,7 @@ class PaypalClient {
13722
13983
  this.paypalButton = window.paypal.Buttons({
13723
13984
  fundingSource: window.paypal.FUNDING.PAYPAL,
13724
13985
  // button locale
13725
- locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : this.siteInfo.default_locale,
13986
+ locale: (_this$config$locale = this.config.locale) !== null && _this$config$locale !== void 0 ? _this$config$locale : getPageOrDefaultLanguage(),
13726
13987
  // button style
13727
13988
  style: (_this$config$style = this.config.style) !== null && _this$config$style !== void 0 ? _this$config$style : defaultButtonStyle,
13728
13989
  // create payment handler
@@ -13819,7 +14080,7 @@ class PaypalClient {
13819
14080
  } : undefined,
13820
14081
  shippingAddressEditable: this.config.shippingAddressEditable,
13821
14082
  displayName: (_this$config$displayN = this.config.displayName) !== null && _this$config$displayN !== void 0 ? _this$config$displayN : this.siteInfo.name,
13822
- locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : this.siteInfo.default_locale
14083
+ locale: (_this$config$locale2 = this.config.locale) !== null && _this$config$locale2 !== void 0 ? _this$config$locale2 : getPageOrDefaultLanguage()
13823
14084
  };
13824
14085
  }
13825
14086
  });
@@ -13828,7 +14089,7 @@ class PaypalClient {
13828
14089
  writable: true,
13829
14090
  value: () => {
13830
14091
  const totalAmount = (this.product.quantity || 1) * this.amount;
13831
- const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, this.siteInfo.default_locale);
14092
+ const priceFormatted = getFormattedPriceByLocal(totalAmount, this.product.currency, getPageOrDefaultLanguage());
13832
14093
  const autoRenewed = this.product.auto_renew;
13833
14094
  const {
13834
14095
  interval,
@@ -14025,14 +14286,11 @@ const TaxAmount = () => {
14025
14286
  taxAmount
14026
14287
  }
14027
14288
  } = React.useContext(store$d);
14028
- const {
14029
- default_locale
14030
- } = Pelcro.site.read();
14031
14289
  const {
14032
14290
  plan
14033
14291
  } = usePelcro();
14034
14292
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14035
- const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, default_locale);
14293
+ const priceFormatted = getFormattedPriceByLocal(taxAmount * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
14036
14294
 
14037
14295
  if (taxAmount) {
14038
14296
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -14905,10 +15163,7 @@ const SubscriptionCreateView = ({
14905
15163
  interval,
14906
15164
  count: interval_count
14907
15165
  });
14908
- const {
14909
- default_locale
14910
- } = Pelcro.site.read();
14911
- 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);
15166
+ 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());
14912
15167
  return /*#__PURE__*/React__default['default'].createElement("p", {
14913
15168
  className: "plc-text-gray-600"
14914
15169
  }, /*#__PURE__*/React__default['default'].createElement("span", {
@@ -18085,7 +18340,6 @@ const OrderConfirmModal = props => {
18085
18340
  const userOrders = window.Pelcro.user.read().orders;
18086
18341
  const latestOrder = userOrders === null || userOrders === void 0 ? void 0 : userOrders[userOrders.length - 1];
18087
18342
  const latestOrderDiscount = latestOrder === null || latestOrder === void 0 ? void 0 : (_latestOrder$coupon = latestOrder.coupon) === null || _latestOrder$coupon === void 0 ? void 0 : _latestOrder$coupon.percent_off;
18088
- const locale = window.Pelcro.site.read().default_locale;
18089
18343
  const {
18090
18344
  t
18091
18345
  } = useTranslation("shop");
@@ -18144,7 +18398,7 @@ const OrderConfirmModal = props => {
18144
18398
  className: "plc-mr-1 pelcro-summary-total-text"
18145
18399
  }, t("labels.total")), /*#__PURE__*/React__default['default'].createElement("p", {
18146
18400
  className: "pelcro-summary-total"
18147
- }, 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['default'].createElement("div", {
18401
+ }, 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['default'].createElement("div", {
18148
18402
  className: "plc-flex plc-justify-center plc-mt-6"
18149
18403
  }, /*#__PURE__*/React__default['default'].createElement(Button, {
18150
18404
  id: "pelcro-submit",
@@ -18206,9 +18460,9 @@ const GiftCreateContainer = ({
18206
18460
  }
18207
18461
 
18208
18462
  if (giftRecipient.startDate) {
18209
- const nowDate = new Date();
18210
- const yearFromNowDate = new Date(new Date().setFullYear(nowDate.getFullYear() + 1));
18211
- const submittedDate = new Date(giftRecipient.startDate);
18463
+ const nowDate = getDateWithoutTime(new Date());
18464
+ const yearFromNowDate = getDateWithoutTime(new Date(new Date().setFullYear(nowDate.getFullYear() + 1)));
18465
+ const submittedDate = getDateWithoutTime(new Date(giftRecipient.startDate));
18212
18466
 
18213
18467
  if (submittedDate < nowDate || submittedDate > yearFromNowDate) {
18214
18468
  dispatch({
@@ -20513,7 +20767,6 @@ const OrderItems = ({
20513
20767
  const {
20514
20768
  t
20515
20769
  } = useTranslation("dashboard");
20516
- const site = window.Pelcro.site.read();
20517
20770
  return !(orders !== null && orders !== void 0 && orders.length) ? /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", {
20518
20771
  colSpan: "3",
20519
20772
  className: "plc-text-center plc-text-gray-500"
@@ -20529,7 +20782,7 @@ const OrderItems = ({
20529
20782
  className: "plc-py-4 plc-pl-2"
20530
20783
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20531
20784
  className: "plc-text-xl plc-font-semibold "
20532
- }, getFormattedPriceByLocal(order.amount, order.currency, site.default_locale)), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
20785
+ }, getFormattedPriceByLocal(order.amount, order.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
20533
20786
  className: "plc-text-xs plc-text-gray-400 plc-uppercase"
20534
20787
  }, t("labels.orders.itemsAmount", {
20535
20788
  count: getItemsAmount(order.id)
@@ -20558,7 +20811,7 @@ const OrderItems = ({
20558
20811
  className: ""
20559
20812
  }, item.product_sku_name))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
20560
20813
  className: "plc-font-semibold"
20561
- }, getFormattedPriceByLocal(item.amount, order.currency, site.default_locale))));
20814
+ }, getFormattedPriceByLocal(item.amount, order.currency, getPageOrDefaultLanguage()))));
20562
20815
  }), /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", {
20563
20816
  colSpan: "3"
20564
20817
  }, /*#__PURE__*/React__default['default'].createElement("hr", {
@@ -21285,7 +21538,7 @@ class Dashboard extends React.Component {
21285
21538
  className: "plc-font-semibold plc-text-gray-500"
21286
21539
  }, sub.plan.nickname), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
21287
21540
  className: "plc-text-xs plc-text-gray-400"
21288
- }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, this.site.default_locale)))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21541
+ }, getFormattedPriceByLocal(sub.plan.amount, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21289
21542
  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`
21290
21543
  }, this.getSubscriptionStatus(sub).icon, this.getSubscriptionStatus(sub).title), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("div", {
21291
21544
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"
@@ -21388,7 +21641,7 @@ class Dashboard extends React.Component {
21388
21641
  className: "plc-font-semibold plc-text-gray-500"
21389
21642
  }, recipient.plan.nickname), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
21390
21643
  className: "plc-text-xs plc-text-gray-400"
21391
- }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, this.site.default_locale)))), recipient.status && /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21644
+ }, getFormattedPriceByLocal(recipient.plan.amount, recipient.plan.currency, getPageOrDefaultLanguage())))), recipient.status && /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("span", {
21392
21645
  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`
21393
21646
  }, this.getSubscriptionStatus(recipient).icon, this.getSubscriptionStatus(recipient).title), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("div", {
21394
21647
  className: "plc-mb-4 plc-text-xs plc-text-gray-500"