@carbon/ibmdotcom-web-components 2.36.0 → 2.38.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.
Files changed (47) hide show
  1. package/custom-elements.json +41 -4
  2. package/dist/dotcom-shell.js +2 -2
  3. package/dist/dotcom-shell.min.js +2 -2
  4. package/dist/ibmdotcom-web-components-dotcom-shell.js +2 -2
  5. package/dist/ibmdotcom-web-components-dotcom-shell.min.js +2 -2
  6. package/dist/{index-d2169090.js → index-24b3c255.js} +9 -4
  7. package/dist/{index-73809758.js → index-9685143e.js} +5 -5
  8. package/dist/{left-nav-menu-413d20af.js → left-nav-menu-0af37d4c.js} +2 -2
  9. package/dist/{left-nav-menu-bdb856c5.js → left-nav-menu-c7d8a71a.js} +2 -2
  10. package/dist/{left-nav-menu-category-heading-720b41e0.js → left-nav-menu-category-heading-439cde18.js} +2 -2
  11. package/dist/{left-nav-menu-category-heading-9b30621a.js → left-nav-menu-category-heading-a28c7802.js} +2 -2
  12. package/dist/{left-nav-menu-item-9f704897.js → left-nav-menu-item-82b8029e.js} +2 -2
  13. package/dist/{left-nav-menu-item-c76b17ad.js → left-nav-menu-item-9c152cd7.js} +2 -2
  14. package/dist/{left-nav-menu-section-e32b4ca3.js → left-nav-menu-section-1b918ba2.js} +2 -2
  15. package/dist/{left-nav-menu-section-c9a18734.js → left-nav-menu-section-e8b7a3e5.js} +2 -2
  16. package/dist/{left-nav-overlay-3e12bf58.js → left-nav-overlay-0773ec02.js} +2 -2
  17. package/dist/{left-nav-overlay-cb3bbb69.js → left-nav-overlay-335db7f3.js} +2 -2
  18. package/dist/{megamenu-category-group-26d1119f.js → megamenu-category-group-2846f096.js} +2 -2
  19. package/dist/{megamenu-category-group-e879dd24.js → megamenu-category-group-b9b6a718.js} +2 -2
  20. package/dist/{megamenu-category-group-copy-09b59d38.js → megamenu-category-group-copy-c3dad805.js} +2 -2
  21. package/dist/{megamenu-category-group-copy-72c2f8e0.js → megamenu-category-group-copy-f5812d47.js} +2 -2
  22. package/dist/{megamenu-category-heading-e0d808fd.js → megamenu-category-heading-0225721b.js} +2 -2
  23. package/dist/{megamenu-category-heading-1a6b0c95.js → megamenu-category-heading-1867f5ac.js} +2 -2
  24. package/dist/{megamenu-category-link-d0ae1be4.js → megamenu-category-link-457e54ab.js} +2 -2
  25. package/dist/{megamenu-category-link-203cea99.js → megamenu-category-link-ae52c0cf.js} +2 -2
  26. package/dist/{megamenu-category-link-group-67b1c22e.js → megamenu-category-link-group-7ed242ff.js} +2 -2
  27. package/dist/{megamenu-category-link-group-f032182d.js → megamenu-category-link-group-fc15e4e7.js} +2 -2
  28. package/dist/{megamenu-left-navigation-7184f258.js → megamenu-left-navigation-0e90c4ce.js} +2 -2
  29. package/dist/{megamenu-left-navigation-c15d6a59.js → megamenu-left-navigation-36add7ad.js} +2 -2
  30. package/dist/{megamenu-overlay-2b454292.js → megamenu-overlay-749fbb55.js} +2 -2
  31. package/dist/{megamenu-overlay-04e55743.js → megamenu-overlay-e7e17e29.js} +2 -2
  32. package/dist/{megamenu-tab-07201542.js → megamenu-tab-2642435a.js} +2 -2
  33. package/dist/{megamenu-tab-8b2e7818.js → megamenu-tab-943fe375.js} +2 -2
  34. package/es/components/masthead/masthead-menu-button.js +1 -1
  35. package/es/components/masthead/masthead-menu-button.js.map +1 -1
  36. package/es/components/notice-choice/notice-choice.d.ts +27 -17
  37. package/es/components/notice-choice/notice-choice.js +345 -206
  38. package/es/components/notice-choice/notice-choice.js.map +1 -1
  39. package/es/components/notice-choice/utils.d.ts +6 -0
  40. package/es/components/notice-choice/utils.js +33 -0
  41. package/es/components/notice-choice/utils.js.map +1 -1
  42. package/es/components/pricing-table/pricing-table.d.ts +4 -2
  43. package/es/components/pricing-table/pricing-table.js +10 -9
  44. package/es/components/pricing-table/pricing-table.js.map +1 -1
  45. package/es/internal/vendor/@carbon/ibmdotcom-services/services/Translation/Translation.js +5 -0
  46. package/lib/internal/vendor/@carbon/ibmdotcom-services/services/Translation/Translation.js +5 -0
  47. package/package.json +5 -5
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _decorate from "@babel/runtime/helpers/esm/decorate";
3
3
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
4
4
  import _get from "@babel/runtime/helpers/esm/get";
5
- let _ = t => t,
5
+ let _2 = t => t,
6
6
  _t,
7
7
  _t2,
8
8
  _t3,
@@ -26,25 +26,18 @@ function _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prot
26
26
  *
27
27
  * This source code is licensed under the Apache-2.0 license found in the
28
28
  * LICENSE file in the root directory of this source tree.
