@carbon/ibmdotcom-web-components 2.28.0 → 2.30.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 (77) hide show
  1. package/custom-elements.json +62 -66
  2. package/dist/dotcom-shell.js +1 -1
  3. package/dist/dotcom-shell.min.js +2 -2
  4. package/dist/ibmdotcom-web-components-dotcom-shell.js +1 -1
  5. package/dist/ibmdotcom-web-components-dotcom-shell.min.js +2 -2
  6. package/dist/{index-cc7138d9.js → index-70141123.js} +13 -13
  7. package/dist/{index-01b63aeb.js → index-dbec7dea.js} +28 -10
  8. package/dist/{left-nav-menu-aac029b1.js → left-nav-menu-4547bc31.js} +1 -1
  9. package/dist/{left-nav-menu-category-heading-b3ff93f8.js → left-nav-menu-category-heading-40a84206.js} +1 -1
  10. package/dist/{left-nav-menu-category-heading-986429d0.js → left-nav-menu-category-heading-ea7b8fd0.js} +2 -2
  11. package/dist/{left-nav-menu-5bb4c667.js → left-nav-menu-e123e07b.js} +2 -2
  12. package/dist/{left-nav-menu-item-db321bca.js → left-nav-menu-item-b13fa9bd.js} +2 -2
  13. package/dist/{left-nav-menu-item-28232edc.js → left-nav-menu-item-f0de1048.js} +1 -1
  14. package/dist/{left-nav-menu-section-3cb98ba9.js → left-nav-menu-section-12c63c9c.js} +2 -2
  15. package/dist/{left-nav-menu-section-3101ac3a.js → left-nav-menu-section-46049aa9.js} +1 -1
  16. package/dist/{left-nav-overlay-3438362c.js → left-nav-overlay-d67d0a6a.js} +1 -1
  17. package/dist/{left-nav-overlay-23bc48bd.js → left-nav-overlay-f71e3d74.js} +2 -2
  18. package/dist/{megamenu-category-group-350529dd.js → megamenu-category-group-2098af3d.js} +1 -1
  19. package/dist/{megamenu-category-group-42c2e7c6.js → megamenu-category-group-c85b1d1c.js} +2 -2
  20. package/dist/{megamenu-category-group-copy-7aeee6b6.js → megamenu-category-group-copy-74dadbb3.js} +2 -2
  21. package/dist/{megamenu-category-group-copy-ab52b66e.js → megamenu-category-group-copy-fd64eb79.js} +1 -1
  22. package/dist/{megamenu-category-heading-304c82c0.js → megamenu-category-heading-24704ad6.js} +1 -1
  23. package/dist/{megamenu-category-heading-de185d0d.js → megamenu-category-heading-88fb4721.js} +2 -2
  24. package/dist/{megamenu-category-link-74c8f943.js → megamenu-category-link-ae6d2273.js} +2 -2
  25. package/dist/{megamenu-category-link-84cc5c34.js → megamenu-category-link-af006474.js} +1 -1
  26. package/dist/{megamenu-category-link-group-677ac299.js → megamenu-category-link-group-06a95043.js} +1 -1
  27. package/dist/{megamenu-category-link-group-902363db.js → megamenu-category-link-group-8c6969cd.js} +2 -2
  28. package/dist/{megamenu-left-navigation-5904eb28.js → megamenu-left-navigation-382f79e5.js} +2 -2
  29. package/dist/{megamenu-left-navigation-68980017.js → megamenu-left-navigation-7796fe5e.js} +1 -1
  30. package/dist/{megamenu-overlay-4181ba67.js → megamenu-overlay-327917c7.js} +2 -2
  31. package/dist/{megamenu-overlay-512ee689.js → megamenu-overlay-d33c2656.js} +1 -1
  32. package/dist/{megamenu-tab-057e644c.js → megamenu-tab-819a92be.js} +2 -2
  33. package/dist/{megamenu-tab-2fa6c908.js → megamenu-tab-d7354c99.js} +1 -1
  34. package/es/components/back-to-top/__stories__/back-to-top.stories.css.js +1 -1
  35. package/es/components/card/card-footer.d.ts +6 -1
  36. package/es/components/card/card-footer.js +18 -1
  37. package/es/components/card/card-footer.js.map +1 -1
  38. package/es/components/card/card.css.js +1 -1
  39. package/es/components/card-group/card-group.css.js +1 -1
  40. package/es/components/card-in-card/card-in-card.css.js +1 -1
  41. package/es/components/card-link/card-link.css.js +1 -1
  42. package/es/components/card-section-offset/card-section-offset.css.js +1 -1
  43. package/es/components/card-section-simple/card-section-simple.css.js +1 -1
  44. package/es/components/content-block/content-block.css.js +1 -1
  45. package/es/components/content-block-cards/content-block-cards.css.js +1 -1
  46. package/es/components/content-block-horizontal/content-block-horizontal.css.js +1 -1
  47. package/es/components/content-block-media/content-block-media.css.js +1 -1
  48. package/es/components/content-block-mixed/content-block-mixed.css.js +1 -1
  49. package/es/components/content-group-cards/content-group-cards.css.js +1 -1
  50. package/es/components/content-item-row/content-item-row-media.css.js +1 -1
  51. package/es/components/content-item-row/content-item-row.css.js +1 -1
  52. package/es/components/cta/cta.css.js +1 -1
  53. package/es/components/cta/defs.d.ts +5 -1
  54. package/es/components/cta/defs.js +2 -1
  55. package/es/components/cta/defs.js.map +1 -1
  56. package/es/components/dotcom-shell/dotcom-shell.css.js +1 -1
  57. package/es/components/feature-card/feature-card.css.js +1 -1
  58. package/es/components/footer/footer.css.js +1 -1
  59. package/es/components/leadspace-block/leadspace-block.css.js +1 -1
  60. package/es/components/leadspace-with-search/leadspace-with-search.css.js +1 -1
  61. package/es/components/link-list/link-list.css.js +1 -1
  62. package/es/components/locale-modal/locale-modal.css.js +1 -1
  63. package/es/components/masthead/masthead.css.js +1 -1
  64. package/es/components/notice-choice/notice-choice.d.ts +53 -39
  65. package/es/components/notice-choice/notice-choice.js +529 -474
  66. package/es/components/notice-choice/notice-choice.js.map +1 -1
  67. package/es/components/notice-choice/services.d.ts +1 -0
  68. package/es/components/notice-choice/services.js +23 -0
  69. package/es/components/notice-choice/services.js.map +1 -1
  70. package/es/components/table-of-contents/table-of-contents.js +5 -3
  71. package/es/components/table-of-contents/table-of-contents.js.map +1 -1
  72. package/es/components/tabs-extended-media/tabs-extended-media.css.js +1 -1
  73. package/es/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +2 -2
  74. package/lib/components/cta/defs.js +2 -1
  75. package/lib/components/cta/defs.js.map +1 -1
  76. package/lib/internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings.js +2 -2
  77. package/package.json +5 -5
@@ -14,7 +14,8 @@ let _ = t => t,
14
14
  _t9,
15
15
  _t10,
16
16
  _t11,
17
- _t12;
17
+ _t12,
18
+ _t13;
18
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
21
  function _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; }
@@ -34,7 +35,7 @@ function _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prot
34
35
  * LICENSE file in the root directory of this source tree.
35
36
  */
36
37
 
37
- import { loadContent, loadSettings } from "./services.js";
38
+ import { loadContent, loadSettings, checkEmailStatus } from "./services.js";
38
39
  import { html, LitElement } from 'lit';
39
40
  import { property } from 'lit/decorators.js';
40
41
  import { pwsValueMap, resetToWorldWideContent, supportedLanguages } from "./utils.js";
@@ -43,16 +44,17 @@ import StableSelectorMixin from "../../globals/mixins/stable-selector.js";
43
44
  import styles from "././notice-choice.css.js";
44
45
  import { unsafeHTML } from 'lit/directives/unsafe-html.js';
