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