29
- */ /**
30
- * @license
31
- *
32
- * Copyright IBM Corp. 2020, 2024
33
- *
34
- * This source code is licensed under the Apache-2.0 license found in the
35
- * LICENSE file in the root directory of this source tree.
36
- */
29
+ */
37
30
 
38
- import { loadContent, loadSettings, checkEmailStatus } from "./services.js";
39
31
  import { html, LitElement } from 'lit';
40
32
  import { property } from 'lit/decorators.js';
41
- import { pwsValueMap, resetToWorldWideContent } from "./utils.js";
42
- import settings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
43
33
  import StableSelectorMixin from "../../globals/mixins/stable-selector.js";
44
- import styles from "././notice-choice.css.js";
45
- import { unsafeHTML } from 'lit/directives/unsafe-html.js';
46
34
  import { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';
47
35
  import '@carbon/web-components/es/components/skeleton-text/index.js';
36
+ import settings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
37
+ import { pwsValueMap, processCustomText, resetToWorldWideContent } from "./utils.js";
38
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
39
+ import { loadContent, loadSettings, checkEmailStatus } from "./services.js";
40
+ import styles from "././notice-choice.css.js";
48
41
  const {
49
42
  prefix,
50
43
  stablePrefix: c4dPrefix
@@ -134,7 +127,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
134
127
  })],
135
128
  key: "termsConditionLink",
136
129
  value() {
137
- return html(_t || (_t = _``));
130
+ return html(_t || (_t = _2``));
138
131
  }
139
132
  }, {
140
133
  kind: "field",
@@ -166,6 +159,26 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
166
159
  value() {
167
160
  return 'prod';
168
161
  }
162
+ }, {
163
+ kind: "field",
164
+ decorators: [property({
165
+ type: String,
166
+ attribute: 'show-custom-notice-text'
167
+ })],
168
+ key: "showCustomNotice",
169
+ value() {
170
+ return 'false';
171
+ }
172
+ }, {
173
+ kind: "field",
174
+ decorators: [property({
175
+ type: String,
176
+ attribute: 'custom-notice-text'
177
+ })],
178
+ key: "customNoticeText",
179
+ value() {
180
+ return '';
181
+ }
169
182
  }, {
170
183
  kind: "field",
171
184
  decorators: [property({
@@ -330,7 +343,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
330
343
  })],
331
344
  key: "preText",
332
345
  value() {
333
- return html(_t2 || (_t2 = _``));
346
+ return html(_t2 || (_t2 = _2``));
334
347
  }
335
348
  }, {
336
349
  kind: "field",
@@ -340,7 +353,27 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
340
353
  })],
341
354
  key: "defaultPreText",
342
355
  value() {
343
- return html(_t3 || (_t3 = _``));
356
+ return html(_t3 || (_t3 = _2``));
357
+ }
358
+ }, {
359
+ kind: "field",
360
+ decorators: [property({
361
+ type: Array,
362
+ attribute: false
363
+ })],
364
+ key: "doubleOptInCountries",
365
+ value() {
366
+ return [];
367
+ }
368
+ }, {
369
+ kind: "field",
370
+ decorators: [property({
371
+ type: Boolean,
372
+ attribute: false
373
+ })],
374
+ key: "isOriginalTextChanged",
375
+ value() {
376
+ return false;
344
377
  }
345
378
  }, {
346
379
  kind: "field",
@@ -369,6 +402,10 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
369
402
  EMAIL: {
370
403
  checkBoxStatus: 'PERMISSION',
371
404
  punsStatus: ''
405
+ },
406
+ PHONE: {
407
+ checkBoxStatus: 'PERMISSION',
408
+ punsStatus: ''
372
409
  }
373
410
  };
374
411
  }
@@ -400,6 +437,24 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
400
437
  value() {
401
438
  return {};
402
439
  }
440
+ }, {
441
+ kind: "field",
442
+ decorators: [property({
443
+ type: Object,
444
+ attribute: false
445
+ })],
446
+ key: "customNoticeTextValue",
447
+ value() {
448
+ return {
449
+ text: ''
450
+ };
451
+ }
452
+ }, {
453
+ kind: "field",
454
+ key: "pwsFieldsMap",
455
+ value() {
456
+ return new Map([['NC_HIDDEN_EMAIL', 'permission_email'], ['NC_HIDDEN_PHONE', 'permission_phone'], ['preventFormSubmission', 'preventFormSubmission'], ['Q_CHINA_PIPL', 'Q_CHINA_PIPL'], ['Q_COUNTRY_TRANSFER', 'Q_COUNTRY_TRANSFER'], ['NC_HIDDEN_EMAIL_VALUE', 'NC_HIDDEN_EMAIL'], ['NC_HIDDEN_PHONE_VALUE', 'NC_HIDDEN_PHONE'], ['EMAIL_CU', 'EMAIL_CU'], ['EMAIL_CC', 'EMAIL_CC'], ['EMAIL_UC', 'EMAIL_UC'], ['EMAIL_UU', 'EMAIL_UU'], ['PHONE_CU', 'PHONE_CU'], ['PHONE_CC', 'PHONE_CC'], ['PHONE_UC', 'PHONE_UC'], ['PHONE_UU', 'PHONE_UU'], ['EMAIL_NOTICE_ONLY', 'EMAIL_NOTICE_ONLY'], ['PHONE_NOTICE_ONLY', 'PHONE_NOTICE_ONLY'], ['NC_HIDDEN_PHONE_NONE', 'NC_HIDDEN_PHONE_NONE']]);
457
+ }
403
458
  }, {
404
459
  kind: "method",
405
460
  key: "connectedCallback",
@@ -446,50 +501,10 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
446
501
  }