45
46
  import { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';
47
+ import '@carbon/web-components/es/components/skeleton-text/index.js';
46
48
  const {
47
49
  prefix,
48
50
  stablePrefix: c4dPrefix
49
51
  } = settings;
50
-
51
52
  /**
52
53
  * Notice Choice
53
54
  *
54
55
  * @element c4d-notice-choice
55
56
  * @fires c4d-notice-choice-change
57
+ * @fires c4d-notice-choice-email-status-changed
56
58
  * The custom event fired when default choice loaded or user change some preferences.
57
59
  * The field and value should be taken from the detail object and send it to MRS.
58
60
  * @csspart checkbox-wrapper - The checkbox wrapper. Usage `c4d-notice-choice::part(checkbox-wrapper)`
@@ -84,6 +86,16 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
84
86
  value() {
85
87
  return '1';
86
88
  }
89
+ }, {
90
+ kind: "field",
91
+ decorators: [property({
92
+ type: String,
93
+ attribute: 'email'
94
+ })],
95
+ key: "email",
96
+ value() {
97
+ return '';
98
+ }
87
99
  }, {
88
100
  kind: "field",
89
101
  decorators: [property({
@@ -114,16 +126,6 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
114
126
  value() {
115
127
  return 'en';
116
128
  }
117
- }, {
118
- kind: "field",
119
- decorators: [property({
120
- type: String,
121
- attribute: 'current-language'
122
- })],
123
- key: "currentLanguage",
124
- value() {
125
- return 'en';
126
- }
127
129
  }, {
128
130
  kind: "field",
129
131
  decorators: [property({
@@ -137,51 +139,41 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
137
139
  }, {
138
140
  kind: "field",
139
141
  decorators: [property({
140
- type: Boolean,
142
+ type: String,
141
143
  attribute: 'enable-all-opt-in'
142
144
  })],
143
145
  key: "enableAllOptIn",
144
146
  value() {
145
- return false;
147
+ return 'false';
146
148
  }
147
149
  }, {
148
150
  kind: "field",
149
151
  decorators: [property({
150
- attribute: 'default-values'
151
- })],
152
- key: "defaultValues",
153
- value() {
154
- return {};
155
- }
156
- }, {
157
- kind: "field",
158
- decorators: [property({
159
- type: Boolean,
152
+ type: String,
160
153
  attribute: 'hide-error-message'
161
154
  })],
162
155
  key: "hideErrorMessage",
163
156
  value() {
164
- return false;
157
+ return 'false';
165
158
  }
166
159
  }, {
167
160
  kind: "field",
168
161
  decorators: [property({
169
- type: Boolean,
170
- attribute: 'combine-email-phone'
162
+ type: String,
163
+ attribute: 'environment'
171
164
  })],
172
- key: "combineEmailPhone",
165
+ key: "environment",
173
166
  value() {
174
- return false;
167
+ return 'prod';
175
168
  }
176
169
  }, {
177
170
  kind: "field",
178
171
  decorators: [property({
179
- type: String,
180
- attribute: 'environment'
172
+ attribute: 'default-values'
181
173
  })],
182
- key: "environment",
174
+ key: "defaultValues",
183
175
  value() {
184
- return 'prod';
176
+ return {};
185
177
  }
186
178
  }, {
187
179
  kind: "field",
@@ -276,7 +268,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
276
268
  type: Boolean,
277
269
  attribute: false
278
270
  })],
279
- key: "emailPrechecked",
271
+ key: "emailValid",
280
272
  value() {
281
273
  return false;
282
274
  }
@@ -300,6 +292,36 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
300
292
  value() {
301
293
  return false;
302
294
  }
295
+ }, {
296
+ kind: "field",
297
+ decorators: [property({
298
+ type: Boolean,
299
+ attribute: false
300
+ })],
301
+ key: "isAnnualPeriodExpired",
302
+ value() {
303
+ return true;
304
+ }
305
+ }, {
306
+ kind: "field",
307
+ decorators: [property({
308
+ type: Boolean,
309
+ attribute: false
310
+ })],
311
+ key: "showCheckBox",
312
+ value() {
313
+ return false;
314
+ }
315
+ }, {
316
+ kind: "field",
317
+ decorators: [property({
318
+ type: Boolean,
319
+ attribute: false
320
+ })],
321
+ key: "isLoading",
322
+ value() {
323
+ return false;
324
+ }
303
325
  }, {
304
326
  kind: "field",
305
327
  decorators: [property({
@@ -338,44 +360,39 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
338
360
  }, {
339
361
  kind: "field",
340
362
  decorators: [property({
341
- reflect: true
363
+ type: Object,
364
+ attribute: false
342
365
  })],
343
- key: "hiddenEmail",
366
+ key: "valuesForEmailPhone",
344
367
  value() {
345
- return '';
368
+ return {
369
+ EMAIL: {
370
+ checkBoxStatus: 'PERMISSION',
371
+ punsStatus: ''
372
+ }
373
+ };
346
374
  }
347
375
  }, {
348
376
  kind: "field",
349
377
  decorators: [property({
350
378
  reflect: true
351
379
  })],
352
- key: "hiddenPhone",
353
- value() {
354
- return '';
355
- }
356
- }, {
357
- kind: "field",
358
- decorators: [property({
359
- reflect: true,
360
- attribute: 'nc-tele-detail'
361
- })],
362
- key: "ncTeleDetail",
380
+ key: "hiddenEmail",
363
381
  value() {
364
382
  return '';
365
383
  }
366
384
  }, {
367
385
  kind: "field",
368
386
  decorators: [property({
369
- reflect: true,
370
- attribute: 'nc-email-detail'
387
+ reflect: true
371
388
  })],
372
- key: "ncEmailDetail",
389
+ key: "hiddenPhone",
373
390
  value() {
374
391
  return '';
375
392
  }
376
393
  }, {
377
394
  kind: "method",
378
- key: "prepareCheckboxes",
395
+ key: "connectedCallback",
379
396
  value:
380
397
  /**
381
398
  * properties for passed attributes.
@@ -389,284 +406,199 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
389
406
  * properties for local state state management.
390
407
  */
391
408
 
392
- function prepareCheckboxes() {
393
- if (this.ncData) {
394
- const OptInContent = this.ncData;
395
- this.preText = OptInContent.preText;
396
- this.defaultPreText = OptInContent.preText;
397
- const newCheckboxes = this._buildCheckboxes();
398
- this.checkboxes = newCheckboxes;
399
- this.performUpdate();
400
- }
401
- }
402
- }, {
403
- kind: "method",
404
- key: "defaultLoadContent",
405
- value: function defaultLoadContent() {
406
- loadContent('en', this.environment, ncData => {
407
- this.ncData = ncData;
408
- this.prepareCheckboxes();
409
- this.countryChanged();
410
- }, error => {
411
- console.error('error loading content', error);
412
- });
413
- }
414
- }, {
415
- kind: "method",
416
- key: "defaultLoadSettings",
417
- value: function defaultLoadSettings() {
418
- loadSettings(this.environment, countryPreferencesSettings => {
419
- this.countrySettings = countryPreferencesSettings.preferences;
420
- this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
421
- }, error => {
422
- console.error('error loading content', error);
423
- });
424
- }
425
- }, {
426
- kind: "method",
427
- key: "connectedCallback",
428
- value: function connectedCallback() {
409
+ function connectedCallback() {
429
410
  _superPropGet(NoticeChoice, "connectedCallback", this, 3)([]);
430
- const [language] = this.language.split(/[-_]/);
431
- let defaultLanguage = 'en';
432
- if (supportedLanguages(this.language)) {
433
- defaultLanguage = supportedLanguages(this.language);
434
- } else if (supportedLanguages(language)) {
435
- defaultLanguage = supportedLanguages(language);
436
- }
437
- loadSettings(this.environment, countryPreferencesSettings => {
438
- this.countrySettings = countryPreferencesSettings.preferences;
439
- this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
440
- }, () => {
441
- this.countrySettings = this.defaultLoadSettings();
442
- });
443
- loadContent(defaultLanguage, this.environment, ncData => {
444
- this.ncData = ncData;
445
- this.prepareCheckboxes();
446
- this.countryChanged();
447
- }, () => {
448
- this.defaultLoadContent();
449
- });
411
+ this._initSettingsAndContent(this.language);
450
412
  }
451
413
  }, {
452
- kind: "method",
453
- key: "setDefaultSelections",
454
- value: function setDefaultSelections() {
455
- if (!this.enableAllOptIn && this.checkboxes) {
456
- const newValues = _objectSpread({}, this.values);
457
- Object.keys(this.checkboxes).forEach(key => {
458
- const option = this._getOptionByQuestion(key);
459
- newValues[key] = !!(option.checked === 'true' || option.checked === true);
460
- if (this.defaultValues && Object.prototype.hasOwnProperty.call(this.defaultValues, key)) {
461
- newValues[key] = this.defaultValues[key];
462
- }
463
- const hiddenFieldName = `NC_HIDDEN_${key}`;
464
- newValues[hiddenFieldName] = option[hiddenFieldName];
465
- this._onChange(hiddenFieldName, newValues.EMAIL ? 'OPT_IN' : 'OPT_OUT');
466
- });
467
- if (JSON.stringify(this.values) !== JSON.stringify(newValues)) {
468
- this.values = newValues;
469
- }
470
- }
414
+ kind: "get",
415
+ static: true,
416
+ key: "stableSelector",
417
+ value: function () {
418
+ return `${c4dPrefix}--notice-choice`;
471
419
  }
472
420
  }, {
473
- kind: "method",
474
- key: "countryChangeAction",
475
- value: function countryChangeAction() {
476
- var _this$ncData, _this$country;
477
- this.preventFormSubmission = false;
478
- if ((_this$ncData = this.ncData) !== null && _this$ncData !== void 0 && _this$ncData.mandatoryCheckbox[(_this$country = this.country) === null || _this$country === void 0 ? void 0 : _this$country.toLocaleLowerCase()]) {
479
- var _this$country2, _this$ncData2, _this$ncData3, _this$ncData4;
480
- const countyCode = (_this$country2 = this.country) === null || _this$country2 === void 0 ? void 0 : _this$country2.toLocaleLowerCase();
481
- const mrsField = (_this$ncData2 = this.ncData) !== null && _this$ncData2 !== void 0 && _this$ncData2.mandatoryCheckbox[countyCode].countryTransferText ? (_this$ncData3 = this.ncData) === null || _this$ncData3 === void 0 ? void 0 : _this$ncData3.mandatoryCheckbox[countyCode].countryTransferText.mrs_field : (_this$ncData4 = this.ncData) === null || _this$ncData4 === void 0 ? void 0 : _this$ncData4.mandatoryCheckbox[countyCode].chinaPIPLtext.mrs_field;
482
- this._onChange(mrsField, 'countyBasedCheckedNo');
483
- this.isMandatoryCheckboxDisplayed.countryCode = countyCode;
484
- this.isMandatoryCheckboxDisplayed.isDisplayed = true;
485
- this.preventFormSubmission = true;
486
- this._onChange('preventFormSubmission', 'formSubmissionNo');
487
- } else {
488
- this._onChange('preventFormSubmission', 'formSubmissionYes');
489
- }
490
-
491
- /**
492
- * @description if the user already interacted with the checkboxes,
493
- * skip country default selection.
494
- */
495
- if (!this.changed && !this.fetchedPref) {
496
- /**
497
- * @description
498
- * change checkbox checked option based on new country.
499
- */
500
-
501
- this.setDefaultSelections();
502
- }
421
+ kind: "field",
422
+ static: true,
423
+ key: "styles",
424
+ value() {
425
+ return styles;
503
426
  }
504
427
  }, {
505
428
  kind: "method",
506
- key: "countryChanged",
507
- value: function countryChanged() {
508
- resetToWorldWideContent();
509
- this.countryChangeAction();
429
+ key: "updated",
430
+ value: function updated(changedProps) {
431
+ changedProps.forEach((oldValue, propName) => {
432
+ const newValue = this[propName];
433
+ const hasValue = newValue !== undefined && newValue !== null;
434
+ this._dispatchChange(propName, newValue, hasValue, oldValue);
435
+ });
510
436
  }
511
- /**
512
- *
513
- * @param name name of the attribute
514
- * @param oldVal old value of the attribute
515
- * @param newVal new value of the attrbute
516
- */
517
437
  }, {
518
438
  kind: "method",
519
- key: "attributeChangedCallback",
520
- value: function attributeChangedCallback(name, oldVal, newVal) {
521
- const hasValue = newVal !== null && oldVal !== null;
522
- _superPropGet(NoticeChoice, "attributeChangedCallback", this, 3)([name, oldVal, newVal]);
523
- switch (name) {
524
- case 'question-choices':
439
+ key: "_dispatchChange",
440
+ value: function _dispatchChange(field, value, hasValue, oldValue) {
441
+ switch (field) {
442
+ case 'questionchoices':
525
443
  {
526
- // Reload checkbox options when questionchoices changed
527
- if (oldVal !== newVal) {
528
- this.prepareCheckboxes();
529
- this.setDefaultSelections();
530
- }
444
+ this.prepareCheckboxes();
445
+ this.setDefaultSelections();
531
446
  break;
532
447
  }
533
448
  case 'language':
534
449
  case 'environment':
535
450
  {
536
- // load content when locale changed.
537
- const [language] = newVal.split(/[-_]/);
538
- let defaultLanguage = 'en';
539
- if (supportedLanguages(newVal)) {
540
- defaultLanguage = supportedLanguages(newVal);
541
- } else if (supportedLanguages(language)) {
542
- defaultLanguage = supportedLanguages(language);
543
- }
544
- this.currentLanguage = defaultLanguage;
545
- if (hasValue && oldVal !== newVal) {
546
- loadSettings(this.environment, countryPreferencesSettings => {
547
- this.countrySettings = countryPreferencesSettings.preferences;
548
- }, error => {
549
- console.error('error loading content', error);
550
- });
551
- loadContent(defaultLanguage, this.environment, ncData => {
552
- this.ncData = ncData;
553
- this.prepareCheckboxes();
554
- }, () => {
555
- this.defaultLoadContent();
556
- });
451
+ var _this$language;
452
+ if (['stage', 'prod'].includes(value)) {
453
+ this.environment = value;
454
+ } else {
455
+ this.language = value;
557
456
  }
457
+ const langPart = (_this$language = this.language) === null || _this$language === void 0 ? void 0 : _this$language.split(/[-_]/)[0];
458
+ const supportedLang = supportedLanguages(this.language) || supportedLanguages(langPart) || 'en';
459
+ this.isLoading = true;
460
+ loadSettings(this.environment, settings => {
461
+ this.countrySettings = settings.preferences;
462
+ }, err => console.error('error loading settings', err));
463
+ loadContent(supportedLang, this.environment, ncData => {
464
+ this.isLoading = false;
465
+ this.ncData = ncData;
466
+ this.prepareCheckboxes();
467
+ }, () => this.defaultLoadContent());
558
468
  break;
559
469
  }
560
470
  case 'country':
561
471
  {
562
- /**
563
- * load content when country value changed.
564
- */
565
- if (hasValue && oldVal !== newVal && this.countrySettings[newVal.toLocaleLowerCase()]) {
472
+ var _this$countrySettings;
473
+ if (hasValue && typeof value === 'string' && oldValue !== value && (_this$countrySettings = this.countrySettings) !== null && _this$countrySettings !== void 0 && _this$countrySettings[value.toLowerCase()]) {
566
474
  this.countryChanged();
567
475
  }
568
476
  break;
569
477
  }
570
- case 'enable-all-opt-in':
571
- if (oldVal !== newVal) {
572
- this.enableAllOptIn = JSON.parse(newVal);
573
- this.setDefaultSelections();
478
+ case 'enableAllOptIn':
479
+ {
480
+ if (oldValue !== value && typeof value === 'string') {
481
+ this.enableAllOptIn = JSON.parse(value);
482
+ this.setDefaultSelections();
483
+ }
484
+ break;
574
485
  }
575
- break;
576
- case 'hide-error-message':
486
+ case 'hideErrorMessage':
577
487
  {
578
- if (oldVal !== newVal) {
579
- this.hideErrorMessage = JSON.parse(newVal);
488
+ if (oldValue !== value && typeof value === 'string') {
489
+ this.hideErrorMessage = JSON.parse(value);
580
490
  this.countryBasedLegalNotice();
581
491
  }
582
492
  break;
583
493
  }
494
+ case 'email':
495
+ {
496
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
497
+ this.emailValid = false;
498
+ if (hasValue && oldValue !== value && typeof value === 'string' && emailRegex.test(value.trim()) && value.trim() !== '') {
499
+ this.email = value.trim();
500
+ this.onEmailChange();
501
+ } else {
502
+ this.showCheckBox = false;
503
+ }
504
+ break;
505
+ }
584
506
  }
585
507
  }
586
508
  }, {
587
- kind: "get",
588
- static: true,
589
- key: "stableSelector",
590
- value: function () {
591
- return `${c4dPrefix}--notice-choice`;
509
+ kind: "method",
510
+ key: "onEmailChange",
511
+ value: function onEmailChange() {
512
+ const email = this.email;
513
+ const oneYearAgo = new Date(Date.now() - 365 * 24 * 60 * 60 * 1000);
514
+ this.isAnnualPeriodExpired = true;
515
+ this.isLoading = true;
516
+ checkEmailStatus(email, this.environment, data => {
517
+ this.isLoading = false;
518
+ this.emailValid = true;
519
+ const {
520
+ email: emailStatus,
521
+ lastUpdated
522
+ } = data;
523
+ const annualPeriodDate = new Date(lastUpdated);
524
+ const isValidDate = !isNaN(annualPeriodDate.getTime());
525
+ const isExpired = isValidDate && emailStatus === 'P' && annualPeriodDate < oneYearAgo;
526
+
527
+ // If bad date, treat as expired
528
+ if (!isValidDate) {
529
+ console.warn('Invalid annualPeriod:', lastUpdated);
530
+ this.isAnnualPeriodExpired = true;
531
+ this._handleEmailCheckFailure(data, true);
532
+ return;
533
+ }
534
+ this.isAnnualPeriodExpired = emailStatus !== 'P' || isExpired;
535
+ this.showCheckBox = isExpired || emailStatus !== 'P';
536
+ this._onEmailStatusChanged('emailStats', _objectSpread(_objectSpread({}, data), {}, {
537
+ isAnnualPeriodExpired: isExpired
538
+ }));
539
+ }, error => {
540
+ this.emailValid = true;
541
+ this.isLoading = false;
542
+ console.error('checkEmailStatus error:', error);
543
+ this._handleEmailCheckFailure(error, true);
544
+ });
592
545
  }
546
+
547
+ /**
548
+ * Centralized handler for failed or invalid responses.
549
+ */
593
550
  }, {
594
- kind: "field",
595
- static: true,
596
- key: "styles",
597
- value() {
598
- return styles;
551
+ kind: "method",
552
+ key: "_handleEmailCheckFailure",
553
+ value: function _handleEmailCheckFailure(responseData, expired) {
554
+ this.isAnnualPeriodExpired = expired;
555
+ this.showCheckBox = true;
556
+ this.renderCombinedEmailPhoneSection();
557
+ this._onEmailStatusChanged('emailStats', _objectSpread(_objectSpread({}, responseData), {}, {
558
+ isAnnualPeriodExpired: expired
559
+ }));
599
560
  }
600
561
  }, {
601
562
  kind: "method",
602
- key: "checkBoxLegalChange",
603
- value: // `styles` here is a `CSSResult` generated by custom WebPack loader
604
- function checkBoxLegalChange($event) {
605
- var _this$country3, _this$ncData5, _this$ncData6, _this$ncData7;
606
- const legalCheckbox = $event.target;
607
- const isChecked = legalCheckbox.checked;
608
- const legalTextError = legalCheckbox.parentNode.querySelector('.nc-error');
609
- const countyBasedText = isChecked ? 'countyBasedCheckedYes' : 'countyBasedCheckedNo';
610
- if (legalTextError) {
611
- legalTextError.style.display = isChecked ? 'none' : '';
612
- }
613
- const countyCode = (_this$country3 = this.country) === null || _this$country3 === void 0 ? void 0 : _this$country3.toLocaleLowerCase();
614
- const mrsField = (_this$ncData5 = this.ncData) !== null && _this$ncData5 !== void 0 && _this$ncData5.mandatoryCheckbox[countyCode].countryTransferText ? (_this$ncData6 = this.ncData) === null || _this$ncData6 === void 0 ? void 0 : _this$ncData6.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].countryTransferText.mrs_field : (_this$ncData7 = this.ncData) === null || _this$ncData7 === void 0 ? void 0 : _this$ncData7.mandatoryCheckbox[countyCode].chinaPIPLtext.mrs_field;
615
- legalCheckbox.value = isChecked ? 1 : 0;
616
- this.preventFormSubmission = !isChecked;
617
- const preventFormSubmissionValue = isChecked ? 'formSubmissionYes' : 'formSubmissionNo';
618
- this._onChange('preventFormSubmission', preventFormSubmissionValue);
619
- this._onChange(mrsField, countyBasedText);
563
+ key: "_initSettingsAndContent",
564
+ value: function _initSettingsAndContent(language) {
565
+ const [lang] = language.split(/[-_]/);
566
+ const defaultLang = supportedLanguages(language) || supportedLanguages(lang) || 'en';
567
+ loadSettings(this.environment, settings => {
568
+ this.countrySettings = settings.preferences;
569
+ this.noticeOnly = settings.noticeOnly || ['us'];
570
+ }, () => this.defaultLoadSettings());
571
+ loadContent(defaultLang, this.environment, ncData => {
572
+ this.ncData = ncData;
573
+ this.prepareCheckboxes();
574
+ this.countryChanged();
575
+ }, () => this.defaultLoadContent());
620
576
  }
621
577
  }, {
622
578
  kind: "method",
623
- key: "countryBasedLegalNotice",
624
- value: function countryBasedLegalNotice() {
625
- var _this$ncData8;
626
- const country = this.country.toLocaleLowerCase();
627
- const itemTemplates = [];
628
- if ((_this$ncData8 = this.ncData) !== null && _this$ncData8 !== void 0 && _this$ncData8.mandatoryCheckbox && this.ncData.mandatoryCheckbox[country]) {
629
- const mandatoryCheckboxes = this.ncData.mandatoryCheckbox[country];
630
- for (const [key, mandatoryCheckbox] of Object.entries(mandatoryCheckboxes)) {
631
- const legalTextName = key.replace(/([A-Z]+)/g, '-$1').toLowerCase();
632
- const mandatoryCheckboxTemplate = html(_t4 || (_t4 = _`
633
- <span>
634
- <div
635
- class="${0}--form-item bx--checkbox-wrapper"
636
- part="checkbox-wrapper checkbox-wrapper--mandatory">
637
- <p part=${0} class=${0}>
638
- <input
639
- type="checkbox"
640
- class="${0}--checkbox"
641
- part="checkbox checkbox--mandatory"
642
- id="${0}"
643
- name="${0}"
644
- @change="${0}" />
645
- <label
646
- for="${0}"
647
- class="${0}--checkbox-label ${0}--nc__checkbox-${0}"
648
- part="checkbox-label checkbox-label--mandatory"
649
- ><span
650
- class="${0}--checkbox-label-text"
651
- part="checkbox-label-text checkbox-label-text--mandatory"
652
- dir="auto"
653
- >${0}
654
- </span>
655
- </label>
656
- ${0}
657
- </p>
658
- </div>
659
- </span>
660
- `), prefix, legalTextName, legalTextName, prefix, mandatoryCheckbox.mrs_field, mandatoryCheckbox.mrs_field, this.checkBoxLegalChange, mandatoryCheckbox.mrs_field, prefix, prefix, mandatoryCheckbox.mrs_field, prefix, mandatoryCheckbox.text, !this.hideErrorMessage && this.preventFormSubmission ? html(_t5 || (_t5 = _`<span
661
- class="nc-error"
662
- part="error"
663
- style="color:#da1e28;font-size:.75rem"
664
- >${0}</span
665
- >`), mandatoryCheckbox.error) : '');
666
- itemTemplates.push(mandatoryCheckboxTemplate);
579
+ key: "countryChangeAction",
580
+ value: function countryChangeAction() {
581
+ var _this$country, _this$ncData;
582
+ const countryCode = (_this$country = this.country) === null || _this$country === void 0 ? void 0 : _this$country.toLowerCase();
583
+ this.preventFormSubmission = false;
584
+ 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];
585
+ this.setDefaultSelections();
586
+ if (mandatory) {
587
+ var _mandatory$countryTra, _mandatory$chinaPIPLt;
588
+ // determine which field to update
589
+ const mrsField = ((_mandatory$countryTra = mandatory.countryTransferText) === null || _mandatory$countryTra === void 0 ? void 0 : _mandatory$countryTra.mrs_field) || ((_mandatory$chinaPIPLt = mandatory.chinaPIPLtext) === null || _mandatory$chinaPIPLt === void 0 ? void 0 : _mandatory$chinaPIPLt.mrs_field);
590
+ if (mrsField) {
591
+ this._onChange(mrsField, 'countyBasedCheckedNo');
667
592
  }
593
+ this.isMandatoryCheckboxDisplayed = {
594
+ countryCode,
595
+ isDisplayed: true
596
+ };
597
+ this.preventFormSubmission = true;
598
+ this._onChange('preventFormSubmission', 'formSubmissionNo');
599
+ } else {
600
+ this._onChange('preventFormSubmission', 'formSubmissionYes');
668
601
  }
669
- return itemTemplates;
670
602
  }
671
603
  }, {
672
604
  kind: "method",
@@ -691,48 +623,108 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
691
623
  if (postText !== '') {
692
624
  postText = "<div part='ncPostTextContainer' id='ncPostTextContainer'>" + postText + '</div>';
693
625
  }
694
- return html(_t6 || (_t6 = _`${0}`), unsafeHTML(postText));
626
+ return html(_t4 || (_t4 = _`${0}`), unsafeHTML(postText));
695
627
  } else {
696
- return html(_t7 || (_t7 = _``));
628
+ return html(_t5 || (_t5 = _``));
697
629
  }
698
630
  }
699
631
  }, {
700
632
  kind: "method",
701
- key: "combinedPreTextTemplate",
702
- value: function combinedPreTextTemplate() {
703
- var _this$country4, _this$state, _ecmTranslateContent$4;
704
- if (!this.ncData) {
705
- return html(_t8 || (_t8 = _``));
633
+ key: "countryChanged",
634
+ value: function countryChanged() {
635
+ resetToWorldWideContent();
636
+ this.countryChangeAction();
637
+ }
638
+ }, {
639
+ kind: "method",
640
+ key: "setDefaultSelections",
641
+ value: function setDefaultSelections() {
642
+ var _this$country2, _this$countrySettings2, _this$countrySettings3;
643
+ if (this.enableAllOptIn || !this.checkboxes) {
644
+ return;
706
645
  }
707
- const ecmTranslateContent = this.ncData;
708
- const country = ((_this$country4 = this.country) === null || _this$country4 === void 0 ? void 0 : _this$country4.toLocaleLowerCase()) || '';
709
- const state = ((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.toLocaleLowerCase()) || '';
710
- let preText = ecmTranslateContent.combinedConsent;
711
- if (ecmTranslateContent.state[country]) {
712
- if ((this.noticeOnly || []).includes(country)) {
713
- preText = state === 'ca' || state === '' ? ecmTranslateContent.state[country]['ca'].noticeOnly : ecmTranslateContent.noticeOnly;
714
- } else {
715
- var _ecmTranslateContent$;
716
- preText = ((_ecmTranslateContent$ = ecmTranslateContent.state[country][state]) === null || _ecmTranslateContent$ === void 0 ? void 0 : _ecmTranslateContent$.combinedConsent) || ecmTranslateContent.combinedConsent;
646
+ const countryCode = (_this$country2 = this.country) === null || _this$country2 === void 0 ? void 0 : _this$country2.toLowerCase();
647
+ 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 : {
648
+ email: 'opt-in',
649
+ phone: 'opt-in'
650
+ };
651
+ const newValues = _objectSpread({}, this.values);
652
+ for (const key of Object.keys(this.checkboxes)) {
653
+ const isOptOut = countryStatus[key.toLowerCase()] === 'opt-out';
654
+ newValues[key] = isOptOut;
655
+ const hiddenFieldName = `NC_HIDDEN_${key}`;
656
+ newValues[hiddenFieldName] = isOptOut ? 'OPT_OUT' : 'OPT_IN';
657
+ if (Object.prototype.hasOwnProperty.call(this.defaultValues, key)) {
658
+ newValues[key] = this.defaultValues[key];
717
659
  }
718
- } else if ((this.noticeOnly || []).includes(country)) {
719
- var _ecmTranslateContent$2, _ecmTranslateContent$3;
720
- preText = state === 'ca' || state === '' || typeof state === 'undefined' ? (_ecmTranslateContent$2 = ecmTranslateContent.state) !== null && _ecmTranslateContent$2 !== void 0 && (_ecmTranslateContent$2 = _ecmTranslateContent$2[country]) !== null && _ecmTranslateContent$2 !== void 0 && (_ecmTranslateContent$2 = _ecmTranslateContent$2['ca']) !== null && _ecmTranslateContent$2 !== void 0 && _ecmTranslateContent$2.noticeOnly ? (_ecmTranslateContent$3 = ecmTranslateContent.state) === null || _ecmTranslateContent$3 === void 0 || (_ecmTranslateContent$3 = _ecmTranslateContent$3[country]) === null || _ecmTranslateContent$3 === void 0 || (_ecmTranslateContent$3 = _ecmTranslateContent$3['ca']) === null || _ecmTranslateContent$3 === void 0 ? void 0 : _ecmTranslateContent$3.noticeOnly : ecmTranslateContent.noticeOnly : ecmTranslateContent.noticeOnly;
660
+ this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : 'OPT_OUT');
721
661
  }
722
- if ((_ecmTranslateContent$4 = ecmTranslateContent.country) !== null && _ecmTranslateContent$4 !== void 0 && _ecmTranslateContent$4[country]) {
723
- preText = ecmTranslateContent.country[country].combinedConsent;
662
+ const changed = Object.keys(newValues).some(field => newValues[field] !== this.values[field]);
663
+ if (changed) {
664
+ this.values = newValues;
724
665
  }
725
- if (!(this.noticeOnly || []).includes(country)) {
726
- let isPermissionOrSuppression = false;
727
- if (typeof this.values.EMAIL === 'object') {
728
- const checkStatus = this.values.EMAIL;
729
- isPermissionOrSuppression = checkStatus.checkBoxStatus === 'PERMISSION';
666
+ }
667
+ }, {
668
+ kind: "method",
669
+ key: "_buildCheckboxes",
670
+ value: function _buildCheckboxes() {
671
+ var _this$ncData2, _this$ncData3;
672
+ const fieldElements = {};
673
+ const fieldCollections = {
674
+ EMAIL: {
675
+ id: 'EMAIL',
676
+ labelText: (_this$ncData2 = this.ncData) === null || _this$ncData2 === void 0 ? void 0 : _this$ncData2.email
677
+ },
678
+ PHONE: {
679
+ id: 'PHONE',
680
+ labelText: (_this$ncData3 = this.ncData) === null || _this$ncData3 === void 0 ? void 0 : _this$ncData3.telephone
730
681
  }
731
- const checked = typeof this.values.EMAIL === 'object' ? isPermissionOrSuppression : this.values.EMAIL;
732
- preText = preText ? this.renderCheckbox(preText, checked) : this.renderCheckbox(ecmTranslateContent.preText, checked);
733
- return preText;
682
+ };
683
+ if (this.questionchoices) {
684
+ // by email
685
+ if (this.questionchoices.indexOf('1') > -1) {
686
+ fieldElements.EMAIL = fieldCollections.EMAIL;
687
+ }
688
+ // by Phone
689
+ if (this.questionchoices.indexOf('2') > -1) {
690
+ fieldElements.PHONE = fieldCollections.PHONE;
691
+ }
692
+ }
693
+ return fieldElements;
694
+ }
695
+ }, {
696
+ kind: "method",
697
+ key: "prepareCheckboxes",
698
+ value: function prepareCheckboxes() {
699
+ if (this.ncData) {
700
+ const newCheckboxes = this._buildCheckboxes();
701
+ this.checkboxes = newCheckboxes;
702
+ this.performUpdate();
734
703
  }
735
- return html(_t9 || (_t9 = _`${0}`), unsafeHTML(preText));
704
+ }
705
+ }, {
706
+ kind: "method",
707
+ key: "defaultLoadContent",
708
+ value: function defaultLoadContent() {
709
+ loadContent('en', this.environment, ncData => {
710
+ this.ncData = ncData;
711
+ this.prepareCheckboxes();
712
+ this.countryChanged();
713
+ }, error => {
714
+ this.isLoading = false;
715
+ console.error('error loading content', error);
716
+ });
717
+ }
718
+ }, {
719
+ kind: "method",
720
+ key: "defaultLoadSettings",
721
+ value: function defaultLoadSettings() {
722
+ loadSettings(this.environment, countryPreferencesSettings => {
723
+ this.countrySettings = countryPreferencesSettings.preferences;
724
+ this.noticeOnly = countryPreferencesSettings.noticeOnly || ['us'];
725
+ }, error => {
726
+ console.error('error loading content', error);
727
+ });
736
728
  }
737
729
  }, {
738
730
  kind: "method",
@@ -746,8 +738,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
746
738
  this.values = newValues;
747
739
  const hiddenFieldName = `NC_HIDDEN_${id}`;
748
740
  const hiddenFieldStatus = checked ? 'PERMISSION' : 'SUPPRESSION';
749
- this.values[id] = {};
750
- this.values[id]['checkBoxStatus'] = hiddenFieldStatus;
741
+ this.valuesForEmailPhone[id]['checkBoxStatus'] = hiddenFieldStatus;
751
742
  let statusPrechecked = '';
752
743
  switch (id) {
753
744
  case 'EMAIL':
@@ -755,7 +746,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
755
746
  statusPrechecked = this.combinedEmailPhonePrechecked && !checked ? 'CU' : !this.combinedEmailPhonePrechecked && checked ? 'UC' : this.combinedEmailPhonePrechecked && checked ? 'CC' : 'UU';
756
747
  break;
757
748
  }
758
- this.values[id]['punsStatus'] = statusPrechecked;
749
+ this.valuesForEmailPhone[id]['punsStatus'] = statusPrechecked;
759
750
  this._onChange(hiddenFieldName, hiddenFieldStatus);
760
751
  this._onChange(`${hiddenFieldName}_VALUE`, `NC_HIDDEN_${hiddenFieldStatus}`);
761
752
  });
@@ -765,7 +756,7 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
765
756
  key: "renderCheckbox",
766
757
  value: function renderCheckbox(preText, checked) {
767
758
  const checkboxId = 'EMAIL_PHONE_CHECKBOX';
768
- return html(_t10 || (_t10 = _`
759
+ return html(_t6 || (_t6 = _`
769
760
  <span part="container">
770
761
  <div
771
762
  class="${0}--form-item cds--checkbox-wrapper"
@@ -793,37 +784,188 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
793
784
  </span>
794
785
  `), prefix, prefix, checkboxId, checkboxId, checked, this.checkCombineEmailPhoneBoxChange, checkboxId, prefix, prefix, checkboxId, prefix, unsafeHTML(preText));
795
786
  }
787
+ }, {
788
+ kind: "method",
789
+ key: "combinedPreTextTemplate",
790
+ value: function combinedPreTextTemplate() {
791
+ var _this$country3, _this$state, _content$state, _content$country;
792
+ if (!this.ncData) {
793
+ return html(_t7 || (_t7 = _``));
794
+ }
795
+ const content = this.ncData;
796
+ const country = ((_this$country3 = this.country) === null || _this$country3 === void 0 ? void 0 : _this$country3.toLowerCase()) || '';
797
+ const state = ((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.toLowerCase()) || '';
798
+ let preText = '';
799
+
800
+ // 1. Base text depending on email
801
+ if (!this.emailValid) {
802
+ preText = content.annualDefaultText;
803
+ } else {
804
+ preText = this.showCheckBox ? content.combinedConsent : content.annualText;
805
+ }
806
+
807
+ // 2. country+state specific override
808
+ const stateConfig = (_content$state = content.state) === null || _content$state === void 0 ? void 0 : _content$state[country];
809
+ if (stateConfig) {
810
+ if ((this.noticeOnly || []).includes(country)) {
811
+ var _stateConfig$ca;
812
+ preText = state === 'ca' || state === '' ? ((_stateConfig$ca = stateConfig['ca']) === null || _stateConfig$ca === void 0 ? void 0 : _stateConfig$ca.noticeOnly) || content.noticeOnly : content.noticeOnly;
813
+ } else {
814
+ var _stateConfig$state;
815
+ preText = ((_stateConfig$state = stateConfig[state]) === null || _stateConfig$state === void 0 ? void 0 : _stateConfig$state.combinedConsent) || content.combinedConsent;
816
+ }
817
+ } else if ((this.noticeOnly || []).includes(country)) {
818
+ var _content$state2;
819
+ preText = state === 'ca' || state === '' || typeof state === 'undefined' ? ((_content$state2 = content.state) === null || _content$state2 === void 0 || (_content$state2 = _content$state2[country]) === null || _content$state2 === void 0 || (_content$state2 = _content$state2['ca']) === null || _content$state2 === void 0 ? void 0 : _content$state2.noticeOnly) || content.noticeOnly : content.noticeOnly;
820
+ }
821
+
822
+ // 3. country content override if exists
823
+
824
+ const countryContent = (_content$country = content.country) === null || _content$country === void 0 ? void 0 : _content$country[country];
825
+ if (countryContent) {
826
+ preText = !this.emailValid ? content.annualDefaultText : this.isAnnualPeriodExpired ? countryContent.combinedConsent : countryContent.annualText;
827
+ }
828
+
829
+ // 4. permission/suppression logic
830
+ if (!(this.noticeOnly || []).includes(country)) {
831
+ let isPermission = false;
832
+ isPermission = this.values.EMAIL;
833
+ const checked = isPermission;
834
+ if (this.showCheckBox) {
835
+ return this.renderCheckbox(preText, checked);
836
+ }
837
+ }
838
+ return html(_t8 || (_t8 = _`${0}`), unsafeHTML(preText));
839
+ }
840
+ }, {
841
+ kind: "method",
842
+ key: "checkBoxLegalChange",
843
+ value: function checkBoxLegalChange(event) {
844
+ var _target$parentElement, _this$country4, _this$ncData4, _mandatoryCheckbox$co, _mandatoryCheckbox$ch;
845
+ const target = event.target;
846
+ if (!target) {
847
+ return;
848
+ }
849
+ const isChecked = target.checked;
850
+
851
+ // handle potential missing error element safely
852
+ const errorEl = (_target$parentElement = target.parentElement) === null || _target$parentElement === void 0 ? void 0 : _target$parentElement.querySelector('.nc-error');
853
+ if (errorEl) {
854
+ errorEl.style.display = isChecked ? 'none' : '';
855
+ }
856
+ const countryCode = (_this$country4 = this.country) === null || _this$country4 === void 0 ? void 0 : _this$country4.toLowerCase();
857
+ const mandatoryCheckbox = (_this$ncData4 = this.ncData) === null || _this$ncData4 === void 0 || (_this$ncData4 = _this$ncData4.mandatoryCheckbox) === null || _this$ncData4 === void 0 ? void 0 : _this$ncData4[countryCode];
858
+ if (!mandatoryCheckbox) {
859
+ console.warn('No mandatoryCheckbox for country:', countryCode);
860
+ return;
861
+ }
862
+ const mrsField = ((_mandatoryCheckbox$co = mandatoryCheckbox.countryTransferText) === null || _mandatoryCheckbox$co === void 0 ? void 0 : _mandatoryCheckbox$co.mrs_field) || ((_mandatoryCheckbox$ch = mandatoryCheckbox.chinaPIPLtext) === null || _mandatoryCheckbox$ch === void 0 ? void 0 : _mandatoryCheckbox$ch.mrs_field);
863
+ if (!mrsField) {
864
+ console.warn('No mrs_field found for country mandatory checkbox');
865
+ return;
866
+ }
867
+ target.value = isChecked ? '1' : '0';
868
+ this.preventFormSubmission = !isChecked;
869
+ this._onChange('preventFormSubmission', isChecked ? 'formSubmissionYes' : 'formSubmissionNo');
870
+ this._onChange(mrsField, isChecked ? 'countyBasedCheckedYes' : 'countyBasedCheckedNo');
871
+ }
872
+ }, {
873
+ kind: "method",
874
+ key: "countryBasedLegalNotice",
875
+ value: function countryBasedLegalNotice() {
876
+ var _this$ncData5;
877
+ const countryCode = this.country.toLowerCase();
878
+ 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];
879
+ if (!mandatoryCheckboxes) {
880
+ return [];
881
+ }
882
+ return Object.entries(mandatoryCheckboxes).map(([key, checkbox]) => {
883
+ const legalTextName = key.replace(/([A-Z]+)/g, '-$1').toLowerCase();
884
+ const errorTemplate = !this.hideErrorMessage && this.preventFormSubmission ? html(_t9 || (_t9 = _`<span
885
+ class="nc-error"
886
+ part="error"
887
+ style="color:#da1e28;font-size:.75rem">
888
+ ${0}
889
+ </span>`), checkbox.error) : null;
890
+ return html(_t10 || (_t10 = _`
891
+ <span>
892
+ <div
893
+ class="${0}--form-item bx--checkbox-wrapper"
894
+ part="checkbox-wrapper checkbox-wrapper--mandatory">
895
+ <p part=${0} class=${0}>
896
+ <input
897
+ type="checkbox"
898
+ class="${0}--checkbox"
899
+ part="checkbox checkbox--mandatory"
900
+ id="${0}"
901
+ name="${0}"
902
+ @change="${0}" />
903
+ <label
904
+ for="${0}"
905
+ class="${0}--checkbox-label ${0}--nc__checkbox-${0}"
906
+ part="checkbox-label checkbox-label--mandatory">
907
+ <span
908
+ class="${0}--checkbox-label-text"
909
+ part="checkbox-label-text checkbox-label-text--mandatory"
910
+ dir="auto">
911
+ ${0}
912
+ </span>
913
+ </label>
914
+ ${0}
915
+ </p>
916
+ </div>
917
+ </span>
918
+ `), prefix, legalTextName, legalTextName, prefix, checkbox.mrs_field, checkbox.mrs_field, this.checkBoxLegalChange, checkbox.mrs_field, prefix, prefix, checkbox.mrs_field, prefix, checkbox.text, errorTemplate);
919
+ });
920
+ }
796
921
  }, {
797
922
  kind: "method",
798
923
  key: "renderCombinedEmailPhoneSection",
799
924
  value: function renderCombinedEmailPhoneSection() {
925
+ var _this$country5, _this$countrySettings4;
926
+ const countryLower = (_this$country5 = this.country) === null || _this$country5 === void 0 ? void 0 : _this$country5.toLocaleLowerCase();
927
+ const isNoticeOnly = (this.noticeOnly || []).includes(countryLower);
928
+ const defaultCountryStatus = {
929
+ email: 'opt-in',
930
+ phone: 'opt-in'
931
+ };
932
+ const countryStatus = ((_this$countrySettings4 = this.countrySettings) === null || _this$countrySettings4 === void 0 ? void 0 : _this$countrySettings4[countryLower]) || defaultCountryStatus;
800
933
  const getPunsStatus = (key, checked) => {
801
- var _this$country5, _this$values$key, _this$values$key2;
802
- const countryLowerCase = (_this$country5 = this.country) === null || _this$country5 === void 0 ? void 0 : _this$country5.toLocaleLowerCase();
803
- const isNoticeOnly = (this.noticeOnly || []).includes(countryLowerCase);
934
+ var _this$valuesForEmailP, _this$valuesForEmailP2;
804
935
  if (isNoticeOnly) {
805
936
  return 'NOTICE_ONLY';
806
937
  }
807
- const defaultCountryStatus = {
808
- email: 'opt-in',
809
- phone: 'opt-in'
810
- };
811
- const countryStatus = countryLowerCase ? this.countrySettings[countryLowerCase] || defaultCountryStatus : defaultCountryStatus;
812
- const checkboxStatus = (_this$values$key = this.values[key]) === null || _this$values$key === void 0 ? void 0 : _this$values$key.checkBoxStatus;
938
+ const checkboxStatus = (_this$valuesForEmailP = this.valuesForEmailPhone[key]) === null || _this$valuesForEmailP === void 0 ? void 0 : _this$valuesForEmailP.checkBoxStatus;
813
939
  if (checkboxStatus === 'SUPPRESSION') {
814
- if (countryStatus.email === 'opt-in') {
815
- return 'UU';
816
- }
817
- if (countryStatus.email === 'opt-out') {
818
- return 'CU';
819
- }
940
+ return countryStatus.email === 'opt-out' ? 'CU' : 'UU';
820
941
  }
821
- return ((_this$values$key2 = this.values[key]) === null || _this$values$key2 === void 0 ? void 0 : _this$values$key2.punsStatus) || (checked ? 'CC' : 'UU');
942
+ return ((_this$valuesForEmailP2 = this.valuesForEmailPhone[key]) === null || _this$valuesForEmailP2 === void 0 ? void 0 : _this$valuesForEmailP2.punsStatus) || (checked ? 'CC' : 'UU');
822
943
  };
823
- const createHiddenInput = (id, value) => html(_t11 || (_t11 = _`<input type="hidden" id=${0} name=${0} value=${0} />`), id, id, value);
944
+ const createHiddenInput = (id, value) => html(_t11 || (_t11 = _`
945
+ <input type="hidden" id=${0} name=${0} value=${0} />
946
+ `), id, id, value);
947
+ const hiddenInputs = Object.keys(this.checkboxes).map(key => {
948
+ var _this$values$key$chec, _this$values$key;
949
+ const checked = this.values.EMAIL;
950
+ const punsStatus = getPunsStatus(key, checked);
951
+ let hiddenValue = (_this$values$key$chec = (_this$values$key = this.values[key]) === null || _this$values$key === void 0 ? void 0 : _this$values$key.checkBoxStatus) !== null && _this$values$key$chec !== void 0 ? _this$values$key$chec : this.values.EMAIL ? 'PERMISSION' : 'SUPPRESSION';
952
+ if (typeof checked !== 'object') {
953
+ this.combinedEmailPhonePrechecked = !!checked;
954
+ }
955
+ if (isNoticeOnly) {
956
+ hiddenValue = countryStatus.email === 'opt-out' ? 'PERMISSION' : 'SUPPRESSION';
957
+ }
958
+ const hiddenBoxId = `NC_HIDDEN_${key}`;
959
+ this._onChange(`NC_${key === 'PHONE' ? 'TELE' : key}_DETAIL`, `${key}_${punsStatus}`);
960
+ this._onChange(`${hiddenBoxId}_VALUE`, `NC_HIDDEN_${hiddenValue}`);
961
+ if (Object.keys(this.checkboxes).length === 1) {
962
+ this._onChange(`NC_HIDDEN_PHONE_VALUE`, `NC_HIDDEN_PHONE_NONE`);
963
+ }
964
+ return createHiddenInput(hiddenBoxId, hiddenValue);
965
+ });
824
966
  return html(_t12 || (_t12 = _`
825
967
  <section class="${0}--nc" part="section">
826
- <p part="ncHeading" id="ncHeading" class="${0}--nc__pre-text ">
968
+ <p part="ncHeading" id="ncHeading" class="${0}--nc__pre-text">
827
969
  ${0} ${0}
828
970
  </p>
829
971
  ${0}
@@ -831,156 +973,69 @@ let NoticeChoice = _decorate([customElement(`c4d-notice-choice`)], function (_in
831
973
  ${0}
832
974
  </div>
833
975
  ${0}
834
- <input
835
- type="hidden"
836
- id="preventFormSubmission"
837
- name="preventFormSubmission"
838
- value=${0} />
839
976
  </section>
840
- `), prefix, c4dPrefix, this.countryBasedLegalNotice(), this.combinedPreTextTemplate(), Object.keys(this.checkboxes).map(key => {
841
- const checked = this.values.EMAIL;
842
- const punsStatus = getPunsStatus(key, checked);
843
- const hiddenBox = {
844
- id: `NC_HIDDEN_${key}`,
845
- value: this.values[key]['checkBoxStatus'] ? this.values[key]['checkBoxStatus'] : this.values.EMAIL ? 'PERMISSION' : 'SUPPRESSION'
846
- };
847
- if (typeof checked !== 'object') {
848
- this.combinedEmailPhonePrechecked = checked ? true : false;
849
- }
850
- if ((this.noticeOnly || []).includes(this.country.toLocaleLowerCase())) {
851
- const countryStatus = this.country ? this.countrySettings[this.country.toLocaleLowerCase()] : {
852
- email: 'opt-in',
853
- phone: 'opt-in'
854
- };
855
- hiddenBox.value = countryStatus.email === 'opt-out' ? 'PERMISSION' : 'SUPPRESSION';
856
- }
857
- this._onChange(`NC_${key === 'PHONE' ? 'TELE' : key}_DETAIL`, `${key}_${punsStatus}`);
858
- console.log(`${hiddenBox.id}_VALUE`, `NC_HIDDEN_${hiddenBox.value}`);
859
- this._onChange(`${hiddenBox.id}_VALUE`, `NC_HIDDEN_${hiddenBox.value}`);
860
- if (Object.keys(this.checkboxes).length === 1) {
861
- this._onChange(`NC_HIDDEN_PHONE_VALUE`, `NC_HIDDEN_PHONE_NONE`);
862
- }
863
- return createHiddenInput(hiddenBox.id, hiddenBox.value);
864
- }), prefix, prefix, this.postTextTemplate(), createHiddenInput('preventFormSubmission', this.preventFormSubmission), this.preventFormSubmission);
865
- }
866
- }, {
867
- kind: "method",
868
- key: "render",
869
- value: function render() {
870
- if (this.isMandatoryCheckboxDisplayed.isDisplayed && this.country.toLocaleLowerCase() !== this.isMandatoryCheckboxDisplayed.countryCode) {
871
- var _this$ncData9, _this$ncData10, _this$ncData11;
872
- const mrsField = (_this$ncData9 = this.ncData) !== null && _this$ncData9 !== void 0 && _this$ncData9.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].countryTransferText ? (_this$ncData10 = this.ncData) === null || _this$ncData10 === void 0 ? void 0 : _this$ncData10.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].countryTransferText.mrs_field : (_this$ncData11 = this.ncData) === null || _this$ncData11 === void 0 ? void 0 : _this$ncData11.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].chinaPIPLtext.mrs_field;
873
- this._onChange(mrsField, 'countyBasedCheckedNo');
874
- }
875
- return this.renderCombinedEmailPhoneSection();
977
+ `), prefix, c4dPrefix, this.countryBasedLegalNotice(), this.combinedPreTextTemplate(), hiddenInputs, prefix, prefix, this.postTextTemplate(), createHiddenInput('preventFormSubmission', String(this.preventFormSubmission)));
876
978
  }
877
979
  }, {
878
980
  kind: "field",
879
- key: "_getOptionByQuestion",
981
+ key: "pwsFieldsMap",
880
982
  value() {
881
- return question => {
882
- const questionChoiceStatus = this.country ? this.countrySettings[this.country.toLocaleLowerCase()] : {
883
- email: 'opt-in',
884
- phone: 'opt-in'
885
- };
886
- let option;
887
- switch (question) {
888
- case 'EMAIL':
889
- {
890
- option = {
891
- id: '0',
892
- checked: questionChoiceStatus.email === 'opt-out' ? true : false,
893
- optionTextPost: this.ncData.email,
894
- NC_HIDDEN_EMAIL: questionChoiceStatus.email === 'opt-out' ? 'OPT_OUT' : 'OPT_IN'
895
- };
896
- break;
897
- }
898
- case 'PHONE':
899
- {
900
- option = {
901
- id: '1',
902
- checked: questionChoiceStatus.phone === 'opt-out' ? true : false,
903
- optionTextPost: this.ncData.telephone,
904
- NC_HIDDEN_PHONE: questionChoiceStatus.phone === 'opt-out' ? 'OPT_OUT' : 'OPT_IN'
905
- };
906
- break;
907
- }
908
- default:
909
- {
910
- option = {
911
- id: '0',
912
- checked: questionChoiceStatus.email === 'opt-out' ? true : false,
913
- optionTextPost: this.ncData.email,
914
- NC_HIDDEN_EMAIL: questionChoiceStatus.email === 'opt-out' ? 'OPT_OUT' : 'OPT_IN'
915
- };
916
- break;
917
- }
918
- }
919
- return option;
920
- };
983
+ 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']]);
921
984
  }
922
985
  }, {
923
986
  kind: "method",
924
- key: "_buildCheckboxes",
925
- value: function _buildCheckboxes() {
926
- const fieldElements = {};
927
- const fieldCollections = {
928
- EMAIL: {
929
- id: 'EMAIL',
930
- labelText: this._getOptionByQuestion('EMAIL').optionTextPost
931
- },
932
- PHONE: {
933
- id: 'PHONE',
934
- labelText: this._getOptionByQuestion('PHONE').optionTextPost
935
- }
936
- };
937
- if (this.questionchoices) {
938
- // by email
939
- if (this.questionchoices.indexOf('1') > -1) {
940
- fieldElements.EMAIL = fieldCollections.EMAIL;
941
- }
942
- // by Phone
943
- if (this.questionchoices.indexOf('2') > -1) {
944
- fieldElements.PHONE = fieldCollections.PHONE;
945
- }
987
+ key: "dispatchCustomEvent",
988
+ value:
989
+ /**
990
+ * Dispatch field change event to parent form
991
+ */
992
+ function dispatchCustomEvent(eventName, field, value) {
993
+ try {
994
+ const eventDetail = {
995
+ bubbles: true,
996
+ detail: {
997
+ field,
998
+ value
999
+ }
1000
+ };
1001
+ this.dispatchEvent(new CustomEvent(eventName, eventDetail));
1002
+ } catch (error) {
1003
+ console.error(`[${eventName}] dispatch failed:`, error);
946
1004
  }
947
- return fieldElements;
948
1005
  }
949
1006
  }, {
950
1007
  kind: "method",
951
1008
  key: "_onChange",
952
1009
  value: function _onChange(field, value) {
953
- const pwsFieldsMap = {
954
- NC_HIDDEN_EMAIL: 'permission_email',
955
- NC_HIDDEN_PHONE: 'permission_phone',
956
- preventFormSubmission: 'preventFormSubmission',
957
- Q_CHINA_PIPL: 'Q_CHINA_PIPL',
958
- Q_COUNTRY_TRANSFER: 'Q_COUNTRY_TRANSFER',
959
- NC_HIDDEN_EMAIL_VALUE: 'NC_HIDDEN_EMAIL',
960
- NC_HIDDEN_PHONE_VALUE: 'NC_HIDDEN_PHONE',
961
- EMAIL_CU: 'EMAIL_CU',
962
- EMAIL_CC: 'EMAIL_CC',
963
- EMAIL_UC: 'EMAIL_UC',
964
- EMAIL_UU: 'EMAIL_UU',
965
- PHONE_CU: 'PHONE_CU',
966
- PHONE_CC: 'PHONE_CC',
967
- PHONE_UC: 'PHONE_UC',
968
- PHONE_UU: 'PHONE_UU',
969
- EMAIL_NOTICE_ONLY: 'EMAIL_NOTICE_ONLY',
970
- PHONE_NOTICE_ONLY: 'PHONE_NOTICE_ONLY',
971
- NC_HIDDEN_PHONE_NONE: 'NC_HIDDEN_PHONE_NONE'
972
- };
973
- if (Object.prototype.hasOwnProperty.call(pwsFieldsMap, field)) {
974
- field = pwsFieldsMap[field];
1010
+ var _this$pwsFieldsMap$ge, _this$pwsFieldsMap, _pwsValueMap;
1011
+ 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;
1012
+ const mappedValue = (_pwsValueMap = pwsValueMap === null || pwsValueMap === void 0 ? void 0 : pwsValueMap(value)) !== null && _pwsValueMap !== void 0 ? _pwsValueMap : value;
1013
+ this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-change`, mappedField, mappedValue);
1014
+ }
1015
+ }, {
1016
+ kind: "method",
1017
+ key: "_onEmailStatusChanged",
1018
+ value: function _onEmailStatusChanged(field, value) {
1019
+ this.dispatchCustomEvent(`${c4dPrefix}-notice-choice-email-status-changed`, field, value);
1020
+ }
1021
+ }, {
1022
+ kind: "method",
1023
+ key: "render",
1024
+ value: function render() {
1025
+ if (this.isLoading) {
1026
+ return html(_t13 || (_t13 = _`<div part="skeleton-notice-choice">
1027
+ <cds-skeleton-text
1028
+ linecount="3"
1029
+ width="100%"
1030
+ paragraph="true"></cds-skeleton-text>
1031
+ </div>`));
975
1032
  }
976
- const init = {
977
- bubbles: true,
978
- detail: {
979
- field,
980
- value: pwsValueMap(value)
981
- }
982
- };
983
- this.dispatchEvent(new CustomEvent(`${c4dPrefix}-notice-choice-change`, init));
1033
+ if (this.isMandatoryCheckboxDisplayed.isDisplayed && this.country.toLocaleLowerCase() !== this.isMandatoryCheckboxDisplayed.countryCode) {
1034
+ var _this$ncData6, _this$ncData7, _this$ncData8;
1035
+ const mrsField = (_this$ncData6 = this.ncData) !== null && _this$ncData6 !== void 0 && _this$ncData6.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].countryTransferText ? (_this$ncData7 = this.ncData) === null || _this$ncData7 === void 0 ? void 0 : _this$ncData7.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].countryTransferText.mrs_field : (_this$ncData8 = this.ncData) === null || _this$ncData8 === void 0 ? void 0 : _this$ncData8.mandatoryCheckbox[this.isMandatoryCheckboxDisplayed.countryCode].chinaPIPLtext.mrs_field;
1036
+ this._onChange(mrsField, 'countyBasedCheckedNo');
1037
+ }
1038
+ return this.renderCombinedEmailPhoneSection();
984
1039
  }
985
1040
  }]
986
1041
  };