add-to-calendar-button 2.6.21 → 2.7.0

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.
@@ -6,15 +6,15 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.6.21
9
+ * Version: 2.7.0
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.6.21';
17
- const atcbCssTemplate = {
16
+ const atcbVersion = '2.7.0';
17
+ const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
20
20
  } else {
@@ -733,19 +733,25 @@ function atcb_decorate_data_button_status_handling(data) {
733
733
  return data;
734
734
  }
735
735
  async function atcb_decorate_data_rsvp(data) {
736
- if (typeof atcb_check_booked_out !== 'function' || !data.rsvp || Object.keys(data.rsvp).length === 0) return data;
736
+ if (typeof atcb_check_bookings !== 'function' || !data.rsvp || !data.proKey || Object.keys(data.rsvp).length === 0) return data;
737
737
  data.rsvp.expired = (function () {
738
738
  if (data.rsvp && data.rsvp.expires && new Date(data.rsvp.expires) < new Date()) {
739
739
  return true;
740
740
  }
741
741
  return false;
742
742
  })();
743
- data.rsvp.bookedOut = await atcb_check_booked_out(data);
744
- if (data.rsvp.expired || data.rsvp.bookedOut) {
745
- data.blockInteraction = true;
746
- }
747
- if (data.blockInteraction) {
748
- data.disabled = true;
743
+ if (data.rsvp.max) {
744
+ const bookings = await atcb_check_bookings(data.proKey, data.dev);
745
+ data.rsvp.seatsLeft = data.rsvp.max - bookings;
746
+ if (data.rsvp.seatsLeft < 1) {
747
+ data.rsvp.bookedOut = true;
748
+ }
749
+ if (data.rsvp.expired || data.rsvp.bookedOut) {
750
+ data.blockInteraction = true;
751
+ }
752
+ if (data.blockInteraction) {
753
+ data.disabled = true;
754
+ }
749
755
  }
750
756
  return data;
751
757
  }
@@ -1484,6 +1490,9 @@ async function atcb_generate_rsvp_form(host, data, hostEl, keyboardTrigger = fal
1484
1490
  ' class="atcb-modal-btn atcb-modal-btn-primary atcb-modal-btn-border">' +
1485
1491
  atcb_translate_hook('submit', data) +
1486
1492
  '</button><span id="pro-form-submitting" class="pro-waiting"><span>.</span><span>.</span><span>.</span></span></p>';
1493
+ if (rsvpData.seatsLeft && rsvpData.seatsLeft > 0) {
1494
+ rsvpContent += '<p class="pro-form-fine">' + atcb_translate_hook('form.seatsleft', data) + ': <b>' + rsvpData.seatsLeft + '</b></p>';
1495
+ }
1487
1496
  rsvpContent += '</form>';
1488
1497
  rsvpContent += '</div></div>';
1489
1498
  let rsvpHost = null;
@@ -1723,24 +1732,20 @@ async function atcb_generate_rsvp_button(host, data) {
1723
1732
  }
1724
1733
  return true;
1725
1734
  }
1726
- async function atcb_check_booked_out(data) {
1727
- if (data.rsvp && data.rsvp.max && data.proKey && data.proKey !== '') {
1728
- try {
1729
- const response = await fetch('https://api.add-to-calendar-pro.com/dffb8bbd-ee5e-4a4f-a7ea-503af98ca468?prokey=' + data.proKey + (data.dev ? '&dev=true' : ''), {
1730
- method: 'GET',
1731
- });
1732
- if (!response.ok) {
1733
- throw new Error('Network response was not ok');
1734
- }
1735
- const responseJson = await response.json();
1736
- if (parseInt(responseJson.total) >= data.rsvp.max) {
1737
- return true;
1738
- }
1739
- } catch (error) {
1740
- console.error('Error:', error);
1735
+ async function atcb_check_bookings(proKey, dev = false) {
1736
+ try {
1737
+ const response = await fetch('https://api.add-to-calendar-pro.com/dffb8bbd-ee5e-4a4f-a7ea-503af98ca468?prokey=' + proKey + (dev ? '&dev=true' : ''), {
1738
+ method: 'GET',
1739
+ });
1740
+ if (!response.ok) {
1741
+ throw new Error('Network response was not ok');
1741
1742
  }
1743
+ const responseJson = await response.json();
1744
+ return parseInt(responseJson.total);
1745
+ } catch (error) {
1746
+ console.error('Error:', error);
1742
1747
  }
1743
- return false;
1748
+ return 0;
1744
1749
  }
1745
1750
  function atcb_build_form(fields, identifier = '', disabled = false) {
1746
1751
  /*!
@@ -2860,7 +2865,7 @@ function atcb_generate_subscribe_links(host, linkType, data, keyboardTrigger) {
2860
2865
  atcb_subscribe_ical(data, data.icsFile);
2861
2866
  break;
2862
2867
  }
2863
- atcb_subscribe_ical(data, adjustedFileUrl);
2868
+ atcb_subscribe_ical(data, adjustedFileUrl, host, keyboardTrigger);
2864
2869
  break;
2865
2870
  case 'google':
2866
2871
  atcb_subscribe_google(data, adjustedFileUrl);
@@ -2929,7 +2934,11 @@ function atcb_set_fully_successful(host, data, multiDateModal = false) {
2929
2934
  atcb_toggle(host, 'close');
2930
2935
  }
2931
2936
  }
2932
- function atcb_subscribe_ical(data, fileUrl) {
2937
+ function atcb_subscribe_ical(data, fileUrl, host = null, keyboardTrigger = false) {
2938
+ if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
2939
+ atcb_ical_copy_note(host, fileUrl, data, keyboardTrigger);
2940
+ return;
2941
+ }
2933
2942
  atcb_open_cal_url(data, 'ical', fileUrl, true);
2934
2943
  }
2935
2944
  function atcb_subscribe_google(data, fileUrl) {
@@ -3254,7 +3263,7 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
3254
3263
  }
3255
3264
  return 'data:text/calendar;charset=utf-8,' + encodeURIComponent(ics_lines.join('\r\n'));
3256
3265
  })();
3257
- if ((atcbIsiOS() && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || (atcbIsAndroid() && atcbIsProblematicWebView())))) {
3266
+ if (((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || data.fakeIOS || ((atcbIsAndroid() || data.fakeAndroid) && atcbIsProblematicWebView())))) {
3258
3267
  atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger);
3259
3268
  return;
3260
3269
  }
@@ -3280,7 +3289,7 @@ function atcb_determine_ical_filename(data, subEvent) {
3280
3289
  }
3281
3290
  function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
3282
3291
  atcb_copy_to_clipboard(dataUrl);
3283
- if (atcbIsiOS() && !atcbIsSafari()) {
3292
+ if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
3284
3293
  atcb_create_modal(
3285
3294
  host,
3286
3295
  data,
@@ -4797,27 +4806,26 @@ if (atcbIsBrowser()) {
4797
4806
  }
4798
4807
  this.proOverride = !proOverrideVal || proOverrideVal === 'true' || proOverrideVal === '' ? true : false;
4799
4808
  }
4800
- if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
4801
- if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4802
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4809
+ try {
4810
+ if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
4811
+ if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4812
+ this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4813
+ } else {
4814
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4815
+ }
4816
+ if (this.data.proKey) this.proKey = this.data.proKey;
4803
4817
  } else {
4804
- this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4805
- }
4806
- if (this.data.proKey) this.proKey = this.data.proKey;
4807
- }
4808
- if (!this.data.name || this.data.name === '') {
4809
- this.data.proKey = '';
4810
- try {
4818
+ this.data.proKey = '';
4811
4819
  this.data = await atcb_process_inline_data(this, this.debug);
4812
- } catch (e) {
4813
- if (this.debug) {
4814
- console.error(e);
4815
- atcb_render_debug_msg(this.shadowRoot, e);
4816
- }
4817
- this.state.initializing = false;
4818
- this.state.ready = true;
4819
- return;
4820
4820
  }
4821
+ } catch (e) {
4822
+ if (this.debug) {
4823
+ console.error(e);
4824
+ atcb_render_debug_msg(this.shadowRoot, e);
4825
+ }
4826
+ this.state.initializing = false;
4827
+ this.state.ready = true;
4828
+ return;
4821
4829
  }
4822
4830
  await this.initButton();
4823
4831
  this.state.initializing = false;
@@ -4872,24 +4880,23 @@ if (atcbIsBrowser()) {
4872
4880
  const elem = document.createElement('template');
4873
4881
  elem.innerHTML = template;
4874
4882
  this.shadowRoot.append(elem.content.cloneNode(true));
4875
- if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4876
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4877
- if (this.data.proKey) this.proKey = this.data.proKey;
4878
- } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
4879
- this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4880
- if (this.data.proKey) this.proKey = this.data.proKey;
4881
- }
4882
- if (!this.data.name || this.data.name === '') {
4883
- try {
4883
+ try {
4884
+ if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4885
+ this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4886
+ if (this.data.proKey) this.proKey = this.data.proKey;
4887
+ } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
4888
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4889
+ if (this.data.proKey) this.proKey = this.data.proKey;
4890
+ } else {
4884
4891
  this.data = await atcb_process_inline_data(this, this.debug);
4885
- } catch (e) {
4886
- if (this.debug) {
4887
- console.error(e);
4888
- atcb_render_debug_msg(this.shadowRoot, e);
4889
- }
4890
- this.updatePending = false;
4891
- return;
4892
4892
  }
4893
+ } catch (e) {
4894
+ if (this.debug) {
4895
+ console.error(e);
4896
+ atcb_render_debug_msg(this.shadowRoot, e);
4897
+ }
4898
+ this.updatePending = false;
4899
+ return;
4893
4900
  }
4894
4901
  atcb_cleanup(this.shadowRoot, this.identifier);
4895
4902
  await this.initButton();
@@ -5220,19 +5227,28 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
5220
5227
  if (!atcbIsBrowser()) {
5221
5228
  return;
5222
5229
  }
5223
- let data = await (async function () {
5224
- const cleanedInput = atcb_secure_content(inputData);
5225
- if (cleanedInput.prokey && cleanedInput.prokey !== '') {
5226
- cleanedInput.proKey = cleanedInput.prokey;
5227
- }
5228
- if (cleanedInput.proKey && cleanedInput.proKey !== '') {
5229
- const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
5230
- if (proData.name && proData.name != '') {
5231
- return proData;
5230
+ let data;
5231
+ try {
5232
+ data = await (async function () {
5233
+ const cleanedInput = atcb_secure_content(inputData);
5234
+ if (cleanedInput.prokey && cleanedInput.prokey !== '') {
5235
+ cleanedInput.proKey = cleanedInput.prokey;
5232
5236
  }
5233
- }
5234
- return cleanedInput;
5235
- })();
5237
+ if (cleanedInput.proKey && cleanedInput.proKey !== '') {
5238
+ try {
5239
+ const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
5240
+ return proData;
5241
+ } catch (e) {
5242
+ throw new Error(e.message);
5243
+ }
5244
+ } else {
5245
+ return cleanedInput;
5246
+ }
5247
+ })();
5248
+ } catch (e) {
5249
+ console.error(e);
5250
+ return;
5251
+ }
5236
5252
  data.debug = data.debug === 'true';
5237
5253
  try {
5238
5254
  await atcb_check_required(data);
@@ -5370,9 +5386,6 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
5370
5386
  const response = await fetch((dataOverrides.dev ? 'https://event-dev.caldn.net/' : 'https://event.caldn.net/') + licenseKey + '/config.json');
5371
5387
  if (response.ok) {
5372
5388
  const data = await response.json();
5373
- if (!data.name || data.name === '') {
5374
- throw new Error('Not possible to read proKey config from server...');
5375
- }
5376
5389
  if (proOverride) {
5377
5390
  atcbWcParams.forEach((key) => {
5378
5391
  if (Object.prototype.hasOwnProperty.call(dataOverrides, key) && ['hideBranding', 'hidebranding', 'rsvp', 'ty'].indexOf(key) === -1) {
@@ -5386,13 +5399,16 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
5386
5399
  }
5387
5400
  });
5388
5401
  }
5402
+ if (!data.name || data.name === '') {
5403
+ throw new Error('Not possible to read proKey config from server...');
5404
+ }
5389
5405
  data.proKey = licenseKey;
5390
5406
  data.identifier = licenseKey;
5391
5407
  return data;
5392
5408
  }
5393
5409
  throw new Error('Not possible to read proKey config from server...');
5394
5410
  } catch {
5395
- console.error('Add to Calendar Button proKey invalid or server not responding! Falling back to local data...');
5411
+ throw new Error('Add to Calendar Button proKey invalid or server not responding!');
5396
5412
  }
5397
5413
  }
5398
5414
  return {};
@@ -6,15 +6,15 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.6.21
9
+ * Version: 2.7.0
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.6.21';
17
- const atcbCssTemplate = {
16
+ const atcbVersion = '2.7.0';
17
+ const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
20
20
  } else {
@@ -733,19 +733,25 @@ function atcb_decorate_data_button_status_handling(data) {
733
733
  return data;
734
734
  }
735
735
  async function atcb_decorate_data_rsvp(data) {
736
- if (typeof atcb_check_booked_out !== 'function' || !data.rsvp || Object.keys(data.rsvp).length === 0) return data;
736
+ if (typeof atcb_check_bookings !== 'function' || !data.rsvp || !data.proKey || Object.keys(data.rsvp).length === 0) return data;
737
737
  data.rsvp.expired = (function () {
738
738
  if (data.rsvp && data.rsvp.expires && new Date(data.rsvp.expires) < new Date()) {
739
739
  return true;
740
740
  }
741
741
  return false;
742
742
  })();
743
- data.rsvp.bookedOut = await atcb_check_booked_out(data);
744
- if (data.rsvp.expired || data.rsvp.bookedOut) {
745
- data.blockInteraction = true;
746
- }
747
- if (data.blockInteraction) {
748
- data.disabled = true;
743
+ if (data.rsvp.max) {
744
+ const bookings = await atcb_check_bookings(data.proKey, data.dev);
745
+ data.rsvp.seatsLeft = data.rsvp.max - bookings;
746
+ if (data.rsvp.seatsLeft < 1) {
747
+ data.rsvp.bookedOut = true;
748
+ }
749
+ if (data.rsvp.expired || data.rsvp.bookedOut) {
750
+ data.blockInteraction = true;
751
+ }
752
+ if (data.blockInteraction) {
753
+ data.disabled = true;
754
+ }
749
755
  }
750
756
  return data;
751
757
  }
@@ -2139,7 +2145,7 @@ function atcb_generate_subscribe_links(host, linkType, data, keyboardTrigger) {
2139
2145
  atcb_subscribe_ical(data, data.icsFile);
2140
2146
  break;
2141
2147
  }
2142
- atcb_subscribe_ical(data, adjustedFileUrl);
2148
+ atcb_subscribe_ical(data, adjustedFileUrl, host, keyboardTrigger);
2143
2149
  break;
2144
2150
  case 'google':
2145
2151
  atcb_subscribe_google(data, adjustedFileUrl);
@@ -2208,7 +2214,11 @@ function atcb_set_fully_successful(host, data, multiDateModal = false) {
2208
2214
  atcb_toggle(host, 'close');
2209
2215
  }
2210
2216
  }
2211
- function atcb_subscribe_ical(data, fileUrl) {
2217
+ function atcb_subscribe_ical(data, fileUrl, host = null, keyboardTrigger = false) {
2218
+ if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
2219
+ atcb_ical_copy_note(host, fileUrl, data, keyboardTrigger);
2220
+ return;
2221
+ }
2212
2222
  atcb_open_cal_url(data, 'ical', fileUrl, true);
2213
2223
  }
2214
2224
  function atcb_subscribe_google(data, fileUrl) {
@@ -2533,7 +2543,7 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
2533
2543
  }
2534
2544
  return 'data:text/calendar;charset=utf-8,' + encodeURIComponent(ics_lines.join('\r\n'));
2535
2545
  })();
2536
- if ((atcbIsiOS() && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || (atcbIsAndroid() && atcbIsProblematicWebView())))) {
2546
+ if (((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || data.fakeIOS || ((atcbIsAndroid() || data.fakeAndroid) && atcbIsProblematicWebView())))) {
2537
2547
  atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger);
2538
2548
  return;
2539
2549
  }
@@ -2559,7 +2569,7 @@ function atcb_determine_ical_filename(data, subEvent) {
2559
2569
  }
2560
2570
  function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
2561
2571
  atcb_copy_to_clipboard(dataUrl);
2562
- if (atcbIsiOS() && !atcbIsSafari()) {
2572
+ if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
2563
2573
  atcb_create_modal(
2564
2574
  host,
2565
2575
  data,
@@ -4076,27 +4086,26 @@ if (atcbIsBrowser()) {
4076
4086
  }
4077
4087
  this.proOverride = !proOverrideVal || proOverrideVal === 'true' || proOverrideVal === '' ? true : false;
4078
4088
  }
4079
- if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
4080
- if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4081
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4089
+ try {
4090
+ if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
4091
+ if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4092
+ this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4093
+ } else {
4094
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4095
+ }
4096
+ if (this.data.proKey) this.proKey = this.data.proKey;
4082
4097
  } else {
4083
- this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4084
- }
4085
- if (this.data.proKey) this.proKey = this.data.proKey;
4086
- }
4087
- if (!this.data.name || this.data.name === '') {
4088
- this.data.proKey = '';
4089
- try {
4098
+ this.data.proKey = '';
4090
4099
  this.data = await atcb_process_inline_data(this, this.debug);
4091
- } catch (e) {
4092
- if (this.debug) {
4093
- console.error(e);
4094
- atcb_render_debug_msg(this.shadowRoot, e);
4095
- }
4096
- this.state.initializing = false;
4097
- this.state.ready = true;
4098
- return;
4099
4100
  }
4101
+ } catch (e) {
4102
+ if (this.debug) {
4103
+ console.error(e);
4104
+ atcb_render_debug_msg(this.shadowRoot, e);
4105
+ }
4106
+ this.state.initializing = false;
4107
+ this.state.ready = true;
4108
+ return;
4100
4109
  }
4101
4110
  await this.initButton();
4102
4111
  this.state.initializing = false;
@@ -4151,24 +4160,23 @@ if (atcbIsBrowser()) {
4151
4160
  const elem = document.createElement('template');
4152
4161
  elem.innerHTML = template;
4153
4162
  this.shadowRoot.append(elem.content.cloneNode(true));
4154
- if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4155
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4156
- if (this.data.proKey) this.proKey = this.data.proKey;
4157
- } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
4158
- this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4159
- if (this.data.proKey) this.proKey = this.data.proKey;
4160
- }
4161
- if (!this.data.name || this.data.name === '') {
4162
- try {
4163
+ try {
4164
+ if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
4165
+ this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
4166
+ if (this.data.proKey) this.proKey = this.data.proKey;
4167
+ } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
4168
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
4169
+ if (this.data.proKey) this.proKey = this.data.proKey;
4170
+ } else {
4163
4171
  this.data = await atcb_process_inline_data(this, this.debug);
4164
- } catch (e) {
4165
- if (this.debug) {
4166
- console.error(e);
4167
- atcb_render_debug_msg(this.shadowRoot, e);
4168
- }
4169
- this.updatePending = false;
4170
- return;
4171
4172
  }
4173
+ } catch (e) {
4174
+ if (this.debug) {
4175
+ console.error(e);
4176
+ atcb_render_debug_msg(this.shadowRoot, e);
4177
+ }
4178
+ this.updatePending = false;
4179
+ return;
4172
4180
  }
4173
4181
  atcb_cleanup(this.shadowRoot, this.identifier);
4174
4182
  await this.initButton();
@@ -4499,19 +4507,28 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
4499
4507
  if (!atcbIsBrowser()) {
4500
4508
  return;
4501
4509
  }
4502
- let data = await (async function () {
4503
- const cleanedInput = atcb_secure_content(inputData);
4504
- if (cleanedInput.prokey && cleanedInput.prokey !== '') {
4505
- cleanedInput.proKey = cleanedInput.prokey;
4506
- }
4507
- if (cleanedInput.proKey && cleanedInput.proKey !== '') {
4508
- const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
4509
- if (proData.name && proData.name != '') {
4510
- return proData;
4510
+ let data;
4511
+ try {
4512
+ data = await (async function () {
4513
+ const cleanedInput = atcb_secure_content(inputData);
4514
+ if (cleanedInput.prokey && cleanedInput.prokey !== '') {
4515
+ cleanedInput.proKey = cleanedInput.prokey;
4511
4516
  }
4512
- }
4513
- return cleanedInput;
4514
- })();
4517
+ if (cleanedInput.proKey && cleanedInput.proKey !== '') {
4518
+ try {
4519
+ const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
4520
+ return proData;
4521
+ } catch (e) {
4522
+ throw new Error(e.message);
4523
+ }
4524
+ } else {
4525
+ return cleanedInput;
4526
+ }
4527
+ })();
4528
+ } catch (e) {
4529
+ console.error(e);
4530
+ return;
4531
+ }
4515
4532
  data.debug = data.debug === 'true';
4516
4533
  try {
4517
4534
  await atcb_check_required(data);
@@ -4649,9 +4666,6 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
4649
4666
  const response = await fetch((dataOverrides.dev ? 'https://event-dev.caldn.net/' : 'https://event.caldn.net/') + licenseKey + '/config.json');
4650
4667
  if (response.ok) {
4651
4668
  const data = await response.json();
4652
- if (!data.name || data.name === '') {
4653
- throw new Error('Not possible to read proKey config from server...');
4654
- }
4655
4669
  if (proOverride) {
4656
4670
  atcbWcParams.forEach((key) => {
4657
4671
  if (Object.prototype.hasOwnProperty.call(dataOverrides, key) && ['hideBranding', 'hidebranding', 'rsvp', 'ty'].indexOf(key) === -1) {
@@ -4665,13 +4679,16 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
4665
4679
  }
4666
4680
  });
4667
4681
  }
4682
+ if (!data.name || data.name === '') {
4683
+ throw new Error('Not possible to read proKey config from server...');
4684
+ }
4668
4685
  data.proKey = licenseKey;
4669
4686
  data.identifier = licenseKey;
4670
4687
  return data;
4671
4688
  }
4672
4689
  throw new Error('Not possible to read proKey config from server...');
4673
4690
  } catch {
4674
- console.error('Add to Calendar Button proKey invalid or server not responding! Falling back to local data...');
4691
+ throw new Error('Add to Calendar Button proKey invalid or server not responding!');
4675
4692
  }
4676
4693
  }
4677
4694
  return {};