447
502
  }, {
448
503
  kind: "method",
449
- key: "handleEmailChange",
450
- value: function handleEmailChange(value, oldValue, hasValue) {
451
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
452
- this.emailValid = false;
453
- if (hasValue && typeof value === 'string' && value.trim() && oldValue !== value && emailRegex.test(value.trim())) {
454
- this.email = value.trim();
455
- this.onEmailChange();
456
- } else {
457
- this.showCheckBox = false;
458
- }
459
- }
460
- }, {
461
- kind: "method",
462
- key: "loadContentWithFallback",
463
- value: function loadContentWithFallback(lang) {
464
- loadContent(lang, this.environment, ncData => {
465
- this.isLoading = false;
466
- this.ncData = ncData;
467
- this.prepareCheckboxes();
468
- }, () => this.defaultLoadContent());
469
- }
470
- }, {
471
- kind: "method",
472
- key: "handleLanguageOrEnvironmentChange",
473
- value: function handleLanguageOrEnvironmentChange(value) {
474
- var _this$language;
475
- if (['stage', 'prod'].includes(value)) {
476
- this.environment = value;
477
- } else {
478
- this.language = value;
479
- }
480
- const langPart = (_this$language = this.language) === null || _this$language === void 0 ? void 0 : _this$language.split(/[-_]/)[0];
481
- this.isLoading = true;
482
- loadSettings(this.environment, settings => {
483
- var _this$language2;
484
- this.countrySettings = settings.preferences;
485
- this.noticeOnly = settings.noticeOnly || ['us'];
486
- this.supportedLanguages = settings.supportedLanguages || {};
487
- const supportedLang = this.supportedLanguages[((_this$language2 = this.language) === null || _this$language2 === void 0 ? void 0 : _this$language2.toLowerCase()) || ''] || langPart && this.supportedLanguages[langPart.toLowerCase()] || 'en';
488
- this.loadContentWithFallback(supportedLang);
489
- }, err => {
490
- console.error('Error loading settings', err);
491
- this.loadContentWithFallback('en');
492
- });
504
+ key: "countryChanged",
505
+ value: function countryChanged() {
506
+ resetToWorldWideContent();
507
+ this.countryChangeAction();
493
508
  }
494
509
  }, {
495
510
  kind: "method",
@@ -526,10 +541,85 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
526
541
  case 'email':
527
542
  this.handleEmailChange(value, oldValue, hasValue);
528
543
  return;
544
+ case 'customNoticeText':
545
+ {
546
+ if (oldValue === value) {
547
+ return;
548
+ }
549
+ this.customNoticeTextValue = this.parseCustomNoticeText(value);
550
+ return;
551
+ }
552
+ case 'showCustomNotice':
553
+ if (oldValue !== value && typeof value === 'string') {
554
+ this.showCustomNotice = JSON.parse(value) || false;
555
+ }
556
+ return;
529
557
  default:
530
558
  return;
531
559
  }
532
560
  }
