@washingtonpost/subs-de-inputs 1.10.1 → 1.11.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.
package/dist/index.js CHANGED
@@ -1,8 +1,665 @@
1
+ import { DEFAULT_HEADERS, ENDPOINTS, ResponseStatus, WPGeo, getCookie, isLoggedIn, listenToCookieStore } from "@washingtonpost/subs-sdk";
2
+ import { useEffect, useState } from "react";
3
+ import { Icon, Select, styled, theme } from "@washingtonpost/wpds-ui-kit";
4
+ import { ScriptStatus, useScript, useWindowSize } from "@washingtonpost/subs-hooks";
5
+ import { ChevronDown } from "@washingtonpost/wpds-assets";
6
+ import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
7
+ //#region src/interfaces/index.ts
8
+ var CollectionBehaviors = {
9
+ COLLECT: "COLLECT",
10
+ DO_NOT_COLLECT: "DO_NOT_COLLECT"
11
+ };
12
+ var AttributesState = { SUCCESS: "100" };
13
+ var DeleteAttributeState = {
14
+ SUCCESS: "150",
15
+ SYSTEM_ERROR: "151",
16
+ INVALID_ATTRIBUTE_NAME: "152",
17
+ INVALID_ATTRIBUTE_NOT_EXISTS: "153"
18
+ };
19
+ var IngestType = {
20
+ EXPLICIT: "explicit",
21
+ IMPLICIT: "implicit"
22
+ };
23
+ var IngestResponseState = {
24
+ SUCCESS: "100",
25
+ SYSTEM_ERROR: "101",
26
+ INVALID_TYPE: "102",
27
+ INVALID_IDENTIFIER: "103",
28
+ INVALID_DATA: "104",
29
+ INVALID_ATTRIBUTE_DEFINITION: "105",
30
+ INVALID_META_DEFINITION: "106",
31
+ UNAUTHENTICATED: "107",
32
+ MISMATCHED_IDENTIFIER: "108",
33
+ DISABLED_ATTRIBUTE_DEFINITION: "109",
34
+ DO_NOT_COLLECT: "110"
35
+ };
36
+ //#endregion
37
+ //#region src/utils/checkConsentCookieForAllowTargeting.ts
38
+ var COOKIE$2 = "OptanonConsent";
39
+ /**
40
+ * Checks the users OptanonConsent cookie to determine if the user has allowed targeting.
41
+ * Returns true or false if the flag is found in the cookie, null otherwise.
42
+ * @returns {boolean | null}
43
+ */
44
+ var checkConsentCookieForAllowTargeting = () => {
45
+ const value = getCookie(COOKIE$2) || "";
46
+ return value.includes("C0004%3A1") ? true : value.includes("C0004%3A0") ? false : null;
47
+ };
48
+ //#endregion
49
+ //#region src/components/DEDisclosure/utils/checkAlertBoxClosedCookie.ts
50
+ var COOKIE$1 = "OptanonAlertBoxClosed";
51
+ var checkAlertBoxClosedCookie = () => {
52
+ return (getCookie(COOKIE$1) || "").length > 12;
53
+ };
54
+ //#endregion
55
+ //#region src/utils/hasRequiredPrivacyCookies.ts
56
+ /**
57
+ * Checks privacy cookies to decide if we can send up 1pd
58
+ * If US, checks that wp_usp exists
59
+ * Else If OptAnonConsent cookie exists, checks the value of targeting cookies consent
60
+ * Else If EEA, always returns true
61
+ * Else, returns false
62
+ * @returns {boolean}
63
+ */
64
+ var hasRequiredPrivacyCookies = () => {
65
+ if (typeof window === "undefined") return false;
66
+ const { intl_region, country_code: countryCode } = WPGeo();
67
+ if (countryCode === "US") return !!getCookie("wp_usp");
68
+ if (window.pageType === "onboarding") {
69
+ const gdprAllowTargarting = checkConsentCookieForAllowTargeting();
70
+ if (typeof gdprAllowTargarting === "boolean" && checkAlertBoxClosedCookie()) return gdprAllowTargarting;
71
+ if (intl_region === "EEA" && window.pageType === "onboarding") return true;
72
+ }
73
+ return false;
74
+ };
75
+ //#endregion
76
+ //#region src/services/getAttributes.ts
77
+ var base$1 = `${ENDPOINTS.base}/de/v1`;
78
+ var attributesCache = {};
79
+ var getAttributes = async ({ fieldName }) => {
80
+ if (attributesCache[fieldName]) return attributesCache[fieldName];
81
+ const fieldNames = [fieldName];
82
+ try {
83
+ const url = new URL(`${base$1}/attributes`);
84
+ url.searchParams.set("attributes", fieldNames.join(","));
85
+ const data = await fetch(url.toString(), {
86
+ credentials: "include",
87
+ headers: DEFAULT_HEADERS
88
+ });
89
+ const json = await data.json();
90
+ if (data.ok && json.status === ResponseStatus.SUCCESS) {
91
+ const attributes = json.attributes || [];
92
+ attributesCache[fieldName] = attributes;
93
+ return attributes;
94
+ }
95
+ return [];
96
+ } catch (e) {
97
+ console.debug(e);
98
+ return [];
99
+ }
100
+ };
101
+ //#endregion
102
+ //#region src/services/sendToGA.ts
103
+ var sendGAEvent = (props) => {
104
+ if (typeof window === "undefined") return;
105
+ window.dataLayer = window.dataLayer || [];
106
+ const eventData = { ...props };
107
+ window.dataLayer.push(eventData);
108
+ };
109
+ var sendToGA = async ({ submitData: { fieldName, value }, source }) => {
110
+ sendGAEvent({
111
+ event: "site-onpage-click",
112
+ action: "site-onpage-click",
113
+ category: "profile",
114
+ label: fieldName,
115
+ "de-label": fieldName,
116
+ [fieldName]: value,
117
+ section: "profile",
118
+ subsection: source
119
+ });
120
+ return true;
121
+ };
122
+ //#endregion
123
+ //#region src/services/ingest.ts
124
+ var base = `${ENDPOINTS.base}/de/v1`;
125
+ var ingest = async ({ submitData: { fieldName, value }, source }) => {
126
+ const url = `${base}/ingest`;
127
+ const wapo_login_id = getCookie("wapo_login_id");
128
+ const payload = {
129
+ jucid: localStorage.getItem("uuid"),
130
+ ga: getCookie("_ga"),
131
+ type: IngestType.EXPLICIT,
132
+ wapo_login_id,
133
+ data: { [fieldName]: [value] },
134
+ metadata: { source }
135
+ };
136
+ try {
137
+ return await (await fetch(url, {
138
+ method: "POST",
139
+ credentials: "include",
140
+ headers: DEFAULT_HEADERS,
141
+ body: JSON.stringify(payload)
142
+ })).json();
143
+ } catch (e) {
144
+ console.debug(e);
145
+ return null;
146
+ }
147
+ };
148
+ //#endregion
149
+ //#region src/utils/isAnonymousWebview.ts
150
+ var isAnonymousWebview = () => {
151
+ if (typeof window === "undefined") return false;
152
+ return !!(getCookie("wp_wv") && !isLoggedIn());
153
+ };
154
+ //#endregion
155
+ //#region src/utils/push.ts
156
+ var push = async ({ submitData, source }) => {
157
+ if (!hasRequiredPrivacyCookies()) throw new Error("does not satisfy cookie check");
158
+ if (isAnonymousWebview()) throw new Error("does not satisfy cookie check");
159
+ const { fieldName } = submitData;
160
+ const attributeInfo = await getAttributes({ fieldName });
161
+ if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) throw new Error("do not collect");
162
+ const type = attributeInfo[0] && attributeInfo[0].explicit === true ? IngestType.EXPLICIT : IngestType.IMPLICIT;
163
+ if (!attributeInfo[0] && false);
164
+ if (type === IngestType.EXPLICIT) return ingest({
165
+ submitData,
166
+ source
167
+ });
168
+ return sendToGA({
169
+ submitData,
170
+ source
171
+ });
172
+ };
173
+ //#endregion
174
+ //#region src/components/DESelect/Dropdown.tsx
175
+ var _jsxFileName$5 = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DESelect/Dropdown.tsx";
176
+ var StyledMobileSelect = styled("select", {
177
+ padding: "12px 16px 12px 6px",
178
+ display: "flex",
179
+ justifyContent: "space-between",
180
+ width: "100%",
181
+ backgroundColor: "$secondary",
182
+ color: "$primary",
183
+ fontFamily: "$meta",
184
+ fontSize: "$100",
185
+ fontWeight: "$light",
186
+ lineHeight: "$125",
187
+ paddingBlockRight: "$125",
188
+ textOverflow: "ellipsis",
189
+ position: "relative",
190
+ borderColor: "transparent",
191
+ borderRightWidth: "10px",
192
+ borderRightColor: "transparent",
193
+ appearance: "none",
194
+ "-webkit-appearance": "none",
195
+ "&:disabled": {
196
+ backgroundColor: theme.colors.disabled,
197
+ borderColor: theme.colors.disabled,
198
+ color: theme.colors.onDisabled,
199
+ cursor: "not-allowed"
200
+ }
201
+ });
202
+ var StyledSelectWrapper = styled("div", {
203
+ width: "100%",
204
+ maxWidth: "380px",
205
+ borderRadius: "$012",
206
+ borderColor: "$subtle",
207
+ borderStyle: "solid",
208
+ borderWidth: "1px",
209
+ backgroundColor: "$secondary",
210
+ position: "relative"
211
+ });
212
+ var StyledMobileOption = styled("option", {
213
+ fontFamily: "inherit",
214
+ fontSize: "inherit",
215
+ color: "inherit"
216
+ });
217
+ /**
218
+ * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.
219
+ * @param {IDropdownProps} props The props.
220
+ * @returns {React.ReactElement} The dropdown.
221
+ */
222
+ var Dropdown = ({ id, label, values, required = false, existingValue, onChange = () => {}, disabled = false, valueSelectedByDefault }) => {
223
+ const [answer, setAnswer] = useState();
224
+ const { isMobileSize } = useWindowSize();
225
+ useEffect(() => {
226
+ if (answer) onChange(answer);
227
+ }, [answer]);
228
+ const disabledProp = disabled ? { disabled: true } : {};
229
+ const presetDropdownValue = existingValue || valueSelectedByDefault;
230
+ const defaultValueProp = answer ? { defaultValue: answer } : presetDropdownValue ? { defaultValue: presetDropdownValue } : {};
231
+ const defaultValuePropMobile = (value) => {
232
+ if (answer) return value === answer ? { selected: true } : {};
233
+ return value === presetDropdownValue ? { selected: true } : {};
234
+ };
235
+ return isMobileSize ? /* @__PURE__ */ jsxDEV(StyledSelectWrapper, { children: [/* @__PURE__ */ jsxDEV(StyledMobileSelect, {
236
+ id: "",
237
+ required,
238
+ onChange: (e) => setAnswer(e.target.value),
239
+ ...disabledProp,
240
+ children: [
241
+ /* @__PURE__ */ jsxDEV("label", { children: label }, void 0, false, {
242
+ fileName: _jsxFileName$5,
243
+ lineNumber: 109,
244
+ columnNumber: 9
245
+ }, void 0),
246
+ /* @__PURE__ */ jsxDEV(StyledMobileOption, {
247
+ value: "",
248
+ disabled: true,
249
+ selected: true,
250
+ style: { color: "#666666" },
251
+ children: label
252
+ }, void 0, false, {
253
+ fileName: _jsxFileName$5,
254
+ lineNumber: 110,
255
+ columnNumber: 9
256
+ }, void 0),
257
+ values.map((value) => /* @__PURE__ */ jsxDEV(StyledMobileOption, {
258
+ value,
259
+ ...defaultValuePropMobile(value),
260
+ children: value
261
+ }, value, false, {
262
+ fileName: _jsxFileName$5,
263
+ lineNumber: 119,
264
+ columnNumber: 11
265
+ }, void 0))
266
+ ]
267
+ }, void 0, true, {
268
+ fileName: _jsxFileName$5,
269
+ lineNumber: 103,
270
+ columnNumber: 7
271
+ }, void 0), /* @__PURE__ */ jsxDEV(Icon, {
272
+ label: "",
273
+ size: "100",
274
+ fill: theme.colors.gray80,
275
+ style: {
276
+ pointerEvents: "none",
277
+ position: "absolute",
278
+ right: "10px",
279
+ top: "50%",
280
+ transform: "translateY(-50%)"
281
+ },
282
+ children: /* @__PURE__ */ jsxDEV(ChevronDown, { style: {
283
+ position: "absolute",
284
+ right: "10px"
285
+ } }, void 0, false, {
286
+ fileName: _jsxFileName$5,
287
+ lineNumber: 140,
288
+ columnNumber: 9
289
+ }, void 0)
290
+ }, void 0, false, {
291
+ fileName: _jsxFileName$5,
292
+ lineNumber: 128,
293
+ columnNumber: 7
294
+ }, void 0)] }, void 0, true, {
295
+ fileName: _jsxFileName$5,
296
+ lineNumber: 102,
297
+ columnNumber: 5
298
+ }, void 0) : /* @__PURE__ */ jsxDEV(Select.Root, {
299
+ onValueChange: (e) => setAnswer(e),
300
+ required,
301
+ ...defaultValueProp,
302
+ ...disabledProp,
303
+ children: [/* @__PURE__ */ jsxDEV(Select.Trigger, {
304
+ "data-test-id": `${id}-select-trigger`,
305
+ children: [/* @__PURE__ */ jsxDEV(Select.Label, { children: label }, void 0, false, {
306
+ fileName: _jsxFileName$5,
307
+ lineNumber: 151,
308
+ columnNumber: 9
309
+ }, void 0), /* @__PURE__ */ jsxDEV(Select.Value, {}, void 0, false, {
310
+ fileName: _jsxFileName$5,
311
+ lineNumber: 152,
312
+ columnNumber: 9
313
+ }, void 0)]
314
+ }, void 0, true, {
315
+ fileName: _jsxFileName$5,
316
+ lineNumber: 150,
317
+ columnNumber: 7
318
+ }, void 0), /* @__PURE__ */ jsxDEV(Select.Content, {
319
+ css: { zIndex: theme.zIndices.page },
320
+ "data-test-id": `${id}-select-content`,
321
+ children: values.map((value) => /* @__PURE__ */ jsxDEV(Select.Item, {
322
+ value,
323
+ children: value
324
+ }, value, false, {
325
+ fileName: _jsxFileName$5,
326
+ lineNumber: 159,
327
+ columnNumber: 11
328
+ }, void 0))
329
+ }, void 0, false, {
330
+ fileName: _jsxFileName$5,
331
+ lineNumber: 154,
332
+ columnNumber: 7
333
+ }, void 0)]
334
+ }, void 0, true, {
335
+ fileName: _jsxFileName$5,
336
+ lineNumber: 144,
337
+ columnNumber: 5
338
+ }, void 0);
339
+ };
340
+ //#endregion
341
+ //#region src/components/DESelect/index.tsx
342
+ var _jsxFileName$4 = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DESelect/index.tsx";
343
+ var scriptSrc = `${ENDPOINTS.base}/de-utils/twpdeu.min.js`;
344
+ var SelectWrapper = styled("div", {
345
+ boxSizing: "border-box",
346
+ display: "flex",
347
+ marginBottom: "$100",
348
+ flexDirection: "column",
349
+ "& button": { padding: "1px 6px" },
350
+ "& *": { boxSizing: "border-box" }
351
+ });
352
+ var DESelect = ({ source, fieldName, label, dataDictionaryConfig, existingValue, disabled, submit, onChange = () => {}, onFinished = () => {}, valuesFilter = () => true, children, valueSelectedByDefault }) => {
353
+ const [config, setConfig] = useState(dataDictionaryConfig);
354
+ const [selected, setSelected] = useState(!existingValue && valueSelectedByDefault ? valueSelectedByDefault : "");
355
+ const scriptStatus = useScript(scriptSrc);
356
+ useEffect(() => {
357
+ const fetchConfig = async () => {
358
+ try {
359
+ const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });
360
+ if (config) setConfig(config[0]);
361
+ else console.error("unable to get config", fieldName);
362
+ } catch (e) {
363
+ console.warn("unable to get config", fieldName, e);
364
+ }
365
+ };
366
+ if (scriptStatus === ScriptStatus.READY && !(children || config)) fetchConfig();
367
+ }, [scriptStatus]);
368
+ useEffect(() => {
369
+ const submitSelected = async () => {
370
+ try {
371
+ const result = await window?.__twpdeu?.push({
372
+ submitData: {
373
+ fieldName,
374
+ value: selected
375
+ },
376
+ source
377
+ });
378
+ onFinished({
379
+ isFinished: true,
380
+ isError: result === true ? false : result ? result.status !== ResponseStatus.SUCCESS : true
381
+ });
382
+ } catch (e) {
383
+ onFinished({
384
+ isFinished: false,
385
+ isError: true
386
+ });
387
+ }
388
+ };
389
+ if (scriptStatus === ScriptStatus.READY && submit && selected) submitSelected();
390
+ }, [scriptStatus, submit]);
391
+ const defaultValueProp = existingValue && config ? { defaultValue: existingValue } : {};
392
+ const disabledProp = disabled || !(children || config) ? { disabled: true } : {};
393
+ const values = config ? [...config.values].sort((a, b) => a.order - b.order).filter((value) => value.archived !== true).filter(valuesFilter) : [];
394
+ return /* @__PURE__ */ jsxDEV(SelectWrapper, { children: [
395
+ children && /* @__PURE__ */ jsxDEV(Select.Root, {
396
+ onValueChange: (e) => {
397
+ setSelected(e);
398
+ onChange({ value: e });
399
+ },
400
+ ...defaultValueProp,
401
+ ...disabledProp,
402
+ children
403
+ }, void 0, false, {
404
+ fileName: _jsxFileName$4,
405
+ lineNumber: 147,
406
+ columnNumber: 9
407
+ }, void 0),
408
+ !children && !config && /* @__PURE__ */ jsxDEV(Dropdown, {
409
+ id: "loading",
410
+ label: "Loading...",
411
+ values: [],
412
+ disabled: true
413
+ }, void 0, false, {
414
+ fileName: _jsxFileName$4,
415
+ lineNumber: 159,
416
+ columnNumber: 9
417
+ }, void 0),
418
+ !children && config && /* @__PURE__ */ jsxDEV(Dropdown, {
419
+ id: config.name,
420
+ label: label || config.name,
421
+ onChange: (e) => {
422
+ setSelected(e);
423
+ onChange({ value: e });
424
+ },
425
+ values: values.map((value) => value.name),
426
+ existingValue,
427
+ disabled,
428
+ valueSelectedByDefault
429
+ }, void 0, false, {
430
+ fileName: _jsxFileName$4,
431
+ lineNumber: 167,
432
+ columnNumber: 9
433
+ }, void 0)
434
+ ] }, void 0, true, {
435
+ fileName: _jsxFileName$4,
436
+ lineNumber: 145,
437
+ columnNumber: 5
438
+ }, void 0);
439
+ };
440
+ //#endregion
441
+ //#region src/components/DEDisclosure/utils/getConfig.ts
442
+ var configSrc = `${ENDPOINTS.base === "https://subscribe.washingtonpost.com" ? "https://www.washingtonpost.com/subscribe" : ENDPOINTS.base}/config/de/disclosure.json`;
443
+ var getConfig = async () => {
444
+ let myConfig;
445
+ const remoteConfig = await (await fetch(configSrc)).json();
446
+ const { country_code, intl_region } = WPGeo();
447
+ Object.keys(remoteConfig).forEach((configKey) => {
448
+ if (country_code && configKey.split("|").includes(country_code.toLowerCase())) myConfig = remoteConfig[configKey];
449
+ else if (intl_region === "EEA" && configKey === "eea") myConfig = remoteConfig[configKey];
450
+ });
451
+ if (typeof myConfig === "undefined" && remoteConfig._) myConfig = remoteConfig._;
452
+ return myConfig;
453
+ };
454
+ //#endregion
455
+ //#region src/components/DEDisclosure/utils/hydrateLinks.tsx
456
+ var _jsxFileName$3 = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DEDisclosure/utils/hydrateLinks.tsx";
457
+ var hydrateLinks = (str, onLinkClick = () => {}) => {
458
+ return str.split(/({{PRIVACY_POLICY}})/g).map((chunk, i) => {
459
+ if (chunk === "{{PRIVACY_POLICY}}") return /* @__PURE__ */ jsxDEV("a", {
460
+ rel: "noopener noreferrer",
461
+ target: "_blank",
462
+ style: { color: "inherit" },
463
+ className: "underline",
464
+ href: "https://www.washingtonpost.com/privacy-policy/",
465
+ onClick: (e) => onLinkClick(e),
466
+ children: "Privacy Policy"
467
+ }, `privacy-link-${i}`, false, {
468
+ fileName: _jsxFileName$3,
469
+ lineNumber: 13,
470
+ columnNumber: 9
471
+ }, void 0);
472
+ return chunk;
473
+ }).reduce((prev, current) => /* @__PURE__ */ jsxDEV(Fragment, { children: [prev, current] }, void 0, true), /* @__PURE__ */ jsxDEV(Fragment, {}, void 0, false));
474
+ };
475
+ //#endregion
476
+ //#region src/components/DEDisclosure/utils/checkOptAnonConsentCookie.ts
477
+ var COOKIE = "OptanonConsent";
478
+ var checkOptanonConsentCookie = () => {
479
+ return (getCookie(COOKIE) || "").length > 12;
480
+ };
481
+ //#endregion
482
+ //#region src/components/DEDisclosure/hooks/useOnetrust.ts
483
+ var CONSENT_COOKIE = "OptanonConsent";
484
+ var ALERT_BOX_COOKIE = "OptanonAlertBoxClosed";
485
+ var useOnetrust = ({ allowCookieStore }) => {
486
+ const [consentCookieExists, setConsentCookieExists] = useState();
487
+ const [alertBoxClosed, setAlertBoxClosed] = useState();
488
+ const [listenToCookieStore$1, setListenToCookieStore] = useState(false);
489
+ const [listenToTcfApi, setListenToTcfApi] = useState(false);
490
+ useEffect(() => {
491
+ if (checkOptanonConsentCookie()) setConsentCookieExists(true);
492
+ if (checkAlertBoxClosedCookie()) {
493
+ setAlertBoxClosed(true);
494
+ return;
495
+ }
496
+ if (!window.__tcfapi) console.warn("warning: __tcfapi not found");
497
+ if (window?.cookieStore && allowCookieStore) setListenToCookieStore(true);
498
+ else if (window.__tcfapi) setListenToTcfApi(true);
499
+ else console.warn("warning: neither cookieStore nor __tcfapi found");
500
+ }, []);
501
+ useEffect(() => {
502
+ const cleanupFns = [];
503
+ if (listenToCookieStore$1 && window.cookieStore) {
504
+ const cleanupFn = listenToCookieStore(CONSENT_COOKIE, () => {
505
+ if (checkOptanonConsentCookie()) setConsentCookieExists(true);
506
+ });
507
+ cleanupFns.push(cleanupFn);
508
+ const cleanupFn2 = listenToCookieStore(ALERT_BOX_COOKIE, () => {
509
+ if (checkAlertBoxClosedCookie()) setAlertBoxClosed(true);
510
+ else setAlertBoxClosed(false);
511
+ });
512
+ cleanupFns.push(cleanupFn2);
513
+ }
514
+ return () => {
515
+ cleanupFns.forEach((fn) => fn && fn());
516
+ };
517
+ }, [listenToCookieStore$1]);
518
+ useEffect(() => {
519
+ let listenerId;
520
+ if (listenToTcfApi && window.__tcfapi) {
521
+ const callback = (_tcData, success) => {
522
+ if (success) {
523
+ listenerId = _tcData.listenerId;
524
+ if (checkOptanonConsentCookie()) setConsentCookieExists(true);
525
+ if (checkAlertBoxClosedCookie()) setAlertBoxClosed(true);
526
+ }
527
+ };
528
+ window.__tcfapi("addEventListener", 2, callback);
529
+ }
530
+ return () => {
531
+ if (window.__tcfapi && listenerId) window.__tcfapi("removeEventListener", 2, (success) => {
532
+ console.debug(success);
533
+ }, listenerId);
534
+ };
535
+ }, [listenToTcfApi]);
536
+ return {
537
+ consentCookieExists,
538
+ alertBoxClosed,
539
+ listenToCookieStore: listenToCookieStore$1,
540
+ listenToTcfApi
541
+ };
542
+ };
543
+ //#endregion
544
+ //#region src/components/DEDisclosure/DisclosureWithBannerStatus.tsx
545
+ var _jsxFileName$2 = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DEDisclosure/DisclosureWithBannerStatus.tsx";
546
+ var DEDisclosureWithBannerStatus = ({ config, onFinished, allowCookieStore = true, onPrivacyPolicyClick = () => {} }) => {
547
+ const [disclosure, setDisclosure] = useState(null);
548
+ const [disclosureRendering, setDisclosureRendering] = useState(null);
549
+ const { alertBoxClosed, consentCookieExists } = useOnetrust({ allowCookieStore });
550
+ useEffect(() => {
551
+ if (config) if (alertBoxClosed) setDisclosure(config.disclosure_afterbanner);
552
+ else setDisclosure(config.disclosure_beforebanner);
553
+ }, [alertBoxClosed]);
554
+ useEffect(() => {
555
+ if (disclosure && Array.isArray(disclosure)) setDisclosureRendering(disclosure.reduce((prev, current) => /* @__PURE__ */ jsxDEV(Fragment, { children: [prev, /* @__PURE__ */ jsxDEV("p", { children: hydrateLinks(current, onPrivacyPolicyClick) }, void 0, false, {
556
+ fileName: _jsxFileName$2,
557
+ lineNumber: 55,
558
+ columnNumber: 15
559
+ }, void 0)] }, void 0, true), /* @__PURE__ */ jsxDEV(Fragment, {}, void 0, false)));
560
+ }, [disclosure]);
561
+ useEffect(() => {
562
+ if (disclosureRendering && consentCookieExists) onFinished({
563
+ isFinished: true,
564
+ isError: false
565
+ });
566
+ }, [disclosureRendering, consentCookieExists]);
567
+ return disclosureRendering;
568
+ };
569
+ //#endregion
570
+ //#region src/components/DEDisclosure/DisclosureWithoutBannerStatus.tsx
571
+ var _jsxFileName$1 = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DEDisclosure/DisclosureWithoutBannerStatus.tsx";
572
+ var DEDisclosureWithoutBannerStatus = ({ config, onFinished, onPrivacyPolicyClick = () => {} }) => {
573
+ const [disclosure, setDisclosure] = useState(null);
574
+ const [disclosureRendering, setDisclosureRendering] = useState(null);
575
+ useEffect(() => {
576
+ if (config) setDisclosure(config.disclosure);
577
+ }, [config]);
578
+ useEffect(() => {
579
+ if (disclosure && Array.isArray(disclosure)) setDisclosureRendering(disclosure.reduce((prev, current) => /* @__PURE__ */ jsxDEV(Fragment, { children: [prev, /* @__PURE__ */ jsxDEV("p", { children: hydrateLinks(current, onPrivacyPolicyClick) }, void 0, false, {
580
+ fileName: _jsxFileName$1,
581
+ lineNumber: 38,
582
+ columnNumber: 15
583
+ }, void 0)] }, void 0, true), /* @__PURE__ */ jsxDEV(Fragment, {}, void 0, false)));
584
+ }, [disclosure]);
585
+ useEffect(() => {
586
+ if (disclosureRendering) onFinished({
587
+ isFinished: true,
588
+ isError: false
589
+ });
590
+ }, [disclosureRendering]);
591
+ return disclosureRendering;
592
+ };
593
+ //#endregion
594
+ //#region src/components/DEDisclosure/index.tsx
595
+ var _jsxFileName = "/var/jenkins/workspace/Subs-FE-Components_production/packages/de-inputs/src/components/DEDisclosure/index.tsx";
596
+ var DEDisclosure = ({ onFinished = () => {}, allowCookieStore = true, onPrivacyPolicyClick = () => {} }) => {
597
+ const [disclosureRendering, setDisclosureRendering] = useState(null);
598
+ const [myConfig, setMyConfig] = useState();
599
+ useEffect(() => {
600
+ (async () => {
601
+ const config = await getConfig();
602
+ setMyConfig(config);
603
+ if (!config) console.error("No config found");
604
+ })();
605
+ }, []);
606
+ useEffect(() => {
607
+ if (myConfig) if ("checkBannerStatus" in myConfig && myConfig.checkBannerStatus) setDisclosureRendering(/* @__PURE__ */ jsxDEV(DEDisclosureWithBannerStatus, {
608
+ config: myConfig,
609
+ allowCookieStore,
610
+ onFinished,
611
+ onPrivacyPolicyClick
612
+ }, void 0, false, {
613
+ fileName: _jsxFileName,
614
+ lineNumber: 55,
615
+ columnNumber: 11
616
+ }, void 0));
617
+ else if ("disclosure" in myConfig) setDisclosureRendering(/* @__PURE__ */ jsxDEV(DEDisclosureWithoutBannerStatus, {
618
+ config: myConfig,
619
+ onFinished,
620
+ onPrivacyPolicyClick
621
+ }, void 0, false, {
622
+ fileName: _jsxFileName,
623
+ lineNumber: 64,
624
+ columnNumber: 11
625
+ }, void 0));
626
+ else console.error("Invalid config");
627
+ }, [myConfig]);
628
+ if (disclosureRendering) return /* @__PURE__ */ jsxDEV("div", {
629
+ "data-test-id": "de-disclosure",
630
+ children: disclosureRendering
631
+ }, void 0, false, {
632
+ fileName: _jsxFileName,
633
+ lineNumber: 77,
634
+ columnNumber: 12
635
+ }, void 0);
636
+ return /* @__PURE__ */ jsxDEV("div", { "data-test-id": "de-disclosure-loading" }, void 0, false, {
637
+ fileName: _jsxFileName,
638
+ lineNumber: 80,
639
+ columnNumber: 10
640
+ }, void 0);
641
+ };
642
+ //#endregion
643
+ //#region src/constants/IngestDataTypes.ts
644
+ var FirstPartyIngestDataTypes = {
645
+ JOB_LEVEL: "profile_job_level",
646
+ JOB_INDUSTRY: "profile_job_industry",
647
+ JOB_TITLE: "profile_job_title",
648
+ PERSONAL_GOALS: "personal_goals",
649
+ HOBBIES: "hobbies",
650
+ PROFESSIONAL_GOALS: "professional_goals",
651
+ INDUSTRY: "industry",
652
+ NEWS_LOCATION: "news_location",
653
+ NY_PERSONAL_GOALS: "new_year_personal_goals",
654
+ NY_HOBBIES: "new_year_hobbies",
655
+ NY_PROFESSIONAL_GOALS: "new_year_professional_goals",
656
+ NY_INDUSTRY: "new_year_industry",
657
+ NY_NEWS_LOCATION: "new_year_news_location",
658
+ EDU_ROLE: "profile_edu_role",
659
+ EDU_MAJOR: "profile_edu_major",
660
+ EDU_GRADUATION_YEAR: "profile_edu_graduation_year"
661
+ };
662
+ //#endregion
663
+ export { AttributesState, CollectionBehaviors, DEDisclosure, DESelect, DeleteAttributeState, FirstPartyIngestDataTypes, IngestResponseState, IngestType, getAttributes, hasRequiredPrivacyCookies, push };
1
664
 
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./subs-de-inputs.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./subs-de-inputs.cjs.development.js')
8
- }
665
+ //# sourceMappingURL=index.js.map