add-to-calendar-button 2.5.0 → 2.5.2

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: 3D
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Date
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Flat
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Neumorphism
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Round
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Text
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Default
7
7
  *
8
- * Version: 2.5.0
8
+ * Version: 2.5.2
9
9
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -977,14 +977,14 @@ function tzlib_get_timezones(jsonType = false) {
977
977
  * Add to Calendar Button
978
978
  * ++++++++++++++++++++++
979
979
  *
980
- * Version: 2.5.0
980
+ * Version: 2.5.2
981
981
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
982
982
  * Project: https://github.com/add2cal/add-to-calendar-button
983
983
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
984
984
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
985
985
  *
986
986
  */
987
- const atcbVersion = '2.5.0';
987
+ const atcbVersion = '2.5.2';
988
988
  const atcbCssTemplate = {};
989
989
  const atcbIsBrowser = () => {
990
990
  if (typeof window === 'undefined') {
@@ -1998,7 +1998,7 @@ function atcb_toggle(host, action, data = '', button = null, keyboardTrigger = f
1998
1998
  atcb_open(host, data, button, keyboardTrigger, generatedButton);
1999
1999
  }
2000
2000
  }
2001
- function atcb_open(host, data, button = null, keyboardTrigger = false, generatedButton = false) {
2001
+ async function atcb_open(host, data, button = null, keyboardTrigger = false, generatedButton = false) {
2002
2002
  if (host.querySelector('.atcb-list') || host.querySelector('.atcb-modal')) return;
2003
2003
  atcb_log_event('openList', data.identifier, data.identifier);
2004
2004
  atcbStates['active'] = data.identifier;
@@ -2029,7 +2029,7 @@ function atcb_open(host, data, button = null, keyboardTrigger = false, generated
2029
2029
  }
2030
2030
  const bgOverlay = atcb_generate_bg_overlay(host, data.trigger, data.listStyle === 'modal', !data.hideBackground);
2031
2031
  if (data.listStyle === 'modal') {
2032
- const modalHost = atcb_generate_modal_host(host, data);
2032
+ const modalHost = await atcb_generate_modal_host(host, data);
2033
2033
  modalHost.querySelector('.atcb-modal-host-initialized').append(bgOverlay);
2034
2034
  bgOverlay.append(list);
2035
2035
  if (!data.hideBranding) {
@@ -2481,9 +2481,9 @@ function atcb_create_atcbl(host, atList = true, returnEl = false) {
2481
2481
  }
2482
2482
  }
2483
2483
  }
2484
- function atcb_create_modal(host, data, icon = '', headline, content = '', buttons = [], subEvents = [], keyboardTrigger = false, goto = {}, closable = true) {
2484
+ async function atcb_create_modal(host, data, icon = '', headline, content = '', buttons = [], subEvents = [], keyboardTrigger = false, goto = {}, closable = true) {
2485
2485
  atcbStates['active'] = data.identifier;
2486
- const modalHost = atcb_generate_modal_host(host, data, false);
2486
+ const modalHost = await atcb_generate_modal_host(host, data, false);
2487
2487
  const bgOverlay = (function () {
2488
2488
  const el = modalHost.getElementById('atcb-bgoverlay');
2489
2489
  if (!el) {
@@ -2659,7 +2659,7 @@ function atcb_create_modal(host, data, icon = '', headline, content = '', button
2659
2659
  });
2660
2660
  if (modalCount > 1) {
2661
2661
  const prevModal = modalHost.querySelector('.atcb-modal[data-modal-nr="' + (modalCount - 1) + '"]');
2662
- prevModal.style.display = 'none';
2662
+ prevModal.classList.add('atcb-hidden');
2663
2663
  }
2664
2664
  atcb_manage_body_scroll(modalHost, modalWrapper);
2665
2665
  }
@@ -2814,7 +2814,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all') {
2814
2814
  parent.append(btnCheck);
2815
2815
  }
2816
2816
  }
2817
- function atcb_generate_modal_host(host, data, reset = true) {
2817
+ async function atcb_generate_modal_host(host, data, reset = true) {
2818
2818
  const existingModalHost = document.getElementById(data.identifier + '-modal-host');
2819
2819
  if (!reset && existingModalHost) {
2820
2820
  return existingModalHost.shadowRoot;
@@ -2824,12 +2824,6 @@ function atcb_generate_modal_host(host, data, reset = true) {
2824
2824
  }
2825
2825
  let newModalHost = document.createElement('div');
2826
2826
  newModalHost.id = data.identifier + '-modal-host';
2827
- if (data.styleLight) {
2828
- newModalHost.setAttribute('styleLight', data.styleLight);
2829
- }
2830
- if (data.styleDark) {
2831
- newModalHost.setAttribute('styleDark', data.styleDark);
2832
- }
2833
2827
  if (host.host.hasAttribute('cspnonce')) {
2834
2828
  newModalHost.setAttribute('cspnonce', host.host.getAttribute('cspnonce'));
2835
2829
  }
@@ -2838,14 +2832,14 @@ function atcb_generate_modal_host(host, data, reset = true) {
2838
2832
  document.body.append(newModalHost);
2839
2833
  newModalHost.attachShadow({ mode: 'open', delegateFocus: true });
2840
2834
  const elem = document.createElement('template');
2841
- elem.innerHTML = '<div class="atcb-modal-host-initialized" style="translate3D(0, 0, 0);visibility:visible;opacity:1;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;z-index:13999999;"></div>';
2835
+ elem.innerHTML = '<div class="atcb-modal-host-initialized" style="transform:translate3D(0, 0, 0);visibility:visible;opacity:1;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;z-index:13999999;"></div>';
2842
2836
  newModalHost.shadowRoot.append(elem.content.cloneNode(true));
2843
2837
  atcb_set_light_mode(newModalHost.shadowRoot, data);
2844
- atcb_load_css(newModalHost.shadowRoot, null, data);
2838
+ await atcb_load_css(newModalHost.shadowRoot, null, data);
2845
2839
  return newModalHost.shadowRoot;
2846
2840
  }
2847
- function atcb_generate_overlay_dom(host, data) {
2848
- const newHost = atcb_generate_modal_host(host, data);
2841
+ async function atcb_generate_overlay_dom(host, data) {
2842
+ const newHost = await atcb_generate_modal_host(host, data);
2849
2843
  atcb_set_fullsize(newHost.querySelector('.atcb-modal-host-initialized'));
2850
2844
  const nodes = Array.from(host.children);
2851
2845
  nodes.forEach((node) => {
@@ -3536,7 +3530,7 @@ function atcb_save_file(file, filename) {
3536
3530
  }
3537
3531
  }
3538
3532
  function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', addTimeZoneOffset = false) {
3539
- if (data.startTime != null && data.startTime != '' && data.endTime != null && data.endTime != '') {
3533
+ if (data.startTime && data.startTime !== '' && data.endTime && data.endTime !== '') {
3540
3534
  const newStartDate = new Date(data.startDate + 'T' + data.startTime + ':00.000+00:00');
3541
3535
  if (!data.endDate) data.endDate = data.startDate;
3542
3536
  const newEndDate = new Date(data.endDate + 'T' + data.endTime + ':00.000+00:00');
@@ -3581,7 +3575,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
3581
3575
  };
3582
3576
  } else {
3583
3577
  const startDate = data.startDate.split('-');
3584
- const endDate = data.endDate.split('-');
3578
+ const endDate = data.endDate ? data.endDate.split('-') : startDate;
3585
3579
  const newStartDate = new Date(Date.UTC(startDate[0], startDate[1] - 1, startDate[2], 12, 0, 0));
3586
3580
  const newEndDate = new Date(Date.UTC(endDate[0], endDate[1] - 1, endDate[2], 12, 0, 0));
3587
3581
  if (targetCal === 'google' || (targetCal === 'microsoft' && !atcbIsMobile()) || targetCal === 'msteams' || targetCal === 'ical') {
@@ -3634,7 +3628,8 @@ function atcb_format_datetime(datetime, style = 'delimiters', includeTime = true
3634
3628
  }
3635
3629
  function atcb_generate_timestring(dates, language = 'en', subEvent = 'all', decorate = false, browserTimeOverride = false, enforceYear = false, hideTimeZone = false) {
3636
3630
  if (decorate) {
3637
- dates = atcb_decorate_data_dates({ dates: dates }).dates;
3631
+ const tmpRootTZ = atcb_decorate_data_timezone();
3632
+ dates = atcb_decorate_data_dates({ dates: dates, timeZone: tmpRootTZ }).dates;
3638
3633
  }
3639
3634
  let startDateInfo, endDateInfo, timeZoneInfoStart, timeZoneInfoEnd;
3640
3635
  let formattedTimeStart = {};
@@ -4950,15 +4945,15 @@ if (atcbIsBrowser()) {
4950
4945
  if (this.data.proKey) this.proKey = this.data.proKey;
4951
4946
  }
4952
4947
  if (!this.data.name || this.data.name === '') {
4948
+ this.data.proKey = '';
4953
4949
  try {
4954
4950
  this.data = atcb_process_inline_data(this, this.debug);
4955
4951
  } catch (e) {
4956
4952
  if (this.debug) {
4957
4953
  atcb_render_debug_msg(this.shadowRoot, e);
4958
4954
  }
4955
+ this.loaded = true;
4959
4956
  return;
4960
- } finally {
4961
- this.data.proKey = '';
4962
4957
  }
4963
4958
  }
4964
4959
  this.loaded = true;
@@ -4975,7 +4970,7 @@ if (atcbIsBrowser()) {
4975
4970
  }
4976
4971
  static get observedAttributes() {
4977
4972
  const observeAdditionally = ['instance', 'proKey'];
4978
- if (this.proKey != null && this.proKey != '') {
4973
+ if (this.proKey && this.proKey !== '') {
4979
4974
  return atcbWcProParams
4980
4975
  .map((element) => {
4981
4976
  return element.toLowerCase();
@@ -5067,17 +5062,19 @@ function atcb_process_inline_data(el, debug = false) {
5067
5062
  if (!atcb_check_required(data)) {
5068
5063
  const slotInput = el.innerHTML;
5069
5064
  const atcbJsonInput = (function () {
5070
- if (slotInput != '') {
5065
+ if (slotInput !== '') {
5071
5066
  try {
5072
5067
  return JSON.parse(atcb_secure_content(slotInput.replace(/(\\r\\n|\\n|\\r)/g, ''), false));
5073
5068
  } catch (e) {
5074
5069
  throw new Error('Add to Calendar Button generation failed: JSON content provided, but badly formatted (in doubt, try some tool like https://jsonformatter.org/ to validate).\r\nError message: ' + e);
5075
5070
  }
5076
5071
  }
5077
- return '';
5072
+ return null;
5078
5073
  })();
5079
- if (atcbJsonInput.length === 0 && debug) {
5080
- console.error(data.validationError);
5074
+ if (!atcbJsonInput || (Array.isArray(atcbJsonInput) && atcbJsonInput.length === 0) || (typeof atcbJsonInput === 'object' && Object.keys(atcbJsonInput).length === 0)) {
5075
+ if (debug) {
5076
+ console.error(data.validationError);
5077
+ }
5081
5078
  throw new Error('Add to Calendar Button generation failed: no data provided or missing required fields - see console logs for details');
5082
5079
  }
5083
5080
  data = atcbJsonInput;
@@ -5208,7 +5205,7 @@ function atcb_csp_nonce(host) {
5208
5205
  }
5209
5206
  return host.host.getAttribute('cspnonce');
5210
5207
  }
5211
- function atcb_load_css(host, rootObj = null, data) {
5208
+ async function atcb_load_css(host, rootObj = null, data) {
5212
5209
  const nonceVal = atcb_csp_nonce(host);
5213
5210
  if (!document.getElementById('atcb-global-style')) {
5214
5211
  const cssGlobalContent = document.createElement('style');
@@ -5247,9 +5244,8 @@ function atcb_load_css(host, rootObj = null, data) {
5247
5244
  if (nonceVal) {
5248
5245
  cssFile.setAttribute('nonce', nonceVal);
5249
5246
  }
5250
- if (rootObj == null) {
5251
- host.host.style.display = 'none';
5252
- loadExternalCssAsynch(cssFile, host, host.host, nonceVal);
5247
+ if (!rootObj) {
5248
+ await loadExternalCssAsynch(cssFile, host, null, nonceVal, null, false, false, overrideDefaultCss + overrideDarkCss);
5253
5249
  } else {
5254
5250
  const placeholder = document.createElement('div');
5255
5251
  placeholder.classList.add('atcb-placeholder');
@@ -5264,7 +5260,7 @@ function atcb_load_css(host, rootObj = null, data) {
5264
5260
  }
5265
5261
  return;
5266
5262
  }
5267
- if (data.buttonStyle !== 'none' && atcbCssTemplate[`${data.buttonStyle}`] != null) {
5263
+ if (data.buttonStyle !== 'none' && atcbCssTemplate[`${data.buttonStyle}`]) {
5268
5264
  const cssContent = document.createElement('style');
5269
5265
  if (nonceVal) {
5270
5266
  cssContent.setAttribute('nonce', nonceVal);
@@ -5272,7 +5268,7 @@ function atcb_load_css(host, rootObj = null, data) {
5272
5268
  cssContent.innerText = atcbCssTemplate[`${data.buttonStyle}`] + overrideDefaultCss + overrideDarkCss;
5273
5269
  host.prepend(cssContent);
5274
5270
  }
5275
- if (rootObj != null) {
5271
+ if (rootObj) {
5276
5272
  if (data.inline) {
5277
5273
  rootObj.style.display = 'inline-block';
5278
5274
  rootObj.classList.add('atcb-inline');
@@ -5284,7 +5280,7 @@ function atcb_load_css(host, rootObj = null, data) {
5284
5280
  rootObj.classList.remove('atcb-hidden');
5285
5281
  }
5286
5282
  }
5287
- async function loadExternalCssAsynch(cssFile, host, rootObj, nonceVal = null, placeholder = null, inline = false, buttonsList = false, overrideCss = '') {
5283
+ async function loadExternalCssAsynch(cssFile, host, rootObj = null, nonceVal = null, placeholder = null, inline = false, buttonsList = false, overrideCss = '') {
5288
5284
  if (overrideCss !== '') {
5289
5285
  const cssContent = document.createElement('style');
5290
5286
  cssContent.innerText = overrideCss;
@@ -5298,18 +5294,20 @@ async function loadExternalCssAsynch(cssFile, host, rootObj, nonceVal = null, pl
5298
5294
  await new Promise((resolve) => {
5299
5295
  cssFile.onload = resolve;
5300
5296
  });
5301
- if (placeholder) {
5302
- placeholder.remove();
5303
- }
5304
- if (inline) {
5305
- rootObj.style.display = 'inline-block';
5306
- rootObj.classList.add('atcb-inline');
5307
- } else {
5308
- if (buttonsList) {
5309
- rootObj.classList.add('atcb-buttons-list');
5297
+ if (rootObj) {
5298
+ if (placeholder) {
5299
+ placeholder.remove();
5310
5300
  }
5301
+ if (inline) {
5302
+ rootObj.style.display = 'inline-block';
5303
+ rootObj.classList.add('atcb-inline');
5304
+ } else {
5305
+ if (buttonsList) {
5306
+ rootObj.classList.add('atcb-buttons-list');
5307
+ }
5308
+ }
5309
+ rootObj.classList.remove('atcb-hidden');
5311
5310
  }
5312
- rootObj.classList.remove('atcb-hidden');
5313
5311
  } catch (e) {
5314
5312
  console.log(e);
5315
5313
  }
@@ -977,14 +977,14 @@ function tzlib_get_timezones(jsonType = false) {
977
977
  * Add to Calendar Button
978
978
  * ++++++++++++++++++++++
979
979
  *
980
- * Version: 2.5.0
980
+ * Version: 2.5.2
981
981
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
982
982
  * Project: https://github.com/add2cal/add-to-calendar-button
983
983
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
984
984
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
985
985
  *
986
986
  */
987
- const atcbVersion = '2.5.0';
987
+ const atcbVersion = '2.5.2';
988
988
  const atcbCssTemplate = {
989
989
  if (typeof window === 'undefined') {
990
990
  return false;
@@ -1997,7 +1997,7 @@ function atcb_toggle(host, action, data = '', button = null, keyboardTrigger = f
1997
1997
  atcb_open(host, data, button, keyboardTrigger, generatedButton);
1998
1998
  }
1999
1999
  }
2000
- function atcb_open(host, data, button = null, keyboardTrigger = false, generatedButton = false) {
2000
+ async function atcb_open(host, data, button = null, keyboardTrigger = false, generatedButton = false) {
2001
2001
  if (host.querySelector('.atcb-list') || host.querySelector('.atcb-modal')) return;
2002
2002
  atcb_log_event('openList', data.identifier, data.identifier);
2003
2003
  atcbStates['active'] = data.identifier;
@@ -2028,7 +2028,7 @@ function atcb_open(host, data, button = null, keyboardTrigger = false, generated
2028
2028
  }
2029
2029
  const bgOverlay = atcb_generate_bg_overlay(host, data.trigger, data.listStyle === 'modal', !data.hideBackground);
2030
2030
  if (data.listStyle === 'modal') {
2031
- const modalHost = atcb_generate_modal_host(host, data);
2031
+ const modalHost = await atcb_generate_modal_host(host, data);
2032
2032
  modalHost.querySelector('.atcb-modal-host-initialized').append(bgOverlay);
2033
2033
  bgOverlay.append(list);
2034
2034
  if (!data.hideBranding) {
@@ -2480,9 +2480,9 @@ function atcb_create_atcbl(host, atList = true, returnEl = false) {
2480
2480
  }
2481
2481
  }
2482
2482
  }
2483
- function atcb_create_modal(host, data, icon = '', headline, content = '', buttons = [], subEvents = [], keyboardTrigger = false, goto = {}, closable = true) {
2483
+ async function atcb_create_modal(host, data, icon = '', headline, content = '', buttons = [], subEvents = [], keyboardTrigger = false, goto = {}, closable = true) {
2484
2484
  atcbStates['active'] = data.identifier;
2485
- const modalHost = atcb_generate_modal_host(host, data, false);
2485
+ const modalHost = await atcb_generate_modal_host(host, data, false);
2486
2486
  const bgOverlay = (function () {
2487
2487
  const el = modalHost.getElementById('atcb-bgoverlay');
2488
2488
  if (!el) {
@@ -2658,7 +2658,7 @@ function atcb_create_modal(host, data, icon = '', headline, content = '', button
2658
2658
  });
2659
2659
  if (modalCount > 1) {
2660
2660
  const prevModal = modalHost.querySelector('.atcb-modal[data-modal-nr="' + (modalCount - 1) + '"]');
2661
- prevModal.style.display = 'none';
2661
+ prevModal.classList.add('atcb-hidden');
2662
2662
  }
2663
2663
  atcb_manage_body_scroll(modalHost, modalWrapper);
2664
2664
  }
@@ -2813,7 +2813,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all') {
2813
2813
  parent.append(btnCheck);
2814
2814
  }
2815
2815
  }
2816
- function atcb_generate_modal_host(host, data, reset = true) {
2816
+ async function atcb_generate_modal_host(host, data, reset = true) {
2817
2817
  const existingModalHost = document.getElementById(data.identifier + '-modal-host');
2818
2818
  if (!reset && existingModalHost) {
2819
2819
  return existingModalHost.shadowRoot;
@@ -2823,12 +2823,6 @@ function atcb_generate_modal_host(host, data, reset = true) {
2823
2823
  }
2824
2824
  let newModalHost = document.createElement('div');
2825
2825
  newModalHost.id = data.identifier + '-modal-host';
2826
- if (data.styleLight) {
2827
- newModalHost.setAttribute('styleLight', data.styleLight);
2828
- }
2829
- if (data.styleDark) {
2830
- newModalHost.setAttribute('styleDark', data.styleDark);
2831
- }
2832
2826
  if (host.host.hasAttribute('cspnonce')) {
2833
2827
  newModalHost.setAttribute('cspnonce', host.host.getAttribute('cspnonce'));
2834
2828
  }
@@ -2837,14 +2831,14 @@ function atcb_generate_modal_host(host, data, reset = true) {
2837
2831
  document.body.append(newModalHost);
2838
2832
  newModalHost.attachShadow({ mode: 'open', delegateFocus: true });
2839
2833
  const elem = document.createElement('template');
2840
- elem.innerHTML = '<div class="atcb-modal-host-initialized" style="translate3D(0, 0, 0);visibility:visible;opacity:1;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;z-index:13999999;"></div>';
2834
+ elem.innerHTML = '<div class="atcb-modal-host-initialized" style="transform:translate3D(0, 0, 0);visibility:visible;opacity:1;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;z-index:13999999;"></div>';
2841
2835
  newModalHost.shadowRoot.append(elem.content.cloneNode(true));
2842
2836
  atcb_set_light_mode(newModalHost.shadowRoot, data);
2843
- atcb_load_css(newModalHost.shadowRoot, null, data);
2837
+ await atcb_load_css(newModalHost.shadowRoot, null, data);
2844
2838
  return newModalHost.shadowRoot;
2845
2839
  }
2846
- function atcb_generate_overlay_dom(host, data) {
2847
- const newHost = atcb_generate_modal_host(host, data);
2840
+ async function atcb_generate_overlay_dom(host, data) {
2841
+ const newHost = await atcb_generate_modal_host(host, data);
2848
2842
  atcb_set_fullsize(newHost.querySelector('.atcb-modal-host-initialized'));
2849
2843
  const nodes = Array.from(host.children);
2850
2844
  nodes.forEach((node) => {
@@ -3535,7 +3529,7 @@ function atcb_save_file(file, filename) {
3535
3529
  }
3536
3530
  }
3537
3531
  function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', addTimeZoneOffset = false) {
3538
- if (data.startTime != null && data.startTime != '' && data.endTime != null && data.endTime != '') {
3532
+ if (data.startTime && data.startTime !== '' && data.endTime && data.endTime !== '') {
3539
3533
  const newStartDate = new Date(data.startDate + 'T' + data.startTime + ':00.000+00:00');
3540
3534
  if (!data.endDate) data.endDate = data.startDate;
3541
3535
  const newEndDate = new Date(data.endDate + 'T' + data.endTime + ':00.000+00:00');
@@ -3580,7 +3574,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
3580
3574
  };
3581
3575
  } else {
3582
3576
  const startDate = data.startDate.split('-');
3583
- const endDate = data.endDate.split('-');
3577
+ const endDate = data.endDate ? data.endDate.split('-') : startDate;
3584
3578
  const newStartDate = new Date(Date.UTC(startDate[0], startDate[1] - 1, startDate[2], 12, 0, 0));
3585
3579
  const newEndDate = new Date(Date.UTC(endDate[0], endDate[1] - 1, endDate[2], 12, 0, 0));
3586
3580
  if (targetCal === 'google' || (targetCal === 'microsoft' && !atcbIsMobile()) || targetCal === 'msteams' || targetCal === 'ical') {
@@ -3633,7 +3627,8 @@ function atcb_format_datetime(datetime, style = 'delimiters', includeTime = true
3633
3627
  }
3634
3628
  function atcb_generate_timestring(dates, language = 'en', subEvent = 'all', decorate = false, browserTimeOverride = false, enforceYear = false, hideTimeZone = false) {
3635
3629
  if (decorate) {
3636
- dates = atcb_decorate_data_dates({ dates: dates }).dates;
3630
+ const tmpRootTZ = atcb_decorate_data_timezone();
3631
+ dates = atcb_decorate_data_dates({ dates: dates, timeZone: tmpRootTZ }).dates;
3637
3632
  }
3638
3633
  let startDateInfo, endDateInfo, timeZoneInfoStart, timeZoneInfoEnd;
3639
3634
  let formattedTimeStart = {};
@@ -4949,15 +4944,15 @@ if (atcbIsBrowser()) {
4949
4944
  if (this.data.proKey) this.proKey = this.data.proKey;
4950
4945
  }
4951
4946
  if (!this.data.name || this.data.name === '') {
4947
+ this.data.proKey = '';
4952
4948
  try {
4953
4949
  this.data = atcb_process_inline_data(this, this.debug);
4954
4950
  } catch (e) {
4955
4951
  if (this.debug) {
4956
4952
  atcb_render_debug_msg(this.shadowRoot, e);
4957
4953
  }
4954
+ this.loaded = true;
4958
4955
  return;
4959
- } finally {
4960
- this.data.proKey = '';
4961
4956
  }
4962
4957
  }
4963
4958
  this.loaded = true;
@@ -4974,7 +4969,7 @@ if (atcbIsBrowser()) {
4974
4969
  }
4975
4970
  static get observedAttributes() {
4976
4971
  const observeAdditionally = ['instance', 'proKey'];
4977
- if (this.proKey != null && this.proKey != '') {
4972
+ if (this.proKey && this.proKey !== '') {
4978
4973
  return atcbWcProParams
4979
4974
  .map((element) => {
4980
4975
  return element.toLowerCase();
@@ -5066,17 +5061,19 @@ function atcb_process_inline_data(el, debug = false) {
5066
5061
  if (!atcb_check_required(data)) {
5067
5062
  const slotInput = el.innerHTML;
5068
5063
  const atcbJsonInput = (function () {
5069
- if (slotInput != '') {
5064
+ if (slotInput !== '') {
5070
5065
  try {
5071
5066
  return JSON.parse(atcb_secure_content(slotInput.replace(/(\\r\\n|\\n|\\r)/g, ''), false));
5072
5067
  } catch (e) {
5073
5068
  throw new Error('Add to Calendar Button generation failed: JSON content provided, but badly formatted (in doubt, try some tool like https://jsonformatter.org/ to validate).\r\nError message: ' + e);
5074
5069
  }
5075
5070
  }
5076
- return '';
5071
+ return null;
5077
5072
  })();
5078
- if (atcbJsonInput.length === 0 && debug) {
5079
- console.error(data.validationError);
5073
+ if (!atcbJsonInput || (Array.isArray(atcbJsonInput) && atcbJsonInput.length === 0) || (typeof atcbJsonInput === 'object' && Object.keys(atcbJsonInput).length === 0)) {
5074
+ if (debug) {
5075
+ console.error(data.validationError);
5076
+ }
5080
5077
  throw new Error('Add to Calendar Button generation failed: no data provided or missing required fields - see console logs for details');
5081
5078
  }
5082
5079
  data = atcbJsonInput;
@@ -5207,7 +5204,7 @@ function atcb_csp_nonce(host) {
5207
5204
  }
5208
5205
  return host.host.getAttribute('cspnonce');
5209
5206
  }
5210
- function atcb_load_css(host, rootObj = null, data) {
5207
+ async function atcb_load_css(host, rootObj = null, data) {
5211
5208
  const nonceVal = atcb_csp_nonce(host);
5212
5209
  if (!document.getElementById('atcb-global-style')) {
5213
5210
  const cssGlobalContent = document.createElement('style');
@@ -5246,9 +5243,8 @@ function atcb_load_css(host, rootObj = null, data) {
5246
5243
  if (nonceVal) {
5247
5244
  cssFile.setAttribute('nonce', nonceVal);
5248
5245
  }
5249
- if (rootObj == null) {
5250
- host.host.style.display = 'none';
5251
- loadExternalCssAsynch(cssFile, host, host.host, nonceVal);
5246
+ if (!rootObj) {
5247
+ await loadExternalCssAsynch(cssFile, host, null, nonceVal, null, false, false, overrideDefaultCss + overrideDarkCss);
5252
5248
  } else {
5253
5249
  const placeholder = document.createElement('div');
5254
5250
  placeholder.classList.add('atcb-placeholder');
@@ -5263,7 +5259,7 @@ function atcb_load_css(host, rootObj = null, data) {
5263
5259
  }
5264
5260
  return;
5265
5261
  }
5266
- if (data.buttonStyle !== 'none' && atcbCssTemplate[`${data.buttonStyle}`] != null) {
5262
+ if (data.buttonStyle !== 'none' && atcbCssTemplate[`${data.buttonStyle}`]) {
5267
5263
  const cssContent = document.createElement('style');
5268
5264
  if (nonceVal) {
5269
5265
  cssContent.setAttribute('nonce', nonceVal);
@@ -5271,7 +5267,7 @@ function atcb_load_css(host, rootObj = null, data) {
5271
5267
  cssContent.innerText = atcbCssTemplate[`${data.buttonStyle}`] + overrideDefaultCss + overrideDarkCss;
5272
5268
  host.prepend(cssContent);
5273
5269
  }
5274
- if (rootObj != null) {
5270
+ if (rootObj) {
5275
5271
  if (data.inline) {
5276
5272
  rootObj.style.display = 'inline-block';
5277
5273
  rootObj.classList.add('atcb-inline');
@@ -5283,7 +5279,7 @@ function atcb_load_css(host, rootObj = null, data) {
5283
5279
  rootObj.classList.remove('atcb-hidden');
5284
5280
  }
5285
5281
  }
5286
- async function loadExternalCssAsynch(cssFile, host, rootObj, nonceVal = null, placeholder = null, inline = false, buttonsList = false, overrideCss = '') {
5282
+ async function loadExternalCssAsynch(cssFile, host, rootObj = null, nonceVal = null, placeholder = null, inline = false, buttonsList = false, overrideCss = '') {
5287
5283
  if (overrideCss !== '') {
5288
5284
  const cssContent = document.createElement('style');
5289
5285
  cssContent.innerText = overrideCss;
@@ -5297,18 +5293,20 @@ async function loadExternalCssAsynch(cssFile, host, rootObj, nonceVal = null, pl
5297
5293
  await new Promise((resolve) => {
5298
5294
  cssFile.onload = resolve;
5299
5295
  });
5300
- if (placeholder) {
5301
- placeholder.remove();
5302
- }
5303
- if (inline) {
5304
- rootObj.style.display = 'inline-block';
5305
- rootObj.classList.add('atcb-inline');
5306
- } else {
5307
- if (buttonsList) {
5308
- rootObj.classList.add('atcb-buttons-list');
5296
+ if (rootObj) {
5297
+ if (placeholder) {
5298
+ placeholder.remove();
5309
5299
  }
5300
+ if (inline) {
5301
+ rootObj.style.display = 'inline-block';
5302
+ rootObj.classList.add('atcb-inline');
5303
+ } else {
5304
+ if (buttonsList) {
5305
+ rootObj.classList.add('atcb-buttons-list');
5306
+ }
5307
+ }
5308
+ rootObj.classList.remove('atcb-hidden');
5310
5309
  }
5311
- rootObj.classList.remove('atcb-hidden');
5312
5310
  } catch (e) {
5313
5311
  console.log(e);
5314
5312
  }