561
+ }, {
562
+ kind: "method",
563
+ key: "htmlDecode",
564
+ value: function htmlDecode(text) {
565
+ const textarea = document.createElement('textarea');
566
+ textarea.innerHTML = text;
567
+ return textarea.value;
568
+ }
569
+ }, {
570
+ kind: "method",
571
+ key: "tryParseJson",
572
+ value: function tryParseJson(text) {
573
+ try {
574
+ return JSON.parse(text);
575
+ } catch (error) {
576
+ // return null
577
+ return null;
578
+ }
579
+ }
580
+ }, {
581
+ kind: "method",
582
+ key: "normalizeObjectLiteral",
583
+ value: function normalizeObjectLiteral(input) {
584
+ let normalized = input;
585
+ normalized = normalized.replace(/`([^`]*)`/g, (_, content) => `"${content}"`);
586
+ normalized = normalized.replace(/'([^']*)'/g, (_, content) => `"${content}"`);
587
+ normalized = normalized.replace(/([{,]\s*)([a-zA-Z0-9_]+)\s*:/g, '$1"$2":');
588
+ normalized = normalized.replace(/,(\s*[}\]])/g, '$1');
589
+ return normalized;
590
+ }
591
+ }, {
592
+ kind: "method",
593
+ key: "parseCustomNoticeText",
594
+ value: function parseCustomNoticeText(rawValue) {
595
+ if (typeof rawValue !== 'string') {
596
+ return rawValue;
597
+ }
598
+ const decodedText = this.htmlDecode(rawValue).trim();
599
+ const jsonDirect = this.tryParseJson(decodedText);
600
+ if (jsonDirect !== null) {
601
+ return jsonDirect;
602
+ }
603
+ const normalized = this.normalizeObjectLiteral(decodedText);
604
+ const jsonNormalized = this.tryParseJson(normalized);
605
+ if (jsonNormalized !== null) {
606
+ return jsonNormalized;
607
+ }
608
+ return {
609
+ text: decodedText
610
+ };
611
+ }
612
+ }, {
613
+ kind: "method",
614
+ key: "_handleEmailCheckFailure",
615
+ value: function _handleEmailCheckFailure(responseData, expired) {
616
+ this.isAnnualPeriodExpired = expired;
617
+ this.showCheckBox = true;
618
+ this.renderCombinedEmailPhoneSection();
619
+ this._onEmailStatusChanged('emailStats', _objectSpread(_objectSpread({}, responseData), {}, {
620
+ isAnnualPeriodExpired: expired
621
+ }));
622
+ }
533
623
  }, {
534
624
  kind: "method",
535
625
  key: "onEmailChange",
@@ -568,44 +658,89 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
568
658
  this._handleEmailCheckFailure(error, true);
569
659
  });
570
660
  }
571
-
572
- /**
573
- * Centralized handler for failed or invalid responses.
574
- */
575
661
  }, {
576
662
  kind: "method",
577
- key: "_handleEmailCheckFailure",
578
- value: function _handleEmailCheckFailure(responseData, expired) {
579
- this.isAnnualPeriodExpired = expired;
580
- this.showCheckBox = true;
581
- this.renderCombinedEmailPhoneSection();
582
- this._onEmailStatusChanged('emailStats', _objectSpread(_objectSpread({}, responseData), {}, {
583
- isAnnualPeriodExpired: expired
584
- }));
663
+ key: "handleEmailChange",
664
+ value: function handleEmailChange(value, oldValue, hasValue) {
665
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
666
+ this.emailValid = false;
667
+ if (hasValue && typeof value === 'string' && value.trim() && oldValue !== value && emailRegex.test(value.trim())) {
668
+ this.email = value.trim();
669
+ this.onEmailChange();
670
+ } else {
671
+ this.showCheckBox = false;
672
+ }
585
673
  }
586
674
  }, {
587
675
  kind: "method",
588
- key: "_initSettingsAndContent",
589
- value: function _initSettingsAndContent(language) {
590
- const [lang] = language.split(/[-_]/);
591
- const defaultLang = this.supportedLanguages[language === null || language === void 0 ? void 0 : language.toLocaleLowerCase()] || this.supportedLanguages[lang === null || lang === void 0 ? void 0 : lang.toLocaleLowerCase()] || 'en';
676
+ key: "loadContentWithFallback",
677
+ value: function loadContentWithFallback(lang) {
678
+ loadContent(lang, this.environment, ncData => {
679
+ this.isLoading = false;
680
+ this.ncData = ncData;
681
+ this.prepareCheckboxes();
682
+ }, () => this.defaultLoadContent());
683
+ }
684
+ }, {
685
+ kind: "method",
686
+ key: "handleLanguageOrEnvironmentChange",
687
+ value: function handleLanguageOrEnvironmentChange(value) {
688
+ var _this$language;
689
+ if (['stage', 'prod'].includes(value)) {
690
+ this.environment = value;
691
+ } else {
692
+ this.language = value;
693
+ }
694
+ const langPart = (_this$language = this.language) === null || _this$language === void 0 ? void 0 : _this$language.split(/[-_]/)[0];
695
+ this.isLoading = true;
592
696
  loadSettings(this.environment, settings => {
697
+ var _this$language2;
593
698
  this.countrySettings = settings.preferences;
594
699
  this.noticeOnly = settings.noticeOnly || ['us'];
595
700
  this.supportedLanguages = settings.supportedLanguages || {};
596
- }, () => this.defaultLoadSettings());
597
- loadContent(defaultLang, this.environment, ncData => {
598
- this.ncData = ncData;
599
- this.prepareCheckboxes();
600
- this.countryChanged();
601
- }, () => this.defaultLoadContent());
701
+ this.isOriginalTextChanged = true;
702
+ const supportedLang = this.supportedLanguages[((_this$language2 = this.language) === null || _this$language2 === void 0 ? void 0 : _this$language2.toLowerCase()) || ''] || langPart && this.supportedLanguages[langPart.toLowerCase()] || 'en';
703
+ this.loadContentWithFallback(supportedLang);
704
+ }, err => {
705
+ console.error('Error loading settings', err);
706
+ this.loadContentWithFallback('en');
707
+ });
708
+ }
709
+ }, {
710
+ kind: "method",
711
+ key: "setDefaultSelections",
712
+ value: function setDefaultSelections() {
713
+ var _this$country, _this$countrySettings2, _this$countrySettings3;
714
+ if (this.enableAllOptIn || !this.checkboxes) {
715
+ return;
716
+ }
717
+ const countryCode = (_this$country = this.country) === null || _this$country === void 0 ? void 0 : _this$country.toLowerCase();
718
+ const countryStatus = (_this$countrySettings2 = (_this$countrySettings3 = this.countrySettings) === null || _this$countrySettings3 === void 0 ? void 0 : _this$countrySettings3[countryCode]) !== null && _this$countrySettings2 !== void 0 ? _this$countrySettings2 : {
719
+ email: 'opt-in',
720
+ phone: 'opt-in'
721
+ };
722
+ const newValues = _objectSpread({}, this.values);
723
+ for (const key of Object.keys(this.checkboxes)) {
724
+ const isOptOut = countryStatus[key.toLowerCase()] === 'opt-out';
725
+ newValues[key] = isOptOut;
726
+ const hiddenFieldName = `NC_HIDDEN_${key}`;
727
+ newValues[hiddenFieldName] = isOptOut ? 'OPT_OUT' : 'OPT_IN';
728
+ if (Object.prototype.hasOwnProperty.call(this.defaultValues, key)) {
729
+ newValues[key] = this.defaultValues[key];
730
+ }
731
+ this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : 'OPT_OUT');
732
+ }
733
+ const changed = Object.keys(newValues).some(field => newValues[field] !== this.values[field]);
734
+ if (changed) {
735
+ this.values = newValues;
736
+ }
602
737
  }
603
738
  }, {
604
739
  kind: "method",
605
740
  key: "countryChangeAction",
606
741
  value: function countryChangeAction() {
607
- var _this$country, _this$ncData;
608
- const countryCode = (_this$country = this.country) === null || _this$country === void 0 ? void 0 : _this$country.toLowerCase();
742
+ var _this$country2, _this$ncData;
743
+ const countryCode = (_this$country2 = this.country) === null || _this$country2 === void 0 ? void 0 : _this$country2.toLowerCase();
609
744
  this.preventFormSubmission = false;
610
745
  const mandatory = (_this$ncData = this.ncData) === null || _this$ncData === void 0 || (_this$ncData = _this$ncData.mandatoryCheckbox) === null || _this$ncData === void 0 ? void 0 : _this$ncData[countryCode];
611
746
  this.setDefaultSelections();
@@ -628,67 +763,48 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
628
763
  }
629
764
  }, {
630
765
  kind: "method",
631
- key: "postTextTemplate",
632
- value: function postTextTemplate() {
633
- if (this.ncData) {
634
- const OtherPreferences = this.ncData.trialPrivacyText;
635
- let postText = this.ncData.postText;
636
- if (postText) {
637
- postText = '<p part="ncPostText">' + postText + '</p>';
638
- }
639
- if (!this.termsConditionLink.strings && this.termsConditionLink) {
640
- const originalValue = OtherPreferences;
641
- const matchedValue = originalValue.match(/<tc>.*<\/tc>/g);
642
- if (matchedValue) {
643
- const anrTagHtml = matchedValue[0].replace(/<tc>|<\/tc>/g, '');
644
- const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' part="tooltip-link">${anrTagHtml}</a>`;
645
- const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');
646
- postText = postText + originalValue.replace(reg, link).replace(/<p>/g, '<p part="nc-trial-text" id="nc-trial-text">');
647
- }
648
- }
649
- if (postText !== '') {
650
- postText = "<div part='ncPostTextContainer' id='ncPostTextContainer'>" + postText + '</div>';
651
- }
652
- return html(_t4 || (_t4 = _`${0}`), unsafeHTML(postText));
653
- } else {
654
- return html(_t5 || (_t5 = _``));
655
- }
766
+ key: "defaultLoadSettings",
767
+ value: function defaultLoadSettings() {
768
+ loadSettings(this.environment, countryPreferencesSettings => {
769
+ this.countrySettings = countryPreferencesSettings.preferences;
770
+ this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
771
+ this.supportedLanguages = settings.supportedLanguages || {};
772
+ this.isOriginalTextChanged = true;
773
+ }, error => {
774
+ console.error('error loading content', error);
775
+ });
656
776
  }
657
777
  }, {
658
778
  kind: "method",
659
- key: "countryChanged",
660
- value: function countryChanged() {
661
- resetToWorldWideContent();
662
- this.countryChangeAction();
779
+ key: "_initSettingsAndContent",
780
+ value: function _initSettingsAndContent(language) {
781
+ const [lang] = language.split(/[-_]/);
782
+ const defaultLang = this.supportedLanguages[language === null || language === void 0 ? void 0 : language.toLocaleLowerCase()] || this.supportedLanguages[lang === null || lang === void 0 ? void 0 : lang.toLocaleLowerCase()] || 'en';
783
+ loadSettings(this.environment, settings => {
784
+ this.countrySettings = settings.preferences;
785
+ this.noticeOnly = settings.noticeOnly || ['us'];
786
+ this.supportedLanguages = settings.supportedLanguages || {};
787
+ this.doubleOptInCountries = settings.doubleOptInCountries || [];
788
+ this.isOriginalTextChanged = true;
789
+ }, () => this.defaultLoadSettings());
790
+ loadContent(defaultLang, this.environment, ncData => {
791
+ this.ncData = ncData;
792
+ this.prepareCheckboxes();
793
+ this.countryChanged();
794
+ }, () => this.defaultLoadContent());
663
795
  }
664
796
  }, {
665
797
  kind: "method",
666
- key: "setDefaultSelections",
667
- value: function setDefaultSelections() {
668
- var _this$country2, _this$countrySettings2, _this$countrySettings3;
669
- if (this.enableAllOptIn || !this.checkboxes) {
670
- return;
671
- }
672
- const countryCode = (_this$country2 = this.country) === null || _this$country2 === void 0 ? void 0 : _this$country2.toLowerCase();
673
- const countryStatus = (_this$countrySettings2 = (_this$countrySettings3 = this.countrySettings) === null || _this$countrySettings3 === void 0 ? void 0 : _this$countrySettings3[countryCode]) !== null && _this$countrySettings2 !== void 0 ? _this$countrySettings2 : {
674
- email: 'opt-in',
675
- phone: 'opt-in'
676
- };
677
- const newValues = _objectSpread({}, this.values);
678
- for (const key of Object.keys(this.checkboxes)) {
679
- const isOptOut = countryStatus[key.toLowerCase()] === 'opt-out';
680
- newValues[key] = isOptOut;
681
- const hiddenFieldName = `NC_HIDDEN_${key}`;
682
- newValues[hiddenFieldName] = isOptOut ? 'OPT_OUT' : 'OPT_IN';
683
- if (Object.prototype.hasOwnProperty.call(this.defaultValues, key)) {
684
- newValues[key] = this.defaultValues[key];
685
- }
686
- this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : 'OPT_OUT');
687
- }
688
- const changed = Object.keys(newValues).some(field => newValues[field] !== this.values[field]);
689
- if (changed) {
690
- this.values = newValues;
691
- }
798
+ key: "defaultLoadContent",
799
+ value: function defaultLoadContent() {
800
+ loadContent('en', this.environment, ncData => {
801
+ this.ncData = ncData;
802
+ this.prepareCheckboxes();
803
+ this.countryChanged();
804
+ }, error => {
805
+ this.isLoading = false;
806
+ console.error('error loading content', error);
807
+ });
692
808
  }
693
809
  }, {
694
810
  kind: "method",
@@ -728,31 +844,6 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
728
844
  this.performUpdate();
729
845
  }
730
846
  }
731
- }, {
732
- kind: "method",
733
- key: "defaultLoadContent",
734
- value: function defaultLoadContent() {
735
- loadContent('en', this.environment, ncData => {
736
- this.ncData = ncData;
737
- this.prepareCheckboxes();
738
- this.countryChanged();
739
- }, error => {
740
- this.isLoading = false;
741
- console.error('error loading content', error);
742
- });
743
- }
744
- }, {
745
- kind: "method",
746
- key: "defaultLoadSettings",
747
- value: function defaultLoadSettings() {
748
- loadSettings(this.environment, countryPreferencesSettings => {
749
- this.countrySettings = countryPreferencesSettings.preferences;
750
- this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
751
- this.supportedLanguages = settings.supportedLanguages || {};
752
- }, error => {
753
- console.error('error loading content', error);
754
- });
755
- }
756
847
  }, {
757
848
  kind: "method",
758
849
  key: "checkCombineEmailPhoneBoxChange",
@@ -766,14 +857,14 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
766
857
  const hiddenFieldName = `NC_HIDDEN_${id}`;
767
858
  const hiddenFieldStatus = checked ? 'PERMISSION' : 'SUPPRESSION';
768
859
  this.valuesForEmailPhone[id]['checkBoxStatus'] = hiddenFieldStatus;
769
- let statusPrechecked = '';
860
+ let statusPreChecked = '';
770
861
  switch (id) {
771
862
  case 'EMAIL':
772
863
  case 'PHONE':
773
- statusPrechecked = this.combinedEmailPhonePrechecked && !checked ? 'CU' : !this.combinedEmailPhonePrechecked && checked ? 'UC' : this.combinedEmailPhonePrechecked && checked ? 'CC' : 'UU';
864
+ statusPreChecked = this.combinedEmailPhonePrechecked && !checked ? 'CU' : !this.combinedEmailPhonePrechecked && checked ? 'UC' : this.combinedEmailPhonePrechecked && checked ? 'CC' : 'UU';
774
865
  break;
775
866
  }
776
- this.valuesForEmailPhone[id]['punsStatus'] = statusPrechecked;
867
+ this.valuesForEmailPhone[id]['punsStatus'] = statusPreChecked;
777
868
  this._onChange(hiddenFieldName, hiddenFieldStatus);
778
869
  this._onChange(`${hiddenFieldName}_VALUE`, `NC_HIDDEN_${hiddenFieldStatus}`);
779
870
  });
@@ -783,7 +874,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
783
874
  key: "renderCheckbox",
784
875
  value: function renderCheckbox(preText, checked) {
785
876
  const checkboxId = 'EMAIL_PHONE_CHECKBOX';
786
- return html(_t6 || (_t6 = _`
877
+ return html(_t4 || (_t4 = _2`
787
878
  <span part="container">
788
879
  <div
789
880
  class="${0}--form-item cds--checkbox-wrapper"
@@ -815,9 +906,9 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
815
906
  kind: "method",
816
907
  key: "combinedPreTextTemplate",
817
908
  value: function combinedPreTextTemplate() {
818
- var _this$country3, _this$state, _content$state, _content$country;
909
+ var _this$country3, _this$state, _content$state, _content$country, _this$values, _this$doubleOptInCoun, _this$noticeOnly;
819
910
  if (!this.ncData) {
820
- return html(_t7 || (_t7 = _``));
911
+ return html(_t5 || (_t5 = _2``));
821
912
  }
822
913
  const content = this.ncData;
823
914
  const country = ((_this$country3 = this.country) === null || _this$country3 === void 0 ? void 0 : _this$country3.toLowerCase()) || '';
@@ -852,17 +943,40 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
852
943
  if (countryContent) {
853
944
  preText = !this.emailValid ? content.annualDefaultText : this.isAnnualPeriodExpired ? countryContent.combinedConsent : countryContent.annualText;
854
945
  }
946
+ const hasEmail = Boolean((_this$values = this.values) === null || _this$values === void 0 ? void 0 : _this$values.EMAIL);
947
+ const inDoubleOptIn = (_this$doubleOptInCoun = this.doubleOptInCountries) === null || _this$doubleOptInCoun === void 0 ? void 0 : _this$doubleOptInCoun.includes(country);
948
+ const inNoticeOnly = (_this$noticeOnly = this.noticeOnly) === null || _this$noticeOnly === void 0 ? void 0 : _this$noticeOnly.includes(country);
949
+ if (this.isOriginalTextChanged) {
950
+ this._onNoticeTextChange('noticeTextChange', preText);
951
+ this.isOriginalTextChanged = false;
952
+ }
953
+ if (this.showCustomNotice) {
954
+ var _this$customNoticeTex;
955
+ if (this.customNoticeTextValue && (_this$customNoticeTex = this.customNoticeTextValue.text) !== null && _this$customNoticeTex !== void 0 && _this$customNoticeTex.trim()) {
956
+ preText = processCustomText(this.customNoticeTextValue);
957
+ } else {
958
+ preText = content.thirdPartyCombinedConsent;
959
+ }
960
+ }
961
+ // Call only if changed
962
+
963
+ // 4. Add double opt-in text if applicable
964
+ if (hasEmail && inDoubleOptIn) {
965
+ var _content$mkDoubleOptI;
966
+ const text = content === null || content === void 0 || (_content$mkDoubleOptI = content.mkDoubleOptInText) === null || _content$mkDoubleOptI === void 0 ? void 0 : _content$mkDoubleOptI.trim();
967
+ if (text) {
968
+ preText += ` <span part="double-opt-in-text">${text}</span>`;
969
+ }
970
+ }
855
971
 
856
- // 4. permission/suppression logic
857
- if (!(this.noticeOnly || []).includes(country)) {
858
- let isPermission = false;
859
- isPermission = this.values.EMAIL;
860
- const checked = isPermission;
972
+ // 5. permission/suppression logic
973
+ if (!inNoticeOnly) {
974
+ const checked = hasEmail;
861
975
  if (this.showCheckBox) {
862
976
  return this.renderCheckbox(preText, checked);
863
977
  }
864
978
  }
865
- return html(_t8 || (_t8 = _`${0}`), unsafeHTML(preText));
979
+ return html(_t6 || (_t6 = _2`${0}`), unsafeHTML(preText));
866
980
  }
867
981
  }, {
868
982
  kind: "method",
@@ -902,19 +1016,20 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
902
1016
  value: function countryBasedLegalNotice() {
903
1017
  var _this$ncData5;
904
1018
  const countryCode = this.country.toLowerCase();
1019
+ this.isOriginalTextChanged = true;
905
1020
  const mandatoryCheckboxes = (_this$ncData5 = this.ncData) === null || _this$ncData5 === void 0 || (_this$ncData5 = _this$ncData5.mandatoryCheckbox) === null || _this$ncData5 === void 0 ? void 0 : _this$ncData5[countryCode];
906
1021
  if (!mandatoryCheckboxes) {
907
1022
  return [];
908
1023
  }
909
1024
  return Object.entries(mandatoryCheckboxes).map(([key, checkbox]) => {
910
1025
  const legalTextName = key.replace(/([A-Z]+)/g, '-$1').toLowerCase();
911
- const errorTemplate = !this.hideErrorMessage && this.preventFormSubmission ? html(_t9 || (_t9 = _`<span
1026
+ const errorTemplate = !this.hideErrorMessage && this.preventFormSubmission ? html(_t7 || (_t7 = _2`<span
912
1027
  class="nc-error"
913
1028
  part="error"
914
1029
  style="color:#da1e28;font-size:.75rem">
915
1030
  ${0}
916
1031
  </span>`), checkbox.error) : null;
917
- return html(_t10 || (_t10 = _`
1032
+ return html(_t8 || (_t8 = _2`
918
1033
  <span>
919
1034
  <div
920
1035
  class="${0}--form-item bx--checkbox-wrapper"
@@ -945,6 +1060,34 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
945
1060
  `), prefix, legalTextName, legalTextName, prefix, checkbox.mrs_field, checkbox.mrs_field, this.checkBoxLegalChange, checkbox.mrs_field, prefix, prefix, checkbox.mrs_field, prefix, checkbox.text, errorTemplate);
946
1061
  });
947
1062
  }
1063
+ }, {
1064
+ kind: "method",
1065
+ key: "postTextTemplate",
1066
+ value: function postTextTemplate() {
1067
+ if (this.ncData) {
1068
+ const OtherPreferences = this.ncData.trialPrivacyText;
1069
+ let postText = this.ncData.postText;
1070
+ if (postText) {
1071
+ postText = '<p part="ncPostText">' + postText + '</p>';
1072
+ }
1073
+ if (!this.termsConditionLink.strings && this.termsConditionLink) {
1074
+ const originalValue = OtherPreferences;
1075
+ const matchedValue = originalValue.match(/<tc>.*<\/tc>/g);
1076
+ if (matchedValue) {
1077
+ const anrTagHtml = matchedValue[0].replace(/<tc>|<\/tc>/g, '');
1078
+ const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' part="tooltip-link">${anrTagHtml}</a>`;
1079
+ const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');
1080
+ postText = postText + originalValue.replace(reg, link).replace(/<p>/g, '<p part="nc-trial-text" id="nc-trial-text">');
1081
+ }
1082
+ }
1083
+ if (postText !== '') {
1084
+ postText = "<div part='ncPostTextContainer' id='ncPostTextContainer'>" + postText + '</div>';
1085
+ }
1086
+ return html(_t9 || (_t9 = _2`${0}`), unsafeHTML(postText));
1087
+ } else {
1088
+ return html(_t10 || (_t10 = _2``));
1089
+ }
1090
+ }
948
1091
  }, {
949
1092
  kind: "method",
950
1093
  key: "renderCombinedEmailPhoneSection",
@@ -968,7 +1111,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
968
1111
  }
969
1112
  return ((_this$valuesForEmailP2 = this.valuesForEmailPhone[key]) === null || _this$valuesForEmailP2 === void 0 ? void 0 : _this$valuesForEmailP2.punsStatus) || (checked ? 'CC' : 'UU');
970
1113
  };
971
- const createHiddenInput = (id, value) => html(_t11 || (_t11 = _`
1114
+ const createHiddenInput = (id, value) => html(_t11 || (_t11 = _2`
972
1115
  <input type="hidden" id=${0} name=${0} value=${0} />
973
1116
  `), id, id, value);
974
1117
  const hiddenInputs = Object.keys(this.checkboxes).map(key => {
@@ -990,7 +1133,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
990
1133
  }
991
1134
  return createHiddenInput(hiddenBoxId, hiddenValue);
992
1135
  });
993
- return html(_t12 || (_t12 = _`
1136
+ return html(_t12 || (_t12 = _2`
994
1137
  <section class="${0}--nc" part="section">
995
1138
  <p part="ncHeading" id="ncHeading" class="${0}--nc__pre-text">
996
1139
  ${0} ${0}
@@ -1004,19 +1147,30 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
1004
1147
  `), prefix, c4dPrefix, this.countryBasedLegalNotice(), this.combinedPreTextTemplate(), hiddenInputs, prefix, prefix, this.postTextTemplate(), createHiddenInput('preventFormSubmission', String(this.preventFormSubmission)));
1005
1148
  }
1006
1149
  }, {
1007
- kind: "field",
1008
- key: "pwsFieldsMap",
1009
- value() {
1010
- return new Map([['NC_HIDDEN_EMAIL', 'permission_email'], ['NC_HIDDEN_PHONE', 'permission_phone'], ['preventFormSubmission', 'preventFormSubmission'], ['Q_CHINA_PIPL', 'Q_CHINA_PIPL'], ['Q_COUNTRY_TRANSFER', 'Q_COUNTRY_TRANSFER'], ['NC_HIDDEN_EMAIL_VALUE', 'NC_HIDDEN_EMAIL'], ['NC_HIDDEN_PHONE_VALUE', 'NC_HIDDEN_PHONE'], ['EMAIL_CU', 'EMAIL_CU'], ['EMAIL_CC', 'EMAIL_CC'], ['EMAIL_UC', 'EMAIL_UC'], ['EMAIL_UU', 'EMAIL_UU'], ['PHONE_CU', 'PHONE_CU'], ['PHONE_CC', 'PHONE_CC'], ['PHONE_UC', 'PHONE_UC'], ['PHONE_UU', 'PHONE_UU'], ['EMAIL_NOTICE_ONLY', 'EMAIL_NOTICE_ONLY'], ['PHONE_NOTICE_ONLY', 'PHONE_NOTICE_ONLY'], ['NC_HIDDEN_PHONE_NONE', 'NC_HIDDEN_PHONE_NONE']]);
1150
+ kind: "method",
1151
+ key: "_onChange",
1152
+ value: function _onChange(field, value) {
1153
+ var _this$pwsFieldsMap$ge, _this$pwsFieldsMap, _pwsValueMap;
1154
+ const mappedField = (_this$pwsFieldsMap$ge = (_this$pwsFieldsMap = this.pwsFieldsMap) === null || _this$pwsFieldsMap === void 0 ? void 0 : _this$pwsFieldsMap.get(field)) !== null && _this$pwsFieldsMap$ge !== void 0 ? _this$pwsFieldsMap$ge : field;
1155
+ const mappedValue = (_pwsValueMap = pwsValueMap === null || pwsValueMap === void 0 ? void 0 : pwsValueMap(value)) !== null && _pwsValueMap !== void 0 ? _pwsValueMap : value;
1156
+ this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-change`, mappedField, mappedValue);
1157
+ }
1158
+ }, {
1159
+ kind: "method",
1160
+ key: "_onNoticeTextChange",
1161
+ value: function _onNoticeTextChange(field, value) {
1162
+ this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-text-change`, field, value);
1163
+ }
1164
+ }, {
1165
+ kind: "method",
1166
+ key: "_onEmailStatusChanged",
1167
+ value: function _onEmailStatusChanged(field, value) {
1168
+ this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-email-status-changed`, field, value);
1011
1169
  }
1012
1170
  }, {
1013
1171
  kind: "method",
1014
1172
  key: "dispatchCustomEvent",
1015
- value:
1016
- /**
1017
- * Dispatch field change event to parent form
1018
- */
1019
- function dispatchCustomEvent(eventName, field, value) {
1173
+ value: function dispatchCustomEvent(eventName, field, value) {
1020
1174
  try {
1021
1175
  const eventDetail = {
1022
1176
  bubbles: true,
@@ -1030,27 +1184,12 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
1030
1184
  console.error(`[${eventName}] dispatch failed:`, error);
1031
1185
  }
1032
1186
  }
1033
- }, {
1034
- kind: "method",
1035
- key: "_onChange",
1036
- value: function _onChange(field, value) {
1037
- var _this$pwsFieldsMap$ge, _this$pwsFieldsMap, _pwsValueMap;
1038
- const mappedField = (_this$pwsFieldsMap$ge = (_this$pwsFieldsMap = this.pwsFieldsMap) === null || _this$pwsFieldsMap === void 0 ? void 0 : _this$pwsFieldsMap.get(field)) !== null && _this$pwsFieldsMap$ge !== void 0 ? _this$pwsFieldsMap$ge : field;
1039
- const mappedValue = (_pwsValueMap = pwsValueMap === null || pwsValueMap === void 0 ? void 0 : pwsValueMap(value)) !== null && _pwsValueMap !== void 0 ? _pwsValueMap : value;
1040
- this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-change`, mappedField, mappedValue);
1041
- }
1042
- }, {
1043
- kind: "method",
1044
- key: "_onEmailStatusChanged",
1045
- value: function _onEmailStatusChanged(field, value) {
1046
- this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-email-status-changed`, field, value);
1047
- }
1048
1187
  }, {
1049
1188
  kind: "method",
1050
1189
  key: "render",
1051
1190
  value: function render() {
1052
1191
  if (this.isLoading) {
1053
- return html(_t13 || (_t13 = _`<div part="skeleton-notice-choice">
1192
+ return html(_t13 || (_t13 = _2`<div part="skeleton-notice-choice">
1054
1193
  <cds-skeleton-text
1055
1194
  linecount="3"
1056
1195
  width="100%"